/* ==========================================================================
   Батч-план обсмажування — стилі
   Шрифти вшиті локально: застосунок повністю працює офлайн.
   ========================================================================== */

/* ---- Golos Text (заголовки) ---- */
@font-face { font-family: "Golos Text"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/golos-text-cyrillic-700-normal.woff2") format("woff2");
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: "Golos Text"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/golos-text-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Golos Text"; font-style: normal; font-weight: 800; font-display: swap;
  src: url("fonts/golos-text-cyrillic-800-normal.woff2") format("woff2");
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: "Golos Text"; font-style: normal; font-weight: 800; font-display: swap;
  src: url("fonts/golos-text-latin-800-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

/* ---- IBM Plex Sans (інтерфейс) ---- */
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/ibm-plex-sans-cyrillic-400-normal.woff2") format("woff2");
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/ibm-plex-sans-cyrillic-500-normal.woff2") format("woff2");
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/ibm-plex-sans-cyrillic-600-normal.woff2") format("woff2");
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

/* ---- IBM Plex Mono (цифри та мітки) ---- */
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/ibm-plex-mono-cyrillic-400-normal.woff2") format("woff2");
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/ibm-plex-mono-cyrillic-500-normal.woff2") format("woff2");
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/ibm-plex-mono-cyrillic-600-normal.woff2") format("woff2");
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/ibm-plex-mono-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

/* ==========================================================================
   Токени
   ========================================================================== */

:root {
  --bg: #F2F4F4;
  --surface: #FFFFFF;
  --surface-2: #E9EEEE;
  --ink: #131A1C;
  --muted: #5E6E71;
  --faint: #8A9A9C;
  --line: #D3DCDC;
  --line-strong: #B6C4C4;
  --accent: #0E6E72;
  --accent-soft: #DCEAEA;
  --ok: #1F7A4D;
  --ok-soft: #DDEEE4;
  --warn: #9C6410;
  --warn-soft: #F4E9D4;
  --bad: #AE3030;
  --bad-soft: #F6DFDD;
  --shadow: 0 1px 2px rgba(19,26,28,.06), 0 8px 24px -16px rgba(19,26,28,.18);

  --f-display: "Golos Text", "Segoe UI", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1315;
    --surface: #151E20;
    --surface-2: #1C2729;
    --ink: #E4EBEA;
    --muted: #93A6A8;
    --faint: #6E8285;
    --line: #253335;
    --line-strong: #35474A;
    --accent: #4FBDB9;
    --accent-soft: #16302F;
    --ok: #52C98C;
    --ok-soft: #16301F;
    --warn: #E0A44B;
    --warn-soft: #322613;
    --bad: #F0817A;
    --bad-soft: #351D1C;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -16px rgba(0,0,0,.6);
  }
}

:root[data-theme="dark"] {
  --bg: #0D1315;
  --surface: #151E20;
  --surface-2: #1C2729;
  --ink: #E4EBEA;
  --muted: #93A6A8;
  --faint: #6E8285;
  --line: #253335;
  --line-strong: #35474A;
  --accent: #4FBDB9;
  --accent-soft: #16302F;
  --ok: #52C98C;
  --ok-soft: #16301F;
  --warn: #E0A44B;
  --warn-soft: #322613;
  --bad: #F0817A;
  --bad-soft: #351D1C;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -16px rgba(0,0,0,.6);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

/* ==========================================================================
   Верхня панель застосунку
   ========================================================================== */

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line-strong);
}

.tabs {
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 18px;
}
.tabs::-webkit-scrollbar { display: none; }

.tabs button {
  flex: 0 0 auto;
  font-family: var(--f-body);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 11px 15px 9px;
  cursor: pointer;
  white-space: nowrap;
}
.tabs button:hover { color: var(--ink); }
.tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tabs button[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.panelgroup { display: flex; flex-direction: column; gap: 30px; }
[hidden] { display: none !important; }

.appbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 18px 8px;
  max-width: 1120px;
  margin: 0 auto;
}
.appbar img { width: 26px; height: 26px; border-radius: 6px; flex: 0 0 auto; }
.appbar .name {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.01em;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.appbar .spacer { flex: 1 1 auto; }

.themes { display: flex; border: 1px solid var(--line-strong); border-radius: 3px; overflow: hidden; }
.themes button {
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 5px 8px;
  border: 0;
  border-right: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.themes button:last-child { border-right: 0; }
.themes button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

/* ==========================================================================
   Каркас
   ========================================================================== */

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 18px 120px;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

/* порожня плашка оновлення не має займати відступ у flex-потоці */
#update-bar:empty { display: none; }

.masthead { display: flex; flex-direction: column; gap: 14px; }

.eyebrow {
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: clamp(27px, 6vw, 42px);
  letter-spacing: -.025em;
  line-height: 1.04;
  margin: 0;
  text-wrap: balance;
}

.lede { margin: 0; max-width: 62ch; color: var(--muted); }

.machine {
  display: flex;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  overflow: hidden;
}
.machine div {
  flex: 1 1 160px;
  padding: 11px 15px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.machine .k {
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--faint);
}
.machine .v {
  font-family: var(--f-mono);
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.machine .v small { font-size: 11.5px; font-weight: 400; color: var(--muted); }

section { display: flex; flex-direction: column; gap: 13px; }

.sec-head { display: flex; align-items: baseline; gap: 11px; flex-wrap: wrap; }

h2 {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -.01em;
  margin: 0;
}
.sec-note { color: var(--muted); font-size: 13px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.scroll { overflow-x: auto; }

/* ==========================================================================
   Таблиці (широкий екран)
   ========================================================================== */

table { width: 100%; border-collapse: collapse; font-size: 14px; }

thead th {
  font-family: var(--f-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .085em;
  text-transform: uppercase;
  color: var(--faint);
  text-align: right;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
  vertical-align: bottom;
}
thead th:first-child { text-align: left; }

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody td:first-child {
  text-align: left;
  font-family: var(--f-body);
  font-weight: 500;
}

tfoot td {
  padding: 12px 14px;
  border-top: 1px solid var(--line-strong);
  text-align: right;
  font-family: var(--f-mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--surface-2);
  white-space: nowrap;
}
tfoot td:first-child { text-align: left; font-family: var(--f-body); }

.code {
  font-family: var(--f-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .06em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 5px;
  border-radius: 2px;
  white-space: nowrap;
}

.mix { display: inline-flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.mix span {
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1px 5px;
  font-variant-numeric: tabular-nums;
}

.blend-name { display: flex; flex-direction: column; }
.blend-name b { font-weight: 600; }
.ratio { color: var(--muted); font-weight: 400; font-family: var(--f-mono); font-size: 12px; }

/* ==========================================================================
   Поля
   ========================================================================== */

input[type="number"] {
  width: 96px;
  padding: 8px 10px;
  text-align: right;
  font-family: var(--f-mono);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  appearance: textfield;
  -moz-appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
input[type="number"].hot { border-color: var(--accent); }

.unit { color: var(--faint); font-family: var(--f-mono); font-size: 11px; margin-left: 6px; }
.nowrap { white-space: nowrap; }
.warn-text { color: var(--warn); }

/* ---------- розділ 2: ужарка та її наслідок ---------- */

#stock-rows td.losscell {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
#stock-rows td.losscell input[type="number"] { width: 78px; }
.meas { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.meas .unit { margin-left: 0; }
#stock-rows td.yieldcell { font-weight: 600; }

button.btn.tiny {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 2px;
}

button.btn.primary { border-color: var(--accent); color: var(--accent); font-weight: 600; }
button.btn:disabled { opacity: .45; cursor: not-allowed; }
button.btn:disabled:hover { border-color: var(--line-strong); color: var(--ink); }

/* ---------- розділ 5: факт після обсмажки ---------- */

.runmeta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  padding: 14px 15px;
  border-bottom: 1px solid var(--line);
}
.runmeta label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
}
.runmeta input {
  font-family: var(--f-mono);
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: 8px 10px;
  min-width: 170px;
}
.runmeta input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

#fact-rows td.factloss { font-weight: 600; }
#fact-rows td.factloss .unit { font-weight: 400; }

/* ---------- розділ 6: журнал ---------- */

.bad-chip { color: var(--bad) !important; border-color: var(--bad) !important; }

/* «Запакувати» — розрахований результат розділу 1, а не поле вводу */
#blend-rows td.topack { font-weight: 600; font-size: 15px; }
#blend-rows tfoot td { font-weight: 600; }

/* ==========================================================================
   Зведення
   ========================================================================== */

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.summary > div {
  background: var(--surface);
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.summary .k {
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--faint);
}
.summary .big {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 32px;
  letter-spacing: -.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.summary .sub { font-size: 12px; color: var(--muted); }
.summary > div.lead .big { color: var(--accent); }

/* ==========================================================================
   Шкала порогу
   ========================================================================== */

.meter { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.meter .raw { font-size: 13px; color: var(--muted); }
.track { position: relative; width: 76px; height: 5px; background: var(--surface-2); border-radius: 3px; }
.track .fill { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--accent-soft); }
.track .tick { position: absolute; left: 40%; top: -3px; bottom: -3px; width: 1px; background: var(--line-strong); }
.track .dot {
  position: absolute; top: 50%; width: 7px; height: 7px; border-radius: 50%;
  transform: translate(-50%, -50%); background: var(--accent);
}
.track .dot.down { background: var(--warn); }

/* ==========================================================================
   Стани
   ========================================================================== */

.pill {
  display: inline-block;
  font-family: var(--f-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .05em;
  padding: 2px 7px;
  border-radius: 2px;
  white-space: nowrap;
}
.pill.ok { color: var(--ok); background: var(--ok-soft); }
.pill.warn { color: var(--warn); background: var(--warn-soft); }
.pill.bad { color: var(--bad); background: var(--bad-soft); }
.pill.idle { color: var(--faint); background: var(--surface-2); }

.batches { font-size: 20px; font-weight: 600; }
.neg { color: var(--bad); }
.zero { color: var(--faint); }

.alerts { display: flex; flex-direction: column; gap: 9px; }
.alert {
  display: flex;
  gap: 11px;
  padding: 12px 15px;
  border-radius: 3px;
  border-left: 3px solid var(--bad);
  background: var(--bad-soft);
  color: var(--ink);
  font-size: 13.5px;
  align-items: flex-start;
}
.alert.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.alert.calm { border-left-color: var(--ok); background: var(--ok-soft); }
.alert .tag {
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  padding-top: 2px;
  white-space: nowrap;
  color: var(--bad);
}
.alert.warn .tag { color: var(--warn); }
.alert.calm .tag { color: var(--ok); }
.alert b { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Кнопки, формула, підвал
   ========================================================================== */

.actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
button.btn {
  font-family: var(--f-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: 9px 14px;
  cursor: pointer;
}
button.btn:hover { border-color: var(--accent); color: var(--accent); }
button.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.formula {
  font-family: var(--f-mono);
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 3px;
  padding: 13px 15px;
  overflow-x: auto;
  white-space: pre;
}

.fine { font-size: 12.5px; color: var(--faint); max-width: 70ch; margin: 0; }

footer.credits {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: baseline;
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--faint);
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

/* ==========================================================================
   Липка стрічка результату (телефон)
   ========================================================================== */

.dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 25;
  background: var(--surface);
  border-top: 1px solid var(--line-strong);
  box-shadow: 0 -6px 20px -12px rgba(0,0,0,.35);
  padding-bottom: env(safe-area-inset-bottom);
}
.dockinner {
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px 18px;
}
.dock .cell { display: flex; flex-direction: column; line-height: 1.15; }
.dock .k {
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--faint);
}
.dock .v {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 21px;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.dock .v.accent { color: var(--accent); }
.dock .v.bad { color: var(--bad); }
.dock .go { margin-left: auto; }

/* ==========================================================================
   Картки замість таблиць на вузькому екрані
   ========================================================================== */

@media (max-width: 880px) {
  .wrap { padding: 20px 14px 132px; gap: 26px; }
  .tabs { padding: 0 8px; }
  .tabs button { padding: 11px 11px 9px; font-size: 13px; }
  .dockinner { gap: 12px; padding: 9px 14px; }

  input[type="number"] { font-size: 16px; width: 100%; max-width: 152px; }

  table, thead, tbody, tfoot, tr, td { display: block; }
  thead { display: none; }

  tbody tr, tfoot tr { padding: 12px 15px; border-bottom: 1px solid var(--line); }
  tbody tr:last-child { border-bottom: 0; }
  tfoot tr { background: var(--surface-2); border-top: 1px solid var(--line-strong); border-bottom: 0; }

  tbody td, tfoot td {
    padding: 3px 0;
    border: 0;
    background: transparent;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    white-space: normal;
    text-align: right;
    min-height: 23px;
    min-width: 0;
  }
  td::before {
    content: attr(data-label);
    font-family: var(--f-mono);
    font-size: 10px;
    font-weight: 400;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--faint);
    text-align: left;
    flex: 0 1 auto;
  }
  td:not([data-label])::before, td.nolabel::before { content: none; }
  td:empty { display: none; }

  /* шапка картки */
  tbody td:first-child, tfoot td:first-child {
    display: block;
    padding: 0 0 5px;
    font-family: var(--f-display);
    font-weight: 700;
    font-size: 15.5px;
    align-self: center;
  }

  /* --- 1 · бленди: назва + поле в один ряд, частки під назвою --- */
  #blend-rows tr { display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; row-gap: 4px; }
  #blend-rows td:nth-child(1) { grid-area: 1 / 1; }
  #blend-rows td.topack { grid-area: 1 / 2; justify-content: flex-end; font-size: 20px; padding: 0 0 4px; }
  #blend-rows td:nth-child(2) { grid-area: 2 / 1 / 3 / 3; justify-content: flex-start; }
  #blend-rows td:nth-child(3) { grid-area: 3 / 1; }
  #blend-rows td:nth-child(4) { grid-area: 3 / 2; }
  #blend-rows td:nth-child(3), #blend-rows td:nth-child(4) {
    flex-direction: column; align-items: stretch; gap: 4px;
  }
  #blend-rows .mix { justify-content: flex-start; }

  /* --- 2 · склад: назва на всю ширину, далі пари полів --- */
  #stock-rows tr { display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; row-gap: 7px; }
  #stock-rows td:nth-child(1) { grid-area: 1 / 1 / 2 / 3; }
  #stock-rows td:nth-child(2) { grid-area: 2 / 1; }
  #stock-rows td:nth-child(3) { grid-area: 2 / 2; justify-content: space-between; }
  #stock-rows td:nth-child(4) { grid-area: 3 / 1; }
  #stock-rows td:nth-child(5) { grid-area: 3 / 2; }
  #stock-rows td:nth-child(2),
  #stock-rows td:nth-child(4),
  #stock-rows td:nth-child(5) {
    flex-direction: column; align-items: stretch; gap: 4px;
  }
  #stock-rows td.losscell { align-items: stretch; }
  #stock-rows td.losscell input[type="number"] { width: 100%; max-width: 152px; }
  .meas { white-space: normal; }

  /* --- 5 · факт: ужарка великим у шапці картки --- */
  #fact-rows tr { display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; row-gap: 5px; }
  #fact-rows td:nth-child(1) { grid-area: 1 / 1; }
  #fact-rows td.factloss { grid-area: 1 / 2; justify-content: flex-end; font-size: 17px; padding: 0 0 4px; }
  #fact-rows td:nth-child(2) { grid-area: 2 / 1; }
  #fact-rows td:nth-child(3) { grid-area: 2 / 2; }
  #fact-rows td:nth-child(2), #fact-rows td:nth-child(3) {
    flex-direction: column; align-items: stretch; gap: 4px;
  }

  /* --- 6 · журнал --- */
  #journal-rows tr { display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; row-gap: 3px; }
  #journal-rows td:nth-child(1) { grid-area: 1 / 1 / 2 / 3; }
  #journal-rows td:nth-child(4) { grid-area: 3 / 1 / 4 / 3; justify-content: flex-start; }
  #journal-rows td:nth-child(5) { grid-area: 4 / 1 / 5 / 3; justify-content: flex-end; }
  .runmeta input { min-width: 0; width: 100%; font-size: 16px; }
  .runmeta label { flex: 1 1 140px; }

  /* --- 3 · результат: батчі великим числом у шапці картки --- */
  #result-rows tr { display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; row-gap: 1px; }
  #result-rows td:nth-child(1) { grid-area: 1 / 1; }
  #result-rows td.batches { grid-area: 1 / 2; justify-content: flex-end; font-size: 26px; padding: 0 0 5px; }

  /* --- 4 · зелене зерно --- */
  #green-rows tr { display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; }
  #green-rows td:nth-child(1) { grid-area: 1 / 1 / 2 / 3; }

  .unit { font-size: 9.5px; margin-left: 5px; }
  .meter { gap: 3px; }
  .summary { grid-template-columns: repeat(auto-fit, minmax(138px, 1fr)); }
  .summary > div { padding: 13px 14px 12px; }
  .summary .big { font-size: 26px; }
  .formula { font-size: 11.5px; }
  .alert { font-size: 13px; }
}

@media (max-width: 380px) {
  .machine div { flex: 1 1 100%; }
  #stock-rows tr, #result-rows tr, #green-rows tr { grid-template-columns: 1fr; }
  #stock-rows td, #result-rows td, #green-rows td { grid-area: auto !important; }
  #result-rows td.batches { justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

@media print {
  body { background: #fff; }
  .topbar, .dock, .actions { display: none !important; }
  .panel { box-shadow: none; }
  /* друк — це знімок усього стану, а не поточної вкладки */
  .panelgroup[hidden] { display: flex !important; }
  .panelgroup { break-inside: avoid; }
}
