@import url("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Outfit:wght@100..900&family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap");

/* ─────────────────────────────────────────────
   1. DESIGN TOKENS  (Low-contrast dark palette)
   Base: https://coolors.co/1e293b-334155-f8fafc-94a3b8-38bdf8
   Tuned down for reduced eye strain.
────────────────────────────────────────────── */
:root {
  /* Palette — Low-contrast variant */
  --color-bg:      #1e293b;
  --color-surface: #283548;
  --color-border:  #3b4a5e;
  --color-text:    #cbd5e1;
  --color-muted:   #7e8fa3;
  --color-accent:  #7dd3fc;

  /* Semantic Aliases */
  --bg:       var(--color-bg);
  --fg:       var(--color-text);
  --border:   var(--color-border);
  --accent:   var(--color-accent);

  /* Status Colors (muted variants) */
  --color-success: #6ee7a0;
  --color-warning: #fcd462;
  --color-danger:  #fca5a5;
  --color-info:    #7dd3fc;

  /* Typography */
  --font-sans: "Inter", system-ui, sans-serif;
  --font-display: "Outfit", sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  /* Spacing & Shape */
  --radius:     6px;
  --radius-lg:  10px;
  --sidebar-w:  260px;
}

/* ─────────────────────────────────────────────
   2. RESET
────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

/* ─────────────────────────────────────────────
   3. LAYOUT — app-shell / sidebar / main
────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background-color: var(--bg);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.25s ease;
}

.sidebar__header { padding: 28px 20px; border-bottom: 1px solid var(--border); }

.sidebar__brand {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: var(--fg);
}

.sidebar__logo {
  width: 28px; height: 28px;
  color: var(--accent);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

.sidebar__title {
  font-family: var(--font-display);
  font-weight: 700; font-size: 16px; line-height: 1.2;
  display: flex; flex-direction: column;
}

.sidebar__subtitle {
  font-size: 10px; font-weight: 400;
  color: var(--color-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}

.sidebar__nav {
  padding: 12px; display: flex; flex-direction: column;
  gap: 2px; flex: 1; overflow-y: auto;
}

.sidebar__link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  font-size: 13px; font-weight: 500;
  color: var(--color-muted);
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.sidebar__link:hover { background-color: var(--color-surface); color: var(--fg); }
.sidebar__link.active { background-color: var(--color-surface); color: var(--accent); }
.sidebar__icon {
  width: 18px; height: 18px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

.sidebar__footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

.sidebar__user-card {
  padding: 10px 12px;
  background-color: var(--color-surface);
  border-radius: var(--radius);
  margin-bottom: 10px;
  display: flex; flex-direction: column; gap: 3px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  border: 1px solid transparent;
  text-decoration: none;
}
.sidebar__user-card:hover { background-color: rgba(255, 255, 255, 0.06); border-color: var(--border); }
.sidebar__user-card--active { border-color: var(--accent); background-color: rgba(125, 211, 252, 0.06); }

.sidebar__logout {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  font-size: 13px; font-weight: 500;
  color: var(--color-danger);
  border-radius: var(--radius);
  transition: background 0.15s;
  cursor: pointer;
  text-decoration: none;
}
.sidebar__logout:hover { background-color: rgba(252, 165, 165, 0.08); }

.sidebar__user-label {
  font-size: 10px; text-transform: uppercase;
  color: var(--color-muted); font-weight: 700; letter-spacing: 0.05em;
}

.sidebar__user-name {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--fg);
}

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content__scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  padding: 40px 40px;
}

/* ── Status Footer ───────────────────────── */
.status-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 8px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 11px;
  color: var(--color-muted);
  min-height: 36px;
}
.status-footer__item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.status-footer__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.status-footer__dot--ok     { background: var(--color-success); }
.status-footer__dot--warn   { background: var(--color-warning); }
.status-footer__dot--error  { background: var(--color-error); }


/* ─────────────────────────────────────────────
   4. PAGE HEADER — .page-header
────────────────────────────────────────────── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 32px; gap: 16px; }
.page-header__text { display: flex; flex-direction: column; gap: 4px; }
.page-header__title,
.page-title { font-family: var(--font-display); font-size: 22px; font-weight: 700; line-height: 1.2; }
.page-header__subtitle,
.page-subtitle { font-size: 13px; color: var(--color-muted); margin-top: 3px; }
.page-header__actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* Legacy alias */
.dash-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 32px; gap: 16px; }
.dash-header__title { font-family: var(--font-display); font-size: 22px; font-weight: 700; }
.dash-header__subtitle { font-size: 13px; color: var(--color-muted); margin-top: 4px; }
.dash-header__actions { display: flex; gap: 8px; align-items: center; }

/* ─────────────────────────────────────────────
   5. CARD — .card
────────────────────────────────────────────── */
.card {
  background-color: var(--color-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card__header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.card__heading { display: flex; flex-direction: column; gap: 4px; }
.card__title { font-family: var(--font-display); font-size: 15px; font-weight: 700; line-height: 1.2; }
.card__description { font-size: 12px; color: var(--color-muted); line-height: 1.5; }

.card__content { padding: 24px; flex: 1; }
.card__footer { padding: 16px 24px; border-top: 1px solid var(--border); }

/* Alias for older templates */
.card-header  { padding: 20px 24px; border-bottom: 1px solid var(--border); }
.card-title   { font-family: var(--font-display); font-size: 15px; font-weight: 700; }
.card-description { font-size: 12px; color: var(--color-muted); margin-top: 3px; }
.card-content { padding: 24px; }

/* ─────────────────────────────────────────────
   6. TABLE — .table / .table-wrapper
────────────────────────────────────────────── */
.table-wrapper, .table-responsive {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table__th {
  height: 38px;
  padding: 0 16px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background-color: rgba(255, 255, 255, 0.02);
  white-space: nowrap;
}

.table td,
.table__td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover { background-color: rgba(255, 255, 255, 0.02); }

/* Table Cell Modifiers */
.table__cell--right,
.table__th--right { text-align: right; }
.table__cell--center,
.table__th--center { text-align: center; }
.table__cell--mono { font-family: var(--font-mono); font-size: 12px; color: var(--color-muted); }
.table__cell--muted { color: var(--color-muted); }
.table__cell--tabular { font-variant-numeric: tabular-nums; }
.table__cell--nowrap { white-space: nowrap; }
.table__cell--bold { font-weight: 600; }
.table__cell--amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-family: var(--font-mono); }
.table__cell--positive { color: var(--color-success) !important; }
.table__cell--negative { color: var(--color-danger) !important; }
.table__cell--empty { text-align: center; color: var(--color-muted); padding: 2.5rem 1rem !important; font-size: 13px; }
.table__cell--actions { text-align: right; white-space: nowrap; }

/* ─── data-table aliases (Carriers, Portability, Sync) ─── */
.data-table-wrapper {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
  height: 38px; padding: 0 16px;
  text-align: left; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--color-muted); font-weight: 600;
  border-bottom: 1px solid var(--border);
  background-color: rgba(255, 255, 255, 0.02);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px; font-size: 13px;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background-color: rgba(255, 255, 255, 0.02); }
.data-table__th--right { text-align: right; }
.data-table__td--right { text-align: right; }

/* ─────────────────────────────────────────────
   7. BUTTON — .btn
────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background-color: var(--color-surface);
  color: var(--fg);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-decoration: none; white-space: nowrap;
}

.btn:hover { background-color: rgba(255, 255, 255, 0.07); border-color: var(--color-muted); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary { background-color: var(--accent); color: var(--color-bg); border-color: var(--accent); }
.btn--primary:hover { background-color: #7dd3fc; border-color: #7dd3fc; }

.btn--danger { background-color: transparent; color: var(--color-danger); border-color: rgba(248, 113, 113, 0.4); }
.btn--danger:hover { background-color: rgba(248, 113, 113, 0.08); }

.btn--success { background-color: transparent; color: var(--color-success); border-color: rgba(74, 222, 128, 0.4); }
.btn--success:hover { background-color: rgba(74, 222, 128, 0.08); }

.btn--ghost { background-color: transparent; border-color: transparent; }
.btn--ghost:hover { background-color: var(--color-surface); border-color: var(--border); }

.btn--outline { background-color: transparent; border-color: var(--border); }
.btn--outline:hover { background-color: rgba(255, 255, 255, 0.05); }

/* Sizes */
.btn--sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn--lg { height: 42px; padding: 0 20px; font-size: 15px; }

/* Width */
.btn.w-full { width: 100%; }

/* ─────────────────────────────────────────────
   8. BADGE — .badge
────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  color: var(--color-muted);
  background-color: rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}

/* Semantic variants */
.badge--success,
.badge--green {
  color: var(--color-success);
  border-color: rgba(74, 222, 128, 0.3);
  background: rgba(74, 222, 128, 0.06);
}

.badge--warning,
.badge--orange {
  color: var(--color-warning);
  border-color: rgba(251, 191, 36, 0.3);
  background: rgba(251, 191, 36, 0.06);
}

.badge--error,
.badge--red {
  color: var(--color-danger);
  border-color: rgba(248, 113, 113, 0.3);
  background: rgba(248, 113, 113, 0.06);
}

.badge--info,
.badge--blue {
  color: var(--color-info);
  border-color: rgba(56, 189, 248, 0.3);
  background: rgba(56, 189, 248, 0.06);
}

.badge--muted {
  color: var(--color-muted);
  border-color: var(--border);
  background: transparent;
}

/* ─────────────────────────────────────────────
   9. FORM CONTROLS — .input / .select / .label
────────────────────────────────────────────── */
.input,
.select {
  display: block;
  width: 100%;
  height: 36px;
  padding: 0 12px;
  background-color: var(--color-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.input::placeholder { color: var(--color-muted); }
.input:disabled { opacity: 0.5; cursor: not-allowed; }

/* Select arrow */
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label {
  font-size: 12px; font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.field__hint { font-size: 11px; color: var(--color-muted); }

/* ─────────────────────────────────────────────
   10. FORM LAYOUTS — .form-row / .form-grid / .form-stack
────────────────────────────────────────────── */
.form-row {
  display: flex; gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.form-row .field { flex: 1; min-width: 120px; }
.form-row .field--sm,
.form-row__field--sm { flex: 0 0 140px; }
.form-row .field--lg { flex: 2; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  align-items: end;
}

.form-stack {
  display: flex; flex-direction: column; gap: 12px;
}

.form-group {
  display: flex; flex-direction: column; gap: 6px;
}

.label {
  font-size: 12px; font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* Additional field standalone sizes */
.field--sm { flex: 0 0 140px !important; }
.field--lg { flex: 2 !important }

/* ─────────────────────────────────────────────
   11. PROFILE LAYOUT (BEM)
────────────────────────────────────────────── */
.profile { display: flex; flex-direction: column; gap: 28px; }

.profile__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.profile__title { font-family: var(--font-display); font-size: 22px; font-weight: 700; }
.profile__subtitle { font-size: 13px; color: var(--color-muted); margin-top: 3px; }
.profile__stats { display: flex; gap: 12px; }

.stat-card {
  padding: 14px 20px;
  background-color: var(--color-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-width: 160px;
}
.stat-card__label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-muted); font-weight: 700; }
.stat-card__value { font-family: var(--font-display); font-size: 22px; font-weight: 800; color: var(--accent); margin-top: 4px; }

/* ─────────────────────────────────────────────
   11b. LOOKUP RESULT — .lookup-card
────────────────────────────────────────────── */
.lookup-card {
  background: var(--color-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-top: 16px;
}
.lookup-header--ported,
.lookup-header--original {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  gap: 12px;
}
.lookup-header--ported {
  background: linear-gradient(135deg, rgba(59,130,246,.12) 0%, rgba(59,130,246,.04) 100%);
  border-bottom: 2px solid rgba(59,130,246,.25);
}
.lookup-header--original {
  background: linear-gradient(135deg, rgba(16,185,129,.12) 0%, rgba(16,185,129,.04) 100%);
  border-bottom: 2px solid rgba(16,185,129,.25);
}
.lookup-title {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.lookup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  padding: 20px;
}
.lookup-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lookup-field__label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
}
.lookup-field__value {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}
.lookup-donor {
  padding: 12px 20px 16px;
  margin: 0 20px 12px;
  border-left: 3px solid rgba(59,130,246,.4);
  background: rgba(59,130,246,.04);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.lookup-admin {
  padding: 12px 20px 16px;
  margin: 0 20px 12px;
  border-left: 3px solid rgba(245,158,11,.4);
  background: rgba(245,158,11,.04);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.lookup-card__donor-idd {
  font-size: 12px;
  color: var(--color-muted);
  margin-left: 6px;
}
.lookup-footer {
  display: flex;
  justify-content: space-between;
  padding: 10px 20px;
  font-size: 11px;
  color: var(--color-muted);
  border-top: 1px solid var(--border);
  background: var(--color-bg);
}
.lookup-error {
  padding: 14px 20px;
  margin-top: 16px;
  border-radius: var(--radius-lg);
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.2);
  color: #ef4444;
  font-weight: 600;
}

/* ─────────────────────────────────────────────
   12. ALERT — .alert (flash messages)
────────────────────────────────────────────── */
.alert {
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.alert--success { border-color: rgba(74, 222, 128, 0.3); background: rgba(74, 222, 128, 0.05); }
.alert--warning { border-color: rgba(251, 191, 36, 0.3); background: rgba(251, 191, 36, 0.05); }
.alert--error   { border-color: rgba(248, 113, 113, 0.3); background: rgba(248, 113, 113, 0.05); }
.alert--info    { border-color: rgba(56, 189, 248, 0.3); background: rgba(56, 189, 248, 0.05); }

.alert__title { font-weight: 700; font-size: 14px; }
.alert__body  { font-size: 13px; color: var(--color-muted); }

.token-display {
  background-color: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  word-break: break-all;
  user-select: all;
  cursor: text;
  color: var(--color-success);
}
.token-display__wrapper {
  display: flex; align-items: stretch; gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.token-display__wrapper .token-display {
  flex: 1; border: none; border-radius: 0;
}
.token-display__copy {
  padding: 12px 16px;
  border-left: 1px solid var(--border);
  border-radius: 0;
  font-size: 12px; font-weight: 600;
  color: var(--color-accent);
  background: rgba(0, 0, 0, 0.15);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.token-display__copy:hover { background: rgba(125, 211, 252, 0.1); }

/* ─────────────────────────────────────────────
   13. AUTH PAGES — Login / Setup
────────────────────────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background-color: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background-color: var(--color-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.auth-logo {
  text-align: center;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}

.auth-logo__icon {
  width: 48px; height: 48px;
  color: var(--accent);
  margin-bottom: 4px;
}

.auth-logo__title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

.auth-logo__subtitle {
  font-size: 13px;
  color: var(--color-muted);
}

.auth-form {
  display: flex; flex-direction: column; gap: 16px;
}

.auth-input-wrapper {
  display: flex; flex-direction: column; gap: 6px;
}

.auth-label {
  font-size: 12px; font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}

.auth-error {
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(248, 113, 113, 0.3);
  background: rgba(248, 113, 113, 0.06);
  color: var(--color-danger);
  font-size: 13px;
  font-weight: 500;
}

.auth-success {
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(74, 222, 128, 0.3);
  background: rgba(74, 222, 128, 0.06);
  color: var(--color-success);
  font-size: 13px;
  font-weight: 500;
}

/* ─────────────────────────────────────────────
   14. DASHBOARD — grid & layout
────────────────────────────────────────────── */
.dashboard {
  display: flex; flex-direction: column; gap: 24px;
  max-width: 1280px;
  width: 100%;
}

.dashboard__header {
  display: flex; flex-direction: column; gap: 4px;
}

.dashboard__title {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700;
}

.dashboard__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

@media (max-width: 768px) {
  .dashboard__grid { grid-template-columns: 1fr; }
}

/* ─────────────────────────────────────────────
   15. PANEL — .panel (Carriers, Sync)
────────────────────────────────────────────── */
.panel {
  background-color: var(--color-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex; flex-direction: column; gap: 16px;
}

.panel__header,
.panel-heading {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
}

.panel__title {
  font-family: var(--font-display);
  font-size: 16px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}

.panel__icon {
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.panel__desc,
.import-desc {
  font-size: 13px;
  color: var(--color-muted);
  line-height: 1.5;
}

.import-desc code {
  font-family: var(--font-mono);
  font-size: 12px;
  background-color: rgba(0, 0, 0, 0.25);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--accent);
}

.import-form {
  display: flex; flex-direction: column; gap: 12px;
}

/* ─────────────────────────────────────────────
   16. SYNC — cards & grid
────────────────────────────────────────────── */
.sync-stack {
  display: flex; flex-direction: column; gap: 24px;
}

.sync-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.sync-card {
  background-color: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
}

.sync-card__header {
  font-size: 14px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}

.sync-card__desc {
  font-size: 12px; color: var(--color-muted); line-height: 1.5;
}

.sync-stats-bar {
  display: flex; gap: 20px; align-items: center; flex-wrap: wrap;
  padding: 10px 16px;
  background-color: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius);
  font-size: 13px;
}

.sync-warning {
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(251, 191, 36, 0.3);
  background: rgba(251, 191, 36, 0.06);
  color: var(--color-warning);
  font-size: 13px;
  font-weight: 500;
}

.sync-applied-row {
  opacity: 0.55;
}

.sync-header-info {
  font-size: 13px;
  color: var(--color-muted);
  display: flex; align-items: center; gap: 8px;
}

.htmx-indicator {
  display: inline-block;
  animation: spin 1.2s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ─────────────────────────────────────────────
   17. PAGINATOR
────────────────────────────────────────────── */
.paginator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 0;
}

.paginator__info {
  font-size: 13px;
  color: var(--color-muted);
}

.paginator__controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─────────────────────────────────────────────
   18. EMPTY STATE
────────────────────────────────────────────── */
.empty-state,
.section-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  text-align: center;
  color: var(--color-muted);
}

.empty-state__icon,
.empty-icon-lg {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  opacity: 0.5;
}

.empty-state__title {
  font-size: 15px; font-weight: 600; color: var(--fg);
}

.empty-state__desc {
  font-size: 13px; color: var(--color-muted);
  max-width: 360px; line-height: 1.5;
}

/* ─────────────────────────────────────────────
   19. FILE INPUT — .file-input
────────────────────────────────────────────── */
.file-input {
  position: relative;
}

.file-input__hidden {
  position: absolute;
  width: 0; height: 0;
  opacity: 0; overflow: hidden;
}

.file-input__label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
}

.file-input__label:hover {
  border-color: var(--accent);
  background-color: rgba(56, 189, 248, 0.04);
}

.file-input__icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  opacity: 0.7;
}

.file-input__text {
  font-size: 13px;
  color: var(--fg);
  font-weight: 500;
}

.file-input__subtext {
  font-size: 11px;
  color: var(--color-muted);
}

/* ─────────────────────────────────────────────
   20. TABLE INLINE EDITING (Carriers)
────────────────────────────────────────────── */
.table-edit-row {
  background-color: rgba(56, 189, 248, 0.04);
}

.table-edit-cell {
  padding: 6px 8px;
}

.table-edit-cell .input {
  height: 30px;
  font-size: 12px;
}

.table-row-actions {
  display: flex; gap: 6px; align-items: center;
  justify-content: flex-end;
}

/* ─────────────────────────────────────────────
   21. PURGE RESULT
────────────────────────────────────────────── */
.purge-container {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(248, 113, 113, 0.3);
  background: rgba(248, 113, 113, 0.06);
}

.purge-container__icon {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.purge-container__title {
  font-weight: 700; font-size: 14px; color: var(--color-danger);
}

.purge-container__desc {
  font-size: 13px; color: var(--color-muted);
}

.purge-container__desc code {
  font-family: var(--font-mono);
  font-size: 12px;
  background-color: rgba(0, 0, 0, 0.25);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ─────────────────────────────────────────────
   22. PORTABILITY — view specifics
────────────────────────────────────────────── */
.portability-table__idd {
  margin-left: 8px;
  vertical-align: middle;
}

/* ─────────────────────────────────────────────
   23. PAGE CONTAINER
────────────────────────────────────────────── */
.page-container {
  display: flex; flex-direction: column; gap: 24px;
  max-width: 1280px;
  width: 100%;
}

/* ─────────────────────────────────────────────
   24. UTILITIES (minimal — prefer BEM)
────────────────────────────────────────────── */
.u-flex { display: flex; }
.u-flex-col { flex-direction: column; }
.u-items-center { align-items: center; }
.u-justify-between { justify-content: space-between; }
.u-gap-1 { gap: 4px; }
.u-gap-2 { gap: 8px; }
.u-gap-3 { gap: 12px; }
.u-gap-4 { gap: 16px; }
.u-flex-1 { flex: 1; }
.u-w-full { width: 100%; }
.u-text-muted { color: var(--color-muted); }
.u-text-mono { font-family: var(--font-mono); }
.u-text-sm { font-size: 12px; }
.u-mt-2 { margin-top: 8px; }
.u-mt-4 { margin-top: 16px; }
.u-mb-4 { margin-bottom: 16px; }

/* Legacy compat aliases */
.w-full { width: 100%; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }

/* Text helpers */
.text-muted { color: var(--color-muted); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-accent { color: var(--accent); }
.text-warning { color: var(--color-warning); }
.text-success { color: var(--color-success); }
.font-mono { font-family: var(--font-mono); }
.font-semibold { font-weight: 600; }

/* ─────────────────────────────────────────────
   25. HTMX TRANSITIONS
────────────────────────────────────────────── */
.main-content {
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.main-content.htmx-swapping {
  opacity: 0;
  transform: translateY(4px);
}
.main-content.htmx-settling {
  opacity: 1;
  transform: translateY(0);
}
.htmx-indicator { opacity: 0.5; pointer-events: none; }

/* ─────────────────────────────────────────────
   26. RESPONSIVE — Sidebar collapse
────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar--open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }
  .main-content__scroll {
    padding: 24px;
  }
}

@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    gap: 12px;
  }

  .form-row {
    flex-direction: column;
  }

  .sync-grid {
    grid-template-columns: 1fr;
  }

  .profile__stats {
    flex-wrap: wrap;
  }
}

/* ─────────────────────────────────────────────
   26. REDUCED MOTION
────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─────────────────────────────────────────────
   CARRIER SEARCH
────────────────────────────────────────────── */
.carrier-search {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 0;
}
.carrier-search .input { flex: 1; }
.carrier-filter-toggle {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--color-muted);
  white-space: nowrap; cursor: pointer;
  user-select: none;
}
.carrier-filter-toggle input[type="checkbox"] {
  accent-color: var(--accent);
}

/* ─────────────────────────────────────────────
   COLLAPSIBLE PANELS
────────────────────────────────────────────── */
.panel--collapsible {
  padding: 0;
}
.panel__summary {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 20px;
  font-size: 14px; font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.panel__summary::-webkit-details-marker { display: none; }
.panel__summary::after {
  content: '▸'; margin-left: auto;
  font-size: 12px; color: var(--color-muted);
  transition: transform .15s ease;
}
details[open] > .panel__summary::after {
  transform: rotate(90deg);
}
.panel__body {
  padding: 0 20px 16px;
}

/* ─────────────────────────────────────────────
   CHART
────────────────────────────────────────────── */
.chart-controls {
  display: flex; gap: 4px;
}
.chart-range {
  padding: 4px 10px;
  font-size: 11px; font-weight: 600;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
  transition: all .15s ease;
}
.chart-range:hover { color: var(--color-text); border-color: var(--color-text); }
.chart-range.active { background: var(--accent); color: #0f172a; border-color: var(--accent); }
.chart-container {
  position: relative; height: 220px;
}
.chart-empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-muted); font-size: 13px;
  pointer-events: none;
}

/* ─────────────────────────────────────────────
   QUERY HISTORY — controls + summary
────────────────────────────────────────────── */
.query-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.query-controls__ranges {
  display: flex;
  gap: 6px;
}
.query-controls__custom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.query-controls__custom .input {
  width: 140px;
  font-size: 12px;
  padding: 6px 10px;
}
.query-summary { margin-bottom: 16px; }
.query-summary__header { margin-bottom: 8px; }
.query-summary__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted);
}
.query-summary__cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.query-summary__card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.query-summary__label {
  font-size: 11px;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.query-summary__value {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--fg);
}

@media (max-width: 768px) {
  .query-controls { flex-direction: column; align-items: stretch; }
  .query-controls__custom { margin-left: 0; flex-wrap: wrap; }
  .query-summary__cards { grid-template-columns: 1fr; }
}

/* ─────────────────────────────────────────────
   BILLING — Stats in card header
────────────────────────────────────────────── */
.billing-stats { display: flex; gap: 20px; flex-wrap: wrap; }
.billing-stats__item { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.billing-stats__label { font-size: 10px; text-transform: uppercase; color: var(--color-muted); letter-spacing: 0.5px; }
.billing-stats__value { font-size: 15px; font-weight: 700; font-family: var(--font-mono, monospace); }
.billing-stats__item--debt .billing-stats__value { color: var(--color-error); }

.query-summary__card--debt {
  border-color: var(--color-error);
  background: rgba(239, 68, 68, 0.08);
}
.query-summary__card--debt .query-summary__value { color: var(--color-error); }

/* Form section heading */
.form-section-title {
  grid-column: 1 / -1;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted);
  margin: 8px 0 0;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.form-group--full { grid-column: 1 / -1; }

/* ─── Dashboard Stats Grid ───────────────────────────────────────────────── */

.dash-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.dash-stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 10px);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dash-stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-muted);
}

.dash-stat-value {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
  color: var(--color-text);
}

/* ─── Carrier List ───────────────────────────────────────────────────────── */

.carrier-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.carrier-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.carrier-item:last-child { border-bottom: none; }
.carrier-item:hover { background: var(--bg-hover, rgba(255,255,255,0.03)); }

.carrier-item__rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-muted);
  flex-shrink: 0;
}

.carrier-item:nth-child(1) .carrier-item__rank {
  background: rgba(250, 204, 21, 0.15);
  color: #facc15;
}

.carrier-item:nth-child(2) .carrier-item__rank {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
}

.carrier-item:nth-child(3) .carrier-item__rank {
  background: rgba(180, 120, 60, 0.15);
  color: #cd7f32;
}

.carrier-item__info {
  flex: 1;
  min-width: 0;
}

.carrier-item__name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.carrier-item__idd {
  font-size: 11px;
  color: var(--color-muted);
  font-family: var(--font-mono, monospace);
}

.carrier-item__count {
  text-align: right;
  flex-shrink: 0;
}

.carrier-item__count-val {
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
  color: var(--color-text);
}

.carrier-item__count-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--color-muted);
}

/* ─── Skeleton / Loading ─────────────────────────────────────────────────── */

.skeleton-pulse {
  display: inline-block;
  min-width: 48px;
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--border) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
  color: transparent !important;
  user-select: none;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* HTMX indicator: show spinner while loading */
.htmx-indicator {
  display: none;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline-block;
}
