/* Дашборд перепродажи. Направление: «бухгалтерская книга»: чистый лист, чернила, табличные цифры.
   Зелёный = заработал, киноварь = минус (как заливка в Excel владельца). Нейтрали чуть тянутся к зелёному. */
@import url('fonts.css');

:root {
  --bg: #f5f6f4;
  --bg-deep: #eceeeb;
  --surface: #ffffff;
  --surface-2: #f8f9f7;
  --ink: #161816;
  --ink-2: #353a36;
  --muted: #5f655f;
  --faint: #636a64;
  --line: #e2e5e1;
  --line-strong: #ccd1cb;
  --profit: #1d7447;
  --profit-soft: #dcefe2;
  --loss: #b8390f;
  --loss-soft: #f8e1d6;
  --warn: #94590a;
  --warn-soft: #f6e8cc;
  --stock: #2f5585;
  --stock-soft: #dde6f2;
  --focus: #2f5585;
  --on-profit: #ffffff;
  --btn: #161816;
  --btn-ink: #ffffff;
  --shadow: 0 1px 0 rgba(16, 24, 18, .04), 0 8px 24px -12px rgba(16, 24, 18, .16);
  --z-sticky: 20; --z-nav: 30; --z-fab: 31; --z-toast: 50;
  --radius: 14px;
  --radius-sm: 9px;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-in-out: cubic-bezier(.77, 0, .175, 1);
  --sidebar: 236px;
  --tabbar: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111312; --bg-deep: #0c0e0d; --surface: #181b19; --surface-2: #1e221f;
    --ink: #ecedea; --ink-2: #cdd1cb; --muted: #a3a9a2; --faint: #8c928b; --line: #2a2e29; --line-strong: #3a3f39;
    --profit: #5cc58b; --profit-soft: #173323; --loss: #f0794a; --loss-soft: #3a1f14; --warn: #e3a54a;
    --warn-soft: #362812; --stock: #7fa6dc; --stock-soft: #1a2638; --focus: #7fa6dc; --on-profit: #0b1a11; --btn: #ecedea;
    --btn-ink: #111312; --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 12px 28px -14px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111312; --bg-deep: #0c0e0d; --surface: #181b19; --surface-2: #1e221f;
  --ink: #ecedea; --ink-2: #cdd1cb; --muted: #a3a9a2; --faint: #8c928b; --line: #2a2e29; --line-strong: #3a3f39;
  --profit: #5cc58b; --profit-soft: #173323; --loss: #f0794a; --loss-soft: #3a1f14; --warn: #e3a54a;
  --warn-soft: #362812; --stock: #7fa6dc; --stock-soft: #1a2638; --focus: #7fa6dc; --on-profit: #0b1a11; --btn: #ecedea;
  --btn-ink: #111312; --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 12px 28px -14px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 'Onest', 'Segoe UI', sans-serif;
  font-feature-settings: 'tnum' 1;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.15; font-weight: 700; letter-spacing: -.01em; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
.num, td.num, .money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.profit { color: var(--profit); }
.loss { color: var(--loss); }
.warn { color: var(--warn); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.i { width: 18px; height: 18px; flex: none; stroke-width: 1.9; vertical-align: -3px; }
.i-sm { width: 15px; height: 15px; vertical-align: -2px; }
.i-lg { width: 22px; height: 22px; }

/* ── Каркас ───────────────────────────────────────── */
.app { min-height: 100dvh; }
.sidebar { display: none; }
.main { padding: 16px 16px calc(var(--tabbar) + 96px + env(safe-area-inset-bottom)); max-width: 1180px; margin: 0 auto; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; position: sticky; top: 0; z-index: var(--z-sticky);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; letter-spacing: -.01em; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--ink); color: var(--bg); font-weight: 800; font-size: 14px;
}

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: var(--z-nav);
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px); border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 500; color: var(--muted); text-decoration: none;
  transition: color .15s var(--ease-out), transform .16s var(--ease-out);
}
.tabbar a[aria-current="page"] { color: var(--ink); }
.tabbar a[aria-current="page"] .i { stroke-width: 2.4; }
.tabbar a:active { transform: scale(.96); }

.fab {
  position: fixed; right: 16px; bottom: calc(var(--tabbar) + 14px + env(safe-area-inset-bottom)); z-index: var(--z-fab);
  display: inline-flex; align-items: center; gap: 8px; height: 50px; padding: 0 20px 0 16px; border-radius: 25px;
  background: var(--btn); color: var(--btn-ink); font-weight: 600; text-decoration: none; box-shadow: var(--shadow);
  transition: transform .16s var(--ease-out);
}
.fab:active { transform: scale(.97); }

@media (min-width: 960px) {
  body { font-size: 15.5px; }
  .app { display: grid; grid-template-columns: var(--sidebar) 1fr; }
  .topbar, .tabbar, .fab { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100dvh;
    padding: 22px 14px; border-right: 1px solid var(--line); background: var(--bg-deep);
    overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
  }
  .sidebar > * { flex-shrink: 0; }
  .sidebar .brand { padding: 0 10px 18px; }
  .nav-link {
    display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--radius-sm);
    color: var(--ink-2); text-decoration: none; font-weight: 500;
    transition: background-color .15s var(--ease-out), color .15s var(--ease-out), transform .16s var(--ease-out);
  }
  .nav-link:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
  .nav-link:active { transform: scale(.98); }
  .nav-link[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
  .nav-link .count { margin-left: auto; font-size: 12px; color: var(--muted); }
  .nav-sub { padding-left: 39px; font-size: 14px; }
  .nav-group { margin-top: 14px; padding: 0 10px 4px; font-size: 12px; color: var(--faint); }
  .sidebar .spacer { flex: 1; }
  .sidebar .btn-buy { margin-bottom: 14px; }
  .main { padding: 28px 40px 64px; }
}

/* ── Шапка страницы ───────────────────────────────── */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 20px; margin: 4px 0 22px; }
.page-head h1 { font-size: 26px; font-weight: 750; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
@media (min-width: 960px) { .page-head h1 { font-size: 32px; } .statement .big { font-size: 72px; } }

.subnav { display: flex; gap: 4px; overflow-x: auto; margin: -8px -16px 18px; padding: 0 16px; scrollbar-width: none; }
.subnav::-webkit-scrollbar { display: none; }
.subnav a {
  flex: none; padding: 8px 14px; border-radius: 99px; text-decoration: none; color: var(--muted); font-weight: 500;
  border: 1px solid transparent; transition: background-color .15s var(--ease-out), color .15s var(--ease-out);
}
.subnav a[aria-current="page"] { color: var(--ink); background: var(--surface); border-color: var(--line); }
@media (min-width: 960px) { .subnav { margin: -10px 0 22px; padding: 0; } }

/* Переключатель периода */
.period { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--bg-deep); border: 1px solid var(--line); }
.seg a, .seg button {
  appearance: none; border: 0; background: none; font: inherit; color: var(--muted); font-weight: 500;
  padding: 6px 12px; border-radius: 8px; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color .15s var(--ease-out), color .15s var(--ease-out);
}
.seg a[aria-current="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.select-compact {
  font: inherit; font-weight: 500; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px 30px 6px 10px; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat;
}
.toggle { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; text-decoration: none; }
.toggle .knob { width: 34px; height: 20px; border-radius: 10px; background: var(--line-strong); position: relative; transition: background-color .2s var(--ease-out); }
.toggle .knob::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); transition: transform .2s var(--ease-out); }
.toggle.on .knob { background: var(--profit); }
.toggle.on .knob::after { transform: translateX(14px); }

/* ── Поверхности ──────────────────────────────────── */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.panel + .panel, .stack > * + * { margin-top: 16px; }
.comb span.now { background-image: repeating-linear-gradient(135deg, transparent 0 4px, color-mix(in srgb, var(--surface) 45%, transparent) 4px 7px); }
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { font-size: 17px; font-weight: 650; }
.panel-head a { color: var(--muted); font-size: 14px; text-decoration: none; }
.panel-head a:hover { color: var(--ink); }
.grid-2 { display: grid; gap: 16px; }
@media (min-width: 960px) { .grid-2 { grid-template-columns: 1.35fr 1fr; align-items: start; } .grid-2 > .panel + .panel { margin-top: 0; } }

/* ── Главная: утверждение и «гребёнка» месяцев ─────── */
.statement { padding: 6px 0 22px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.statement .lead { color: var(--muted); font-size: 15px; }
.statement .big { font-size: 52px; font-weight: 800; letter-spacing: -.035em; line-height: 1; margin: 8px 0 10px; }
.statement .big .cur { font-weight: 300; color: var(--muted); margin-left: .12em; }
.statement .big.neg { color: var(--loss); }
.delta { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: 14px; padding: 3px 9px; border-radius: 99px; }
.delta.up { color: var(--profit); background: var(--profit-soft); }
.delta.down { color: var(--loss); background: var(--loss-soft); }
.delta.flat { color: var(--muted); background: var(--bg-deep); }

.comb { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; align-items: end; height: 64px; margin-top: 20px; }
.comb span { display: block; border-radius: 3px 3px 1px 1px; background: var(--line-strong); min-height: 2px; }
.comb span.pos { background: var(--profit); }
.comb span.neg { background: var(--loss); }
.comb span.now { outline: 2px solid var(--ink); outline-offset: 1px; }
.comb-labels { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; font-size: 12px; color: var(--muted); margin-top: 6px; text-align: center; }

/* Строка показателей: не одинаковые карточки, а ведомость с разделителями */
.ledger { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.ledger > div { padding: 14px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.ledger > div:nth-child(2n) { border-right: 0; }
.ledger .k { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.ledger .v { font-size: 22px; font-weight: 700; margin-top: 4px; letter-spacing: -.01em; }
.ledger .h { font-size: 13px; color: var(--muted); margin-top: 2px; }
.ledger a { text-decoration: none; }
@media (min-width: 960px) {
  .ledger { grid-template-columns: repeat(4, 1fr); }
  .ledger > div { border-bottom: 0; }
  .ledger > div:nth-child(2n) { border-right: 1px solid var(--line); }
  .ledger > div:last-child { border-right: 0; }
}

.insights { list-style: none; margin: 0; padding: 0; }
.insights li { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.insights li:first-child { border-top: 0; padding-top: 2px; }
.insights .dot { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.insights .up .dot { background: var(--profit-soft); color: var(--profit); }
.insights .down .dot { background: var(--loss-soft); color: var(--loss); }
.insights .warn .dot { background: var(--warn-soft); color: var(--warn); }
.insights .info .dot { background: var(--stock-soft); color: var(--stock); }

/* ── Списки и таблицы ─────────────────────────────── */
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { border-top: 1px solid var(--line); }
.rows > li:first-child { border-top: 0; }
.row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; padding: 12px 2px;
  text-decoration: none; color: inherit; border-radius: 8px;
  transition: background-color .15s var(--ease-out);
}
@media (hover: hover) and (pointer: fine) { a.row:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); } }
a.row:active { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.row .t { font-weight: 550; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .m { grid-column: 1; color: var(--muted); font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .r { grid-column: 2; grid-row: 1 / span 2; text-align: right; }
.row .r .s { font-size: 13px; color: var(--muted); }
.row .r b { font-weight: 650; }

.table-wrap:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.t th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 8px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
table.t td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t th.num, table.t td.num { text-align: right; }
table.t tfoot td { font-weight: 700; border-top: 1px solid var(--line-strong); border-bottom: 0; }
@media (hover: hover) and (pointer: fine) { table.t tbody tr:hover td { background: color-mix(in srgb, var(--ink) 3%, transparent); } }

.bar { height: 6px; border-radius: 3px; background: var(--bg-deep); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--profit); border-radius: 3px; }
.bar.neg > i { background: var(--loss); }

.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 550; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.sold { color: var(--profit); background: var(--profit-soft); }
.chip.in_stock { color: var(--stock); background: var(--stock-soft); }
.chip.written_off { color: var(--muted); background: var(--bg-deep); }
.chip.old { color: var(--warn); background: var(--warn-soft); }
.chip.mid { color: var(--warn); background: var(--warn-soft); }
.chip.fresh { color: var(--profit); background: var(--profit-soft); }
.chip.plain::before { display: none; }

/* ── Кнопки и формы ───────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px;
  border-radius: 11px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; background: var(--btn); color: var(--btn-ink);
  transition: transform .16s var(--ease-out), background-color .15s var(--ease-out), opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
@media (hover: hover) and (pointer: fine) { .btn.ghost:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); } }
.btn.armed { background: var(--loss); color: #fff; border-color: var(--loss); }
.btn.soft { background: var(--bg-deep); color: var(--ink); }
.btn.good { background: var(--profit); color: var(--on-profit); }
.btn.danger { background: transparent; color: var(--loss); border-color: color-mix(in srgb, var(--loss) 45%, transparent); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.form { display: grid; gap: 14px; }
.form .cols { display: grid; gap: 14px; align-items: start; }
@media (min-width: 640px) { .form .cols { grid-template-columns: 1fr 1fr; } .form .cols.three { grid-template-columns: 1fr 1fr 1fr; } }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13.5px; font-weight: 550; color: var(--ink-2); }
.field small { color: var(--muted); font-size: 12.5px; }
.input, .field input, .field select, .field textarea {
  height: 44px;
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px; min-height: 44px;
  transition: border-color .15s var(--ease-out), box-shadow .15s var(--ease-out);
}
.field textarea { height: auto; min-height: 84px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.with-unit { position: relative; }
.with-unit input { padding-right: 34px; }
.with-unit::after { content: '₽'; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.error { color: var(--loss); background: var(--loss-soft); padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.note { color: var(--ink-2); background: var(--bg-deep); padding: 10px 12px; border-radius: 10px; font-size: 14px; }

.searchbar { display: flex; gap: 8px; margin-bottom: 12px; }
.searchbar .input { flex: 1; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 4px; margin-bottom: 8px; }
.filters::-webkit-scrollbar { display: none; }
.filters .chip-link { flex: none; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); text-decoration: none; color: var(--muted); font-size: 14px; background: var(--surface); }
.filters .chip-link { transition: transform .16s var(--ease-out), background-color .15s var(--ease-out); }
.filters .chip-link:active { transform: scale(.97); }
.filters .chip-link[aria-current="true"] { color: var(--btn-ink); background: var(--btn); border-color: var(--btn); }

/* ── Карточка сделки: путь «купил → продал» ───────── */
.trail { list-style: none; margin: 0; padding: 0; position: relative; }
.trail li { display: grid; grid-template-columns: 26px 1fr auto; gap: 12px; align-items: baseline; padding: 10px 0; position: relative; }
.trail li::before { content: ''; position: absolute; left: 12px; top: 26px; bottom: -12px; border-left: 2px dotted var(--line-strong); }
.trail li:last-child::before { display: none; }
.trail .knot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-deep); color: var(--ink-2); align-self: start; position: relative; z-index: 1; }
.trail .knot .i { width: 14px; height: 14px; }
.trail .lbl { font-weight: 550; }
.trail .lbl small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; }
.trail .amt { font-weight: 600; }
.trail li.total { border-top: 1px solid var(--line-strong); margin-top: 6px; padding-top: 14px; }
.trail li.total .amt { font-size: 22px; font-weight: 800; }
.trail li.total .knot { background: var(--ink); color: var(--bg); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; }

/* ── Графики ──────────────────────────────────────── */
.chart { position: relative; height: 260px; }
.chart.tall { height: 340px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.quad { display: grid; gap: 10px; }
@media (min-width: 640px) { .quad { grid-template-columns: 1fr 1fr; } }
.quad > div { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface-2); }
.quad h3 { font-size: 14px; display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.quad p { font-size: 14px; color: var(--muted); }

/* ── Пустые состояния, тосты, разное ──────────────── */
.empty { text-align: left; padding: 28px 22px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface-2); }
.empty h2 { font-size: 20px; margin-bottom: 6px; }
.empty p { color: var(--muted); margin-bottom: 14px; max-width: 52ch; }

.flash {
  position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: var(--z-toast); max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: 12px;
  background: var(--btn); color: var(--btn-ink); box-shadow: var(--shadow); font-weight: 500;
  animation: toast 3.6s var(--ease-out) both;
}
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -8px); } 8%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -8px); visibility: hidden; } }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; color: var(--muted); font-size: 14px; }

details.more > summary { cursor: pointer; list-style: none; color: var(--muted); font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
details.more > summary::-webkit-details-marker { display: none; }
details.more[open] > summary .i { transform: rotate(180deg); }
details.more > summary .i { transition: transform .2s var(--ease-out); }

.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-list a { display: flex; align-items: center; gap: 12px; padding: 14px 4px; border-top: 1px solid var(--line); text-decoration: none; }
.menu-list li:first-child a { border-top: 0; }
.menu-list a .i:last-child { margin-left: auto; color: var(--faint); }
.menu-list small { display: block; color: var(--muted); font-size: 13px; }

/* Импорт */
.map-row { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 10px 0; border-top: 1px solid var(--line); }
.map-row:first-child { border-top: 0; }
@media (min-width: 720px) { .map-row { grid-template-columns: 1fr 24px 1.2fr; align-items: center; } }
.map-row .src { font-weight: 550; }
.map-row .src small { display: block; color: var(--muted); font-weight: 400; font-size: 12.5px; }
.map-row .arrow { color: var(--faint); display: none; }
@media (min-width: 720px) { .map-row .arrow { display: block; } }
.conf-low { background: var(--warn-soft); border-radius: 10px; padding: 10px 12px; border-top-color: transparent; }
.conf-low .src small { color: var(--warn); }
.issue { padding: 12px 0; border-top: 1px solid var(--line); }
.issue:first-child { border-top: 0; }
.issue .where { font-size: 12.5px; color: var(--muted); }
.issue form { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.issue .done { color: var(--profit); font-size: 13.5px; margin-top: 6px; display: flex; gap: 6px; align-items: center; }

.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand { margin-bottom: 28px; }
.auth-card h1 { font-size: 28px; margin-bottom: 6px; }
.auth-card .lead { color: var(--muted); margin-bottom: 22px; }

.theme-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--bg-deep); border: 1px solid var(--line); }
.theme-switch button { appearance: none; border: 0; background: none; color: var(--muted); padding: 6px 9px; border-radius: 7px; cursor: pointer; display: grid; place-items: center; }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.hide-mobile { display: none; }
@media (min-width: 960px) { .hide-mobile { display: revert; } .hide-desktop { display: none !important; } }

/* дети сеток не должны распирать страницу (графики, таблицы) */
.grid-2 > *, .main > *, .app > div { min-width: 0; }
canvas { max-width: 100%; }
.fab-group { position: fixed; right: 16px; bottom: calc(var(--tabbar) + 14px + env(safe-area-inset-bottom)); z-index: var(--z-fab); display: flex; gap: 8px; }
.fab-group .fab { position: static; }
.fab.alt { background: var(--profit); color: var(--on-profit); }
.row .t { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row-actions { display: flex; align-items: center; gap: 8px; }
.row-actions .row { flex: 1; min-width: 0; }
.scroll-hint { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
@media (min-width: 960px) { .fab-group { display: none; } .scroll-hint { display: none; } }
@media (max-width: 639px) { .hide-sm { display: none; } }

@media (max-width: 959px) {
  .toggle, details.more > summary, .panel-head a, .back-link, .brand { min-height: 44px; display: inline-flex; align-items: center; }
  details.more > summary { display: flex; }
  .btn.small { min-height: 44px; }
  .filters { flex-wrap: wrap; overflow: visible; }
  .stock-layout > :last-child { order: -1; }
  .place-row { grid-template-columns: 1fr 1fr !important; }
  .place-row .num { display: none; }
  .filters .chip-link { min-height: 44px; display: inline-flex; align-items: center; }
  .seg a { padding: 10px 12px; }
  .theme-switch button { min-width: 44px; min-height: 40px; }
  .select-compact { min-height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  *:not(.flash), *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .btn:active, .fab:active, .tabbar a:active, .chip-link:active { transform: none; }
  .flash { animation-name: toast-fade; }
  @keyframes toast-fade { 0% { opacity: 0; } 6%, 88% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }
}

/* v2: разобрать склад */
.triage { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.triage-item { padding: 14px 16px; }
.triage-item .t { text-decoration: none; }
.triage-hint { color: var(--ink-2); font-size: 14px; margin: 8px 0 10px; }
.triage-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.triage-actions details.act { flex-basis: auto; }
.triage-actions details.act[open] { flex-basis: 100%; order: -1; }
.triage-actions details.act > summary { list-style: none; cursor: pointer; }
.triage-actions details.act > summary::-webkit-details-marker { display: none; }
.act-form { margin-top: 10px; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }

/* v2: быстрый ввод */
table.bulk td { padding: 4px 4px; border-bottom: 0; }
table.bulk th { padding: 6px 4px; }
table.bulk .input { min-height: 40px; height: 40px; padding: 6px 10px; font-size: 15px; }
table.bulk input.num { text-align: right; }
.b-hint { font-size: 12.5px; color: var(--muted); min-height: 0; padding: 2px 2px 0; }
.bulk-row.has-error .input { border-color: var(--loss); }
.suggest { position: absolute; z-index: var(--z-toast); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow); padding: 4px; max-height: 320px; overflow-y: auto; }
.suggest-item { display: block; width: 100%; text-align: left; border: 0; background: none; font: inherit; color: var(--ink); padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.suggest-item span { display: block; color: var(--muted); font-size: 13px; }
.suggest-item.on, .suggest-item:hover { background: var(--bg-deep); }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { text-align: left; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; font: inherit; color: var(--ink); cursor: pointer; min-height: 56px; transition: transform .16s var(--ease-out), border-color .15s var(--ease-out); }
.tile:active { transform: scale(.97); }
.tile.on { border-color: var(--profit); background: var(--profit-soft); }
.tile b { display: block; font-weight: 600; font-size: 14.5px; }
.tile span { color: var(--muted); font-size: 13px; }

/* v2: ремонт */
.parts-list { max-height: 280px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; margin-top: 8px; background: var(--surface-2); }
.part { display: grid; grid-template-columns: 24px 1fr auto; gap: 8px; align-items: center; padding: 10px 12px; border-top: 1px solid var(--line); cursor: pointer; min-height: 44px; }
.part:first-child { border-top: 0; }
.part input { width: 18px; height: 18px; }
.part[hidden] { display: none; }

.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--ink-2); }
.triage-item .t { display: inline-flex; align-items: center; min-height: 44px; }

/* Что покупать */
.buy-search { white-space: nowrap; }
.buy-search details.act { display: inline-block; vertical-align: top; margin-left: 4px; }
.buy-search details.act > summary { list-style: none; cursor: pointer; }
.buy-search details.act > summary::-webkit-details-marker { display: none; }
.buy-search details.act[open] { display: block; margin: 8px 0 0; white-space: normal; min-width: 240px; }
@media (max-width: 639px) {
  .buy-table thead { display: none; }
  .buy-table, .buy-table tbody { display: block; }
  .buy-table tr { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
  .buy-table td { display: block; padding: 0; border: 0; }
  .buy-table td:first-child { grid-column: 1 / -1; }
  .buy-table td.num { text-align: left; font-size: 17px; }
  .buy-table td.num::before { content: 'брать до '; font-size: 13px; font-weight: 400; color: var(--muted); }
  .buy-table td.hide-sm { display: none; }
  .buy-table td.num.skip::before { content: none; }
  .buy-table .buy-search { text-align: right; }
  .buy-table tr:has(details[open]) .buy-search { grid-column: 1 / -1; text-align: left; }
}
