:root {
      color-scheme: light;
      --app:#f7f7f4;
      --rail:#f0f0ed;
      --panel:#ffffff;
      --panel-soft:#f7f7f5;
      --panel-hover:#ecece8;
      --text:#171717;
      --muted:#676764;
      --soft:#8c8c88;
      --line:#dfdfd8;
      --line-soft:#ecece7;
      --accent:#10a37f;
      --accent-strong:#087a5f;
      --accent-soft:#e5f4ee;
      --danger:#d24a4a;
      --danger-soft:#fae7e7;
      --warn:#a76f26;
      --warn-soft:#f7ecd9;
      --shadow:0 1px 2px rgba(0,0,0,.04);
    }
    :root[data-theme="dark"] {
      color-scheme: dark;
      --app:#212121;
      --rail:#171717;
      --panel:#2f2f2f;
      --panel-soft:#262626;
      --panel-hover:#383838;
      --text:#ececec;
      --muted:#c7c7c7;
      --soft:#9b9b9b;
      --line:#3f3f3f;
      --line-soft:#3a3a3a;
      --accent:#10a37f;
      --accent-strong:#42d8b2;
      --accent-soft:#17372f;
      --danger:#ff7777;
      --danger-soft:#402222;
      --warn:#e3b86c;
      --warn-soft:#3a2b17;
      --shadow:0 1px 2px rgba(0,0,0,.22);
    }
    * { box-sizing:border-box; }
    body {
      margin:0;
      min-height:100vh;
      background:var(--app);
      color:var(--text);
      font-family:ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      -webkit-font-smoothing:antialiased;
      letter-spacing:0;
    }
    button, input, select, textarea { font:inherit; letter-spacing:0; }
    .app-shell {
      min-height:100vh;
      display:grid;
      grid-template-columns:292px minmax(0, 1fr);
    }
    .sidebar {
      min-width:0;
      background:var(--rail);
      border-right:1px solid var(--line);
      display:flex;
      flex-direction:column;
      padding:12px;
      gap:12px;
      position:sticky;
      top:0;
      height:100vh;
    }
    .brand {
      height:38px;
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:10px;
      padding:0 4px;
    }
    .brand-left {
      display:flex;
      align-items:center;
      gap:10px;
      min-width:0;
    }
    .logo {
      width:30px;
      height:30px;
      border-radius:8px;
      display:grid;
      place-items:center;
      background:var(--text);
      color:var(--app);
      font-weight:800;
      font-size:14px;
      flex:0 0 auto;
    }
    .brand-title {
      font-size:14px;
      font-weight:700;
      color:var(--text);
      white-space:nowrap;
      overflow:hidden;
      text-overflow:ellipsis;
    }
    .icon-btn {
      width:32px;
      height:32px;
      border:0;
      border-radius:8px;
      background:transparent;
      color:var(--muted);
      display:grid;
      place-items:center;
      cursor:pointer;
    }
    .icon-btn:hover { background:var(--panel-hover); color:var(--text); }
    svg { width:17px; height:17px; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; fill:none; }
    .nav-tools {
      display:flex;
      gap:8px;
      padding:0 4px;
    }
    .quiet-btn {
      border:1px solid var(--line);
      background:var(--panel);
      color:var(--text);
      border-radius:8px;
      min-height:36px;
      padding:0 11px;
      display:inline-flex;
      align-items:center;
      justify-content:center;
      gap:8px;
      font-size:13px;
      font-weight:600;
      text-decoration:none;
      cursor:pointer;
    }
    .quiet-btn:hover { background:var(--panel-hover); }
    .quiet-btn.fill { flex:1 1 auto; }
    .strategy-list {
      display:flex;
      flex-direction:column;
      gap:4px;
      overflow:auto;
      padding:4px 0;
      min-height:0;
    }
    .strategy-row {
      width:100%;
      border:0;
      background:transparent;
      color:var(--text);
      border-radius:8px;
      padding:10px;
      display:grid;
      grid-template-columns:minmax(0, 1fr) auto;
      gap:8px;
      text-align:left;
      cursor:pointer;
      min-height:62px;
    }
    .strategy-row:hover { background:var(--panel-hover); }
    .strategy-row.selected { background:var(--panel); box-shadow:var(--shadow); }
    .strategy-row.flash { box-shadow:0 0 0 2px color-mix(in srgb, var(--warn) 38%, transparent) inset; }
    .strategy-row.flash:hover { box-shadow:0 0 0 2px color-mix(in srgb, var(--warn) 38%, transparent) inset; }
    .row-title {
      font-size:13px;
      font-weight:650;
      line-height:1.25;
      white-space:nowrap;
      overflow:hidden;
      text-overflow:ellipsis;
    }
    .row-meta {
      margin-top:5px;
      display:flex;
      align-items:center;
      gap:6px;
      flex-wrap:wrap;
      color:var(--soft);
      font-size:11px;
      line-height:1.2;
    }
    .dot {
      width:7px;
      height:7px;
      border-radius:50%;
      background:var(--soft);
      display:inline-block;
      flex:0 0 auto;
    }
    .dot.green { background:var(--accent); box-shadow:0 0 14px color-mix(in srgb, var(--accent) 70%, transparent); }
    .dot.amber { background:var(--warn); box-shadow:0 0 14px color-mix(in srgb, var(--warn) 65%, transparent); }
    .dot.red { background:var(--danger); }
    .mini-pnl {
      color:var(--muted);
      font-size:12px;
      font-weight:650;
      white-space:nowrap;
      align-self:start;
      margin-top:1px;
    }
    .sidebar-footer {
      border-top:1px solid var(--line);
      padding:11px 4px 0;
      display:grid;
      gap:8px;
    }
    .status-line {
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:10px;
      color:var(--muted);
      font-size:12px;
    }
    .status-line strong { color:var(--text); font-weight:650; text-align:right; }
    .main {
      min-width:0;
      display:flex;
      flex-direction:column;
      min-height:100vh;
    }
    .topbar {
      min-height:58px;
      border-bottom:1px solid var(--line-soft);
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:14px;
      padding:0 22px;
      background:color-mix(in srgb, var(--app) 86%, transparent);
      backdrop-filter:blur(18px);
      position:sticky;
      top:0;
      z-index:20;
    }
    .crumb {
      min-width:0;
      display:flex;
      flex-direction:column;
      gap:2px;
    }
    .crumb span:first-child {
      color:var(--text);
      font-size:14px;
      font-weight:650;
      white-space:nowrap;
      overflow:hidden;
      text-overflow:ellipsis;
      max-width:55vw;
    }
    .crumb span:last-child {
      color:var(--soft);
      font-size:12px;
      white-space:nowrap;
      overflow:hidden;
      text-overflow:ellipsis;
    }
    .top-actions {
      display:flex;
      align-items:center;
      justify-content:flex-end;
      gap:8px;
      flex-wrap:wrap;
    }
    .live-toggle {
      border:1px solid var(--line);
      background:var(--panel);
      color:var(--muted);
      border-radius:999px;
      min-height:34px;
      padding:0 12px;
      display:inline-flex;
      align-items:center;
      gap:8px;
      cursor:pointer;
      font-size:13px;
      font-weight:650;
    }
    .live-toggle.live-mode {
      color:var(--accent-strong);
      background:var(--accent-soft);
      border-color:color-mix(in srgb, var(--accent) 40%, var(--line));
    }
    .live-toggle.virtual-mode {
      color:var(--text);
      background:var(--panel);
      border-color:var(--line);
    }
    .login-link {
      border:1px solid var(--line);
      background:var(--panel);
      color:var(--text);
      min-height:34px;
      border-radius:999px;
      padding:0 12px;
      text-decoration:none;
      display:inline-flex;
      align-items:center;
      gap:8px;
      font-size:13px;
      font-weight:650;
    }
    .workspace {
      width:100%;
      max-width:980px;
      margin:0 auto;
      padding:32px 22px 36px;
      flex:1;
    }
    .hero {
      margin:8px 0 24px;
    }
    h1 {
      margin:0;
      color:var(--text);
      font-size:34px;
      line-height:1.12;
      font-weight:700;
      letter-spacing:0;
    }
    .hero-sub {
      margin-top:10px;
      color:var(--muted);
      font-size:15px;
      line-height:1.55;
      max-width:720px;
    }
    .pill-row {
      display:flex;
      align-items:center;
      gap:8px;
      flex-wrap:wrap;
      margin-top:14px;
    }
    .pill {
      border:1px solid var(--line);
      background:var(--panel);
      color:var(--muted);
      border-radius:999px;
      padding:5px 10px;
      font-size:12px;
      font-weight:600;
    }
    .metrics {
      display:grid;
      grid-template-columns:repeat(5, minmax(0, 1fr));
      gap:10px;
      margin-bottom:22px;
    }
    .metric {
      border:1px solid var(--line);
      border-radius:8px;
      background:var(--panel);
      padding:13px;
      min-width:0;
      box-shadow:var(--shadow);
    }
    .metric span, .section-kicker {
      display:block;
      color:var(--soft);
      font-size:11px;
      font-weight:650;
      text-transform:uppercase;
      letter-spacing:0;
    }
    .metric strong {
      display:block;
      margin-top:8px;
      color:var(--text);
      font-size:16px;
      font-weight:700;
      line-height:1.15;
      overflow-wrap:anywhere;
    }
    .section {
      border:1px solid var(--line);
      background:var(--panel);
      border-radius:8px;
      box-shadow:var(--shadow);
      overflow:hidden;
      margin-bottom:14px;
    }
    .section-head {
      min-height:48px;
      padding:0 14px;
      border-bottom:1px solid var(--line-soft);
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:12px;
    }
    .section-title {
      font-size:14px;
      font-weight:680;
      color:var(--text);
    }
    .section-note {
      color:var(--soft);
      font-size:12px;
      white-space:nowrap;
    }
    .recon {
      display:grid;
      grid-template-columns:repeat(3, minmax(0, 1fr));
      gap:10px;
      padding:14px;
    }
    .soft-card {
      border:1px solid var(--line-soft);
      background:var(--panel-soft);
      border-radius:8px;
      padding:12px;
      min-width:0;
    }
    .soft-card span {
      display:block;
      color:var(--soft);
      font-size:11px;
      font-weight:650;
    }
    .soft-card strong {
      display:block;
      margin-top:6px;
      color:var(--text);
      font-size:15px;
      font-weight:700;
      overflow-wrap:anywhere;
    }
    .table-wrap { overflow:auto; }
    table {
      width:100%;
      border-collapse:collapse;
      min-width:760px;
    }
    th, td {
      padding:11px 14px;
      border-bottom:1px solid var(--line-soft);
      text-align:left;
      vertical-align:top;
      white-space:nowrap;
      font-size:13px;
      color:var(--muted);
    }
    th {
      color:var(--soft);
      font-size:11px;
      font-weight:650;
      text-transform:uppercase;
    }
    tr:last-child td { border-bottom:0; }
    .reconciliation-exception-row td { background:var(--warn-soft); }
    .instrument-cell {
      display:flex;
      align-items:center;
      gap:8px;
      color:var(--text);
      font-weight:650;
      flex-wrap:wrap;
    }
    .mini-line {
      display:block;
      width:100%;
      color:var(--soft);
      font-size:11px;
      font-weight:520;
      white-space:normal;
      line-height:1.35;
    }
    .reconcile-controls {
      display:flex;
      flex-wrap:wrap;
      gap:6px;
      min-width:98px;
    }
    .reconcile-controls span {
      width:100%;
      color:var(--soft);
      font-size:11px;
      font-weight:650;
    }
    .reconcile-action {
      border:1px solid var(--line);
      border-radius:8px;
      background:var(--panel);
      color:var(--muted);
      padding:5px 9px;
      font:inherit;
      font-size:12px;
      font-weight:650;
      cursor:pointer;
    }
    .reconcile-action.adopt {
      color:var(--accent-strong);
      background:var(--accent-soft);
      border-color:color-mix(in srgb, var(--accent) 36%, var(--line));
    }
    .reconcile-action.dismiss {
      color:var(--danger);
      background:var(--danger-soft);
      border-color:color-mix(in srgb, var(--danger) 34%, var(--line));
    }
    .reconcile-action[disabled] {
      opacity:.55;
      cursor:wait;
    }
    .side-pill {
      border-radius:999px;
      padding:3px 8px;
      font-size:11px;
      font-weight:650;
      border:1px solid var(--line);
    }
    .side-pill.buy { color:var(--accent-strong); background:var(--accent-soft); border-color:color-mix(in srgb, var(--accent) 38%, var(--line)); }
    .side-pill.sell { color:var(--danger); background:var(--danger-soft); border-color:color-mix(in srgb, var(--danger) 35%, var(--line)); }
    .price-stack { display:grid; gap:4px; }
    .price-row { display:flex; align-items:center; gap:8px; }
    .price-row span {
      width:45px;
      color:var(--soft);
      font-size:11px;
    }
    .price-row strong { color:var(--text); font-weight:650; }
    .empty {
      padding:32px 16px;
      color:var(--soft);
      text-align:center;
      font-size:14px;
    }
    .positive { color:var(--accent-strong) !important; }
    .negative { color:var(--danger) !important; }
    .neutral { color:var(--muted) !important; }
    .toast {
      position:fixed;
      right:20px;
      bottom:20px;
      background:var(--panel);
      border:1px solid var(--line);
      box-shadow:0 18px 50px rgba(0,0,0,.18);
      border-radius:8px;
      padding:12px 14px;
      max-width:340px;
      display:none;
      z-index:80;
      color:var(--text);
      font-size:13px;
      line-height:1.4;
    }
    .toast.show { display:block; }
    @media (max-width: 980px) {
      .app-shell { grid-template-columns:1fr; }
      .sidebar { position:relative; height:auto; border-right:0; border-bottom:1px solid var(--line); }
      .strategy-list { max-height:250px; }
      .metrics, .recon { grid-template-columns:1fr 1fr; }
    }
    @media (max-width: 680px) {
      .topbar { align-items:flex-start; flex-direction:column; padding:12px 16px; }
      .top-actions { justify-content:flex-start; }
      .workspace { padding:22px 16px 30px; }
      h1 { font-size:28px; }
      .metrics, .recon { grid-template-columns:1fr; }
      .quiet-btn.fill { flex:auto; }
    }
