:root {
  --bg: #0a0e17;
  --panel: #111827;
  --panel-soft: #1a2234;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --primary: #10b981;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #f85149;
  --border: rgba(255, 255, 255, 0.08);
  --field-bg: #0f1625;
  --field-text: #e5e7eb;
  --field-placeholder: #7c8797;
  --code-bg: #0f1625;
  --brand-900: #0a0e17;
  --brand-800: #111827;
  --brand-700: #1a2234;
  --sidebar-bg: #0f172a;
  --sidebar-text: #e5e7eb;
  --sidebar-muted: #9ca3af;
  --sidebar-item-bg: rgba(255, 255, 255, 0.08);
  --sidebar-item-hover: rgba(255, 255, 255, 0.14);
  --sidebar-item-active: #10b981;
}

body.theme-light {
  --bg: #f7faf9;
  --panel: #ffffff;
  --panel-soft: #ecfdf5;
  --text: #0f172a;
  --muted: #475569;
  --primary: #10b981;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #b91c1c;
  --border: #d1d5db;
  --field-bg: #ffffff;
  --field-text: #0f172a;
  --field-placeholder: #64748b;
  --code-bg: #f0fdf4;
  --brand-900: #d1fae5;
  --brand-800: #a7f3d0;
  --brand-700: #6ee7b7;
  --sidebar-bg: #ecfdf5;
  --sidebar-text: #064e3b;
  --sidebar-muted: #047857;
  --sidebar-item-bg: #d1fae5;
  --sidebar-item-hover: #a7f3d0;
  --sidebar-item-active: #10b981;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.center-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 420px;
}

.title {
  margin: 0 0 14px;
  font-size: 22px;
}

.brand-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1d4ed8, #60a5fa);
  color: #fff;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 30px;
}

.muted {
  color: var(--muted);
  margin: 0 0 18px;
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

input,
select,
button {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--field-bg);
  color: var(--field-text);
  padding: 10px 12px;
}

input::placeholder {
  color: var(--field-placeholder);
}

input,
select {
  margin-bottom: 12px;
}

.password-wrap {
  position: relative;
  margin-bottom: 12px;
}

.password-wrap input {
  margin-bottom: 0;
  padding-right: 44px;
}

.toggle-pass {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.date-wrap {
  position: relative;
  margin-bottom: 12px;
}

.date-wrap input[type='text'] {
  margin-bottom: 0;
  padding-right: 44px;
}

.native-date-picker {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  margin: 0;
  padding: 0;
  border: 0;
}

.date-popover {
  position: fixed;
  z-index: 2000;
  width: 260px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
}

.date-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.date-head strong {
  font-size: 13px;
  text-transform: capitalize;
}

.date-week,
.date-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.date-week span {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}

.date-empty {
  display: block;
  height: 28px;
}

.date-day {
  width: 100%;
  height: 28px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  font-size: 12px;
  padding: 0;
}

.date-day:hover {
  background: color-mix(in srgb, var(--primary) 18%, transparent);
}

.date-day.is-selected {
  background: var(--primary);
  color: #fff;
}

button {
  background: var(--primary);
  border: none;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
}

button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.error {
  margin-top: 12px;
  color: var(--danger);
  font-size: 13px;
}

.ok-text {
  margin-top: 12px;
  color: #7ee787;
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, var(--sidebar-bg), color-mix(in srgb, var(--sidebar-bg) 70%, #ffffff));
  padding: 16px;
  color: var(--sidebar-text);
}

.brand {
  font-size: 20px;
  margin: 0 0 4px;
  color: var(--sidebar-text);
}

.user {
  color: var(--sidebar-muted);
  font-size: 13px;
  margin-bottom: 16px;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu button {
  text-align: left;
  background: var(--sidebar-item-bg);
  color: var(--sidebar-text);
  border: 1px solid color-mix(in srgb, var(--sidebar-text) 14%, transparent);
}

.menu button.active {
  background: var(--sidebar-item-active);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.menu button:hover {
  background: var(--sidebar-item-hover);
}

body.theme-light .sidebar {
  border-right: 1px solid #a7f3d0;
}

.main {
  padding: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.topbar h2 {
  margin: 0;
}

.topbar .actions {
  display: flex;
  gap: 10px;
}

.topbar .actions button {
  width: auto;
  padding: 8px 12px;
  border-radius: 10px;
}

.ghost {
  background: transparent !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
}

.btn-xs {
  width: auto;
  padding: 6px 10px;
  font-size: 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  position: relative;
  overflow: hidden;
}

.metric .k {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.metric .v {
  margin-top: 6px;
  font-size: 24px;
  font-weight: 700;
}

.metric::after {
  content: '';
  position: absolute;
  right: -24px;
  top: -24px;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 18%, transparent);
}

.block {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.block h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.toolbar input,
.toolbar select {
  width: auto;
  min-width: 180px;
  margin: 0;
}

.toolbar button {
  width: auto;
  padding: 8px 12px;
}

pre {
  white-space: pre-wrap;
  background: var(--code-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  max-height: 460px;
  overflow: auto;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal {
  width: min(760px, 92vw);
  max-height: 88vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-head h3 {
  margin: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel-soft);
  color: var(--text);
}

.badge {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.ok {
  background: color-mix(in srgb, var(--ok) 30%, transparent);
}

.warn {
  background: color-mix(in srgb, var(--warn) 28%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 55%, transparent);
}

.danger {
  background: color-mix(in srgb, var(--danger) 28%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 55%, transparent);
}

.ok {
  border: 1px solid color-mix(in srgb, var(--ok) 55%, transparent);
}

.table-wrap {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.b2b-master {
  background: color-mix(in srgb, var(--panel) 90%, #000 10%);
}

.b2b-master-shell {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand-900) 62%, transparent), color-mix(in srgb, var(--panel) 96%, #000 4%));
  padding: 12px;
}

.b2b-master-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.b2b-master-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.b2b-master-user {
  font-size: 13px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
}

.b2b-master-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.b2b-master-toolbar input,
.b2b-master-toolbar select {
  width: auto;
  min-width: 210px;
  margin: 0;
}

.b2b-master-toolbar button {
  width: auto;
  min-width: 120px;
  padding: 8px 14px;
  border-radius: 10px;
}

.b2b-master-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

.plan-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 12px;
  border: 1px solid color-mix(in srgb, var(--primary) 45%, transparent);
  background: color-mix(in srgb, var(--primary) 24%, transparent);
}

.plan-badge-premium {
  border-color: color-mix(in srgb, #93c5fd 70%, transparent);
  background: color-mix(in srgb, #93c5fd 28%, transparent);
}

.state-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.state-badge-ok {
  color: #d1fae5;
  background: color-mix(in srgb, var(--ok) 34%, transparent);
  border-color: color-mix(in srgb, var(--ok) 60%, transparent);
}

.state-badge-danger {
  color: #fecaca;
  background: color-mix(in srgb, var(--danger) 28%, transparent);
  border-color: color-mix(in srgb, var(--danger) 60%, transparent);
}

.state-badge-warn {
  color: #fef3c7;
  background: color-mix(in srgb, var(--warn) 34%, transparent);
  border-color: color-mix(in srgb, var(--warn) 60%, transparent);
}

.b2b-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.b2b-actions .btn-xs {
  border-radius: 999px;
}

.kpi-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 30%, transparent);
  font-size: 11px;
}

.global-config-hero {
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand-900) 55%, transparent), transparent 35%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.global-config-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.global-config-toolbar input {
  margin: 0;
  min-width: 320px;
  height: 38px;
}

.global-config-toolbar button {
  width: auto;
  white-space: nowrap;
}

.global-config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.gc-card {
  background: color-mix(in srgb, var(--panel) 86%, var(--brand-900) 14%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.gc-card h3 {
  margin: 0 0 10px;
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.gc-card p {
  margin: 10px 0;
  color: var(--muted);
  line-height: 1.35;
  font-size: 20px;
}

.gc-card p strong {
  color: var(--text);
  margin-right: 6px;
}

.gc-chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 14px;
  line-height: 1;
  font-weight: 600;
  color: #dbeafe;
  background: color-mix(in srgb, var(--primary) 45%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 70%, transparent);
}

.gc-chip-ok {
  color: #d1fae5;
  background: color-mix(in srgb, var(--ok) 42%, transparent);
  border-color: color-mix(in srgb, var(--ok) 70%, transparent);
}

.gc-chip-warn {
  color: #fef3c7;
  background: color-mix(in srgb, var(--warn) 42%, transparent);
  border-color: color-mix(in srgb, var(--warn) 70%, transparent);
}

body.theme-light .global-config-hero {
  background: linear-gradient(180deg, #dbeafe, #f7fbff 45%);
}

body.theme-light .gc-card {
  background: #ffffff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.12);
}

body.theme-light .gc-card h3 {
  color: #142850;
}

body.theme-light .gc-card p {
  color: #334155;
}

body.theme-light .gc-chip {
  color: #1e3a8a;
  background: #dbeafe;
  border-color: #bfdbfe;
}

body.theme-light .gc-chip-ok {
  color: #166534;
  background: #dcfce7;
  border-color: #86efac;
}

body.theme-light .gc-chip-warn {
  color: #92400e;
  background: #fef3c7;
  border-color: #fcd34d;
}

/* Panel super admin — configuración global */
.global-config-super {
  padding: 16px;
}

.global-config-top {
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px;
}

.gc-head-text {
  flex: 1;
  min-width: 220px;
}

.gc-page-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.gc-page-date {
  margin-top: 6px;
  font-size: 0.9rem;
  text-transform: capitalize;
}

.gc-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.gc-toolbar-actions input[type='search'] {
  margin: 0;
  min-width: 200px;
  height: 38px;
  border-radius: 10px;
}

.gc-profile-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  font-size: 0.85rem;
}

.gc-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
}

.btn-gc-save {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0 18px;
  height: 38px;
  font-weight: 600;
  cursor: pointer;
}

.btn-gc-save:hover {
  filter: brightness(1.08);
}

.btn-gc-save:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.gc-super-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.gc-card .gc-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 14px;
  line-height: 1.25;
  letter-spacing: 0;
  color: var(--text);
}

.gc-metrics-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.gc-metric {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  position: relative;
  overflow: hidden;
}

.gc-metric-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gc-metric-value {
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 4px;
}

.gc-spark {
  height: 28px;
  margin-top: 8px;
  border-radius: 4px;
  opacity: 0.85;
}

.gc-spark-blue {
  background: linear-gradient(90deg, transparent, #3b82f6 40%, #60a5fa 100%);
}

.gc-spark-mix {
  background: linear-gradient(90deg, transparent, #f97316 35%, #3b82f6 100%);
}

.gc-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gc-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.gc-toggle-row-pad {
  margin-top: 8px;
}

.gc-toggle-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.88rem;
  line-height: 1.3;
}

.gc-toggle-sub {
  display: block;
  font-weight: 400;
  font-size: 0.78rem;
}

.gc-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.gc-toggle input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 2;
}

.gc-toggle-ui {
  position: absolute;
  inset: 0;
  background: #374151;
  border-radius: 999px;
  pointer-events: none;
  transition: background 0.2s;
}

.gc-toggle-ui::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.gc-toggle input:checked + .gc-toggle-ui {
  background: #2563eb;
}

.gc-toggle input:checked + .gc-toggle-ui::after {
  transform: translateX(20px);
}

.gc-toggle-warn input:checked + .gc-toggle-ui {
  background: #ea580c;
}

.gc-toggle-ok input:checked + .gc-toggle-ui {
  background: #22c55e;
}

.gc-field {
  margin-bottom: 14px;
}

.gc-field label,
.gc-field-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.gc-field select {
  width: 100%;
  margin: 0;
}

.gc-countries {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gc-chip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--field-bg);
  font-size: 0.85rem;
  cursor: pointer;
}

.gc-chip-toggle input {
  margin: 0;
}

.gc-plan-status {
  font-size: 0.8rem;
  margin: 8px 0 12px;
}

.gc-btn-block {
  width: 100%;
  margin-top: 4px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.gc-btn-block:hover {
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
}

.gc-btn-download {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.gc-btn-download:hover {
  filter: brightness(1.06);
}

.gc-api-status {
  margin-top: 12px;
  font-size: 0.85rem;
  font-weight: 600;
}

.gc-api-ok {
  color: #22c55e;
}

.gc-api-warn {
  color: #f59e0b;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .gc-super-grid {
    grid-template-columns: 1fr;
  }

  .gc-metrics-row {
    grid-template-columns: 1fr;
  }
}

/* Facturación (panel estilo FLOTIX SPA) */
.billing-shell {
  background: #121212;
  color: #f3f4f6;
  border-radius: 16px;
  padding: 22px 24px 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.billing-brand {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #9ca3af;
  font-weight: 600;
  margin-bottom: 6px;
}

.billing-head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.billing-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.billing-export-btns {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.bill-btn-outline {
  background: transparent;
  color: #f9fafb;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.bill-btn-outline:hover {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.billing-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 22px 0 18px;
}

.billing-kpi {
  background: #1e1e1e;
  border-radius: 12px;
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.billing-kpi-label {
  font-size: 0.78rem;
  color: #9ca3af;
  margin-bottom: 8px;
}

.billing-kpi-value {
  font-size: 1.25rem;
  font-weight: 700;
}

.billing-kpi-danger {
  color: #f87171;
}

.billing-toolbar {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}

.billing-toolbar input,
.billing-toolbar select,
.billing-toolbar button {
  margin: 0 !important;
  width: auto !important;
  flex: 0 0 auto;
  min-width: 0;
  box-sizing: border-box;
}

.billing-toolbar select {
  min-width: 148px;
}

.billing-toolbar input[data-filter-key='search'] {
  flex: 1 1 220px;
  min-width: 200px;
  max-width: 380px;
}

.billing-toolbar > button#btnApplyFilter {
  white-space: nowrap;
  min-width: 104px;
}

.billing-table-wrap {
  background: #1a1a1a;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: auto;
}

.billing-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.billing-table th {
  text-align: left;
  padding: 12px 14px;
  color: #9ca3af;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.billing-table td {
  padding: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: middle;
}

.billing-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.bill-amount {
  font-weight: 600;
  white-space: nowrap;
}

.bill-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.bill-pill-ok {
  background: rgba(34, 197, 94, 0.18);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.bill-pill-warn {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.bill-pill-danger {
  background: rgba(248, 113, 113, 0.12);
  color: #fca5a5;
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.bill-pill-info {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.bill-pay-text {
  color: #e5e7eb;
  font-weight: 500;
}

.billing-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
  font-size: 0.85rem;
  color: #9ca3af;
}

body.theme-light .billing-shell {
  background: #ffffff;
  color: #0f172a;
  border-color: #e2e8f0;
}

body.theme-light .billing-kpi {
  background: #f8fafc;
  border-color: #e2e8f0;
}

body.theme-light .billing-table-wrap {
  background: #f8fafc;
  border-color: #e2e8f0;
}

body.theme-light .billing-table th {
  color: #64748b;
  border-bottom-color: #e2e8f0;
}

body.theme-light .billing-table td {
  border-bottom-color: #e2e8f0;
}

body.theme-light .bill-btn-outline {
  color: #0f172a;
  border-color: #94a3b8;
}

body.theme-light .bill-btn-outline:hover {
  background: #f1f5f9;
}

@media print {
  .sidebar,
  .topbar,
  .billing-no-print,
  #notif {
    display: none !important;
  }

  .layout {
    display: block !important;
  }

  .main {
    padding: 0 !important;
  }

  .billing-shell {
    border: none;
    border-radius: 0;
    background: #fff !important;
    color: #111 !important;
  }

  .billing-kpi {
    background: #f4f4f5 !important;
    border: 1px solid #ddd !important;
  }

  .billing-table-wrap {
    background: #fff !important;
    border: 1px solid #ddd !important;
  }

  .bill-pill-ok {
    background: #dcfce7 !important;
    color: #166534 !important;
    border-color: #86efac !important;
  }

  .bill-pill-warn {
    background: #fef3c7 !important;
    color: #92400e !important;
  }

  .bill-pill-danger {
    background: #fee2e2 !important;
    color: #991b1b !important;
  }

  .bill-pill-info {
    background: #dbeafe !important;
    color: #1e40af !important;
  }
}

@media (max-width: 768px) {
  .billing-kpis {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 12px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar .actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }

  .topbar .actions button {
    flex: 1 1 calc(50% - 8px);
    min-width: 120px;
  }

  .billing-shell {
    padding: 14px 12px;
  }

  .billing-toolbar {
    flex-direction: column;
    flex-wrap: wrap;
    align-items: stretch;
    overflow-x: visible;
  }

  .billing-toolbar input,
  .billing-toolbar select,
  .billing-toolbar button {
    width: 100% !important;
    max-width: none;
    flex: none;
    min-width: 0 !important;
  }

  .billing-toolbar input[data-filter-key='search'] {
    max-width: none;
  }

  .billing-table th,
  .billing-table td {
    white-space: nowrap;
  }
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 220px 1fr;
  }

  .sidebar {
    padding: 12px;
  }

  .menu button {
    font-size: 13px;
    padding: 9px 10px;
  }
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .menu {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 8px;
  }

  .b2b-master-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .b2b-master-toolbar input,
  .b2b-master-toolbar select,
  .b2b-master-toolbar button,
  .toolbar input,
  .toolbar select,
  .toolbar button {
    width: 100%;
    min-width: 0;
  }
}
