/* Общий UI-кит RBS (из ERP «Бетон»). Оформление системы продаж вина — vino/app.css поверх этого файла.
   Шрифты системные: без внешних CDN. */

:root {
  --bg: #e9ecee;
  --panel: #ffffff;
  --panel-2: #f4f6f7;
  --ink: #18212b;
  --muted: #5b6875;
  --line: #c9d0d6;
  --line-soft: #dde2e6;
  --accent: #1f5fbf;
  --accent-ink: #ffffff;
  --accent-soft: #e3ecfa;
  --focus: #1f5fbf;

  /* статусы — из макетов ТЗ; легенда на каждом графике */
  --st-done: #2f9a53;      --st-done-bg: #d6efdd;
  --st-transit: #dd7334;   --st-transit-bg: #fbe2d3;
  --st-loading: #d9a021;   --st-loading-bg: #fcefcd;
  --st-planned: #5a8bd6;   --st-planned-bg: #dce7f8;
  --st-conflict: #c93a3a;  --st-conflict-bg: #f6d6d6;
  --st-none: #9aa5b0;      --st-none-bg: #ffffff;
  --fill-done: #8fd19e; --fill-planned: #9fc0f2; --fill-loading: #f6cf6e; --fill-conflict: #ee9b9b; --fill-plan: #e3e7eb;

  --radius-s: 6px;
  --radius-m: 10px;
  --shadow-pop: 0 12px 32px rgba(24, 33, 43, 0.18);
  --font: "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --rail: 208px;
  color-scheme: light;
}

/* Тёмная тема */
:root[data-theme="dark"] {
  --bg: #161d24;
  --panel: #1f2832;
  --panel-2: #26313c;
  --ink: #e6ebef;
  --muted: #9aa7b3;
  --line: #3a4753;
  --line-soft: #2e3944;
  --accent: #5b9bff;
  --accent-ink: #0d1620;
  --accent-soft: #23344d;
  --focus: #8db8ff;
  --st-done-bg: #1e3a29;
  --st-transit-bg: #42291b;
  --st-loading-bg: #40351a;
  --st-planned-bg: #1f3150;
  --st-conflict-bg: #4a2222;
  --st-none-bg: #1f2832;
  --fill-done: #2f6b41; --fill-planned: #2d4f85; --fill-loading: #7a6020; --fill-conflict: #7a3030; --fill-plan: #34404c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
#root { min-height: 100%; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 700; }
.right { text-align: right; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 6px; }
.grow { flex: 1 1 auto; min-width: 0; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------------- каркас приложения ---------------- */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
.rail {
  background: var(--ink);
  color: #dfe5ea;
  display: flex; flex-direction: column;
  padding: 14px 10px; gap: 2px;
  position: sticky; top: 0; height: 100vh;
}
:root[data-theme="dark"] .rail { background: #0f151b; }
.rail .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: #fff; font-weight: 700; }
.rail .brand svg { flex: none; }
.rail a {
  display: flex; align-items: center; gap: 10px;
  color: inherit; text-decoration: none;
  padding: 9px 10px; border-radius: var(--radius-s);
  font-size: 14px;
}
.rail a:hover { background: rgba(255, 255, 255, 0.07); }
.rail a.active { background: var(--accent); color: #fff; }
.rail a .ico { width: 20px; height: 20px; flex: none; opacity: 0.9; }
.rail .spacer { flex: 1; }
.rail .who { font-size: 13px; padding: 8px 10px; color: #aeb9c3; border-top: 1px solid rgba(255,255,255,0.1); }
.rail .who button { background: none; border: 0; color: #fff; padding: 0; cursor: pointer; text-decoration: underline; }
.rail .rail-links { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; font-size: 13px; }
.rail .rail-links a { color: #e8dcc4; text-decoration: none; }
.rail .rail-links a:hover { text-decoration: underline; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 22px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.content { padding: 18px 22px 40px; display: flex; flex-direction: column; gap: 16px; }
.content.flush { padding: 0; }
.bottom-nav { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }
  .topbar { padding: 12px 16px; }
  .content { padding: 14px 16px 92px; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--panel); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a, .bottom-nav button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: 11px; color: var(--muted); text-decoration: none; padding: 4px 2px;
  }
  .bottom-nav button { background: none; border: 0; font: inherit; font-size: 11px; cursor: pointer; }
  .bottom-nav a.active { color: var(--accent); font-weight: 700; }
  .bottom-nav .ico { width: 22px; height: 22px; }
}

/* ---------------- панели и блоки ---------------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); }
.panel > .ph { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; gap: 12px; }
.panel > .pb { padding: 14px 16px; }
.panel.pad { padding: 14px 16px; }
.split { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .cols-2, .cols-3 { grid-template-columns: 1fr; } }

/* ---------------- кнопки и поля ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--panel); color: var(--ink); cursor: pointer; font-weight: 600;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--st-conflict); border-color: var(--st-conflict); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn.big { min-height: 64px; font-size: 19px; padding: 0 22px; border-width: 2px; border-radius: var(--radius-m); }
.btn.block { width: 100%; }
.icon-btn { width: 36px; padding: 0; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .field > .label { font-size: 13px; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .err { font-size: 12px; color: var(--st-conflict); }
.input, .select, textarea.input {
  width: 100%; min-height: 40px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--panel); color: var(--ink);
}
textarea.input { min-height: 72px; resize: vertical; }
.input:focus, .select:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
.input.invalid { border-color: var(--st-conflict); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .wide { grid-column: 1 / -1; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { width: 18px; height: 18px; }

/* сегментированные кнопки */
.seg { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.seg button {
  min-height: 48px; border: 1.5px solid var(--line); border-radius: var(--radius-s);
  background: var(--panel); font-weight: 600; font-size: 16px; cursor: pointer;
}
.seg button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); border-width: 2px; }
.stepper { display: inline-grid; grid-template-columns: 48px 56px 48px; border: 1.5px solid var(--line); border-radius: var(--radius-s); overflow: hidden; }
.stepper button { border: 0; background: var(--panel-2); font-size: 22px; cursor: pointer; min-height: 48px; }
.stepper input { border: 0; text-align: center; font-size: 18px; font-weight: 700; width: 56px; background: var(--panel); }

/* ---------------- таблицы ---------------- */
.table-wrap { overflow: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; }
.table td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--panel-2); }
.table td.num, .table th.num { text-align: right; }

/* ---------------- статусы ---------------- */
.tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
}
.tag::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--st-none); }
.tag.s-done::before { background: var(--st-done); }
.tag.s-transit::before { background: var(--st-transit); }
.tag.s-loading::before { background: var(--st-loading); }
.tag.s-planned::before { background: var(--st-planned); }
.tag.s-conflict::before { background: var(--st-conflict); }
.tag.plain::before { display: none; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 16px; height: 12px; border-radius: 3px; border: 1.5px solid; display: inline-block; }

.sw-done { background: var(--st-done-bg); border-color: var(--st-done); }
.sw-transit { background: var(--st-transit-bg); border-color: var(--st-transit); }
.sw-loading { background: var(--st-loading-bg); border-color: var(--st-loading); }
.sw-planned { background: var(--st-planned-bg); border-color: var(--st-planned); }
.sw-conflict { background: var(--st-conflict-bg); border-color: var(--st-conflict); }
.sw-none { background: var(--st-none-bg); border-color: var(--line); }

/* предупреждения */
.alert {
  border: 1.5px solid var(--st-loading); background: var(--st-loading-bg);
  border-radius: var(--radius-s); padding: 10px 12px;
}
.alert.risk { border-color: var(--st-conflict); background: var(--st-conflict-bg); }
.alert.info { border-color: var(--st-planned); background: var(--st-planned-bg); }
.alert.ok { border-color: var(--st-done); background: var(--st-done-bg); }
.alert .t { font-weight: 600; }
.alert .d { font-size: 13px; color: var(--muted); }
.alert.opt { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.alert.opt input { margin-top: 3px; }
.alert.opt .d { display: block; }

/* ИИ-выводы визуально отделены от фактических данных */
.ai {
  border: 1.5px dashed var(--accent); border-radius: var(--radius-m);
  background: repeating-linear-gradient(135deg, var(--accent-soft) 0 10px, transparent 10px 20px);
  padding: 12px 14px;
}
.ai .badge { font-size: 12px; font-weight: 700; color: var(--accent); }

/* ---------------- показатели ---------------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 12px 14px; }
.kpi .k { font-size: 13px; color: var(--muted); }
.kpi .v { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; margin-top: 2px; }
.kpi .s { font-size: 13px; color: var(--muted); }
.kpi.warn { border-color: var(--st-loading); }
.kpi.bad { border-color: var(--st-conflict); }

.bar { height: 10px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--st-done); border-radius: 999px; }
.bar.warn > i { background: var(--st-transit); }
.bar.thin { height: 6px; }

/* ---------------- выезжающая панель и диалоги ---------------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 21, 27, 0.4); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(980px, 100vw);
  background: var(--panel); z-index: 41; display: flex; flex-direction: column;
  box-shadow: var(--shadow-pop);
}
.drawer.narrow { width: min(560px, 100vw); }
.drawer > header { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer > .body { overflow: auto; flex: 1; padding: 16px 18px; }
.drawer > footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; flex-wrap: wrap; }
.modal {
  position: fixed; left: 50%; top: 12vh; transform: translateX(-50%);
  width: min(520px, calc(100vw - 32px)); background: var(--panel); border-radius: var(--radius-m);
  z-index: 41; box-shadow: var(--shadow-pop); padding: 18px; display: flex; flex-direction: column; gap: 14px;
  max-height: calc(100vh - 12vh - 16px); overflow-y: auto;
}

/* уведомления */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--radius-s); max-width: 420px; box-shadow: var(--shadow-pop); }
.toast.err { background: #8f2424; }
@media (max-width: 860px) { .toasts { bottom: 84px; left: 16px; } }

/* связь с сервером */
.netbar { padding: 8px 16px; background: var(--st-conflict); color: #fff; font-weight: 600; text-align: center; }
.netbar.queued { background: var(--st-loading); color: #1b1404; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button {
  border: 0; background: none; padding: 10px 12px; cursor: pointer; color: var(--muted);
  border-bottom: 3px solid transparent; font-weight: 600; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }

.empty { padding: 28px; text-align: center; color: var(--muted); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- вход ---------------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .box { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 26px; display: flex; flex-direction: column; gap: 14px; }
.login .mark { display: flex; gap: 10px; align-items: center; }


@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .rail, .topbar, .bottom-nav, .no-print { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
}

/* дочерние элементы сеток не растягивают страницу */
.split > *, .cols-2 > *, .cols-3 > * { min-width: 0; }
.main { overflow-x: hidden; }

/* ---------------- клиентская система: оформление поверх общего UI-кита ----------------
   Спокойный сине-серый акцент — чтобы её нельзя было спутать с рабочей системой продаж. */

:root {
  --bg: #f1f3f6;
  --panel: #ffffff;
  --panel-2: #f6f7f9;
  --ink: #1b1f27;
  --muted: #5b6372;
  --line: #d5dae2;
  --line-soft: #e7eaef;
  --accent: #33415c;
  --accent-ink: #ffffff;
  --accent-soft: #e5e9f1;
  --focus: #33415c;
}
:root[data-theme="dark"] {
  --accent: #8fa3c8;
  --accent-soft: #263042;
  --focus: #a9badb;
}
.rail { background: #1c2230; }
.rail a.active { background: var(--accent); }
.sec-bar { background: #1c2230; color: #d7deea; padding: 8px 20px; font-size: 13px; display: flex; gap: 12px; justify-content: space-between; flex-wrap: wrap; }
.sec-bar b { color: #fff; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.vbars { display: flex; align-items: flex-end; gap: 12px; height: 210px; border-bottom: 1px solid var(--line); padding-top: 10px; }
.vbars .c { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; min-width: 0; }
.vbars .c i { display: block; width: 100%; max-width: 56px; border-radius: 6px 6px 0 0; background: #a9b6cc; }
.vbars .c.cur i { background: var(--accent); }
.vbars .c b { font-size: 13px; font-variant-numeric: tabular-nums; }
.vbars-x { display: flex; gap: 12px; margin-top: 6px; }
.vbars-x span { flex: 1 1 0; text-align: center; font-size: 13px; color: var(--muted); }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 18px; letter-spacing: 2px; word-break: break-all;
  background: var(--panel-2); border: 1px dashed var(--line); border-radius: 10px; padding: 10px 14px; }
.qr { background: #fff; padding: 10px; border-radius: 12px; border: 1px solid var(--line); width: max-content; }
.qr img { display: block; width: 220px; height: 220px; image-rendering: pixelated; }
td.num, .num { white-space: nowrap; }
