:root {
  --bg: #070a11;
  --bg-2: #0b1019;
  --card: rgba(17, 24, 37, 0.78);
  --card-solid: #111825;
  --line: rgba(148, 163, 184, 0.12);
  --line-2: rgba(148, 163, 184, 0.2);
  --text: #e6eaf2;
  --muted: #8a96ab;
  --faint: #5b667a;
  --accent: #5eead4;
  --accent-2: #6366f1;
  --safe: #34d399;
  --warning: #fbbf24;
  --critical: #fb923c;
  --emergency: #f43f5e;
  --binance: #f0b90b;
  --hyper: #50e3c2;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { background: var(--bg); }

body {
  font-family: Inter, ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(99, 102, 241, 0.16), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(94, 234, 212, 0.10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  transition: box-shadow 0.3s;
}

a:not(.btn), a:not(.btn):visited {
  color: var(--accent); text-decoration: underline; text-decoration-color: rgba(94, 234, 212, 0.4); text-underline-offset: 3px;
}
a:not(.btn):hover { color: #99f6e4; text-decoration-color: currentColor; }
a:not(.btn):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

body.flash-emergency { box-shadow: inset 0 0 0 3px var(--emergency), inset 0 0 120px rgba(244, 63, 94, 0.25); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  padding: 14px 28px;
  background: rgba(7, 10, 17, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 34px; height: 34px; flex-shrink: 0; filter: drop-shadow(0 0 12px rgba(94, 234, 212, 0.35)); }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: -0.02em; }
.brand-sub { font-size: 12px; color: var(--muted); white-space: nowrap; }

.pills { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--muted); background: rgba(148, 163, 184, 0.08); border: 1px solid var(--line);
  white-space: nowrap;
}
.pill-demo { color: #c7d2fe; background: rgba(99, 102, 241, 0.16); border-color: rgba(99, 102, 241, 0.4); }
.pill.live { color: var(--accent); border-color: rgba(94, 234, 212, 0.35); }
.pill.degraded { color: var(--warning); border-color: rgba(251, 191, 36, 0.35); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--emergency); }
.pill.connected .dot { background: var(--safe); box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6); animation: ping 2s infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); } 80%, 100% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); } }

.controls { display: flex; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 10px;
  font: inherit; font-size: 13.5px; font-weight: 650;
  border: 1px solid transparent; cursor: pointer; transition: transform 0.1s, background 0.2s, opacity 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; fill: currentColor; }
.btn-primary {
  color: #061015;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  box-shadow: 0 6px 24px -6px rgba(94, 234, 212, 0.55);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 8px 30px -4px rgba(94, 234, 212, 0.75); }
.btn-primary.running { background: linear-gradient(135deg, #334155, #1e293b); color: var(--text); box-shadow: none; }
.btn-ghost { color: var(--text); background: rgba(148, 163, 184, 0.08); border-color: var(--line-2); }
.btn-ghost:hover:not(:disabled) { background: rgba(148, 163, 184, 0.16); }

.progress { height: 2px; background: transparent; position: sticky; top: 67px; z-index: 19; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.4s ease; }

/* ---------- layout ---------- */
.layout { max-width: 1520px; margin: 0 auto; padding: 22px 28px 40px; display: grid; gap: 18px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 20px 40px -30px rgba(0, 0, 0, 0.8);
  min-width: 0;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px 12px; }
.card-title { font-weight: 700; font-size: 14.5px; letter-spacing: -0.01em; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.tag {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  padding: 3px 7px; border-radius: 6px; color: var(--muted);
  background: rgba(148, 163, 184, 0.12); border: 1px solid var(--line);
}
.tag-ro { color: var(--safe); border-color: rgba(52, 211, 153, 0.35); background: rgba(52, 211, 153, 0.08); }

/* ---------- banner ---------- */
.banner { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 22px; padding: 18px 22px; position: relative; overflow: hidden; }
.banner::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, var(--level-glow, transparent), transparent 45%); opacity: 0.5; pointer-events: none; transition: background 0.4s; }
.banner-level {
  position: relative;
  min-width: 128px; text-align: center; padding: 12px 16px; border-radius: 12px;
  font-weight: 800; font-size: 20px; letter-spacing: 0.06em;
  color: var(--level-color, var(--muted)); background: rgba(148, 163, 184, 0.06);
  border: 1px solid var(--level-color, var(--line-2));
  transition: color 0.3s, border-color 0.3s;
}
.banner-body, .banner-riskiest { position: relative; min-width: 0; }
.banner-label { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; display: flex; align-items: center; gap: 8px; }
.muse-glyph { color: #a5b4fc; }
.muse-mark { font-size: 10.5px; font-weight: 600; letter-spacing: 0.02em; color: #a5b4fc; opacity: 0.75; white-space: nowrap; }
.rec-line { font-size: 13px; font-weight: 600; line-height: 1.5; margin-top: 6px; overflow-wrap: anywhere; }
.rec-line .muse-mark { margin-left: 4px; }
.banner-headline { font-size: 19px; font-weight: 600; line-height: 1.35; margin-top: 6px; letter-spacing: -0.01em; }
.riskiest-chip { margin-top: 8px; font-family: var(--mono); font-size: 14px; font-weight: 700; padding: 8px 12px; border-radius: 10px; background: rgba(148, 163, 184, 0.08); border: 1px solid var(--line-2); white-space: nowrap; }

.lvl-safe, .lvl-low { --level-color: var(--safe); --level-glow: rgba(52, 211, 153, 0.18); }
.lvl-moderate { --level-color: var(--warning); --level-glow: rgba(251, 191, 36, 0.18); }
.lvl-high { --level-color: var(--critical); --level-glow: rgba(251, 146, 60, 0.22); }
.lvl-critical { --level-color: var(--emergency); --level-glow: rgba(244, 63, 94, 0.28); }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { padding: 14px 16px; }
.kpi-label { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.kpi-value { font-size: 24px; font-weight: 750; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; transition: color 0.3s; }
.kpi-sub { font-size: 12px; color: var(--faint); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos { color: var(--safe); }
.neg { color: var(--emergency); }

/* ---------- main row ---------- */
.row-main { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: 18px; }
.chart-card { display: flex; flex-direction: column; }
.chart-wrap { position: relative; height: 380px; padding: 0 14px; }
.chart-empty[hidden] { display: none; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; text-align: center; padding: 20px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 10px 18px 16px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.dashed { background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px) !important; height: 2px; }

.tabs { display: flex; gap: 4px; padding: 3px; border-radius: 10px; background: rgba(148, 163, 184, 0.08); border: 1px solid var(--line); flex-wrap: wrap; }
.tab { font: inherit; font-size: 12px; font-weight: 650; color: var(--muted); background: transparent; border: 0; padding: 6px 10px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); background: rgba(148, 163, 184, 0.16); }

.positions { padding: 0 12px 12px; display: grid; gap: 10px; }
.position {
  padding: 12px 14px; border-radius: 12px; background: rgba(148, 163, 184, 0.04); border: 1px solid var(--line);
  transition: border-color 0.3s, background 0.3s; cursor: pointer;
}
.position:hover { background: rgba(148, 163, 184, 0.08); }
.position.selected { border-color: var(--line-2); background: rgba(148, 163, 184, 0.08); }
.position.flash { animation: flash 1.2s ease; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 var(--flash, var(--warning)); } 100% { box-shadow: 0 0 0 10px transparent; } }
.pos-top { display: flex; align-items: center; gap: 8px; }
.pos-sym { font-weight: 750; font-size: 14.5px; letter-spacing: -0.01em; }
.venue { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 6px; letter-spacing: 0.03em; }
.venue-binance { color: var(--binance); background: rgba(240, 185, 11, 0.12); }
.venue-hyperliquid { color: var(--hyper); background: rgba(80, 227, 194, 0.12); }
.side { font-size: 10.5px; font-weight: 750; padding: 2px 7px; border-radius: 6px; }
.side-long { color: var(--safe); background: rgba(52, 211, 153, 0.12); }
.side-short { color: var(--emergency); background: rgba(244, 63, 94, 0.12); }
.lev { font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.pos-dist { margin-left: auto; font-family: var(--mono); font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; transition: color 0.3s; }
.pos-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 11.5px; color: var(--muted); font-family: var(--mono); }

.gauge { position: relative; height: 8px; margin-top: 10px; border-radius: 999px; background: rgba(148, 163, 184, 0.1); overflow: visible; }
.gauge-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; transition: width 0.5s ease, background 0.3s; }
.gauge-tick { position: absolute; top: -3px; bottom: -3px; width: 2px; border-radius: 1px; opacity: 0.8; }
.gauge-labels { position: relative; height: 14px; margin-top: 4px; font-size: 9.5px; color: var(--faint); font-family: var(--mono); }
.gauge-labels span { position: absolute; transform: translateX(-50%); }

.c-safe { color: var(--safe); }
.c-warning { color: var(--warning); }
.c-critical { color: var(--critical); }
.c-emergency { color: var(--emergency); }

/* ---------- bottom row ---------- */
.row-bottom { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.scroll { max-height: 420px; overflow-y: auto; padding: 0 16px 16px; scrollbar-width: thin; scrollbar-color: rgba(148, 163, 184, 0.25) transparent; }

.empty { display: grid; place-items: center; text-align: center; gap: 6px; padding: 36px 12px; color: var(--muted); font-size: 13px; }
.empty b { color: var(--text); font-weight: 650; }
.empty .glyph { font-size: 22px; opacity: 0.8; }

.tier-counts { display: flex; gap: 6px; }
.tc { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: rgba(148, 163, 184, 0.08); }
.tc i { width: 7px; height: 7px; border-radius: 50%; }
.tc-warning i { background: var(--warning); } .tc-critical i { background: var(--critical); } .tc-emergency i { background: var(--emergency); }

.timeline { list-style: none; position: relative; }
.tl-item { position: relative; padding: 10px 0 10px 26px; animation: slideIn 0.35s ease; }
.tl-item::before { content: ""; position: absolute; left: 7px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.tl-item:first-child::before { top: 18px; }
.tl-item:last-child::before { bottom: calc(100% - 18px); }
.tl-node { position: absolute; left: 1px; top: 12px; width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--card-solid); }
.tl-warning .tl-node { background: var(--warning); } .tl-critical .tl-node { background: var(--critical); }
.tl-emergency .tl-node { background: var(--emergency); box-shadow: 0 0 12px var(--emergency); }
.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lvl { font-size: 10px; font-weight: 800; letter-spacing: 0.06em; padding: 2px 7px; border-radius: 6px; }
.lvl-warning-b { color: var(--warning); background: rgba(251, 191, 36, 0.12); }
.lvl-critical-b { color: var(--critical); background: rgba(251, 146, 60, 0.14); }
.lvl-emergency-b { color: var(--emergency); background: rgba(244, 63, 94, 0.14); }
.tl-sym { font-weight: 700; font-size: 13.5px; }
.tl-time { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--faint); }
.tl-body { margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.tl-body b { color: var(--text); font-family: var(--mono); }
.chips { display: flex; gap: 5px; margin-top: 6px; }
.chip { font-size: 10.5px; font-weight: 650; padding: 2px 7px; border-radius: 999px; color: var(--muted); border: 1px solid var(--line-2); }
.chip-telegram { color: #7dd3fc; border-color: rgba(125, 211, 252, 0.35); }
.chip-web { color: #c4b5fd; border-color: rgba(196, 181, 253, 0.35); }

@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.advice { display: grid; gap: 10px; align-content: start; }
.adv { position: relative; padding: 12px 14px 12px 16px; border-radius: 12px; background: rgba(148, 163, 184, 0.05); border: 1px solid var(--line); animation: slideIn 0.35s ease; overflow: hidden; }
.adv::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--adv, var(--accent)); }
.adv-warning { --adv: var(--warning); } .adv-critical { --adv: var(--critical); } .adv-emergency { --adv: var(--emergency); }
.adv-head { display: flex; align-items: center; gap: 8px; }
.adv-sym { font-weight: 750; }
.adv-head .tag { margin-left: auto; }
.adv-summary { margin-top: 6px; font-size: 13px; font-weight: 650; }
.adv-text { margin-top: 4px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.adv-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.adv-act { padding: 8px 10px; border-radius: 9px; background: rgba(7, 10, 17, 0.5); border: 1px solid var(--line); }
.adv-act-label { font-size: 10.5px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 650; }
.adv-act-value { font-family: var(--mono); font-weight: 800; font-size: 15px; margin-top: 2px; }
.adv-act-sub { font-size: 11px; color: var(--muted); margin-top: 1px; font-family: var(--mono); }
.adv-foot { margin-top: 8px; font-size: 11px; color: var(--faint); }

.audit { font-family: var(--mono); font-size: 11.5px; }
.au { display: grid; grid-template-columns: 62px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); animation: slideIn 0.3s ease; }
.au:last-child { border-bottom: 0; }
.au-time { color: var(--faint); }
.au-event { font-weight: 700; color: var(--text); }
.au-event .src { font-weight: 600; color: var(--faint); margin-left: 6px; }
.au-detail { color: var(--muted); margin-top: 2px; word-break: break-word; font-family: Inter, ui-sans-serif, sans-serif; font-size: 12px; }
.ev-alert_warning { color: var(--warning); } .ev-alert_critical { color: var(--critical); } .ev-alert_emergency { color: var(--emergency); }
.ev-advice_generated { color: #a5b4fc; }

.foot { text-align: center; color: var(--faint); font-size: 12px; padding-top: 4px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 22px; bottom: 22px; display: grid; gap: 10px; z-index: 50; width: min(360px, calc(100vw - 44px)); }
.toast {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border-radius: 12px;
  background: rgba(17, 24, 37, 0.96); border: 1px solid var(--line-2);
  box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.8);
  animation: toastIn 0.35s cubic-bezier(.2, .9, .3, 1.2);
  border-left: 3px solid var(--t, var(--warning));
}
.toast.out { animation: toastOut 0.3s ease forwards; }
.toast-title { font-weight: 750; font-size: 13px; }
.toast-body { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

/* ---------- scope ribbon & account ---------- */
a.btn { text-decoration: none; }
[hidden] { display: none !important; }
.ribbon {
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  padding: 7px 16px; font-size: 12.5px; color: #e0e7ff;
  background: repeating-linear-gradient(135deg, rgba(99, 102, 241, 0.28) 0 14px, rgba(99, 102, 241, 0.18) 14px 28px);
  border-bottom: 1px solid rgba(99, 102, 241, 0.45);
}
.ribbon b { letter-spacing: 0.12em; font-size: 11.5px; padding: 2px 8px; border-radius: 6px; background: rgba(99, 102, 241, 0.55); color: #fff; }
.ribbon a, .ribbon a:visited { color: #fff; font-weight: 650; text-decoration-color: rgba(255, 255, 255, 0.5); }
.ribbon.private { background: rgba(94, 234, 212, 0.1); border-bottom-color: rgba(94, 234, 212, 0.35); color: #ccfbf1; }
.ribbon.private b { background: rgba(94, 234, 212, 0.25); color: #ecfeff; }
.pill-private { color: var(--accent); background: rgba(94, 234, 212, 0.1); border-color: rgba(94, 234, 212, 0.35); }

.account-grid { display: grid; grid-template-columns: 1fr 1.4fr 1.2fr; gap: 18px; padding: 0 18px 16px; }
.account-label { font-size: 11px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; }
.bindings { display: grid; gap: 8px; }
.binding { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); background: rgba(148, 163, 184, 0.05); font-size: 13px; }
.binding .hint { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.account-positions { display: grid; gap: 6px; }
.acct-pos { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 8px 11px; border-radius: 10px; background: rgba(148, 163, 184, 0.05); font-size: 13px; }
.acct-pos .d { font-family: var(--mono); font-weight: 700; }
.account-actions { max-height: 220px; }
.account .empty { padding: 14px 8px; }

/* ---------- login page ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(460px, 100%); padding: 28px; display: grid; gap: 18px; }
.login-card h1 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.login-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.login-card code { font-family: var(--mono); color: var(--accent); background: rgba(94, 234, 212, 0.08); padding: 1px 6px; border-radius: 6px; }
.login-steps { margin: 0; padding-left: 20px; color: var(--text); font-size: 14px; line-height: 1.7; }
.login-error { padding: 10px 12px; border-radius: 10px; font-size: 13px; color: #fecdd3; background: rgba(244, 63, 94, 0.12); border: 1px solid rgba(244, 63, 94, 0.35); }
.login-divider { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 12px; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.login-widget { min-height: 44px; display: grid; place-items: center; }
.login-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.login-top .brand-sub { white-space: normal; }
.login-notice { padding: 10px 12px; border-radius: 10px; font-size: 13px; color: #ccfbf1; background: rgba(94, 234, 212, 0.1); border: 1px solid rgba(94, 234, 212, 0.35); }
.login-error a, .login-notice a { color: inherit; }


/* ---------- true liquidation, funding, rescue ---------- */
.pos-detail { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 11px; color: var(--muted); font-family: var(--mono); flex-wrap: wrap; }
.pos-detail i { color: var(--faint); font-style: italic; }
.mode { font-size: 9.5px; font-weight: 800; letter-spacing: 0.05em; padding: 1px 6px; border-radius: 5px; font-family: Inter, ui-sans-serif, sans-serif; }
.mode-cross { color: #93c5fd; background: rgba(147, 197, 253, 0.12); }
.mode-isolated { color: #fcd34d; background: rgba(252, 211, 77, 0.1); }
.mode-funding { color: var(--funding); background: rgba(167, 139, 250, 0.13); font-family: var(--mono); }
.pos-actions { display: flex; justify-content: flex-end; margin-top: 6px; }
.mini-btn {
  font: inherit; font-size: 11.5px; font-weight: 650; color: var(--text); cursor: pointer;
  padding: 4px 9px; border-radius: 8px; background: rgba(148, 163, 184, 0.08); border: 1px solid var(--line-2);
}
.mini-btn:hover { background: rgba(148, 163, 184, 0.18); }

:root { --funding: #a78bfa; }
.tc-funding i { background: var(--funding); }
.tl-funding .tl-node { background: var(--funding); box-shadow: 0 0 10px var(--funding); }
.lvl-funding-b { color: var(--funding); background: rgba(167, 139, 250, 0.14); }
.ev-prefunding_warning, .ev-funding_settled { color: var(--funding); }
.chips .mini-btn { margin-left: auto; padding: 2px 8px; font-size: 10.5px; }

.adv-rescue { margin-top: 10px; padding: 8px 10px; border-radius: 9px; background: rgba(7, 10, 17, 0.5); border: 1px solid var(--line); display: grid; gap: 4px; }
.rm-row { display: grid; grid-template-columns: 1fr 64px 84px 14px; gap: 6px; font-size: 12px; font-family: var(--mono); color: var(--muted); }
.rm-row span:first-child { font-family: Inter, ui-sans-serif, sans-serif; color: var(--text); }
.rm-row.best { color: var(--safe); }
.rm-row .star { color: var(--safe); }
.adv-rescue .mini-btn { justify-self: start; margin-top: 4px; }

.row-rescue { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: 18px; }
.rescue-body { padding: 0 18px 16px; display: grid; gap: 12px; }
.rs-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rs-now { margin-left: auto; font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.rs-caveat { margin-top: 3px; font-size: 11.5px; color: var(--muted); font-style: italic; }
.rs-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.rs-opt { padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(148, 163, 184, 0.04); display: grid; gap: 8px; align-content: start; }
.rs-opt.best { border-color: rgba(52, 211, 153, 0.5); background: rgba(52, 211, 153, 0.06); box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.15) inset; }
.rs-opt.weak { opacity: 0.85; }
.rs-opt-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rs-kind { font-weight: 750; font-size: 13.5px; }
.tag-best { color: var(--safe); border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.1); }
.rs-title { font-size: 12px; color: var(--muted); min-height: 30px; }
.rs-liq { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rs-big { font-family: var(--mono); font-weight: 800; font-size: 15px; margin-top: 2px; }
.rs-costs { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; font-size: 12px; }
.rs-costs dt { color: var(--muted); }
.rs-costs dd { font-family: var(--mono); text-align: right; }
.rs-costs .total { color: var(--text); font-weight: 750; border-top: 1px dashed var(--line-2); padding-top: 3px; }
.rs-pc { list-style: none; display: grid; gap: 3px; font-size: 11.5px; }
.rs-pc li { padding-left: 14px; position: relative; color: var(--muted); }
.rs-pc li.pro::before { content: "+"; position: absolute; left: 0; color: var(--safe); font-weight: 800; }
.rs-pc li.con::before { content: "−"; position: absolute; left: 0; color: var(--emergency); font-weight: 800; }
.rs-notes { font-size: 11px; color: var(--faint); line-height: 1.45; }

.funding-card { display: flex; flex-direction: column; }
.wallets { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 16px 10px; }
.wallet { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(148, 163, 184, 0.05); font-size: 12px; }
.wallet b { font-family: var(--mono); }
.wallet-label { color: var(--muted); }
.funding { display: grid; gap: 8px; align-content: start; }
.fund-row { padding: 9px 11px; border-radius: 10px; background: rgba(148, 163, 184, 0.05); border: 1px solid var(--line); }
.fund-top { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.fund-rate { margin-left: auto; font-family: var(--mono); color: var(--funding); font-weight: 700; }
.fund-apr { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.fund-meta { margin-top: 4px; font-size: 12px; color: var(--muted); }
.fund-drift { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.fund-drift b { color: var(--text); }
.fund-drift i { color: var(--faint); }
.fund-ev-head { margin: 6px 0 0; }
.fund-ev { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; font-size: 11.5px; font-family: var(--mono); color: var(--muted); }
.fund-ev-sym { font-weight: 700; }
.acct-pos .mini-btn { padding: 2px 7px; }
.acct-pos { grid-template-columns: 1fr auto auto auto; }
.acct-fund { grid-column: 1 / -1; font-size: 11px; font-family: var(--mono); color: var(--muted); }

@media (max-width: 1280px) {
  .row-rescue { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .rs-grid { grid-template-columns: 1fr; }
  .rs-now { margin-left: 0; width: 100%; }
}

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row-bottom { grid-template-columns: 1fr 1fr; }
  .row-bottom > :last-child { grid-column: 1 / -1; }
}
@media (max-width: 1024px) {
  .row-main { grid-template-columns: 1fr; }
  .account-grid { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
  .pills { order: 3; width: 100%; margin-left: 0; }
  .progress { top: 0; position: relative; }
}
@media (max-width: 720px) {
  .layout { padding: 14px; gap: 14px; }
  .topbar { padding: 12px 14px; gap: 12px; }
  .brand-sub { display: none; }
  .controls { margin-left: auto; }
  .btn { padding: 0 12px; }
  .banner { grid-template-columns: 1fr; gap: 12px; }
  .banner-level { justify-self: start; font-size: 16px; min-width: 0; }
  .banner-headline { font-size: 16px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-value { font-size: 19px; }
  .row-bottom { grid-template-columns: 1fr; }
  .chart-wrap { height: 280px; }
  .chart-card .card-head { flex-direction: column; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; }
  .adv-actions { grid-template-columns: 1fr; }
}

/* ---------------- wick stress, stops, ADL, wake-up ---------------- */

.faint { color: var(--faint); }
.c-muted { color: var(--muted); }
.tc-stop i { background: var(--emergency); }
.tc-adl i { background: #facc15; }
.lvl-stop-b { color: var(--emergency); background: rgba(244, 63, 94, 0.14); }
.lvl-adl-b { color: #facc15; background: rgba(250, 204, 21, 0.12); }
.lvl-esc-b { color: var(--critical); background: rgba(251, 146, 60, 0.14); }
.lvl-esc-final { color: #fff; background: var(--emergency); }
.lvl-ack-b { color: var(--safe); background: rgba(52, 211, 153, 0.12); }
.tl-stop .tl-node { background: var(--emergency); }
.tl-adl .tl-node { background: #facc15; }
.tl-esc .tl-node { background: var(--critical); box-shadow: 0 0 0 4px rgba(251, 146, 60, 0.18); }
.tl-ack .tl-node { background: var(--safe); }
.tl-sub { margin-top: 3px; font-size: 11.5px; color: var(--muted); }
.tl-muse { margin-top: 5px; font-size: 12px; color: #c3cad6; line-height: 1.45; }

.ack-btn { color: #0b0f17 !important; background: var(--safe) !important; border-color: transparent !important; font-weight: 750; }
.ack-btn:hover { filter: brightness(1.1); }
.ack-btn.done { color: var(--muted) !important; background: rgba(148, 163, 184, 0.1) !important; cursor: default; }

.wake {
  display: flex; align-items: center; gap: 16px; padding: 14px 18px;
  border: 1px solid rgba(251, 146, 60, 0.45); background: linear-gradient(90deg, rgba(251, 146, 60, 0.14), rgba(17, 24, 37, 0.8));
}
.wake-emergency { border-color: rgba(244, 63, 94, 0.6); background: linear-gradient(90deg, rgba(244, 63, 94, 0.2), rgba(17, 24, 37, 0.8)); }
.wake.ring { animation: ring 0.9s ease; }
.wake-icon { font-size: 28px; }
.wake-title { font-weight: 750; font-size: 15px; }
.wake-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.wake-body { flex: 1; min-width: 0; }
.wake-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.wake-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-radius: 10px; background: rgba(7, 10, 17, 0.55); border: 1px solid var(--line-2); font-size: 12.5px; }
@keyframes ring {
  0%, 100% { transform: none; }
  15%, 45%, 75% { transform: translateX(-4px); }
  30%, 60%, 90% { transform: translateX(4px); }
}

.pchips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pchip { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 650; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-2); background: rgba(148, 163, 184, 0.06); }
.adl { display: inline-flex; gap: 2px; vertical-align: middle; }
.adl i { width: 7px; height: 11px; border-radius: 2px; background: rgba(148, 163, 184, 0.18); }
.adl i.on { background: var(--safe); }
.adl-3 i.on { background: var(--warning); }
.adl-4 i.on { background: var(--critical); }
.adl-5 i.on { background: var(--emergency); box-shadow: 0 0 6px rgba(244, 63, 94, 0.6); }

.row-protect { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; }
.session { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; align-items: center; }
.sess-clock { font-size: 12px; font-weight: 650; margin-right: 6px; }
.sess { font-size: 11px; font-weight: 650; padding: 3px 9px; border-radius: 999px; color: var(--faint); border: 1px dashed var(--line-2); }
.sess.on { color: var(--warning); border-style: solid; border-color: rgba(251, 191, 36, 0.45); background: rgba(251, 191, 36, 0.08); }
.stress { display: grid; gap: 8px; }
.st-row {
  display: grid; grid-template-columns: 1.2fr 0.8fr 1fr 1fr 1.6fr; gap: 12px; align-items: center;
  padding: 10px 12px; border-radius: 10px; background: rgba(7, 10, 17, 0.4); border: 1px solid var(--line);
}
.st-row.danger { border-color: rgba(244, 63, 94, 0.5); background: rgba(244, 63, 94, 0.08); }
.st-sym { display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.st-sym .venue { align-self: flex-start; }
.st-big { text-align: center; }
.st-n { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.st-big .faint { font-size: 10px; margin-top: 3px; }
.st-cell { font-size: 11.5px; display: grid; gap: 2px; font-variant-numeric: tabular-nums; }
.st-iv { font-weight: 750; color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; }
.st-tiers { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11px; }
.st-tier b { margin-left: 1px; }
.st-why { width: 100%; font-size: 10.5px; }

.stops { display: grid; gap: 8px; }
.sp-row { padding: 10px 12px; border-radius: 10px; background: rgba(7, 10, 17, 0.4); border: 1px solid var(--line); border-left: 3px solid var(--line-2); }
.sp-safe { border-left-color: var(--safe); }
.sp-warning { border-left-color: var(--warning); }
.sp-critical { border-left-color: var(--critical); }
.sp-emergency { border-left-color: var(--emergency); background: rgba(244, 63, 94, 0.07); }
.sp-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12.5px; }
.sp-status { font-weight: 700; }
.sp-adl { margin-left: auto; font-size: 11px; display: inline-flex; align-items: center; gap: 4px; }
.sp-line { margin-top: 5px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sp-fixes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.sp-fix { font-size: 11px; padding: 3px 8px; border-radius: 8px; border: 1px solid var(--line-2); color: #c3cad6; }
.sp-fix.best { border-color: rgba(52, 211, 153, 0.5); background: rgba(52, 211, 153, 0.08); color: var(--text); }
.sp-fix .star { color: var(--safe); font-weight: 700; }
.sp-muse { margin-top: 7px; font-size: 12px; line-height: 1.45; color: #c3cad6; }
.acct-wake { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 650; }

@media (max-width: 1280px) {
  .row-protect { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .wake { flex-direction: column; align-items: stretch; }
  .wake-list { justify-content: stretch; }
  .wake-item { flex-wrap: wrap; }
  .st-row { grid-template-columns: 1fr 1fr; }
  .st-tiers { grid-column: 1 / -1; }
}

/* ---------- portfolio: scenario, concentration, triage, stress, liq comparison, sizing ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.scenario select {
  height: 36px; padding: 0 30px 0 12px; border-radius: 10px; border: 1px solid var(--line-2); color: var(--text);
  background: rgba(17, 24, 37, 0.9) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238a96ab'/%3E%3C/svg%3E") no-repeat right 11px center;
  appearance: none; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; max-width: 230px;
}
.scenario select:disabled { opacity: 0.55; cursor: not-allowed; }
.scenario select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.riskiest-why { font-size: 12px; margin-top: 6px; max-width: 320px; line-height: 1.35; }
.tri-why { font-size: 12.5px; color: var(--muted); padding: 8px 12px; margin-bottom: 10px; border-radius: 10px;
  border: 1px solid var(--line-2); background: rgba(17, 24, 37, 0.6); line-height: 1.4; }
.tri-why b { color: var(--text); }

.tag-hot { color: var(--emergency); border-color: rgba(244, 63, 94, 0.4); background: rgba(244, 63, 94, 0.1); }

.conc { display: flex; align-items: center; gap: 16px; padding: 14px 18px; border-color: rgba(251, 146, 60, 0.45);
  background: linear-gradient(90deg, rgba(251, 146, 60, 0.14), rgba(17, 24, 37, 0.78) 60%); }
.conc-icon { font-size: 26px; }
.conc-body { flex: 1; min-width: 0; }
.conc-title { font-weight: 750; font-size: 15px; color: var(--critical); }
.conc-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.conc-stat { text-align: center; }
.conc-n { font-size: 26px; font-weight: 800; font-family: var(--mono); color: var(--critical); line-height: 1; }

.row-portfolio { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }

.triage { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tri { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px;
  border-radius: 10px; border: 1px solid var(--line); background: rgba(7, 10, 17, 0.4); }
.tri.first { border-color: rgba(94, 234, 212, 0.55); background: linear-gradient(90deg, rgba(94, 234, 212, 0.12), rgba(7, 10, 17, 0.4)); box-shadow: 0 0 0 1px rgba(94, 234, 212, 0.15) inset; }
.tri.calm { opacity: 0.7; }
.tri-rank { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-family: var(--mono);
  background: rgba(148, 163, 184, 0.1); }
.tri.first .tri-rank { background: var(--accent); color: #04211d; }
.tri-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tri-sev { font-size: 11px; font-weight: 750; letter-spacing: 0.04em; }
.first-tag { font-size: 11px; font-weight: 750; color: var(--accent); }
.tri-bar { height: 5px; border-radius: 999px; background: rgba(148, 163, 184, 0.1); margin: 7px 0 6px; overflow: hidden; }
.tri-bar i { display: block; height: 100%; border-radius: inherit; transition: width 0.4s ease; }
.tri-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.tri-score { font-family: var(--mono); font-weight: 800; font-size: 18px; color: var(--muted); }
.tri.first .tri-score { color: var(--accent); }

.pstress { display: grid; gap: 14px; }
.ps-acct { display: grid; gap: 10px; }
.ps-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; }
.ps-big { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 12px; border: 1px solid currentColor;
  background: rgba(7, 10, 17, 0.45); }
.ps-big > div:last-child { color: var(--text); font-size: 13px; }
.ps-n { font-size: 30px; font-weight: 800; font-family: var(--mono); line-height: 1; min-width: 92px; }
.ps-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ps-cell { padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(52, 211, 153, 0.06); }
.ps-cell.dead { background: rgba(244, 63, 94, 0.14); border-color: rgba(244, 63, 94, 0.45); }
.ps-move { font-family: var(--mono); font-weight: 800; font-size: 15px; }
.ps-out { font-size: 11.5px; color: var(--safe); font-weight: 650; }
.ps-cell.dead .ps-out { color: var(--emergency); letter-spacing: 0.05em; }
.ps-up .ps-cell { opacity: 0.75; }

.liqcmp { display: grid; gap: 10px; }
.lc-row { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(7, 10, 17, 0.4); display: grid; gap: 6px; }
.lc-row.hot { border-color: rgba(244, 63, 94, 0.4); }
.lc-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lc-gap { margin-left: auto; font-size: 11.5px; font-weight: 750; color: var(--emergency); background: rgba(244, 63, 94, 0.12);
  padding: 2px 8px; border-radius: 999px; }
.lc-line { display: grid; grid-template-columns: 128px 104px minmax(0, 1fr); gap: 10px; align-items: center; font-size: 12px; }
.lc-label { color: var(--muted); }
.lc-price { font-family: var(--mono); font-weight: 700; }
.lc-bar { position: relative; height: 16px; border-radius: 6px; background: rgba(148, 163, 184, 0.08); overflow: hidden; }
.lc-bar i { display: block; height: 100%; border-radius: inherit; }
.lc-bar span { position: absolute; right: 6px; top: 0; font-size: 10.5px; line-height: 16px; font-family: var(--mono); font-weight: 700; }
.lc-bar.plat i { background: rgba(148, 163, 184, 0.35); }
.lc-bar.real i { background: rgba(52, 211, 153, 0.55); }
.lc-bar.real.hot i { background: linear-gradient(90deg, rgba(244, 63, 94, 0.9), rgba(251, 146, 60, 0.7)); }
.lc-note { font-size: 11px; }

.sizing { display: grid; gap: 10px; }
.sz-row { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(7, 10, 17, 0.4); display: grid; gap: 8px; }
.sz-row.over { border-left: 3px solid var(--warning); }
.sz-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; }
.sz-status { margin-left: auto; font-weight: 750; font-size: 12px; }
.sz-meters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.meter-top { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); }
.meter-top b { font-family: var(--mono); color: var(--text); }
.meter-bar { position: relative; height: 6px; border-radius: 999px; background: rgba(148, 163, 184, 0.1); margin: 5px 0 3px; }
.meter-bar i { display: block; height: 100%; border-radius: inherit; background: var(--safe); }
.meter-bar u { position: absolute; top: -3px; width: 2px; height: 12px; background: var(--text); opacity: 0.5; text-decoration: none; }
.meter.near .meter-bar i { background: var(--warning); }
.meter.over .meter-bar i { background: var(--emergency); }
.meter.over .meter-top b { color: var(--emergency); }
.meter-sub { font-size: 11px; }
.sz-suggest { font-size: 12.5px; }
.sz-suggest b { font-family: var(--mono); color: var(--accent); }

.chip-first, .pchip.chip-first { color: var(--accent); border-color: rgba(94, 234, 212, 0.45); background: rgba(94, 234, 212, 0.1); }
.tc-triage i { background: var(--accent); }
.tc-corr i { background: var(--critical); }
.tc-sizing i { background: var(--warning); }
.lvl-triage-b { color: var(--accent); background: rgba(94, 234, 212, 0.12); }
.lvl-corr-b { color: var(--critical); background: rgba(251, 146, 60, 0.14); }
.lvl-sizing-b { color: var(--warning); background: rgba(251, 191, 36, 0.14); }
.tl-triage .tl-node { background: var(--accent); }
.tl-corr .tl-node { background: var(--critical); }
.tl-sizing .tl-node { background: var(--warning); }
.tl-order { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 3px; font-size: 12.5px; }
.tl-order li.first { font-weight: 700; }
.acct-insights { display: grid; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12.5px; }

@media (max-width: 1280px) {
  .row-portfolio { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .scenario select { max-width: 150px; }
  .conc { flex-wrap: wrap; }
  .lc-line { grid-template-columns: 1fr auto; }
  .lc-line .lc-bar { grid-column: 1 / -1; }
  .ps-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ps-n { font-size: 24px; min-width: 0; }
  .sz-meters { grid-template-columns: 1fr; }
  .tri { grid-template-columns: 24px minmax(0, 1fr); }
  .tri-score { display: none; }
}

/* ---------------- quick actions, settings & binding panels ---------------- */
.tool-row { display: flex; flex-wrap: wrap; gap: 6px; }
.acct-pos .tool-row { grid-column: 1 / -1; }
.tool-btn { font-size: 12px; }
.tool-dialog {
  width: min(560px, calc(100vw - 24px)); max-height: min(80vh, 720px); padding: 0; border: 1px solid var(--line-2, var(--line));
  border-radius: var(--radius); background: #0d131f; color: var(--text); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
}
.tool-dialog::backdrop { background: rgba(3, 6, 12, 0.65); backdrop-filter: blur(2px); }
.tool-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 8px; }
.tool-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px 10px; border-bottom: 1px solid var(--line); }
.tool-tabs .active, .bind-tab.active { background: rgba(94, 234, 212, 0.16); border-color: rgba(94, 234, 212, 0.45); color: var(--accent); }
.tool-body { padding: 14px 18px 18px; overflow: auto; max-height: calc(min(80vh, 720px) - 110px); font-size: 13.5px; line-height: 1.6; }
.tool-line { white-space: pre-wrap; }
.tool-line.indent { color: var(--muted); font-family: var(--mono); font-size: 12.5px; }
.tool-line.warn { color: var(--critical); font-weight: 600; }
.tool-line.good { color: var(--safe); }
.tool-line.muted { color: var(--muted); }
.tool-line.muse { color: var(--text); padding: 8px 10px; border-left: 2px solid var(--accent-2); background: rgba(99, 102, 241, 0.08); border-radius: 0 8px 8px 0; }
.acct-muse { margin-top: 0; padding: 8px 12px; border-radius: 10px; border-left: 2px solid var(--accent-2); background: rgba(99, 102, 241, 0.06); }
.tool-gap { height: 8px; }
.tool-more { margin-top: 12px; }
.confirm-dialog .tool-body { padding-top: 18px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 18px 16px; }
.btn-danger { color: #fff; background: linear-gradient(135deg, #f43f5e, #be123c); border-color: transparent; }
.mini-btn.danger { margin-left: 8px; color: var(--emergency); }
.account-grid-2 { grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); padding-top: 16px; }
.panel { display: grid; gap: 10px; align-content: start; }
.panel-sub { font-size: 12px; color: var(--muted); line-height: 1.5; }
.label-en { margin-left: 6px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--faint); }
.settings-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px 12px; }
.setting-row { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.toggles { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; }
.toggle-row { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.toggle-row input { accent-color: var(--accent); width: 16px; height: 16px; }
.field {
  width: 100%; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line); background: rgba(148, 163, 184, 0.06);
  color: var(--text); font: inherit; font-size: 13px;
}
.field:focus { outline: 2px solid rgba(94, 234, 212, 0.45); outline-offset: 1px; }
select.field option { background: #0d131f; }
.security-note { white-space: pre-line; font-size: 12.5px; line-height: 1.55; padding: 10px 12px; border-radius: 10px;
  border: 1px solid rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.07); }
.bind-tabs { display: flex; gap: 6px; }
.bind-form { display: grid; gap: 8px; }
.bind-steps { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.panel-msg { min-height: 1em; font-size: 13px; }
.panel-msg.ok { color: var(--safe); }
.panel-msg.err { color: var(--emergency); }
@media (max-width: 900px) {
  .account-grid-2 { grid-template-columns: 1fr; }
}

/* ---------------- first-run hierarchy: demo bar, hero, position list, folds ---------------- */
.layout { max-width: 1180px; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 9px; }
.btn-xs { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 8px; gap: 6px; }
.btn-xs svg { width: 11px; height: 11px; }
.pill-sm { padding: 3px 8px; font-size: 10.5px; }
.lang-btn { min-width: 64px; justify-content: center; }
.progress { top: 61px; }

.demobar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 6px 10px; border-radius: 12px; border: 1px dashed rgba(99, 102, 241, 0.4); background: rgba(99, 102, 241, 0.06);
  font-size: 12px;
}
.demobar-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #a5b4fc; margin-right: 4px; }
.demobar .scenario select { height: 28px; font-size: 12px; border-radius: 8px; padding: 0 26px 0 10px; max-width: 220px; }
.demobar-pills { display: inline-flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }

.hero {
  display: grid; grid-template-columns: minmax(160px, 0.8fr) minmax(0, 1.1fr) minmax(0, 1.4fr); gap: 0;
  position: relative; overflow: hidden; --hero: var(--muted); border-color: color-mix(in srgb, var(--hero) 45%, transparent);
}
.hero::before { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(110deg, color-mix(in srgb, var(--hero) 22%, transparent), transparent 55%); }
.status-safe { --hero: var(--safe); }
.status-warning { --hero: var(--warning); }
.status-danger { --hero: var(--emergency); }
.status-idle { --hero: var(--muted); }
.hero-col { position: relative; padding: 20px 22px; display: grid; gap: 6px; align-content: start; min-width: 0; }
.hero-col + .hero-col { border-left: 1px solid var(--line); }
.hero-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.hero-level { font-size: 34px; font-weight: 850; letter-spacing: 0.04em; color: var(--hero); line-height: 1.05; }
.status-danger .hero-level { text-shadow: 0 0 24px rgba(244, 63, 94, 0.45); }
.hero-sub { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.hero .riskiest-chip { margin-top: 0; justify-self: start; display: inline-flex; align-items: center; gap: 6px; font-family: inherit; font-size: 14px; white-space: normal; flex-wrap: wrap; }
.hero-dist { font-size: 13px; color: var(--muted); }
.hero-dist b { font-family: var(--mono); font-size: 30px; font-weight: 850; letter-spacing: -0.02em; margin-right: 4px; }
.hero-action-title { font-size: 17px; font-weight: 700; line-height: 1.35; }
.hero-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.hero-muse {
  position: relative; grid-column: 1 / -1; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  padding: 10px 22px; border-top: 1px solid var(--line); background: rgba(7, 10, 17, 0.35); font-size: 13px;
}
.hero-headline { color: #c3cad6; flex: 1 1 320px; min-width: 0; line-height: 1.45; }
.hero .riskiest-why { max-width: none; }

.kpi { padding: 12px 16px; }
.kpi-value { font-size: 22px; }

.positions-card .card-head { padding-bottom: 8px; }
.plist-head, .prow {
  display: grid; grid-template-columns: minmax(110px, 1.2fr) minmax(90px, 0.9fr) minmax(90px, 0.8fr) minmax(150px, 1.6fr) 92px 18px;
  gap: 12px; align-items: center;
}
.plist-head { padding: 0 30px 6px; font-size: 10.5px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: 0.07em; }
.plist-head span:nth-child(5) { grid-column: 5 / 7; }
.plist { padding: 0 12px 12px; display: grid; gap: 6px; }
.pgroup { border-radius: 12px; border: 1px solid var(--line); background: rgba(148, 163, 184, 0.03); transition: border-color 0.2s, background 0.2s; }
.pgroup.open { border-color: var(--line-2); background: rgba(148, 163, 184, 0.06); }
.prow { padding: 11px 16px; cursor: pointer; border-radius: 12px; border-left: 3px solid transparent; }
.prow:hover { background: rgba(148, 163, 184, 0.06); }
.prow:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.prow.tier-warning { border-left-color: var(--warning); }
.prow.tier-critical { border-left-color: var(--critical); }
.prow.tier-emergency { border-left-color: var(--emergency); }
.prow.tier-safe { border-left-color: rgba(52, 211, 153, 0.5); }
.prow.flash { animation: flash 1.2s ease; }
.prow-sym { display: inline-flex; align-items: center; gap: 8px; font-weight: 750; font-size: 14px; min-width: 0; }
.prow-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.tier-safe .prow-dot { color: var(--safe); } .tier-warning .prow-dot { color: var(--warning); }
.tier-critical .prow-dot { color: var(--critical); } .tier-emergency .prow-dot { color: var(--emergency); box-shadow: 0 0 8px var(--emergency); }
.prow-side { display: inline-flex; align-items: center; gap: 4px; }
.prow-dist { display: grid; grid-template-columns: minmax(40px, 1fr) auto; gap: 10px; align-items: center; }
.prow-dist b { font-family: var(--mono); font-size: 15px; font-weight: 800; min-width: 54px; text-align: right; font-variant-numeric: tabular-nums; }
.prow-bar { height: 6px; border-radius: 999px; background: rgba(148, 163, 184, 0.1); overflow: hidden; }
.prow-bar i { display: block; height: 100%; border-radius: inherit; transition: width 0.4s ease; }
.prow-risk { justify-self: start; font-size: 10.5px; font-weight: 800; letter-spacing: 0.05em; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.risk-safe { color: var(--safe); background: rgba(52, 211, 153, 0.12); }
.risk-warning { color: var(--warning); background: rgba(251, 191, 36, 0.14); }
.risk-critical { color: var(--critical); background: rgba(251, 146, 60, 0.16); }
.risk-emergency { color: #fff; background: var(--emergency); }
.prow-chev { color: var(--faint); font-size: 18px; transition: transform 0.2s; text-align: center; }
.pgroup.open .prow-chev { transform: rotate(90deg); color: var(--text); }
.pdetail { padding: 2px 18px 14px 19px; border-top: 1px dashed var(--line); display: grid; gap: 4px; }
.pdetail .pos-meta { justify-content: flex-start; gap: 16px; flex-wrap: wrap; }
.pdetail .pos-actions { justify-content: flex-start; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.mini-btn.primary { color: #061015; background: linear-gradient(135deg, var(--accent), #818cf8); border-color: transparent; font-weight: 750; }
.mini-btn.primary:hover { filter: brightness(1.08); }

.group-head { margin-top: 10px; }
.group-title { font-weight: 750; font-size: 16px; letter-spacing: -0.01em; }
.group-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.group-label { font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: 0.1em; margin: 6px 0 -8px 4px; }

.fold > summary { list-style: none; }
.fold > summary::-webkit-details-marker { display: none; }
.fold-head { display: flex; align-items: center; gap: 12px; padding: 13px 18px; cursor: pointer; border-radius: var(--radius); }
.fold-head:hover { background: rgba(148, 163, 184, 0.04); }
.fold-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.fold-icon { font-size: 17px; width: 22px; text-align: center; flex-shrink: 0; }
.fold-text { display: grid; gap: 1px; flex: 1; min-width: 0; }
.fold-text .card-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fold[open] .fold-text .card-sub { white-space: normal; }
.fold-chev { width: 9px; height: 9px; flex-shrink: 0; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform 0.2s; margin: 0 4px 0 2px; }
.fold[open] > summary .fold-chev { transform: rotate(45deg); }
.fold-body { padding: 0 16px 16px; }
.fold-body > .scroll { padding: 0; }
.fold .tier-counts { flex-wrap: wrap; justify-content: flex-end; }
.fold .chart-wrap { padding: 0; }
.fold .legend { padding: 10px 2px 0; }
.chart-tabs { margin-bottom: 10px; display: inline-flex; }
.rescue-card .rescue-body { padding: 10px 0 0; }
.exposure-line { font-size: 12.5px; color: var(--muted); font-family: var(--mono); margin-bottom: 12px; }
.fold .wallets { padding: 0 0 10px; }

.tag, .side, .venue, .lvl, .mode, .tri-sev { text-transform: uppercase; }
html[lang^="zh"] .tag, html[lang^="zh"] .side, html[lang^="zh"] .lvl, html[lang^="zh"] .mode { letter-spacing: 0.02em; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr 1fr; }
  .hero-action { grid-column: 1 / -1; border-left: 0 !important; border-top: 1px solid var(--line); }
  .plist-head { display: none; }
  .prow { grid-template-columns: minmax(0, 1fr) auto auto 18px; grid-template-areas: "sym dist risk chev" "meta meta meta meta"; row-gap: 6px; }
  .prow-sym { grid-area: sym; }
  .prow-dist { grid-area: dist; grid-template-columns: auto; }
  .prow-dist .prow-bar { display: none; }
  .prow-risk { grid-area: risk; }
  .prow-chev { grid-area: chev; }
  .prow-venue, .prow-side { grid-area: meta; }
  .prow-side { justify-self: end; }
}
@media (max-width: 720px) {
  .topbar { gap: 10px; }
  .controls { gap: 6px; }
  .pills { order: 3; width: 100%; margin-left: 0; }
  .progress { position: relative; top: 0; }
  .demobar-pills { margin-left: 0; width: 100%; }
  .hero { grid-template-columns: 1fr; }
  .hero-col + .hero-col { border-left: 0; border-top: 1px solid var(--line); }
  .hero-col { padding: 14px 16px; }
  .hero-level { font-size: 28px; }
  .hero-muse { padding: 10px 16px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .fold-head { padding: 12px 14px; gap: 10px; }
  .fold-head .tag-ro, .fold .tier-counts { display: none; }
  .fold-body { padding: 0 12px 14px; }
}
