/* Customer-facing app and sign-in. Brand tokens live in base.css. */
:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --card: #ffffff;
  --card-2: #f7f9fd;
  --text: #0b1733;
  --text-2: #3c4a66;
  --text-3: #64728c;
  --border: #e3e8f2;
  --grid: #edf1f7;
  --axis: #c9d4e8;
  --field: #ffffff;
  --series-fx: #2a78d6;
  --series-cr: #eb6834;
  --gain: #2a78d6;
  --loss: #e34948;
  --good-text: #0f7a3d;
  --bad-text: #c02f2f;
  --warn-bg: #fff7e6;
  --warn-text: #8a5a00;
  --accent-soft: #eaf1ff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #060d20;
    --card: #0d1830;
    --card-2: #111e3a;
    --text: #eef3ff;
    --text-2: #c3cee6;
    --text-3: #8d9cbc;
    --border: #1c2a4a;
    --grid: #172441;
    --axis: #2a3b60;
    --field: #0a1428;
    --series-fx: #3987e5;
    --series-cr: #d95926;
    --gain: #3987e5;
    --loss: #e66767;
    --good-text: #4ade80;
    --bad-text: #f87171;
    --warn-bg: #2b2210;
    --warn-text: #fcd58a;
    --accent-soft: #14244a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #060d20;
  --card: #0d1830;
  --card-2: #111e3a;
  --text: #eef3ff;
  --text-2: #c3cee6;
  --text-3: #8d9cbc;
  --border: #1c2a4a;
  --grid: #172441;
  --axis: #2a3b60;
  --field: #0a1428;
  --series-fx: #3987e5;
  --series-cr: #d95926;
  --gain: #3987e5;
  --loss: #e66767;
  --good-text: #4ade80;
  --bad-text: #f87171;
  --warn-bg: #2b2210;
  --warn-text: #fcd58a;
  --accent-soft: #14244a;
}

body { background: var(--bg); color: var(--text); }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--good-text); }
.neg { color: var(--bad-text); }

/* ---------- Forms (shared) ---------- */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.input, .select { width: 100%; min-height: 46px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--field); color: var(--text); font-size: 15px; transition: border-color .15s, box-shadow .15s; }
.input:focus, .select:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 4px rgba(59, 130, 246, .18); }
.input[aria-invalid="true"] { border-color: var(--bad-text); }
.hint { font-size: 12.5px; color: var(--text-3); }
.err-text { font-size: 12.5px; color: var(--bad-text); min-height: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--text-2); line-height: 1.5; margin: 6px 0 18px; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--blue-600); flex-shrink: 0; }
.check a { color: var(--blue-600); font-weight: 600; }
.btn-block { width: 100%; }

/* ---------- Sign-in ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { position: relative; overflow: hidden; background: radial-gradient(70% 60% at 70% 20%, rgba(37, 99, 235, .5), transparent 70%), var(--navy-950); color: #fff; padding: 40px 56px; display: flex; flex-direction: column; }
.auth-side .brand-mark { color: var(--blue-500); }
.auth-side h2 { font-family: var(--display); font-size: clamp(30px, 3vw, 42px); line-height: 1.1; letter-spacing: -1px; margin: auto 0 14px; max-width: 460px; }
.auth-side p { color: #b9c8e6; font-size: 16px; line-height: 1.65; max-width: 440px; margin: 0; }
.auth-side > :not(.tech-bg) { position: relative; z-index: 1; }
.auth-side h2 { text-shadow: 0 2px 24px rgba(4, 11, 28, .8); }


.auth-foot { font-size: 12.5px; color: #7f93bb; line-height: 1.6; margin-top: auto; padding-top: 24px; border-top: 1px solid rgba(255, 255, 255, .1); }
.auth-main { display: flex; flex-direction: column; padding: 32px 24px; }
.auth-top { display: flex; justify-content: space-between; align-items: center; width: 100%; max-width: 440px; margin: 0 auto; font-size: 14px; color: var(--text-3); }
.auth-top a:hover { color: var(--text); }
.auth-top .brand { display: none; color: var(--text); }
.auth-card { width: 100%; max-width: 440px; margin: auto; padding: 36px 0; }
.auth-card h1 { font-family: var(--display); font-size: 30px; letter-spacing: -.8px; margin: 0 0 6px; }
.auth-card > p { color: var(--text-3); margin: 0 0 28px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--card-2); border: 1px solid var(--border); border-radius: 12px; padding: 4px; margin-bottom: 28px; }
.seg button { border: 0; background: transparent; min-height: 40px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--text-3); cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(11, 23, 51, .12); }
.row-between { display: flex; justify-content: space-between; align-items: center; margin: -4px 0 20px; font-size: 13.5px; }
.row-between a { color: var(--blue-600); font-weight: 600; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 12.5px; margin: 22px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.demo-link { text-align: center; font-size: 14px; color: var(--text-3); }
.demo-link a { color: var(--blue-600); font-weight: 600; }
.auth-note { margin-top: 18px; font-size: 12.5px; color: var(--text-3); text-align: center; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100vh; height: 100dvh; background: var(--navy-950); color: #c7d4ee; display: flex; flex-direction: column; padding: 22px 16px; border-right: 1px solid rgba(255, 255, 255, .06); }
.sidebar .brand { color: #fff; padding: 0 8px 24px; }
.sidebar .brand-mark { color: var(--blue-500); }
.side-nav { display: grid; gap: 2px; }
.side-label { font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: #6d80a8; padding: 18px 12px 8px; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; font-size: 14.5px; font-weight: 500; transition: background .15s, color .15s; }
.side-nav a svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.side-nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.side-nav a[aria-current="page"] { background: rgba(59, 130, 246, .18); color: #fff; }
.side-nav a[aria-current="page"] svg { stroke: #93c5fd; opacity: 1; }
.side-card { margin-top: auto; background: linear-gradient(160deg, rgba(37, 99, 235, .35), rgba(37, 99, 235, .08)); border: 1px solid rgba(96, 165, 250, .25); border-radius: 14px; padding: 16px; font-size: 13px; line-height: 1.55; }
.side-card b { display: block; color: #fff; font-size: 14px; margin-bottom: 4px; }
.side-card a { display: inline-block; margin-top: 10px; color: #93c5fd; font-weight: 600; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; height: 68px; padding: 0 32px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.topbar h1 { font-family: var(--display); font-size: 20px; letter-spacing: -.4px; margin: 0; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--card); cursor: pointer; color: var(--text-2); }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .badge { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--blue-500); box-shadow: 0 0 0 2px var(--card); }
.avatar { display: flex; align-items: center; gap: 10px; padding: 4px 12px 4px 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); cursor: pointer; font-size: 14px; font-weight: 600; }
.avatar i { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--blue-500), var(--navy-700)); color: #fff; font-style: normal; font-size: 13px; }
.menu-btn { display: none; }

.preview-banner { display: flex; align-items: center; gap: 12px; margin: 20px 32px 0; padding: 12px 16px; border-radius: 12px; background: var(--warn-bg); color: var(--warn-text); font-size: 13.5px; line-height: 1.5; }
.preview-banner svg { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.preview-banner b { font-weight: 700; }

.content { padding: 24px 32px 48px; display: grid; gap: 20px; align-content: start; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head h2 { font-family: var(--display); font-size: 26px; letter-spacing: -.6px; margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--text-3); font-size: 14.5px; }

.grid { display: grid; gap: 20px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 22px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h3 { font-size: 16px; margin: 0; letter-spacing: -.1px; }
.card-head p { margin: 2px 0 0; font-size: 13px; color: var(--text-3); }
.card-link { font-size: 13.5px; font-weight: 600; color: var(--blue-600); background: none; border: 0; cursor: pointer; padding: 0; }

.stat small { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-3); font-weight: 500; }
.stat .v { font-family: var(--display); font-size: 28px; font-weight: 700; letter-spacing: -.8px; margin: 6px 0 4px; }
.stat .d { font-size: 13px; font-weight: 600; }
.stat .d span { color: var(--text-3); font-weight: 400; }

/* Segmented control */
.segmented { display: inline-flex; background: var(--card-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.segmented button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--text-3); cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(11, 23, 51, .12); }

/* Charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--series-fx); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--series-fx); opacity: .1; }
.chart .cross { stroke: var(--axis); stroke-width: 1; }
.chart .marker { fill: var(--series-fx); stroke: var(--card); stroke-width: 2; }
.chart .bar-gain { fill: var(--gain); }
.chart .bar-loss { fill: var(--loss); }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .bar-hit { fill: transparent; }
.chart .bar-hit:hover + .bar-mark, .chart .bar-mark.active { opacity: .75; }
.tip { position: absolute; pointer-events: none; z-index: 5; background: var(--navy-950); color: #fff; border-radius: 10px; padding: 8px 11px; font-size: 12.5px; line-height: 1.45; white-space: nowrap; box-shadow: 0 8px 24px rgba(4, 11, 28, .3); opacity: 0; transform: translate(-50%, calc(-100% - 12px)); transition: opacity .12s; }
.tip.show { opacity: 1; }
.tip b { font-variant-numeric: tabular-nums; }
.tip small { color: #9fb3d9; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.l-gain { background: var(--gain); }
.l-loss { background: var(--loss); }
.l-fx { background: var(--series-fx); }
.l-cr { background: var(--series-cr); }

/* Allocation split */
.split { display: flex; height: 14px; gap: 2px; border-radius: 999px; overflow: hidden; margin: 6px 0 18px; }
.split i { display: block; height: 100%; }
.split i:first-child { background: var(--series-fx); }
.split i:last-child { background: var(--series-cr); }
.alloc-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.alloc-row .sw { width: 10px; height: 10px; border-radius: 3px; }
.alloc-row div { flex: 1; min-width: 0; }
.alloc-row b { display: block; font-size: 14.5px; }
.alloc-row small { color: var(--text-3); font-size: 12.5px; }
.alloc-row .pct { font-weight: 700; font-size: 15px; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -22px -22px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .6px; padding: 10px 22px; border-bottom: 1px solid var(--border); background: var(--card-2); white-space: nowrap; }
td { padding: 13px 22px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
.t-main { font-weight: 600; }
.t-sub { display: block; font-size: 12.5px; color: var(--text-3); font-weight: 400; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 999px; background: var(--card-2); color: var(--text-2); border: 1px solid var(--border); }
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.ok { color: var(--good-text); }
.chip.pending { color: var(--warn-text); }
.chip.fx::before { background: var(--series-fx); }
.chip.cr::before { background: var(--series-cr); }
.chip.fx, .chip.cr { color: var(--text-2); }

/* Strategy cards */
.strategy { display: grid; grid-template-columns: 140px 1fr; gap: 20px; }
.strategy img { width: 140px; aspect-ratio: 1; object-fit: cover; border-radius: 12px; background: #eef2f9; }
.strategy h3 { font-family: var(--display); font-size: 22px; letter-spacing: -.4px; margin: 4px 0 2px; }
.strategy .sub { font-size: 11.5px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--blue-600); }
.strategy p { font-size: 14px; color: var(--text-3); line-height: 1.6; margin: 10px 0 0; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-top: 18px; }
.kv div { background: var(--card); padding: 12px 14px; }
.kv small { display: block; font-size: 12px; color: var(--text-3); }
.kv b { font-size: 16px; font-variant-numeric: tabular-nums; }
.range { width: 100%; accent-color: var(--blue-600); margin: 8px 0 4px; }
.range-labels { display: flex; justify-content: space-between; font-size: 13.5px; font-weight: 600; }

/* Info blocks */
.info { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px; background: var(--accent-soft); color: var(--text-2); font-size: 13.5px; line-height: 1.6; }
.info svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px; fill: none; stroke: var(--blue-500); stroke-width: 2; stroke-linecap: round; }
.calc { display: grid; gap: 0; font-size: 14px; }
.calc div { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px dashed var(--border); }
.calc div:last-child { border-bottom: 0; font-weight: 700; }
.calc span:last-child { font-variant-numeric: tabular-nums; }

/* Referral */
.ref-link { display: flex; gap: 8px; }
.ref-link .input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px; }

/* Settings */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; border-top: 1px solid var(--border); }
.set-row:first-of-type { border-top: 0; padding-top: 0; }
.set-row b { display: block; font-size: 14.5px; }
.set-row small { color: var(--text-3); font-size: 13px; }
.switch { position: relative; width: 44px; height: 26px; flex-shrink: 0; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--axis); transition: background .15s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .15s; }
.switch input:checked + span { background: var(--blue-600); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 3px solid var(--blue-500); outline-offset: 2px; }

.empty { text-align: center; padding: 28px 12px; color: var(--text-3); font-size: 14px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--navy-950); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.scrim { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-top .brand { display: inline-flex; }

  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; width: 272px; transform: translateX(-100%); transition: transform .22s ease; }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(4, 11, 28, .5); }
  .menu-btn { display: grid; }
  .g-3, .g-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { padding: 0 16px; height: 60px; }
  .avatar span { display: none; }
  .avatar { padding: 4px; }
  .preview-banner { margin: 14px 16px 0; }
  .content { padding: 18px 16px 40px; gap: 16px; }
  .grid { gap: 16px; }
  .g-4 { grid-template-columns: 1fr 1fr; gap: 12px; }
  .card { padding: 18px; border-radius: 14px; }
  .table-wrap { margin: 0 -18px -18px; }
  th, td { padding-inline: 18px; }
  .stat .v { font-size: 22px; }
  .strategy { grid-template-columns: 1fr; }
  .strategy img { width: 100%; aspect-ratio: 16 / 9; }
  .kv b { font-size: 14.5px; }
  .ref-link { flex-direction: column; }
}
