:root {
  --ink: #17231f;
  --muted: #5d6b66;
  --paper: #f1f3ef;
  --surface: #ffffff;
  --line: #d8ddd6;
  --spruce: #12463a;
  --spruce-dark: #0c332a;
  --spruce-soft: #e1ede8;
  --diesel: #b5790c;
  --diesel-soft: #f7ecd5;
  --petrol: #1f6a8a;
  --petrol-soft: #dcecf3;
  --owed: #a8321f;
  --warn-bg: #fbf0d3;
  --err-bg: #f8dedb;
  --radius: 6px;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5; font-variant-numeric: tabular-nums;
}
a { color: var(--spruce); }
a:hover { color: var(--spruce-dark); }
:focus-visible { outline: 3px solid #e2a21a; outline-offset: 2px; }
h1 { font-size: 1.6rem; margin: 0 0 .75rem; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 1.75rem 0 .6rem; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.neg { color: var(--owed); font-weight: 600; }
.r { text-align: right; }
.scroll-x { overflow-x: auto; }
code, .mono { font-family: Consolas, "Courier New", monospace; }

/* frame */
.topbar { display: none; }
.shell { display: flex; min-height: 100vh; }
.side {
  width: 15rem; flex: none; background: var(--spruce); color: #e8f1ed;
  padding: 1.25rem 0; display: flex; flex-direction: column;
}
.brand { font-weight: 700; font-size: 1.1rem; padding: 0 1.25rem 1rem; border-bottom: 1px solid rgba(255,255,255,.18); margin-bottom: .75rem; }
.side ul { list-style: none; margin: 0; padding: 0; flex: 1; }
.side li a { display: block; padding: .55rem 1.25rem; color: #e8f1ed; text-decoration: none; border-left: 4px solid transparent; }
.side li a:hover { background: rgba(255,255,255,.08); }
.side li a.on { background: var(--spruce-dark); border-left-color: #e2a21a; font-weight: 600; }
.who { padding: 1rem 1.25rem 0; border-top: 1px solid rgba(255,255,255,.18); font-size: .9rem; }
.who a, .who .linklike { color: #cfe3dc; display: block; margin-top: .35rem; }
.who .muted { color: #a9c4ba; }
.main { flex: 1; min-width: 0; padding: 1.75rem 2rem 3rem; max-width: 76rem; }

/* flash */
.flash { padding: .65rem .9rem; border-radius: var(--radius); margin: 0 0 1rem; border: 1px solid transparent; }
.flash.ok { background: var(--spruce-soft); border-color: #b7d3c8; }
.flash.warn { background: var(--warn-bg); border-color: #e6cf93; }
.flash.err { background: var(--err-bg); border-color: #e3b2ab; }

/* dashboard */
.hero {
  display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: center; justify-content: space-between;
  background: var(--spruce); color: #fff; border-radius: var(--radius); padding: 1.25rem 1.5rem; margin-bottom: 1rem;
}
.hero-label { margin-bottom: .5rem; color: #cfe3dc; }
.hero-action { display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; }
.odo { display: inline-flex; align-items: center; gap: 3px; }
.od {
  font-style: normal; font-family: Consolas, "Courier New", monospace; font-weight: 700;
  font-size: 2rem; width: 1.55rem; text-align: center; background: #0a1f1a; color: #f4efe0;
  border-radius: 3px; padding: .15rem 0; box-shadow: inset 0 -10px 0 rgba(255,255,255,.04);
}
.od.sign { width: 1.1rem; }
.od-sep { font-size: 1.6rem; font-weight: 700; margin: 0 1px; align-self: flex-end; }
.strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; }
.strip > div { padding: .9rem 1.1rem; display: flex; flex-direction: column; }
.strip > div + div { border-left: 1px solid var(--line); }
.strip .k { color: var(--muted); font-size: .9rem; }
.strip .v { font-size: 1.5rem; font-weight: 650; }
.strip .s { color: var(--muted); font-size: .85rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1rem; }
.panel h2 { margin-top: 0; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); gap: 1rem; }
.chart { width: 100%; min-width: 30rem; height: auto; display: block; }
.chart .bar { fill: var(--spruce); }
.chart .bar:hover { fill: var(--diesel); }
.chart .axis { font-size: 11px; fill: var(--muted); }

/* tables */
.tbl { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); }
.tbl th, .tbl td { padding: .5rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tbl th.r, .tbl td.r { text-align: right; }
.tbl thead th { background: #e9eee8; font-weight: 600; white-space: nowrap; }
.tbl tfoot th { background: #e9eee8; }
.tbl tbody tr:hover { background: #f7f9f6; }
.tbl .empty, .empty { color: var(--muted); padding: 1rem; }
.tbl .muted-row td { color: var(--muted); background: #f7f9f6; }
.tbl input.num { width: 9rem; text-align: right; }
.panel .tbl { border: 0; }

/* forms */
.form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1rem; }
.form.narrow { max-width: 30rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .75rem; font-size: .95rem; }
.inline-form .field, .filters .field { margin-bottom: 0; }
.field.grow { flex: 1; min-width: 12rem; }
.field.inline { flex-direction: row; align-items: center; gap: .5rem; }
input[type=text], input[type=search], input[type=tel], input[type=password], input[type=date], input[type=number], select, textarea {
  font: inherit; padding: .45rem .55rem; border: 1px solid #aeb8b1; border-radius: var(--radius); background: #fff; color: var(--ink); min-width: 0;
}
input.num { text-align: right; }
.check { display: inline-flex; gap: .4rem; align-items: center; }
.filters { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: center; margin-bottom: 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .5rem; }
.page-head { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; align-items: flex-start; justify-content: space-between; margin-bottom: .5rem; }
.page-head h1 { margin-bottom: .25rem; }
.summary, .balance-line, .status-line { margin: .25rem 0 1rem; }
.balance-line strong { font-size: 1.3rem; }
.machine-list { display: grid; gap: .5rem; margin-bottom: 1rem; }
.machine-row { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .9rem; }
.machine-row input[type=text] { width: 12rem; }
.mini { display: flex; gap: .4rem; }
.mini input { width: 10rem; }

/* buttons */
.btn {
  display: inline-block; font: inherit; padding: .45rem .95rem; border: 1px solid #8fa098; border-radius: var(--radius);
  background: #fff; color: var(--ink); text-decoration: none; cursor: pointer; line-height: 1.3;
}
.btn:hover { background: #eef2ee; color: var(--ink); }
.btn.primary { background: var(--spruce); border-color: var(--spruce); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--spruce-dark); color: #fff; }
.btn.danger { border-color: var(--owed); color: var(--owed); }
.btn.danger:hover { background: var(--err-bg); }
.btn.wide { width: 100%; text-align: center; }
.hero .btn { border-color: #fff; }
.hero .btn.primary { background: #e2a21a; border-color: #e2a21a; color: #1b1405; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--spruce); cursor: pointer; text-decoration: underline; }
.danger-text { color: var(--owed); }
.danger-zone { border-color: #e3b2ab; }
.pager { display: flex; gap: 1rem; align-items: center; margin: 1rem 0; }
.tabs { display: flex; gap: .25rem; }
.tabs a { padding: .4rem .9rem; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; background: #fff; }
.tabs a.on { background: var(--spruce); color: #fff; border-color: var(--spruce); }

/* badges and tags */
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 99px; font-size: .85rem; font-weight: 600; }
.badge.ok { background: var(--spruce-soft); color: var(--spruce); }
.badge.warn { background: var(--warn-bg); color: #7a5600; }
.hero .badge.ok { background: #cfe8dd; }
.tag { display: inline-block; padding: .05rem .5rem; border-radius: 3px; font-size: .85rem; font-weight: 600; }
.tag.diesel { background: var(--diesel-soft); color: #7a4f00; }
.tag.petrol { background: var(--petrol-soft); color: #134a63; }

/* daily closing */
.closing-grid { display: grid; grid-template-columns: minmax(0, 1fr) 21rem; gap: 1.25rem; align-items: start; }
.closing fieldset { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 1rem; padding: .5rem 1.1rem .9rem; }
.closing legend { font-weight: 650; padding: 0 .4rem; }
.field.row { flex-direction: row; justify-content: space-between; align-items: center; gap: 1rem; }
.field.row input { width: 10rem; }
.closing fieldset > .field:not(.row) input { width: 100%; }
.cashbook { position: sticky; top: 1rem; background: var(--surface); border: 2px solid var(--spruce); border-radius: var(--radius); padding: 1rem 1.2rem; }
.cashbook h2 { margin-top: 0; }
.cashbook dl { display: grid; grid-template-columns: 1fr auto; gap: .35rem 1rem; margin: 0 0 1rem; }
.cashbook dt { color: var(--muted); }
.cashbook dd { margin: 0; text-align: right; }
.cashbook .total { color: var(--ink); font-weight: 700; font-size: 1.15rem; border-top: 1px solid var(--line); padding-top: .5rem; }

/* login and installer */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 1rem; background: var(--spruce); }
.login-box { background: #fff; border-radius: var(--radius); padding: 1.75rem; width: 100%; max-width: 24rem; }
.login-box.wide-box { max-width: 34rem; }
.login-box textarea { width: 100%; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

@media (max-width: 62rem) {
  .closing-grid { grid-template-columns: 1fr; }
  .cashbook { position: static; }
}
@media (max-width: 52rem) {
  .topbar { display: flex; align-items: center; gap: .75rem; background: var(--spruce); color: #fff; padding: .6rem 1rem; position: sticky; top: 0; z-index: 5; }
  .topbar-title { font-weight: 700; }
  .menu-btn { font: inherit; background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.6); border-radius: var(--radius); padding: .3rem .75rem; }
  .shell { display: block; }
  .side { display: none; width: auto; }
  .side.open { display: flex; }
  .main { padding: 1.25rem 1rem 2.5rem; }
  .od { font-size: 1.4rem; width: 1.15rem; }
  .field.row { flex-direction: column; align-items: stretch; gap: .25rem; }
  .field.row input { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  .side, .topbar, .noprint, .btn, .flash { display: none !important; }
  body { background: #fff; }
  .main { padding: 0; max-width: none; }
  .tbl { font-size: 11pt; }
  a { color: #000; text-decoration: none; }
}
