[hidden] { display: none !important; }

/* v4 · bright tech theme: cool near-white base, cyan → blue → violet accents, glass cards */
:root {
  --bg: #f4f7fc;
  --bg-2: #eaf0fa;
  --card: rgba(255, 255, 255, .78);
  --card-solid: #ffffff;
  --line: rgba(40, 72, 140, .10);
  --line-2: rgba(40, 72, 140, .18);
  --text: #0d1630;
  --text-2: #33405f;
  --muted: #6b7896;
  --c1: #06b6d4;   /* cyan */
  --c2: #3b82f6;   /* blue */
  --c3: #8b5cf6;   /* violet */
  --c4: #ec4899;   /* pink accent (sparingly) */
  --grad: linear-gradient(120deg, var(--c1) 0%, var(--c2) 48%, var(--c3) 100%);
  --acc: #2563eb;
  --acc-dim: rgba(59, 130, 246, .10);
  --ok: #059669;
  --ok-bg: rgba(16, 185, 129, .12);
  --warn: #c2790a;
  --warn-bg: rgba(245, 158, 11, .14);
  --bad: #e11d48;
  --bad-bg: rgba(244, 63, 94, .10);
  --shadow: 0 1px 2px rgba(16, 32, 80, .04), 0 8px 28px rgba(30, 60, 140, .08);
  --shadow-lg: 0 2px 4px rgba(16, 32, 80, .05), 0 22px 60px rgba(40, 80, 180, .14);
  --sidebar: 248px;
  --tab-h: 62px;
  --mono: "SF Mono", "JetBrains Mono", "Menlo", "Consolas", ui-monospace, monospace;
  --sans: -apple-system, "SF Pro Display", "PingFang SC", "Noto Sans SC", "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; min-height: 100%;
  color: var(--text);
  font: 14px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1100px 520px at 0% -10%, rgba(6,182,212,.14), transparent 60%),
    radial-gradient(900px 480px at 100% -5%, rgba(139,92,246,.12), transparent 55%),
    radial-gradient(800px 600px at 50% 120%, rgba(59,130,246,.08), transparent 60%),
    linear-gradient(180deg, #f7faff 0%, var(--bg) 45%, var(--bg-2) 100%);
  background-attachment: fixed;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(59,130,246,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59,130,246,.07) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 10%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 10%, transparent 75%);
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: .01em; }
.muted { color: var(--muted); margin: 0; }
.err { color: var(--bad); }
.note { color: var(--muted); font-size: 12px; line-height: 1.6; }
.mono, .value, td, .hero-num, .kpi .value { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* login */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; z-index: 1; }
.login-card {
  width: min(420px, 100%);
  background: rgba(255,255,255,.82);
  border: 1px solid var(--line-2); border-radius: 22px; padding: 34px 28px;
  display: grid; gap: 14px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4);
  position: relative; overflow: hidden;
}
.login-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--grad); }
.brand-mark {
  width: 44px; height: 44px; border-radius: 13px;
  display: grid; place-items: center; font-weight: 750; font-size: 14px; color: #fff;
  background: var(--grad);
  box-shadow: 0 8px 22px rgba(59,130,246,.35), inset 0 1px 0 rgba(255,255,255,.35);
}
.brand-mark.sm { width: 34px; height: 34px; font-size: 12px; border-radius: 10px; }
.login-card h1 { font-size: 1.45rem; }
.login-card label, .field label { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); }
input, select, textarea {
  background: #fff; border: 1px solid var(--line-2); border-radius: 11px; padding: 10px 12px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--c2); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
button {
  background: #fff; border: 1px solid var(--line-2); border-radius: 11px;
  padding: 8px 14px; cursor: pointer; color: var(--text-2);
  transition: border-color .15s, background .15s, color .15s, box-shadow .15s;
}
button:hover { border-color: rgba(59,130,246,.35); color: var(--acc); }
button.primary {
  background: var(--grad); color: #fff; border: 0; font-weight: 650;
  box-shadow: 0 6px 18px rgba(59,130,246,.30);
}
button.primary:hover { color: #fff; filter: brightness(1.05); }
button.ghost { background: transparent; border-color: transparent; }
button.active { border-color: transparent; color: #fff; background: var(--grad); box-shadow: 0 4px 14px rgba(59,130,246,.25); }
button:disabled { opacity: .45; cursor: not-allowed; }

/* layout */
#app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; position: relative; z-index: 1; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 20px 14px;
  border-right: 1px solid var(--line);
  background: rgba(255,255,255,.66);
  backdrop-filter: blur(22px) saturate(1.5); -webkit-backdrop-filter: blur(22px) saturate(1.5);
  display: flex; flex-direction: column; gap: 20px;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 4px; }
.brand strong { display: block; font-size: 14px; }
.brand span { color: var(--muted); font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; }
#sidenav { display: grid; gap: 3px; overflow: auto; }
#sidenav button { text-align: left; background: transparent; border-color: transparent; padding: 9px 12px; border-radius: 11px; color: var(--text-2); position: relative; box-shadow: none; }
#sidenav button:hover { background: rgba(59,130,246,.06); }
#sidenav button.active { background: linear-gradient(90deg, rgba(6,182,212,.12), rgba(139,92,246,.10)); color: var(--acc); font-weight: 600; }
#sidenav button.active::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--grad); }
#sidenav .nav-sub { font-size: 11px; color: var(--muted); margin-top: 1px; font-weight: 400; }
.sidebar-foot { margin-top: auto; }

.shell { min-width: 0; padding-bottom: 24px; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 18px 26px 8px; }
.topbar h1 { font-size: 21px; }
.menu-btn { display: none; }
.balances { margin-left: auto; display: flex; gap: 10px; }
.bal { display: grid; font-size: 12px; padding: 6px 12px; border-radius: 12px; background: rgba(255,255,255,.7); border: 1px solid var(--line); }
.bal b { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.flags { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 26px 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 2px 9px; font-size: 11px;
  letter-spacing: .02em; border: 1px solid var(--line-2); color: var(--text-2); background: rgba(255,255,255,.7);
}
.pill.ok { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.pill.bad { color: var(--bad); background: var(--bad-bg); border-color: transparent; }
.pill.warn { color: var(--warn); background: var(--warn-bg); border-color: transparent; }

main { padding: 8px 26px 34px; display: grid; gap: 16px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar .note { margin-left: 8px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: rgba(15,30,70,.05); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 9px; font-size: 12.5px; box-shadow: none; }
.seg button.active { background: #fff; color: var(--acc); box-shadow: 0 1px 2px rgba(16,32,80,.08), 0 4px 12px rgba(40,80,180,.10); }

/* hero */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, rgba(255,255,255,.92), rgba(240,246,255,.86));
  border: 1px solid var(--line-2); border-radius: 22px; padding: 26px 28px 22px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.hero::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--grad); }
.hero::after {
  content: ""; position: absolute; width: 420px; height: 420px; right: -140px; top: -200px;
  background: radial-gradient(circle, rgba(139,92,246,.18), rgba(6,182,212,.10) 40%, transparent 70%);
  pointer-events: none;
}
.hero-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; align-items: end; position: relative; z-index: 1; }
.kicker { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.hero-num { font-family: var(--mono); font-size: clamp(34px, 5.6vw, 54px); font-weight: 650; letter-spacing: -0.035em; line-height: 1.08; margin: 8px 0 4px; }
.hero-sub { font-family: var(--mono); font-size: 15px; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.hs { padding: 10px 12px; border-radius: 14px; background: rgba(255,255,255,.75); border: 1px solid var(--line); }
.hs .l { font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.hs .v { font-family: var(--mono); font-size: 16px; font-weight: 600; margin-top: 2px; }
.hs .s { font-size: 11px; color: var(--muted); margin-top: 1px; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kpi, .card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
}
.kpi { padding: 15px 17px; position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%; background: radial-gradient(circle, rgba(59,130,246,.10), transparent 70%); }
.kpi .label, .card h2 { font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 650; }
.kpi .value { font-family: var(--mono); font-size: 21px; margin-top: 6px; font-weight: 600; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.card { padding: 18px 20px; }
.card h2 { margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card h2::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--grad); box-shadow: 0 0 10px rgba(59,130,246,.6); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h2 { margin: 0; }

/* equity chart */
.eq-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.eq-legend button { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; padding: 5px 10px; border-radius: 999px; background: #fff; box-shadow: none; }
.eq-legend button .sw { width: 14px; height: 4px; border-radius: 3px; }
.eq-legend button.off { opacity: .45; }
.eq-legend button.off .sw { background: #c4cbe0 !important; }
.chart-wrap { position: relative; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart { width: 100%; height: 340px; display: block; overflow: visible; }
.chart.sm { height: 180px; }
.chart .ax { fill: #8a96b3; font-size: 10.5px; font-family: var(--mono); }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 3; top: 8px;
  background: rgba(255,255,255,.95); border: 1px solid var(--line-2); border-radius: 12px;
  padding: 8px 10px; font-size: 12px; min-width: 170px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.chart-tip .t { font-weight: 650; margin-bottom: 4px; color: var(--text); font-family: var(--mono); font-size: 11.5px; }
.chart-tip .r { display: flex; justify-content: space-between; gap: 12px; font-family: var(--mono); }
.chart-tip .r i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.brush { height: 54px; margin-top: 8px; position: relative; border-radius: 10px; background: rgba(15,30,70,.03); border: 1px solid var(--line); overflow: hidden; touch-action: none; }
.brush svg { width: 100%; height: 100%; display: block; }
.brush .win { position: absolute; top: 0; bottom: 0; background: rgba(59,130,246,.10); border-left: 2px solid var(--c2); border-right: 2px solid var(--c3); cursor: grab; }
.brush .win .h { position: absolute; top: 50%; width: 12px; height: 26px; margin-top: -13px; border-radius: 6px; background: #fff; border: 1px solid var(--line-2); box-shadow: var(--shadow); }
.brush .win .h.l { left: -7px; } .brush .win .h.r { right: -7px; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 12px; }
.stat { padding: 10px 12px; border-radius: 14px; background: rgba(255,255,255,.7); border: 1px solid var(--line); }
.stat .l { font-size: 11px; color: var(--muted); }
.stat .v { font-family: var(--mono); font-size: 15.5px; font-weight: 600; margin-top: 2px; }
.stat .s { font-size: 11px; color: var(--muted); }
.gap-note { margin-top: 10px; padding: 8px 12px; border-radius: 12px; background: var(--warn-bg); color: #8a5a06; font-size: 12px; }

.bstrip { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.bstrip-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 11px 13px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(255,255,255,.7);
}
.bstrip-item b { font-size: 13px; font-weight: 650; }
.bstrip-item span { font-size: 11px; color: var(--muted); }

.method-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.method { padding: 14px 16px; border-radius: 16px; background: rgba(255,255,255,.75); border: 1px solid var(--line); }
.method h3 { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.method h3 .sw { width: 14px; height: 4px; border-radius: 3px; }
.method p { margin: 6px 0 0; font-size: 12.5px; color: var(--text-2); }
.method .v { font-family: var(--mono); font-size: 15px; font-weight: 600; margin-top: 6px; }

.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 650; padding: 8px 10px; white-space: nowrap; }
td { padding: 9px 10px; border-top: 1px solid var(--line); }
tr:hover td { background: rgba(59,130,246,.03); }
a { color: var(--acc); text-decoration: none; }

.strategy { border: 1px solid var(--line); border-radius: 16px; background: var(--card); overflow: hidden; box-shadow: var(--shadow); }
.strategy + .strategy { margin-top: 10px; }
.strategy summary { list-style: none; display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 14px 16px; cursor: pointer; }
.strategy summary::-webkit-details-marker { display: none; }
.strategy[open] summary { background: linear-gradient(90deg, rgba(6,182,212,.06), rgba(139,92,246,.05)); }
.strategy .sum-line { color: var(--muted); font-size: 12px; margin-top: 4px; font-family: var(--mono); }
.strategy .body { padding: 0 16px 16px; border-top: 1px solid var(--line); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; padding-top: 14px; }
.field small { color: var(--muted); font-size: 11px; }
.branch-head { padding: 0 2px 4px; }
details.fold { border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.6); }
details.fold > summary { cursor: pointer; padding: 10px 14px; font-size: 13px; color: var(--text-2); list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: "展开"; float: right; color: var(--acc); font-size: 12px; }
details.fold[open] > summary::after { content: "收起"; }
details.fold > div { padding: 0 14px 12px; }

.savebar {
  position: sticky; bottom: 0; display: flex; gap: 10px; align-items: center; justify-content: flex-end;
  padding: 12px 20px; background: rgba(255,255,255,.9); border-top: 1px solid var(--line); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  z-index: 22;
}
#dirty-count { margin-right: auto; color: var(--warn); }
dialog { border: 1px solid var(--line-2); background: var(--card-solid); color: var(--text); border-radius: 18px; padding: 22px; max-width: 560px; box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(15,25,55,.25); backdrop-filter: blur(3px); }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; }
.diff-item { padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.diff-item .from { color: var(--bad); } .diff-item .to { color: var(--ok); }

.mobile-tab { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 1100px) {
  .hero-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 960px) {
  #app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 30; width: min(84vw, 300px);
    transform: translateX(-105%); transition: transform .22s ease;
    background: rgba(255,255,255,.95);
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; background: rgba(15,25,55,.25); z-index: 25; backdrop-filter: blur(2px); }
  .menu-btn { display: inline-flex; }
  .balances { display: none; }
  main { padding: 6px 12px calc(var(--tab-h) + 26px + env(safe-area-inset-bottom)); gap: 12px; }
  .topbar { padding: 12px 14px 4px; padding-top: max(12px, env(safe-area-inset-top)); }
  .topbar h1 { font-size: 18px; }
  .flags { padding: 0 14px 6px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .hero { padding: 20px 18px 18px; border-radius: 20px; }
  .hero-num { font-size: 34px; }
  .hero-stats { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .hs { padding: 8px 9px; } .hs .v { font-size: 13.5px; }
  .card { padding: 15px 14px; border-radius: 16px; }
  .kpi { padding: 13px 14px; } .kpi .value { font-size: 17px; }
  .chart { height: 250px; }
  .method-grid { grid-template-columns: 1fr; }
  .seg button { padding: 6px 9px; font-size: 12px; }
  .mobile-tab {
    display: grid; grid-template-columns: repeat(4, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255,255,255,.9); border-top: 1px solid var(--line);
    backdrop-filter: blur(18px) saturate(1.5); -webkit-backdrop-filter: blur(18px) saturate(1.5);
  }
  .mobile-tab button { border: 0; background: transparent; border-radius: 0; font-size: 11.5px; display: grid; place-items: center; color: var(--muted); letter-spacing: .04em; box-shadow: none; }
  .mobile-tab button.active { color: var(--acc); font-weight: 650; background: transparent; }
  .mobile-tab button.active::before { content: ""; position: absolute; }
  .savebar { bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
}
@media (max-width: 420px) {
  .kpi .value { font-size: 15.5px; }
  .hero-stats .hs .s { display: none; }
}
