:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #eef1f6;
  --border: #e3e7ef;
  --border-strong: #cfd5e1;
  --text: #1b2232;
  --text-2: #4a5468;
  --muted: #7a8396;
  --primary: #3655f5;
  --primary-hover: #2944d8;
  --primary-weak: #eceffe;
  --success: #15924a;
  --success-weak: #e6f6ec;
  --warning: #c26a00;
  --warning-weak: #fff4e0;
  --danger: #d42b2b;
  --danger-weak: #fdeceb;
  --info: #0b7f9c;
  --info-weak: #e3f5f9;
  --violet: #7040e0;
  --violet-weak: #f1ebfe;
  --side-bg: #121826;
  --side-text: #b9c1d3;
  --side-muted: #6b7489;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(18, 24, 38, .05), 0 1px 1px rgba(18, 24, 38, .03);
  --shadow-lg: 0 18px 50px rgba(18, 24, 38, .18);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 13px/1.55 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.t2 { color: var(--text-2); }
.small { font-size: 12px; }
.xs { font-size: 11px; }
.bold { font-weight: 600; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.neg { color: var(--danger) !important; font-weight: 600; }
.pos { color: var(--success); }
.warn-t { color: var(--warning); }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 228px; flex: 0 0 228px; background: var(--side-bg); color: var(--side-text); display: flex; flex-direction: column; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; }
.brand-logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #4f6bff, #8a5cf6); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.brand-name { font-weight: 600; font-size: 14px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--side-muted); }
.nav-group { padding: 6px 10px 4px; }
.nav-label { font-size: 11px; color: var(--side-muted); padding: 10px 8px 6px; letter-spacing: .04em; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--side-text); cursor: pointer; font-size: 13px; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item svg { width: 16px; height: 16px; flex: 0 0 16px; opacity: .9; }
.nav-code { margin-left: auto; font-size: 10px; color: var(--side-muted); font-family: var(--mono); }
.nav-item.active .nav-code { color: rgba(255,255,255,.75); }
.nav-dot { margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; display: grid; place-items: center; }
.side-foot { margin-top: auto; padding: 14px 18px; font-size: 11px; color: var(--side-muted); border-top: 1px solid rgba(255,255,255,.06); }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; flex: 0 0 56px; display: flex; align-items: center; gap: 14px; padding: 0 22px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar h1 { font-size: 16px; }
.topbar .crumb { color: var(--muted); font-size: 12px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.menu-btn { display: none; }
.search { display: flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 5px 10px; width: 260px; color: var(--muted); }
.search input { border: 0; outline: 0; background: transparent; width: 100%; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--violet-weak); color: var(--violet); display: grid; place-items: center; font-weight: 600; }
.user-meta { line-height: 1.2; }
.user-meta .xs { color: var(--muted); }

#view { flex: 1; overflow-y: auto; }
.page { padding: 20px 22px 40px; max-width: 1480px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 18px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; max-width: 820px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Alert bar ---------- */
.alertbar { display: flex; align-items: center; gap: 12px; padding: 9px 22px; background: #fff7d6; border-bottom: 1px solid #f0dc8a; color: #6b5200; font-size: 13px; flex-wrap: wrap; }
.alertbar b { color: #4d3b00; }
.alertbar .btn { padding: 4px 10px; }

/* ---------- Cards / grid ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-h h3 { font-size: 14px; }
.card-h .sub { color: var(--muted); font-size: 12px; font-weight: 400; margin-left: 6px; }
.card-b { padding: 14px 16px; }
.card-b.flush { padding: 0; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g-side { grid-template-columns: 340px minmax(0, 1fr); }
.g-side-r { grid-template-columns: minmax(0, 1fr) 340px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.nowrap { flex-wrap: nowrap; }
.mt { margin-top: 14px; }
.mt-s { margin-top: 8px; }
.mb { margin-bottom: 14px; }
.sep { height: 1px; background: var(--border); margin: 12px 0; }

/* ---------- KPI ---------- */
.kpi { padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 22px; font-weight: 650; margin-top: 4px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 12px; margin-top: 2px; }
.kpi .delta.up { color: var(--success); }
.kpi .delta.down { color: var(--danger); }
.kpi.clickable { cursor: pointer; }
.kpi.clickable:hover { border-color: var(--primary); }
.kpi.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-weak); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; white-space: nowrap; font-size: 13px; line-height: 1.4; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(.94); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--primary); padding: 4px 6px; }
.btn.ghost:hover { background: var(--primary-weak); }
.btn.ghost.danger-t { color: var(--danger); }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.btn.lg { padding: 10px 18px; font-size: 14px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 20px; line-height: 1; color: var(--muted); padding: 2px 6px; border-radius: 6px; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* ---------- Badges / chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; line-height: 18px; white-space: nowrap; border: 1px solid transparent; }
.b-gray { background: var(--surface-3); color: var(--text-2); }
.b-blue { background: var(--primary-weak); color: var(--primary); }
.b-green { background: var(--success-weak); color: var(--success); }
.b-amber { background: var(--warning-weak); color: var(--warning); }
.b-red { background: var(--danger-weak); color: var(--danger); }
.b-cyan { background: var(--info-weak); color: var(--info); }
.b-violet { background: var(--violet-weak); color: var(--violet); }
.b-dark { background: #1b2232; color: #fff; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); font-size: 12px; border: 1px solid var(--border); }
.chip.on { background: var(--primary-weak); color: var(--primary); border-color: #c9d2fd; }
.chip.click { cursor: pointer; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.green { background: var(--success); } .dot.amber { background: #e59a1a; } .dot.red { background: var(--danger); } .dot.blue { background: var(--primary); }
.pulse { animation: pulse 1.4s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- Tabs / segmented ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 9px 14px; cursor: pointer; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-count { background: var(--surface-3); color: var(--text-2); border-radius: 10px; padding: 0 6px; font-size: 11px; font-weight: 500; }
.tab.active .tab-count { background: var(--primary-weak); color: var(--primary); }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 12px; border-radius: 6px; cursor: pointer; color: var(--text-2); font-size: 12.5px; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { text-align: left; font-weight: 500; color: var(--muted); background: var(--surface-2); padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #fafbfe; }
.tbl tr.row-red td { background: #fff6f6; }
.tbl tr.row-amber td { background: #fffbf2; }
.tbl tr.row-dim td { color: var(--muted); }
.tbl tr.row-sel td { background: var(--primary-weak); }
.tbl tr.clickable { cursor: pointer; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl td.expand { background: var(--surface-2) !important; padding: 12px 16px; }
.tbl input.cell { width: 72px; padding: 3px 6px; }
.tbl input.cell.w48 { width: 48px; }
.empty { padding: 36px; text-align: center; color: var(--muted); }

/* ---------- Forms ---------- */
.input, select.input, textarea.input { width: 100%; padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); outline: none; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-weak); }
.input.err { border-color: var(--danger); background: #fffafa; }
textarea.input { resize: vertical; min-height: 96px; font-family: var(--mono); font-size: 12px; }
.input.inline { width: auto; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label, .lbl { font-size: 12px; color: var(--text-2); font-weight: 500; }
.field .hint { font-size: 11.5px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.inline-field { display: inline-flex; align-items: center; gap: 6px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.check input { accent-color: var(--primary); width: 14px; height: 14px; }
.switch { position: relative; width: 32px; height: 18px; display: inline-block; flex: 0 0 32px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 18px; cursor: pointer; transition: .15s; }
.switch span::after { content: ""; position: absolute; width: 14px; height: 14px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(14px); }

/* ---------- Progress / pipeline ---------- */
.progress { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; min-width: 80px; }
.progress > i { display: block; height: 100%; background: var(--primary); border-radius: 3px; transition: width .4s; }
.progress.green > i { background: var(--success); }
.progress.amber > i { background: #e59a1a; }
.progress.red > i { background: var(--danger); }
.pipe { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pipe .st { font-size: 11px; padding: 1px 7px; border-radius: 4px; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.pipe .st.done { background: var(--success-weak); color: var(--success); }
.pipe .st.run { background: var(--primary-weak); color: var(--primary); }
.pipe .st.fail { background: var(--danger-weak); color: var(--danger); }
.pipe .arrow { color: var(--border-strong); font-size: 10px; }
.steps { display: flex; gap: 0; align-items: center; }
.steps .s { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.steps .s::after { content: ""; width: 14px; height: 1px; background: var(--border-strong); margin: 0 4px; }
.steps .s:last-child::after { display: none; }
.steps .s.done { color: var(--success); }
.steps .s.cur { color: var(--primary); font-weight: 600; }

/* ---------- Thumbs ---------- */
.thumb { width: 36px; height: 36px; border-radius: 7px; display: grid; place-items: center; font-size: 18px; flex: 0 0 36px; border: 1px solid rgba(0,0,0,.04); }
.thumb.lg { width: 64px; height: 64px; font-size: 32px; border-radius: 10px; flex-basis: 64px; }
.thumb.xl { width: 120px; height: 120px; font-size: 60px; border-radius: 14px; flex-basis: 120px; }
.thumb.sm { width: 26px; height: 26px; font-size: 13px; border-radius: 5px; flex-basis: 26px; }
.prod { display: flex; align-items: center; gap: 10px; min-width: 0; }
.prod .meta { min-width: 0; }
.prod .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.prod .sub { color: var(--muted); font-size: 11.5px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.tile { aspect-ratio: 1; border-radius: 8px; display: grid; place-items: center; font-size: 11px; color: rgba(0,0,0,.55); position: relative; overflow: hidden; border: 1px solid rgba(0,0,0,.05); }
.tile .tag { position: absolute; left: 4px; top: 4px; font-size: 10px; background: rgba(255,255,255,.85); padding: 0 5px; border-radius: 4px; }
.tile.excluded { opacity: .45; outline: 2px dashed var(--danger); outline-offset: -2px; }
.tile-strip { display: flex; gap: 4px; }
.tile-strip .tile { width: 34px; flex: 0 0 34px; border-radius: 5px; font-size: 10px; }

/* ---------- Flow strip ---------- */
.flow { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 8px; }
.flow-node { position: relative; padding: 12px 10px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; min-height: 104px; }
.flow-node:hover { border-color: var(--primary); background: var(--primary-weak); }
.flow-node .code { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.flow-node .nm { font-weight: 600; font-size: 12.5px; margin: 2px 0 6px; }
.flow-node .big { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.flow-node .lab { font-size: 11px; color: var(--muted); }
.flow-node .alarm { margin-top: 4px; font-size: 11px; color: var(--danger); }
.flow-node:not(:last-child)::after { content: "›"; position: absolute; right: -8px; top: 40%; color: var(--border-strong); font-size: 16px; }

/* ---------- Bars ---------- */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 90px; align-items: center; gap: 10px; font-size: 12.5px; }
.bar-track { height: 10px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.bar-track > i { display: block; height: 100%; border-radius: 5px; background: var(--primary); }
.stack-bar { display: flex; height: 22px; border-radius: 6px; overflow: hidden; }
.stack-bar > i { display: grid; place-items: center; color: #fff; font-size: 11px; font-style: normal; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart text { font-size: 10px; fill: var(--muted); }

/* ---------- Key-value ---------- */
.kv { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 7px 12px; font-size: 12.5px; }
.kv > div:nth-child(odd) { color: var(--muted); }
.note { background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 8px; padding: 9px 12px; font-size: 12px; color: var(--text-2); }
.note.blue { background: var(--primary-weak); border-color: #c9d2fd; color: #2a3d9e; }
.note.amber { background: var(--warning-weak); border-color: #f1d29a; color: #7a4700; }
.note.red { background: var(--danger-weak); border-color: #f3b9b6; color: #8f1d1d; }
.note.green { background: var(--success-weak); border-color: #a9dfbd; color: #0f6a35; }
.formula { font-family: var(--mono); font-size: 12px; background: #151b2b; color: #dfe6ff; padding: 10px 14px; border-radius: 8px; line-height: 1.7; overflow-x: auto; }
.formula .k { color: #9fb3ff; }

/* ---------- List items ---------- */
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.li:last-child { border-bottom: 0; }
.li:hover { background: var(--surface-2); }
.li.active { background: var(--primary-weak); box-shadow: inset 3px 0 0 var(--primary); }
.li .grow { flex: 1; min-width: 0; }
.todo { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.todo:hover { background: var(--surface-2); }
.todo:last-child { border-bottom: 0; }
.todo .ic { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; font-size: 13px; flex: 0 0 26px; }

/* ---------- Shop cards ---------- */
.shop-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface); display: flex; flex-direction: column; gap: 8px; }
.shop-card.ready { border-color: #a9dfbd; }
.shop-card.missing { border-color: #f1d29a; }
.shop-card .t { font-weight: 600; }
.price-big { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.strike { text-decoration: line-through; color: var(--muted); font-size: 12px; }

/* ---------- Scan desk ---------- */
.scan-box { display: flex; gap: 10px; }
.scan-input { flex: 1; font-size: 20px !important; padding: 12px 16px !important; font-family: var(--mono) !important; letter-spacing: .04em; }
.scan-result { border-radius: 12px; padding: 18px; border: 2px solid var(--border); background: var(--surface); }
.scan-result.ok { border-color: #8fd3a9; background: #f6fcf8; }
.scan-result.asn { border-color: #b5c3fb; background: #f7f8ff; }
.scan-result.miss { border-color: #f1d29a; background: #fffbf2; }
.big-spec { font-size: 26px; font-weight: 700; letter-spacing: .01em; }
.basket { font-size: 20px; font-weight: 700; color: #fff; background: #1b2232; border-radius: 10px; padding: 12px 16px; display: inline-flex; align-items: center; gap: 10px; }
.kill-screen { position: fixed; inset: 0; z-index: 90; background: rgba(190, 18, 18, .96); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; animation: flash .5s 3; }
.kill-screen h2 { font-size: 40px; margin: 10px 0; }
.kill-screen p { font-size: 18px; opacity: .92; max-width: 760px; }
.kill-screen .btn { font-size: 16px; padding: 12px 22px; }
@keyframes flash { 50% { background: rgba(120, 0, 0, .98); } }

/* ---------- Browser mock ---------- */
.browser { border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden; background: #fff; }
.browser-bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--surface-3); border-bottom: 1px solid var(--border); font-size: 12px; }
.browser-bar .url { flex: 1; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 3px 10px; color: var(--text-2); font-family: var(--mono); font-size: 11.5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.browser-view { height: 420px; display: grid; place-items: center; background: linear-gradient(180deg, #fff3f0, #fff); position: relative; }
.captcha { width: 320px; background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); padding: 16px; }
.captcha-img { height: 150px; border-radius: 8px; background: linear-gradient(135deg, #f9c58b, #e86b5d 60%, #8b3e8f); position: relative; overflow: hidden; }
.captcha-hole { position: absolute; top: 55px; width: 44px; height: 44px; border-radius: 8px; background: rgba(0,0,0,.35); box-shadow: inset 0 0 0 2px rgba(255,255,255,.7); }
.captcha-piece { position: absolute; top: 55px; left: 0; width: 44px; height: 44px; border-radius: 8px; background: linear-gradient(135deg, #f7b37a, #db6a5c); box-shadow: 0 0 0 2px #fff, 0 4px 10px rgba(0,0,0,.3); }
.slider { margin-top: 12px; height: 40px; border-radius: 20px; background: var(--surface-3); position: relative; user-select: none; touch-action: none; }
.slider .trail { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 20px; background: #ffe0d6; }
.slider .knob { position: absolute; top: 2px; left: 2px; width: 36px; height: 36px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25); display: grid; place-items: center; cursor: grab; color: #e0533c; font-weight: 700; }
.slider .txt { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; color: var(--muted); pointer-events: none; }

/* ---------- Overlay ---------- */
.ov-mask { position: fixed; inset: 0; background: rgba(15, 20, 32, .38); z-index: 50; animation: fade .15s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(var(--w, 760px), 100vw); background: var(--surface); z-index: 51; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: slide .18s ease-out; }
.modal { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(var(--w, 560px), calc(100vw - 32px)); max-height: calc(100vh - 48px); background: var(--surface); z-index: 51; display: flex; flex-direction: column; border-radius: 12px; box-shadow: var(--shadow-lg); animation: fade .15s; }
.ov-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.ov-head h3 { font-size: 15px; }
.ov-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
.ov-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

#toast-root { position: fixed; top: 66px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; max-width: 420px; background: #1b2232; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow-lg); font-size: 12.5px; animation: slide .2s ease-out; transition: opacity .3s, transform .3s; border-left: 4px solid var(--primary); }
.toast.t-success { border-left-color: #34c46e; }
.toast.t-warn { border-left-color: #f0a81f; }
.toast.t-error { border-left-color: #f05252; }
.toast.out { opacity: 0; transform: translateX(20px); }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .flow { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .flow-node::after { display: none; }
  .g5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-side, .g-side-r { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .app.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .menu-btn { display: inline-flex; }
  .search, .user-meta { display: none; }
  .topbar { padding: 0 16px; }
  .page { padding: 16px 16px 40px; }
  .alertbar { padding: 9px 16px; }
  .g2, .g3, .g4, .g5 { grid-template-columns: minmax(0, 1fr); }
  .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid, .form-grid.c3, .form-grid.c4 { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
  .bar-row { grid-template-columns: 72px minmax(0, 1fr) 70px; }
  .kill-screen h2 { font-size: 28px; }
}

/* ---------- Inbox ---------- */
.mail-btn { position: relative; display: inline-flex; padding: 6px; }
.mail-btn .nav-dot { position: absolute; top: -2px; right: -4px; margin: 0; }
.mail-grid { display: grid; grid-template-columns: 270px 360px minmax(0, 1fr); gap: 14px; align-items: start; }
.mail-list .list, .mail-read { max-height: calc(100vh - 230px); overflow-y: auto; }
.mail-item { align-items: flex-start; }
.mail-item.unread { background: #fbfcff; }
.code-box { text-align: center; padding: 18px; border-radius: 12px; background: var(--primary-weak); border: 1px solid #c9d2fd; color: var(--primary); }
.code-box.expired { background: var(--surface-3); border-color: var(--border); color: var(--muted); }
.code-digits { font-size: 40px !important; font-weight: 700; letter-spacing: .3em; margin: 6px 0 12px; }
.code-box.expired .code-digits { text-decoration: line-through; }
.mail-body { white-space: pre-wrap; font-size: 13px; line-height: 1.8; padding: 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
@media (max-width: 1200px) { .mail-grid { grid-template-columns: 240px minmax(0, 1fr); } .mail-read { grid-column: 1 / -1; max-height: none; } }
@media (max-width: 860px) { .mail-grid { grid-template-columns: minmax(0, 1fr); } .mail-list .list { max-height: 360px; } }

/* ---------- Connected pages ---------- */
.live-columns { grid-template-columns: 310px minmax(0, 1fr); align-items: start; }
.live-form { display: grid; gap: 10px; }
.live-form p, .live-feedback { margin: 0; }
.live-form fieldset { display: grid; gap: 12px; min-width: 0; border: 0; margin: 0; padding: 0; }
.live-form textarea { min-height: 215px; }
.form-grid.live-capture-fields { grid-template-columns: minmax(0, 1fr) minmax(85px, .55fr); }
.live-form [aria-invalid=true], .live-edit [aria-invalid=true] { border-color: var(--danger); }
.live-file { min-width: 0; max-width: 100%; }
.live-file::file-selector-button { font: inherit; color: var(--text); margin-right: 8px; cursor: pointer; }
.live-feedback { color: #305e44; background: var(--success-weak); border-radius: var(--radius-sm); padding: 8px 10px; overflow-wrap: anywhere; }
.live-feedback[data-error] { color: #962222; background: var(--danger-weak); }
.live-state { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.live-state [role="alert"] { color: #962222; overflow-wrap: anywhere; }
.live-table { overflow: auto; }
.live-table .tbl th, .live-table .tbl td { overflow-wrap: anywhere; }
.live-table .tbl th, .live-table .tbl td.num { white-space: normal; }
.live-table .tbl td.num { min-width: 65px; }
.live-table .tbl a:not(.btn):hover { text-decoration: underline; }
.live-title { overflow-wrap: anywhere; }
.live-title a { display: block; font-weight: 600; }
.live-title .mono { display: block; }
.live-links { display: flex; gap: 5px 9px; flex-wrap: wrap; }
.live-links a { white-space: nowrap; }
.live-tabs .tab { text-decoration: none; }
.live-tabs a:hover { color: var(--primary); }
.live-facts { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 18px; }
.live-facts div { min-width: 0; overflow-wrap: anywhere; }
.live-facts dt { margin-bottom: 3px; color: var(--muted); font-size: 12px; }
.live-facts dd { margin: 0; }
.live-facts a:hover { text-decoration: underline; }
.catalog-suite-history { border-top: 1px solid var(--border); }
.catalog-suite-history > summary { padding: 12px 16px; color: var(--primary); cursor: pointer; }
.catalog-suite-history fieldset { margin: 0; padding: 0; min-width: 0; border: 0; align-items: end; }
.catalog-suite-history .check { min-height: 34px; }
.catalog-suite-feedback { margin: 0 16px 10px; }
.catalog-suite-more { margin: 12px 16px; }
.live-footer { border-top: 1px solid var(--border); }
.live-filters .field { flex: 0 1 145px; }
.live-filters .live-query { flex: 1 1 215px; }
.live-edit { display: flex; flex-wrap: wrap; gap: 6px; min-width: 208px; }
.live-edit .input { width: 85px; padding: 4px 7px; }
.live-edit .live-feedback { width: 100%; }
.live-table input[type=checkbox] { cursor: pointer; accent-color: var(--primary); }
@media (max-width: 1200px) {
  .live-columns { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .app.nav-open .nav-dismiss { display: block; position: fixed; border: 0; inset: 0; z-index: 59; background: #12182655; }
  .app:not(.nav-open) .sidebar { visibility: hidden; }
  .live-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .live-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .live-kpis .kpi { padding: 10px 8px; }
}
@media (max-width: 600px) {
  .live-table .tbl, .live-table tbody, .live-table tr { display: block; }
  .live-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .live-table .tbl tbody tr { padding: 9px 12px; border-bottom: 1px solid var(--border); }
  .live-table .tbl tbody tr:last-child { border-bottom: 0; }
  .live-table .tbl td, .live-table .tbl td.num { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: 7px; border: 0; padding: 4px 0; text-align: left; }
  .live-table .tbl td::before { content: attr(data-label); color: var(--muted); }
  .live-edit { min-width: 0; }
  .live-edit .input { width: 100%; }
  .live-form .input, .live-filters .input, .live-edit .input { font-size: 16px; }
}
