/* TapLedger. Dark by intent, not by default: this board is read in a cellar
   and a cold room under low light, and the tank fills carry real beer colour
   which only reads correctly against a dark ground. */

:root {
  --ground:    oklch(15.5% 0.012 62);
  --surface:   oklch(19.5% 0.014 62);
  --surface-2: oklch(23.5% 0.016 62);
  --raised:    oklch(27% 0.018 62);
  --line:      oklch(31% 0.014 62);
  --line-soft: oklch(25% 0.012 62);

  --text:      oklch(95% 0.008 75);
  --muted:     oklch(68% 0.012 75);
  --faint:     oklch(52% 0.010 75);

  --amber:     oklch(78% 0.152 72);
  --copper:    oklch(64% 0.132 44);
  --ok:        oklch(74% 0.148 156);
  --warn:      oklch(80% 0.150 86);
  --bad:       oklch(66% 0.196 26);
  --cool:      oklch(72% 0.110 232);

  --display: "Instrument Serif", Georgia, serif;
  --body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 18px; --s5: 26px; --s6: 40px; --s7: 64px;
  --r1: 6px; --r2: 10px; --r3: 16px;
  --fast: 140ms; --normal: 280ms;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --shadow: 0 1px 2px oklch(0% 0 0 / .5), 0 8px 28px -12px oklch(0% 0 0 / .7);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--ground);
  color: var(--text);
  font: 400 15px/1.55 var(--body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
/* a faint mill grain so large dark fields are not dead flat */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: .5; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.045'/%3E%3C/svg%3E");
}
#app { position: relative; z-index: 1; }

a { color: inherit; }
canvas { max-width: 100%; }

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

.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.rail {
  border-right: 1px solid var(--line-soft);
  background: linear-gradient(180deg, var(--surface), var(--ground) 60%);
  padding: var(--s5) 0 var(--s4);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--s2);
}
.brand { padding: 0 var(--s5) var(--s4); }
.brand__mark {
  font: 400 27px/1 var(--display); letter-spacing: -.01em;
  display: flex; align-items: baseline; gap: 7px;
}
.brand__mark b { color: var(--amber); font-weight: 400; }
.brand__sub {
  font: 500 10px/1.4 var(--mono); letter-spacing: .13em; text-transform: uppercase;
  color: var(--faint); margin-top: 7px;
}
.nav { display: flex; flex-direction: column; }
.nav__group {
  font: 500 9.5px/1 var(--mono); letter-spacing: .15em; text-transform: uppercase;
  color: var(--faint); padding: var(--s4) var(--s5) var(--s2);
}
.nav a {
  display: flex; align-items: center; gap: var(--s3);
  padding: 9px var(--s5); text-decoration: none; color: var(--muted);
  border-left: 2px solid transparent; font-size: 14px;
  transition: color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.nav a:hover { color: var(--text); background: oklch(100% 0 0 / .035); }
.nav a.on {
  color: var(--text); border-left-color: var(--amber);
  background: linear-gradient(90deg, oklch(78% .152 72 / .12), transparent 70%);
}
.nav a .k {
  margin-left: auto; font: 500 10px/1 var(--mono); color: var(--faint);
}
.rail__foot { margin-top: auto; padding: var(--s4) var(--s5) 0; }

.main { padding: var(--s6) var(--s6) var(--s7); max-width: 1500px; }

.head { margin-bottom: var(--s5); }
.head__eyebrow {
  font: 500 10px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase;
  color: var(--amber); margin-bottom: var(--s3);
}
.head h1 {
  font: 400 clamp(30px, 2.6vw, 44px)/1.02 var(--display);
  letter-spacing: -.015em; margin: 0 0 var(--s2);
}
.head p { color: var(--muted); margin: 0; max-width: 68ch; font-size: 14.5px; }

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

.panel {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r3); padding: var(--s5);
  box-shadow: var(--shadow);
}
.panel--flush { padding: 0; overflow: hidden; }
.panel__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s4); margin-bottom: var(--s4); flex-wrap: wrap;
}
.panel--flush .panel__head { padding: var(--s5) var(--s5) 0; margin-bottom: var(--s3); }
.panel__title { font: 500 12px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.panel__sub { font-size: 13px; color: var(--faint); }

.grid { display: grid; gap: var(--s4); align-items: start; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid--tanks { grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); }
.grid--wide { grid-template-columns: 1.65fr 1fr; }
.span-2 { grid-column: span 2; }
/* Let a chart grow to match a taller neighbour instead of leaving a hole. */
.grid--stretch { align-items: stretch; }
.panel--fill { display: flex; flex-direction: column; }
.panel--fill .chart { flex: 1; height: auto; min-height: 240px; }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }

/* ----------------------------------------------------------------- stats */

.stat { padding: var(--s4) 0; }
.stat__label {
  font: 500 10px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase;
  color: var(--faint); margin-bottom: 10px;
}
.stat__value {
  font: 400 clamp(28px, 2.5vw, 40px)/1 var(--display);
  letter-spacing: -.02em; display: flex; align-items: baseline; gap: 6px;
}
.stat__unit { font: 500 11px/1 var(--mono); color: var(--muted); letter-spacing: .06em; }
.stat__foot { font-size: 12.5px; color: var(--faint); margin-top: 9px; }
.stat--ok .stat__value { color: var(--ok); }
.stat--warn .stat__value { color: var(--warn); }
.stat--bad .stat__value { color: var(--bad); }
.stat--amber .stat__value { color: var(--amber); }

/* divided KPI strip, no card borders, rhythm from rules not boxes */
.kpibar {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r3); overflow: hidden; box-shadow: var(--shadow);
}
.kpibar > * { padding: var(--s4) var(--s5); border-right: 1px solid var(--line-soft); }
.kpibar > *:last-child { border-right: 0; }

/* ----------------------------------------------------------------- tanks */

.tank {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r2); overflow: hidden; display: flex; flex-direction: column;
  transition: transform var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.tank:hover { transform: translateY(-2px); border-color: var(--line); }
.tank--empty { opacity: .55; }
.tank--empty .tank__liquid { display: none; }
.tank__top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px var(--s3) 8px;
}
.tank__code { font: 600 13px/1 var(--mono); letter-spacing: .04em; }
.tank__vessel {
  position: relative; height: 112px; margin: 0 var(--s3);
  border: 1px solid var(--line); border-radius: 4px 4px 11px 11px;
  background:
    linear-gradient(90deg, oklch(0% 0 0 / .35), transparent 22%, transparent 78%, oklch(0% 0 0 / .35)),
    var(--surface-2);
  overflow: hidden;
}
.tank__liquid {
  position: absolute; left: 0; right: 0; bottom: 0;
  transition: height var(--normal) var(--ease);
  background: linear-gradient(180deg, var(--beer, var(--amber)), color-mix(in oklab, var(--beer, var(--amber)) 74%, black));
  box-shadow: inset 0 1px 0 oklch(100% 0 0 / .35);
}
.tank__liquid::before {                      /* krausen or foam line */
  content: ""; position: absolute; left: 0; right: 0; top: -3px; height: 5px;
  background: color-mix(in oklab, var(--beer, var(--amber)) 30%, white);
  opacity: .8; border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}
.tank__ticks { position: absolute; inset: 0; }
.tank__ticks i {
  position: absolute; right: 0; width: 7px; height: 1px; background: var(--line);
}
.tank__pct {
  position: absolute; inset: auto 0 6px; text-align: center;
  font: 600 11px/1 var(--mono); color: oklch(12% 0 0 / .8); mix-blend-mode: hard-light;
}
.tank__meta { padding: 10px var(--s3) var(--s3); }
.tank__beer {
  font-size: 13px; font-weight: 500; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.tank__line {
  display: flex; justify-content: space-between; gap: 6px;
  font: 400 11px/1.5 var(--mono); color: var(--faint); margin-top: 5px;
}

/* ----------------------------------------------------------------- pills */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font: 500 10px/1 var(--mono); letter-spacing: .09em; text-transform: uppercase;
  padding: 4px 8px; border-radius: 100px; border: 1px solid;
  color: var(--muted); border-color: var(--line);
  background: var(--surface-2); white-space: nowrap;
}
.pill--ok   { color: var(--ok);   border-color: color-mix(in oklab, var(--ok) 42%, transparent);   background: color-mix(in oklab, var(--ok) 12%, transparent); }
.pill--warn { color: var(--warn); border-color: color-mix(in oklab, var(--warn) 42%, transparent); background: color-mix(in oklab, var(--warn) 12%, transparent); }
.pill--bad  { color: var(--bad);  border-color: color-mix(in oklab, var(--bad) 45%, transparent);  background: color-mix(in oklab, var(--bad) 13%, transparent); }
.pill--amber{ color: var(--amber);border-color: color-mix(in oklab, var(--amber) 42%, transparent);background: color-mix(in oklab, var(--amber) 12%, transparent); }
.pill--cool { color: var(--cool); border-color: color-mix(in oklab, var(--cool) 42%, transparent); background: color-mix(in oklab, var(--cool) 12%, transparent); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------------------------------------------------------------- tables */

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font: 500 10px/1 var(--mono); letter-spacing: .12em;
  text-transform: uppercase; color: var(--faint);
  padding: 0 var(--s3) var(--s3); border-bottom: 1px solid var(--line);
  white-space: nowrap; position: sticky; top: 0; background: var(--surface);
}
.table td { padding: 11px var(--s3); border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr { transition: background var(--fast) var(--ease); }
.table tbody tr:hover { background: oklch(100% 0 0 / .028); }
.table tbody tr:last-child td { border-bottom: 0; }
.table--pad td:first-child, .table--pad th:first-child { padding-left: var(--s5); }
.table--pad td:last-child,  .table--pad th:last-child  { padding-right: var(--s5); }
.num { font: 400 13px/1 var(--mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
th.num { text-align: right; }
.strong { font-weight: 600; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.pos { color: var(--ok); } .neg { color: var(--bad); } .amber { color: var(--amber); }

.scroll { overflow-x: auto; }
.scrollY { max-height: 440px; overflow-y: auto; }

/* ------------------------------------------------------------------ bars */

.bar { height: 6px; border-radius: 100px; background: var(--surface-2); overflow: hidden; min-width: 56px; }
.bar__fill { height: 100%; border-radius: 100px; background: var(--amber); transition: width var(--normal) var(--ease); }
.bar__fill--ok { background: var(--ok); } .bar__fill--warn { background: var(--warn); } .bar__fill--bad { background: var(--bad); }

.meter { display: grid; grid-template-columns: 1fr auto; gap: var(--s3); align-items: center; }
.gauge { position: relative; height: 8px; border-radius: 100px; background: var(--surface-2); }
.gauge__band { position: absolute; inset: 0; border-radius: 100px; opacity: .3;
  background: linear-gradient(90deg, var(--ok) 0 38%, var(--warn) 38% 70%, var(--bad) 70% 100%); }
.gauge__pin { position: absolute; top: -4px; width: 2px; height: 16px; background: var(--text); border-radius: 2px; }

/* --------------------------------------------------------------- controls */

.btn {
  font: 500 12px/1 var(--mono); letter-spacing: .07em; text-transform: uppercase;
  padding: 9px 14px; border-radius: var(--r1); cursor: pointer;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  transition: all var(--fast) var(--ease);
}
.btn:hover { background: var(--raised); border-color: var(--muted); }
.btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.btn--primary { background: var(--amber); color: oklch(18% .03 62); border-color: var(--amber); font-weight: 600; }
.btn--primary:hover { background: color-mix(in oklab, var(--amber) 88%, white); }
.btn--ghost { background: transparent; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r1); overflow: hidden; }
.seg button {
  font: 500 11px/1 var(--mono); letter-spacing: .07em; padding: 8px 13px;
  background: transparent; color: var(--muted); border: 0; cursor: pointer;
  border-right: 1px solid var(--line); transition: all var(--fast) var(--ease);
}
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--text); background: oklch(100% 0 0 / .04); }
.seg button[aria-pressed="true"] { background: var(--amber); color: oklch(18% .03 62); font-weight: 600; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font: 500 10px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.field input, .field select {
  font: 400 15px/1 var(--body); padding: 11px var(--s3); border-radius: var(--r1);
  background: var(--ground); color: var(--text); border: 1px solid var(--line);
  min-height: 44px;
}
.field input:focus, .field select:focus { outline: 2px solid var(--amber); outline-offset: 1px; border-color: var(--amber); }
.field input.num { font: 500 17px/1 var(--mono); text-align: left; }

.note {
  border-left: 2px solid var(--amber); padding: var(--s3) var(--s4);
  background: color-mix(in oklab, var(--amber) 7%, transparent);
  border-radius: 0 var(--r1) var(--r1) 0; font-size: 13.5px; color: var(--muted);
}
.note--bad { border-left-color: var(--bad); background: color-mix(in oklab, var(--bad) 8%, transparent); }
.empty { padding: var(--s6); text-align: center; color: var(--faint); font-size: 14px; }
.chart { position: relative; height: 260px; }
.chart--tall { height: 340px; }
.chart--short { height: 180px; }

/* --------------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  .grid--wide, .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: sticky; top: 0; height: auto; z-index: 20; padding: var(--s3) 0;
    border-right: 0; border-bottom: 1px solid var(--line-soft);
  }
  .brand { padding: 0 var(--s4) var(--s3); }
  .nav { flex-direction: row; overflow-x: auto; gap: 2px; padding: 0 var(--s3); }
  .nav__group, .nav a .k, .rail__foot { display: none; }
  .nav a { border-left: 0; border-bottom: 2px solid transparent; white-space: nowrap; padding: 8px 12px; }
  .nav a.on { border-left: 0; border-bottom-color: var(--amber); background: none; }
  .main { padding: var(--s5) var(--s4) var(--s7); }
  .grid--wide, .grid--4, .grid--3, .grid--2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media print {
  .rail, .btn, .seg { display: none !important; }
  body, .panel { background: #fff; color: #000; }
  .main { padding: 0; max-width: none; }
  .panel { border: 1px solid #ccc; box-shadow: none; }
}
