/* Та же схема, что в аналитике: днём «Сумерки», в тёмной теме телефона «Ночь».
   Красный: готового меньше, чем нужно по заказам. Янтарный: нужно по заказам. Зелёный: приход. */
:root {
  --bg: #EEF1F8; --surface: #FFFFFF; --surface-2: #F3F5FB; --ink: #0F1B3D; --muted: #5E6A8C; --line: #DDE3F0;
  --accent: #2563EB; --accent-ink: #FFFFFF; --accent-soft: #DCE7FD;
  --amber: #B45309; --amber-soft: #FFF0DE; --red: #D12B34; --red-soft: #FDE5E6; --green: #0B8A5F; --green-soft: #DEF5EC;
  --shadow: 0 1px 2px rgba(15, 27, 61, .05); --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B0F1E; --surface: #141A2E; --surface-2: #1B2240; --ink: #EEF1FF; --muted: #8D94B8; --line: #252D4D;
    --accent: #4FD1FF; --accent-ink: #06121F; --accent-soft: #1C3350;
    --amber: #FFB547; --amber-soft: #3A2E14; --red: #FF6B6B; --red-soft: #3D1C24; --green: #34D399; --green-soft: #12352C;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B0F1E; --surface: #141A2E; --surface-2: #1B2240; --ink: #EEF1FF; --muted: #8D94B8; --line: #252D4D;
  --accent: #4FD1FF; --accent-ink: #06121F; --accent-soft: #1C3350;
  --amber: #FFB547; --amber-soft: #3A2E14; --red: #FF6B6B; --red-soft: #3D1C24; --green: #34D399; --green-soft: #12352C;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.45 Manrope, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
button, input, select { font: inherit; color: inherit; }
input[type="search"], input[type="text"], input[type="number"], select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 16px;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.err { color: var(--red); margin: 6px 0 0; }
.ok { color: var(--green); font-weight: 700; }

.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 16px; font-weight: 700; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.small { padding: 6px 12px; font-size: 14px; border-radius: 9px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; margin-top: 12px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { border: 0; background: transparent; width: 36px; height: 36px; border-radius: 10px; cursor: pointer; color: var(--muted); font-size: 16px; flex: none; }

/* вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-box { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 6px; }
.login-logo { border-radius: 16px; margin-bottom: 12px; }
.login-box h1 { font-size: 26px; font-weight: 800; }
.login-box p.muted { margin: 0 0 16px; }
.login-box label { font-size: 13px; color: var(--muted); margin-top: 8px; }
.login-box input { padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 16px; }
.login-box .btn { margin-top: 18px; }

/* шапка */
.bar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.bar-in { max-width: 980px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 17px; color: inherit; text-decoration: none; }
.brand img { border-radius: 7px; display: block; }
.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; max-width: 100%; }
.tabs a { padding: 5px 11px; border-radius: 7px; font-size: 14px; font-weight: 700; color: var(--muted); text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.tabs a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(15, 27, 61, .12); }
.badge { background: var(--red); color: #fff; border-radius: 99px; font-size: 11px; line-height: 1; padding: 3px 6px; font-weight: 800; }
.who { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
@media (max-width: 640px) {
  .bar-in { gap: 8px; }
  .brand span { display: none; }
  .tabs { order: 3; width: 100%; }
  .tabs a { flex: 1; justify-content: center; padding: 6px 6px; }
}

.wrap { max-width: 980px; margin: 0 auto; padding: 14px 16px 90px; }
.view { display: flex; flex-direction: column; gap: 12px; }
.h { font-size: 20px; font-weight: 800; }
.h3 { font-size: 15px; font-weight: 800; margin-top: 14px; }
.lead { margin: -6px 0 4px; font-size: 14px; }
.notice { border-radius: 12px; padding: 10px 14px; font-size: 14px; margin-bottom: 12px; }
.notice.warn { background: var(--amber-soft); color: var(--amber); font-weight: 600; }
.empty { padding: 20px 4px; text-align: center; }
.empty-big { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 28px 20px; text-align: center; }
.empty-big p { margin: 8px 0 0; }
.empty-ok { background: var(--green-soft); color: var(--green); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 2px; }
.empty-ok .muted { color: inherit; opacity: .8; }

/* сегодня */
.today { display: flex; gap: 8px; overflow-x: auto; }
.tchip { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; display: flex; flex-direction: column; min-width: 110px; font-size: 13px; }
.tchip b { font-size: 20px; font-weight: 800; }

/* переключатели */
.seg { display: flex; gap: 4px; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
.seg button { flex: 1 0 auto; border: 0; background: transparent; border-radius: 9px; padding: 8px 10px; font-weight: 700; color: var(--muted); cursor: pointer; white-space: nowrap; position: relative; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(15, 27, 61, .12); }
.seg.small { margin: 14px 0 10px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--red); margin-left: 5px; vertical-align: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 12px; font-weight: 700; font-size: 14px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.chips button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chips .cnt { font-weight: 600; opacity: .7; font-size: 12px; }
.toolbar { display: flex; gap: 10px; align-items: center; }
.toolbar.wrap-tb { flex-wrap: wrap; }
.toolbar.wrap-tb select { width: auto; }
.switch { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; font-weight: 700; font-size: 14px; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }
.legend { font-size: 12.5px; margin-top: -4px; }

/* список остатков */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.list.small { margin: 8px 0; }
.row { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 12px 11px 14px; border: 0; background: transparent; text-align: left; cursor: pointer; }
.row-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.nums { display: flex; align-items: baseline; gap: 8px; flex: none; }
.n-ready { font-size: 19px; font-weight: 800; min-width: 28px; text-align: right; }
.n-cut { font-size: 12.5px; color: var(--muted); }
.n-cut.faint { opacity: .5; }
.n-need { font-size: 12.5px; color: var(--amber); background: var(--amber-soft); border-radius: 6px; padding: 1px 6px; font-weight: 700; }
.row.zero .n-ready { color: var(--muted); }
.row.short .n-ready { color: var(--red); }
.row.short .n-need { color: var(--red); background: var(--red-soft); }
.plus { width: 52px; flex: none; border: 0; border-left: 1px solid var(--line); background: transparent; font-size: 24px; font-weight: 500; color: var(--accent); cursor: pointer; }
.plus:active, .row-main:active { background: var(--surface-2); }
.list-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; flex-wrap: wrap; }

/* лист (диалог) */
.sheet { border: 0; padding: 0; background: transparent; max-width: 560px; width: 100%; max-height: 100%; margin: auto auto 0; }
.sheet::backdrop { background: rgba(8, 12, 30, .45); }
.sheet-in { background: var(--surface); color: var(--ink); border-radius: 18px 18px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto; }
@media (min-width: 700px) { .sheet { margin: auto; } .sheet-in { border-radius: 18px; } }
.sheet-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.sheet-head h2 { font-size: 19px; font-weight: 800; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 6px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 8px 10px; display: flex; flex-direction: column; font-size: 12px; line-height: 1.25; justify-content: space-between; }
.stat b { font-size: 20px; font-weight: 800; }
.stat.bad b { color: var(--red); }
.form { display: flex; flex-direction: column; gap: 8px; }
.lbl { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 4px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline select { width: auto; }
.stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; width: fit-content; background: var(--surface); }
.stepper button { width: 48px; border: 0; background: var(--surface-2); font-size: 22px; cursor: pointer; }
.stepper .step-in { width: 70px; border: 0; border-radius: 0; text-align: center; font-size: 20px; font-weight: 800; padding: 8px 4px; -moz-appearance: textfield; }
.step-in.wide { width: 120px; border: 1px solid var(--line); border-radius: 10px; }
.step-in::-webkit-outer-spin-button, .step-in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; padding: 4px 0; }
.check input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--accent); }
details.mgr { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
details.mgr summary { cursor: pointer; font-weight: 700; font-size: 14px; color: var(--muted); }
details.mgr .form { margin-top: 10px; }
.hist { display: flex; flex-direction: column; }

/* журнал */
.dayhead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 8px 2px 6px; flex-wrap: wrap; font-size: 14px; }
.mrow { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.mrow:last-child { border-bottom: 0; }
.hist .mrow { padding: 8px 0; }
.mrow.undone { opacity: .5; }
.m-time { color: var(--muted); font-size: 12.5px; flex: none; min-width: 42px; }
.m-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.m-kind { font-weight: 700; font-size: 13px; }
.m-name { font-weight: 600; overflow-wrap: anywhere; }
.m-meta { font-size: 12.5px; overflow-wrap: anywhere; }
.m-delta { font-weight: 800; font-size: 16px; flex: none; min-width: 34px; text-align: right; }
.m-delta.pos { color: var(--green); }
.m-delta.neg { color: var(--ink); }
.k-order { color: var(--accent); } .k-return { color: var(--amber); } .k-in, .k-sew { color: var(--green); } .k-adjust, .k-undo { color: var(--red); }

/* уточнить */
.pcard { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--amber); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); }
.pc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.pc-head b { font-size: 17px; }
.ctx { display: flex; flex-wrap: wrap; gap: 6px; }
.ctx span { background: var(--surface-2); border-radius: 8px; padding: 3px 8px; font-size: 13px; font-weight: 600; }
.why { margin: 0; font-size: 13px; }
.cands { display: flex; flex-direction: column; gap: 6px; }
.cand-wrap { display: flex; gap: 8px; align-items: center; }
.cand { flex: 1; display: flex; justify-content: space-between; gap: 10px; align-items: center; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 12px; cursor: pointer; text-align: left; font-weight: 600; }
.cand.on { border-color: var(--accent); background: var(--accent-soft); }
.cand.static { cursor: default; }
.cand-n { font-size: 12.5px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.cand-n.bad { color: var(--red); }
.results { display: flex; flex-direction: column; gap: 4px; }
.res { border: 1px dashed var(--line); background: transparent; border-radius: 10px; padding: 8px 12px; text-align: left; cursor: pointer; font-size: 14px; }

/* настройки */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow); }
.card h3 { font-size: 16px; font-weight: 800; }
.card p { margin: 0; font-size: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card-head input { max-width: 220px; }
.rrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: transparent; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; font-size: 14px; }
.rrow:last-child { border-bottom: 0; }
.rrow.click { cursor: pointer; }
.rr-main { display: flex; flex-direction: column; min-width: 0; }
.rr-what { font-size: 13px; color: var(--muted); text-align: right; max-width: 55%; overflow-wrap: anywhere; }
#unmatchedList .rrow { padding-left: 0; padding-right: 0; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 50;
  background: var(--ink); color: var(--bg); border-radius: 12px; padding: 11px 14px; font-weight: 600; font-size: 14px;
  display: flex; gap: 14px; align-items: center; max-width: calc(100vw - 32px); box-shadow: 0 6px 24px rgba(0, 0, 0, .25); }
.toast-act { border: 0; background: transparent; color: inherit; font-weight: 800; text-decoration: underline; cursor: pointer; padding: 0; }

.small-note { font-size: 12.5px; margin: 6px 0 0; }
.cand-wrap .stepper button { width: 36px; font-size: 18px; }
.cand-wrap .stepper .step-in { width: 40px; font-size: 16px; padding: 6px 2px; }
.cand-wrap .cand { padding: 8px 10px; }
