/* Signal Taxi — UI (based on Dashboard reference) */

:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --surface-2: #f5f5f4;
  --border: #e7e5e1;
  --border-2: #ededea;
  --ink: #0c0a09;
  --ink-2: #1c1917;
  --text: #292524;
  --muted: #78716c;
  --muted-2: #a8a29e;
  --accent: #0c0a09;
  --taxi: #f5c400;
  --taxi-deep: #e0b300;
  --taxi-soft: #fff7d6;
  --taxi-ink: #2a2200;
  --good: #15803d;
  --good-bg: #f0fdf4;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --bad: #b91c1c;
  --bad-bg: #fef2f2;
  --info: #1d4ed8;
  --info-bg: #eff6ff;
  --shadow: 0 1px 0 rgba(12, 10, 9, 0.02), 0 1px 2px rgba(12, 10, 9, 0.04);

  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Geist', 'Söhne', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'ss01', 'cv11';
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
}

.mono {
  font-family: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.error {
  color: var(--bad);
  font-size: 0.9rem;
}

/* ─── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(250, 250, 249, 0.85);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar .inner {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.brand .mark {
  width: 36px;
  height: 24px;
  display: grid;
  place-items: center;
  color: var(--ink);
}

.brand .mark svg {
  display: block;
  width: 36px;
  height: auto;
}

.brand .medallion {
  font-family: 'Geist Mono', monospace;
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: 2px;
  font-weight: 500;
}

nav.primary {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 18px;
}

nav.primary .nav-link {
  font-size: 13.5px;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 500;
}

nav.primary .nav-link:hover {
  color: var(--ink);
  background: var(--surface-2);
}

nav.primary .nav-link.active {
  color: var(--ink);
  background: var(--surface-2);
}

nav.primary .nav-dropdown {
  position: relative;
}

nav.primary .nav-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  box-shadow: none;
  padding: 6px 12px;
}

nav.primary .nav-dropdown-caret {
  font-size: 0.65rem;
  line-height: 1;
  opacity: 0.7;
}

nav.primary .nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 1100;
  min-width: 190px;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: 0 10px 30px rgba(12, 10, 9, 0.16);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

nav.primary .nav-dropdown-item {
  display: block;
  padding: 0.55rem 0.65rem;
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

nav.primary .nav-dropdown-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}

nav.primary .nav-dropdown-item.active {
  background: var(--taxi-soft);
  color: var(--ink);
  font-weight: 600;
}

.topbar .spacer {
  flex: 1;
}

/* ─── Subnav ─────────────────────────────────────────────────────────────── */
.subnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.subnav-inner {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  gap: 4px;
}

.subnav-link {
  padding: 0.65rem 1rem;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.subnav-link:hover {
  color: var(--ink);
}

.subnav-link.active {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--taxi);
}

/* ─── Page layout ────────────────────────────────────────────────────────── */
.page {
  max-width: 1480px;
  margin: 0 auto;
  padding: 32px 28px 80px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.page-head h1 {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.page-head .sub {
  font-size: 14px;
  color: var(--muted);
}

.page-head .crumbs {
  font-size: 12px;
  color: var(--muted-2);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-head .crumbs .sep {
  opacity: 0.6;
}

.page-head .actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.end {
  height: 24px;
}

/* ─── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: background 120ms ease, border-color 120ms ease;
}

.btn:hover {
  background: var(--surface-2);
}

.btn.primary {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  box-shadow: 0 1px 2px rgba(12, 10, 9, 0.18);
}

.btn.primary:hover {
  background: #000;
}

.btn.secondary {
  background: var(--surface);
}

.btn.verification {
  background: #0d9488;
  color: #fff;
  border-color: #0f766e;
  box-shadow: 0 1px 2px rgba(13, 148, 136, 0.28);
}

.btn.verification:hover {
  background: #0f766e;
  border-color: #115e59;
}

.iconbtn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid transparent;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0;
  box-shadow: none;
}

.iconbtn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

button:disabled,
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.is-loading {
  opacity: 0.75;
  pointer-events: none;
}

/* ─── Segmented control ──────────────────────────────────────────────────── */
.seg {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 8px;
}

.seg button {
  border: none;
  background: transparent;
  padding: 5px 11px;
  font-size: 12.5px;
  color: var(--muted);
  border-radius: 5px;
  cursor: pointer;
  font-weight: 500;
  box-shadow: none;
}

.seg button:hover {
  color: var(--ink);
}

.seg button.on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.card-head .title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
}

.card-head .meta {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

.card-head .right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── KPI cards ──────────────────────────────────────────────────────────── */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

@media (max-width: 1100px) {
  .kpis {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

.kpi {
  padding: 18px 18px 16px;
  position: relative;
  overflow: hidden;
}

.kpi .head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.kpi .head .name {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.kpi .head .badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border-2);
  font-weight: 500;
}

.kpi .head .badge.good {
  background: var(--good-bg);
  color: var(--good);
  border-color: #bbf7d0;
}

.kpi .head .badge.taxi {
  background: var(--taxi-soft);
  color: var(--taxi-ink);
  border-color: #fde68a;
}

.kpi .value {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.kpi .value .num {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.kpi .value .unit {
  font-size: 13px;
  color: var(--muted);
}

.kpi .footline {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--muted);
}

.kpi .footline .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted-2);
  display: inline-block;
  margin-right: 4px;
}

.kpi .footline .dot.g {
  background: #22c55e;
}

.kpi .footline strong {
  color: var(--ink);
  font-weight: 600;
}

.kpi .spark {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 96px;
  height: 34px;
  min-width: 96px;
  min-height: 34px;
  display: block;
  opacity: 0.9;
  pointer-events: none;
  z-index: 1;
}

.kpi.muted .value .num {
  color: var(--muted-2);
  font-weight: 500;
}

.kpi.muted .stub {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

a.kpi.kpi-link {
  color: inherit;
  text-decoration: none;
  display: block;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

a.kpi.kpi-link:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.detail-subtitle-medallion {
  font-size: 12px;
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
}

.sync-expand-btn {
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  box-shadow: none;
  justify-content: center;
  flex-shrink: 0;
}

.sync-expand-btn:hover {
  background: var(--taxi-soft);
  border-color: var(--taxi-deep);
  color: var(--taxi-ink);
}

.sync-expand-btn[aria-expanded='true'] {
  background: var(--taxi-soft);
  border-color: var(--taxi-deep);
  color: var(--taxi-ink);
}

.sync-history-details td {
  background: var(--surface-2);
  padding: 12px 16px;
}

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

.sync-stat-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
}

.sync-stat-row .k {
  color: var(--muted);
  font-family: var(--font-mono);
}

.sync-stat-row .v {
  color: var(--ink);
  word-break: break-word;
}

.sync-run-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #fecaca;
  background: var(--bad-bg);
  color: var(--bad);
  font-size: 0.9rem;
  line-height: 1.45;
}

.sync-details-heading {
  margin: 18px 0 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

.bekman-results-table {
  margin-top: 8px;
}

.bekman-results-table .error-cell {
  max-width: 28rem;
  white-space: normal;
}

/* ─── Dashboard grid ─────────────────────────────────────────────────────── */
.dashboard-grid,
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
}

@media (max-width: 1180px) {
  .dashboard-grid,
  .grid {
    grid-template-columns: 1fr;
  }
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rail .card {
  padding: 0;
}

.file-completion-parent td {
  border-bottom-color: transparent;
}

.file-completion-subrow td {
  background: color-mix(in srgb, var(--surface) 92%, var(--taxi-soft));
  border-top-color: transparent;
}

.file-completion-subrow + .file-completion-subrow td {
  border-top-color: transparent;
}

.file-completion-parent + .file-completion-subrow td,
.file-completion-subrow + tr:not(.file-completion-subrow) td {
  border-top-color: var(--line);
}

.file-completion-subrow .doc-sub {
  color: var(--muted);
  font-size: 12.5px;
  padding-left: 18px;
}

.doc-sub-prefix {
  color: var(--muted-2);
  font-family: var(--font-mono);
}

tr.file-completion-unclassified-link {
  cursor: pointer;
}

tr.file-completion-unclassified-link .doc::after {
  content: ' →';
  color: var(--muted-2);
  font-size: 12px;
}

.unclassified-table .path-cell {
  font-family: var(--font-mono);
  font-size: 12px;
  max-width: 280px;
  word-break: break-all;
  color: var(--muted);
}

.unclassified-table .path-cell.missing {
  color: var(--muted-2);
}

.unclassified-table td.actions {
  white-space: nowrap;
  text-align: right;
}

/* ─── Tables ───────────────────────────────────────────────────────────────── */
.tbl-wrap {
  overflow: auto;
}

table.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}

table.tbl th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}

table.tbl td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-2);
  color: var(--text);
  vertical-align: middle;
}

table.tbl tbody tr:hover {
  background: #fbfaf8;
}

table.tbl tbody tr:last-child td {
  border-bottom: none;
}

td.doc {
  font-weight: 500;
  color: var(--ink);
}

td.doc .sub {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 1px;
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: 'Geist Mono', monospace;
  font-size: 13px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-2);
  white-space: nowrap;
}

.chip .d {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
}

.chip.driver .d {
  background: #1d4ed8;
}

.chip.tlc .d {
  background: #7c3aed;
}

.chip.dmv .d {
  background: #0891b2;
}

.chip.fleet .d,
.chip.compliance .d,
.chip.service .d {
  background: #15803d;
}

.pct {
  font-weight: 500;
}

.pct.zero,
.pct.none {
  color: var(--muted-2);
}

.pct.high {
  color: var(--good);
}

.pct.mid {
  color: var(--warn);
}

.pct.low {
  color: var(--bad);
}

.bar {
  position: relative;
  height: 6px;
  width: 160px;
  max-width: 100%;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.bar .fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--ink);
  border-radius: 999px;
}

.bar .fill.good {
  background: #22c55e;
}

.bar .fill.warn {
  background: #f59e0b;
}

.bar .fill.bad {
  background: #ef4444;
}

.bar.empty {
  background: repeating-linear-gradient(135deg, transparent 0 6px, var(--border-2) 6px 7px);
}

/* ─── Sync rail ────────────────────────────────────────────────────────────── */
.sync .row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  column-gap: 12px;
  row-gap: 4px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-2);
  align-items: center;
}

.sync .row:last-child {
  border-bottom: none;
}

.sync .row:hover {
  background: #fbfaf8;
}

.sync .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.12);
}

.sync .dot.err {
  background: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.12);
}

.sync .dot.running {
  background: var(--info);
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.12);
}

.sync .meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.sync .src {
  font-family: 'Geist Mono', monospace;
  font-size: 10.5px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 4px;
  padding: 1px 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
}

.sync .when {
  font-family: 'Geist Mono', monospace;
  font-size: 12px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sync .stats {
  font-family: 'Geist Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.sync .stats .up {
  color: var(--ink);
  font-weight: 600;
}

.sync .stats .skip {
  color: var(--muted-2);
}

.sync .stats .sep {
  color: var(--border);
}

.sync .stats .arrow {
  color: var(--muted-2);
  margin-right: 1px;
}

.sync-foot {
  padding: 10px 16px;
  border-top: 1px solid var(--border-2);
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sync-foot a {
  color: var(--ink);
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
}

.sync-foot a:hover {
  border-color: var(--ink);
}

.sync-empty {
  padding: 16px;
  font-size: 13px;
  color: var(--muted);
}

/* ─── KV list ──────────────────────────────────────────────────────────────── */
.kv .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-2);
  font-size: 13px;
}

.kv .row:last-child {
  border-bottom: none;
}

.kv .k {
  color: var(--muted);
}

.kv .v {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-family: 'Geist Mono', monospace;
  font-size: 12.5px;
  font-weight: 500;
}

.kv .v.accent {
  color: var(--good);
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
}

.live .pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

/* ─── Status badges ────────────────────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: lowercase;
}

.status-badge.status-success {
  background: var(--good-bg);
  color: var(--good);
}

.status-badge.status-error {
  background: var(--bad-bg);
  color: var(--bad);
}

.status-badge.status-running {
  background: var(--info-bg);
  color: var(--info);
}

.status-badge.status-unknown {
  background: var(--surface-2);
  color: var(--muted);
}

.source-tag {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 500;
  font-family: 'Geist Mono', monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border-2);
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--good-bg);
  color: var(--good);
  font-size: 0.78rem;
  font-weight: 600;
}

.badge.empty {
  background: var(--surface-2);
  color: var(--muted);
}

.badge.status-active {
  background: var(--good-bg);
  color: var(--good);
}

.badge.status-inactive {
  background: var(--bad-bg);
  color: var(--bad);
}

/* ─── Forms ────────────────────────────────────────────────────────────────── */
label {
  font-size: 0.85rem;
  color: var(--muted);
  display: block;
  margin-bottom: 0.35rem;
}

input[type='search'],
input[type='password'],
input[type='date'],
select {
  padding: 0.55rem 0.75rem;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow);
}

input[type='search']:focus,
input[type='password']:focus,
input[type='date']:focus,
select:focus {
  outline: 2px solid var(--taxi);
  outline-offset: -1px;
  border-color: var(--taxi);
}

input:disabled,
select:disabled {
  opacity: 0.5;
}

/* ─── Login ────────────────────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.login-panel {
  width: 100%;
  max-width: 380px;
  padding: 1.75rem;
}

.login-brand {
  margin-bottom: 1.25rem;
}

.login-panel h1 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--ink);
}

.login-panel form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1rem;
}

.login-panel input[type='password'] {
  width: 100%;
}

/* ─── Browse pages (drivers, vehicles, medallions) ─────────────────────────── */
.page-browse {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.browse-toolbar {
  padding: 0.85rem 1.15rem 0.75rem;
}

.browse-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.browse-filters-stacked {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0.25rem;
}

.browse-filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  row-gap: 0.35rem;
  align-items: center;
}

.browse-filters-stacked input[type='search'] {
  flex: 1 1 280px;
  min-width: 240px;
  margin: 0;
}

.browse-filters-stacked select {
  flex: 0 1 auto;
  min-width: 150px;
  max-width: 220px;
  margin: 0;
}

.browse-filters-stacked input[type='date'] {
  flex: 0 1 auto;
  min-width: 150px;
  margin: 0;
}

.browse-filters-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-left: auto;
}

.browse-filters input[type='search'] {
  flex: 1 1 220px;
  min-width: 180px;
}

.browse-count {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
}

.browse-layout {
  display: block;
  min-height: 0;
}

.browse-table-wrap {
  padding: 0;
  overflow: auto;
  max-height: calc(100vh - 14rem);
}

.browse-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.browse-page-label {
  margin: 0;
  font-size: 0.85rem;
  text-align: center;
  flex: 1;
}

/* Fixed flyout panels (driver + file preview) — full viewport, above top nav */
:root {
  --browse-flyout-width: clamp(300px, 40vw, 640px);
}

body.browse-flyouts-open {
  overflow: hidden;
}

.browse-flyout-scrim {
  position: fixed;
  inset: 0;
  background: rgba(12, 10, 9, 0.28);
  z-index: 1000;
}

.browse-flyout {
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  width: var(--browse-flyout-width);
  margin: 0;
  padding: 0;
  border-radius: 0;
  border: none;
  box-shadow: -10px 0 40px rgba(12, 10, 9, 0.14);
  z-index: 1010;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.browse-flyout:not(.hidden) {
  display: flex !important;
}

/* loading-region also sets position:relative; flyouts must stay fixed */
.browse-flyout.loading-region {
  position: fixed;
}

.browse-flyout-driver {
  transition: right 0.2s ease;
}

.browse-flyout-fleet {
  transition: right 0.2s ease;
}

body.browse-file-open .browse-flyout-driver,
body.browse-file-open .browse-flyout-fleet {
  right: var(--browse-flyout-width);
}

.browse-flyout-file {
  z-index: 1020;
}

.browse-flyout-header {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.browse-flyout-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  min-width: 0;
  flex: 1;
}

.browse-flyout-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.browse-flyout-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
  width: 100%;
}

.browse-flyout-header-driver .browse-flyout-actions .iconbtn {
  width: 34px;
  height: 34px;
}

.browse-flyout-header-driver .browse-flyout-title {
  overflow-wrap: anywhere;
}

/* Header actions dropdown */
.dropdown {
  position: relative;
}

.dropdown-toggle {
  gap: 0.4rem;
}

.dropdown-caret {
  font-size: 0.7rem;
  line-height: 1;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 1100;
  min-width: 220px;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: 0 10px 30px rgba(12, 10, 9, 0.16);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.65rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: none;
  text-decoration: none;
  height: auto;
}

.dropdown-item:hover {
  background: var(--surface-2);
}

/* Link modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(12, 10, 9, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.hidden {
  display: none;
}

.modal-box {
  width: min(540px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(12, 10, 9, 0.28);
  padding: 1.25rem;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.modal-head h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
}

.modal-note {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.5;
}

.modal-copied-badge {
  display: inline-block;
  margin-right: 0.4rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--good-bg);
  color: var(--good);
  font-size: 0.75rem;
  font-weight: 600;
}

.link-row {
  display: flex;
  gap: 0.5rem;
}

.link-row input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 0.7rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.link-row .btn {
  flex-shrink: 0;
}

.link-modal-box {
  width: min(620px, 100%);
}

.link-modal-sms-section {
  margin-top: 1.1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.link-modal-sms-title {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.link-modal-phone-table-wrap {
  overflow-x: auto;
  margin-bottom: 0.85rem;
}

.link-modal-phone-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.link-modal-phone-table th,
.link-modal-phone-table td {
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.link-modal-phone-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.link-modal-phone-table td:first-child,
.link-modal-phone-table th:first-child {
  width: 3rem;
  text-align: center;
}

.link-modal-phone-table td code,
.link-modal-custom-phone-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
}

.link-modal-custom-phone-input {
  width: 100%;
  min-width: 10rem;
  height: 32px;
  padding: 0 0.55rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
}

.link-modal-sms-status {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  line-height: 1.45;
}

.link-modal-sms-status.hidden {
  display: none;
}

.link-modal-sms-status.is-error {
  color: var(--bad);
}

.link-modal-sms-status.is-success {
  color: var(--good);
}

.link-modal-sms-sent {
  padding: 0.85rem 1rem;
  border: 1px solid color-mix(in srgb, var(--good) 35%, var(--border));
  border-radius: 10px;
  background: color-mix(in srgb, var(--good) 8%, var(--surface-2));
}

.link-modal-sms-sent-message {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--good);
  font-weight: 500;
}

.link-modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.browse-flyout-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 1rem;
}

.browse-flyout .loading-overlay {
  border-radius: 0;
}

.drivers-table th.sortable {
  padding: 0;
}

.drivers-table .th-sort-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  padding: 10px 16px;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 500;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  box-shadow: none;
  height: auto;
}

.drivers-table .th-sort-btn:hover {
  background: #fbfaf8;
  color: var(--ink);
}

.drivers-table th.sorted .th-sort-btn {
  color: var(--ink);
}

.drivers-table .sort-indicator {
  font-size: 0.65rem;
  line-height: 1;
  opacity: 0.7;
  min-width: 0.75rem;
}

.drivers-table tbody tr {
  cursor: pointer;
}

.drivers-table tbody tr.selected {
  background: var(--taxi-soft);
}

#medallions-table tbody tr.fleet-row,
#vehicles-table tbody tr.fleet-row {
  cursor: pointer;
}

#medallions-table tbody tr.fleet-row.selected,
#vehicles-table tbody tr.fleet-row.selected {
  background: var(--taxi-soft);
}

.drivers-table tr.driver-inactive td:first-child {
  color: var(--muted);
}

.drivers-table .empty-cell {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
}

.drivers-table .mono {
  font-family: 'Geist Mono', monospace;
  font-size: 12px;
  color: var(--muted);
}

/* ─── Detail drawer (driver flyout content) ───────────────────────────────── */
.detail-section-title {
  margin: 1rem 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

.detail-files-container {
  margin-top: 0.75rem;
}

.detail-file-group {
  margin-bottom: 1.1rem;
}

.detail-file-group-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.detail-file-group-head h4 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

.detail-file-group-count {
  font-size: 0.75rem;
  color: var(--muted);
}

.detail-meta p {
  margin: 0.25rem 0;
  font-size: 0.9rem;
}

/* Driver drawer header subtitle */
.detail-headline {
  min-width: 0;
  flex: 1;
}

.detail-subtitle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.detail-subtitle:empty {
  display: none;
}

.detail-subtitle-tlc {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}

/* Driver drawer body sections */
.detail-section {
  margin-bottom: 1.25rem;
}

.detail-section + .detail-section {
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
}

.detail-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.detail-section-title {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.detail-section-count {
  font-size: 0.75rem;
  color: var(--muted);
}

.detail-documents {
  margin-bottom: 0;
}

/* Label/value info grid */
.info-grid {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.info-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-2);
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  color: var(--muted);
  flex-shrink: 0;
}

.info-value {
  color: var(--ink);
  text-align: right;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.info-value code {
  font-size: 0.85em;
}

.fleet-meta-link {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  text-align: right;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.fleet-meta-link:hover {
  color: var(--ink);
}

.browse-flyout-actions .btn {
  white-space: nowrap;
}

.detail-empty {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.5;
}

.badge.status-pending {
  color: var(--warn);
  background: var(--warn-bg);
}

.badge.status-error {
  color: #b91c1c;
  background: #fef2f2;
}

.detail-file-list,
.detail-contract-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.detail-file-list li button,
.detail-contract-list li button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.35rem;
  box-shadow: none;
  height: auto;
}

.detail-file-list li button:hover,
.detail-contract-list li button:hover {
  border-color: var(--border);
  background: var(--surface-2);
}

.detail-file-list li button.active,
.detail-contract-list li button.active {
  border-color: var(--taxi);
  background: var(--taxi-soft);
}

.contract-meta,
.file-meta {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.pdf-viewport img.file-preview-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.pdf-viewport {
  width: 100%;
  min-height: 12rem;
  max-height: none;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 0.5rem;
}

.pdf-page-canvas {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto 0.75rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.pdf-page-canvas:last-child {
  margin-bottom: 0;
}

.pdf-toolbar {
  display: none;
}

.pdf-toolbar h3 {
  margin: 0;
  font-size: 1rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Sync / integrations pages ────────────────────────────────────────────── */
.page-sync,
.page-integrations {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sync-history-wrap,
.integrations-wrap {
  padding: 0;
  overflow: auto;
  max-height: calc(100vh - 14rem);
}

.api-key-status,
.integrations-status {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.35;
}

.integrations-status.error {
  color: var(--bad);
}

.integration-account-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.integration-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.integration-avatar--placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--border);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.integration-actions {
  text-align: right;
  white-space: nowrap;
}

table.tbl .error-cell {
  max-width: 14rem;
  font-size: 0.8rem;
  color: var(--bad);
  word-break: break-word;
}

table.tbl .empty-cell {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
}

/* ─── Loading ──────────────────────────────────────────────────────────────── */
.loading-region {
  position: relative;
}

.loading-region.is-loading > :not(.loading-overlay):not(.loading-skip) {
  opacity: 0.45;
  pointer-events: none;
}

.loading-region.is-loading > .loading-skip {
  opacity: 1;
  pointer-events: auto;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(250, 250, 249, 0.82);
  z-index: 10;
  border-radius: inherit;
  min-height: 4rem;
}

.loading-state {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
}

.spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--border);
  border-top-color: var(--taxi);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

.loading-cell {
  text-align: center;
  padding: 2.5rem 1rem !important;
}

/* ─── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .page-head .actions {
    width: 100%;
  }

  .page-head .actions .btn {
    flex: 1;
    justify-content: center;
  }

  .browse-flyout {
    width: 100vw;
    max-width: none;
    min-width: 0;
  }

  body.browse-file-open .browse-flyout-driver,
  body.browse-file-open .browse-flyout-fleet {
    right: 100vw;
    visibility: hidden;
  }

  .browse-flyout-file {
    z-index: 1020;
  }

  .topbar .inner {
    flex-wrap: wrap;
    height: auto;
    padding: 0.6rem 20px;
    gap: 12px;
  }

  nav.primary {
    order: 3;
    width: 100%;
    margin-left: 0;
    padding-bottom: 0.35rem;
  }

  .page {
    padding: 24px 20px 60px;
  }
}
