:root {
  --paper: #ECEAE3;      /* concrete apron */
  --panel: #FFFFFF;
  --panel-2: #F5F3EE;
  --ink: #1A1D1F;
  --ink-soft: #5C6469;
  --line: #CBC7BD;
  --line-hard: #1A1D1F;
  --diesel: #C8951C;     /* plant-machinery amber */
  --steel: #33434D;      /* tank steel */
  --red: #A93226;
  --amber: #B8760F;
  --green: #1F6F49;

  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --cond: "Barlow Condensed", "Arial Narrow", var(--sans);
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;

  --gap: 14px;
  --tap: 52px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 {
  font-family: var(--cond);
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0 0 8px;
  line-height: 1.1;
}
h1 { font-size: 30px; }
h2 { font-size: 23px; }
h3 { font-size: 19px; }

a { color: var(--steel); }
:focus-visible { outline: 3px solid var(--diesel); outline-offset: 2px; }

/* ---------- shell ---------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 14px;
  background: var(--steel); color: #fff;
  position: sticky; top: 0; z-index: 20;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-name { font-family: var(--cond); font-size: 22px; font-weight: 600; }
.brand-mark {
  width: 15px; height: 22px; display: inline-block;
  background: linear-gradient(to top, var(--diesel) 62%, transparent 62%);
  border: 2px solid #fff; border-radius: 2px 2px 4px 4px;
}
.brand-mark.big { width: 26px; height: 38px; border-color: var(--steel);
  background: linear-gradient(to top, var(--diesel) 62%, transparent 62%); }
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.whoami { opacity: .85; }
.link-btn { background: none; border: 0; color: #fff; font: inherit; text-decoration: underline; cursor: pointer; padding: 6px; }

.view { padding: var(--gap) var(--gap) 90px; max-width: 1080px; margin: 0 auto; }

/* bottom tabs on phones, left rail on desktop */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: grid; grid-auto-flow: column;
  background: var(--panel); border-top: 2px solid var(--line-hard);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  min-height: var(--tap); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; text-decoration: none; color: var(--ink-soft);
  font-family: var(--cond); font-size: 15px; letter-spacing: .02em;
  border-top: 3px solid transparent;
}
.tabbar a[aria-current="page"] { color: var(--ink); border-top-color: var(--diesel); }
.tabbar .dot { display: inline-block; min-width: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--red); color: #fff; font-family: var(--mono); font-size: 11px; line-height: 18px; }
.rail { display: none; }

@media (min-width: 860px) {
  .tabbar { display: none; }
  .rail {
    display: flex; flex-direction: column; gap: 2px;
    position: fixed; top: 56px; bottom: 0; left: 0; width: 190px;
    background: var(--panel); border-right: 2px solid var(--line-hard); padding: 12px 0;
  }
  .rail a {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 11px 16px; text-decoration: none; color: var(--ink-soft);
    font-family: var(--cond); font-size: 18px; border-left: 4px solid transparent;
  }
  .rail a[aria-current="page"] { color: var(--ink); border-left-color: var(--diesel); background: var(--panel-2); }
  .rail .dot { background: var(--red); color: #fff; border-radius: 9px; padding: 0 6px;
    font-family: var(--mono); font-size: 12px; }
  .view { margin-left: 190px; padding: 20px 24px 40px; }
}

/* ---------- panels ---------- */

.panel { background: var(--panel); border: 1px solid var(--line); padding: 14px; margin-bottom: var(--gap); }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.panel.flagged { border-left: 5px solid var(--red); }
.panel.warn { border-left: 5px solid var(--amber); }
.panel.good { border-left: 5px solid var(--green); }

.grid { display: grid; gap: var(--gap); }
@media (min-width: 720px) { .grid.two { grid-template-columns: 1fr 1fr; } }

.muted { color: var(--ink-soft); }
.small { font-size: 14px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.stack { display: grid; gap: 10px; }

/* ---------- tank gauge (the hero) ---------- */

.tank-hero { display: grid; grid-template-columns: 96px 1fr; gap: 18px; align-items: stretch; }
.gauge {
  position: relative; border: 3px solid var(--steel); border-radius: 6px 6px 12px 12px;
  background: repeating-linear-gradient(180deg, transparent 0 27px, rgba(51,67,77,.14) 27px 28px);
  min-height: 190px; overflow: hidden;
}
.gauge-fill { position: absolute; left: 0; right: 0; bottom: 0; background: var(--diesel); transition: height .5s ease; }
.gauge-fill.low { background: var(--red); }
.gauge-mark { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--steel); }
.gauge-mark span { position: absolute; right: 3px; top: -17px; font-family: var(--mono); font-size: 10px; color: var(--steel); }
.tank-readout .litres { font-family: var(--mono); font-size: 42px; font-weight: 600; line-height: 1; }
.tank-readout .litres small { font-size: 17px; font-weight: 500; color: var(--ink-soft); }
.tank-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 14px; }
.fact { border-top: 2px solid var(--line-hard); padding-top: 6px; }
.fact b { display: block; font-family: var(--mono); font-size: 19px; font-weight: 600; }
.fact span { font-size: 13px; color: var(--ink-soft); }

/* ---------- forms ---------- */

label { display: block; font-size: 14px; color: var(--ink-soft); margin-bottom: 10px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--panel);
  border: 2px solid var(--line-hard); border-radius: 0; padding: 12px;
  min-height: var(--tap); margin-top: 4px;
}
input[type="number"], .mono-input { font-family: var(--mono); font-size: 19px; }
textarea { min-height: 84px; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%),
  linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 20px) 22px, calc(100% - 14px) 22px;
  background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; padding-right: 40px; }
fieldset { border: 0; padding: 0; margin: 0 0 4px; }

.btn {
  min-height: var(--tap); padding: 12px 18px; border: 2px solid var(--line-hard); background: var(--panel);
  color: var(--ink); font-family: var(--cond); font-size: 19px; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--diesel); border-color: #8A6510; }
.btn.steel { background: var(--steel); color: #fff; border-color: var(--steel); }
.btn.danger { background: var(--red); color: #fff; border-color: #7C241B; }
.btn.block { width: 100%; }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.capture { border: 2px solid var(--line-hard); background: var(--panel-2); padding: 12px; margin-bottom: 12px; }
.capture h3 { margin-bottom: 4px; }
.capture .hint { font-size: 13px; color: var(--ink-soft); margin: 0 0 10px; }
.capture .shot { display: flex; gap: 10px; align-items: flex-start; }
.capture img { width: 84px; height: 84px; object-fit: cover; border: 2px solid var(--line-hard); }
.ocr-state { font-size: 13px; color: var(--ink-soft); min-height: 18px; }
.ocr-state.done { color: var(--green); }
.ocr-state.fail { color: var(--red); }

/* ---------- lists and tables ---------- */

.list { display: grid; gap: 10px; }
.item {
  background: var(--panel); border: 1px solid var(--line); border-left: 5px solid var(--line);
  padding: 12px; display: grid; gap: 4px;
}
.item.red { border-left-color: var(--red); }
.item.watch { border-left-color: var(--amber); }
.item.ok { border-left-color: var(--green); }
.item .head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.item .code { font-family: var(--cond); font-size: 20px; font-weight: 600; }
.item .when { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
.item .facts { display: flex; flex-wrap: wrap; gap: 6px 16px; font-family: var(--mono); font-size: 14px; }
.item .why { font-size: 14px; color: var(--red); }
.item .note { font-size: 14px; }

.tag { display: inline-block; font-size: 12px; padding: 2px 7px; border: 1px solid var(--line-hard); }
.tag.red { background: var(--red); color: #fff; border-color: var(--red); }
.tag.amber { background: var(--amber); color: #fff; border-color: var(--amber); }
.tag.green { background: var(--green); color: #fff; border-color: var(--green); }
.tag.steel { background: var(--steel); color: #fff; border-color: var(--steel); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 8px 8px 0; border-bottom: 1px solid var(--line); }
th { font-family: var(--cond); font-size: 16px; font-weight: 600; }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }

.empty { border: 2px dashed var(--line); padding: 22px 16px; text-align: center; color: var(--ink-soft); }
.empty .btn { margin-top: 12px; }
.err { color: var(--red); font-size: 14px; }

/* ---------- login ---------- */

.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: var(--steel); }
.login-card { background: var(--panel); border: 2px solid var(--line-hard); padding: 26px; width: min(400px, 100%); }
.login-card h1 { margin: 10px 0 2px; }
.login-sub { margin: 0 0 18px; color: var(--ink-soft); font-size: 14px; }

/* ---------- toast and offline queue ---------- */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 84px; z-index: 40;
  background: var(--ink); color: #fff; padding: 12px 18px; max-width: 92vw;
  border-left: 5px solid var(--diesel); font-size: 15px;
}
.toast.bad { border-left-color: var(--red); }
.toast.good { border-left-color: var(--green); }
.queue-bar {
  position: fixed; left: 0; right: 0; bottom: 68px; z-index: 30;
  background: var(--amber); color: #fff; padding: 8px 14px; font-size: 14px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
@media (min-width: 860px) { .toast { bottom: 24px; } .queue-bar { bottom: 0; } }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
