/* Демо-панель оптового бота. Светлая и тёмная темы (по настройке системы). */
:root {
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e2e5ea;
  --border-strong: #cfd4dc;
  --text: #1b2130;
  --muted: #687082;
  --primary: #2f6fed;
  --primary-hover: #245ad0;
  --primary-soft: #e9f0ff;
  --ok: #138a45;
  --ok-soft: #e6f6ec;
  --warn: #b86a00;
  --warn-soft: #fff3df;
  --danger: #cf2b2b;
  --danger-soft: #fdecec;
  --info: #0b7f99;
  --info-soft: #e2f5f9;
  --violet: #6d4bd8;
  --violet-soft: #f0ebff;
  --sidebar: #131926;
  --sidebar-2: #1b2334;
  --sidebar-text: #b9c2d3;
  --sidebar-active: #26324b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e121a;
    --surface: #161c27;
    --surface-2: #1b2230;
    --border: #283142;
    --border-strong: #354055;
    --text: #e6e9ef;
    --muted: #97a1b3;
    --primary: #5b8ef5;
    --primary-hover: #7aa3f7;
    --primary-soft: #1d2a45;
    --ok: #4cc27f;
    --ok-soft: #15301f;
    --warn: #e8a33b;
    --warn-soft: #36290f;
    --danger: #f06a6a;
    --danger-soft: #3a1b1b;
    --info: #4cc0d8;
    --info-soft: #12303a;
    --violet: #a68bff;
    --violet-soft: #2a2245;
    --sidebar: #0b0f16;
    --sidebar-2: #121824;
    --sidebar-active: #1e2738;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
small, .muted { color: var(--muted); }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 18px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; font-size: 15px; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, #3f7cff, #7a5cff);
  display: grid; place-items: center; font-size: 16px;
}
.brand small { display: block; color: var(--sidebar-text); font-weight: 400; font-size: 11.5px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--sidebar-text); font-weight: 500;
}
.nav a:hover { background: var(--sidebar-2); color: #fff; text-decoration: none; }
.nav a.active { background: var(--sidebar-active); color: #fff; }
.nav .ico { width: 20px; text-align: center; }
.nav .count {
  margin-left: auto; min-width: 20px; padding: 1px 7px; border-radius: 999px;
  background: #e5484d; color: #fff; font-size: 11.5px; font-weight: 700; text-align: center;
}
.nav .count:empty, .nav .count[data-zero="1"] { display: none; }
.nav-sep { margin: 14px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6f7a8f; }
.sidebar .bottom { margin-top: auto; padding: 10px; font-size: 12.5px; }
.sidebar .bottom form { display: inline; }
.sidebar .bottom button { background: none; border: 0; color: var(--sidebar-text); cursor: pointer; padding: 0; font: inherit; }
.sidebar .bottom a { color: var(--sidebar-text); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { margin: 0; font-size: 19px; }
.topbar .spacer { flex: 1; }
.content { padding: 22px 28px 60px; max-width: 1500px; width: 100%; }

/* ---------- cards & grid ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; min-width: 0;
}
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-head .spacer { flex: 1; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr); }
.stack > * + * { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -.01em; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.attention a.item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); margin-bottom: 8px; color: var(--text); background: var(--surface-2);
}
.attention a.item:hover { border-color: var(--primary); text-decoration: none; }
.attention .num { margin-left: auto; font-weight: 700; font-size: 16px; }
.attention .item.hot { border-color: #f4b4b4; background: var(--danger-soft); }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 550;
  cursor: pointer; white-space: nowrap; text-decoration: none; line-height: 1.2;
}
.btn:hover { border-color: var(--primary); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost-danger { color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.xs { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.btn[disabled] { opacity: .5; cursor: default; }
input[type=text], input[type=number], input[type=password], input[type=search], input[type=date],
input[type=datetime-local], select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 7px 10px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea { width: 100%; resize: vertical; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-weight: 550; margin-bottom: 5px; }
label.field input[type=text], label.field input[type=password], label.field input[type=number],
label.field select, label.field textarea { width: 100%; }
.check { display: inline-flex; align-items: center; gap: 6px; margin-right: 14px; cursor: pointer; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { width: 260px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a {
  padding: 9px 14px; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a.active { color: var(--text); border-bottom-color: var(--primary); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.seg a { padding: 6px 12px; color: var(--muted); font-weight: 550; border-right: 1px solid var(--border); }
.seg a:last-child { border-right: 0; }
.seg a.active { background: var(--primary-soft); color: var(--primary); }
.seg a:hover { text-decoration: none; color: var(--text); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.t { width: 100%; border-collapse: collapse; }
table.t th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--border);
  white-space: nowrap; position: sticky; top: 0; background: var(--surface);
}
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.clickable { cursor: pointer; }
table.t tr.clickable:hover td, table.t tbody tr:hover td { background: var(--surface-2); }
table.t td.num, table.t th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.t td.nowrap { white-space: nowrap; }
table.t .title { font-weight: 550; }
table.t tr.focus td { background: var(--warn-soft) !important; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* ---------- pills & badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border);
}
.pill.st-new { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.pill.st-processing { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.st-assembled { background: var(--violet-soft); color: var(--violet); border-color: transparent; }
.pill.st-shipped { background: var(--info-soft); color: var(--info); border-color: transparent; }
.pill.st-done { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.st-cancelled { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.pill.today { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.preorder { background: var(--info-soft); color: var(--info); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .2); }
.dot.off { background: #ef4444; }

/* ---------- sales switch in topbar ---------- */
.sales { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.sales b { font-weight: 650; }
.sales form { margin: 0; }

/* ---------- flash ---------- */
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.error { background: var(--danger-soft); color: var(--danger); }
.flash.info { background: var(--primary-soft); color: var(--primary); }
.banner { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; background: var(--warn-soft); color: var(--warn); }

/* ---------- feed ---------- */
.feed { list-style: none; margin: 0; padding: 0; max-height: 640px; overflow-y: auto; }
.feed li { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; padding: 9px 4px; border-bottom: 1px solid var(--border); }
.feed li:last-child { border-bottom: 0; }
.feed li.fresh { animation: fresh 2.5s ease-out; }
@keyframes fresh { from { background: var(--warn-soft); } to { background: transparent; } }
.feed .ico { font-size: 15px; text-align: center; }
.feed .who { font-weight: 600; }
.feed .what { word-break: break-word; }
.feed .time { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* ---------- chat (client feed) ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; max-height: 620px; overflow-y: auto; padding: 4px; }
.msg { max-width: 78%; padding: 9px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); word-break: break-word; }
.msg .text { white-space: pre-wrap; }
.msg.ev { align-self: stretch; max-width: none; background: transparent; border: 0; border-left: 3px solid var(--border-strong); border-radius: 0; padding: 3px 10px; font-size: 12.5px; color: var(--muted); }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; background: var(--primary-soft); border-color: transparent; }
.msg.sys { align-self: center; background: transparent; border-style: dashed; color: var(--muted); font-size: 12.5px; }
.msg .meta { display: block; font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.msg.req { border-color: #f1c27a; background: var(--warn-soft); }

/* ---------- catalog ---------- */
.cat-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.tree { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.tree ul { list-style: none; margin: 0; padding-left: 14px; border-left: 1px dashed var(--border); margin-left: 8px; }
.tree a { display: flex; justify-content: space-between; gap: 6px; padding: 4px 8px; border-radius: 6px; color: var(--text); }
.tree a:hover { background: var(--surface-2); text-decoration: none; }
.tree a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.tree a .n { color: var(--muted); font-size: 12px; white-space: nowrap; }
.tree a.off { color: var(--muted); text-decoration: line-through; }
.tree-scroll { max-height: calc(100vh - 160px); overflow-y: auto; position: sticky; top: 76px; }
input.price { width: 110px; text-align: right; font-variant-numeric: tabular-nums; }
input.tiers { width: 170px; }
input.qty { width: 74px; text-align: right; }
.saved { outline: 2px solid var(--ok) !important; }
.err { outline: 2px solid var(--danger) !important; }
.attrs { color: var(--muted); font-size: 12px; }

/* ---------- misc ---------- */
.toast-box { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--sidebar); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.25); max-width: 380px; animation: pop .2s ease-out; }
.toast a { color: #9cc0ff; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.autocomplete { position: relative; }
.autocomplete .list { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 320px; overflow-y: auto; }
.autocomplete .list div { padding: 7px 10px; cursor: pointer; }
.autocomplete .list div:hover, .autocomplete .list div.sel { background: var(--primary-soft); }
.bar { height: 8px; border-radius: 4px; background: var(--primary); min-width: 2px; }
.bar-bg { background: var(--surface-2); border-radius: 4px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.pagination { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 5px 10px; border-radius: 6px; border: 1px solid var(--border); }
.pagination span.cur { background: var(--primary); color: #fff; border-color: var(--primary); }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 360px; max-width: 100%; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.timeline li { padding: 6px 0; border-bottom: 1px dashed var(--border); display: grid; grid-template-columns: 92px 1fr; gap: 8px; }
.timeline li:last-child { border-bottom: 0; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.w100 { width: 100%; }
.mt0 { margin-top: 0; }
.mb0 { margin-bottom: 0; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .cat-layout { grid-template-columns: minmax(0, 1fr); }
  .tree-scroll { position: static; max-height: 320px; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .brand { padding: 4px 8px; width: 100%; }
  .nav-sep, .sidebar .bottom { display: none; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px; }
  .grid-2, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: 1fr; }
  .filters input[type=search] { width: 100%; }
}

/* ---------- позиции заказа в списке, отметка «собрано» ---------- */
.lines-row > td { background: var(--bg); padding-top: 4px; padding-bottom: 10px; }
table.lines { width: 100%; border-collapse: collapse; font-size: 13px; }
table.lines td { padding: 5px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.lines tr:last-child td { border-bottom: 0; }
.check-cell { width: 28px; }
.check-cell input { width: 16px; height: 16px; cursor: pointer; }
tr.done > td { background: var(--ok-soft); }
.check-cell .check { margin-right: 0; }
table.t td.grow, table.lines td.grow { min-width: 260px; }
table.t tr.out > td { background: var(--danger-soft); }
