/* Портал «Склад и сделки».
   Палитра взята из доступной среды: графит табличек и сигнальный жёлтый
   тактильной разметки. Жёлтый используется мало: для главных кнопок
   и отметки текущего раздела. */
:root {
  --ink: #1D2633;
  --ink-2: #2B3747;
  --muted: #5E6A7B;
  --line: #D6DCE4;
  --line-2: #E7EBF0;
  --bg: #EEF1F4;
  --panel: #FFFFFF;
  --signal: #F5C400;
  --signal-deep: #D9A900;
  --ok: #2E7D4F;
  --ok-bg: #E6F3EA;
  --warn: #9A5B00;
  --warn-bg: #FFF4D6;
  --danger: #B42318;
  --danger-bg: #FDECEA;
  --info-bg: #E8EEF6;
  --radius: 8px;
  --radius-sm: 5px;
  --font: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
}
a { color: #1F4E8C; text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 1px; border-radius: 3px; }
h1 { font-size: 26px; line-height: 1.2; font-weight: 700; margin: 2px 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 10px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.lead { max-width: 70ch; margin-bottom: 14px; }
.nowrap { white-space: nowrap; }
.plus { color: var(--ok); }
.minus { color: var(--danger); }

/* ---------- каркас ---------- */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side {
  background: var(--ink); color: #DCE3EC; padding: 18px 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 11px; align-items: center; padding: 0 18px 20px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand b { display: block; font-size: 15px; font-weight: 600; }
.brand small { display: block; color: #9AA8BA; font-size: 12px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 6px; flex: none;
  background: radial-gradient(circle, var(--signal) 2.6px, transparent 3px) 0 0 / 10px 10px, var(--ink-2);
}
.nav { list-style: none; margin: 0; padding: 0; flex: 1; }
.nav a {
  display: block; padding: 9px 18px 9px 24px; color: #C9D3DF; position: relative; font-weight: 500;
}
.nav a:hover { background: var(--ink-2); color: #fff; text-decoration: none; }
/* текущий раздел отмечен полосой «тактильных» точек, как на напольной разметке */
.nav a.on { color: #fff; background: var(--ink-2); }
.nav a.on::before {
  content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 8px;
  background: radial-gradient(circle, var(--signal) 2px, transparent 2.4px) center top / 8px 7px repeat-y;
}
.me { padding: 14px 18px 0; border-top: 1px solid var(--ink-2); font-size: 13px; display: flex; justify-content: space-between; gap: 8px; }
.me a { color: #DCE3EC; }
.me form { margin: 0; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: #1F4E8C; cursor: pointer; }
.linkish:hover { text-decoration: underline; }
.linkish.danger { color: var(--danger); }
.me .linkish { color: #9AA8BA; }

.main { padding: 22px 28px 48px; min-width: 0; max-width: 1280px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.back { font-size: 13px; color: var(--muted); }
.back::before { content: "‹ "; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel);
  color: var(--ink); font: 500 14px var(--font); cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #AEB8C6; text-decoration: none; }
.btn-primary { background: var(--signal); border-color: var(--signal-deep); color: var(--ink); font-weight: 600; }
.btn-primary:hover { background: #FFD21A; border-color: var(--signal-deep); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-ghost { background: transparent; border-color: transparent; color: #1F4E8C; }
.btn-ghost:hover { background: var(--line-2); border-color: transparent; }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: #F0C4C0; }
.btn-danger-ghost:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn-small { height: 30px; padding: 0 10px; font-size: 13px; }
.icon-btn { width: 30px; height: 30px; border: 0; background: none; color: var(--muted); font-size: 20px; line-height: 1; border-radius: 4px; cursor: pointer; }
.icon-btn:hover { background: var(--danger-bg); color: var(--danger); }

input, select, textarea {
  font: 15px var(--font); color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 7px 9px; width: 100%; min-height: 36px;
}
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: 2px solid var(--signal); outline-offset: 0; }
input[readonly] { background: var(--bg); color: var(--muted); }
input.num { text-align: right; }
textarea { resize: vertical; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 12px; flex: 1; min-width: 0; }
.form label > input, .form label > select, .form label > textarea { color: var(--ink); font-weight: 400; }
.form label small { font-weight: 400; font-size: 12px; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; flex: 0 0 auto; padding-top: 22px; }
.form label.check input { width: auto; min-height: 0; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > .w-wide { flex: 2.2; min-width: 240px; }
.row > .w-sm { flex: 0 0 150px; }
.row > label { min-width: 160px; }
.row-btn { padding-top: 21px; }
.form-actions { display: flex; gap: 10px; margin: 16px 0; }
.narrow { max-width: 420px; }

.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filters input[type=search] { width: 320px; max-width: 100%; }
.filters select { width: auto; min-width: 160px; }
.filters input[type=date] { width: auto; }
label.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }

/* ---------- панели ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.panel.flush { padding: 0; overflow-x: auto; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 14px 18px 10px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.panel-head a, .panel-head span { font-size: 13px; }
.panel:not(.flush) > .panel-head { padding: 0 0 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid-2 > .panel { margin-bottom: 0; }
.grid-wide-left { grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); }
.grid-2 + .panel, .grid-2 + .grid-2 { margin-top: 16px; }
.stack > .panel { margin-bottom: 16px; }
.empty { color: var(--muted); padding: 18px; margin: 0; }
.panel:not(.flush) > .empty { padding: 0; }
.note { background: var(--panel); border-left: 3px solid var(--line); padding: 8px 14px; margin-bottom: 16px; }
.meta p { margin: 0 0 4px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.inline-form { display: inline-flex; gap: 8px; align-items: center; margin: 0 6px 0 0; flex-wrap: wrap; }
.danger-zone { display: flex; align-items: center; gap: 12px; margin-top: 8px; }

/* ключевые числа */
.figures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.figure { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.figure span { display: block; font-size: 13px; color: var(--muted); }
.figure b { display: block; font-size: 24px; font-weight: 700; margin: 2px 0; letter-spacing: -0.01em; }
.figure small { color: var(--muted); font-size: 13px; }
.figure-warn { border-color: #E9C46A; background: var(--warn-bg); }
.figure-danger { border-color: #F0B4AE; background: var(--danger-bg); }
.figure-danger b { color: var(--danger); }

/* ---------- таблицы ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--line); background: #F7F9FB; white-space: nowrap; }
.tbl td { padding: 8px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tfoot td { border-top: 1px solid var(--line); background: #F7F9FB; font-weight: 600; }
.tbl .num { text-align: right; }
.tbl-main tbody tr:hover td { background: #FAFBFC; }
.sub { font-size: 12.5px; color: var(--muted); }
tr.group td { background: var(--bg); font-size: 12.5px; font-weight: 600; color: var(--ink-2); padding: 5px 12px; }
tr.row-warn td:first-child { box-shadow: inset 4px 0 0 var(--signal); }
tr.row-warn .sub { color: var(--warn); }
tr.row-danger td:first-child { box-shadow: inset 4px 0 0 var(--danger); }
tr.row-danger .sub { color: var(--danger); }
tr.row-muted td { color: var(--muted); }
tr.row-muted a { color: var(--muted); }

.status { display: inline-block; font-size: 12.5px; font-weight: 500; padding: 1px 8px; border-radius: 10px; white-space: nowrap; }
.status-work { background: var(--info-bg); color: #1F4E8C; }
.status-done { background: var(--ok-bg); color: var(--ok); }
.status-cancelled { background: var(--line-2); color: var(--muted); text-decoration: line-through; }

/* строки документа */
.lines td { vertical-align: top; padding: 6px 8px; }
.lines th { padding: 8px; }
.lines .w-qty { width: 120px; }
.lines .w-price { width: 130px; }
.lines .w-sum { width: 120px; }
.lines .w-unit { width: 80px; }
.lines .w-kind { width: 76px; }
.lines td.js-sum { padding-top: 14px; white-space: nowrap; }
.lines tfoot td { background: #fff; font-weight: 400; }
.lines .unit { font-size: 12px; color: var(--muted); }
.kind { display: inline-block; font-size: 12px; font-weight: 600; padding: 9px 0 0; }
.kind-product { color: var(--ink-2); }
.kind-work { color: #6A4FA3; }
.line-work td { background: #FBFAFE; }
.avail { font-size: 12px; color: var(--muted); text-align: right; padding-top: 2px; }
.avail-bad { color: var(--danger); font-weight: 600; }
.line-bad td:first-child { box-shadow: inset 4px 0 0 var(--danger); }
.totals { display: flex; justify-content: flex-end; gap: 28px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.totals div { text-align: right; }
.totals span { display: block; font-size: 12.5px; color: var(--muted); }
.totals b { font-size: 16px; }
.totals-main b { font-size: 22px; }
.hint { font-size: 13px; color: var(--muted); padding: 0 18px 14px; margin: 0; max-width: 90ch; }

.inline-edit { display: flex; gap: 8px; align-items: center; }
.inline-edit input { min-height: 32px; padding: 4px 8px; }
.inline-edit .w-unit { width: 90px; flex: none; }
.inline-edit .w-price { width: 120px; flex: none; }
.works .w-unit { width: 90px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; color: var(--muted); font-weight: 500; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--signal); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

/* ---------- сообщения ---------- */
.flash { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; border: 1px solid; }
.flash-ok { background: var(--ok-bg); border-color: #BFDCC8; color: #1F5A38; }
.flash-error { background: var(--danger-bg); border-color: #F0B4AE; color: #8A1C12; }
.flash-info { background: var(--info-bg); border-color: #C8D5E6; color: var(--ink-2); }

/* ---------- вход ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 28px 28px; width: 100%; max-width: 360px; overflow: hidden; }
.login-strip { height: 14px; margin: 0 -28px 24px; background: radial-gradient(circle, var(--signal) 2.6px, transparent 3px) 0 0 / 10px 10px, var(--ink); }
.login h1 { font-size: 22px; }
.login label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.login .btn { width: 100%; justify-content: center; margin-top: 6px; }

/* ---------- узкие экраны ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 16px; gap: 6px; }
  .brand { padding: 0 12px 0 0; }
  .brand small { display: none; }
  .nav { display: flex; overflow-x: auto; flex: 1 1 100%; order: 3; gap: 2px; }
  .nav a { padding: 7px 12px; white-space: nowrap; border-radius: 5px; }
  .nav a.on::before { left: 2px; top: auto; bottom: 1px; height: 4px; width: auto; right: 2px; background: radial-gradient(circle, var(--signal) 1.6px, transparent 2px) left center / 7px 4px repeat-x; }
  .me { border: 0; padding: 0; margin-left: auto; }
  .main { padding: 16px; }
  .grid-2, .grid-wide-left, .figures { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  h1 { font-size: 22px; }
  .row > .w-sm { flex: 1 1 140px; }
  .lines thead { display: none; }
  .lines tr.line { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 6px; padding: 10px; border-bottom: 1px solid var(--line); }
  .lines tr.line td { padding: 0; border: 0; }
  .deal-lines tr.line td:nth-child(1) { grid-column: 1 / 4; }
  .deal-lines tr.line td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .deal-lines tr.line td:last-child { grid-column: 4; grid-row: 1; }
  .receipt-lines tr.line td:nth-child(1) { grid-column: 1 / -1; }
  .lines td.js-sum { padding-top: 8px; }
  .inline-edit { flex-wrap: wrap; }
  .filters input[type=search] { width: 100%; }
}

/* ---------- печать любой страницы ---------- */
@media print {
  .side, .actions, .filters, .form-actions, .flash, .tabs, .danger-zone, .row-between { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
  .panel { border: 0; padding: 0; }
  .main { padding: 0; }
}

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