:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --green: #10b981;
  --green-soft: #ecfdf5;
  --amber: #f59e0b;
  --amber-soft: #fffbeb;
  --red: #ef4444;
  --red-soft: #fef2f2;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden { display: none !important; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.wrap { max-width: 1360px; margin: 0 auto; padding: 14px 18px 40px; }

/* Topbar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 1360px;
  margin: 0 auto;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.brand-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.brand { font-size: 17px; letter-spacing: -0.01em; }
.pill {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.pill-placeholder { background: var(--amber-soft); color: #b45309; border: 1px solid #fde68a; }
.pill-verified { background: var(--green-soft); color: #047857; border: 1px solid #a7f3d0; }
.seed-box select { border: none; outline: none; font-size: 13px; font-weight: 600; background: transparent; color: var(--text); cursor: pointer; }
.mode-desc { margin: 10px auto 0; max-width: 720px; font-size: 13px; color: #334155; background: var(--surface); border: 1px solid var(--border); padding: 8px 12px; border-radius: 8px; }
.calendar-pill { font-weight: 700; font-size: 13px; padding: 3px 10px; border-radius: 999px; background: #f1f5f9; color: #0f172a; border: 1px solid #cbd5e1; }
.hist-card {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px solid #fcd34d;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.hist-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: #92400e; margin-bottom: 4px; flex-wrap: wrap; }
.hist-card-title { font-size: 14px; font-weight: 700; color: #78350f; margin: 0 0 4px; }
.hist-card-body { font-size: 12px; color: #78350f; margin: 0 0 4px; line-height: 1.45; }
.hist-card-src { font-size: 11px; color: #b45309; }
.disclaimer { font-size: 12px; color: var(--muted); }
.top-actions { display: flex; gap: 8px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--surface-alt); border-color: #cbd5e1; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #e2e8f0; color: var(--text); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin: 0; font-size: 16px; }
.card-head .sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.card-head.compact { margin-bottom: 8px; align-items: center; }

/* Lobby */
.lobby-hero {
  text-align: center;
  max-width: 780px;
  margin: 18px auto 22px;
}
.lobby-hero h1 { margin: 0 0 8px; font-size: 26px; }
.lobby-hero p { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.lobby-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.seed-box {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 13px;
}
.seed-box input {
  width: 84px;
  border: none;
  outline: none;
  font-size: 14px;
  font-weight: 600;
  text-align: right;
}

.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}
.char-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all 0.16s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.char-card:hover { border-color: #93c5fd; transform: translateY(-2px); }
.char-card.selected {
  border-color: var(--primary);
  background: #f8fbff;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.12);
}
.char-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.char-name { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.char-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.char-badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-alt); border: 1px solid var(--border); font-weight: 600; }
.char-meta { font-size: 12px; color: var(--muted); }
.char-tagline { font-size: 13px; color: #334155; margin: 0; }
.char-bars { display: grid; gap: 5px; }
.mini-bar-row { display: grid; grid-template-columns: 64px 1fr 34px; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.mini-bar-track { height: 6px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.mini-bar-fill { height: 100%; border-radius: 999px; }
.char-fin {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  color: #334155;
}

/* Dashboard Status Strip */
.status-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.status-left, .status-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.char-pill { font-weight: 700; font-size: 14px; padding: 3px 10px; border-radius: 999px; background: var(--primary-soft); color: #1d4ed8; }
.age-pill { font-weight: 700; font-size: 14px; padding: 3px 10px; border-radius: 999px; background: var(--surface-alt); border: 1px solid var(--border); }
.regime-pill { font-weight: 700; font-size: 13px; padding: 3px 10px; border-radius: 999px; color: #fff; }

/* Main Grid */
.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 1fr);
  gap: 14px;
  align-items: start;
}
.col-left, .col-right { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* Segmented Toggle */
.seg-toggle { display: inline-flex; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.seg-btn { border: none; background: transparent; padding: 4px 10px; font-size: 12px; font-weight: 600; border-radius: 6px; cursor: pointer; color: var(--muted); }
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

/* Preview & Warnings (fixed height preview bar prevents hover layout shift!) */
.preview-banner {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
  min-height: 36px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.preview-banner.active {
  background: var(--primary-soft);
  border-color: #93c5fd;
  color: #1e40af;
}
.nudge-banner {
  background: #eff6ff;
  border: 1px solid #93c5fd;
  color: #1e40af;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 10px;
}
.card-nudge {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Insurance & Lifestyle & Direct Trade */
.ins-tier-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.ins-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  text-align: left;
  cursor: pointer;
  font-size: 11px;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.ins-btn:hover { border-color: #93c5fd; }
.ins-btn.active { border-color: #10b981; background: #ecfdf5; }
.ins-btn strong { display: block; font-size: 12px; color: var(--text); }
.ins-btn span { color: var(--muted); }

.trade-tabs {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  margin-bottom: 8px;
}
.trade-form { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.trade-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.trade-select, .trade-input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
}
.trade-input { width: 120px; }
.quick-amts { display: flex; gap: 4px; flex-wrap: wrap; }

.lifestyle-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.lifestyle-icon { font-size: 26px; line-height: 1; }
.lifestyle-info { flex: 1; min-width: 0; }
.lifestyle-title { font-size: 13px; font-weight: 700; display: flex; justify-content: space-between; gap: 8px; }
.lifestyle-perks { font-size: 12px; color: #334155; margin-top: 2px; }
.lifestyle-effect { font-size: 11px; color: var(--muted); margin-top: 2px; }

.transition-hero {
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}
.transition-hero h2 { margin: 0 0 4px; font-size: 17px; color: #1e3a8a; }
.transition-hero p { margin: 0; font-size: 13px; color: #334155; }

/* Macro quantitative strip, Strategy Presets, Real Estate Box & Left Pulse */
.macro-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.macro-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: #334155;
  font-variant-numeric: tabular-nums;
}
.macro-pill strong { color: var(--text); }
.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.preset-btn {
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: var(--surface);
  color: #334155;
  cursor: pointer;
}
.preset-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.preset-btn.custom { border-color: #10b981; color: #047857; background: #ecfdf5; }

.home-box {
  background: #fffbeb;
  border-color: #fde68a;
}
.home-offer-box {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff;
  border: 1.5px solid #f59e0b;
  font-size: 12px;
}
.lifestyle-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
}
.life-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}
@keyframes leftPulse {
  0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.32); border-color: #3b82f6; }
  60% { box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.08); border-color: #60a5fa; }
  100% { box-shadow: var(--shadow); border-color: var(--border); }
}
.act-pulse {
  animation: leftPulse 1.1s ease;
}

/* ---- GAME FEEL & KINETIC FX ---- */
/* Flowing cashflow stream inside Sankey */
.sk-stream {
  stroke-dasharray: 6 12;
  stroke-linecap: round;
  animation: flowDash 1.9s linear infinite;
}
@keyframes flowDash {
  from { stroke-dashoffset: 36; }
  to { stroke-dashoffset: 0; }
}

/* Macro Mood Atmosphere on Body */
body { transition: background 0.55s ease; }
body[data-regime="boom"] {
  background: linear-gradient(180deg, #fffbeb 0%, #f4f6f9 260px);
}
body[data-regime="recession"], body[data-regime="tightening"] {
  background: linear-gradient(180deg, #fee2e2 0%, #eef2f6 240px);
}
body[data-regime="lowrate"] {
  background: linear-gradient(180deg, #e2e8f0 0%, #f4f6f9 240px);
}
body[data-regime="expansion"], body[data-regime="recovery"] {
  background: linear-gradient(180deg, #ecfdf5 0%, #f4f6f9 240px);
}

/* Boom Gold Shimmer & Recession Hit Shake */
@keyframes hitShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}
.fx-shake {
  animation: hitShake 0.42s ease;
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18) !important;
}
@keyframes boomGlow {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.45); border-color: #f59e0b; }
  50% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0.16); border-color: #10b981; }
  100% { box-shadow: var(--shadow); border-color: var(--border); }
}
.fx-boom-glow {
  animation: boomGlow 1.1s ease;
}

/* Floating +X万 / -X万 Pop-up Badge */
.kpi-box { position: relative; }
.fx-float-num {
  position: absolute;
  top: -8px;
  right: 10px;
  font-size: 13px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  pointer-events: none;
  z-index: 15;
  animation: floatUpFade 1.8s ease forwards;
}
.fx-float-num.pos { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.fx-float-num.neg { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
@keyframes floatUpFade {
  0% { opacity: 0; transform: translateY(8px) scale(0.92); }
  18% { opacity: 1; transform: translateY(-4px) scale(1.04); }
  80% { opacity: 1; transform: translateY(-16px) scale(1); }
  100% { opacity: 0; transform: translateY(-26px) scale(0.96); }
}

/* Floating Action Receipt Toast */
.fx-toast {
  position: fixed;
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: #0f172a;
  color: #f8fafc;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.28);
  max-width: min(560px, calc(100vw - 32px));
  animation: toastDrop 0.22s ease;
}
.fx-toast.pos { background: #065f46; }
.fx-toast.neg { background: #991b1b; }
@keyframes toastDrop {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Concrete Change Receipt List inside Settlement */
.change-receipt {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 0 0 12px;
  font-size: 12px;
}
.change-receipt ul { margin: 4px 0 0; padding-left: 16px; }
.change-receipt li { margin-bottom: 3px; color: #1e293b; }
.change-receipt li.warn { color: #b45309; font-weight: 600; }
.change-receipt li.ok { color: #047857; font-weight: 600; }

/* ---- LIFE HAPPINESS BANNER, NPC GUIDE, LOAN BAR & PRICE CHART ---- */
.life-atm-banner {
  margin-bottom: 10px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
  border-left: 5px solid #10b981;
}
.life-atm-main { flex: 1; min-width: 260px; }
.life-atm-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.life-atm-score { font-size: 16px; font-weight: 800; }
.life-atm-text { font-size: 13px; color: #334155; margin: 0; }

.npc-guide-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  border: 2px solid #38bdf8;
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.22);
  color: #f8fafc;
}
.npc-guide-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 240px; }
.npc-avatar-circle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid #38bdf8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.35);
}
.npc-nameplate {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  padding: 1px 8px;
  border-radius: 999px;
  background: #38bdf8;
  color: #0f172a;
  margin-bottom: 3px;
}
.npc-guide-msg { font-size: 13px; color: #e2e8f0; line-height: 1.5; }
.npc-guide-msg strong { color: #ffffff; }
.npc-guide-actions { display: flex; gap: 6px; align-items: center; }

/* Commercial Pension Card */
.pension-box {
  background: linear-gradient(135deg, #f0fdfa 0%, #eff6ff 100%);
  border-color: #99f6e4;
}
.pension-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* Dramatic 2.4s Market Reveal Overlay */
.reveal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.reveal-card {
  background: #0f172a;
  color: #f8fafc;
  border: 2px solid #38bdf8;
  border-radius: 18px;
  padding: 22px 24px;
  max-width: 560px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  animation: popIn 0.28s ease;
}
.reveal-title { font-size: 20px; font-weight: 800; margin: 0 0 6px; }
.reveal-sub { font-size: 13px; color: #94a3b8; margin: 0 0 14px; }
.reveal-tickers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.reveal-pill {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 8px 10px;
  text-align: center;
}
.reveal-pill .r-name { font-size: 11px; color: #94a3b8; }
.reveal-pill .r-val { font-size: 16px; font-weight: 800; margin-top: 2px; }
.reveal-pill .r-val.up { color: #34d399; }
.reveal-pill .r-val.down { color: #f87171; }
.reveal-bar-track { height: 5px; background: #1e293b; border-radius: 999px; overflow: hidden; margin-bottom: 10px; }
.reveal-bar-fill { height: 100%; background: #38bdf8; width: 0%; transition: width 2.3s linear; }

.spotlight-glow {
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.28) !important;
  border-color: #2563eb !important;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.loan-bar {
  background: #fef2f2;
  border: 1.5px solid #fca5a5;
  border-radius: 10px;
  padding: 9px 12px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: #991b1b;
}
.price-chart-svg { width: 100%; height: auto; display: block; background: #ffffff; border: 1px solid var(--border); border-radius: 8px; }
.npc-event-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}
.warning-strip { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.warning-item {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
}
.warning-item.danger { background: var(--red-soft); color: #b91c1c; border: 1px solid #fecaca; }
.warning-item.warn { background: var(--amber-soft); color: #b45309; border: 1px solid #fde68a; }

/* Sankey */
.sankey-host {
  width: 100%;
  background: #fafcff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 4px;
  overflow: hidden;
}
.sankey-svg { width: 100%; height: auto; display: block; }
.sk-label { font-size: 12px; font-weight: 600; fill: #334155; }
.sk-val { font-size: 12px; font-weight: 700; fill: #0f172a; }
.sk-delta { font-size: 11px; font-weight: 700; fill: #2563eb; }
.sk-mid-title { font-size: 12px; font-weight: 700; fill: #1e293b; }

/* KPI Row & Buffer Tank */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.kpi-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}
.kpi-label { font-size: 11px; color: var(--muted); }
.kpi-val { font-size: 17px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.kpi-val.pos { color: #059669; }
.kpi-val.neg { color: #dc2626; }
.tank-track { height: 7px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin-top: 6px; }
.tank-fill { height: 100%; border-radius: 999px; transition: width 0.25s ease; }

/* Portfolio & Sliders */
.rebal-rule-box { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.rebal-rule-box select { padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border); font-size: 12px; background: var(--surface); }

.alloc-bar {
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: #e2e8f0;
  margin-bottom: 10px;
}
.alloc-seg { height: 100%; transition: width 0.25s ease; }

.asset-chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.asset-chip {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.asset-chip:hover { border-color: var(--primary); }
.asset-chip-head { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.asset-chip-val { font-size: 14px; font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; }
.asset-chip-pct { font-size: 11px; color: var(--muted); }

.control-block {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.control-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.control-block input[type="range"] { width: 100%; }
.control-foot { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 2px; }

.alloc-details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  padding: 6px 0;
}
.alloc-sliders { display: grid; gap: 8px; margin: 10px 0; }
.alloc-slider-row {
  display: grid;
  grid-template-columns: 116px 1fr 44px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.rebal-preview {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  margin-bottom: 8px;
}
.rebal-actions { display: flex; gap: 8px; }

/* Auto-flow progress & Event Card */
.flow-progress {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
}
.flow-progress-bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  background: rgba(37, 99, 235, 0.12);
  transition: width 0.2s linear;
}
.flow-progress span { position: relative; z-index: 1; font-weight: 600; }

.event-card { border-top: 4px solid var(--primary); animation: popIn 0.22s ease; }
@keyframes popIn {
  from { opacity: 0.4; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.event-tags { display: flex; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-alt); border: 1px solid var(--border); }
.tag-life { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }
.tag-market { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.event-title { margin: 0 0 8px; font-size: 18px; }
.event-scene { margin: 0 0 10px; font-size: 14px; color: #1e293b; }
.news-ticker {
  background: var(--surface-alt);
  border-left: 3px solid var(--amber);
  padding: 6px 10px;
  border-radius: 0 6px 6px 0;
  font-size: 12px;
  color: #475569;
  margin-bottom: 12px;
}

.advisor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.advisor-bubble {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
}
.advisor-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.advisor-name { font-weight: 700; color: var(--text); }
.advisor-stars { color: #f59e0b; font-size: 11px; letter-spacing: 1px; }
.advisor-quote { margin: 0; color: #334155; line-height: 1.4; }

.option-list { display: flex; flex-direction: column; gap: 8px; }
.option-btn {
  text-align: left;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.14s ease;
}
.option-btn:hover, .option-btn:focus-visible {
  border-color: var(--primary);
  background: var(--primary-soft);
  outline: none;
}
.option-title { font-size: 14px; font-weight: 700; color: var(--text); }
.option-hint { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* Settlement Attribution */
.settlement-card { border-left: 4px solid var(--green); }
.attr-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.attr-row {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
}
.attr-top { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 3px; }
.attr-factors { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0; }
.f-chip { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: #e2e8f0; color: #334155; }
.attr-reason { color: #475569; margin: 0; }

/* Timeline */
.timeline-list { display: flex; flex-direction: column; gap: 8px; max-height: 240px; overflow-y: auto; }
.tl-item {
  border-left: 3px solid var(--border);
  padding: 4px 0 4px 10px;
  font-size: 12px;
}
.tl-head { display: flex; justify-content: space-between; font-weight: 600; }
.tl-sub { color: var(--muted); margin-top: 2px; }

/* Modals */
.modal {
  border: none;
  border-radius: 14px;
  padding: 0;
  max-width: 520px;
  width: calc(100% - 28px);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}
.modal-wide { max-width: 680px; }
.modal-xl { max-width: 860px; }
.modal::backdrop { background: rgba(15, 23, 42, 0.45); }

/* L3 Knowledge Pill & Comparison Tabs */
.k-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.k-trigger:hover { background: #dcfce7; }
.tab-bar { display: flex; gap: 6px; border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.tab-btn { border: 1px solid var(--border); background: var(--surface-alt); padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted); }
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.compare-svg { width: 100%; height: auto; background: #fafcff; border: 1px solid var(--border); border-radius: 10px; }
.legend-row { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; margin: 8px 0; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.robot-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; }
.robot-table th, .robot-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.robot-table th { background: var(--surface-alt); color: var(--muted); font-weight: 600; }
.fork-item { background: var(--surface-alt); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; font-size: 12px; }
.code-area { width: 100%; min-height: 70px; font-family: ui-monospace, monospace; font-size: 11px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; resize: vertical; }
.k-card-item { background: var(--surface-alt); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.k-card-item h4 { margin: 0 0 4px; font-size: 14px; color: var(--text); }
.k-card-item p { margin: 0 0 4px; font-size: 12px; color: #334155; }
.modal-body { padding: 18px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.tuning-grid { display: grid; gap: 12px; margin-bottom: 12px; }
.tuning-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }

.check-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  margin-bottom: 6px;
  font-size: 13px;
}
.badge-ok { color: #059669; font-weight: 700; }
.badge-fail { color: #dc2626; font-weight: 700; }

.ledger-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.ledger-col {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
}
.ledger-col h4 { margin: 0 0 6px; font-size: 12px; color: var(--muted); }
.ledger-row { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed #e2e8f0; }
.ledger-row.total { border-bottom: none; border-top: 1.5px solid #cbd5e1; margin-top: 4px; padding-top: 5px; font-weight: 700; }
@media (max-width: 640px) { .ledger-grid { grid-template-columns: 1fr; } }

@media (max-width: 980px) {
  .main-grid { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ins-tier-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .advisor-grid { grid-template-columns: 1fr; }
  .wrap { padding: 10px 12px 32px; }
}
