/* ==========================================================================
   PAGES — Dashboard, forms, tables toolbar, chart modal, login, extras
   ========================================================================== */

/* ---------------------------------------------------------------------------
   FUEL CARDS (dashboard)
   --------------------------------------------------------------------------- */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4, 16px);
}

@media (max-width: 1280px) { .dash-grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); } }

.fuel-card { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.fc-diesel { border-top: 3px solid var(--fuel-diesel); }
.fc-hfo    { border-top: 3px solid var(--fuel-hfo); }
.fc-lpg    { border-top: 3px solid var(--fuel-lpg); }

.fhead { display: flex; align-items: flex-start; justify-content: space-between; }
.fname { font-size: 15px; font-weight: 700; }
.funit { font-size: 11.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; }
.fuel-value { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.15; }
.fuel-value .max { font-size: 13px; font-weight: 600; color: var(--text-faint); }
.fuel-full { display: block; font-size: 12px; font-weight: 600; color: var(--text-dim); margin-top: 2px; }
.tank-wrap { display: flex; justify-content: center; padding: 4px 0; align-items: center; }
.tank-wrap .tank { width: auto; max-width: 100%; }
.tank-wrap .tank--v { height: 258px; }

/* Instrument typography — liquid surface is static (no animation) */
.tank-tick {
  font-family: var(--font-mono, monospace); font-size: 10px;
  fill: var(--text-faint); font-variant-numeric: tabular-nums;
}
.tank-value {
  font-family: var(--font-mono, monospace); font-size: 28px; font-weight: 800;
  fill: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.3px;
}
.tank-value__unit { font-size: 11px; font-weight: 600; fill: var(--text-dim); letter-spacing: 0; }
.tank-value__label {
  font-family: var(--font-mono, monospace); font-size: 8.5px; font-weight: 700;
  fill: var(--text-faint); letter-spacing: 0.22em;
}
.tank-flag {
  font-family: var(--font-mono, monospace); font-size: 9px; font-weight: 700;
  fill: var(--bad); letter-spacing: 0.14em;
}
.tank-surface { /* static highlight line — animation removed */ }
.fuel-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--text-dim); align-items: center; }
.fuel-meta .ts { color: var(--text-faint); margin-left: auto; }
.low-tag { color: var(--bad); font-weight: 700; }
.forecast-tag { color: var(--text-dim); background: var(--panel-hover); border-radius: 6px; padding: 2px 8px; }
.delta-up { color: var(--good); font-weight: 600; }
.delta-down { color: var(--bad); font-weight: 600; }
.amount-cell { font-weight: 700; font-variant-numeric: tabular-nums; }
.amount-neutral { color: var(--text-dim); }

/* --- data table readability -------------------------------------------- */
td[data-align="right"] { font-variant-numeric: tabular-nums; }

.col-pin {
  appearance: none; background: none; border: 0; padding: 2px; margin-left: auto;
  line-height: 0; cursor: pointer; color: var(--text-faint);
  opacity: 0; transition: opacity 120ms ease, color 120ms ease;
}
th:hover .col-pin, .col-pin:focus-visible { opacity: 0.65; }
.col-pin:hover { opacity: 1 !important; color: var(--accent); }
.col-pin--on, .col-pin--on:hover { opacity: 1; color: var(--accent); transform: rotate(45deg); }

/* ---------------------------------------------------------------------------
   DASHBOARD ACCOUNTING
   --------------------------------------------------------------------------- */
.dash-accounting { margin-top: var(--space-4, 16px); padding: 16px; }
.dash-accounting__head { display: flex; align-items: center; justify-content: space-between; }
.dash-accounting__head h3 { margin: 0; font-size: 14px; }
.dash-accounting__body { margin-top: 12px; overflow-x: auto; }

/* Low Stock Alerts */
.dash-alert { margin-top: var(--space-4, 16px); padding: 16px; border-left: 3px solid var(--warn, #f39c12); }
.dash-alert__head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.dash-alert__head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.dash-alert__icon { display: inline-flex; align-items: center; }
.dash-alert__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.dash-alert__item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; transition: background var(--motion-fast); }
.dash-alert__item:hover { background: var(--panel-hover, rgba(255,255,255,0.04)); }
.dash-alert__name { flex: 1; font-size: 13px; }
.dash-alert__stock { font-size: 12px; }
.dash-alert__min { font-size: 11px; color: var(--text-faint); }

/* KPI chips */
.acct-kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.acct-kpi {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-hover);
}

.acct-kpi__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.acct-kpi__value {
  font-family: var(--font-mono);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

/* Desktop table */
.acct-table th {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.acct-table td.num,
.acct-table td[data-align="right"] {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.acct-fuel {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  padding: 2px 7px;
  border-radius: 5px;
}

.acct-fuel--diesel { color: var(--fuel-diesel); background: var(--fuel-diesel-bg); }
.acct-fuel--hfo { color: var(--fuel-hfo); background: var(--fuel-hfo-bg); }
.acct-fuel--lpg { color: var(--fuel-lpg); background: var(--fuel-lpg-bg); }

.acct-table tfoot td {
  border-top: 1px solid var(--border-strong);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  padding-top: 9px;
}

.acct-note { margin: 10px 0 0; font-size: 12px; }

/* Mobile card list (hidden on desktop) */
.acct-list { display: none; }

@media (max-width: 640px) {
  .acct-kpi { flex: 1 1 40%; }

  /* Table is unusable at phone width — swap to stacked line items */
  .acct-table-wrap { display: none; }
  .acct-list { display: flex; flex-direction: column; gap: 8px; }

  .acct-item {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-hover);
  }

  .acct-item__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
  }

  .acct-item__date {
    font-size: 12px;
    color: var(--text-faint);
    font-family: var(--font-mono);
  }

  .acct-item__mid {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
  }

  .acct-item__mid strong { font-size: 15px; color: var(--text); }

  .acct-item__meta {
    margin-top: 5px;
    font-size: 12px;
    color: var(--text-faint);
  }

  .acct-item--total {
    background: var(--accent-bg);
    border-color: var(--accent-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--accent);
  }
}

.acct-table th, .acct-table td { white-space: nowrap; }

/* ---------------------------------------------------------------------------
   FORM CARDS (diesel / gauge entry)
   --------------------------------------------------------------------------- */
.form-card { padding: 20px; display: flex; flex-direction: column; gap: 14px; max-width: 720px; }
.form-card__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.form-card__head h3 { margin: 0; font-size: 16px; }
.form-card__balance { font-size: 13px; color: var(--text-dim); }
.form-card__balance strong { color: var(--fuel-diesel); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------------------
   TABLE TOOLBAR + FROZEN COLUMNS
   --------------------------------------------------------------------------- */
.table-card { position: relative; padding: 0; overflow: hidden; }

/* While selecting, extra scroll room is added BELOW the last row so any
   record can be scrolled fully clear of the floating bulk bar. */
/* (bulk bar is now in-flow, no padding needed) */

/* Wrapped text cells (notes/details): up to two lines, no horizontal blowout */
.cell-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  word-break: break-word;
  line-height: 1.45;
  max-width: 340px;
}
.table-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.table-toolbar__count { font-size: 12.5px; color: var(--text-faint); flex-shrink: 0; white-space: nowrap; }
.log-filters { display: flex; gap: 8px; align-items: center; }

/* ==========================================================================
   FILTER CHIPS — professional filter bar above tables (Baserow/Airtable style)
   Each filter is a pill-shaped chip with icon + label + dropdown chevron.
   Active filters get an accent tint. Clicking opens a dropdown/popover.
   ========================================================================== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0;
  flex: 1 1 0;
  min-width: 0;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  white-space: nowrap;
  user-select: none;
  flex-shrink: 1;
  min-width: 0;
}
.filter-chip:hover {
  border-color: var(--border-strong, var(--border));
  background: var(--panel-hover);
}
.filter-chip--active {
  border-color: var(--accent-border);
  background: var(--accent-bg);
  color: var(--accent);
}
.filter-chip__icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0.6;
}
.filter-chip--active .filter-chip__icon { opacity: 1; }
.filter-chip__label { line-height: 1; }
.filter-chip__chevron {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0.4;
  font-size: 10px;
  transition: transform 0.15s;
}
.filter-chip--active .filter-chip__chevron { opacity: 0.7; }
/* Date inputs inside chips */
.filter-chip input[type="date"] {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 12px;
  padding: 0;
  width: 90px;
  outline: none;
  color-scheme: dark;
}
.filter-chip input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0.4;
  cursor: pointer;
  filter: invert(0.7);
}
.filter-chip select {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 12px;
  padding: 0;
  outline: none;
  cursor: pointer;
  max-width: 100px;
  color-scheme: dark;
}
.filter-chip select option {
  background: var(--bg-elevated);
  color: var(--text);
}
.filter-clear {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  gap: 4px;
  height: 30px;
  padding: 0 8px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-faint);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-clear:hover {
  border-color: var(--bad);
  color: var(--bad);
  background: rgba(255, 93, 84, 0.06);
}

.table-scroll { overflow: auto; max-height: calc(100vh - 220px); position: relative; -webkit-overflow-scrolling: touch; }
.table-inner { position: relative; }
.table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 100%; }
/* thead acts as a sticky rail — always on top of frozen cells and group headers */
.table thead {
  position: sticky; top: 0; z-index: 30;
}
.table thead th {
  background: var(--bg-elevated);
  border-bottom: 2px solid var(--border);
  padding: 0; text-align: left;
}
.table thead th.th-frozen {
  position: sticky; left: var(--frozen-left, 0);
  z-index: 31;
}
.th-content { display: flex; align-items: center; gap: 6px; padding: 10px 12px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); user-select: none; }
.field__req { color: var(--bad); font-weight: 700; margin-left: 1px; }
.th-sort { display: inline-flex; align-items: center; justify-content: center; color: var(--accent); }
.th-sort .th-sort-ico { display: block; }
.th-sort--idle { color: var(--text-faint); opacity: 0; transition: opacity var(--t-fast, 0.12s) ease; }
th:hover .th-sort--idle, th:focus-within .th-sort--idle { opacity: 0.7; }
th[data-align="right"] .th-content, td[data-align="right"] { justify-content: flex-end; text-align: right; }
td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.12s ease;
}
/* Hover — soft accent tint */
tbody tr:hover td:not(.td-group-date) {
  background: var(--accent-bg);
}

.col-resizer {
  position: absolute; right: -3px; top: 0; bottom: 0; width: 7px;
  cursor: col-resize; z-index: 5; touch-action: none;
}
.col-resizer:hover { background: linear-gradient(90deg, transparent, var(--fuel-diesel)); opacity: .4; }

.th-frozen, .td-frozen {
  position: sticky; left: var(--frozen-left, 0);
}
/* Frozen data cells — below thead (30) and group headers (15) */
.table tbody td.td-frozen {
  z-index: 5;
  background: var(--panel) !important;
}
tbody tr:hover .td-frozen {
  background: var(--panel) !important;
}

.th-frozen::after, .td-frozen::after {
  content: ''; position: absolute; top: 0; right: -1px; bottom: -1px; width: 1px;
  background: var(--border);
}
.th-frozen::before, .td-frozen[data-frozen-order]:not(:last-child)::before { content: none; }
.th-frozen:last-child::after, .td-frozen:last-of-type::after { box-shadow: 6px 0 8px -4px rgba(0,0,0,.45); }

.table-empty { padding: 48px 24px; text-align: center; color: var(--text-faint); }
.table-card--fill .table-empty { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.table-empty__icon { font-size: 34px; margin-bottom: 8px; opacity: .5; }
.table-empty__title { font-weight: 700; color: var(--text-dim); }
.table-empty__sub { font-size: 12.5px; }

/* ---------------------------------------------------------------------------
   TABLE CARD CONTAINMENT — the bordered card ALWAYS matches the visible
   content width and never exceeds the viewport edge; all horizontal panning
   happens INSIDE (.table-scroll / .table-wrap), like a normal table.
   --------------------------------------------------------------------------- */
.card { min-width: 0; max-width: 100%; }
.page > * { min-width: 0; max-width: 100%; }

/* ---------------------------------------------------------------------------
   TABLE FLUID SCALE (phones & small tablets) — placed AFTER the base table
   rules so the fluid values win the cascade at equal specificity.
   Values are CONTINUOUS functions of viewport width — no breakpoint jump:
   every clamp() equals the desktop value at ~1024px and eases down to the
   smallest-phone floor at ~330px. Freezing stays ON throughout. Rows
   auto-size based on content with uniform cell padding.
   --------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .table { font-size: clamp(10px, calc(6.8px + 0.97vw), 13px); }

  .th-content {
    padding: clamp(5px, calc(2.9px + 0.65vw), 7px);
    font-size: clamp(8.5px, calc(6.4px + 0.65vw), 10.5px);
    gap: 3px;
  }

  td {
    padding: clamp(3px, calc(0.9px + 0.65vw), 5px) clamp(4px, calc(0.8px + 0.97vw), 7px);
    font-size: inherit;
    max-width: clamp(150px, calc(79px + 22.6vw), 220px);
  }


  .cell-clamp { max-width: clamp(120px, calc(67px + 16.1vw), 170px); line-height: 1.3; }

  /* Frozen timestamp column narrows with the screen (beats inline widths) */
  .table thead th[data-key="ts"] {
    width: clamp(56px, calc(30px + 10vw), 120px) !important;
    min-width: clamp(56px, calc(30px + 10vw), 120px) !important;
  }
}

/* Touch extras on phones */
@media (max-width: 640px) {
  .col-resizer { width: 9px; } /* easier grab target on touch */

  .table-toolbar { padding: 8px 10px; }

  /* Let the slim timestamp wrap onto two short lines instead of clipping */
  .table tbody td:first-child { white-space: normal; }
}

/* ---------------------------------------------------------------------------
   LOG PAGE
   --------------------------------------------------------------------------- */
.dot { display: inline-block; flex: none; box-sizing: border-box; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }
.dot--diesel { background: var(--fuel-diesel); }
.dot--hfo { background: var(--fuel-hfo); }
.dot--lpg { background: var(--fuel-lpg); }
.dot--system { background: var(--text-faint); }

.field__control-input, .field__control-select {
  height: 36px; padding: 0 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel);
  color: var(--text); font-size: 13px; font-family: inherit;
}
.field__control-input:focus, .field__control-select:focus { outline: none; border-color: var(--fuel-diesel); }

/* ---------------------------------------------------------------------------
   DATA & BACKUP PAGE
   --------------------------------------------------------------------------- */
.data-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--space-4, 16px); align-items: start; align-content: start; }
.data-card { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.data-card h3 { margin: 0; font-size: 15px; }
.data-card__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.data-card--danger { border-color: rgba(229, 72, 77, .35); }
.integrity-result { font-size: 13px; }
.integrity-ok { color: var(--good); font-weight: 600; }
.integrity-bad { color: var(--bad); }
.integrity-bad ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------------------------------------------------------------------------
   CHART MODAL
   --------------------------------------------------------------------------- */
.chart-controls { display: flex; gap: 6px; margin-bottom: 14px; }
.chart-preset--active { background: var(--fuel-diesel-bg); border-color: var(--fuel-diesel-border); color: var(--fuel-diesel); }
.chart-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; margin-bottom: 14px; }
.chart-stat { background: var(--panel-hover); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.chart-stat__label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); }
.chart-stat__value { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-stat--empty { grid-column: 1 / -1; color: var(--text-dim); }
.chart-canvas-wrap { border: 1px solid var(--border); border-radius: 10px; padding: 10px; background: var(--panel); }
.chart-tick { fill: var(--text-faint); font-size: 9.5px; font-family: inherit; }
.chart-unit { font-weight: 700; }
.chart-forecast { margin-top: 12px; font-size: 13px; color: var(--text-dim); }
.chart-forecast__row { display: flex; flex-direction: column; gap: 4px; }
.chart-forecast strong { color: var(--fuel-diesel); }
.chart-empty { padding: 40px; text-align: center; color: var(--text-faint); }

/* ---------------------------------------------------------------------------
   LOGIN — Professional Design
   --------------------------------------------------------------------------- */
.login-overlay {
  position: fixed; inset: 0; z-index: var(--z-modal, 300);
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 16px;
  overflow: hidden;
}

.login-container {
  position: relative;
  width: 100%;
  max-width: 420px;
}

.login-glow {
  position: absolute;
  top: -120px;
  left: 50%;
  transform: translateX(-50%);
  width: 400px;
  height: 300px;
  background: radial-gradient(ellipse at center, rgba(10, 132, 255, 0.12) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 36px 32px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(10, 132, 255, 0.08);
}

.login-card--shake {
  animation: loginShake 0.5s ease-in-out;
}

@keyframes loginShake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}

/* Logo */
.login-logo-section {
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
}

.login-logo-ring {
  width: 72px;
  height: 72px;
  border-radius: 50%;
background: linear-gradient(135deg, rgba(10, 132, 255, 0.18), rgba(0, 122, 255, 0.06));
  border: 1px solid rgba(10, 132, 255, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.login-logo-ring::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid rgba(10, 132, 255, 0.12);
}

.login-logo-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
background: linear-gradient(135deg, #409cff, #0063d6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--on-accent);
}

/* Header */
.login-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.login-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.login-subtitle {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-faint);
  line-height: 1.5;
}

/* Error */
.login-error {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(255, 93, 84, 0.1);
  border: 1px solid rgba(255, 93, 84, 0.3);
  color: var(--bad);
  font-size: 13px;
  font-weight: 500;
}

.login-error svg {
  flex-shrink: 0;
}

/* Field */
.login-field {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.login-field__label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.login-field__input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.login-field__icon {
  position: absolute;
  left: 14px;
  color: var(--text-faint);
  pointer-events: none;
  transition: color var(--motion-fast);
}

.login-field__input-wrap:focus-within .login-field__icon {
  color: var(--accent);
}

.login-field__input {
  width: 100%;
  height: 46px;
  padding: 0 16px 0 44px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 15px;
letter-spacing: 0.5px;
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast), background var(--motion-fast);
}

.login-field__input:hover {
  border-color: var(--input-border-hover);
}

.login-field__input:focus {
outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
  background: var(--panel-hover);
}

.login-field__input::placeholder {
  color: var(--text-faint);
  opacity: 0.5;
}

/* Remember me */
.login-remember {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.login-remember__checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border-strong);
  border-radius: 5px;
  background: var(--input-bg);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: border-color var(--motion-fast), background var(--motion-fast);
}

.login-remember__checkbox:hover {
  border-color: var(--accent-border);
}

.login-remember__checkbox:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.login-remember__checkbox:checked::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / 11px no-repeat;
}

.login-remember__checkbox:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.login-remember__text {
  font-size: 13px;
  color: var(--text-dim);
}

/* Submit button */
.login-btn {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
background: linear-gradient(135deg, #409cff, #0063d6);
  color: var(--on-accent);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform var(--motion-fast), box-shadow var(--motion-fast), opacity var(--motion-fast);
  position: relative;
  overflow: hidden;
}

.login-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
  opacity: 0;
  transition: opacity var(--motion-fast);
}

.login-btn:hover::before {
  opacity: 1;
}

.login-btn:hover {
  box-shadow: 0 6px 20px rgba(10, 132, 255, 0.35);
  transform: translateY(-1px);
}

.login-btn:active {
  transform: translateY(0) scale(0.98);
}

.login-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.login-btn--loading {
  pointer-events: none;
}

.login-btn__text,
.login-btn__spinner {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-spinner {
  animation: loginSpin 0.8s linear infinite;
}

@keyframes loginSpin {
  to { transform: rotate(360deg); }
}

/* Footer */
.login-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-faint);
  opacity: 0.6;
}

.login-footer__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--good);
}

/* Mobile login */
@media (max-width: 640px) {
  .login-card {
    padding: 28px 20px 24px;
    border-radius: 12px;
  }
  .login-logo-ring { width: 60px; height: 60px; }
  .login-logo-icon { width: 44px; height: 44px; }
  .login-logo-icon svg { width: 24px; height: 24px; }
  .login-title { font-size: 19px; }
  .login-field__input { height: 44px; font-size: 16px; }
  .login-btn { height: 46px; }
}

/* ---------------------------------------------------------------------------
   SHARED EXTRAS
   --------------------------------------------------------------------------- */
.muted { color: var(--text-faint); font-size: 13px; }
.form-error {
  background: rgba(229,72,77,.12); border: 1px solid rgba(229,72,77,.4);
  color: var(--bad); border-radius: 8px; padding: 8px 12px; font-size: 13px; margin-bottom: 10px;
}
.badge--info { background: var(--info-bg); color: var(--info); }
.table .badge::before {
  content: ''; display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: currentColor; margin-right: 6px;
  vertical-align: 1px;
}
.dropdown__menu--fixed { position: fixed; display: block; }
.dropdown__sep { height: 1px; background: var(--border); margin: 4px 6px; }

@media (prefers-reduced-motion: reduce) {
  .tank-wrap .tank * { animation: none !important; }
}
/* ============================================================
   MOBILE — phones (≤ 640px)
   ============================================================ */
/* ============================================================================
   PHONE TABLE COMPACT MODE (≤ 640px) — Aggressive downscaling
   Makes tables comfortable to read and use on small screens.
   ========================================================================== */
@media (max-width: 640px) {
  .card { padding: 12px; }
  .form-card__head { flex-direction: column; align-items: flex-start; gap: 4px; }
  .form-card__balance { font-size: 11px; }
  .form-card__balance strong { font-size: 12px; }
  #content { padding: 10px 8px 20px; }

  /* Table: ultra-compact font sizes */
  .table { font-size: 10px; }
  .table th { font-size: 8.5px; }
  .table td { font-size: 10px; padding: 3px 5px; max-width: 100px; }

  /* Table header content */
  .th-content {
    padding: 5px 6px;
    font-size: 8px;
    gap: 2px;
  }
  .th-content .th-label { font-size: 8px; }
  .th-content .th-sort { font-size: 7px; }
  .th-content .col-pin { width: 10px; height: 10px; }
  .th-content .col-pin svg { width: 9px; height: 9px; }

  /* Frozen timestamp: slim column with 2-line wrap */
  .table thead th[data-key="ts"] {
    width: 56px !important;
    min-width: 56px !important;
  }
  .table tbody td:first-child {
    white-space: normal;
    word-break: break-word;
    line-height: 1.3;
    font-size: 9px;
    max-width: 62px;
  }

  /* Mobile mode bar: replaces per-row actions on phone */
  .mobile-mode-bar {
    display: flex;
    gap: 6px;
    padding: 8px 0 2px;
    justify-content: center;
  }
  .mobile-mode-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--panel);
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
  }
  .mobile-mode-btn svg { flex-shrink: 0; }
  .mobile-mode-btn--active {
    background: var(--accent-bg);
    color: var(--accent);
    border-color: var(--accent-border);
    box-shadow: 0 0 0 2px var(--accent-bg);
  }
  /* Edit mode: rows get pointer cursor */
  .table-wrap--edit-mode .table tbody tr { cursor: pointer; }
  .table-wrap--edit-mode .table tbody tr:active { background: var(--accent-bg); }
  /* Select mode: rows get pointer cursor + subtle feedback */
  .table-wrap--select-mode .table tbody tr { cursor: pointer; }
  .table-wrap--select-mode .table tbody tr:active { background: var(--accent-bg); }

  /* Table toolbar */
  .table-toolbar {
    padding: 6px 8px;
    gap: 6px;
    flex-wrap: wrap;
  }
  .table-toolbar__count {
    font-size: 10px;
    width: 100%;
    order: 3;
  }
  .table-toolbar__actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
    gap: 6px;
  }
  .table-toolbar__actions .btn--sm {
    height: 26px;
    padding: 0 8px;
    font-size: 10px;
  }

  /* Log filters compact */
  .log-filters {
    flex-wrap: wrap;
    row-gap: 4px;
    gap: 4px;
  }
  .log-filters .field__control-input,
  .log-filters .field__control-select {
    height: 30px;
    font-size: 11px;
    padding: 0 8px;
    min-width: 0;
    flex: 1 1 auto;
  }

  /* Badge compact */
  .badge {
    font-size: 8px;
    padding: 1px 4px;
    letter-spacing: 0.02em;
  }
  .badge::before {
    width: 4px;
    height: 4px;
    margin-right: 3px;
  }

  /* Cell clamp tighter */
  .cell-clamp {
    max-width: 80px;
    font-size: 9px;
    line-height: 1.3;
  }

  /* Bulk bar compact */
  .bulk-bar {
    padding: 6px 8px 6px 12px;
    gap: 8px;
    border-radius: 0 0 8px 8px;
  }
  .bulk-bar__count { font-size: 10px; }
  .bulk-bar .btn--sm {
    height: 26px;
    padding: 0 8px;
    font-size: 10px;
  }

  /* Selected row more subtle */
.table tbody tr.tr--selected td {
    background: var(--accent-bg) !important;
  }
  .table tbody tr.tr--selected td:first-child {
    box-shadow: inset 2px 0 0 var(--accent);
  }

  /* Row height: natural on mobile */
  .table tbody tr { height: auto !important; }

  /* Fuel card stats tighter */
  .stat-chips { gap: 6px; }
  .chip { padding: 5px 8px; }
  .chip dt { font-size: 8px; }
  .chip dd { font-size: 11px; }

  /* Tank gauge smaller */
  .tank-wrap .tank--v { height: 180px; }
  .tank-value { font-size: 20px; }
  .tank-tick { font-size: 8px; }
  .tank-value__label { font-size: 7px; }
  .tank-flag { font-size: 7px; }

  /* Activity list compact */
  .activity-item { font-size: 11px; padding: 6px 2px; gap: 6px; }
  .act-fuel { font-size: 9px; min-width: 0; }
  .act-ref { font-size: 9px; }

  /* Burn panel compact */
  .burn-stats { gap: 6px; }
  .burn-stats dt { font-size: 8px; }
  .burn-stats dd { font-size: 11px; }
  .share-legend { gap: 6px 12px; }
  .share-legend li { font-size: 11px; }

  /* Chart stats compact */
  .chart-stats { grid-template-columns: repeat(2, 1fr) !important; gap: 6px; }
  .chart-stat { padding: 6px 8px; min-width: 0; }
  .chart-stat__label { font-size: 8px; }
  .chart-stat__value { font-size: 11px; }

  /* Modal bottom sheet on phones */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal, .modal[style] {
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 92dvh;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
  }
  .modal__body { padding: 14px 14px; }
  .modal__header { padding: 12px 14px; }
  .modal__footer { padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); }

  /* Form fields in modals */
  .field__control input, .field__control select,
  .field__control textarea { font-size: 16px; }
  .form { gap: 10px; }
  .field { min-width: 0; }
  .field__label { font-size: 9px; }
  .field__input, .field__select { height: 38px; font-size: 13px; }

  /* Buttons in modals */
  .btn--lg { width: 100%; height: 42px; }
}

/* ==========================================================================
   GROUPED TABLE — sticky date label rows (all screens)
   Each day group gets a sticky header that pins below the column header
   and pushes the previous day's header out of view when scrolling.
   ========================================================================== */
/* ==========================================================================
   GROUP DATE BANNERS — full-width sticky rows between day groups
   Single <td colspan> so no empty spacer cells. Sits below thead but above
   data rows. Background matches panel so it never looks transparent.
   ========================================================================== */
.tr--group-header {
  position: sticky;
  top: var(--thead-h, 0);
  z-index: 14;
}
.tr--group-header td {
  padding: 0;
  border-bottom: none;
}
.tr--group-header td.td-group-date {
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  left: 0;
  z-index: 29;
  width: 100%;
  padding: 4px 14px;
  background: var(--panel);
  border-left: 3px solid var(--accent);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tr--group-header td.td-group-date::after {
  content: attr(data-count);
  font-weight: 400;
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: normal;
  margin-left: auto;
  flex-shrink: 0;
}

/* ============================================================================
   DASHBOARD v2 — fleet strip, tank cards, burn panel, activity feed
   ========================================================================== */
.dot--bad { background: var(--bad); }
.dot--dispenser { background: var(--fuel-diesel); }
.dot--generator {
  background: repeating-linear-gradient(135deg,
    var(--fuel-diesel) 0 2px, transparent 2px 4px);
}

.fuel-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.fuel-card__name { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: .02em; }
.fuel-card__unit { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); }
.fuel-card__badges { display: flex; align-items: center; gap: 6px; }

.fuel-sub { font-size: 12px; color: var(--text-faint); margin-top: -6px; }
.fuel-empty-hint { font-size: 13px; color: var(--text-faint); text-align: center; margin: 0; }
.fuel-meta-row { display: flex; flex-wrap: wrap; gap: 6px; min-height: 24px; }
.fuel-meta-row:empty { display: none; }

.trend-chip {
  font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 99px;
  border: 1px solid var(--border);
}
.trend-chip--up { color: var(--bad); border-color: rgba(255, 93, 84, .35); background: rgba(255, 93, 84, .08); }
.trend-chip--down { color: var(--good); border-color: rgba(88, 201, 107, .35); background: rgba(88, 201, 107, .08); }

.stat-chips {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  margin: 0; padding: 0;
}
.chip {
  background: var(--panel-hover); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 10px; display: flex; flex-direction: column; gap: 1px;
  min-width: 0;
}
.chip dt { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint); }
.chip dd {
  margin: 0; font-size: 13px; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.spark-block { margin-top: 2px; }
.spark-block__label {
  display: block; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-faint); margin-bottom: 2px;
}

.low-strip {
  padding: 9px 12px; border-radius: 6px; font-size: 13px; font-weight: 600;
  color: var(--bad); background: rgba(255, 93, 84, .09);
  border: 1px solid rgba(255, 93, 84, .38);
}

.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-head h3 { margin: 0; font-size: 14px; }
.panel-head__sum { font-size: 13px; font-weight: 600; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.burn-panel { margin-top: var(--space-4, 16px); padding: 16px; }
.share-bar {
  display: flex; height: 12px; border-radius: 6px; overflow: hidden;
  background: var(--panel-hover); border: 1px solid var(--border);
}
.share-fill { display: block; height: 100%; min-width: 0; transition: width .45s ease; }
.share-fill--dispenser { background: var(--fuel-diesel); }
.share-fill--generator {
  background: repeating-linear-gradient(135deg,
    var(--fuel-diesel) 0 5px, rgba(19, 17, 16, 0) 5px 10px);
}
.share-legend {
  list-style: none; margin: 10px 0 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 8px 20px;
}
.share-legend li { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-dim); }
.share-legend strong { color: var(--text); font-variant-numeric: tabular-nums; }
.share-legend em { font-style: normal; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.burn-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin: 14px 0 0; padding-top: 14px; border-top: 1px solid var(--border);
}
.burn-stats > div { display: flex; flex-direction: column; gap: 2px; }
.burn-stats dt { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint); }
.burn-stats dd { margin: 0; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }

.activity-panel { margin-top: var(--space-4, 16px); padding: 16px; }
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 2px; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.activity-item:last-child { border-bottom: 0; }
.act-kind { flex-shrink: 0; }
.act-ref { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.act-fuel {
  flex: none; min-width: 56px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
}
.act-fuel--diesel { color: var(--fuel-diesel); }
.act-fuel--hfo { color: var(--fuel-hfo); }
.act-fuel--lpg { color: var(--fuel-lpg); }
.act-fuel--system { color: var(--text-faint); }
.act-ts { margin-left: auto; color: var(--text-faint); white-space: nowrap; }

@media (max-width: 640px) {
  .stat-chips { grid-template-columns: repeat(2, 1fr); }
  .burn-stats { grid-template-columns: 1fr 1fr; }
  .activity-item { flex-wrap: wrap; row-gap: 2px; }
  .act-ts { width: 100%; margin-left: 18px; }
}
.table-toolbar__actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }

@media (max-width: 640px) {
  .tank-wrap .tank--v { height: 224px; }
  .act-fuel { min-width: 0; }
  .table-toolbar__actions { width: 100%; margin-left: 0; justify-content: flex-end; }
}
@media (max-width: 640px) {
  .table-toolbar { flex-wrap: wrap; row-gap: 8px; }
  .log-filters { flex-wrap: wrap; row-gap: 6px; }
  .table-toolbar__count { width: 100%; order: 3; }
}

/* ==========================================================================
   SECTION HEADERS — divider between grouped sub-tables in history view
   ========================================================================== */
#dieselSections, #gaugeSections {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.history-section {
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* Expanded section fills remaining space */
.history-section:not(.history-section--collapsed) {
  flex: 1 1 0;
  min-height: 0;
}
/* Collapsed sections are compact and stick to the bottom */
.history-section--collapsed {
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  z-index: 10;
  background: var(--panel);
}
.history-section:first-child {
  border-top: none;
}
.history-section .table-wrap {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}
.history-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 6px;
  position: relative;
  display: block;
  flex-wrap: wrap;
  flex-direction: row;
  justify-content: flex-start;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}
.history-section-header:hover {
  color: var(--accent);
}
.history-section-header::before {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.2s;
  flex-shrink: 0;
}
.history-section--collapsed .history-section-header::before {
  transform: rotate(0deg);
}
.history-section:not(.history-section--collapsed) .history-section-header::before {
  transform: rotate(90deg);
}
.history-section-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.history-section-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  text-transform: none;
  letter-spacing: 0;
}
.history-section--collapsed > div:not(.history-section-header) {
  display: none;
}

[hidden] { display: none !important; }

/* ==========================================================================
   CHECKBOX (merged into first-column) + PEN COLUMN (right edge)
   Checkbox lives inside the first column cell (timestamp), not a separate col.
   Pen: sticky right, hover-reveal.
   ========================================================================== */
/* --- Inline checkbox inside first column cell --- */
th:first-child .row-check--all,
td:first-child .row-check {
  position: relative;
  margin-right: 6px;
  vertical-align: middle;
}
th:first-child .th-content {
  gap: 5px;
}
td:first-child .row-check {
  margin-top: -1px;
}

/* --- Row actions viewport (sticky right in .table-scroll, hover-reveal) --- */
.actions-viewport {
  position: absolute;
  right: 0;
  top: 0;
  z-index: 20;
  width: 56px;
  pointer-events: none;
}
.actions-viewport .row-actions {
  position: absolute;
  right: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 6px;
  border-radius: 6px;
  background: transparent;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  white-space: nowrap;
}
.actions-viewport .row-actions svg {
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.7)) drop-shadow(0 0 2px rgba(0,0,0,0.5));
}
.actions-viewport .row-actions:hover,
.actions-viewport .row-actions.row-actions--visible {
  opacity: 1;
  pointer-events: auto;
}
.actions-viewport .row-actions:hover .row-btn,
.actions-viewport .row-actions.row-actions--visible .row-btn {
  background: rgba(0, 0, 0, 0.8);
}
.actions-viewport .row-actions .row-btn {
  flex-shrink: 0;
}

/* Touch: always show actions (no hover on touch) */
@media (hover: none) {
  .actions-viewport .row-actions { opacity: 1; pointer-events: auto; }
}

/* Mobile: hide actions viewport — mode bar replaces per-row actions */
@media (max-width: 640px) {
  .actions-viewport { display: none !important; }
}

/* Select-all checkbox in header */
.row-check--all {
  appearance: none; -webkit-appearance: none;
  width: 14px; height: 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: 3px;
  background: var(--input-bg);
  cursor: pointer;
  position: relative;
  opacity: 1 !important;
}
.row-check--all:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.row-check--all:checked::after {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231a1408' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / 10px no-repeat;
}
/* Zebra for action cells */
/* (check + pen cells have their own zebra rules above) */

.row-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  opacity: 0;
  flex-shrink: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.row-btn:hover {
  background: rgba(255,255,255,0.08);
}
.row-btn svg {
  width: 15px;
  height: 15px;
}

/* Themed checkbox — tiny like BeeBook (14px) */
.row-check {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 3px;
  background: var(--input-bg);
  cursor: pointer;
  position: relative;
  opacity: 0;
  transition: opacity 0.15s ease, border-color 0.15s ease,
              background 0.15s ease, box-shadow 0.15s ease;
}

.row-check:hover {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.row-check:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.row-check:checked::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231a1408' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / 9px no-repeat;
}

.row-check:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-bg);
  border-color: var(--accent-border);
}

/* Reveal on row hover; checked boxes always visible */
.table tbody tr:hover .row-btn,
.table tbody tr:hover .row-check,
.table tbody tr:focus-within .row-btn,
.table tbody tr:focus-within .row-check { opacity: 1; }
.actions-viewport .row-actions--visible .row-btn { opacity: 1; }

.table-wrap--has-selection .row-check,
.table tbody tr.tr--selected .row-check { opacity: 1; }

/* Touch: always show actions (no hover on touch) */
@media (hover: none) {
  .table tbody tr .row-btn,
  .table tbody tr .row-check { opacity: 1; }
  .actions-viewport .row-btn { opacity: 1; }
}

.row-btn--edit:hover {
  color: var(--accent);
}
.row-btn--view:hover {
  color: var(--info);
}

/* Checked rows — subtle amber tint with left accent edge */
.table tbody tr.tr--selected td {
  background: var(--accent-sel) !important;
}
.table tbody tr.tr--selected td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

/* Bulk action bar — sits in flow below the table, never overlaps records.
   Matches the BeeBook pattern: dock appears below the last visible row. */
.bulk-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 100%;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  border-radius: 0 0 10px 10px;
  background: var(--panel);
  animation: bulkIn var(--motion-base) both;
}

@keyframes bulkIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Hovering the record strip covered by the dock ghosts it out (transparent +
   click-through, see bulkDockGhost()); any other part of the dock — including
   the half hanging over empty clearance space — stays solid & clickable. */
.bulk-bar { transition: opacity var(--motion-fast); }
.bulk-bar--ghost { opacity: 0.18; pointer-events: none; }

/* ---------------------------------------------------------------------------
   FULL-HEIGHT HISTORY TABLES
   Pages stretch to fill the visible content area and history cards absorb the
   leftover height: the toolbar stays put and rows scroll INSIDE the card all
   the way to the bottom of the viewport.
   --------------------------------------------------------------------------- */
/* Content + page form a flex column that fills the viewport.
   When a .table-card--fill is present, the page fills the content and
   the table-scroll absorbs all remaining height so rows scroll internally
   while the header stays sticky at the top.
   Non-fill pages (dashboard, entry forms) scroll via overflow-y on .page. */
.content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;   /* non-fill pages scroll here */
  overflow-x: hidden;
}

/* Fill pages: page doesn't scroll — table-scroll handles it */
.page:has(.table-card--fill) {
  overflow: hidden;
}

.table-card--fill {
  flex: 1 1 0;
  min-height: 0;    /* was 320px — now shrinks to fit */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.table-card--fill .table-toolbar { flex-shrink: 0; }
.table-card--fill .bulk-bar { flex-shrink: 0; }

/* Flex chain: card → mount div → table-wrap → table-scroll must all flex-grow.
   The history summary bar must NOT grow — it stays compact at the top or it
   stretches into a huge empty field above the table. */
.table-card--fill > div:not(.table-toolbar):not(.bulk-bar):not(.table-empty):not(.history-summary) {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.table-card--fill .history-summary {
  flex: 0 0 auto;
}
.table-card--fill .table-wrap {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;  /* clips sticky pen column */
  border: none;       /* card already has border */
  border-radius: 0;   /* card already has radius */
  background: transparent;
}
.table-card--fill .table-scroll {
  flex: 1 1 0;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: auto;
}


.bulk-bar__count {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.bulk-bar__actions {
  display: flex;
  gap: 8px;
}

/* Record detail view (simple modal for non-delivery records) */
.record-detail { padding: 8px 16px 4px; }
.record-detail__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
  gap: 16px;
}
.record-detail__row:last-child { border-bottom: none; }
.record-detail__label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-faint);
  flex-shrink: 0;
}
.record-detail__value {
  font-size: 13px;
  color: var(--text);
  text-align: right;
  word-break: break-word;
}

/* ==========================================================================
   CATEGORY TREE
   ========================================================================== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 0 4px;
}

.page-header__title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.page-header__subtitle {
  font-size: 13px;
  color: var(--text-faint);
  margin: 2px 0 0;
}

.page-header__info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.page-header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
}

.btn__icon svg {
  width: 16px;
  height: 16px;
}

/* Tree container */
.category-tree {
  padding: 8px 0;
}

.category-tree__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.category-tree__list .category-tree__list {
  padding-left: 24px;
}

/* Tree item */
.category-tree__item {
  margin: 0;
  padding: 0;
}

.category-tree__item.collapsed > .category-tree__list {
  display: none;
}

/* Tree row */
.category-tree__row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-soft);
  transition: background var(--motion-fast);
}

.category-tree__row:hover {
  background: var(--panel-hover);
}

.category-tree__item:last-child > .category-tree__row {
  border-bottom: none;
}

/* Toggle button */
.category-tree__toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: transform var(--motion-fast), color var(--motion-fast);
  flex-shrink: 0;
}

.category-tree__toggle:hover {
  color: var(--text);
}

.category-tree__toggle svg {
  width: 14px;
  height: 14px;
}

.category-tree__item.collapsed > .category-tree__row .category-tree__toggle {
  transform: rotate(-90deg);
}

/* Spacer for leaf nodes */
.category-tree__spacer {
  width: 20px;
  flex-shrink: 0;
}

/* Icon */
.category-tree__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--accent);
  flex-shrink: 0;
}

.category-tree__icon svg {
  width: 16px;
  height: 16px;
}

/* Name */
.category-tree__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}

/* Description */
.category-tree__desc {
  font-size: 12px;
  color: var(--text-faint);
  margin-left: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

/* Product count badge */
.category-tree__count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  background: var(--panel-hover);
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

/* Action buttons */
.category-tree__actions {
  display: flex;
  gap: 4px;
  margin-left: 8px;
  opacity: 0;
  transition: opacity var(--motion-fast);
  flex-shrink: 0;
}

.category-tree__row:hover .category-tree__actions {
  opacity: 1;
}

/* Icon buttons */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background var(--motion-fast), color var(--motion-fast);
}

.icon-btn:hover {
  background: var(--panel-pressed);
  color: var(--text);
}

.icon-btn--sm {
  width: 24px;
  height: 24px;
}

.icon-btn--sm svg {
  width: 14px;
  height: 14px;
}

.icon-btn--danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--bad);
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-state__icon {
  width: 48px;
  height: 48px;
  color: var(--text-faint);
  margin-bottom: 16px;
}

.empty-state__icon svg {
  width: 48px;
  height: 48px;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px;
}

.empty-state p {
  font-size: 13px;
  color: var(--text-faint);
  margin: 0;
}

/* Info field in modal */
.field--info {
  background: var(--panel-hover);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-line;
}

/* Variant manager (add/remove simple variant names) */
.var-manager {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.var-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.var-row__input {
  flex: 1;
}
.var-row__remove {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--text-faint, #666);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.var-row__remove:hover { color: var(--bad, #e74c3c); }
.var-manager__add { align-self: flex-start; margin-top: 2px; }

/* Variant summary chips in stock tables */
.var-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.var-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255, 165, 0, 0.1);
  color: var(--text-primary, #fff);
  white-space: nowrap;
}
.var-chip--out {
  background: rgba(231, 76, 60, 0.16);
  color: #e74c3c;
}

/* Variant detail modal (open from stock/value chips) */
.variant-modal__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--text-secondary, #aaa);
  padding: 2px 2px 10px;
  border-bottom: 1px solid var(--border-soft, #2a2a2a);
  margin-bottom: 10px;
}
.variant-modal__meta strong { color: var(--text-primary, #fff); }
.variant-modal__meta .mono { color: var(--accent, #007aff); font-weight: 600; }
.variant-modal__scroll {
  max-height: 52vh;
  overflow-y: auto;
}
.variant-modal__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.variant-modal__table th {
  position: sticky;
  top: 0;
  background: var(--bg-card, #1c1f26);
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-faint, #888);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft, #2a2a2a);
}
.variant-modal__table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft, #23262c);
  color: var(--text-primary, #fff);
}
.variant-modal__table tbody tr:hover { background: rgba(255,255,255,.02); }
.variant-modal__table tfoot td {
  font-weight: 600;
  border-top: 1px solid var(--border-soft, #333);
  border-bottom: none;
}
.variant-modal__name { font-weight: 600; }
.variant-modal__unit { color: var(--text-faint, #888); font-size: 11px; }
.variant-modal__lots { font-size: 10px; }

/* "More variants" affordance on chips */
.var-summary__more {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
color: var(--accent, #007aff);
  cursor: pointer;
  border: 1px dashed var(--accent-border, rgba(0,122,255,.4));
  border-radius: 10px;
  padding: 2px 8px;
  background: transparent;
  white-space: nowrap;
}
.var-summary__more:hover { background: rgba(255,165,0,.08); }

/* ==========================================================================
   PRODUCTS PAGE
   ========================================================================== */

/* Filters bar */
.products-filters {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border-soft);
}

/* Search input */
.products-search {
  position: relative;
  display: flex;
  align-items: center;
}

.products-search__icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-faint);
  pointer-events: none;
}

.products-search__icon svg {
  width: 16px;
  height: 16px;
}

.products-search__input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}

.products-search__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.15);
}

.products-search__input::placeholder {
  color: var(--text-faint);
}

/* Category tabs */
.products-category-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.products-category-tabs::-webkit-scrollbar {
  display: none;
}

.products-tab {
  display: flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--motion-fast);
  white-space: nowrap;
  flex-shrink: 0;
}

.products-tab:hover {
  background: var(--panel-hover);
  border-color: var(--border-soft);
  color: var(--text);
}

.products-tab--active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
}

.products-tab--active:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

/* Product table wrapper */
.products-table-wrap {
  padding: 0;
}

/* Mono text (item codes) */
.mono {
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

/* Muted text */
.muted {
  color: var(--text-faint);
}

/* Row delete button */
.row-btn--delete {
  color: var(--text-faint);
}

.row-btn--delete:hover {
  color: var(--bad);
  background: rgba(239, 68, 68, 0.15);
}

/* Form modal sections */
.form-section {
  margin-top: 16px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
}

.form-section:first-child {
  margin-top: 0;
}

.form-section__label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}

/* Textarea field */
.field--textarea {
  min-height: 60px;
  resize: vertical;
}

/* Readonly field */
.field--readonly {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ------------------------------------------------------------------------
   Stock Opening & Locations
   ------------------------------------------------------------------------ */
.stock-set {
  color: var(--accent);
  font-weight: 700;
  font-family: var(--font-mono, monospace);
}
.stock-unset {
  color: var(--text-faint);
  font-style: italic;
}
.mono {
  font-family: var(--font-mono, monospace);
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Stock Overview Table — full width */
.stock-overview-wrap {
  width: 100%;
}
.stock-overview-wrap .table-wrap {
  width: 100%;
}
.stock-overview-wrap .table {
  width: 100%;
  table-layout: auto;
}

/* Stock summary cards */
.stock-summary {
  display: flex;
  gap: 12px;
  padding: 16px 20px 12px;
}
.stock-summary__item {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 12px 16px;
  text-align: center;
}
.stock-summary__item--danger {
  border-color: var(--danger, #e74c3c);
  background: rgba(231, 76, 60, 0.06);
}
.stock-summary__label {
  display: block;
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.stock-summary__value {
  display: block;
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
  color: var(--text);
}
.stock-summary__item--danger .stock-summary__value {
  color: var(--danger, #e74c3c);
}

/* Stock value colors */
.stock-value {
  font-family: var(--font-mono, monospace);
  font-weight: 600;
}
.stock-value--in { color: var(--success, #27ae60); }
.stock-value--out { color: var(--danger, #e74c3c); }

/* Current stock status */
.stock-current {
  font-family: var(--font-mono, monospace);
  font-weight: 700;
  font-size: 13px;
}
.stock-current--ok { color: var(--success, #27ae60); }
.stock-current--low { color: var(--warning, #f39c12); }
.stock-current--out { color: var(--danger, #e74c3c); }

/* ------------------------------------------------------------------------
   Variant Breakdown (Maintenance Supplies)
   ------------------------------------------------------------------------ */
.variant-breakdown {
  margin-bottom: 24px;
}
.variant-breakdown h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.variant-breakdown__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.variant-breakdown__card {
  background: var(--bg-card, #fff);
  border: 1px solid var(--border-soft, #e5e7eb);
  border-radius: 8px;
  padding: 16px;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.variant-breakdown__card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border-color: var(--border, #d1d5db);
}
.variant-breakdown__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft, #e5e7eb);
}
.variant-breakdown__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 13px;
}
.variant-breakdown__row span:first-child {
  color: var(--text-secondary, #6b7280);
}
.variant-breakdown__row span:last-child {
  font-weight: 500;
  font-family: var(--font-mono, monospace);
}
.variant-breakdown__row--balance {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft, #e5e7eb);
}
.variant-breakdown__row--balance span:last-child {
  font-weight: 700;
  color: var(--success, #27ae60);
}

/* ------------------------------------------------------------------------
   Report Page
   ------------------------------------------------------------------------ */
.report-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
  align-items: flex-end;
}
.report-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 120px;
}
.report-filter--wide {
  flex: 1;
  min-width: 200px;
}
.report-filter__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.report-filter__input {
  padding: 7px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-mono, monospace);
}
.report-filter__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow, rgba(184, 173, 160, 0.15));
}
.report-filter__input option {
  background: var(--panel);
  color: var(--text);
}

/* Custom themed dropdowns inside the report filter bar.
   Match the .report-filter__input box (bordered dark input) so the
   custom dropdowns look identical to the date/search inputs. */
.report-filter .cs {
  display: block;
  width: 100%;
}
.report-filter .cs__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono, monospace);
  font-size: 13px;
  font-weight: 400;
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}
.report-filter .cs__trigger:hover {
  border-color: var(--input-border-hover);
  color: var(--text);
}
.report-filter .cs__trigger:focus,
.report-filter .cs--open .cs__trigger {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-bg);
}
.report-filter .cs__chevron {
  color: var(--text-faint);
  flex-shrink: 0;
}
.report-filter .cs__menu {
  min-width: 100%;
  width: 100%;
  top: calc(100% + 6px);
}
.report-summary {
  display: flex;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.report-summary__item {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.report-summary__label {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.report-summary__value {
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
  color: var(--text);
}
.badge--success { background: rgba(39, 174, 96, 0.15); color: var(--success, #27ae60); padding: 2px 8px; border-radius: 5px; font-size: 11px; font-weight: 600; }
.badge--danger { background: rgba(231, 76, 60, 0.15); color: var(--danger, #e74c3c); padding: 2px 8px; border-radius: 5px; font-size: 11px; font-weight: 600; }
.badge--ok { background: rgba(39, 174, 96, 0.15); color: var(--success, #27ae60); padding: 2px 8px; border-radius: 5px; font-size: 11px; font-weight: 600; }
.badge--warn { background: rgba(243, 156, 18, 0.15); color: var(--warn, #f39c12); padding: 2px 8px; border-radius: 5px; font-size: 11px; font-weight: 600; }

/* ------------------------------------------------------------------------
   Maintenance Report Modal
   ------------------------------------------------------------------------ */
.report-filters-panel {
  background: var(--bg-secondary, #f9fafb);
  padding: 16px;
  border-radius: 8px;
}
.report-filter-group {
  margin-bottom: 16px;
}
.report-filter-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.report-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.report-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.report-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.report-date-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-soft, #e5e7eb);
  border-radius: 6px;
  background: var(--bg);
  font-size: 13px;
  margin-bottom: 8px;
}
.report-export-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Report Content Styles */
.maint-report {
  font-size: 13px;
  line-height: 1.5;
}
.maint-report__header {
  text-align: left;
  padding: 16px;
  border-bottom: 2px solid var(--border-soft);
  margin-bottom: 20px;
}
.maint-report__header .maint-report__title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 4px 0;
}
.maint-report__header .maint-report__brand {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0;
}
.maint-report__header .maint-report__subtitle {
  font-size: 11px;
  color: var(--text-faint);
  margin: 4px 0 0 0;
}
.maint-report__section {
  margin-bottom: 24px;
  page-break-before: always;
}
.maint-report__section:first-child {
  page-break-before: avoid;
}
.maint-report__section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent, #3b82f6);
  border-bottom: 2px solid var(--accent, #3b82f6);
  padding-bottom: 8px;
  margin-bottom: 16px;
}
.maint-report__subsection {
  margin-bottom: 16px;
}
.maint-report__subsection h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px 0;
}
.maint-report__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.maint-report__table th,
.maint-report__table td {
  padding: 8px 12px;
  border: 1px solid var(--border-soft);
  text-align: left;
}
.maint-report__table th {
  background: var(--bg-secondary, #f9fafb);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.3px;
}
.maint-report__table td {
  color: var(--text);
}
.maint-report__day {
  padding: 12px;
  background: var(--bg-secondary, #f9fafb);
  border-radius: 6px;
  margin-bottom: 12px;
}
.maint-report__day h4 {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: var(--text);
}
.maint-report__day p {
  margin: 4px 0;
  font-size: 12px;
}

/* Approve / Reject row buttons */
.row-btn--approve:hover { color: var(--success, #27ae60); border-color: rgba(39, 174, 96, 0.3); background: rgba(39, 174, 96, 0.1); }
.row-btn--reject:hover { color: var(--danger, #e74c3c); border-color: rgba(231, 76, 60, 0.3); background: rgba(231, 76, 60, 0.1); }

/* Stock invoice modal item row */
.stock-inv__scroll { overflow-x: auto; border: 1px solid var(--border-soft, #333); border-radius: 6px; padding: 0 8px; margin: 4px 0; }
.stock-inv__scroll::-webkit-scrollbar { height: 8px; }
.stock-inv__scroll::-webkit-scrollbar-track { background: transparent; }
.stock-inv__scroll::-webkit-scrollbar-thumb { background: var(--border-soft, #333); border-radius: 4px; }
.stock-inv__item { transition: background var(--motion-fast); }
.stock-inv__item:hover { background: var(--panel-hover); border-radius: 6px; }
.inv__item-remove {
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: 4px; background: transparent;
  color: var(--text-faint); cursor: pointer; font-size: 14px; font-weight: 700;
  transition: all var(--motion-fast);
}
.inv__item-remove:hover { color: var(--bad); background: var(--bad-bg); border-color: var(--bad-border); }
.inv__item-total { display: flex; align-items: center; font-weight: 600; font-size: 12px; }

/* Stock invoice modal: taller, wider, and grid fills available vertical space */
.modal:has(.stock-inv) {
  max-height: min(95dvh, 1600px);
}
.modal:has(.stock-inv) .modal__body {
  display: flex;
  flex-direction: column;
}
.modal:has(.stock-inv) .stock-inv {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.modal:has(.stock-inv) .stock-inv__scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.modal:has(.stock-inv) .stock-inv__items-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-bg, #1e1e1e);
  border-bottom: 1px solid var(--border-soft, #333);
}

/* Product Picker — single-input combobox (type to filter + dropdown + clear) */
.prod-pick {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}
.prod-pick__input {
  width: 100%;
  box-sizing: border-box;
  padding-right: 28px;
}
.prod-pick__dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: var(--panel-bg, #1e1e1e);
  border: 1px solid var(--border-soft, #333);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  z-index: 1000;
}
.prod-pick__open .prod-pick__dropdown { display: block; }
.prod-pick__opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text-secondary, #bbb);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--motion-fast), color var(--motion-fast);
}
.prod-pick__opt-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.prod-pick__opt-meta {
  color: var(--text-faint, #666);
  font-size: 11px;
  flex-shrink: 0;
}
.prod-pick__opt:hover,
.prod-pick__opt--active {
  background: var(--accent-bg, rgba(255, 165, 0, 0.12));
  color: var(--text-primary, #fff);
}
.prod-pick__opt--active .prod-pick__opt-meta {
  color: var(--text-secondary, #bbb);
}
.prod-pick__opt:empty {
  display: none;
}
.prod-pick__dropdown:empty::after {
  content: attr(data-empty);
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-faint, #666);
}
.prod-pick__clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--text-faint, #666);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
}
.prod-pick__clear:hover { color: var(--bad, #e74c3c); }
.prod-pick__clear--active { display: flex; }

/* Variant selector inside a product picker */
.prod-pick__variant {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-secondary, #bbb);
}
.prod-pick__variant-label {
  white-space: nowrap;
  opacity: 0.8;
}
.prod-pick__variant-single {
  font-weight: 600;
  color: var(--text-primary, #fff);
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(255, 165, 0, 0.12);
}
.prod-pick__variant-select {
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0 4px;
}

/* Dark theme scrollbar for picker dropdown */
.prod-pick__dropdown::-webkit-scrollbar { width: 6px; }
.prod-pick__dropdown::-webkit-scrollbar-track { background: transparent; }
.prod-pick__dropdown::-webkit-scrollbar-thumb { background: var(--border-soft, #333); border-radius: 3px; }
.prod-pick__dropdown::-webkit-scrollbar-thumb:hover { background: var(--text-faint, #666); }

/* Supplier picker — free text + dropdown + product cap */
.sup-pick { position: relative; display: flex; align-items: center; width: 100%; }
.sup-pick__input { width: 100%; box-sizing: border-box; padding-right: 34px; }
.sup-pick__dropdown {
  display: none; position: absolute; top: calc(100% + 2px); left: 0; right: 0; z-index: 1000;
  max-height: 220px; overflow-y: auto; background: var(--panel-bg, #1e1e1e);
  border: 1px solid var(--border-soft, #333); border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.sup-pick__open .sup-pick__dropdown { display: block; }
.sup-pick__opt { padding: 7px 10px; font-size: 12px; color: var(--text-secondary, #bbb); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sup-pick__opt .sup-pick__meta { color: var(--text-faint, #666); }
.sup-pick__opt:hover, .sup-pick__opt--active { background: var(--accent-bg, rgba(255,165,0,.12)); color: var(--text-primary, #fff); }
.sup-pick__clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; border: 1px solid transparent; border-radius: 50%;
  background: transparent; color: var(--text-faint, #666); cursor: pointer;
  font-size: 14px; font-weight: 700; line-height: 1; display: none; align-items: center; justify-content: center;
}
.sup-pick__clear:hover { color: var(--bad, #e74c3c); }
.sup-pick__clear--active { display: flex; }
.sup-pick__cap {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px; padding: 5px 8px;
  font-size: 11.5px; color: var(--text-secondary, #bbb);
  background: var(--accent-bg, rgba(255,165,0,.08)); border: 1px solid var(--accent-border, rgba(255,165,0,.25));
  border-radius: 6px; width: 100%; box-sizing: border-box;
}
.sup-pick__cap em { font-style: normal; font-weight: 600; color: var(--text-primary, #fff); }
.sup-pick__clearcap {
  margin-left: auto; border: 1px solid var(--border-soft, #333); border-radius: 4px;
  background: transparent; color: var(--text-secondary, #bbb); cursor: pointer;
  font-size: 11px; padding: 2px 8px;
}
.sup-pick__clearcap:hover { color: var(--bad, #e74c3c); border-color: var(--bad-border, rgba(231,76,60,.3)); }
.prod-pick.cap-on { outline: 1px dashed var(--accent-border, rgba(255,165,0,.35)); outline-offset: 2px; border-radius: 4px; box-shadow: inset 0 0 0 1px var(--accent-border, rgba(255,165,0,.2)); }

/* Checkbox group (e.g. assign multiple suppliers to a product) */
.field__checks { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
.field__check {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border: 1px solid var(--border-soft, #333); border-radius: 6px;
  background: var(--panel-bg, #1e1e1e); color: var(--text-secondary, #bbb);
  font-size: 12.5px; cursor: pointer; user-select: none;
  transition: border-color var(--motion-fast), background var(--motion-fast), color var(--motion-fast);
}
.field__check:hover { border-color: var(--accent-border, rgba(255,165,0,.4)); color: var(--text-primary, #fff); }
.field__check input { accent-color: var(--accent, #f5a623); cursor: pointer; }
.field__check:has(input:checked) {
  border-color: var(--accent-border, rgba(255,165,0,.5));
  background: var(--accent-bg, rgba(255,165,0,.1));
  color: var(--text-primary, #fff);
}



/* ==========================================================================
   PAGE-SPECIFIC STYLES
   ========================================================================== */

/* Stock Adjustment */
.page--stock-adjustment .page-header__subtitle { color: var(--text-secondary); }
.page--stock-adjustment .badge--warn { font-size: 12px; }

/* Stock Transfer */
.page--stock-transfer .page-header__subtitle { color: var(--text-secondary); }

/* Stock Opening */
.page--stock-opening .stock-set {
  color: var(--good, #27ae60);
  font-weight: 600;
}
.page--stock-opening .stock-unset {
  color: var(--text-faint);
  font-style: italic;
}

/* Categories */
.page--categories .category-tree {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.page--categories .category-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-md, 6px);
  transition: background var(--motion-fast);
}
.page--categories .category-item:hover {
  background: var(--panel-hover);
}
.page--categories .category-item--child {
  margin-left: 24px;
}
.page--categories .category-name {
  flex: 1;
  font-weight: 500;
}
.page--categories .category-count {
  font-size: 12px;
  color: var(--text-faint);
}

/* Locations */
.page--locations .location-code {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.02em;
}

/* Products */
.page--products .products-tab {
  transition: all var(--motion-fast);
}
.page--products .products-tab--active {
  background: var(--accent);
  color: var(--on-accent);
}

/* Stock Levels */
.page--stock-levels .stock-current--low {
  color: var(--warn, #f39c12);
  font-weight: 600;
}
.page--stock-levels .stock-current--out {
  color: var(--bad, #e74c3c);
  font-weight: 700;
}
.page--stock-levels .stock-current--ok {
  color: var(--good, #27ae60);
}

/* Report */
.page--report .report-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.page--report .report-kpi {
  padding: 12px;
  background: var(--panel);
  border-radius: var(--radius-md, 6px);
  border: 1px solid var(--border-soft);
}
.page--report .report-kpi__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.page--report .report-kpi__value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ── HFO Flowmeter toggle ────────────────────────────────────── */
.fm-toggle {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.fm-toggle__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.fm-toggle__track {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--border, #444);
  border-radius: 10px;
  transition: background 0.2s;
}
.fm-toggle__track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.fm-toggle__input:checked + .fm-toggle__track {
  background: var(--accent);
}
.fm-toggle__input:checked + .fm-toggle__track::after {
  transform: translateX(16px);
}
.fm-toggle__input:focus-visible + .fm-toggle__track {
  box-shadow: 0 0 0 2px var(--accent-border);
}
/* ============================================================================
   OVERVIEW DASHBOARDS (product overview / quarry overview)
   Rendered by Dashboard.js contextual dispatcher.
   ============================================================================ */
.ov-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--content-gap);
  margin-bottom: var(--content-gap);
}

.ov-kpi {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px;
  border-radius: 12px;
  background: var(--card-bg, var(--panel));
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow, none);
  position: relative;
  overflow: hidden;
}

.ov-kpi__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-bg);
  color: var(--accent);
}

.ov-kpi__value {
  font-size: var(--fs-2xl, 22px);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.1;
}

.ov-kpi__label {
  font-size: var(--fs-sm);
  color: var(--text-faint);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ov-kpi--warn .ov-kpi__icon {
  background: var(--bad-bg, rgba(255, 93, 84, 0.13));
  color: var(--bad, #ff5d54);
}

.ov-kpi--warn .ov-kpi__value {
  color: var(--bad, #ff5d54);
}

/* Quick access buttons */
.ov-quick__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.ov-quick__btn {
  justify-content: flex-start;
  text-align: left;
}

/* Recent transactions feed */
.ov-recent__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.ov-recent__item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--border-soft, var(--border));
  font-size: 13px;
}

.ov-recent__item:last-child {
  border-bottom: none;
}

.ov-recent__ref {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ov-recent__qty {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
}

.ov-recent__sup {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.act-ts {
  font-size: 11.5px;
  color: var(--text-faint);
  white-space: nowrap;
}

/* Quarry spark chart */
.ov-spark__chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 56px;
  padding-top: 6px;
}

.ov-spark__bar {
  flex: 1 1 0;
  min-width: 4px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-dim, var(--accent)));
  opacity: 0.85;
  transition: opacity var(--motion-fast);
}

.ov-spark__bar:hover {
  opacity: 1;
}

/* Top vehicles */
.top-veh__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.top-veh__item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) minmax(70px, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.top-veh__rank {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--panel-hover);
  color: var(--text-faint);
  font-weight: 700;
  font-size: 11.5px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.top-veh__name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-veh__bar {
  height: 6px;
  border-radius: 99px;
  background: var(--panel-hover);
  overflow: hidden;
}

.top-veh__fill {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
}

.top-veh__qty {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.top-veh__trips {
  white-space: nowrap;
}

/* Settings page */
.integrity-result {
  margin-top: 12px;
}

.integrity-ok {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(39, 174, 96, 0.10);
  color: var(--good, #27ae60);
  font-size: 13px;
  font-weight: 600;
}

.integrity-bad {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bad-bg);
  color: var(--bad, #ff5d54);
  font-size: 13px;
}

.integrity-bad ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.data-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.data-card .muted {
  font-size: var(--fs-sm);
}

/* Mobile: tighten overview feed */
@media (max-width: 767px) {
  .ov-recent__item {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
  .ov-recent__sup {
    display: none;
  }
  .top-veh__item {
    grid-template-columns: 24px minmax(0, 1fr) auto auto;
  }
  .top-veh__bar {
    display: none;
  }
}
