:root {
  --bg: #f3f1eb;
  --surface: #fffcf8;
  --ink: #1b2330;
  --muted: #5e6a78;
  --faint: #8b95a1;
  --line: #e4ddd0;
  --line-strong: #d3cbbd;
  --accent: #0f6e56;
  --accent-ink: #084838;
  --accent-soft: #e5f4ee;
  --in: #0c7a43;
  --in-soft: #e6f6ec;
  --out: #9a3d12;
  --out-soft: #fdeee4;
  --neg: #b42318;
  --neg-soft: #fdecec;
  --warn-soft: #fbf3df;
  --shadow: 0 1px 2px rgba(60, 42, 20, 0.04), 0 10px 28px rgba(60, 42, 20, 0.05);
  --sans: "Golos Text", "Segoe UI", sans-serif;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.4;
}

body.lock { overflow: hidden; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
h1, h2, h3 { font-weight: 700; }
::selection { background: #cfe8dc; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus {
  outline: none;
  border-color: #8fceba;
  box-shadow: 0 0 0 3px rgba(15, 110, 86, 0.15);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 22px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(243, 241, 235, 0.92);
  backdrop-filter: blur(12px);
  flex-wrap: wrap;
}

.brand { display: flex; gap: 12px; align-items: center; margin-right: auto; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: -0.03em; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }
.brand-mark { width: 36px; height: 36px; flex: none; }

.date-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.date-field input, .date-input, .drawer input, .catalog-table input, .note input {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 10px;
  background: white;
}
.date-field input, .date-input { height: 38px; }

.actions, .row { display: flex; gap: 8px; align-items: center; }
.top-tools { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.spread { justify-content: space-between; width: 100%; }
.center { text-align: center; }

.btn {
  height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  font-weight: 700;
  border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: white; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-primary:hover { background: #0c5b47; }
.btn-ghost { background: white; border-color: var(--line); }
.btn-ghost:hover { border-color: var(--line-strong); }
.btn-danger { background: var(--neg); color: white; }
.btn-danger-ghost { color: var(--neg); height: 40px; padding: 0 8px; font-weight: 700; }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}
.icon-btn:hover { background: #f3f0e8; }

.subbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 22px 16px;
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  background: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.tabs button {
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 700;
}
.tabs button.is-on { background: #1b2330; color: white; }

.month-switch { display: flex; align-items: center; gap: 6px; }
.month-switch > button {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: white;
  border: 1px solid var(--line);
  font-size: 18px;
}
.month-switch b { min-width: 140px; text-align: center; font-size: 15px; }
.month-switch .today { width: auto; padding: 0 10px; font-size: 14px; font-weight: 700; color: var(--accent); }

.search { margin-left: auto; position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 12px; color: var(--faint); }
.search input {
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 0 32px 0 34px;
  width: 240px;
  background: white;
}
.search-clear { position: absolute; right: 6px; width: 28px; height: 28px; border-radius: 50%; color: var(--muted); }

.page { display: flex; flex-direction: column; gap: 16px; padding: 0 22px 56px; min-width: 0; max-width: 100%; }

.hint {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: #eef8f3;
  border: 1px solid #cfe6da;
  border-radius: 16px;
  padding: 14px 14px 14px 16px;
  margin: 0;
}
.hint b { color: #0e4f3c; }
.hint p { margin: 4px 0 0; color: #245444; font-size: 14.5px; }
.hint-actions { display: flex; gap: 8px; align-items: flex-start; flex: none; }

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
  text-align: left;
  height: 100%;
  min-height: 118px;
  display: flex;
  flex-direction: column;
}
button.kpi { width: 100%; }
.kpi > span { display: block; color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi.in > span { color: var(--in); }
.kpi.out > span { color: var(--out); }
.kpi strong {
  display: block;
  margin: 8px 0 0;
  font-size: 30px;
  letter-spacing: -0.04em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.kpi strong em { font-style: normal; font-size: 16px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.kpi small { color: var(--muted); font-size: 12.5px; margin-top: auto; padding-top: 8px; }
.unit-sums { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; }
.unit-sums span { font-size: 14px; font-weight: 600; color: var(--muted); }
.unit-sums b { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi.bad { background: #fff6f5; border-color: #f3d0d0; }
.kpi.bad strong { color: var(--neg); }
.kpi.warn { background: #fbf6ea; border-color: #ead7a4; }
.kpi.warn strong { color: #8a5a10; }

.month-line { margin: 0; color: var(--muted); font-size: 14px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.facets { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.facets label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 700; }
.facets select {
  height: 32px;
  max-width: 280px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  padding: 0 12px;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
}
.facet-count { margin: 0; color: var(--muted); font-size: 13px; }
.report-tools { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.print-report { display: none; }
.chip-btn {
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: white;
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}
.chip-btn.is-on { background: var(--accent-soft); color: var(--accent-ink); border-color: #b7dece; }

.days { display: flex; gap: 8px; overflow: auto; padding: 0; }
.day-chip {
  min-width: 68px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 12px;
  padding: 6px 8px 7px;
}
.day-chip b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.day-chip span { color: var(--muted); font-size: 12px; }
.day-chip.is-on { background: var(--accent-soft); border-color: #9dcebc; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.table-card { overflow: auto; }

.stock, .catalog-table { width: 100%; border-collapse: collapse; }
.stock { table-layout: fixed; }
.stock th.num, .stock td.num { width: 120px; }
.stock th button.sort {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 0;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.stock th.num button.sort { justify-content: flex-end; }
.stock th button.sort.is-on { color: var(--ink); }
.stock th button.sort i { font-style: normal; color: var(--accent); }
.stock th, .catalog-table th {
  text-align: left;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
}
.stock td, .catalog-table td { padding: 12px; border-bottom: 1px solid #f0ebe3; vertical-align: middle; }
.stock th.num, .stock td.num, .catalog-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.stock tr.group td, .catalog-table tr.group td {
  background: #f6f3ec;
  color: #3c4a44;
  font-weight: 700;
  font-size: 13px;
}
.stock tbody tr:hover td { background: #fbfaf6; }
.stock tr.group:hover td, .stock tr.group td { background: #f6f3ec; }
.stock tr.neg td { background: #fff6f5; }
.stock tr.low td { background: #fbf6ea; }
.stock tr.neg.low td { background: #fff6f5; }
.min-mark { display: block; margin-top: 2px; color: #8a5a10; font-size: 12px; font-weight: 600; }
.stock .bal { font-weight: 700; font-size: 16px; }
.stock tr.neg .bal, .negnum { color: var(--neg); }
.plus-num { color: var(--in); font-weight: 700; }
.minus-num { color: var(--out); font-weight: 700; }
.faint { color: var(--faint); }
.muted { color: var(--muted); }
.unit { color: var(--faint); font-size: 12px; margin-left: 6px; font-weight: 500; }
.link { font-weight: 700; padding: 0; }
.link:hover { color: var(--accent); }
.stock tr.total td, .matrix tr.total td { font-weight: 700; background: #faf8f4; border-bottom: 0; }

.side { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.side-head { display: flex; flex-direction: column; gap: 4px; }
.side h2 { margin: 0; font-size: 22px; letter-spacing: -0.03em; }
.jump { margin: 0; font-size: 15px; }
.fine { color: var(--muted); font-size: 13px; margin: 0; }
.text-link { color: var(--accent); font-weight: 700; padding: 0; margin: 2px 0 10px; }
.text-link:hover { text-decoration: underline; }

.docs { display: flex; flex-direction: column; gap: 16px; }
.doc {
  display: block;
  width: 100%;
  text-align: left;
  background: white;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 12px;
  padding: 10px 12px;
}
.doc.in { border-left-color: var(--in); }
.doc.out { border-left-color: #c2410c; }
.doc:hover { border-color: #cfc6b6; }
.doc.in:hover { border-left-color: var(--in); }
.doc.out:hover { border-left-color: #c2410c; }
.doc header { display: flex; gap: 8px; align-items: center; }
.doc ul { list-style: none; margin: 8px 0 0; padding: 0; }
.doc li { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.doc li b, .chain, .hist-row, .preview b { font-variant-numeric: tabular-nums; }
.doc em { display: block; margin-top: 6px; color: var(--muted); font-size: 13px; font-style: normal; }
.badge { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 8px; }
.badge.in, .doc li b.in { background: var(--in-soft); color: var(--in); }
.doc li b.in, .doc li b.out { background: none; }
.badge.out, .doc li b.out { color: var(--out); }
.badge.out { background: var(--out-soft); }
.doc.adjust { border-left-color: #a0792c; }
.badge.adjust { background: var(--warn-soft); color: #7a4e10; }
.inv-lines { display: grid; gap: 8px; margin-top: 12px; }
.inv-line { display: grid; grid-template-columns: minmax(0, 1fr) 76px 76px 76px 36px; gap: 8px; align-items: end; }
.inv-metric { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.inv-metric b { min-height: 40px; display: flex; align-items: center; font-size: 16px; color: var(--ink); }
.inv-metric input { height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 8px; background: white; width: 100%; }

.formula { margin-top: 0; background: #f6faf7; border-radius: 12px; padding: 12px; }
.side .text-link { margin: 0; }
.formula h3 { margin: 0 0 8px; font-size: 14px; }
.formula-row { margin-bottom: 8px; }
.formula-row > b { display: block; font-size: 14px; }
.chain { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; margin: 2px 0 0; }
.chain .plus, .plus { color: var(--in); font-weight: 700; }
.chain .minus, .minus { color: var(--out); font-weight: 700; }
.chain b { font-size: 18px; }

.journal { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.journal-desk { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 16px; align-items: start; }
.journal-list { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.journal-day h3 { margin: 0; font-size: 18px; letter-spacing: -0.03em; }
.journal-day .muted { margin: 2px 0 8px; }
.journal-picks { display: flex; flex-direction: column; gap: 8px; }
.journal-pick {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  background: white;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 12px;
  padding: 10px 12px;
}
.journal-pick.in { border-left-color: var(--in); }
.journal-pick.out { border-left-color: #c2410c; }
.journal-pick.adjust { border-left-color: #a0792c; }
.journal-pick.is-on { background: #f4fbf7; border-color: #8fbfa8; box-shadow: var(--shadow); }
.journal-pick.is-on.in { border-left-color: var(--in); }
.journal-pick.is-on.out { border-left-color: #c2410c; }
.journal-pick.is-on.adjust { border-left-color: #a0792c; }
.jp-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.jp-text b { font-size: 14px; }
.jp-text span { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.journal-detail {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 96px);
  overflow: auto;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}
.journal-detail header { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.journal-detail h2 { margin: 6px 0 0; font-size: 22px; letter-spacing: -0.03em; }
.journal-detail header .muted { margin: 4px 0 0; }
.detail-lines { list-style: none; margin: 16px 0; padding: 0; }
.detail-lines li { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); }
.detail-lines span { min-width: 0; overflow-wrap: anywhere; }
.detail-lines b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.detail-lines b.in { color: var(--in); }
.detail-lines b.out { color: var(--out); }
.journal-phone { display: none; }
.journal-phone .docs { display: flex; flex-direction: column; gap: 12px; }
.day-block { margin: 0; }
.day-block > header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.day-block h2 { margin: 0; font-size: 22px; letter-spacing: -0.03em; }

.legend { color: var(--muted); font-size: 13.5px; margin: 0; }

.matrix-scroll {
  overflow: auto;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  max-height: calc(100vh - 230px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}
.matrix {
  --name: 320px;
  --edge: 132px;
  --doc: 148px;
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: calc(var(--name) + (var(--edge) * 2) + (var(--docs) * var(--doc)));
  table-layout: fixed;
}
.matrix.is-roomy { --name: 280px; --edge: 120px; --doc: 180px; }
.matrix th, .matrix td {
  border-bottom: 1px solid var(--line);
  background: #fffcf8;
  white-space: nowrap;
}
.matrix tbody td { padding: 8px 10px; }
.matrix thead th { position: sticky; top: 0; z-index: 3; padding: 0; vertical-align: bottom; }
.matrix thead th.sticky-name,
.matrix thead th.sticky-start,
.matrix thead th.sticky-end { padding: 8px 10px; z-index: 5; }
.matrix .sticky-name {
  position: sticky;
  left: 0;
  z-index: 2;
  width: var(--name);
  min-width: var(--name);
  max-width: var(--name);
  background: #fffcf8;
  white-space: normal;
  overflow-wrap: break-word;
  box-shadow: 8px 0 10px -8px rgba(60, 40, 20, 0.45);
}
.matrix.is-roomy .sticky-name {
  width: 36%;
  min-width: 280px;
  max-width: none;
}
.matrix .sticky-start {
  background: #fffcf8;
}
.matrix .sticky-end {
  position: sticky;
  right: 0;
  z-index: 2;
  min-width: 0;
  background: #eef8f3;
  font-weight: 700;
  box-shadow: -8px 0 10px -8px rgba(60, 40, 20, 0.45);
}
.matrix thead .sticky-name,
.matrix thead .sticky-start,
.matrix thead .sticky-end { z-index: 6; }
.matrix td.num, .matrix th.num { text-align: right; font-variant-numeric: tabular-nums; }
.matrix th button.sort { font: inherit; font-weight: 700; color: inherit; padding: 0; }
.matrix th button.sort.is-on { color: var(--accent); }
.matrix th button.colhead {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  width: 100%;
  min-width: 0;
  padding: 8px 8px 6px;
}
.matrix th button .dt { color: var(--muted); font-size: 12px; font-weight: 600; }
.matrix th button .nn { font-weight: 700; }
.matrix th button small { font-size: 12px; font-weight: 700; }
.matrix th.in { box-shadow: inset 0 3px 0 var(--in); }
.matrix th.out { box-shadow: inset 0 3px 0 #c2410c; }
.matrix th.in small { color: var(--in); }
.matrix th.out small { color: var(--out); }
.matrix td.band, .matrix th.band { background: #f7f4ee; }
.matrix td.is-day, .matrix th.is-day { background: #e5f6ee; }
.matrix td.future, .matrix th.future { background: #f3f4f6; color: #8b95a1; }
.matrix tr.group td { background: #efece4; font-weight: 700; color: #3e4a42; }
.matrix tr.group td.sticky-name { background: #efece4; }
.matrix tr.neg td.sticky-name,
.matrix tr.neg td.sticky-start { background: #fff7f6; }
.matrix tr.neg td.sticky-end { background: #fdeeee; color: var(--neg); }
.matrix tbody tr:hover td { background: #fbfaf6; }
.matrix tbody tr:hover td.sticky-end { background: #e7f6ee; }
.matrix tbody tr.neg:hover td { background: #fff1f0; }
.matrix tr.total td.sticky-name,
.matrix tr.total td.sticky-start { background: #faf8f4; }
.matrix tr.total td.sticky-end { background: #e7f4ee; }
.matrix .sticky-name .link,
.matrix .sticky-name .sort {
  display: block;
  max-width: none;
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
  overflow-wrap: break-word;
  text-align: left;
  line-height: 1.3;
}
.cell { padding: 4px 6px; border-radius: 8px; font-weight: 700; }
.cell:hover { background: rgba(255, 255, 255, 0.75); }
.cell.in { color: var(--in); }
.cell.out { color: var(--out); }

.catalog { display: flex; flex-direction: column; gap: 16px; }
.catalog-head { display: flex; justify-content: space-between; gap: 16px; align-items: end; margin: 0; }
.catalog-head h2 { margin: 0 0 6px; font-size: 22px; }
.catalog-head p { margin: 0; color: var(--muted); max-width: 680px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.chip {
  background: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px 4px 12px;
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.chip button { color: var(--muted); font-size: 16px; padding: 0 4px; }
.catalog-table input {
  width: 100%;
  height: 36px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: 0 8px;
}
.catalog-table input:hover { border-color: var(--line); background: white; }
.catalog-table input:focus { background: white; }
.catalog-table .add-row input { border-color: var(--line); background: white; }
.opening-input { text-align: right; font-variant-numeric: tabular-nums; }
.data-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.warn { background: var(--warn-soft); color: #7a4e10; border-radius: 12px; padding: 10px 12px; margin: 0; }
.warn button { color: #7a4e10; font-weight: 700; text-decoration: underline; margin-right: 8px; }

.empty { padding: 36px 20px; text-align: center; }
.empty h2 { margin: 0 0 8px; }
.empty p { color: var(--muted); margin: 0 0 14px; }

.overlay { position: fixed; inset: 0; background: rgba(32, 28, 22, 0.28); z-index: 30; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(460px, 100%);
  background: #fffcf8;
  z-index: 40;
  display: flex;
  flex-direction: column;
  box-shadow: -16px 0 40px rgba(40, 32, 20, 0.12);
}
.drawer-head, .drawer-foot { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.drawer-foot { border-bottom: 0; border-top: 1px solid var(--line); flex-direction: column; align-items: stretch; }
.drawer-head h2 { margin: 0; font-size: 20px; }
.back { color: var(--accent); font-weight: 700; padding: 0 0 4px; }
.drawer-body { flex: 1; overflow: auto; padding: 8px 16px 20px; }
.drawer label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg button { height: 48px; border-radius: 12px; border: 1px solid var(--line); background: white; font-weight: 700; }
.seg button.is-on.in { background: var(--in-soft); border-color: #b7e0c8; color: var(--in); }
.seg button.is-on.out { background: var(--out-soft); border-color: #f0d0bc; color: var(--out); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.line { display: grid; grid-template-columns: minmax(0, 1fr) 96px 36px; gap: 8px; margin-top: 8px; align-items: start; }
.combo { position: relative; }
.suggest { display: none; margin-top: 4px; background: white; border: 1px solid var(--line); border-radius: 10px; overflow: auto; max-height: 280px; box-shadow: var(--shadow); }
.combo:focus-within .suggest { display: block; }
.suggest button { display: flex; width: 100%; justify-content: space-between; gap: 8px; padding: 8px 10px; text-align: left; }
.suggest button small { color: var(--muted); font-weight: 500; }
.suggest button:hover, .suggest button.is-active { background: var(--accent-soft); }
.suggest .create { color: var(--accent); font-weight: 700; }
.qty { text-align: right; font-variant-numeric: tabular-nums; }
.add-line {
  margin-top: 8px;
  width: 100%;
  height: 38px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--muted);
  font-weight: 700;
}
.add-line:hover { border-color: var(--accent); color: var(--accent); }
.note { display: flex; margin-top: 12px; }
.preview { margin-top: 16px; background: #f6faf7; border-radius: 12px; padding: 12px; }
.preview h3 { margin: 0 0 8px; font-size: 14px; }
.preview p { display: flex; justify-content: space-between; gap: 8px; margin: 4px 0; align-items: baseline; }
.preview em { color: var(--neg); font-style: normal; font-weight: 700; }
.form-error { background: var(--neg-soft); color: var(--neg); border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; font-size: 14px; }
.form-warn { background: #fbf6ea; color: #6d4a12; border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; font-size: 14px; }
.form-warn p { margin: 0 0 6px; }
.form-warn p:last-child { margin: 0; }
.similar { margin: 4px 0 0; color: #8a5a10; font-size: 12px; }
.save-status { font-size: 13px; font-weight: 700; white-space: nowrap; color: var(--muted); }
.save-status.saving { color: #8a5a10; }
.save-status.saved { color: #0f6e56; }
.save-status.error { color: #9f2d2d; }

.hist-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: baseline;
  width: 100%;
  text-align: left;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
  background: none;
}
button.hist-row:hover { background: #f6faf7; }
.hist-row.future { color: var(--faint); }
.move-card { display: grid; gap: 10px; margin: 4px 0 16px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.move-card h3 { margin: 4px 0 0; font-size: 15px; }
.now-bal { margin-top: 16px; font-size: 18px; }

.modal-overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; }
.modal-dismiss { position: absolute; inset: 0; background: rgba(32, 28, 22, 0.35); }
.modal {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  background: white;
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.modal h3 { margin: 0 0 8px; }
.modal p { margin: 0 0 16px; color: var(--muted); }
.modal .row { justify-content: flex-end; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login { width: min(420px, 100%); padding: 28px 24px 22px; }
.login h1 { margin: 0 0 8px; letter-spacing: -0.03em; }
.login p { margin: 0; color: var(--muted); }
.login input { width: 100%; margin: 14px 0 8px; }
.login .btn { width: 100%; margin-top: 8px; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1b2330;
  color: white;
  padding: 12px 16px;
  border-radius: 999px;
  z-index: 80;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  max-width: min(560px, calc(100% - 32px));
}

@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .stock { table-layout: auto; }
  .stock th.num, .stock td.num { width: auto; }
  .search { margin-left: 0; }
  .search input { width: 200px; }
}

@media (max-width: 720px) {
  html, body { overflow-x: hidden; max-width: 100%; }
  body { font-size: 14px; }
  .topbar, .subbar, .page { padding-left: 12px; padding-right: 12px; }
  .topbar, .subbar { justify-content: flex-start; gap: 10px; }
  .brand { margin-right: 0; gap: 8px; }
  .brand h1, .side h2, .day-block h2 { font-size: 18px; }
  .brand-mark { width: 28px; height: 28px; }
  .tabs { max-width: 100%; }
  .tabs button { padding: 0 10px; font-size: 13px; }
  .month-switch { justify-content: flex-start; }
  .month-switch b { min-width: 0; text-align: left; font-size: 14px; }
  .top-tools { width: 100%; margin-left: 0; flex-wrap: wrap; }
  .search { flex: 1 1 140px; width: auto; min-width: 0; }
  .search input { width: 100%; }
  .page, .layout, .table-card, .matrix-scroll, .catalog { min-width: 0; max-width: 100%; }
  .kpis, .page, .layout, .side, .catalog, .journal, .journal-phone { gap: 12px; }
  .facets { width: 100%; }
  .facets label { flex: 1 1 150px; min-width: 0; }
  .facets select { width: 100%; max-width: none; min-width: 0; }
  .report-tools { justify-content: flex-start; }
  .save-status { font-size: 12px; }
  .journal-desk { display: none; }
  .journal-phone { display: flex; flex-direction: column; }
  .journal-detail { position: static; max-height: none; }
  .kpi { padding: 12px; min-height: 0; }
  .kpi strong { font-size: 22px; }
  .days { flex-wrap: wrap; overflow: visible; }
  .table-card { overflow: hidden; }
  .stock, .catalog-table { table-layout: fixed; font-size: 12px; }
  .stock th, .stock td, .catalog-table th, .catalog-table td {
    padding: 8px 4px;
    text-align: left;
    overflow-wrap: anywhere;
  }
  .stock th.num, .stock td.num, .catalog-table th.num, .catalog-table td.num {
    width: 17%;
    text-align: left;
  }
  .stock th button.sort, .stock th.num button.sort { justify-content: flex-start; font-size: 11px; text-align: left; }
  .stock .bal, .link { font-size: 13px; }
  .unit { display: block; margin: 2px 0 0; }
  .matrix, .matrix.is-roomy { --name: 168px; --edge: 84px; --doc: 96px; }
  .matrix .sticky-name, .matrix.is-roomy .sticky-name { width: var(--name); min-width: var(--name); max-width: var(--name); }
  .matrix .sticky-end, .matrix th button.colhead { min-width: 0; }
  .matrix th, .matrix td { font-size: 12px; }
  .matrix td.num, .matrix th.num { text-align: left; }
  .matrix th button.colhead { align-items: flex-start; }
  .inv-line { grid-template-columns: 1fr 1fr 1fr 36px; }
  .inv-line .combo { grid-column: 1 / -1; }
}

@media (min-width: 1100px) {
  .side { position: sticky; top: 96px; max-height: calc(100vh - 112px); overflow: auto; }
}

@media print {
  .topbar, .subbar, .hint, .side, .filters, .facets, .days, .kpis, .month-line, .report-tools, .overlay, .drawer, .toast, .modal-overlay, .data-tools, .layout { display: none !important; }
  .matrix-scroll { overflow: visible; max-height: none; border: none; }
  .print-report { display: block !important; }
  .print-report h1 { margin: 0 0 4px; font-size: 20px; }
  .print-report p { margin: 0 0 8px; }
  .print-report table { width: 100%; border-collapse: collapse; font-size: 12px; }
  .print-report th, .print-report td { border: 1px solid #bbb; padding: 4px 6px; text-align: left; vertical-align: top; }
  .print-report td.num, .print-report th:nth-child(n+4) { text-align: right; font-variant-numeric: tabular-nums; }
  .page { padding: 0; }
  body { background: white; color: #111; }
  @page { margin: 12mm; }
}

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