/* ─── Beach Gas Reports — Dark Dashboard Theme ─── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-body: #0b0f1a;
  --bg-sidebar: #0f1320;
  --bg-card: #141825;
  --bg-card-hover: #1a1f30;
  --bg-input: #0f1320;
  --bg-header: #111523;
  --border: #1e2338;
  --border-light: #262b40;
  --text-primary: #e8ecf4;
  --text-secondary: #8b92a8;
  --text-muted: #5a6178;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --green: #22c55e;
  --green-dim: #16a34a;
  --red: #ef4444;
  --red-dim: rgba(239,68,68,0.12);
  --yellow: #eab308;
  --yellow-dim: rgba(234,179,8,0.12);
  --blue: #3b82f6;
  --purple: #a855f7;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
}

[data-theme="light"] {
  --bg-body: #f1f5f9;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #f1f5f9;
  --bg-header: #ffffff;
  --border: #e2e8f0;
  --border-light: #cbd5e1;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent: #4f46e5;
  --accent-light: #6366f1;
  --green: #16a34a;
  --green-dim: #22c55e;
  --red: #dc2626;
  --red-dim: rgba(220,38,38,0.08);
  --yellow: #ca8a04;
  --yellow-dim: rgba(202,138,4,0.08);
  --blue: #2563eb;
  --purple: #7c3aed;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── Login Page ─── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #141825 0%, #0b0f1a 70%);
}
[data-theme="light"] .login-page {
  background: radial-gradient(ellipse at top, #e2e8f0 0%, #f1f5f9 70%);
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  width: min(380px, calc(100vw - 32px));
  text-align: center;
}
.login-logo { color: var(--accent); margin-bottom: 16px; }
.login-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 32px; }
.login-footer { color: var(--text-muted); font-size: 11px; margin-top: 24px; }
.form-group { margin-bottom: 16px; text-align: left; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input {
  width: 100%; padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary); font-size: 15px; outline: none; transition: border-color 0.2s;
}
.form-group input:focus { border-color: var(--accent); }
.error-msg { color: var(--red); font-size: 13px; margin-bottom: 12px; padding: 8px 12px; background: var(--red-dim); border-radius: var(--radius-sm); }

/* ─── Buttons ─── */
.btn-primary {
  width: 100%; padding: 11px; background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer; transition: background 0.2s;
}
.btn-primary:hover { background: var(--accent-light); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  background: none; border: 1px solid var(--border); color: var(--text-secondary); padding: 6px 14px;
  border-radius: var(--radius-sm); font-size: 12px; cursor: pointer; transition: all 0.2s;
}
.btn-ghost:hover { border-color: var(--text-muted); color: var(--text-primary); }
.theme-toggle {
  background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-secondary); width: 30px; height: 30px; display: flex; align-items: center;
  justify-content: center; cursor: pointer; transition: all 0.15s; flex-shrink: 0;
}
.theme-toggle:hover { color: var(--text-primary); border-color: var(--text-muted); }
.btn-export {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px;
  background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 12px; font-weight: 500; cursor: pointer; text-decoration: none; transition: all 0.2s;
}
.btn-export:hover { border-color: var(--accent); color: var(--accent); }

/* ─── App Layout ─── */
#app {
  min-height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  width: 220px;
  height: 100vh;
  z-index: 10;
}
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
  color: var(--accent);
}
.sidebar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.sidebar-title small {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.nav-links {
  list-style: none;
  flex: 1;
  padding: 0 8px;
  overflow-y: auto;
}
.nav-links a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  margin: 2px 0;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.nav-links a svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.nav-links a:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.nav-links a.active { background: rgba(99,102,241,0.12); color: var(--accent-light); }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.about-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  padding: 7px;
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}
.about-link svg { flex-shrink: 0; opacity: 0.8; }
.about-link:hover { color: var(--text-secondary); background: var(--bg-card-hover); }
.about-link.active { color: var(--accent-light); }
.text-muted { color: var(--text-muted); }
.subcat-crumb { color: var(--text-muted); font-size: 12px; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
}
.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 13px;
}
.footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.footer-actions .btn-ghost { flex: 1; text-align: center; }
.role-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(99,102,241,0.15);
  color: var(--accent-light);
}

/* ─── Content ─── */
.content {
  position: relative;
  margin-left: 220px;
  min-height: 100vh;
  width: calc(100% - 220px);
}
.content-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.content-header h2 {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.date-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-icon:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-icon:disabled { cursor: default; }
.btn-icon .refresh-icon { flex-shrink: 0; }
.btn-icon.is-refreshing { color: var(--accent); }
.btn-icon.is-refreshing .refresh-icon { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Sync toast ─── */
.sync-toast {
  position: fixed;
  top: 76px;
  right: 32px;
  z-index: 50;
  max-width: 320px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
.sync-toast.show { opacity: 1; transform: translateY(0); }
.sync-toast.success { border-left-color: var(--green); }
.sync-toast.error { border-left-color: var(--red); }
.sync-toast.info { border-left-color: var(--accent); }
.date-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.date-input:focus { border-color: var(--accent); }
/* Native calendar icon is near-black by default — invert it to show on the dark input. */
.date-input::-webkit-calendar-picker-indicator { filter: invert(0.85); cursor: pointer; }
[data-theme="light"] .date-input::-webkit-calendar-picker-indicator { filter: none; }
.date-sep { color: var(--text-muted); font-size: 12px; }
.period-btns { display: flex; gap: 0; margin-left: 8px; }
.period-btn {
  padding: 6px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.period-btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.period-btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.period-btn:not(:first-child) { border-left: none; }
.period-btn:hover { color: var(--text-primary); }
.period-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.page-content { padding: 24px 32px; }

/* ─── KPI Cards ─── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
/* The FNGTR claim block. Its litres figure carries three decimals because that number is
   transcribed onto the rebate claim, so it can't be rounded like every other card figure —
   it needs a wider track instead, or "76,435.051 L" wraps onto two lines. Scoped to this
   one grid so the widescreen six-column layout is untouched everywhere else. */
.kpi-grid.kpi-grid-wide {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.kpi-clickable {
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.kpi-clickable:hover { border-color: var(--accent); }
.kpi-active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
a.kpi-link {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, transform 0.15s;
}
a.kpi-link:hover {
  border-color: var(--accent, #4a9eff);
  transform: translateY(-1px);
}
.kpi-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.kpi-change { font-size: 12px; font-weight: 600; margin-top: 6px; }
.kpi-change.up { color: var(--green); }
.kpi-change.down { color: var(--red); }
.kpi-change.neutral { color: var(--text-muted); }
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ─── Live tank level strip (Fuel page) ─── */
/* ─── Station Alarms card (Live page) ─── */
.sysalarm-card { border-left: 3px solid var(--red); }
.sysalarm-row { padding: 7px 0; border-bottom: 1px solid var(--border); }
.sysalarm-row:last-child { border-bottom: none; }
.sysalarm-expandable { cursor: pointer; }
.sysalarm-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sysalarm-message { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.sysalarm-meta { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.sysalarm-caret { display: inline-block; transition: transform 0.15s; }
.sysalarm-open .sysalarm-caret { transform: rotate(180deg); }
.sysalarm-detail { display: none; }
.sysalarm-open .sysalarm-detail { display: block; margin: 8px 0 4px 0; }
.sysalarm-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.sysalarm-chip {
  font-size: 11px; font-weight: 600; color: var(--text-secondary);
  background: var(--bg-input); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); padding: 2px 8px;
}
.sysalarm-txn-link {
  font-size: 11px; font-weight: 600; color: var(--accent-light);
  background: rgba(99,102,241,0.12); border: 1px solid rgba(99,102,241,0.35);
  border-radius: var(--radius-sm); padding: 2px 8px; cursor: pointer; font-family: inherit;
}
.sysalarm-txn-link:hover { background: rgba(99,102,241,0.22); }
.sysalarm-detail-text {
  font-size: 12px; line-height: 1.6; color: var(--text-secondary);
  background: var(--bg-input); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); padding: 10px 12px;
  word-break: break-word; /* raw JSON records must wrap, not overflow */
}
.sysalarm-detail-key { font-size: 10px; color: var(--text-muted); margin-top: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.sysalarm-analysis {
  font-size: 12px; line-height: 1.6; color: var(--text-secondary);
  background: var(--bg-input); border: 1px solid var(--border-light);
  border-left: 3px solid rgba(99,102,241,0.6);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 8px;
  display: flex; flex-direction: column; gap: 4px; word-break: break-word;
}
.sysalarm-analysis-head {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted);
}
.sysalarm-analysis-pending { color: var(--text-muted); font-style: italic; }

/* ─── Alarms page (episode history) ─── */
.alarmpage-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-bottom: 12px; margin-bottom: 4px; border-bottom: 1px solid var(--border-light);
}
.alarmpage-count { margin-left: auto; font-size: 11px; color: var(--text-muted); }
.alarmpage-day {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); padding: 14px 0 4px;
}
@media (max-width: 700px) {
  .alarmpage-count { flex-basis: 100%; margin-left: 0; }
}

/* ─── Station Logs page (shipped warn/error lines) ─── */
.logline {
  display: flex; align-items: baseline; gap: 10px;
  padding: 5px 4px; border-bottom: 1px solid var(--border-light);
  font-size: 12px;
}
.logline-time {
  color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.logline-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text-secondary); word-break: break-word; white-space: pre-wrap;
}
.logline-error .logline-text { color: var(--text-primary); }
#logs-more { margin-top: 14px; }

/* ─── Day End page ─── */
.dayend-toolbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding-bottom: 14px; margin-bottom: 6px; border-bottom: 1px solid var(--border-light);
}
.dayend-toolbar label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.dayend-toolbar .btn-export { margin-left: auto; }
.dayend-section { margin-top: 18px; }
.dayend-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); margin-bottom: 6px;
}
.dayend-table { width: 100%; max-width: 520px; }
.dayend-table td { padding: 7px 8px; border-bottom: 1px solid var(--border-light); }
.dayend-table td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.dayend-note { margin-top: 16px; font-size: 12px; color: var(--text-muted); }

/* ─── Shifts page (per-employee day rows + login segments) ─── */
.table-card-note { font-size: 11px; font-weight: 400; color: var(--text-muted); margin-left: 8px; }
.shiftday-row { cursor: pointer; }
.shiftday-row.shiftday-open td { border-bottom: none; }
.shiftday-segments td { background: var(--bg-input); padding: 6px 14px 10px; }
.shiftseg {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-secondary); padding: 4px 0;
}
.shiftseg-meta { color: var(--text-muted); }
.shiftday-flag { color: var(--text-muted); margin-left: 2px; cursor: help; }
.cashvar-detail-head {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-secondary);
  padding: 10px 4px 6px; border-top: 1px solid var(--border-light); margin-top: 10px;
}
.cashvar-close {
  margin-left: auto; background: none; border: 1px solid var(--border-light);
  color: var(--text-muted); border-radius: var(--radius-sm); width: 22px; height: 22px;
  cursor: pointer; line-height: 1;
}
.cashvar-close:hover { color: var(--text-primary); }
.cashvar-table { width: 100%; font-size: 12px; }
.cashvar-table th, .cashvar-table td { padding: 4px 8px; }
.cashvar-note { font-size: 11px; color: var(--text-muted); padding: 6px 4px 0; }
.cashvar-deposits-title { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; padding: 10px 4px 4px; }
.cashvar-deposits { list-style: none; margin: 0; padding: 0 4px; font-size: 12px; }
.cashvar-deposits li { padding: 3px 0; border-top: 1px solid var(--border); }
.cashvar-deposits li:first-child { border-top: none; }
.cashvar-by { color: var(--text-muted); }

/* ─── Fuel Order card (Live page) — same visual language as the tank strip ─── */
.lp-card { border-left: 3px solid var(--border); }
.lp-card.lp-urgent { border-left-color: var(--red); }
.lp-card.lp-expedite { border-left-color: var(--yellow); }
.lp-card.lp-order { border-left-color: var(--green); }
.lp-card.lp-optional { border-left-color: var(--yellow); }
.lp-card.lp-skip { border-left-color: var(--accent); }
.lp-headline { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.lp-headline .badge { flex-shrink: 0; }
.lp-reason { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.lp-order-line {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 12px;
  background: var(--bg-input); border: 1px solid var(--border-light); border-radius: var(--radius-sm);
}
.lp-order-qty { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.lp-order-grade { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.lp-order-plus { color: var(--text-muted); font-size: 14px; }
.lp-order-total { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.lp-tile .tank-tile-grade { margin-top: 2px; margin-bottom: 6px; }
.lp-tile-dry { border-color: rgba(239,68,68,0.45); }
.lp-proj-line {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  font-size: 12px; color: var(--text-secondary); padding: 2px 0;
}
.lp-proj-when { color: var(--text-muted); }
.lp-proj-val { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.lp-proj-final { font-weight: 700; }
.lp-tile-dry .lp-proj-final { color: var(--red); }
.lp-dry-note { font-size: 11px; color: var(--red); margin-top: 6px; }
.lp-dry-note.lp-ok-note { color: var(--text-muted); }
.lp-pending { font-size: 12px; color: var(--text-muted); margin-top: 12px; }
.lp-foot { font-size: 12px; margin-top: 10px; }

.tank-strip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
}
.tank-strip-header {
  display: flex; justify-content: space-between; align-items: baseline;
  flex-wrap: wrap; gap: 4px 16px; margin-bottom: 12px;
}
.tank-strip-title { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.tank-strip-status { font-size: 12px; color: var(--text-secondary); }
.tank-strip-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.tank-tile { background: var(--bg-input); border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 12px 14px; }
.tank-tile-head { display: flex; align-items: center; gap: 6px; }
.tank-tile-name { font-size: 13px; font-weight: 600; }
.tank-tile-grade { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.tank-tile-value { font-size: 22px; font-weight: 700; margin-top: 6px; }
.tank-tile-pct { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.tank-bar { height: 6px; border-radius: 3px; background: var(--border); margin-top: 8px; overflow: hidden; }
.tank-bar-fill { height: 100%; border-radius: 3px; }
.tank-tile-sub { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.tank-badge { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px; letter-spacing: 0.3px; }
.tank-badge-alarm { background: var(--red-dim); color: var(--red); }
.tank-badge-low { background: var(--yellow-dim); color: var(--yellow); }
.tank-badge-book { background: var(--bg-card-hover); color: var(--text-muted); font-weight: 600; }
/* Stale: the one honest state — gray it all out so old numbers don't read as current */
.tank-strip-stale { opacity: 0.55; }
.tank-strip-stale .tank-strip-status { color: var(--yellow); font-weight: 600; }
.tank-strip-stale .tank-bar-fill { background: var(--text-muted) !important; }

/* ─── Charts ─── */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.chart-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.chart-container {
  position: relative;
  height: 280px;
}
.chart-card.wide { grid-column: 1 / -1; }
.chart-card.wide .chart-container { height: 320px; }

/* ─── Tables ─── */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* Wide tables scroll sideways on narrow screens instead of clipping columns */
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 24px;
}
.table-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.table-card-title { font-size: 14px; font-weight: 600; }
/* Non-table content inside the FNGTR claim card needs its own padding
   (the card itself has none — only the header and table cells do). */
.fngtr-body { padding: 16px 20px; }
.table-card-actions { display: flex; gap: 8px; }
.recon-pills { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.recon-pill { border: none; cursor: pointer; font-family: inherit; transition: box-shadow 0.15s; }
.recon-pill:disabled { cursor: default; }
.recon-pill:not(:disabled):hover { box-shadow: 0 0 0 1px currentColor; }
.recon-pill.recon-active { box-shadow: 0 0 0 2px var(--accent); }
.recon-clear { background: none; border: 1px solid var(--border); color: var(--text-secondary); }
.recon-clear:hover { color: var(--text-primary); box-shadow: none !important; border-color: var(--text-muted); }
.recon-banner {
  background: var(--yellow-dim);
  border: 1px solid var(--yellow);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.recon-banner-note { font-size: 12px; color: var(--text-muted); }
.table-note { padding: 12px 20px; margin: 0; font-size: 12px; color: var(--text-muted); border-top: 1px solid var(--border); }

table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
  background: rgba(0,0,0,0.15);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: default;
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text-secondary); }
thead th.sortable.active { color: var(--text-primary); }
.sort-arrow { font-size: 10px; }
tbody td {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr:hover td { background: var(--bg-card-hover); }
tbody tr:last-child td { border-bottom: none; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
thead th.num { text-align: right; }
td.positive { color: var(--green); }
td.negative { color: var(--red); }
td.primary { color: var(--text-primary); font-weight: 500; }

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}
.pagination {
  display: flex;
  gap: 4px;
}
.pagination button {
  padding: 4px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
}
.pagination button:hover { border-color: var(--accent); color: var(--accent); }
.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }
.pagination button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ─── Search & Filters ─── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  min-width: 200px;
}
.filter-input:focus { border-color: var(--accent); }
.filter-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

/* ─── Badges ─── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-green { background: rgba(34,197,94,0.12); color: var(--green); }
.badge-red { background: var(--red-dim); color: var(--red); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); }
.badge-blue { background: rgba(59,130,246,0.12); color: var(--blue); }
.badge-purple { background: rgba(168,85,247,0.12); color: var(--purple); }
.badge-amber { background: rgba(180,83,9,0.18); color: #d97706; }

/* ─── Loading ─── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
  color: var(--text-muted);
  font-size: 14px;
}
.loading::before {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin-right: 10px;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Empty State ─── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ─── Section headings ─── */
.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
  margin-top: 8px;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Account page ─── */
.acct-card { margin-bottom: 20px; }
.acct-body { padding: 20px; }
.acct-form { max-width: 420px; }
/* The create form is wide enough to sit on one row on a desktop, which is the only
   place this app is used. */
.acct-form-row {
  max-width: none;
  display: grid;
  /* auto for the button so it takes only the width of its label, instead of an equal
     share that leaves it stranded in a wide column. */
  grid-template-columns: repeat(4, minmax(160px, 1fr)) auto;
  gap: 0 16px;
  align-items: end;
}
/* Nothing inside a cell may add height below its input, or that column grows and the row
   loses its shared baseline — which is exactly what a hint under the password field did. */
.acct-form-row .form-group { margin-bottom: 16px; }
.acct-form-row .btn-primary { margin-bottom: 16px; white-space: nowrap; }
.acct-form-note {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-muted);
}
.acct-form-note strong { color: var(--text-secondary); font-weight: 600; }

@media (max-width: 1100px) {
  /* Stack rather than squeeze: four fields plus a button need real width. */
  .acct-form-row { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}
.acct-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.acct-note { font-size: 12px; color: var(--text-muted); margin: 12px 0 0; max-width: 60ch; }
.acct-note code { font-size: 11px; background: var(--bg-surface-alt); padding: 1px 4px; border-radius: 3px; }
/* Metrics copied from .form-group input, not approximated: a select 4px shorter than the
   text fields beside it lifts its label off the row's baseline. */
.acct-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}
.acct-select:focus { border-color: var(--accent); }
/* Same rule for both controls, because a select's default line box is ~2px taller than an
   input's at the same font-size and padding — enough to break the row. What the value is
   matters less than that they share it. */
.acct-form-row .form-group input,
.acct-form-row .acct-select { line-height: 1.2; }
/* The in-table role pickers sit in dense rows, where the full-size control is too heavy. */
td .acct-select { padding: 6px 10px; font-size: 13px; }
.acct-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.acct-actions .btn-ghost { padding: 4px 10px; font-size: 12px; }
.acct-you { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.acct-empty { text-align: center; color: var(--text-muted); padding: 24px; }
.acct-ip { color: var(--text-muted); font-size: 11px; }
.acct-msg { display: inline-block; margin-left: 12px; font-size: 12px; }
.acct-msg-ok { color: var(--green); }
.acct-msg-bad { color: var(--red); }
/* A temporary password is one the owner also knows, so this is a real block, not a nag. */
.acct-forced {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
  font-size: 13px;
}

/* ─── Responsive (widescreen optimization) ─── */
@media (min-width: 1600px) {
  .kpi-grid { grid-template-columns: repeat(6, 1fr); }
  .chart-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Responsive (narrow screens) ─── */
.menu-btn { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  /* Sidebar becomes an off-canvas drawer, opened by the header hamburger */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 260px;
    z-index: 20;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,0.45); }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 19;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
  .content { margin-left: 0; width: 100%; }
  .menu-btn { display: inline-flex; }
  /* 16px inputs stop iOS Safari from auto-zooming on focus */
  .form-group input, .date-input, .filter-input, .filter-select { font-size: 16px; }
  /* Header controls wrap onto extra rows instead of overflowing the page */
  .content-header { flex-wrap: wrap; padding: 12px 16px; }
  .content-header h2 { flex: 1; } /* title sits beside the hamburger, not pushed right */
  .header-right { flex-wrap: wrap; flex: 1 1 100%; }
  .date-controls { flex-wrap: wrap; flex: 1; }
  .date-input { flex: 1 1 110px; min-width: 0; }
  .page-content { padding: 16px; }
  /* Toast spans the top of the screen instead of hanging off the right edge */
  .sync-toast { left: 16px; right: 16px; max-width: none; top: 12px; }
  .filter-input { min-width: 0; flex: 1 1 160px; }
}
@media (max-width: 480px) {
  /* Period buttons become a full-width segmented row */
  .period-btns { flex: 1 1 100%; margin-left: 0; }
  .period-btn { flex: 1; padding: 9px 0; }
  .chart-container { height: 220px; }
  .chart-card.wide .chart-container { height: 240px; }
  .filter-input, .filter-select { flex: 1 1 100%; }
}
@media (max-width: 420px) {
  .login-card { padding: 36px 24px; }
}

/* ─── Touch targets (phones/tablets) ─── */
@media (pointer: coarse) {
  .pagination button { padding: 8px 14px; }
  .btn-export { padding: 9px 14px; }
  .theme-toggle { width: 38px; height: 38px; }
  .btn-ghost { padding: 9px 16px; }
  .nav-links a { padding: 12px 14px; }
}

/* ─── Print ─── */
@media print {
  .sidebar, .content-header { display: none !important; }
  .content { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  .chart-card, .table-card, .kpi-card { break-inside: avoid; }
}

/* ─── Transaction row detail (expandable) ─── */
tr.txn-row { cursor: pointer; }
tr.txn-row.expanded td { background: var(--bg-card-hover); }
.txn-detail-row > td { padding: 0 !important; background: var(--bg-card); }
.txn-detail-loading { padding: 14px 16px; color: var(--text-muted); font-size: 13px; }
.txn-detail {
  display: flex; flex-wrap: wrap; gap: 20px;
  padding: 14px 16px; border-left: 3px solid var(--accent);
}
.txd-section { min-width: 200px; }
.txd-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 6px;
}
.txd-kv { display: flex; gap: 8px; font-size: 13px; line-height: 1.7; }
.txd-label { color: var(--text-muted); min-width: 110px; }
.txd-value { color: var(--text-primary); }
.txd-empty { color: var(--text-muted); font-size: 13px; }
.txd-items-table { font-size: 13px; }
.txd-items-table th, .txd-items-table td { padding: 3px 10px 3px 0; }

/* ─── Reconciliation: selection, resolve form, resolved rows ─── */
.recon-check { width: 34px; padding-right: 0 !important; }
.recon-check input { cursor: pointer; width: 15px; height: 15px; vertical-align: middle; }
tr.recon-resolved td { opacity: 0.6; }
tr.txn-row:focus-visible td { outline: none; background: var(--bg-card-hover); box-shadow: inset 0 0 0 1px var(--accent); }
.recon-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); cursor: pointer; margin-left: 4px; }
.recon-toggle:has(input:disabled) { opacity: 0.5; cursor: default; }
.recon-bulk {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 10px 20px; border-bottom: 1px solid var(--border); background: var(--bg-card-hover);
  font-size: 13px; color: var(--text-primary);
}
.recon-bulk-form { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.recon-resolve { display: flex; flex-direction: column; gap: 8px; max-width: 520px; }
.recon-resolve-section { flex: 1 1 320px; }
.recon-reasons { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-primary); }
.recon-reasons label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.recon-resolve textarea {
  width: 100%; padding: 8px 10px; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary); font: inherit; font-size: 13px; resize: vertical;
}
.recon-resolve textarea:focus { outline: none; border-color: var(--accent); }
.recon-hint { font-size: 12px; color: var(--yellow); background: var(--yellow-dim); padding: 6px 10px; border-radius: var(--radius-sm); margin: 0; }
.recon-form-actions { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.recon-error { color: var(--red); font-size: 12px; }
.btn-primary.btn-inline { width: auto; padding: 7px 16px; font-size: 13px; }
/* Table cells are nowrap; the detail panel's prose and form must wrap. */
.recon-detail { white-space: normal; }
.recon-detail .txd-section { max-width: 100%; }
.recon-detail .txd-items-table th { font-size: 11px; color: var(--text-muted); text-align: left; font-weight: 600; }
.recon-detail .txd-items-table td { white-space: nowrap; }
td.cell-clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }

/* ─── Today-at-the-station live strip (dashboard) ─── */
.today-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.today-tile { background: var(--bg-input); border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 12px 14px; }
