/* admin/src/admin.css — SBSDispatch Admin Backend shared styles */
@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=JetBrains+Mono:wght@400;500&family=DM+Sans:wght@400;500;600&display=swap');

:root {
  --bg:       #07090f;
  --bg2:      #0d1117;
  --surface:  #111720;
  --surface2: #161d2b;
  --surface3: #1b2436;
  --border:   #1f2d42;
  --border2:  #273548;
  --accent:   #e8a020;
  --accent2:  #c87d0e;
  --teal:     #0db388;
  --blue:     #2563eb;
  --red:      #dc3545;
  --green:    #16a34a;
  --amber:    #d97706;
  --text:     #d4dae8;
  --text2:    #8494b0;
  --text3:    #4d6080;
  --font-serif: 'Instrument Serif', Georgia, serif;
  --font-mono:  'JetBrains Mono', monospace;
  --font-sans:  'DM Sans', system-ui, sans-serif;
  --nav-w: 200px;
  --top-h: 52px;
  --radius: 6px;
  --radius-lg: 10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font-sans); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; padding-bottom: 36px; }

.zc-copy-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 400;
  padding: 8px 12px; text-align: center; font-size: 11px; color: var(--text3);
  background: rgba(7, 9, 15, 0.94); border-top: 1px solid var(--border);
  font-family: var(--font-mono);
}
.admin-surface-on { box-shadow: 0 0 0 2px var(--teal); }

@media (min-width: 901px) {
  html, body { overflow: hidden; }
}

/* ── Scrollbar (same accent as .btn-accent / primary buttons) ── */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--accent) var(--bg2);
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg2); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent2); }

/* ── Layout shell ── */
.shell { display: grid; grid-template-columns: var(--nav-w) 1fr; grid-template-rows: var(--top-h) 1fr; height: 100vh; }

/* ── Topbar ── */
.topbar {
  grid-column: 1 / -1;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px; gap: 14px;
  position: relative; z-index: 50;
}
.topbar-brand {
  display: flex; align-items: center; gap: 10px;
  width: calc(var(--nav-w) - 20px); flex-shrink: 0;
}
.brand-icon {
  width: 28px; height: 28px;
  background: var(--accent); color: #000;
  clip-path: polygon(50% 0%,100% 25%,100% 75%,50% 100%,0% 75%,0% 25%);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 500; font-size: 11px; flex-shrink: 0;
}
.brand-name { font-family: var(--font-mono); font-size: 13px; font-weight: 500; letter-spacing: .5px; }
.brand-name em { color: var(--accent); font-style: normal; }
.brand-tag {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 2px;
  text-transform: uppercase; color: var(--text3);
  border: 1px solid var(--border2); padding: 1px 6px; border-radius: 3px;
}
.topbar-middle { flex: 1; display: flex; align-items: center; gap: 8px; }
.topbar-search {
  background: var(--bg2); border: 1px solid var(--border); color: var(--text);
  font-family: var(--font-sans); font-size: 13px; padding: 6px 12px; padding-left: 30px;
  border-radius: var(--radius); outline: none; width: 280px; position: relative;
}
.topbar-search:focus { border-color: var(--accent); }
.search-wrap { position: relative; }
.search-wrap::before { content: '⌕'; position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--text3); font-size: 16px; pointer-events: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.ws-indicator { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text3); font-family: var(--font-mono); }
.ws-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text3); }
.ws-dot.live { background: var(--teal); box-shadow: 0 0 5px var(--teal); }
.topbar-user {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 6px; border-radius: 20px;
  border: 1px solid var(--border); cursor: pointer;
  transition: border-color .15s;
}
.topbar-user:hover { border-color: var(--border2); }
.user-ava {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #000;
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-name { font-size: 12px; }
.user-role { font-size: 10px; color: var(--accent); font-family: var(--font-mono); }
.topbar-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text2);
  font-size: 11px; font-family: var(--font-sans); padding: 5px 10px;
  border-radius: var(--radius); cursor: pointer; transition: all .15s;
}
.topbar-btn:hover { border-color: var(--red); color: var(--red); }

/* ── Sidebar nav ── */
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) var(--surface);
}
.sidebar::-webkit-scrollbar { width: 8px; height: 8px; }
.sidebar::-webkit-scrollbar-track { background: var(--surface); border-radius: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 4px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--accent2); }
.nav-group-label {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 3px;
  text-transform: uppercase; color: var(--text3);
  padding: 16px 14px 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; cursor: pointer;
  color: var(--text2); font-size: 13px;
  border-left: 2px solid transparent;
  transition: all .12s; user-select: none; position: relative;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.02); }
.nav-item.active { color: var(--accent); border-left-color: var(--accent); background: rgba(232,160,32,.06); }
/* Hybrid pricing: extra visibility in sidebar (also duplicated under Overview + Overview toolbar). */
.nav-item.nav-item-hybrid { font-weight: 600; border-left-color: rgba(232, 160, 32, 0.35); }
.nav-item.nav-item-hybrid.active { border-left-color: var(--accent); }
a.nav-item { text-decoration: none; color: inherit; }
.nav-icon { width: 15px; font-size: 13px; flex-shrink: 0; text-align: center; }
.nav-badge {
  margin-left: auto; background: var(--red); color: #fff;
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  padding: 0 5px; border-radius: 8px; min-width: 18px; text-align: center;
}
.nav-badge.amber { background: var(--amber); color: #000; }
.sidebar-footer { margin-top: auto; padding: 12px 14px; font-size: 10px; color: var(--text3); font-family: var(--font-mono); border-top: 1px solid var(--border); }

/* ── Main content ── */
.main { overflow: hidden; display: flex; flex-direction: column; background: var(--bg2); }
.page { display: none; flex-direction: column; height: 100%; overflow: hidden; }
.page.active { display: flex; }
.page-top {
  padding: 18px 24px 0; flex-shrink: 0;
  display: flex; align-items: flex-start; gap: 12px;
}
.page-heading { flex: 1; }
.page-title { font-family: var(--font-serif); font-size: 22px; font-weight: 400; line-height: 1.2; }
.page-title em { color: var(--accent); font-style: italic; }
.page-desc { font-size: 12px; color: var(--text2); margin-top: 3px; font-family: var(--font-mono); }
.page-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.page-body { flex: 1; overflow-y: auto; padding: 16px 24px 28px; }

/* ── Tabs ── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-shrink: 0; padding: 0 24px; }
.tab {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 1px;
  text-transform: uppercase; padding: 10px 16px;
  color: var(--text3); cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: all .15s;
}
.tab:hover { color: var(--text2); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── KPI cards ── */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px 16px; position: relative; overflow: hidden;
}
.kpi::after { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px; }
.kpi.a::after { background: var(--accent); }
.kpi.t::after { background: var(--teal); }
.kpi.b::after { background: var(--blue); }
.kpi.g::after { background: var(--green); }
.kpi.r::after { background: var(--red); }
.kpi-label { font-family: var(--font-mono); font-size: 9px; letter-spacing: 2px; text-transform: uppercase; color: var(--text3); margin-bottom: 5px; }
.kpi-val { font-family: var(--font-mono); font-size: 28px; font-weight: 500; line-height: 1; color: var(--text); }
.kpi-val-sm { font-size: 17px; line-height: 1.15; word-break: break-word; }
.kpi-val-date { font-size: 13px; letter-spacing: 0; font-weight: 600; }
.kpi-sub { font-size: 11px; color: var(--text3); margin-top: 4px; }
.acct-ar-ap-kpis { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 1200px) {
  .acct-ar-ap-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ── Buttons ── */
.btn {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
  padding: 7px 14px; border-radius: var(--radius); border: none; cursor: pointer;
  transition: all .12s; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn-accent  { background: var(--accent); color: #000; }
.btn-accent:hover  { background: #f0ad27; }
.btn-teal    { background: var(--teal); color: #000; }
.btn-teal:hover { background: #12c99a; }
.btn-ghost   { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--border2); color: var(--text); }
.btn-danger  { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-blue    { background: var(--blue); color: #fff; }
.btn-blue:hover { background: #1d4ed8; }
.btn-sm { padding: 4px 10px; font-size: 10px; }
.btn:disabled { opacity: .35; cursor: not-allowed; }

/* General Accounting — section tabs + fleet toolbar (shared look, one active tab) */
.acct-tabstrip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}
.btn.acct-tab {
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
}
.btn.acct-tab:hover {
  border-color: var(--border2);
  color: var(--text);
}
.btn.acct-tab.active {
  background: rgba(232, 160, 32, 0.14);
  border-color: var(--accent);
  color: var(--accent);
}
.acct-tab-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: 2px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}
@media (max-width: 720px) {
  .acct-tab-actions {
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    width: 100%;
  }
}

/* ── Table ── */
.tbl-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.tbl-toolbar {
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.tbl-label { font-family: var(--font-mono); font-size: 9px; letter-spacing: 2px; text-transform: uppercase; color: var(--text3); }
.inp {
  background: var(--bg2); border: 1px solid var(--border); color: var(--text);
  font-family: var(--font-sans); font-size: 12px; padding: 5px 10px;
  border-radius: var(--radius); outline: none;
}
.inp:focus { border-color: var(--accent); }
.sel {
  background: var(--bg2); border: 1px solid var(--border); color: var(--text);
  font-family: var(--font-sans); font-size: 12px; padding: 5px 8px;
  border-radius: var(--radius); outline: none; cursor: pointer;
}
.sel:focus { border-color: var(--accent); }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--surface2);
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--text3); padding: 9px 14px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
thead th.r { text-align: right; }
tbody tr { border-bottom: 1px solid var(--border); transition: background .08s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.015); }
tbody td { padding: 9px 14px; font-size: 13px; vertical-align: middle; }
tbody td.r { text-align: right; }
tbody td.mono { font-family: var(--font-mono); font-size: 11px; }
.empty-row td { text-align: center; color: var(--text3); padding: 32px; font-size: 12px; font-family: var(--font-mono); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 1px; text-transform: uppercase;
  padding: 2px 7px; border-radius: 3px;
}
.b-admin     { background: rgba(232,160,32,.15); color: var(--accent); border: 1px solid rgba(232,160,32,.25); }
.b-dispatcher{ background: rgba(37,99,235,.15);  color: #7ba8f5;       border: 1px solid rgba(37,99,235,.25); }
.b-order_taker{background: rgba(13,179,136,.15); color: var(--teal);   border: 1px solid rgba(13,179,136,.25);}
.b-driver    { background: rgba(217,119,6,.15);  color: #f59e0b;       border: 1px solid rgba(217,119,6,.25); }
.b-customer  { background: rgba(100,116,139,.15);color: #94a3b8;       border: 1px solid rgba(100,116,139,.25);}
.b-active    { background: rgba(22,163,74,.12);  color: #4ade80;       border: 1px solid rgba(22,163,74,.2);  }
.b-inactive  { background: rgba(220,53,69,.12);  color: #f87171;       border: 1px solid rgba(220,53,69,.2);  }
.b-paid      { background: rgba(22,163,74,.12);  color: #4ade80;       border: 1px solid rgba(22,163,74,.2);  }
.b-overdue   { background: rgba(220,53,69,.15);  color: var(--red);    border: 1px solid rgba(220,53,69,.3);  }
.b-sent      { background: rgba(37,99,235,.12);  color: #7ba8f5;       border: 1px solid rgba(37,99,235,.2);  }
.b-draft     { background: rgba(100,116,139,.12);color: #94a3b8;       border: 1px solid rgba(100,116,139,.2);}
.b-partial   { background: rgba(217,119,6,.12);  color: #f59e0b;       border: 1px solid rgba(217,119,6,.2);  }
.b-pending   { background: rgba(100,116,139,.12);color: #94a3b8;       border: 1px solid rgba(100,116,139,.2);}
.b-delivered { background: rgba(22,163,74,.12);  color: #4ade80;       border: 1px solid rgba(22,163,74,.2);  }
.b-cancelled { background: rgba(100,116,139,.1); color: #64748b;       border: 1px solid rgba(100,116,139,.15);}
.b-km { background: rgba(13,179,136,.12); color: var(--teal); border: 1px solid rgba(13,179,136,.2); }
.b-mi { background: rgba(232,160,32,.12); color: var(--accent); border: 1px solid rgba(232,160,32,.2); }

/* ── Modal ── */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.75);
  display: flex; align-items: center; justify-content: center; z-index: 200;
  opacity: 0; pointer-events: none; transition: opacity .18s;
}
.overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius-lg);
  padding: 26px; width: 580px; max-width: 95vw; max-height: 90vh; overflow-y: auto;
  transform: translateY(16px); transition: transform .18s;
}
.overlay.open .modal { transform: none; }
.modal-hd { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { font-family: var(--font-serif); font-size: 19px; }
.modal-title em { color: var(--accent); font-style: italic; }
.modal-x {
  background: var(--bg2);
  border: 1px solid var(--border2);
  color: var(--text3);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  min-width: 36px;
  min-height: 36px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.modal-x:hover { color: var(--accent); border-color: rgba(232, 160, 32, 0.55); }
.modal-ft { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal-ft .btn.btn-ghost {
  min-height: 42px;
  padding: 10px 18px;
  font-weight: 700;
  border: 2px solid rgba(248, 250, 252, 0.35);
  color: var(--text);
  border-radius: var(--radius);
}
.modal-ft .btn.btn-ghost:hover {
  border-color: rgba(232, 160, 32, 0.75);
  color: var(--accent);
  background: rgba(232, 160, 32, 0.08);
}

/* ── Form grid ── */
.fg { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fg.c1 { grid-template-columns: 1fr; }
.fg.c3 { grid-template-columns: 1fr 1fr 1fr; }
.fg-sep { grid-column: 1 / -1; font-family: var(--font-mono); font-size: 9px; letter-spacing: 2px; text-transform: uppercase; color: var(--accent); padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--border); }
.fld { display: flex; flex-direction: column; gap: 5px; }
.fld label { font-family: var(--font-mono); font-size: 9px; letter-spacing: 2px; text-transform: uppercase; color: var(--text3); }
.fld input, .fld select, .fld textarea {
  background: var(--bg2); border: 1px solid var(--border); color: var(--text);
  font-family: var(--font-sans); font-size: 13px; padding: 8px 10px; border-radius: var(--radius);
  outline: none; transition: border-color .15s;
}
.fld input:focus, .fld select:focus, .fld textarea:focus { border-color: var(--accent); }
.fld textarea { resize: vertical; min-height: 64px; }
.fld .hint { font-size: 10px; color: var(--text3); }
.fld-full { grid-column: 1 / -1; }

/* ── Audit log entry ── */
.audit-entry {
  display: flex; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border); font-size: 12px;
}
.audit-entry:last-child { border-bottom: none; }
.audit-action {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 1px; text-transform: uppercase;
  padding: 2px 6px; border-radius: 3px; flex-shrink: 0; align-self: flex-start; margin-top: 1px;
}
.aa-INSERT { background: rgba(22,163,74,.15);  color: #4ade80; }
.aa-UPDATE { background: rgba(232,160,32,.15); color: var(--accent); }
.aa-DELETE { background: rgba(220,53,69,.15);  color: var(--red); }
.audit-meta { color: var(--text3); font-family: var(--font-mono); font-size: 10px; margin-top: 2px; }

/* ── Pricing rule card ── */
.rule-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px; margin-bottom: 10px;
}
.rule-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.rule-name { font-family: var(--font-serif); font-size: 16px; }
.rule-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.rule-field { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; }
.rule-field-label { font-family: var(--font-mono); font-size: 9px; letter-spacing: 1px; text-transform: uppercase; color: var(--text3); margin-bottom: 3px; }
.rule-field-val { font-family: var(--font-mono); font-size: 15px; color: var(--accent); }

/* ── Setting row ── */
.setting-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-info { flex: 1; }
.setting-key { font-family: var(--font-mono); font-size: 12px; color: var(--text); }
.setting-desc { font-size: 11px; color: var(--text3); margin-top: 2px; }
.setting-val { display: flex; align-items: center; gap: 8px; }
.setting-val input, .setting-val select {
  background: var(--bg2); border: 1px solid var(--border); color: var(--text);
  font-family: var(--font-mono); font-size: 12px; padding: 5px 9px;
  border-radius: var(--radius); outline: none; min-width: 140px;
}
.setting-val input:focus, .setting-val select:focus { border-color: var(--accent); }

/* ── Toast ── */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 7px; z-index: 9999; }
.toast {
  background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--radius);
  padding: 9px 14px; font-size: 12px; font-family: var(--font-mono);
  min-width: 260px; max-width: 380px;
  animation: tSlide .2s ease;
}
.toast.ok   { border-left: 3px solid var(--teal);   color: var(--teal); }
.toast.err  { border-left: 3px solid var(--red);    color: #f87171; }
.toast.info { border-left: 3px solid var(--accent); color: var(--accent); }
@keyframes tSlide { from { transform: translateX(30px); opacity: 0; } }

/* ── Toggle switch ── */
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.toggle-track { width: 36px; height: 20px; background: var(--border2); border-radius: 10px; position: relative; transition: background .2s; flex-shrink: 0; }
.toggle-track.on { background: var(--teal); }
.toggle-thumb { width: 14px; height: 14px; background: #fff; border-radius: 50%; position: absolute; top: 3px; left: 3px; transition: left .2s; }
.toggle-track.on .toggle-thumb { left: 19px; }
.toggle-lbl { font-size: 12px; color: var(--text2); }

/* ── Section card ── */
.scard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; margin-bottom: 14px; }
.scard-title { font-family: var(--font-mono); font-size: 9px; letter-spacing: 2px; text-transform: uppercase; color: var(--text3); margin-bottom: 14px; }

/* ── Progress bar ── */
.pbar-wrap { background: var(--bg2); border-radius: 3px; height: 4px; overflow: hidden; }
.pbar { height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s; }
.pbar.teal { background: var(--teal); }
.pbar.red { background: var(--red); }

/* Desktop-only floating Report button */
.desktop-page-report-fab {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 400;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--border2);
  background: var(--accent);
  color: #0a0c10;
  font-weight: 700;
  font-size: 13px;
  font-family: var(--font-sans);
  cursor: pointer;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.45);
}
@media (min-width: 1024px) {
  .desktop-page-report-fab { display: block; }
}

/* ── Mobile / narrow screens ── */
.nav-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-right: 8px;
  flex-shrink: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.nav-menu-btn:hover { border-color: var(--accent); color: var(--accent); }
.nav-menu-btn { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

/* Mobile drawer backdrop: hidden from layout + hits when menu open only */
.sidebar-backdrop {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  top: var(--top-h);
  bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 150;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
  touch-action: manipulation;
}

@media (max-width: 900px) {
  html {
    height: auto;
    -webkit-text-size-adjust: 100%;
  }

  body {
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-menu-btn { display: flex; }

  /* Flex column avoids grid 1fr collapse on auto-height containers (was blocking layout + touches). */
  .shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    height: auto;
  }

  .topbar {
    flex: 0 0 auto;
    width: 100%;
    position: relative;
    z-index: 200;
    grid-column: unset;
    padding:
      max(0px, env(safe-area-inset-top, 0px))
      max(20px, env(safe-area-inset-right, 0px))
      0
      max(20px, env(safe-area-inset-left, 0px));
  }

  .topbar-brand {
    width: auto;
    min-width: 0;
    flex: 1;
  }

  .topbar-middle {
    display: none;
  }

  .topbar-right {
    flex-shrink: 0;
    gap: 6px;
  }

  .topbar-user .user-name,
  .topbar-user .user-role {
    display: none;
  }

  .topbar-btn {
    padding: 8px 10px;
    font-size: 11px;
    touch-action: manipulation;
    min-height: 40px;
  }

  /* Drawer: no pointer capture when off-screen (fixes dead clicks on main). */
  .sidebar {
    position: fixed;
    top: var(--top-h);
    left: 0;
    bottom: 0;
    width: min(300px, 90vw);
    max-height: calc(100vh - var(--top-h));
    max-height: calc(100dvh - var(--top-h));
    z-index: 160;
    transform: translate3d(-100%, 0, 0);
    transition: transform 0.2s ease;
    box-shadow: none;
    border-right: 1px solid var(--border);
    pointer-events: none;
    -webkit-overflow-scrolling: touch;
  }

  body.admin-nav-open .sidebar {
    transform: translate3d(0, 0, 0);
    pointer-events: auto;
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.4);
  }

  body.admin-nav-open .sidebar-backdrop {
    display: block;
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }

  .main {
    flex: 1 1 auto;
    width: 100%;
    min-height: 50vh;
    overflow: visible;
    position: relative;
    z-index: 1;
    isolation: isolate;
    grid-column: unset;
    grid-row: unset;
  }

  .page {
    min-height: 0;
    flex: 1 1 auto;
    display: none;
    flex-direction: column;
    overflow: visible;
    height: auto;
  }

  .page.active {
    display: flex;
  }

  .page-body {
    flex: 1 1 auto;
    overflow: visible;
    padding: 12px 14px 28px;
    -webkit-overflow-scrolling: touch;
  }

  .page-top {
    padding: 14px 14px 0;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    flex-shrink: 0;
  }

  .page-actions {
    flex-wrap: wrap;
    width: 100%;
  }

  .page-title {
    font-size: 19px;
  }

  .nav-item {
    min-height: 44px;
    align-items: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(232, 160, 32, 0.15);
  }

  .tabs {
    padding: 0 14px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }

  .tab {
    flex-shrink: 0;
    touch-action: manipulation;
  }

  .tbl-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 520px;
  }

  .fg,
  .fg.c3 {
    grid-template-columns: 1fr;
  }

  .kpi-row {
    grid-template-columns: 1fr 1fr;
  }

  .modal {
    width: 100%;
    margin: 10px;
    max-height: calc(100dvh - 20px);
  }

  #toasts {
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 10050;
  }

  .toast {
    min-width: 0;
    max-width: none;
  }

  .btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
}

/* Phone autocomplete (Admin Users / Customers modals) */
.zc-ph-wrap {
  position: relative;
  width: 100%;
}
.zc-ph-wrap > input {
  width: 100%;
  padding-right: 72px;
}
.zc-ph-status {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--text3);
  pointer-events: none;
  max-width: 68%;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.zc-ph-drop {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  z-index: 50;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}
.zc-ph-row {
  padding: 8px 10px;
  cursor: pointer;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.zc-ph-row:last-child {
  border-bottom: none;
}
.zc-ph-row:hover,
.zc-ph-row.zc-ph-row-active {
  background: var(--surface3);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.zc-ph-meta {
  font-size: 10px;
  color: var(--text3);
  margin-top: 3px;
  line-height: 1.35;
}

@media (max-width: 480px) {
  .kpi-row {
    grid-template-columns: 1fr;
  }

  .ws-indicator span#wsLabel {
    display: none;
  }
}
