/* NP mini — приладова панель підприємства. Світла тема, високий контраст,
   чорні головні кнопки, червоний лише як акцент. Шрифти самохостинг. */
@import url("fonts/fonts.css");

:root {
  /* Бренд: чорний і червоний з логотипа; нейтралі тоновані в теплий червоний. */
  --ink: oklch(19% 0.012 25);
  --ink-2: oklch(38% 0.014 25);
  --ink-3: oklch(52% 0.014 25);
  --line: oklch(86% 0.010 25);
  --line-2: oklch(92% 0.008 25);
  --bg: oklch(97.5% 0.006 30);
  --surface: oklch(99.4% 0.003 30);
  --surface-2: oklch(95% 0.008 30);
  --red: oklch(54% 0.21 27);
  --red-ink: oklch(42% 0.18 27);
  --red-soft: oklch(94% 0.04 27);
  --green: oklch(48% 0.13 150);
  --green-soft: oklch(94% 0.045 150);
  --amber: oklch(62% 0.14 75);
  --amber-soft: oklch(95% 0.06 85);
  --display-bg: oklch(17% 0.01 250);
  --display-fg: oklch(88% 0.19 95);
  --focus: oklch(60% 0.2 27);

  --font-ui: "Onest", "Segoe UI", system-ui, sans-serif;
  --font-display: "Geologica", "Onest", "Segoe UI", system-ui, sans-serif;

  --space-xs: 4px; --space-sm: 8px; --space-md: 12px; --space-lg: 16px;
  --space-xl: 24px; --space-2xl: 32px; --space-3xl: 48px;
  --radius: 10px; --radius-sm: 6px;
  --shadow: 0 1px 2px oklch(20% 0.02 25 / 0.06), 0 6px 20px oklch(20% 0.02 25 / 0.05);
  --tap: 48px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.5 var(--font-ui); font-kerning: normal;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.01em; margin: 0; line-height: 1.15; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: 0.875rem; }
.xs { font-size: 0.75rem; }
.neg { color: var(--red-ink); }
.pos { color: var(--green); }
.hidden { display: none !important; }
svg.i { width: 20px; height: 20px; flex: none; }

/* ── оболонка ─────────────────────────────────────────────── */
.app { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
.topbar {
  display: flex; align-items: center; gap: var(--space-lg);
  padding: var(--space-md) var(--space-lg); padding-top: max(var(--space-md), env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 200;
}
.topbar .brand { display: flex; align-items: center; gap: var(--space-md); text-decoration: none; }
.topbar .brand img { height: 34px; width: auto; display: block; }
.topbar .brand span { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; }
.topbar nav { display: flex; gap: var(--space-xs); flex: 1; overflow-x: auto; scrollbar-width: none; }
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a {
  text-decoration: none; padding: 8px 12px; border-radius: 999px; white-space: nowrap;
  color: var(--ink-2); font-weight: 500; min-height: 40px; display: inline-flex; align-items: center;
}
.topbar nav a.active { background: var(--ink); color: var(--surface); }
.topbar nav a:hover:not(.active) { background: var(--surface-2); }
.topbar .who { display: flex; align-items: center; gap: var(--space-sm); font-size: 0.875rem; color: var(--ink-2); white-space: nowrap; }
.topbar .who b { color: var(--ink); font-weight: 600; }
main { padding: var(--space-xl) var(--space-lg) var(--space-3xl); max-width: 1280px; width: 100%; margin: 0 auto; }
main.narrow { max-width: 640px; }
main.phone { max-width: 520px; padding-inline: var(--space-md); }

/* ── кнопки ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-sm);
  min-height: var(--tap); padding: 0 18px; border-radius: var(--radius); border: 1.5px solid var(--ink);
  background: var(--surface); color: var(--ink); font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: transform .12s cubic-bezier(.2,.8,.2,1), background .15s, opacity .15s;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: var(--surface); }
.btn-primary:hover:not(:disabled) { background: oklch(28% 0.014 25); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.btn-danger { border-color: var(--red); color: var(--red-ink); }
.btn-danger:hover:not(:disabled) { background: var(--red-soft); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.875rem; }
.btn-xl { min-height: 64px; font-size: 1.125rem; padding: 0 24px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-icon { width: var(--tap); padding: 0; }
.btn .spin { display: none; }
.btn.busy .spin { display: inline-block; }
.btn.busy .lbl { opacity: .6; }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }

/* ── форми ────────────────────────────────────────────────── */
.field { display: grid; gap: 6px; }
.field > label { font-size: 0.875rem; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 0.8125rem; color: var(--ink-3); }
.field .err { font-size: 0.8125rem; color: var(--red-ink); }
.input, select.input, textarea.input {
  width: 100%; min-height: var(--tap); padding: 10px 14px; border: 1.5px solid var(--line);
  border-radius: var(--radius); background: var(--surface); transition: border-color .15s;
}
.input:focus { border-color: var(--ink); outline: none; }
.input[aria-invalid="true"] { border-color: var(--red); }
textarea.input { min-height: 80px; resize: vertical; }
.input.num { text-align: right; }
.row { display: flex; gap: var(--space-md); align-items: end; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; }
.row > .fit { flex: 0 0 auto; }
.stack { display: grid; gap: var(--space-lg); }
.stack-sm { display: grid; gap: var(--space-sm); }
.actions { display: flex; gap: var(--space-md); flex-wrap: wrap; align-items: center; }
.check { display: flex; align-items: center; gap: var(--space-sm); min-height: var(--tap); cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--ink); }

/* Випадаючий список з додаванням значення (combobox). */
.combo { position: relative; }
.combo .input { padding-right: 44px; }
.combo .caret { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; display: grid; place-items: center; color: var(--ink-3); pointer-events: none; }
.combo-list {
  position: fixed; z-index: 400; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); max-height: 40vh; overflow: auto; padding: 4px; min-width: 200px;
}
.combo-list button { display: flex; width: 100%; text-align: left; padding: 10px 12px; border: 0; background: none; border-radius: var(--radius-sm); min-height: 44px; align-items: center; gap: 8px; }
.combo-list button:hover, .combo-list button.on { background: var(--surface-2); }
.combo-list button.add { color: var(--red-ink); font-weight: 600; }
.combo-list .empty { padding: 10px 12px; color: var(--ink-3); font-size: .875rem; }

/* ── блоки ────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: var(--space-xl); }
.card.tight { padding: var(--space-lg); }
.section { display: grid; gap: var(--space-lg); }
.section > header { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-lg); flex-wrap: wrap; }
.section > header .sub { color: var(--ink-3); font-size: .875rem; }
.divider { height: 1px; background: var(--line-2); }
.notice { padding: var(--space-md) var(--space-lg); border-radius: var(--radius); background: var(--surface-2); color: var(--ink-2); display: flex; gap: var(--space-md); align-items: flex-start; }
.notice.warn { background: var(--amber-soft); color: oklch(38% 0.1 70); }
.notice.bad { background: var(--red-soft); color: var(--red-ink); }
.notice.good { background: var(--green-soft); color: var(--green); }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); }
.badge.red { background: var(--red-soft); color: var(--red-ink); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: oklch(40% 0.1 70); }
.badge.ink { background: var(--ink); color: var(--surface); }

/* Кількісні показники: великий рядок цифр, без плиток. */
.figures { display: flex; flex-wrap: wrap; gap: var(--space-xl) var(--space-3xl); }
.figure .v { font-family: var(--font-display); font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.figure .u { font-size: 1rem; font-weight: 500; color: var(--ink-3); margin-left: 4px; }
.figure .l { font-size: .8125rem; color: var(--ink-3); margin-top: 6px; }

/* Табло ваг — єдиний темний елемент. */
.display {
  background: var(--display-bg); color: var(--display-fg); border-radius: 14px; padding: 14px 20px;
  font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.04em;
  display: flex; align-items: baseline; justify-content: flex-end; gap: 10px; min-height: 72px;
  box-shadow: inset 0 2px 12px oklch(0% 0 0 / .5);
}
.display .kg { font-size: 2.6rem; line-height: 1; }
.display .unit { font-size: 1rem; opacity: .7; }
.display.dim { color: oklch(60% 0.03 95); }
.display.dim .kg { font-size: 1.1rem; font-weight: 500; letter-spacing: 0; }

/* ── таблиці ──────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table.tbl { border-collapse: collapse; width: 100%; font-size: .9375rem; }
.tbl th, .tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.tbl th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
.tbl td.n, .tbl th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tr.total td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--line); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td .sub { display: block; font-size: .75rem; color: var(--ink-3); }
.tbl th .sub { display: block; font-size: .6875rem; color: var(--ink-3); font-weight: 500; text-transform: none; letter-spacing: 0; }

/* ── календар графіка ─────────────────────────────────────── */
.cal { display: grid; gap: var(--space-sm); }
.cal-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)) 128px; gap: var(--space-sm); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); padding: 0 2px; }
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)) 128px; gap: var(--space-sm); align-items: stretch; }
.cal-day { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px; min-height: 96px; display: grid; grid-template-rows: auto 1fr auto; gap: 6px; }
.cal-day.out { opacity: .38; background: transparent; border-style: dashed; }
.cal-day.today { border-color: var(--ink); border-width: 2px; }
.cal-day.sun { background: var(--surface-2); }
.cal-day .d { font-family: var(--font-display); font-weight: 700; font-size: .9375rem; display: flex; justify-content: space-between; align-items: center; }
.cal-day .d small { font-weight: 500; color: var(--ink-3); font-size: .75rem; }
.cal-day .entries { display: grid; gap: 4px; align-content: start; }
.entry { display: grid; grid-template-columns: 1fr auto; gap: 4px; align-items: center; padding: 6px 8px; border-radius: 8px; background: var(--surface-2); border: 0; text-align: left; font-size: .8125rem; line-height: 1.25; min-height: 40px; }
.entry:hover { background: oklch(91% 0.012 30); }
.entry.place { background: var(--amber-soft); }
.entry .s { font-weight: 600; }
.entry .m { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.entry .p { color: var(--ink-3); font-size: .75rem; }
.cal-day .add { border: 1px dashed var(--line); background: transparent; border-radius: 8px; min-height: 36px; color: var(--ink-3); font-size: .8125rem; }
.cal-day .add:hover { border-color: var(--ink); color: var(--ink); }
.cal-week-sum { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: grid; gap: 6px; align-content: start; }
.cal-week-sum .big { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.cal-week-sum .cap { font-size: .75rem; color: var(--ink-3); display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.cal-week-sum input { width: 56px; text-align: right; padding: 2px 6px; border: 1px solid var(--line); border-radius: 6px; font-size: .8125rem; }
.fill { height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.fill i { display: block; height: 100%; background: var(--ink); border-radius: 3px; }
.fill i.over { background: var(--red); }
@media (max-width: 900px) {
  .cal-head { display: none; }
  .cal-week { grid-template-columns: 1fr; }
  .cal-day { min-height: 0; }
  .cal-day.out { display: none; }
  .cal-week-sum { order: -1; }
}

/* ── діалог (лише для форм редагування) ────────────────────── */
dialog { border: 0; border-radius: 16px; padding: 0; max-width: min(560px, calc(100vw - 24px)); width: 100%; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: oklch(20% 0.02 25 / .45); }
dialog form.body { padding: var(--space-xl); display: grid; gap: var(--space-lg); }
dialog header { display: flex; justify-content: space-between; align-items: center; gap: var(--space-md); }

/* ── повідомлення ─────────────────────────────────────────── */
.toasts { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 8px; z-index: 500; width: min(520px, calc(100vw - 24px)); }
.toast { background: var(--ink); color: var(--surface); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center; animation: rise .25s cubic-bezier(.2,.8,.2,1); }
.toast.bad { background: var(--red-ink); }
.toast.good { background: var(--green); }
.toast button { margin-left: auto; background: none; border: 0; color: inherit; font-weight: 600; min-height: 36px; padding: 0 8px; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── сторінка входу ───────────────────────────────────────── */
.login { min-height: 100dvh; display: grid; place-items: center; padding: var(--space-xl); }
.login .box { width: min(420px, 100%); display: grid; gap: var(--space-xl); }
.login .logo { display: grid; justify-items: center; gap: var(--space-md); }
.login .logo img { width: min(280px, 70vw); height: auto; }
.login .logo p { color: var(--ink-3); font-size: .9375rem; text-align: center; }
.login h1 { font-size: 1.5rem; text-align: center; }
.login .alt { display: grid; gap: 6px; text-align: center; font-size: .9375rem; }
.login .alt a { color: var(--ink-2); }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.codes code { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; letter-spacing: .06em; padding: 10px; background: var(--surface-2); border-radius: 8px; text-align: center; }

/* ── телефон: водій / вагар ───────────────────────────────── */
.steps { display: grid; gap: var(--space-lg); }
.step { display: grid; gap: var(--space-md); }
.step > header { display: flex; align-items: center; gap: var(--space-md); }
.step .n { width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: var(--surface); display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; flex: none; }
.step.done .n { background: var(--green); }
.step.wait .n { background: var(--line); color: var(--ink-3); }
.shot { display: grid; gap: var(--space-md); }
.shot img { width: 100%; border-radius: 12px; display: block; background: var(--surface-2); aspect-ratio: 4/3; object-fit: cover; }
.shot .cam { min-height: 88px; font-size: 1.25rem; border-radius: 16px; }
.shot .cam svg.i { width: 28px; height: 28px; }
.kgrow { display: grid; grid-template-columns: 1fr auto; gap: var(--space-md); align-items: center; }
.kgrow input { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; text-align: right; min-height: 60px; }
.truck-list { display: grid; gap: var(--space-sm); }
.truck { display: grid; grid-template-columns: 1fr auto; gap: var(--space-md); align-items: center; padding: 14px 16px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); text-align: left; min-height: 64px; }
.truck:hover { border-color: var(--ink); }
.truck .t { font-weight: 600; }
.truck .s { font-size: .8125rem; color: var(--ink-3); }

/* ── підказки «як порахована цифра» ───────────────────────── */
.tip-box { position: fixed; z-index: 600; max-width: 380px; background: var(--ink); color: var(--surface); padding: 10px 12px; border-radius: 10px; font-size: .8125rem; line-height: 1.4; pointer-events: none; white-space: pre-line; box-shadow: var(--shadow); }
[data-tip] { cursor: help; text-decoration: underline dotted var(--ink-3); text-underline-offset: 3px; }

@media print { .topbar, .toasts, .tip-box, .btn { display: none !important; } main { padding: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
