/* ============ СГЭП Резерв — Styles ============ */
:root {
  --bg: #eef2fa;
  --panel: #ffffff;
  --panel-2: #f6f8fd;
  --ink: #16203a;
  --ink-2: #5b6b85;
  --line: #e3e9f5;
  --primary: #1a4bc4;
  --primary-2: #3b6ff0;
  --primary-soft: #e8efff;
  --accent: #ff8a00;
  --success: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --info: #2f6ded;
  --sidebar: #0d1b3a;
  --sidebar-2: #142750;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(26, 29, 41, 0.06);
  --shadow-lg: 0 18px 50px rgba(26, 29, 41, 0.16);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  min-height: 100dvh;
  /* Liquid glass — мягкий градиентный фон с цветными «каплями» позади стекла */
  background:
    radial-gradient(1100px 750px at 12% -8%, rgba(59,111,240,.34), transparent 60%),
    radial-gradient(950px 700px at 108% 108%, rgba(255,138,0,.26), transparent 55%),
    radial-gradient(750px 520px at 50% 125%, rgba(34,197,94,.20), transparent 62%),
    radial-gradient(600px 420px at 90% 20%, rgba(139,92,246,.18), transparent 55%),
    linear-gradient(135deg, #d9e5ff 0%, #eef2fa 45%, #fbeef8 100%);
  background-attachment: fixed;
  overscroll-behavior-y: none;
}
.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
a { color: var(--primary); text-decoration: none; }

/* ---------- Buttons (unified) ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: none; cursor: pointer; font-family: inherit; font-weight: 600;
  border-radius: 10px; padding: 10px 16px; font-size: 14px;
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease, border-color .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; }
.btn-primary, .btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff;
  box-shadow: 0 6px 16px rgba(26, 75, 196, .35);
}
.btn-primary:hover, .btn.primary:hover { box-shadow: 0 8px 22px rgba(26, 75, 196, .45); }
.btn.ghost { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: #eef0f8; }
.btn.success { background: var(--success); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn-mini { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.link { background: none; border: none; color: var(--primary); cursor: pointer; font-weight: 600; font-size: 13px; padding: 0; }
.icon-btn { background: none; border: none; cursor: pointer; color: var(--ink-2); border-radius: 8px; display: inline-flex; padding: 6px; align-items: center; justify-content: center; flex-shrink: 0; }
.icon-btn:hover { background: var(--panel-2); color: var(--ink); }
.icon-btn.danger { color: var(--danger); }

/* ---------- Badges / chips ---------- */
.badge {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; line-height: 1.4; white-space: nowrap;
  color: var(--c, #3b82f6);
  background: color-mix(in srgb, var(--c, #3b82f6) 13%, transparent);
}
.chip {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-2);
  border-radius: 999px; padding: 6px 14px; font-size: 13px; cursor: pointer; font-weight: 600;
}
.chip.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

/* ---------- Login ---------- */
.login-view {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(1200px 600px at 10% -10%, #2b4fd0 0%, transparent 55%),
              radial-gradient(900px 500px at 110% 110%, #ff8a00 0%, transparent 50%),
              linear-gradient(135deg, #0d1b3a, #162a54 60%, #0a1530);
}
.login-card {
  width: 100%; max-width: 400px; border-radius: 22px;
  padding: 36px 32px;
  background: rgba(255,255,255,.55);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  backdrop-filter: blur(24px) saturate(170%);
  border: 1px solid rgba(255,255,255,.7);
  box-shadow: 0 20px 60px rgba(26,29,41,.2), inset 0 1px 0 rgba(255,255,255,.6);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.logo-badge {
  width: 58px; height: 58px; margin: 0 auto 12px; border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center; color: #fff;
  box-shadow: 0 10px 24px rgba(26,75,196,.4);
}
.login-brand h1 { margin: 6px 0 2px; font-size: 24px; }
.login-brand p { margin: 0; }
.login-hint { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); text-align: center; }
.login-hint p { margin: 3px 0; }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field span { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field input, .field select {
  border: 1px solid var(--line); background: var(--panel); border-radius: 10px;
  padding: 11px 12px; font-size: 14px; font-family: inherit; outline: none;
  transition: border .15s, box-shadow .15s; color: var(--ink); width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field select { appearance: none; }
.field textarea {
  border: 1px solid var(--line); background: var(--panel); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; font-family: inherit; outline: none; color: var(--ink);
  resize: vertical; min-height: 44px;
}
.field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-error { background: #fee2e2; color: #b91c1c; border-radius: 10px; padding: 10px 12px; font-size: 13px; margin: 8px 0; font-weight: 500; }

/* ---------- App layout ---------- */
.app { display: flex; min-height: 100dvh; }
.sidebar {
  width: 236px;
  background: linear-gradient(180deg, rgba(13,27,58,.62), rgba(20,39,80,.5));
  color: #cdd0e4; display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh;
  padding: 18px 14px; flex-shrink: 0;
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  backdrop-filter: blur(22px) saturate(150%);
  border-right: 1px solid rgba(255,255,255,.1);
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; color: #fff; }
.sidebar-brand .logo-badge { width: 40px; height: 40px; border-radius: 11px; margin: 0; }
.brand-name { font-weight: 700; font-size: 16px; }
.nav { flex: 1; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; min-height: 0; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  background: none; border: none; color: #b9bdd6; padding: 11px 12px; border-radius: 10px;
  font-family: inherit; font-size: 14px; font-weight: 500; cursor: pointer; transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 6px 16px rgba(26,75,196,.4); }
.sidebar-foot { padding-top: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--primary-2)); color: #fff; font-weight: 700;
}
.user-meta { flex: 1; min-width: 0; }
.user-name { display: block; color: #fff; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; color: #8f94b4; font-size: 11px; }
.user-chip .icon-btn { color: #b9bdd6; }
.user-chip .icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 20px 28px 6px; position: sticky; top: 0; background: rgba(238,241,248,.5);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  border-bottom: 1px solid rgba(255,255,255,.55);
  z-index: 20;
}
.topbar-logout { display: none; }
.topbar > div:first-child { min-width: 0; flex: 1; }
.page-title { margin: 0; font-size: 22px; }
.page-sub { margin: 2px 0 0; overflow-wrap: anywhere; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.sync-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); background: var(--panel); border: 1px solid var(--line); padding: 5px 11px; border-radius: 999px; }
.sync-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(34,197,94,.2); }

.content { padding: 14px 28px 60px; }

.bottom-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  transform: translateZ(0);
  will-change: transform;
}

/* ---------- Cards & KPI ---------- */
.card {
  background: rgba(255,255,255,.58);
  border: 1px solid rgba(255,255,255,.65);
  border-radius: var(--radius);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.7);
  padding: 18px; margin-bottom: 18px;
  min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h3 { margin: 0; font-size: 15px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-card {
  background: rgba(255,255,255,.55);
  border: 1px solid rgba(255,255,255,.65);
  border-radius: var(--radius);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  padding: 16px; box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.7);
}
.kpi-icon { width: 40px; height: 40px; border-radius: 11px; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.kpi-num { font-size: 28px; font-weight: 800; line-height: 1; }
.kpi-label { margin-top: 6px; font-size: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.empty { text-align: center; padding: 24px 10px; }
.empty-card { display: flex; align-items: center; justify-content: center; min-height: 120px; }
.empty-card p { margin: 0; color: var(--ink-2); }

/* ---------- Stock bars ---------- */
.stock-bars { display: flex; flex-direction: column; gap: 14px; }
.stock-bar-row { display: flex; flex-direction: column; gap: 6px; }
.stock-bar-label { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.stock-bar-label b { margin-left: auto; }
.stock-bar-stats { display: flex; gap: 12px; font-size: 12px; }
.stock-bar-stats .stat { display: inline-flex; align-items: baseline; gap: 5px; }
.stock-bar-stats .stat i { font-style: normal; color: var(--ink-2); }
.stock-bar-stats .stat b { color: var(--ink); }
.stock-bar-stats .stat.stat-free { margin-left: auto; }
.stock-bar-stats .stat.stat-free b { color: #16a34a; }
.stock-bar { display: flex; height: 10px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.stock-bar-fill { height: 100%; border-radius: 999px; transition: width .5s ease; }
.stock-bar-res { height: 100%; background: var(--danger); opacity: .75; }

.res-row { padding: 10px 2px; border-bottom: 1px solid var(--line); }
.res-row:last-child { border-bottom: none; }
.res-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.res-sub { font-size: 12px; margin-top: 3px; }
.expiring-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--line); gap: 10px; }
.expiring-row:last-child { border-bottom: none; }
.countdown { font-size: 12px; font-weight: 700; color: var(--danger); white-space: nowrap; }

/* ---------- Tree ---------- */
.tree-toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.tree-toolbar .muted { margin-left: auto; }
.tree-search {
  position: relative; display: inline-flex; align-items: center; min-width: 250px; flex: 1 1 260px;
  max-width: 420px; color: var(--ink-2);
}
.tree-search > svg { position: absolute; left: 12px; pointer-events: none; }
.tree-search input {
  width: 100%; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 10px; padding: 9px 36px 9px 38px; font-size: 14px; font-family: inherit;
  outline: none; transition: border .15s, box-shadow .15s;
}
.tree-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.tree-search input::placeholder { color: var(--ink-3, #9aa0bb); }
.tree-search-clear {
  position: absolute; right: 6px; background: none; border: none; cursor: pointer;
  color: var(--ink-2); font-size: 14px; line-height: 1; padding: 4px 6px; border-radius: 6px;
}
.tree-search-clear:hover { background: var(--panel-2); color: var(--ink); }
.tree-results { display: flex; flex-direction: column; }
.tree-results .product-row:first-child { border-top: none; }
.tree-header {
  display: grid; grid-template-columns: minmax(200px, 1.1fr) minmax(320px, 2fr); gap: 10px;
  align-items: center; padding: 6px 12px; color: var(--ink-2); font-size: 11px; font-weight: 700;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px 12px 0 0;
}
.th-type { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tree-node { border: 1px solid var(--line); background: var(--panel); }
.tree-node.line { border-radius: 12px; margin-bottom: 10px; overflow: hidden; box-shadow: var(--shadow); }
.node-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; }
.tree-node.type > .node-head { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }
.tree-node.type > .node-head .node-count { color: rgba(255,255,255,.85); }
.tree-node.type > .node-head .chev { color: rgba(255,255,255,.9); }
.tree-node.line > .node-head { background: linear-gradient(135deg, #f4f5ff, #eef2ff); }
.tree-node.execution > .node-head { background: var(--panel-2); }
.tree-node.model > .node-head { background: #fff; box-shadow: inset 0 1px 0 var(--line); }
.tree-node.model > .node-head .node-title { color: var(--primary); }
.chev { background: none; border: none; color: var(--ink-2); cursor: pointer; display: inline-flex; transition: transform .2s; padding: 0; transform: rotate(0deg); flex-shrink: 0; }
.tree-node:not(.collapsed) .chev { transform: rotate(90deg); }
.tree-node.collapsed .chev { transform: rotate(0deg); }
.node-title { font-weight: 700; min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.node-count { font-size: 11px; margin-left: auto; white-space: nowrap; }
.node-children { display: none; }
.node-children.open { display: block; }
/* Иерархия дерева: каждая следующая ветвь сдвигается вправо и отделяется линией */
.tree-node > .node-children {
  padding-left: 18px;
  border-left: 1px solid var(--line);
  margin-left: 14px;
}

.product-row {
  display: grid; grid-template-columns: minmax(200px, 1.1fr) minmax(320px, 2fr); gap: 10px;
  align-items: center; padding: 7px 12px; border-top: 1px solid var(--line);
}
.product-row:hover { background: var(--panel-2); }
.product-row.selected { background: var(--primary-soft); }
.p-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.check { position: relative; display: inline-flex; cursor: pointer; flex-shrink: 0; }
.check input { position: absolute; opacity: 0; cursor: pointer; }
.checkmark { width: 18px; height: 18px; border: 2px solid #c7cbde; border-radius: 6px; display: inline-block; transition: all .15s; }
.check input:checked + .checkmark { background: var(--primary); border-color: var(--primary); box-shadow: inset 0 0 0 3px #fff; }
.p-name { min-width: 0; }
.p-name b { display: block; overflow-wrap: anywhere; font-size: 13px; }
.sku { color: var(--ink-2); font-size: 11px; }
.p-desc { color: var(--ink-2); font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; display: block; }
.p-base { color: var(--primary); font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; display: block; }
.p-base b { font-weight: 600; }
.total-free {
  display: inline-block; margin-top: 2px; padding: 1px 7px;
  font-size: 10px; font-weight: 700; color: var(--primary);
  background: var(--primary-soft); border: 1px solid var(--line);
  border-radius: 999px; white-space: nowrap;
}
.total-free.low { color: var(--danger); background: rgba(239, 68, 68, .12); }
.p-stock { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; min-width: 0; }
.td-qty .stock-label { color: var(--primary); }
.detail-allocs { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.td-stock {
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
  border: 1px solid var(--line); border-radius: 9px; padding: 6px 8px; background: var(--panel);
}
.stock-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.stock-label { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: var(--ink-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swatch { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.avail { font-size: 13px; font-weight: 800; color: var(--primary); white-space: nowrap; flex-shrink: 0; }
.avail.low { color: var(--danger); }
.avail-res { font-size: 11px; font-weight: 700; color: #ef4444; white-space: nowrap; flex-shrink: 0; }
.avail-res.is-zero { color: var(--ink-3); font-weight: 600; opacity: .7; }
.meter {
  display: flex; height: 6px; border-radius: 999px; overflow: hidden;
  background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line);
}
.meter > div { height: 100%; transition: width .3s ease; }
.meter-avail { opacity: .8; }
.meter-reserved { background: var(--danger); }
.stock-line { display: flex; }
.stock-cell { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); flex-shrink: 0; }
.stock-cell button { width: 26px; height: 26px; border: none; background: var(--panel-2); cursor: pointer; font-size: 15px; color: var(--ink); flex-shrink: 0; }
.stock-cell button:hover { background: #e6e9f4; }
.stock-cell input { width: 40px; height: 26px; border: none; text-align: center; font-family: inherit; font-size: 13px; outline: none; -moz-appearance: textfield; }
.stock-cell input::-webkit-outer-spin-button, .stock-cell input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.used-ind { font-size: 10px; color: var(--primary); font-weight: 700; }
.stock-input { margin-top: 2px; width: 48px; border: 1px dashed var(--line); border-radius: 6px; padding: 2px 4px; font-size: 10px; color: var(--ink-2); background: var(--panel-2); outline: none; }
.stock-input:focus { border-color: var(--primary); color: var(--ink); }
.stock-move { margin-top: 2px; width: 22px; height: 18px; line-height: 1; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); color: var(--primary); cursor: pointer; font-size: 12px; padding: 0; }
.stock-move:hover:not(:disabled) { border-color: var(--primary); background: var(--primary); color: #fff; }
.stock-move:disabled { opacity: .4; cursor: not-allowed; }
.stock-move-box { display: inline-flex; gap: 3px; align-items: center; margin-left: 4px; }
.stock-move-qty { width: 34px; border: 1px dashed var(--line); border-radius: 6px; padding: 2px 3px; font-size: 10px; color: var(--ink-2); background: var(--panel-2); outline: none; text-align: center; }
.stock-move-qty:focus { border-color: var(--primary); color: var(--ink); }

/* ---------- Tables (shared shell) ---------- */
.table { overflow-x: auto; width: 100%; max-width: 100%; }
.thead, .trow { display: grid; align-items: center; gap: 12px; padding: 11px 6px; }
.thead { color: var(--ink-2); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); }
.trow { border-bottom: 1px solid var(--line); font-size: 13px; }
.trow:last-child { border-bottom: none; }
.trow:hover { background: var(--panel-2); }
.t-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.warn-t { color: var(--danger); font-weight: 600; }
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

/* Reservations table — 7 columns */
.tbl-res .thead, .tbl-res .trow { grid-template-columns: 120px minmax(0,1.4fr) 60px minmax(0,1.2fr) 110px 100px 170px; }

/* Admin users table — 5 columns */
.tbl-users .thead, .tbl-users .trow { grid-template-columns: minmax(0,1.3fr) minmax(0,1.1fr) 120px 110px minmax(0,1fr); }

/* Заявки на согласование — 6 columns */
.tbl-req .thead, .tbl-req .trow { grid-template-columns: minmax(0,1.2fr) minmax(0,1fr) 150px minmax(0,1.6fr) minmax(0,0.9fr) 190px; }

/* DB (products) table — 7 columns (checkbox + данные) */
.tbl-db .thead, .tbl-db .trow { grid-template-columns: 32px minmax(0,1.4fr) minmax(0,1fr) 74px 74px 74px 150px; align-items: center; }
.tbl-db .tdb-check { display: flex; align-items: center; justify-content: center; }
.tbl-db .tdb-check input, .tbl-db .db-selall { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.tbl-db .trow.sel { background: var(--primary-soft); }
.tbl-db .tdb-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tbl-db .tdb-name b { overflow-wrap: anywhere; }
.tbl-db .tdb-num { white-space: nowrap; }
.db-bulkbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; padding: 8px 12px; border-radius: 10px; background: var(--primary-soft); border: 1px solid var(--line); font-size: 13px; }
.db-bulkbar b { color: var(--primary); }

/* ---------- Admin ---------- */
.line-stats { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.line-stat { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--panel-2); border-radius: 10px; padding: 10px 12px; flex-wrap: wrap; }
.add-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.import-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 4px; }
.import-row input[type="file"] { font-size: 13px; color: var(--ink-2); }
.import-mode { max-width: 320px; }
.import-mode select { cursor: pointer; }
.import-result { margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--primary); }
.import-result.warn { color: #b45309; }
.import-result.err { color: var(--danger); }
.import-result.ok { color: #16a34a; }
.add-form input {
  border: 1px solid var(--line); background: var(--panel); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; font-family: inherit; outline: none; color: var(--ink);
}
.add-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.add-form .btn { grid-column: 1 / -1; }
.check-line { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 14px; }

/* ---------- Modal ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(16,18,30,.5); backdrop-filter: blur(3px); }
.modal {
  position: relative; border-radius: 18px; width: 100%; max-width: 520px; max-height: 92dvh;
  display: flex; flex-direction: column;
  background: rgba(255,255,255,.72);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  backdrop-filter: blur(22px) saturate(170%);
  border: 1px solid rgba(255,255,255,.7);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,.7);
}
.modal.lg { max-width: 600px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 10px; padding: 14px 20px; border-top: 1px solid var(--line); }
.modal-foot .btn { margin: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cart-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; max-height: 200px; overflow-y: auto; }
.cart-line { display: flex; align-items: center; gap: 10px; background: var(--panel-2); border-radius: 10px; padding: 9px 12px; font-size: 13px; }
.cart-line > span:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.cart-qty { white-space: nowrap; flex-shrink: 0; }

/* ---------- Toast ---------- */
.toast-root { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast { background: rgba(22,32,58,.88); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 13px; opacity: 0; transform: translateX(20px); transition: all .25s ease; max-width: 320px; -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.toast.show { opacity: 1; transform: none; }
.toast-success { background: var(--success); }
.toast-warn { background: var(--warn); }
.toast-danger { background: var(--danger); }

/* ---------- Cart FAB ---------- */
.cart-fab {
  position: fixed; right: 20px; bottom: 84px; z-index: 40; width: 58px; height: 58px; border-radius: 50%;
  border: none; cursor: pointer; color: #fff; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--accent)); box-shadow: 0 10px 26px rgba(26,75,196,.5);
}
.fab-badge {
  position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 5px;
}

/* ---------- Reservation detail card ---------- */
.trow[data-id] { cursor: pointer; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.detail-cell { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.detail-cell > span:not(.badge) { font-size: 11px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .03em; }
.detail-cell > b { font-size: 14px; overflow-wrap: anywhere; }
.detail-sub { margin: 0 0 10px; font-size: 13px; color: var(--ink-2); font-weight: 700; }
.detail-items { display: flex; flex-direction: column; gap: 8px; }
.detail-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; flex-wrap: wrap; }
.detail-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.detail-name b { overflow-wrap: anywhere; }
.detail-qty { white-space: nowrap; flex-shrink: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .sidebar { display: none; }
  .topbar-logout { display: inline-flex; }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    background: rgba(255,255,255,.68);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    backdrop-filter: blur(18px) saturate(160%);
    border-top: 1px solid rgba(255,255,255,.6);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    transform: translateZ(0);
    will-change: transform;
  }
  .bnav-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: none; color: var(--ink-2); font-size: 11px; cursor: pointer; padding: 6px 2px; border-radius: 10px; font-family: inherit; font-weight: 600; }
  .bnav-item.active { color: var(--primary); background: var(--primary-soft); }
  .content { padding: 12px 14px 90px; }
  .topbar { padding: 14px 14px 6px; }
  .tree-toolbar .muted { margin-left: 0; width: 100%; }
  .tree-search { max-width: none; flex: 1 1 100%; order: 3; }
  .tree-header, .product-row { grid-template-columns: 1fr; }
  .th-type { grid-template-columns: repeat(2, 1fr); justify-items: stretch; gap: 8px; }
  .p-stock { grid-template-columns: repeat(2, 1fr); }

  /* Reservations: drop "Создал", actions to own row */
  .tbl-res .thead, .tbl-res .trow { grid-template-columns: 92px minmax(0,1.2fr) 46px minmax(0,1fr) 84px 96px; }
  .tbl-res .thead span:nth-child(6), .tbl-res .trow > span:nth-child(6) { display: none; }
  .tbl-res .t-actions { grid-column: 1 / -1; }

  /* Users: actions to own row */
  .tbl-users .thead, .tbl-users .trow { grid-template-columns: minmax(0,1.3fr) minmax(0,1.1fr) 110px 96px; }
  .tbl-users .t-actions { grid-column: 1 / -1; }

  /* DB: compact columns, actions to own row */
  .tbl-db .thead, .tbl-db .trow { grid-template-columns: 32px minmax(0,1.4fr) minmax(0,1fr) 64px 64px 64px; }
  .tbl-db .t-actions { grid-column: 1 / -1; }

  .field-row { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .p-stock { grid-template-columns: 1fr; }
  .th-type { grid-template-columns: 1fr; justify-items: start; gap: 6px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .tree-node > .node-children { padding-left: 8px; margin-left: 6px; }

  /* Мобильные таблицы -> карточный вид (строки складываются в столбик) */
  .table .thead { display: none; }
  .table .trow {
    grid-template-columns: 1fr;
    gap: 5px 0;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--panel);
    margin-bottom: 8px;
  }
  .table .trow > span { min-width: 0; overflow-wrap: anywhere; }
  .table .trow > span[data-label]:not([data-label=""])::before {
    content: attr(data-label);
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-2);
    margin-bottom: 1px;
  }
  .table .trow > .t-actions { grid-column: auto; justify-content: flex-start; margin-top: 6px; }
  .tbl-res .trow > span:nth-child(6) { display: block; } /* вернуть «Создал» в карточке */
  .tbl-db .tdb-check { order: -1; margin-bottom: 4px; }
}