/* TrackBridge dashboard. Tokens first; light and dark themes; no external fonts. */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f0f3f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #e8efff;
  --accent-text: #ffffff;
  --ok: #15803d;
  --ok-soft: #e6f6ec;
  --warn: #b45309;
  --warn-soft: #fdf3e2;
  --bad: #c2410c;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --idle: #64748b;
  --idle-soft: #eef1f5;
  --sim: #7c3aed;
  --sim-soft: #f1eafe;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .16);
  --radius: 12px;
  --radius-sm: 8px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --surface: #111a2e; --surface-2: #17223a; --border: #22304d; --border-strong: #31415f;
    --text: #e6ecf7; --text-2: #b4c0d6; --text-3: #8492ab; --accent: #4f8bff; --accent-hover: #6b9dff; --accent-soft: #172a4f;
    --ok: #4ade80; --ok-soft: #12301f; --warn: #fbbf24; --warn-soft: #33270c; --bad: #fb923c; --danger: #f87171; --danger-soft: #3a1515;
    --idle: #8492ab; --idle-soft: #1b253a; --sim: #b794f6; --sim-soft: #2a1d47;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120; --surface: #111a2e; --surface-2: #17223a; --border: #22304d; --border-strong: #31415f;
  --text: #e6ecf7; --text-2: #b4c0d6; --text-3: #8492ab; --accent: #4f8bff; --accent-hover: #6b9dff; --accent-soft: #172a4f;
  --ok: #4ade80; --ok-soft: #12301f; --warn: #fbbf24; --warn-soft: #33270c; --bad: #fb923c; --danger: #f87171; --danger-soft: #3a1515;
  --idle: #8492ab; --idle-soft: #1b253a; --sim: #b794f6; --sim-soft: #2a1d47;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0 0 8px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--text-3); }

/* Shell */
.shell { --side-w: 236px; display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; background: linear-gradient(90deg, var(--surface) 0 calc(var(--side-w) - 1px), var(--border) calc(var(--side-w) - 1px) var(--side-w), transparent var(--side-w)); }
/* Only the menu scrolls; the brand, account and sign-out controls stay on screen at any window height. */
.sidebar { position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: 4px; padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--border); overflow: hidden; }
.nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: 0 -4px; padding: 0 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 4px 16px 8px; font-weight: 700; font-size: 16px; flex: none; }
.brand .collapse-btn { margin-left: auto; width: 32px; height: 32px; color: var(--text-3); }
.nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand img { width: 28px; height: 28px; }
.brand small { display: block; font-weight: 500; font-size: 11.5px; color: var(--text-3); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav-section { margin: 14px 10px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.sidebar-foot { flex: none; padding: 12px 8px 0; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; } /* minmax keeps a long name inside the sidebar so it can end in an ellipsis. */
.account-switch { flex: none; }
@media (max-height: 820px) and (min-width: 901px) {
  .brand { padding-bottom: 10px; }
  .nav a { padding: 6px 10px; }
  .nav-section { margin: 10px 10px 2px; }
  .account-switch { padding-bottom: 8px; }
}
/* Collapsed desktop sidebar: an icon rail with tooltips; labels stay readable to screen readers. */
@media (min-width: 901px) {
  .shell.collapsed { --side-w: 68px; }
  .collapsed .sidebar { padding: 16px 10px; align-items: stretch; }
  .collapsed .nav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .collapsed .brand { flex-direction: column; gap: 8px; padding: 4px 0 12px; }
  .collapsed .brand .collapse-btn { margin: 0; }
  .collapsed .nav a { justify-content: center; padding: 9px 0; }
  .collapsed .nav-section { height: 1px; margin: 8px 6px; background: var(--border); overflow: hidden; color: transparent; }
  .collapsed .account-switch { display: none; }
  .collapsed .sidebar-foot { padding: 10px 0 0; justify-items: center; }
  .collapsed .foot-actions { flex-direction: column; }
  .collapsed .foot-actions .btn { width: 36px; padding: 0; }
}
.who { display: flex; align-items: center; gap: 8px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }
.who b { display: block; color: var(--text); font-size: 13px; overflow: hidden; text-overflow: ellipsis; } /* Long names end in an ellipsis; the full name is in the hover text. */
.main { min-width: 0; }
.topbar { display: none; }
.page { max-width: 1320px; margin: 0 auto; padding: 24px 28px 48px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { color: var(--text-2); margin: 4px 0 0; max-width: 720px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; background: none; }
  .sidebar { position: fixed; z-index: 1200; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .shell.menu-open .sidebar { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 1100; }
  .topbar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 1000; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
  .brand .collapse-btn { display: none; }
  .page { padding: 16px 16px 40px; }
}

/* Surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.card-head p { margin: 2px 0 0; color: var(--text-3); font-size: 12.5px; }
.card-body { padding: 16px 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
.stack { display: grid; gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* Stat tiles */
.stat { padding: 16px 18px; }
.stat-label { color: var(--text-3); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 14px; color: var(--text-3); font-weight: 500; }
.stat-note { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.metric { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.metric .k { font-size: 12px; color: var(--text-3); }
.metric .v { font-size: 16px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 500 13.5px var(--font); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.icon-btn { width: 36px; padding: 0; }

/* Pills and badges */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--idle-soft); color: var(--idle); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.no-dot::before { display: none; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.info { background: var(--accent-soft); color: var(--accent); }
.pill.sim { background: var(--sim-soft); color: var(--sim); }
.pill.live::before { animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 currentColor; } 70% { box-shadow: 0 0 0 5px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.badge-sim { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; padding: 1px 6px; border-radius: 4px; background: var(--sim-soft); color: var(--sim); vertical-align: middle; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
.cell-title { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--text-3); font-family: var(--mono); }

/* Forms */
.field { display: grid; gap: 6px; }
.field label, .label { font-weight: 600; font-size: 13px; }
.field .hint { font-size: 12px; color: var(--text-3); }
.field .error { font-size: 12px; color: var(--danger); }
.input, select.input, textarea.input { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: 14px var(--font); }
textarea.input { height: auto; min-height: 72px; padding: 10px 12px; resize: vertical; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.mono { font-family: var(--mono); }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-weight: 500; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: var(--shadow); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); }
.search .input { padding-left: 34px; min-width: 240px; }

/* Segmented control and tabs */
.segmented { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); gap: 2px; flex-wrap: wrap; }
.segmented button { height: 28px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--text-2); font: 500 12.5px var(--font); cursor: pointer; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }

/* Alerts */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert b { color: var(--text); }
.alert.info { background: var(--accent-soft); border-color: transparent; }
.alert.info svg { color: var(--accent); }
.alert.warn { background: var(--warn-soft); border-color: transparent; }
.alert.warn svg { color: var(--warn); }
.alert.bad { background: var(--danger-soft); border-color: transparent; }
.alert.bad svg { color: var(--danger); }
.alert.ok { background: var(--ok-soft); border-color: transparent; }
.alert.ok svg { color: var(--ok); }

/* Empty states */
.empty { text-align: center; padding: 40px 20px; color: var(--text-3); }
.empty svg { width: 40px; height: 40px; color: var(--border-strong); margin-bottom: 8px; }
.empty h3 { color: var(--text); margin-bottom: 4px; }
.empty .actions { justify-content: center; margin-top: 14px; }

/* Map */
.map { height: 460px; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); z-index: 0; }
.map.tall { height: 560px; }
.map.short { height: 320px; }
.map-card { position: relative; overflow: hidden; }
.map-card .map { border-radius: 0; }
.map-legend { position: absolute; z-index: 500; right: 12px; top: 12px; display: flex; gap: 10px; padding: 6px 10px; border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); font-size: 12px; color: var(--text-2); }
.map-legend span { display: inline-flex; align-items: center; gap: 5px; }
.map-legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
/* Vehicle pin: large core with a white ring and a soft halo so it stands out on busy street tiles. */
.vpin { position: relative; width: 34px; height: 34px; color: #64748b; }
.vpin-core { position: absolute; inset: 7px; border-radius: 50%; background: currentColor; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(15, 23, 42, .35), 0 2px 8px rgba(0, 0, 0, .45); }
.vpin-pulse { position: absolute; inset: 0; border-radius: 50%; background: currentColor; opacity: .22; }
.vpin.online .vpin-pulse, .vpin.alarm .vpin-pulse { animation: halo 2s ease-out infinite; }
.vpin-arrow { position: absolute; left: 50%; top: -9px; width: 0; height: 0; margin-left: -7px; border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 11px solid currentColor; transform-origin: 7px 26px; filter: drop-shadow(0 0 1px #fff); }
.vpin.online { color: #16a34a; } .vpin.recent { color: #d97706; } .vpin.offline { color: #64748b; } .vpin.alarm { color: #dc2626; }
.vpin.sim .vpin-core { border-color: #e9d5ff; }
@keyframes halo { 0% { transform: scale(.6); opacity: .45; } 100% { transform: scale(1.5); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .vpin .vpin-pulse { animation: none !important; } }
.leaflet-tooltip.pin-label { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 6px; padding: 2px 8px; font-weight: 600; font-size: 12px; box-shadow: var(--shadow); }
.leaflet-tooltip.pin-label::before { display: none; }
.map-summary { color: var(--text-2) !important; font-weight: 500; }
.hint-line { margin: 12px 0 0; font-size: 12.5px; color: var(--text-3); }
/* Map controls and the full-screen mode. */
.map-stage { position: relative; }
.map-tools { position: absolute; z-index: 600; left: 12px; bottom: 28px; display: grid; gap: 6px; }
.map-tool { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); box-shadow: var(--shadow); cursor: pointer; }
.map-tool:hover { background: var(--surface-2); text-decoration: none; }
.map-tool.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.map-tool svg { width: 18px; height: 18px; }
.map-full { position: fixed; inset: 0; z-index: 1500; border-radius: 0; border: 0; display: flex; flex-direction: column; }
.map-full .map-stage { flex: 1 1 auto; min-height: 0; }
.map-full .map { height: 100%; border-radius: 0; }
body.no-scroll { overflow: hidden; }
.leaflet-container { font: 13px var(--font); background: var(--surface-2); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.leaflet-popup-content { margin: 12px 14px; }
.popup-title { font-weight: 650; margin-bottom: 2px; }
.popup-coords { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.popup-coords .btn { padding: 2px 8px; }
.popup-links { display: flex; gap: 12px; margin-top: 6px; }
.popup-address { margin-top: 6px; font-size: 12.5px; color: var(--text); line-height: 1.35; }
.popup-credit { display: block; margin-top: 2px; font-size: 11px; color: var(--text-3); }
/* Default OpenStreetMap tiles: slightly muted in the light theme so pins and routes stand out; dimmed for the dark theme
   when no dark tile set is configured. Configured providers' own styles are shown unchanged. */
.map.tiles-muted .leaflet-tile-pane { filter: saturate(.7) contrast(.95) brightness(1.03); }
.map.tiles-dim .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.88) saturate(.55); }
.map.tiles-dim .leaflet-control-attribution { background: rgba(20, 24, 33, .8) !important; color: #cbd5e1; }
.map.tiles-dim .leaflet-control-attribution a { color: #93c5fd; }
.leaflet-control-attribution { background: rgba(255, 255, 255, .8) !important; }

/* Feed */
.feed { display: grid; }
.feed-item { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); align-items: start; }
.feed-item:last-child { border-bottom: 0; }
.feed-item.new { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
.feed-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.feed-icon svg { width: 17px; height: 17px; }
.feed-icon.location { background: var(--accent-soft); color: var(--accent); }
.feed-icon.alarm { background: var(--danger-soft); color: var(--danger); }
.feed-icon.heartbeat { background: var(--ok-soft); color: var(--ok); }
.feed-icon.command_response { background: var(--sim-soft); color: var(--sim); }
.feed-icon.login { background: var(--warn-soft); color: var(--warn); }
.feed-title { font-weight: 600; }
.feed-sub { color: var(--text-2); font-size: 13px; }
.feed-meta { font-size: 12px; color: var(--text-3); text-align: right; white-space: nowrap; }
.feed-detail { grid-column: 2 / -1; margin-top: 4px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; font-size: 12.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-family: var(--mono); word-break: break-all; }
pre.code, .hex { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); font: 12px/1.6 var(--mono); white-space: pre-wrap; word-break: break-all; color: var(--text-2); max-height: 320px; overflow: auto; }

/* Steps (wizard) */
.steps { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text-3); font-weight: 500; font-size: 13px; }
.step .n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: 12px; font-weight: 700; }
.step.on { border-color: var(--accent); color: var(--accent); }
.step.on .n { background: var(--accent); color: #fff; }
.step.done { color: var(--ok); }
.step.done .n { background: var(--ok); color: #fff; }
.sms-list { display: grid; gap: 10px; counter-reset: sms; }
.sms { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.sms .num { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.sms code { font-size: 14px; font-weight: 600; color: var(--text); overflow-wrap: anywhere; } /* Long SERVER texts wrap on phones instead of widening the page. */
.sms .why { font-size: 12.5px; color: var(--text-3); }
.checklist { display: grid; gap: 10px; }
.check { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }
.check .mark { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--border-strong); color: transparent; flex: none; }
.check.done .mark { background: var(--ok); border-color: var(--ok); color: #fff; }
.check.wait .mark { border-color: var(--accent); border-top-color: transparent; animation: spin 1s linear infinite; }
.check .mark svg { width: 14px; height: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Command UI */
.catalog { display: grid; gap: 8px; }
.cmd-group { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.cmd-group > summary { list-style: none; cursor: pointer; padding: 11px 14px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; background: var(--surface); }
.cmd-group > summary::-webkit-details-marker { display: none; }
.cmd-group[open] > summary { border-bottom: 1px solid var(--border); }
.cmd-entries { display: grid; }
.cmd-entry { padding: 12px 14px; border-bottom: 1px solid var(--border); display: grid; gap: 10px; background: var(--surface); }
.cmd-entry:last-child { border-bottom: 0; }
.cmd-entry-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.cmd-entry-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-3); }
.tier { font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 4px; letter-spacing: .03em; }
.tier-0 { background: var(--ok-soft); color: var(--ok); }
.tier-1 { background: var(--accent-soft); color: var(--accent); }
.tier-2 { background: var(--warn-soft); color: var(--warn); }
.tier-3 { background: var(--danger-soft); color: var(--danger); }
.preview { font-family: var(--mono); font-size: 13px; padding: 6px 10px; border-radius: 6px; background: var(--surface-2); border: 1px dashed var(--border-strong); }
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.quick .btn { height: auto; padding: 10px 12px; flex-direction: column; align-items: flex-start; text-align: left; white-space: normal; }
.quick .btn small { color: var(--text-3); font-weight: 400; font-size: 11.5px; }
.engine { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.history-item { padding: 12px 16px; border-bottom: 1px solid var(--border); display: grid; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.split > * { min-width: 0; }
.feed-sub, .preview { overflow-wrap: anywhere; }
.history-item:last-child { border-bottom: 0; }

/* Modal and toasts */
.modal-back { position: fixed; inset: 0; z-index: 2000; background: rgba(15, 23, 42, .5); display: grid; place-items: center; padding: 16px; }
.modal { width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.modal-head { padding: 18px 20px 0; }
.modal-body { padding: 12px 20px; color: var(--text-2); }
.modal-foot { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 3000; display: grid; gap: 8px; width: min(380px, calc(100% - 32px)); }
.toast { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--text); color: var(--surface); box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: flex-start; animation: rise .2s ease-out; }
.toast.bad { background: var(--danger); color: #fff; }
.toast.ok { background: #166534; color: #fff; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Login */

.signin { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.signin-art { background: linear-gradient(135deg, #1e3a8a, #2563eb 55%, #0ea5e9); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.signin-art h1 { font-size: 34px; line-height: 1.15; max-width: 460px; }
.signin-art p { color: #dbeafe; font-size: 15px; max-width: 460px; margin-top: 12px; }
.signin-art ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.signin-art li { display: flex; gap: 10px; align-items: center; color: #eff6ff; }
.signin-art li svg { width: 18px; height: 18px; }
.signin-form { display: grid; place-items: center; padding: 32px; background: var(--bg); }
.signin-box { width: min(400px, 100%); display: grid; gap: 16px; }
@media (max-width: 860px) { .signin { grid-template-columns: 1fr; } .signin-art { display: none; } }

.kbd { font-family: var(--mono); font-size: 12px; padding: 1px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); }
.divider { height: 1px; background: var(--border); margin: 8px 0; }
.list-plain { margin: 0; padding-left: 18px; display: grid; gap: 6px; color: var(--text-2); }
.hide-sm { }
@media (max-width: 640px) { .hide-sm { display: none; } }

/* Current tracker value asked for before a first change */
.current-value { border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 10px 12px 12px; margin: 0; display: grid; gap: 8px; min-width: 0; }
.current-value legend { font-weight: 600; font-size: 13px; padding: 0 6px; }
.current-value p { margin: 0; }

/* Account controls retain the existing light/dark tokens and phone layout. */
.account-switch { padding: 0 16px 12px; }
.account-switch label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.account-switch .input { width: 100%; min-width: 0; }
.owner-banner { margin: 16px 24px 0; padding: 12px 16px; display: flex; gap: 12px; justify-content: space-between; align-items: center; flex-wrap: wrap; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.admin-modal { width: min(620px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); overflow: auto; }
.admin-modal .input { width: 100%; }
/* Save and Cancel stay visible at the bottom of tall dialogs instead of scrolling below the window. */
.admin-modal .modal-body > form > .row:last-child { position: sticky; bottom: 0; z-index: 1; margin: 4px -20px -12px; padding: 12px 20px; justify-content: flex-end; background: var(--surface); border-top: 1px solid var(--border); }
.admin-modal summary { cursor: pointer; font-weight: 600; }
.admin-advanced { padding-top: 14px; }
.admin-permissions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.permission-chips { display: flex; flex-wrap: wrap; gap: 4px; max-width: 220px; }
.permission-chip { font-size: 11px; border: 1px solid var(--border); border-radius: 4px; padding: 2px 5px; background: var(--bg); }
.issued-key { white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; }
.admin-created { display: grid; gap: 12px; margin-bottom: 16px; justify-items: start; }
.audit-list details { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.audit-list summary { cursor: pointer; display: flex; justify-content: space-between; gap: 12px; }
.audit-list .kv { margin: 16px 0; }
.audit-list summary .cell-sub { display: block; margin-top: 2px; }
@media (max-width: 640px) { .owner-banner { margin: 12px 12px 0; } .admin-permissions { grid-template-columns: 1fr; } .admin-modal .row { flex-wrap: wrap; } }
.map-card .card-head { flex-wrap: wrap; }
.kv dd a.nowrap { word-break: normal; white-space: nowrap; }
.kv dd.place { font-family: var(--font); word-break: normal; overflow-wrap: anywhere; } /* Addresses read as text, not identifiers. */

/* Command log: filters, day groups and rows that work from phone to desktop */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.cmd-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cmd-selects { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cmd-selects .input { width: auto; min-width: 170px; max-width: 260px; }
.cmd-day-head { display: flex; justify-content: space-between; padding: 8px 16px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); background: var(--surface-2); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1; }
.cmd-day:first-child .cmd-day-head { border-radius: var(--radius) var(--radius) 0 0; }
.cmd-row { display: grid; grid-template-columns: 4.6em minmax(0, 1fr) auto 14px; gap: 12px; align-items: start; padding: 12px 16px; border-bottom: 1px solid var(--border); color: inherit; }
.cmd-row:hover { background: var(--surface-2); text-decoration: none; }
.cmd-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.cmd-day:last-child .cmd-row:last-child { border-bottom: 0; }
.cmd-time { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 13px; padding-top: 1px; }
.cmd-main { display: grid; gap: 3px; min-width: 0; }
.cmd-title { overflow-wrap: anywhere; }
.cmd-text { font: 12px var(--mono); color: var(--text-3); overflow-wrap: anywhere; }
.cmd-reply { font-size: 13px; color: var(--text-2); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cmd-state { display: grid; justify-items: end; gap: 4px; text-align: right; }
.cmd-go { color: var(--text-3); font-size: 20px; line-height: 1; align-self: center; }
.cmd-more { text-align: center; border-top: 1px solid var(--border); }
@media (max-width: 900px) { .cmd-day-head { top: 57px; } } /* Below the sticky top bar. */
@media (max-width: 640px) {
  .cmd-filters { display: grid; }
  .cmd-show { overflow-x: auto; flex-wrap: nowrap; max-width: 100%; }
  .cmd-show button { white-space: nowrap; }
  .cmd-selects .input { flex: 1 1 140px; min-width: 0; max-width: none; }
  .cmd-row { grid-template-columns: 4.3em minmax(0, 1fr) 12px; padding: 12px; gap: 10px; }
  .cmd-time { font-size: 12px; }
  .cmd-state { grid-column: 2; grid-row: 2; justify-items: start; text-align: left; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
  .cmd-go { grid-column: 3; grid-row: 1 / span 2; }
}

/* One command */
.back-link { display: inline-block; margin-bottom: 8px; font-size: 13px; }
.cmd-reply-full { max-height: none; font-size: 13px; color: var(--text); }
.cmd-kv dd { font-family: var(--font); word-break: normal; overflow-wrap: anywhere; }
.cmd-change { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cmd-change .label { margin-bottom: 6px; }
.cmd-timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.cmd-timeline li { position: relative; padding-left: 22px; }
.cmd-timeline li::before { content: ""; position: absolute; left: 3px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.cmd-timeline li:not(:last-child)::after { content: ""; position: absolute; left: 7px; top: 18px; bottom: -12px; width: 1px; background: var(--border-strong); }
.cmd-timeline li.pending::before { background: var(--surface); border: 2px dashed var(--border-strong); width: 7px; height: 7px; }
.cmd-step { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; }
.cmd-step time { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.cmd-mini { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border); color: inherit; }
.cmd-mini:last-child { border-bottom: 0; }
.cmd-mini:hover { background: var(--surface-2); text-decoration: none; }
.cmd-tech summary { padding: 14px 20px; cursor: pointer; font-weight: 600; }
.cmd-tech[open] summary { border-bottom: 1px solid var(--border); }
.cmd-tech .kv, .cmd-tech .label, .cmd-tech pre { margin-left: 20px; margin-right: 20px; }
.cmd-tech .kv { margin-top: 14px; }
.cmd-tech pre { margin-bottom: 16px; }
@media (max-width: 640px) { .cmd-change { grid-template-columns: 1fr; } }

/* Tracker Commands tab: on narrow screens recent history comes first and stays short */
.history-title { color: inherit; }
.history-reply { overflow-wrap: anywhere; }
.history-more { border-top: 1px solid var(--border); text-align: center; }
@media (max-width: 1100px) {
  .split > .history-card { order: -1; }
  .history-card .history-extra { display: none; }
}
@media (min-width: 1101px) { .history-more { display: none; } }
.cmd-kv dd.mono { font-family: var(--mono); }
