/* ============================================================
   Driver Payments — design tokens
   ============================================================ */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efebe2;
  --surface-3: #e6e1d5;
  --border: #ddd7c8;
  --ink: #23211c;
  --ink-muted: #746c5c;
  --ink-faint: #9a9280;

  --accent: #c1602a;
  --accent-hover: #a94f21;
  --accent-ink: #fffaf4;
  --accent-soft: #f3ddc7;

  --good: #2f7d52;
  --good-soft: #dcefdf;
  --warn: #9c7412;
  --warn-soft: #f3e6c3;
  --danger: #ad3527;
  --danger-soft: #f6dcd6;
  --info: #2f5f7d;
  --info-soft: #dbe6ec;

  --shadow: 0 1px 2px rgba(35,32,27,0.05), 0 4px 14px -6px rgba(35,32,27,0.14);
  --shadow-lift: 0 2px 4px rgba(35,32,27,0.06), 0 10px 26px -10px rgba(35,32,27,0.22);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --ease: 140ms cubic-bezier(.2,.7,.3,1);

  --font-display: "Archivo", "Segoe UI", system-ui, sans-serif;
  --font-body: "Public Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #18170f;
    --surface: #211f16;
    --surface-2: #2a2718;
    --surface-3: #34301d;
    --border: #3c3822;
    --ink: #ece6d6;
    --ink-muted: #b0a68d;
    --ink-faint: #7c7460;

    --accent: #e0904f;
    --accent-hover: #eda766;
    --accent-ink: #211405;
    --accent-soft: #4a3116;

    --good: #58b789;
    --good-soft: #1e3327;
    --warn: #dcb650;
    --warn-soft: #3a2f11;
    --danger: #e2887c;
    --danger-soft: #3c211d;
    --info: #7fb1cf;
    --info-soft: #1e2e38;

    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 4px 16px -6px rgba(0,0,0,0.45);
    --shadow-lift: 0 2px 4px rgba(0,0,0,0.35), 0 12px 30px -10px rgba(0,0,0,0.55);
  }
}
:root[data-theme="dark"] {
  --bg: #18170f;
  --surface: #211f16;
  --surface-2: #2a2718;
  --surface-3: #34301d;
  --border: #3c3822;
  --ink: #ece6d6;
  --ink-muted: #b0a68d;
  --ink-faint: #7c7460;

  --accent: #e0904f;
  --accent-hover: #eda766;
  --accent-ink: #211405;
  --accent-soft: #4a3116;

  --good: #58b789;
  --good-soft: #1e3327;
  --warn: #dcb650;
  --warn-soft: #3a2f11;
  --danger: #e2887c;
  --danger-soft: #3c211d;
  --info: #7fb1cf;
  --info-soft: #1e2e38;

  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 4px 16px -6px rgba(0,0,0,0.45);
  --shadow-lift: 0 2px 4px rgba(0,0,0,0.35), 0 12px 30px -10px rgba(0,0,0,0.55);
}

* { box-sizing: border-box; }
html { color-scheme: light dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; margin: 0; text-wrap: balance; color: var(--ink); letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 0.95rem; }
p { margin: 0; }
a { color: var(--accent); transition: color var(--ease); }
a:hover { color: var(--accent-hover); }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
::selection { background: var(--accent-soft); }
.tnum { font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.hidden { display: none !important; }
label.field-label, .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ink-muted);
}

/* ---------------- Layout shell ---------------- */
#shell { display: flex; min-height: 100vh; }
#sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 18px;
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(155deg, var(--accent), var(--accent-hover));
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-ink); font-family: var(--font-display); font-weight: 800; font-size: 1rem;
  flex-shrink: 0;
}
.brand-text { font-family: var(--font-display); font-weight: 700; font-size: 0.95rem; line-height: 1.15; }
.brand-text small { display: block; font-family: var(--font-body); font-weight: 500; color: var(--ink-muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: .05em; }

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px 9px 8px; border-radius: var(--radius-sm);
  color: var(--ink-muted); text-decoration: none; cursor: pointer;
  font-weight: 600; font-size: 0.88rem; border: 1px solid transparent;
  border-left: 2px solid transparent;
  background: none; text-align: left; width: 100%;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.active { background: var(--accent-soft); color: var(--accent-hover); border-left-color: var(--accent); padding-left: 8px; }
.nav-link .ic { width: 18px; text-align: center; flex-shrink: 0; }
.nav-section-gap { height: 10px; }
.nav-divider { height: 1px; background: var(--border); margin: 10px 4px; }

#staffbox {
  margin-top: auto; padding: 10px; border-radius: var(--radius); background: var(--surface-2);
  display: flex; align-items: center; gap: 8px; font-size: 0.82rem;
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent);
  color: var(--accent-ink); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-family: var(--font-display); font-size: 0.8rem; flex-shrink: 0;
}
#staffbox .who { flex: 1; min-width: 0; }
#staffbox .who .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#staffbox .who .role { color: var(--ink-muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: .04em; }
#staffbox button { background: none; border: none; color: var(--ink-muted); cursor: pointer; padding: 4px; border-radius: var(--radius-sm); transition: color var(--ease), background var(--ease); }
#staffbox button:hover { color: var(--danger); background: var(--surface-3); }

#main { flex: 1; min-width: 0; }
#topbar {
  display: none;
  align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
#content { padding: 24px 28px 80px; max-width: 1280px; }
.view-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.view-header .sub { color: var(--ink-muted); font-size: 0.88rem; margin-top: 4px; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: 0.85rem;
  cursor: pointer; white-space: nowrap; line-height: 1.2;
  transition: background var(--ease), border-color var(--ease), transform 80ms ease;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.97); }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .nav-link:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger-soft); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 6px 10px; font-size: 0.78rem; }
.btn-icon { padding: 7px 8px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn[disabled]:active { transform: none; }

/* ---------------- Cards / stats ---------------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 18px;
  transition: box-shadow var(--ease);
}
.grid-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px;
}
.stat-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 6px;
  transition: box-shadow var(--ease), border-color var(--ease);
}
.stat-tile:hover { box-shadow: var(--shadow); }
.stat-tile .stat-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-muted); font-weight: 700; }
.stat-tile .stat-value { font-family: var(--font-mono); font-size: 1.55rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat-tile .stat-sub { font-size: 0.76rem; color: var(--ink-faint); }
.stat-tile.accent { border-color: var(--accent-soft); background: linear-gradient(180deg, var(--accent-soft), var(--surface) 65%); }

.section-title { display:flex; align-items:center; justify-content:space-between; margin: 26px 0 10px; }
.section-title h2 { }

/* ---------------- Forms ---------------- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field input, .field select, .field textarea {
  padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); width: 100%;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 160px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
table.data th {
  text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-muted); font-weight: 700; padding: 10px 12px; background: var(--surface-2);
  position: sticky; top: 0; white-space: nowrap;
}
table.data td { padding: 9px 12px; border-top: 1px solid var(--border); white-space: nowrap; }
table.data tbody tr { transition: background var(--ease); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.wrap { white-space: normal; }
table.data tfoot td { font-weight: 700; border-top: 2px solid var(--border); background: var(--surface-2); }

/* Prominent date section (Daily Entry, Driver Summary) */
.date-section { padding: 14px 18px; }
.date-section-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.date-display { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; color: var(--ink); margin-top: 2px; }
.date-section-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.date-section-controls input[type="date"] { padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }

/* Daily entry grid (a single row — Daily Entry adds one record at a time) */
.entry-grid { display: grid; grid-template-columns: 100px 1.3fr 0.85fr 1.1fr 0.8fr 0.8fr 0.8fr 0.95fr 1.2fr; gap: 8px; align-items: center; }
.entry-grid .eh { font-size: 0.68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-muted); font-weight: 700; padding-bottom: 2px; }
.entry-rows { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.entry-row {
  display: grid; grid-template-columns: 100px 1.3fr 0.85fr 1.1fr 0.8fr 0.8fr 0.8fr 0.95fr 1.2fr;
  gap: 8px; align-items: center;
}
.entry-grid input, .entry-grid select, .entry-row input, .entry-row select {
  padding: 7px 9px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); width: 100%;
}

/* Bulk Add (AI) review rows — same entry-row grid, plus a remove button */
.bulk-row-wrap { display: flex; gap: 8px; align-items: center; }
.bulk-row-wrap .btn-icon { flex-shrink: 0; }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 8px; border-radius: 99px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.pill-pending { background: var(--surface-3); color: var(--ink-muted); }
.pill-approved { background: var(--info-soft); color: var(--info); }
.pill-paid { background: var(--good-soft); color: var(--good); }
.pill-cancelled { background: var(--danger-soft); color: var(--danger); }
.pill-car { background: var(--info-soft); color: var(--info); }
.pill-van { background: var(--accent-soft); color: var(--accent-hover); }
.pill-other { background: var(--surface-3); color: var(--ink-muted); }

/* Toolbar / filters */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1 1 220px; }
.search-input { position: relative; }
.search-input input { padding-left: 30px; }
.search-input .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); }

/* Toasts */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow); font-size: 0.85rem; font-weight: 600; max-width: 320px;
  animation: toastin .18s ease-out;
}
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--good); color: #fff; }
@keyframes toastin { from { opacity:0; transform: translateY(6px);} to {opacity:1; transform:none;} }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,18,14,0.45); display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border);
  box-shadow: var(--shadow-lift); width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto; padding: 22px;
  animation: modalin 140ms cubic-bezier(.2,.7,.3,1);
}
.modal.wide { max-width: 720px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head button { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--ink-muted); border-radius: var(--radius-sm); transition: background var(--ease), color var(--ease); padding: 2px 6px; }
.modal-head button:hover { background: var(--surface-2); color: var(--ink); }
@keyframes modalin { from { opacity: 0; transform: translateY(6px) scale(0.99); } to { opacity: 1; transform: none; } }

/* Gate screen */
#gate {
  position: fixed; inset: 0; background: var(--bg); z-index: 300;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.gate-card { width: 100%; max-width: 420px; animation: gatein 180ms cubic-bezier(.2,.7,.3,1); }
@keyframes gatein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.staff-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin: 16px 0; }
.staff-chip {
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius);
  padding: 14px 8px; display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer;
  transition: border-color var(--ease), background var(--ease), transform 80ms ease;
}
.staff-chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.staff-chip:active { transform: scale(0.98); }
.staff-chip .avatar { width: 40px; height: 40px; font-size: 0.95rem; }
.staff-chip span { font-weight: 600; font-size: 0.82rem; text-align: center; }
.pin-dots { display: flex; gap: 10px; justify-content: center; margin: 18px 0; }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--ink-faint); transition: background 100ms ease, border-color 100ms ease, transform 100ms ease; }
.pin-dot.filled { background: var(--accent); border-color: var(--accent); transform: scale(1.08); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad button {
  padding: 14px 0; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
  font-size: 1.1rem; font-weight: 700; cursor: pointer; font-family: var(--font-mono);
  transition: background var(--ease), transform 80ms ease;
}
.keypad button:hover { background: var(--surface-2); }
.keypad button:active { transform: scale(0.95); }

/* Bar chart (dashboard) */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; padding-top: 8px; }
.bars .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.bars .bar { width: 100%; max-width: 30px; background: var(--accent); border-radius: 4px 4px 2px 2px; min-height: 3px; }
.bars .bar-label { font-size: 0.65rem; color: var(--ink-muted); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-muted); }
.empty-state .ic { font-size: 1.8rem; margin-bottom: 8px; }

.badge-count { background: var(--surface-3); color: var(--ink-muted); border-radius: 99px; font-size: 0.68rem; padding: 1px 7px; font-weight: 700; }

.helptext { font-size: 0.78rem; color: var(--ink-faint); }

.mapping-table th, .mapping-table td { font-size: 0.8rem; white-space: normal; }

/* Responsive */
@media (max-width: 860px) {
  #sidebar { display: none; }
  #topbar { display: flex; }
  #content { padding: 16px 14px 90px; }
  .entry-grid { grid-template-columns: 1fr; gap: 4px; }
  .entry-grid .eh { display: none; }
  .entry-row { grid-template-columns: 1fr; gap: 6px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 4px; }
  .entry-row > div { display:flex; align-items:center; gap:8px; flex-wrap: wrap; }
  .entry-row > div::before { content: attr(data-label); font-size:0.68rem; text-transform:uppercase; color:var(--ink-muted); font-weight:700; width:86px; flex-shrink:0; }
  .bulk-row-wrap { flex-direction: column; align-items: stretch; gap: 4px; margin-bottom: 8px; }
  .bulk-row-wrap .btn-icon { align-self: flex-end; }
}

#drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 90; animation: fadein var(--ease); }
#mobilenav {
  position: fixed; top: 0; left: 0; bottom: 0; width: 250px; background: var(--surface); z-index: 95;
  padding: 18px 14px; overflow-y: auto; border-right: 1px solid var(--border);
  box-shadow: var(--shadow-lift);
  animation: drawerin 160ms cubic-bezier(.2,.7,.3,1);
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes drawerin { from { transform: translateX(-12px); opacity: 0.6; } to { transform: none; opacity: 1; } }



/* ============================================================
   UMA Management — Premium midnight & champagne theme
   Visual-only overrides; all existing layout and behaviour retained.
   ============================================================ */
:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f7f7f8;
  --surface-3: #eceef1;
  --border: #e1e4e9;
  --ink: #172033;
  --ink-muted: #687386;
  --ink-faint: #929bab;

  --accent: #b58a45;
  --accent-hover: #967039;
  --accent-ink: #ffffff;
  --accent-soft: #f5eddf;

  --good: #23845b;
  --good-soft: #e1f2e9;
  --warn: #a97920;
  --warn-soft: #fbf1dc;
  --danger: #bd4a4a;
  --danger-soft: #fae8e8;
  --info: #3f6f9f;
  --info-soft: #e7eff8;

  --shadow: 0 2px 8px rgba(19, 29, 48, .045), 0 10px 28px rgba(19, 29, 48, .035);
  --shadow-lift: 0 8px 24px rgba(19, 29, 48, .10);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1422;
  --surface: #141e30;
  --surface-2: #1b2940;
  --surface-3: #24334b;
  --border: #2a3951;
  --ink: #edf1f7;
  --ink-muted: #aab5c6;
  --ink-faint: #7d8ba0;

  --accent: #d5ad68;
  --accent-hover: #e4c184;
  --accent-ink: #111827;
  --accent-soft: #382f22;

  --good: #65c497;
  --good-soft: #17382d;
  --warn: #e0b85e;
  --warn-soft: #3a301c;
  --danger: #ed8b8b;
  --danger-soft: #402528;
  --info: #8db9e5;
  --info-soft: #1d3047;

  --shadow: 0 2px 10px rgba(0,0,0,.20), 0 12px 30px rgba(0,0,0,.16);
  --shadow-lift: 0 10px 28px rgba(0,0,0,.30);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1422;
    --surface: #141e30;
    --surface-2: #1b2940;
    --surface-3: #24334b;
    --border: #2a3951;
    --ink: #edf1f7;
    --ink-muted: #aab5c6;
    --ink-faint: #7d8ba0;
    --accent: #d5ad68;
    --accent-hover: #e4c184;
    --accent-ink: #111827;
    --accent-soft: #382f22;
    --good: #65c497;
    --good-soft: #17382d;
    --warn: #e0b85e;
    --warn-soft: #3a301c;
    --danger: #ed8b8b;
    --danger-soft: #402528;
    --info: #8db9e5;
    --info-soft: #1d3047;
    --shadow: 0 2px 10px rgba(0,0,0,.20), 0 12px 30px rgba(0,0,0,.16);
    --shadow-lift: 0 10px 28px rgba(0,0,0,.30);
  }
}

body {
  background: var(--bg);
  letter-spacing: .005em;
}
#sidebar {
  background: linear-gradient(180deg, #111b2d 0%, #17243a 100%);
  border-right: 1px solid #26354b;
  color: #edf1f7;
}
#sidebar .brand-text { color: #f4f6fa; }
#sidebar .brand-text small { color: #aab5c6; }
#sidebar .brand-mark {
  background: linear-gradient(145deg, #e2c184, #a77b39);
  color: #172033;
  box-shadow: 0 5px 14px rgba(0,0,0,.18);
}
#sidebar .nav-link { color: #b8c2d1; }
#sidebar .nav-link:hover {
  background: rgba(255,255,255,.075);
  color: #fff;
}
#sidebar .nav-link.active {
  background: rgba(213,173,104,.16);
  color: #f0d49e;
  border-left-color: #d5ad68;
}
#sidebar .nav-divider { background: rgba(255,255,255,.12); }
#sidebar #staffbox { background: rgba(255,255,255,.075); color: #edf1f7; }
#sidebar #staffbox .who .role { color: #aab5c6; }
#sidebar #staffbox .avatar {
  background: linear-gradient(145deg, #e2c184, #a77b39);
  color: #172033;
}
#topbar {
  backdrop-filter: blur(14px);
  box-shadow: 0 1px 0 rgba(20,30,48,.04);
}
.card, .stat-tile, .table-wrap {
  box-shadow: var(--shadow);
}
.card {
  border-color: var(--border);
}
.stat-tile {
  border-radius: 14px;
}
.stat-tile.accent {
  background: linear-gradient(145deg, var(--accent-soft), var(--surface) 72%);
}
.btn {
  border-radius: 9px;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}
.btn-primary {
  background: linear-gradient(135deg, #c5a064, #a77b39);
  border-color: #a77b39;
  color: #fff;
  box-shadow: 0 4px 12px rgba(167,123,57,.18);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #d0ad72, #967039);
  border-color: #967039;
  box-shadow: 0 6px 16px rgba(167,123,57,.24);
}
.field input, .field select, .field textarea {
  border-radius: 9px;
}
.table-wrap {
  border-radius: 14px;
  overflow: auto;
}
table.data th {
  letter-spacing: .075em;
}
table.data tbody tr:hover {
  background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface));
}
.view-header { margin-bottom: 24px; }
h1, h2, h3, h4 { letter-spacing: -.025em; }
::selection { background: var(--accent-soft); color: var(--ink); }

@media (max-width: 760px) {
  #sidebar { box-shadow: 12px 0 32px rgba(0,0,0,.18); }
  #content { padding: 18px 16px 72px; }
}


/* ============================================================
   UMA cross-device and login reliability improvements
   ============================================================ */
html, body { min-height: 100%; width: 100%; }
body { overflow-x: hidden; -webkit-text-size-adjust: 100%; }
#shell, #main, #content { min-width: 0; }
#content { width: 100%; }
button, .btn, input, select, textarea { touch-action: manipulation; }
button, .btn { -webkit-tap-highlight-color: transparent; }
.field input, .field select, .field textarea,
#gate input { min-width: 0; max-width: 100%; }

#gate {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-top: max(20px, env(safe-area-inset-top));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  -webkit-overflow-scrolling: touch;
}
.gate-card {
  flex: 0 1 420px;
  width: min(100%, 420px);
  max-width: 420px;
  margin: auto;
  padding: clamp(18px, 4vw, 28px);
  overflow: visible;
}
#gate .field { min-width: 0; }
#gate .field input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  font-size: 16px; /* prevents iOS Safari zooming the login form */
  line-height: 1.35;
}
#gate .gate-submit { min-height: 48px; font-size: 0.95rem; }
#gate .gate-submit:disabled { opacity: .72; cursor: wait; }
#gate .keypad { gap: clamp(8px, 2.5vw, 12px); }
#gate .keypad button { min-height: 54px; font-size: 1.15rem; touch-action: manipulation; }
.gate-storage-notice {
  display: grid;
  gap: 4px;
  margin: 0 0 16px;
  padding: 11px 12px;
  border: 1px solid var(--warn, #a97920);
  border-radius: 10px;
  background: var(--warn-soft, #fbf1dc);
  color: var(--ink, #172033);
  font-size: .78rem;
  line-height: 1.45;
}
.gate-storage-notice strong { font-size: .8rem; }
.gate-storage-notice span { color: var(--ink-muted, #687386); }

/* Tables and large forms stay usable without forcing the whole page wider. */
.table-wrap, .table-responsive, .mapping-table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { min-width: 620px; }
.modal-backdrop { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: max(14px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom)); }
.modal { max-width: min(720px, 100%); max-height: calc(100dvh - 28px); overflow-y: auto; }

@media (max-width: 860px) {
  #content { max-width: none; padding: 16px 14px calc(88px + env(safe-area-inset-bottom)); }
  #topbar { padding-top: max(10px, env(safe-area-inset-top)); }
  #mobilenav { width: min(310px, 86vw); padding-top: max(18px, env(safe-area-inset-top)); padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .view-header { align-items: flex-start; }
  .view-header > div:last-child { max-width: 100%; }
  .view-header .btn, .view-header button { max-width: 100%; }
  .stat-grid, .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal { width: 100%; }
}
@media (max-width: 560px) {
  body { font-size: 14px; }
  h1 { font-size: 1.3rem; }
  #content { padding-left: 12px; padding-right: 12px; }
  .gate-card { padding: 20px 17px; }
  .view-header { gap: 10px; margin-bottom: 16px; }
  .view-header > * { min-width: 0; }
  .view-header .btn, .view-header button { white-space: normal; }
  .card { max-width: 100%; }
  .stat-grid, .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-tile { min-width: 0; padding: 12px; }
  .form-row, .form-grid { grid-template-columns: 1fr !important; }
  .modal-backdrop { align-items: flex-start; }
  .modal { margin: auto 0; padding: 16px; }
}
@media (max-height: 620px) and (max-width: 860px) {
  #gate { align-items: flex-start; }
  .gate-card { margin-top: 8px; margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}


/* ============================================================
   UMA theme consistency fix — retain premium navy/champagne brand,
   but keep dashboard surfaces light and all text high-contrast.
   This deliberately overrides OS dark-mode preference for this app.
   ============================================================ */
html { color-scheme: light !important; }
:root,
:root[data-theme="light"],
:root[data-theme="dark"] {
  color-scheme: light !important;
  --bg: #f4f5f7 !important;
  --surface: #ffffff !important;
  --surface-2: #f7f8fa !important;
  --surface-3: #edf0f4 !important;
  --border: #dce2ea !important;
  --ink: #172033 !important;
  --ink-muted: #59677b !important;
  --ink-faint: #738096 !important;
  --accent: #b58a45 !important;
  --accent-hover: #967039 !important;
  --accent-ink: #ffffff !important;
  --accent-soft: #f5eddf !important;
  --good: #23845b !important;
  --good-soft: #e1f2e9 !important;
  --warn: #8a651d !important;
  --warn-soft: #fbf1dc !important;
  --danger: #bd4a4a !important;
  --danger-soft: #fae8e8 !important;
  --info: #3f6f9f !important;
  --info-soft: #e7eff8 !important;
  --shadow: 0 2px 8px rgba(19, 29, 48, .045), 0 10px 28px rgba(19, 29, 48, .055) !important;
  --shadow-lift: 0 8px 24px rgba(19, 29, 48, .10) !important;
}
body { background: #f4f5f7; color: #172033; }
.card, .stat-tile, .table-wrap { background-color: #ffffff; color: #172033; }
.stat-tile .stat-value, table.data td, table.data tfoot td,
.section-title h2, .view-header h1 { color: #172033; }
.stat-tile .stat-label, .helptext, .view-header .sub,
.section-title .helptext, .bars .bar-label { color: #59677b; }
.date-section { background: #ffffff; color: #172033; }
table.data th { background: #eef2f7; color: #3d4b60; }
table.data tfoot td { background: #f1f3f6; }
.gate-account-list { display: grid; gap: 9px; margin: 14px 0; }
.gate-account-option { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px; border: 1px solid #dce2ea; border-radius: 11px; background: #fff; color: #172033; cursor: pointer; }
.gate-account-option:hover, .gate-account-option:focus-visible { background: #f7f8fa; border-color: #b58a45; outline: 2px solid rgba(181,138,69,.18); }
.gate-account-avatar { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%; display: grid; place-items: center; background: #f5eddf; color: #775a2c; font-weight: 700; }
.gate-account-copy { min-width: 0; display: grid; gap: 2px; }
.gate-account-copy strong { font-size: .9rem; }
.gate-account-copy small { color: #59677b; font-size: .72rem; letter-spacing: .06em; }
.gate-account-arrow { margin-left: auto; font-size: 1.4rem; color: #967039; }
.gate-back-account { width: 100%; }
.gate-account-warning { margin-top: 8px; padding: 9px 10px; border-radius: 8px; background: #fff5df; color: #694e19; font-size: .73rem; line-height: 1.4; }



/* Mobile login feedback: visible inline status instead of relying on transient toasts. */
#gate .gate-inline-error {
  margin: 0 0 12px;
  padding: 11px 12px;
  border: 1px solid #c45b50;
  border-radius: 9px;
  background: #fff0ee;
  color: #8a3028;
  font-size: .82rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
#gate .gate-inline-error[hidden] { display: none !important; }
#gate .gate-submit { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
#gate .gate-submit:focus-visible { outline: 3px solid rgba(181,138,69,.35); outline-offset: 2px; }
