:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #dbeafe;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --petrol: #16a34a;
  --diesel: #d97706;
  --side: #0f172a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px; color: var(--text); background: var(--bg); line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 24px; }
h2 { font-size: 17px; }
h3 { font-size: 16px; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.pos-num { color: var(--ok); }
.neg-num { color: var(--danger); }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 9px 16px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ok:hover { filter: brightness(.95); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-outline { color: var(--danger); border-color: #fecaca; }
.btn.danger-outline:hover { background: var(--danger-soft); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(15, 23, 42, .05); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.big { padding: 13px 20px; font-size: 16px; }
.btn.huge { padding: 18px 20px; font-size: 20px; border-radius: 14px; }
.btn.block { width: 100%; }
.icon-btn { border: 0; background: transparent; font-size: 18px; cursor: pointer; padding: 6px 9px; border-radius: 8px; color: var(--muted); }
.icon-btn:hover { background: rgba(15, 23, 42, .06); color: var(--text); }

input, select, textarea {
  font: inherit; color: var(--text); background: #fff; border: 1px solid #cbd5e1; border-radius: 10px;
  padding: 9px 11px; width: 100%; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; padding: 0; accent-color: var(--primary); }
input:disabled, select:disabled { background: #f1f5f9; color: var(--muted); }
textarea { resize: vertical; min-height: 70px; }
.field { display: block; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 5px; }
.field .hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 14px; }
.check input { margin-top: 2px; flex: none; }
.check .hint { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(circle at 20% 10%, #1e3a8a 0, transparent 50%), radial-gradient(circle at 90% 90%, #065f46 0, transparent 45%), #0f172a; }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 18px; padding: 32px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.login-card .logo { font-size: 44px; text-align: center; }
.login-card h1 { text-align: center; margin: 6px 0 2px; }
.login-card p.sub { text-align: center; color: var(--muted); margin: 0 0 22px; }
.login-card .field { margin-bottom: 14px; }
.demo-box { margin-top: 18px; background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.demo-box button { margin: 4px 4px 0 0; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--side); color: #cbd5e1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { padding: 18px 18px 14px; display: flex; gap: 10px; align-items: center; color: #fff; }
.brand .logo { font-size: 26px; }
.brand b { display: block; font-size: 17px; }
.brand small { color: #94a3b8; font-size: 12px; display: block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { padding: 6px 10px; flex: 1; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; color: #cbd5e1; text-decoration: none; border-radius: 10px; font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.nav .ico { width: 22px; text-align: center; font-size: 17px; }
.nav .sep { height: 1px; background: rgba(255,255,255,.08); margin: 8px 6px; }
.side-foot { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.side-foot .who { color: #fff; font-weight: 600; }
.side-foot .role { color: #94a3b8; text-transform: capitalize; }
.side-foot .row { margin-top: 8px; }
.side-foot .btn { background: rgba(255,255,255,.07); color: #e2e8f0; border-color: transparent; }
.side-foot .btn:hover { background: rgba(255,255,255,.14); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.view { padding: 24px; max-width: 1500px; width: 100%; }
.demo-banner { background: #fef3c7; color: #92400e; padding: 6px 24px; font-size: 13px; text-align: center; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- cards / tables ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card.narrow { max-width: 720px; }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid > .card + .card { margin-top: 0; }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tbody tr.click { cursor: pointer; }
.table tbody tr.click:hover { background: #f8fafc; }
.table tr.voided td { color: #94a3b8; text-decoration: line-through; }
.table tr.voided td.keep { text-decoration: none; }
.table tfoot td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; }
.table tr.disabled td { opacity: .55; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }

.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--fc, #64748b) 14%, white); color: color-mix(in srgb, var(--fc, #64748b) 80%, black); white-space: nowrap; }
.tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--fc, #64748b); }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #f1f5f9; color: #475569; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: #166534; }
.badge.warn { background: var(--warn-soft); color: #92400e; }
.badge.danger { background: var(--danger-soft); color: #991b1b; }
.badge.info { background: var(--primary-soft); color: #1e40af; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; border-left: 4px solid var(--kc, var(--primary)); }
.kpi .label { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: clamp(19px, 2.1vw, 25px); white-space: nowrap; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ---------- alerts ---------- */
.alert { padding: 10px 14px; border-radius: 10px; font-size: 14px; display: flex; gap: 10px; align-items: center; background: #f1f5f9; }
.alert + .alert { margin-top: 8px; }
.alert.danger { background: var(--danger-soft); color: #991b1b; }
.alert.warn { background: var(--warn-soft); color: #92400e; }
.alert.info { background: var(--primary-soft); color: #1e3a8a; }
.alert.ok { background: var(--ok-soft); color: #166534; }
.alert a { color: inherit; font-weight: 700; margin-left: auto; white-space: nowrap; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid #f1f5f9; }
.checklist li:last-child { border-bottom: 0; }
.checklist .tick { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; background: #f1f5f9; color: var(--muted); flex: none; }
.checklist li.done .tick { background: var(--ok); color: #fff; }
.checklist li.done span { color: var(--muted); text-decoration: line-through; }
.checklist a { margin-left: auto; font-size: 13px; font-weight: 600; }

/* ---------- tanks ---------- */
.tanks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tank { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: flex; gap: 14px; }
.gauge { width: 46px; height: 120px; border: 2px solid #cbd5e1; border-radius: 10px; position: relative; overflow: hidden; flex: none; background: #f8fafc; }
.gauge .fill { position: absolute; left: 0; right: 0; bottom: 0; background: var(--fc); opacity: .85; transition: height .6s; }
.gauge .mark { position: absolute; left: 0; right: 0; border-top: 2px dashed #ef4444; }
.tank .info { flex: 1; min-width: 0; }
.tank .vol { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tank .meta { font-size: 13px; color: var(--muted); }

/* ---------- bar chart ---------- */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 200px; padding-top: 10px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 0; }
.chart .bars { flex: 1; width: 100%; max-width: 46px; display: flex; flex-direction: column; justify-content: flex-end; }
.chart .seg { width: 100%; }
.chart .seg:first-child { border-radius: 5px 5px 0 0; }
.chart .lbl { font-size: 11px; color: var(--muted); margin-top: 6px; white-space: nowrap; }
.chart .val { font-size: 11px; color: #334155; font-weight: 600; margin-bottom: 3px; white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--fc); margin-right: 6px; }
.hbar { height: 8px; background: #f1f5f9; border-radius: 99px; overflow: hidden; margin-top: 4px; }
.hbar > div { height: 100%; background: var(--fc, var(--primary)); border-radius: 99px; }

/* ---------- tabs & filters ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters select, .filters input { width: auto; min-width: 130px; padding: 7px 10px; }
.filters input[type=search] { min-width: 200px; }

/* ---------- modal ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50; animation: fade .12s; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 520px; box-shadow: 0 25px 60px rgba(0,0,0,.3); animation: pop .15s; }
.modal.wide { max-width: 820px; }
.modal.xwide { max-width: 1050px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 20px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: #0f172a; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25); font-weight: 500; border-left: 4px solid var(--ok); transition: opacity .4s, transform .4s; }
.toast.err { border-left-color: var(--danger); }
.toast.hide { opacity: 0; transform: translateX(20px); }

/* ---------- daily figures ---------- */
.step { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
.fuel-card .form-grid { gap: 12px; }
.fuel-card .field input { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.closing-field input { border-width: 2px; border-color: #94a3b8; font-size: 20px !important; padding: 11px 12px; }
.calc-box { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; background: #0f172a; color: #fff; border-radius: 12px; padding: 12px 16px; }
.calc-box span { display: block; font-size: 12px; color: #94a3b8; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.calc-box b { font-size: 22px; font-variant-numeric: tabular-nums; }
.summary-card { border-left: 4px solid var(--primary); }
.sum-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.sum-grid > div { background: #f8fafc; border-radius: 12px; padding: 12px 14px; }
.sum-grid span { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.sum-grid b { display: block; font-size: clamp(18px, 2vw, 22px); white-space: nowrap; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.sum-grid b .badge { font-size: 16px; padding: 4px 10px; }
.sum-grid small { color: var(--muted); font-size: 12px; }
.exp-grid { grid-template-columns: minmax(0, 1fr) 300px; }
.side-list { list-style: none; padding: 0; margin: 0; }
.side-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid #f1f5f9; font-size: 14px; }
.side-list li:last-child { border-bottom: 0; }
@media (max-width: 1100px) { .sum-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .exp-grid { grid-template-columns: 1fr; } }

/* ---------- report document ---------- */
.doc h2 { margin: 18px 0 8px; }
.doc .doc-head { margin-bottom: 10px; }
.pnl td { padding: 8px 10px; }
.pnl tr.sub td { padding-left: 28px; color: #475569; }
.pnl tr.total td { font-weight: 800; border-top: 2px solid var(--line); }
.help h3 { margin: 18px 0 6px; }
.help ol, .help ul { margin: 6px 0; padding-left: 22px; }
.help li { margin: 4px 0; }

#print-area { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--side); color: #fff; position: sticky; top: 0; z-index: 30; }
  .topbar .icon-btn { color: #fff; }
  .view { padding: 16px; }
  .grid.c2, .grid.c3 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .grid.c4 { grid-template-columns: 1fr; }
  h1 { font-size: 21px; }
}

/* ---------- printing ---------- */
@media print {
  body { background: #fff; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; }
  #print-area.page { font-size: 12px; }
  #print-area.page .table th, #print-area.page .table td { padding: 4px 6px; }
  #print-area .no-print { display: none !important; }
  .card { box-shadow: none; padding: 0; }
  @page { margin: 10mm; }
}

/* ---------- prices ---------- */
.price-box { background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
input.flash { background: #fef9c3; transition: background .3s; }
.price-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #f1f5f9; flex-wrap: wrap; }
.price-row:last-of-type { border-bottom: 0; }
.price-row .pr { font-variant-numeric: tabular-nums; }
.price-row .pr b { font-size: 18px; }
.locked { padding: 9px 11px; border: 1px dashed #cbd5e1; border-radius: 10px; background: #f8fafc; font-weight: 700; font-variant-numeric: tabular-nums; }
input.locked-input, .fuel-card input.locked-input { background: #f1f5f9; border-style: dashed; color: #334155; cursor: not-allowed; }
