:root {
  --bg: #f4f5f2;
  --panel: #ffffff;
  --ink: #1d2320;
  --muted: #67716b;
  --line: #dde1dc;
  --line-strong: #c3c9c3;
  --accent: #1f6f50;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ea;
  --warn: #9a5b00;
  --warn-soft: #fff3dc;
  --bad: #b3261e;
  --bad-soft: #fde8e6;
  --good: #1f6f50;
  --row-hover: #f7faf8;
  --focus: #2f8f68;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--sans); }
a { color: var(--accent); }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 15px; margin: 18px 0 8px; }
h3 { font-size: 13px; margin: 12px 0 6px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.topbar { display: flex; align-items: center; gap: 18px; padding: 0 18px; height: 48px; background: #17231e; color: #e8efe9; position: sticky; top: 0; z-index: 20; }
.topbar .brand { color: #fff; font-weight: 700; text-decoration: none; letter-spacing: .01em; }
.topbar nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.topbar nav a { color: #c8d4cc; text-decoration: none; padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
.topbar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.topbar nav a.on { background: rgba(255,255,255,.14); color: #fff; }
.topbar .who { color: #aab8af; white-space: nowrap; font-size: 13px; }
.topbar .who a { color: #d9e4dc; }

main { padding: 18px; max-width: 1200px; margin: 0 auto; }
body.wide main { max-width: none; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; background: var(--accent-soft); border: 1px solid #b9dcc9; }
.flash.err { background: var(--bad-soft); border-color: #f1b8b2; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.over { color: var(--good); }
.short { color: var(--bad); font-weight: 600; }
.zero { color: var(--muted); }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.spacer { flex: 1; }

form.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--line-strong); border-radius: 6px; padding: 6px 8px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: var(--focus); }
textarea { width: 100%; min-height: 60px; }
.btn, button { font: inherit; border: 1px solid var(--line-strong); background: #fff; color: var(--ink); padding: 6px 12px; border-radius: 6px; cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover, button:hover { border-color: var(--accent); }
.btn.primary, button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger, button.danger { color: var(--bad); border-color: #e6b3ae; }
button:disabled { opacity: .5; cursor: default; }

table.data { width: 100%; border-collapse: collapse; background: var(--panel); }
table.data th, table.data td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: left; background: #fafbf9; position: sticky; top: 48px; z-index: 2; }
table.data tr:hover td { background: var(--row-hover); }
table.data tfoot td { font-weight: 700; border-top: 2px solid var(--line-strong); background: #fafbf9; }
.table-wrap { overflow: auto; max-height: calc(100vh - 120px); border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.table-wrap table.data th { top: 0; }
@media print { .table-wrap { max-height: none; overflow: visible; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- daily entry ---------- */
.entry-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.entry-head h1 { margin: 0; }
.entry-head .date-nav a { text-decoration: none; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.badge.closed { background: #ececec; color: #555; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

.entry-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .entry-layout { grid-template-columns: 1fr; } }

.grid-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
table.grid { border-collapse: collapse; width: 100%; min-width: 1320px; }
table.grid th { position: sticky; top: 0; background: #fafbf9; font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; padding: 6px 4px; border-bottom: 1px solid var(--line-strong); text-align: left; z-index: 3; white-space: nowrap; }
table.grid td { border-bottom: 1px solid var(--line); padding: 0; }
table.grid td.ln { width: 34px; text-align: right; padding-right: 6px; color: var(--muted); font-size: 12px; }
table.grid input, table.grid select { width: 100%; border: 0; border-radius: 0; padding: 7px 5px; background: transparent; font-variant-numeric: tabular-nums; }
table.grid input:focus, table.grid select:focus { outline: 2px solid var(--focus); outline-offset: -2px; background: #fff; }
table.grid input.q { width: 44px; text-align: center; }
table.grid input[data-f="vehicle"] { min-width: 210px; }
table.grid input[data-f="coupon_desc"] { min-width: 120px; }
table.grid select[data-f="fleet_account_id"] { min-width: 100px; }
table.grid input.m { width: 78px; text-align: right; }
table.grid td.total { width: 82px; text-align: right; padding-right: 8px; font-weight: 600; font-variant-numeric: tabular-nums; }
table.grid tr.saving td.total { color: var(--muted); }
table.grid tr.error td { background: var(--bad-soft); }
table.grid tr.unbalanced td.total { color: var(--warn); }
table.grid tr.unbalanced td.total::after { content: " ●"; font-size: 10px; }
table.grid tr.new td { background: #fcfdfc; }
table.grid td.act { width: 64px; white-space: nowrap; text-align: center; }
table.grid td.act button { border: 0; background: none; padding: 4px; color: var(--muted); font-size: 13px; }
table.grid td.act button:hover { color: var(--accent); }
table.grid td.act button.del:hover { color: var(--bad); }
.grid-help { font-size: 12px; color: var(--muted); padding: 8px 10px; border-top: 1px solid var(--line); display: flex; gap: 16px; flex-wrap: wrap; }
kbd { font: 11px var(--mono); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: #fff; }

.closeout { position: sticky; top: 60px; }
.closeout .panel { padding: 12px 14px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; font-variant-numeric: tabular-nums; }
.kv .r { text-align: right; }
.kv .strong { font-weight: 700; }
.kv .sep { grid-column: 1 / -1; border-top: 1px solid var(--line); margin: 4px 0; }
.closeout .field { display: grid; grid-template-columns: 1fr 110px; align-items: center; gap: 6px; margin-bottom: 6px; }
.closeout .field label { margin: 0; font-size: 13px; color: var(--ink); }
.closeout .field input { text-align: right; }
.os-box { text-align: center; padding: 10px; border-radius: 8px; background: #fafbf9; border: 1px solid var(--line); margin: 8px 0; }
.os-box .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.staff-row, .adj-row { display: flex; gap: 6px; align-items: center; margin-bottom: 5px; font-size: 13px; }
.staff-row .name { flex: 1; }
.adj-row select, .adj-row input { padding: 4px 6px; font-size: 13px; }
.adj-row input.amt { width: 80px; text-align: right; }
.adj-row input.why { flex: 1; min-width: 0; }
.warn-box { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin: 8px 0; }
.save-state { font-size: 12px; color: var(--muted); }

/* ---------- receipt ---------- */
.receipt { max-width: 420px; margin: 0 auto; background: #fff; padding: 24px; border: 1px solid var(--line); }
.receipt h2 { margin: 0; font-size: 18px; }
.receipt table { width: 100%; border-collapse: collapse; margin-top: 14px; }
.receipt td, .receipt th { padding: 4px 0; border-bottom: 1px dotted var(--line-strong); }
@media print {
  .topbar, .no-print { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
  .receipt { border: 0; }
  .panel, .table-wrap { border: 0; }
  table.data th { position: static; }
}

.login { max-width: 340px; margin: 10vh auto; }
.login input { width: 100%; margin-bottom: 10px; }
.login button { width: 100%; }

.bar { height: 8px; background: var(--accent); border-radius: 4px; min-width: 2px; }
.bar-cell { width: 30%; }

/* ---------- quick entry (built for a busy counter) ---------- */
[hidden] { display: none !important; }
.quick { background: var(--panel); border: 2px solid var(--accent); border-radius: 12px; padding: 12px 14px 10px; margin-bottom: 14px; }
.quick.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.q-top, .q-bottom { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.q-field label, .q-pay label { font-size: 12px; margin-bottom: 3px; }
.q-field label kbd, .q-pay label kbd { margin-left: 2px; }
.q-vehicle { flex: 1; min-width: 260px; }
.q-vehicle input { width: 100%; font-size: 20px; padding: 9px 12px; text-transform: uppercase; font-weight: 600; letter-spacing: .01em; }
.q-vehicle input::placeholder { text-transform: none; font-weight: 400; color: #9aa39d; }
.q-short { width: 110px; font-size: 16px; padding: 8px 10px; }
.q-money { width: 100px; text-align: right; font-size: 16px; padding: 8px 10px; }
.q-desc { width: 150px; font-size: 16px; padding: 8px 10px; }
.q-calc { font-size: 16px; padding: 8px 4px; font-variant-numeric: tabular-nums; min-width: 80px; }
.q-total-box { text-align: right; min-width: 150px; }
.q-total-box .k { font-size: 12px; color: var(--muted); }
.q-total-box .v { font-size: 32px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }

.q-pad { margin: 10px -6px; padding: 8px 6px; border-radius: 10px; outline: none; border: 2px dashed transparent; }
.q-pad:focus { border-color: var(--focus); background: #f3faf6; }
.q-pad:focus::before { content: "Press letters for services, then Enter to save"; display: block; font-size: 12px; color: var(--accent); font-weight: 600; margin: 0 2px 6px; }
.q-group { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.q-presets { margin-top: 8px; }
button.svc { font-size: 15px; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line-strong); background: #fff; display: inline-flex; gap: 6px; align-items: center; }
button.svc .p { color: var(--muted); font-size: 12px; }
button.svc .n { font-weight: 800; }
button.svc.on { background: var(--accent); border-color: var(--accent); color: #fff; }
button.svc.on .p { color: #d5eee1; }
button.svc.on kbd { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.4); }
button.preset { font-size: 13px; padding: 5px 10px; border-radius: 99px; background: #f7f8f6; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--line-strong); padding: 8px 12px; font-size: 15px; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: #fff; }
.seg button.on kbd { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.4); }
button.big { font-size: 17px; padding: 10px 18px; font-weight: 700; }
button.primary kbd { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.4); }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.q-hint { font-size: 13px; color: var(--muted); margin-top: 8px; min-height: 18px; }
.q-hint strong { color: var(--ink); }

.unsaved { background: var(--bad-soft); border: 1px solid #f1b8b2; color: #7a1d17; border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-size: 14px; }
.unsaved button { margin-left: 8px; }

table.grid tr.pending td { color: var(--muted); }
table.grid tr.pending td.ln::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); margin-left: 3px; vertical-align: middle; }
table.grid tr.error td.ln { color: var(--bad); font-weight: 800; cursor: help; }
table.grid tr.just-added td { animation: flashrow 1.6s ease-out; }
@keyframes flashrow { from { background: #d9f0e3; } to { background: transparent; } }
table.grid input.veh { min-width: 210px; text-transform: uppercase; }
table.grid input.desc { min-width: 110px; }
table.grid input.dmvn { width: 80px; }
table.grid input.tr { width: 70px; }

.big-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: center; margin-bottom: 6px; }
.big-stats .v { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.big-stats .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
details summary { cursor: pointer; margin: 4px 0; }
