/* ═══════════════════════════════════════════════
   FiveM CAD — Dashboard styles
   ═══════════════════════════════════════════════ */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
* { scrollbar-width: thin; scrollbar-color: var(--border2) transparent; }

html, body {
  height: 100%; overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}

/* ════════════════════════ LEO SUB-NAV ════════════════════════ */
.subnav {
  display: none;
  position: fixed; top: var(--nav-h); left: 0; right: 0; z-index: 99;
  height: var(--subnav-h);
  background: var(--surface);
  border-bottom: 2px solid var(--border2);
  align-items: stretch;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.subnav::-webkit-scrollbar { display: none; }
.subnav .nav-tab { height: var(--subnav-h); font-size: 12px; padding: 0 16px; }

body.leo-mode .subnav { display: flex; }

/* When the LEO sub-nav is visible, push all panels down by its height */
body.leo-mode .tab-panel { top: calc(var(--nav-h) + var(--subnav-h)); }
body.leo-mode .tab-panel.active { height: calc(100dvh - var(--nav-h) - var(--subnav-h)); }
body.leo-mode #tab-dispatch.active { height: calc(100dvh - var(--nav-h) - var(--subnav-h)); }

/* ═══════════════════════ TOP NAV ═══════════════════════ */
.topnav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--panel);
  border-bottom: 2px solid var(--border2);
  display: flex; align-items: center;
  padding: 0 0 0 16px;
}

.nav-logo {
  font-family: var(--sans); font-size: 15px; font-weight: 700;
  letter-spacing: 0.04em; color: #fff; flex-shrink: 0;
  display: flex; align-items: center; gap: 8px;
}
.nav-logo-badge {
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 600; padding: 2px 7px;
  letter-spacing: 0.06em;
}

.nav-sep { width: 1px; height: 24px; background: var(--border2); margin: 0 14px; flex-shrink: 0; }

.nav-community {
  font-family: var(--sans); font-size: 13px; font-weight: 600;
  color: var(--text-dim); flex-shrink: 0;
}

.nav-tabs {
  display: flex; align-items: stretch; height: 100%; margin-left: 8px;
  flex: 1 1 0;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.nav-tabs::-webkit-scrollbar { display: none; }

.nav-tab {
  display: flex; align-items: center; gap: 7px; padding: 0 18px;
  cursor: pointer; font-family: var(--sans); font-size: 13px; font-weight: 500;
  color: var(--text-dim); border-bottom: 3px solid transparent;
  transition: color 0.12s, border-color 0.12s; white-space: nowrap; user-select: none;
  letter-spacing: 0;
}
.nav-tab:hover  { color: var(--text); }
.nav-tab.active { color: #fff; border-bottom-color: var(--accent); }

.tab-badge {
  background: var(--red); color: #fff; font-family: var(--mono);
  font-size: 10px; font-weight: 500; padding: 1px 6px;
  border-radius: 10px; min-width: 18px; text-align: center;
}
.tab-badge.green { background: var(--green); }
.tab-badge.amber { background: var(--amber); }

.nav-right {
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px; margin-left: auto; flex-shrink: 0;
  border-left: 1px solid var(--border);
}

/* ── Duty toggle ── */
.duty-toggle {
  display: flex; align-items: center; gap: 8px; height: 32px;
  padding: 0 14px; border: 1px solid var(--border2); border-radius: 4px;
  cursor: pointer; font-family: var(--sans); font-size: 12px; font-weight: 600;
  letter-spacing: 0.03em; background: transparent; transition: all 0.15s;
}
.duty-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.duty-toggle.off-duty { color: var(--text-faint); border-color: var(--border); }
.duty-toggle.on-duty  { color: var(--green); border-color: var(--green); background: var(--green-soft); }
.duty-toggle.on-duty .duty-dot { box-shadow: 0 0 0 3px rgba(22,163,74,0.25); animation: pulse-dot 2s ease-in-out infinite; }
@keyframes pulse-dot { 0%,100% { box-shadow: 0 0 0 3px rgba(22,163,74,0.25); } 50% { box-shadow: 0 0 0 5px rgba(22,163,74,0.1); } }

/* ── Character select ── */
.char-select {
  height: 32px; padding: 0 10px;
  background: var(--raised); border: 1px solid var(--border2); border-radius: 4px;
  color: var(--text); font-family: var(--sans); font-size: 12px; font-weight: 500;
  outline: none; cursor: pointer; max-width: 180px;
}
.char-select:focus { border-color: var(--accent); }

.btn-new-char {
  height: 32px; padding: 0 12px; border-radius: 4px;
  background: var(--accent); border: none;
  color: #fff; font-family: var(--sans); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: background 0.12s; white-space: nowrap;
}
.btn-new-char:hover { background: var(--accent-h); }

.nav-user { font-size: 12px; font-weight: 500; color: var(--text-dim); white-space: nowrap; }

#clock { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }

.btn-logout {
  height: 28px; padding: 0 10px; border-radius: 3px;
  background: transparent; border: 1px solid var(--border2);
  color: var(--text-faint); font-family: var(--sans); font-size: 11px; font-weight: 500;
  cursor: pointer; transition: all 0.12s;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* ═══════════════════════ LAYOUT ═══════════════════════ */
.tab-panel {
  display: none; position: fixed;
  top: var(--nav-h); left: 0; right: 0; bottom: 0;
  overflow: hidden;
}
.tab-panel.active { display: flex; flex-direction: column; }

#tab-dispatch.active {
  display: grid;
  grid-template-columns: minmax(420px, 520px) minmax(0, 1fr) 320px;
  height: calc(100dvh - var(--nav-h));
  overflow: hidden;
}

/* ── Dispatch center column ── */
.dispatch-main {
  display: flex; flex-direction: column; overflow: hidden; min-height: 0;
  border-right: 1px solid var(--border2);
}

/* ── Detail pane ── */
.detail-pane {
  flex: 1; overflow: hidden; display: flex; flex-direction: column; min-height: 0;
}

/* ── Units sidebar ── */
.units-sidebar {
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  min-width: 0;
}

.lookup-split {
  flex: 1; overflow: hidden; display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--border2);
}

/* ═══════════════════════ DISPATCH ═══════════════════════ */
.calls-pane { display: flex; flex-direction: column; overflow: hidden; border-right: 1px solid var(--border2); background: var(--panel); }

/* ── Pane header ── */
.pane-header {
  height: 44px; padding: 0 14px; flex-shrink: 0;
  background: var(--surface); border-bottom: 1px solid var(--border2);
  display: flex; align-items: center; justify-content: space-between;
}
.pane-title { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
.pane-actions { display: flex; gap: 6px; align-items: center; }

/* ── Action buttons ── */
.btn-icon {
  height: 28px; padding: 0 10px; border-radius: 3px;
  background: transparent; border: 1px solid var(--border2);
  color: var(--text-dim); font-family: var(--sans); font-size: 11px; font-weight: 500;
  cursor: pointer; transition: all 0.12s; display: inline-flex; align-items: center; gap: 5px;
  white-space: nowrap;
}
.btn-icon:hover          { border-color: var(--accent); color: var(--accent); background: var(--blue-soft); }
.btn-icon.primary        { border-color: var(--accent); color: var(--accent); background: var(--blue-soft); }
.btn-icon.primary:hover  { background: rgba(37,99,235,0.18); }
.btn-icon.danger         { border-color: rgba(229,62,62,0.4); color: var(--red); }
.btn-icon.danger:hover   { background: var(--red-soft); border-color: var(--red); }

/* ── Stats strip ── */
.stats-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--border2); flex-shrink: 0;
}
.units-stats-row {
  grid-template-columns: repeat(3, 1fr);
  background: var(--panel);
}
.units-stats-row .stat-cell {
  padding: 10px 12px;
}
.units-stats-row .stat-val {
  font-size: 18px;
}
.stat-cell {
  padding: 10px 16px; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
}
.stat-cell:last-child { border-right: none; }
.stat-label { font-size: 10px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-faint); }
.stat-val   { font-family: var(--mono); font-size: 22px; font-weight: 500; line-height: 1; color: #fff; }
.stat-val.accent { color: var(--accent); }
.stat-val.green  { color: #4ade80; }
.stat-val.amber  { color: #fbbf24; }
.stat-val.red    { color: #f87171; }

/* ═══════════════════════ CALL TABLE ═══════════════════════ */
.calls-scroll { flex: 1; overflow-y: auto; }

.call-table-head {
  display: grid;
  grid-template-columns: 56px 1fr 90px minmax(90px,auto) 80px;
  padding: 0 10px; height: 30px;
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border2);
  position: sticky; top: 0; z-index: 5;
}
.call-table-head span {
  font-size: 10px; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-faint);
}

/* ── Call row ── */
.call-row {
  display: grid;
  grid-template-columns: 56px 1fr 90px minmax(90px,auto) 80px;
  padding: 0 10px; min-height: 44px;
  align-items: center; cursor: pointer;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  transition: background 0.08s;
  gap: 0;
}
.call-row:hover    { background: var(--raised); }
.call-row.selected { background: var(--panel-alt); border-left-color: var(--accent); }
.call-row.p1 { border-left-color: var(--text-faint); }
.call-row.p2 { border-left-color: var(--amber); }
.call-row.p3 { border-left-color: var(--red); }
.call-row.selected.p3 { background: rgba(229,62,62,0.07); }

.call-row-num   { font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--text-dim); }
.call-row-title { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-row-loc   { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-row-units { font-size: 11px; color: var(--text-dim); }
.call-row-none { color: var(--text-faint); font-family: var(--mono); }
.unit-chip.more { background: rgba(100,116,139,0.15); color: var(--text-faint); border-color: rgba(148,163,184,0.2); }
.call-row-time  { font-family: var(--mono); font-size: 11px; color: var(--text-faint); }

/* ── Priority badges ── */
.pri-badge {
  display: inline-block; font-family: var(--mono); font-size: 10px; font-weight: 500;
  padding: 2px 7px; border-radius: 3px; letter-spacing: 0.03em;
}
.pri-badge.p1 { background: rgba(100,116,139,0.15); color: var(--text-faint); }
.pri-badge.p2 { background: var(--amber-soft); color: #fbbf24; }
.pri-badge.p3 { background: var(--red-soft);   color: #f87171; }

/* ── Status badge ── */
.status-badge {
  display: inline-block; font-family: var(--mono); font-size: 10px; font-weight: 500;
  padding: 2px 7px; border-radius: 3px; text-transform: uppercase;
}
.status-badge.active  { background: var(--blue-soft); color: #93c5fd; }
.status-badge.pending { background: var(--amber-soft); color: #fbbf24; }
.status-badge.closed  { background: rgba(100,116,139,0.1); color: var(--text-faint); }

/* ═══════════════════════ CALL DETAIL ═══════════════════════ */
.detail-pane {
  background: var(--surface);
  border-left: 1px solid var(--border2);
}
.detail-scroll { flex: 1; overflow-y: auto; padding: 16px; }
.detail-empty  {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; color: var(--text-faint); gap: 10px; font-size: 13px;
}

/* ── Detail sections ── */
.detail-section { margin-bottom: 20px; }
.detail-section-title {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-faint); padding-bottom: 6px; margin-bottom: 10px;
  border-bottom: 1px solid var(--border2);
}

/* ── Info table ── */
.info-table { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.info-table td { padding: 5px 0; vertical-align: top; }
.info-table td:first-child {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-faint); width: 110px; padding-right: 12px;
}
.info-table td:last-child { font-size: 13px; color: var(--text); }

/* ── Narrative ── */
.narrative-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.narrative-item:last-child { border-bottom: none; }
.narrative-meta { font-size: 11px; color: var(--text-faint); margin-bottom: 4px; }
.narrative-meta strong { color: var(--text-dim); font-weight: 600; }
.narrative-body { font-size: 13px; color: var(--text); line-height: 1.6; }

.narrative-input-area {
  border-top: 1px solid var(--border2); padding: 10px;
  display: flex; gap: 8px; flex-shrink: 0; background: var(--panel);
}
.narrative-input-area textarea {
  flex: 1; background: var(--raised); border: 1px solid var(--border2); border-radius: 4px;
  color: var(--text); font-family: var(--sans); font-size: 13px;
  padding: 8px 10px; resize: none; outline: none; height: 60px; line-height: 1.5;
  transition: border 0.12s;
}
.narrative-input-area textarea:focus { border-color: var(--accent); }
.narrative-input-area textarea::placeholder { color: var(--text-faint); }

/* ── Unit rows in detail ── */
.unit-assigned-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; background: var(--raised); border-radius: 4px; margin-bottom: 5px;
}
.unit-initials {
  width: 30px; height: 30px; border-radius: 4px;
  background: var(--blue-soft); border: 1px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--accent);
  flex-shrink: 0;
}
.unit-assigned-name { font-size: 13px; font-weight: 600; color: #fff; }
.unit-assigned-dept { font-size: 11px; color: var(--text-dim); }

/* ── Detail action buttons ── */
.detail-actions-bar {
  padding: 10px 12px; background: var(--panel); border-top: 1px solid var(--border2);
  display: none; gap: 8px; flex-shrink: 0;
}

/* ═══════════════════════ UNITS SIDEBAR ═══════════════════════ */
.units-sidebar {
  overflow: hidden; display: flex; flex-direction: column;
}

.unit-group + .unit-group {
  border-top: 1px solid var(--border2);
}

.unit-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
}

.unit-group-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}

.unit-group-count {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
}

.unit-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px; border-bottom: 1px solid var(--border);
}
.unit-avatar {
  width: 30px; height: 30px; border-radius: 4px; flex-shrink: 0;
  background: var(--raised); border: 1px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--accent);
}
.unit-name   { font-size: 13px; font-weight: 600; color: #fff; line-height: 1.2; }
.unit-dept   { font-size: 11px; color: var(--text-dim); }
.unit-status {
  margin-left: auto; font-family: var(--mono); font-size: 10px; font-weight: 600;
  padding: 3px 8px; border-radius: 3px; flex-shrink: 0;
  border: 1px solid transparent;
  cursor: default; user-select: none;
}
.unit-status[data-action="cycle-status"] { cursor: pointer; box-shadow: 0 0 0 1px rgba(255,255,255,0.08); }
.unit-status[data-action="cycle-status"]:hover { opacity: 0.8; filter: brightness(1.15); }
.unit-status.available { background: rgba(22,163,74,0.12);  color: #4ade80; border-color: rgba(74,222,128,0.3); }
.unit-status.enroute   { background: rgba(59,130,246,0.12); color: #60a5fa; border-color: rgba(96,165,250,0.3); }
.unit-status.on_scene  { background: rgba(217,119,6,0.15);  color: #fbbf24; border-color: rgba(251,191,36,0.3); }
.unit-status.busy      { background: rgba(229,62,62,0.12);  color: #f87171; border-color: rgba(248,113,113,0.3); }

/* ═══════════════════════ DISPATCH HISTORY / MAP ═══════════════════════ */
.dispatch-history-panel {
  height: 220px;
  border-top: 1px solid var(--border2);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.dispatch-history-header { flex-shrink: 0; }

.dispatch-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.dispatch-history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  margin-bottom: 8px;
}

.dispatch-history-num {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  color: #dbeafe;
  min-width: 38px;
}

.dispatch-history-main { flex: 1; min-width: 0; }
.dispatch-history-title { font-size: 13px; font-weight: 600; color: #fff; }
.dispatch-history-meta { font-size: 11px; color: var(--text-faint); }
.dispatch-history-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ═══════════════════════ GENERIC TAB CONTENT ═══════════════════════ */
.tab-content { flex: 1; overflow-y: auto; padding: 16px; }

/* ── BOLO / Warrant rows ── */
.record-row {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 12px 14px; margin-bottom: 6px; border-radius: 6px;
  background: var(--panel); border: 1px solid var(--border);
  transition: background 0.08s;
}
.record-row:hover { background: var(--raised); }

.record-icon {
  width: 38px; height: 38px; border-radius: 6px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
}
.record-icon.bolo    { background: var(--amber-soft); color: #fbbf24; }
.record-icon.warrant { background: var(--red-soft);   color: #f87171; }

.record-title { font-size: 14px; font-weight: 600; color: #fff; margin-bottom: 2px; }
.record-desc  { font-size: 12px; color: var(--text-dim); line-height: 1.5; margin-bottom: 4px; }
.record-meta  { font-family: var(--mono); font-size: 11px; color: var(--text-faint); }

/* ── Unit chips ── */
.unit-chip {
  display: inline-flex; align-items: center;
  font-family: var(--mono); font-size: 10px; padding: 2px 7px; border-radius: 3px;
  background: var(--blue-soft); color: #93c5fd; border: 1px solid rgba(59,130,246,0.25);
}

/* ═══════════════════════ MODAL ═══════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 200; display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(3px);
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--panel); border: 1px solid var(--border2); border-radius: 8px;
  width: 520px; max-width: 95vw; max-height: 88vh;
  display: flex; flex-direction: column;
  animation: modalIn 0.18s cubic-bezier(0.16,1,0.3,1) both;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border2);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.modal-title { font-size: 15px; font-weight: 700; color: #fff; }
.modal-close {
  width: 28px; height: 28px; border-radius: 4px; display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; color: var(--text-faint); font-size: 18px; cursor: pointer; transition: all 0.12s;
}
.modal-close:hover { background: var(--red-soft); color: var(--red); }
.modal-body   { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 20px; border-top: 1px solid var(--border2);
  display: flex; gap: 8px; justify-content: flex-end; flex-shrink: 0;
}

/* ═══════════════════════ FORM ELEMENTS ═══════════════════════ */

/* Global dark-theme baseline for all inputs — no white flash regardless of wrapper */
input[type="text"], input[type="search"], input[type="number"],
input[type="email"], input[type="password"], input[type="date"],
input[type="tel"], input[type="url"], textarea {
  background: var(--raised); border: 1px solid var(--border2); border-radius: 4px;
  color: var(--text); font-family: var(--sans); font-size: 13px;
  padding: 9px 12px; outline: none; transition: border-color 0.12s;
  appearance: none; box-sizing: border-box;
}
input[type="text"]:focus, input[type="search"]:focus, input[type="number"]:focus,
input[type="email"]:focus, input[type="password"]:focus, input[type="date"]:focus,
input[type="tel"]:focus, input[type="url"]:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }

.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-dim); margin-bottom: 6px;
}
.field input, .field select, .field textarea { width: 100%; }
.field textarea { resize: vertical; }
.field select {
  background: var(--raised); border: 1px solid var(--border2); border-radius: 4px;
  color: var(--text); font-family: var(--sans); font-size: 13px;
  padding: 9px 12px; outline: none; appearance: none; box-sizing: border-box;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px;
}
.field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ═══════════════════════ BUTTONS ═══════════════════════ */
.btn-primary {
  height: 36px; padding: 0 20px; border-radius: 4px;
  background: var(--accent); border: none; color: #fff;
  font-family: var(--sans); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background 0.12s;
}
.btn-primary:hover    { background: var(--accent-h); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-cancel {
  height: 36px; padding: 0 16px; border-radius: 4px;
  background: transparent; border: 1px solid var(--border2); color: var(--text-dim);
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.12s;
}
.btn-cancel:hover { border-color: var(--text-dim); color: var(--text); }

/* ═══════════════════════ TOAST ═══════════════════════ */
.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 300;
  background: var(--panel); border: 1px solid var(--border2); border-radius: 6px;
  font-size: 13px; font-weight: 500; padding: 12px 18px;
  min-width: 260px; display: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: toastIn 0.18s ease both;
}
.toast.show { display: flex; align-items: center; gap: 10px; }
.toast.success { border-color: var(--green); }
.toast.success::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #4ade80; flex-shrink: 0; }
.toast.error { border-color: var(--red); }
.toast.error::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #f87171; flex-shrink: 0; }
.toast.info { border-color: var(--accent); }
.toast.info::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ═══════════════════════ EMPTY STATE ═══════════════════════ */
.empty { text-align: center; padding: 48px 20px; font-size: 13px; color: var(--text-faint); }

/* ═══════════════════════ LOOKUP ═══════════════════════ */
.lookup-result { background: var(--panel); border: 1px solid var(--border2); border-radius: 6px; padding: 16px; margin-top: 14px; display: none; }
.lookup-result.show { display: block; }
.lookup-flag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 4px;
  margin: 0 6px 6px 0;
}
.lookup-flag.hit   { background: var(--red-soft);   color: #f87171; }
.lookup-flag.clear { background: var(--green-soft); color: #4ade80; }

/* ── Info grid (plate result) ── */
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.info-cell { background: var(--raised); border-radius: 4px; padding: 10px 12px; }
.info-cell-label { font-size: 10px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 4px; }
.info-cell-value { font-size: 13px; font-weight: 500; color: var(--text); }

/* ── Section label ── */
.section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border2);
}

/* ═══════════════════════ ANIMATIONS ═══════════════════════ */
@keyframes slideIn    { from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; transform: translateX(0); } }
@keyframes callPulse  { 0%,100% { box-shadow: none; } 50% { box-shadow: inset 0 0 0 1px rgba(229,62,62,0.5); } }
.call-row.new { animation: callPulse 1.2s ease; }

/* ═══════════════════════ DROPDOWN MENU ═══════════════════════ */
.new-record-dropdown { position: relative; flex-shrink: 0; }
.new-record-menu {
  display: none;
  position: fixed;
  top: 52px;
  left: auto;
  min-width: 170px;
  background: var(--panel);
  border: 1px solid var(--border2);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 9999;
  overflow: hidden;
  animation: menuIn 0.12s ease both;
}
@keyframes menuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.new-record-dropdown.open .new-record-menu { display: block; }
.new-record-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 14px;
  background: transparent; border: none;
  color: var(--text); font-family: var(--sans); font-size: 13px; font-weight: 500;
  cursor: pointer; text-align: left; transition: background 0.1s;
}
.new-record-item:hover { background: var(--raised); color: #fff; }
.new-record-item svg   { flex-shrink: 0; color: var(--text-dim); }
.new-record-item:hover svg { color: var(--accent); }
.new-record-item + .new-record-item { border-top: 1px solid var(--border); }

/* ═══════════════════════ ADMIN SIDEBAR NAV ═══════════════════════ */
/* ── Admin sidebar ── */
#admin-sidebar {
  width: 190px;
  flex-shrink: 0;
  border-right: 1px solid var(--border2);
  padding: 6px 0 12px;
  overflow-y: auto;
}
.admin-nav-group { margin-bottom: 4px; }
.admin-nav-group-label {
  padding: 14px 14px 5px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  user-select: none;
}
.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 14px 7px 16px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-dim);
  border-left: 2px solid transparent;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  user-select: none;
  border-radius: 0;
}
.admin-nav-item:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text);
}
.admin-nav-item.active {
  background: rgba(99,102,241,0.12);
  border-left-color: var(--accent);
  color: #e0e7ff;
  font-weight: 500;
}
.admin-nav-item.active .admin-nav-icon { opacity: 1; color: var(--accent); }
.admin-nav-item.danger { color: #f87171; }
.admin-nav-item.danger:hover { background: rgba(248,113,113,0.07); color: #fca5a5; }
.admin-nav-item.danger.active { background: rgba(248,113,113,0.12); border-left-color: #f87171; color: #fca5a5; }
.admin-nav-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.55;
  transition: opacity 0.12s;
}
.admin-nav-item:hover .admin-nav-icon { opacity: 0.8; }
.admin-nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ═══════════════════════ ADMIN CARDS ═══════════════════════ */
.admin-card { background: var(--panel); border: 1px solid var(--border); overflow: hidden; }
.admin-card-header {
  height: 44px; padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border2);
  display: flex; align-items: center; justify-content: space-between;
}
.admin-card-title {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-dim);
}
.admin-card-body { padding: 16px; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — aggressive compression for all viewports
   ═══════════════════════════════════════════════════════════ */

/* ── Base: tabs always scrollable, never wrap ── */
.nav-tabs { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch; flex: 1 1 0; min-width: 0; }
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tab   { flex-shrink: 0; }
.nav-right { flex-shrink: 0; }

/* Mobile back button — hidden by default, CSS-driven visibility */
#btn-mobile-back { display: none; }

/* ── 1440px: hide version badge and clock ── */
@media (max-width: 1440px) {
  #ver-badge { display: none; }
  #clock     { display: none; }
}

/* ── 1280px: tighten everything, hide community name ── */
@media (max-width: 1280px) {
  .nav-tab            { padding: 0 10px; font-size: 12px; }
  .nav-right          { padding: 0 10px; gap: 6px; }
  .char-select        { max-width: 140px; }
  #nav-community      { display: none; }
  .nav-sep            { margin: 0 8px; }
  .btn-new-char       { display: none; }
  .new-record-dropdown { display: none; }
  /* shorten long tab labels and show thin scroll hint */
  .tab-label-full     { display: none; }
  .tab-label-short    { display: inline !important; }
  .nav-tabs           { scrollbar-width: thin; scrollbar-color: var(--border2) transparent; }
  .nav-tabs::-webkit-scrollbar { display: block; height: 2px; }
  .nav-tabs::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 1px; }
}

/* ── 1024px: compress duty toggle to icon only ── */
@media (max-width: 1024px) {
  .nav-tab       { padding: 0 8px; font-size: 11px; }
  #duty-label    { display: none; }
  .duty-toggle   { padding: 0 10px; min-width: 36px; }
  .nav-user      { display: none; }
  .char-select   { max-width: 120px; }
  .btn-logout    { padding: 0 8px; font-size: 10px; }
  #callsign-display { display: none !important; }
}

/* ── 768px: two-row nav (tabs on row 2) ── */
@media (max-width: 768px) {
  :root { --nav-h: 88px; }

  .topnav {
    height: var(--nav-h);
    flex-wrap: wrap;
    padding: 0;
    align-content: flex-start;
    overflow: hidden;
  }

  .nav-logo  { padding: 0 12px; height: 44px; flex-shrink: 0; }
  .nav-right { height: 44px; margin-left: auto; padding: 0 10px; gap: 6px; border-left: none; flex-shrink: 0; }
  .nav-sep   { display: none !important; }

  .nav-tabs {
    order: 10; flex: 0 0 44px; width: 100%; height: 44px; margin: 0;
    border-top: 1px solid var(--border2); background: var(--surface);
  }
  .nav-tab { height: 44px; padding: 0 10px; font-size: 11px; }

  .tab-panel          { top: var(--nav-h); }
  #tab-dispatch.active { top: var(--nav-h); }

  #tab-dispatch.active {
    display: grid !important;
    grid-template-columns: minmax(320px, 420px) minmax(0, 1fr) 260px !important;
    grid-template-rows: 1fr !important;
    height: calc(100dvh - var(--nav-h)) !important;
  }

  /* subnav sits below the two-row topnav at this breakpoint */
  .subnav { top: var(--nav-h); }
  .subnav .nav-tab { height: var(--subnav-h); font-size: 11px; padding: 0 10px; }

  body.leo-mode .tab-panel          { top: calc(var(--nav-h) + var(--subnav-h)); }
  body.leo-mode .tab-panel.active   { height: calc(100dvh - var(--nav-h) - var(--subnav-h)); }
  body.leo-mode #tab-dispatch.active { height: calc(100dvh - var(--nav-h) - var(--subnav-h)) !important; }
  .dispatch-main { flex-direction: column; }
  .detail-pane    { border-left: 1px solid var(--border2) !important; }
  .dispatch-history-panel { height: 190px; }

  .lookup-split { grid-template-columns: 1fr !important; overflow-y: auto; }
  .stats-row    { grid-template-columns: 1fr 1fr !important; }

  .call-table-head { grid-template-columns: 48px 1fr 80px !important; }
  .call-row        { grid-template-columns: 48px 1fr 80px !important; }
  .call-row > div:nth-child(4), .call-row > div:nth-child(5) { display: none; }
  .call-table-head > span:nth-child(4), .call-table-head > span:nth-child(5) { display: none; }

  .field-row { grid-template-columns: 1fr !important; }

  #admin-content > div[style*="grid-template-columns:repeat(4"] { grid-template-columns: 1fr 1fr !important; }
  #admin-content > div[style*="grid-template-columns:1fr 1fr"]  { grid-template-columns: 1fr !important; }
}

/* ── 640px: mobile — stacked dispatch, detail as full-screen overlay ── */
@media (max-width: 640px) {
  /* Dispatch becomes a vertical flex stack */
  #tab-dispatch.active {
    display: flex !important;
    flex-direction: column !important;
    height: calc(100dvh - var(--nav-h)) !important;
  }

  /* Calls pane fills remaining space */
  .calls-pane {
    flex: 1;
    min-height: 0;
    border-right: none;
    overflow: hidden;
  }

  .dispatch-history-panel {
    height: 180px;
  }

  /* Right column shrinks to just the units strip */
  .dispatch-main {
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  .units-sidebar {
    flex: 0 0 148px;
    border-top: 1px solid var(--border2);
    overflow: hidden;
  }

  /* Detail pane hidden by default — shown as overlay when a call is selected */
  .detail-pane { display: none !important; }

  .detail-pane.mobile-open {
    display: flex !important;
    position: fixed !important;
    top: var(--nav-h);
    left: 0; right: 0; bottom: 0;
    z-index: 50;
    flex-direction: column;
    background: var(--surface);
    border: none !important;
    border-top: 1px solid var(--border2) !important;
  }

  body.leo-mode .detail-pane.mobile-open { top: calc(var(--nav-h) + var(--subnav-h)); }

  /* dispatch height with subnav open on mobile */
  body.leo-mode #tab-dispatch.active { height: calc(100dvh - var(--nav-h) - var(--subnav-h)) !important; }

  /* Show back button inside the overlay */
  .detail-pane.mobile-open #btn-mobile-back { display: inline-flex !important; }

  /* Units strip fills the right column */
  .units-sidebar { border-top: none; }
}

/* ── 480px: full-screen modals, compact call table ── */
@media (max-width: 480px) {
  .nav-tab { padding: 0 7px; font-size: 10px; gap: 3px; }
  .char-select { max-width: 90px; font-size: 10px; }
  .duty-toggle { padding: 0 8px; min-width: 32px; }
  .btn-logout  { padding: 0 8px; font-size: 10px; }

  .call-table-head { grid-template-columns: 40px 1fr !important; }
  .call-row        { grid-template-columns: 40px 1fr !important; }
  .call-row > div:nth-child(3),
  .call-row > div:nth-child(4),
  .call-row > div:nth-child(5) { display: none; }
  .call-table-head > span:nth-child(3),
  .call-table-head > span:nth-child(4),
  .call-table-head > span:nth-child(5) { display: none; }

  /* Units strip shorter on tiny screens */
  .units-sidebar { flex: 0 0 120px; }
  .dispatch-history-panel { height: 160px; }

  .modal {
    width: 100% !important; max-width: 100% !important;
    max-height: 96dvh !important;
    border-radius: 12px 12px 0 0 !important;
    border-bottom: none !important;
  }
  .modal-backdrop { align-items: flex-end; padding: 0; }

  .tab-content { padding: 10px; }
  .pane-header { padding: 0 10px; }
  .stats-row   { grid-template-columns: 1fr 1fr !important; }
}

/* ── Business sub-tabs ───────────────────────────────────────────────────────── */
.biz-subtab-bar {
  display: flex;
  gap: 2px;
  padding: 10px 16px 0;
  border-bottom: 1px solid var(--border2);
  flex-shrink: 0;
  background: var(--surface);
}
.biz-subtab {
  padding: 7px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 4px 4px 0 0;
  transition: color 0.12s, border-color 0.12s;
  white-space: nowrap;
  user-select: none;
}
.biz-subtab:hover { color: var(--text); }
.biz-subtab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Danger button ───────────────────────────────────────────────────────────── */
.btn-danger {
  background: transparent;
  border: 1px solid #dc2626;
  color: #f87171;
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.btn-danger:hover { background: #dc2626; color: #fff; }

/* ── Business rank badge ─────────────────────────────────────────────────────── */
.biz-rank-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
