/* ============================================================
     Design tokens — dark mode primary
     ============================================================ */
  :root[data-theme="dark"] {
    --bg-0: oklch(0.16 0.008 250);   /* top bar, deepest */
    --bg-1: oklch(0.19 0.008 250);   /* main canvas */
    --bg-2: oklch(0.22 0.009 250);   /* panel */
    --bg-3: oklch(0.26 0.010 250);   /* raised / hover */
    --bg-4: oklch(0.30 0.010 250);   /* active row */
    --border: oklch(0.30 0.008 250);
    --border-strong: oklch(0.38 0.010 250);
    --text: oklch(0.94 0.004 250);
    --text-2: oklch(0.72 0.008 250);
    --text-3: oklch(0.54 0.010 250);
    --text-4: oklch(0.42 0.010 250);

    --buy:  oklch(0.74 0.17 145);
    --buy-bg: oklch(0.38 0.09 145 / 0.35);
    --sell: oklch(0.68 0.22 25);
    --sell-bg: oklch(0.40 0.12 25 / 0.35);
    --warn: oklch(0.80 0.15 78);
    --warn-bg: oklch(0.42 0.08 78 / 0.35);
    --info: oklch(0.72 0.13 245);
    --info-bg: oklch(0.40 0.08 245 / 0.40);
    --neutral: oklch(0.62 0.01 250);

    --accent: oklch(0.68 0.12 245); /* firm primary */
    --accent-bg: oklch(0.36 0.08 245 / 0.40);
  }
  :root[data-theme="light"] {
    --bg-0: oklch(0.97 0.004 250);
    --bg-1: oklch(0.99 0.003 250);
    --bg-2: oklch(1 0 0);
    --bg-3: oklch(0.95 0.004 250);
    --bg-4: oklch(0.92 0.006 250);
    --border: oklch(0.88 0.006 250);
    --border-strong: oklch(0.80 0.008 250);
    --text: oklch(0.22 0.008 250);
    --text-2: oklch(0.42 0.010 250);
    --text-3: oklch(0.55 0.010 250);
    --text-4: oklch(0.68 0.008 250);

    --buy:  oklch(0.52 0.16 145);
    --buy-bg: oklch(0.88 0.08 145);
    --sell: oklch(0.54 0.20 25);
    --sell-bg: oklch(0.90 0.07 25);
    --warn: oklch(0.58 0.14 78);
    --warn-bg: oklch(0.92 0.08 78);
    --info: oklch(0.50 0.13 245);
    --info-bg: oklch(0.90 0.06 245);
    --neutral: oklch(0.55 0.01 250);

    --accent: oklch(0.50 0.14 245);
    --accent-bg: oklch(0.90 0.06 245);
  }

  * { box-sizing: border-box; }
  html, body {
    margin: 0; padding: 0;
    background: var(--bg-1);
    color: var(--text);
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
    font-size: 13px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "ss01", "cv11";
    overflow: hidden;
  }
  .mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-feature-settings: "tnum", "zero"; }

  /* ============================================================
     Shell — sidebar + content
     ============================================================ */
  .app {
    display: grid;
    grid-template-columns: var(--sidebar-w, 220px) 1fr;
    height: 100vh;
    width: 100vw;
    transition: grid-template-columns .18s ease;
  }
  .app.sidebar-collapsed { --sidebar-w: 64px; }
  .content {
    display: grid;
    grid-template-rows: 48px 1fr;
    min-height: 0;
    min-width: 0;
  }

  /* ============================================================
     Sidebar
     ============================================================ */
  .sidebar {
    background: var(--bg-0);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }
  .sb-top {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px;
    height: 48px;
    border-bottom: 1px solid var(--border);
  }
  .sb-brand {
    display: flex; align-items: center; gap: 10px;
    font-weight: 600; letter-spacing: 0.02em;
    font-size: 13px;
    color: var(--text);
    min-width: 0;
    overflow: hidden;
  }
  .sb-brand small { color: var(--text-3); font-weight: 400; }
  .sb-collapse {
    background: transparent; border: none;
    color: var(--text-3); cursor: pointer;
    width: 20px; height: 20px;
    display: grid; place-items: center;
    border-radius: 3px;
  }
  .sb-collapse:hover { color: var(--text); background: var(--bg-2); }
  .sb-collapse svg { width: 12px; height: 12px; }

  .sb-nav {
    flex: 1; overflow-y: auto;
    padding: 10px 8px;
    display: flex; flex-direction: column; gap: 1px;
    scrollbar-width: thin;
  }
  .sb-nav::-webkit-scrollbar { width: 4px; }
  .sb-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
  .sb-section {
    font-size: 9.5px; letter-spacing: 0.14em;
    color: var(--text-4); text-transform: uppercase;
    padding: 10px 10px 4px;
    font-weight: 600;
  }
  .sb-item {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 10px;
    border-radius: 5px;
    color: var(--text-2);
    font-size: 12.5px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    border-left: 2px solid transparent;
    position: relative;
  }
  .sb-item:hover { background: var(--bg-2); color: var(--text); }
  .sb-item.active {
    background: var(--bg-3);
    color: var(--text);
    border-left-color: var(--accent);
    padding-left: 8px;
  }
  .sb-item .sb-icon {
    width: 16px; height: 16px; flex: 0 0 16px;
    color: var(--text-3);
    display: grid; place-items: center;
  }
  .sb-item.active .sb-icon { color: var(--accent); }
  .sb-item .sb-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .sb-item .sb-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--text-3);
    background: var(--bg-3);
    padding: 1px 6px;
    border-radius: 3px;
  }
  .sb-item.active .sb-badge { color: var(--text); background: var(--accent-bg); }

  .app.sidebar-collapsed .sb-label,
  .app.sidebar-collapsed .sb-badge,
  .app.sidebar-collapsed .sb-section,
  .app.sidebar-collapsed .sb-brand span,
  .app.sidebar-collapsed .sb-user-meta,
  .app.sidebar-collapsed .sb-user-chev { display: none; }
  .app.sidebar-collapsed .sb-item { justify-content: center; padding: 8px 0; border-left: none; }
  .app.sidebar-collapsed .sb-item.active {
    background: var(--accent-bg);
    padding: 8px 0;
  }
  .app.sidebar-collapsed .sb-top { justify-content: center; padding: 12px 0; }
  .app.sidebar-collapsed .sb-brand { gap: 0; justify-content: center; }
  .app.sidebar-collapsed .sb-collapse { position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%); display: none; }

  .sb-footer {
    border-top: 1px solid var(--border);
    padding: 8px;
    position: relative;
  }
  .sb-user {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 8px;
    border-radius: 5px;
    cursor: pointer;
    color: var(--text-2);
  }
  .sb-user:hover { background: var(--bg-2); color: var(--text); }
  .sb-user-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--accent-bg);
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px; font-weight: 600;
    display: grid; place-items: center;
    flex: 0 0 28px;
    border: 1px solid var(--border);
  }
  .sb-user-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .sb-user-name { font-size: 12px; color: var(--text); font-weight: 500; line-height: 1.25; }
  .sb-user-role { font-size: 10.5px; color: var(--text-3); line-height: 1.25; }
  .sb-user-chev { width: 10px; height: 10px; color: var(--text-3); }

  .user-popover {
    position: absolute;
    left: 8px; right: 8px; bottom: calc(100% - 4px);
    background: var(--bg-2);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 4px;
    display: none;
    z-index: 60;
  }
  .user-popover.open { display: block; }
  .user-popover .pop-item {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 10px; border-radius: 4px;
    font-size: 12px; color: var(--text);
    cursor: pointer;
  }
  .user-popover .pop-item:hover { background: var(--bg-3); }
  .user-popover .pop-item.danger { color: var(--sell); }
  .user-popover .pop-sep { height: 1px; background: var(--border); margin: 4px 0; }

  /* ============================================================
     Top bar — slim (48px)
     ============================================================ */
  .topbar {
    background: var(--bg-0);
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 14px;
    gap: 16px;
    height: 48px;
  }
  .brand-mark {
    width: 18px; height: 18px;
    border: 1.5px solid var(--text);
    border-radius: 3px;
    position: relative;
    flex: 0 0 18px;
  }
  .brand-mark::after {
    content: ''; position: absolute; inset: 3px 3px auto auto;
    width: 4px; height: 4px; background: var(--accent); border-radius: 1px;
  }
  .breadcrumb {
    display: flex; align-items: center; gap: 8px;
    font-size: 12.5px;
    color: var(--text-2);
    min-width: 0;
  }
  .breadcrumb .crumb-sep { color: var(--text-4); }
  .breadcrumb .crumb-current { color: var(--text); font-weight: 500; }
  .breadcrumb .crumb-parent { color: var(--text-3); }
  .breadcrumb .crumb-parent:hover { color: var(--text); cursor: pointer; }

  .cmdk {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 4px 6px 4px 10px;
    width: 340px;
    color: var(--text-3);
    cursor: text;
    transition: border-color .12s, background .12s;
    height: 28px;
  }
  .cmdk:hover { border-color: var(--border-strong); }
  .cmdk svg { width: 12px; height: 12px; opacity: 0.6; }
  .cmdk .placeholder { flex: 1; font-size: 11.5px; }
  .kbd {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    color: var(--text-2);
    padding: 1px 6px;
    border-radius: 4px;
    line-height: 1.3;
    white-space: nowrap;
  }
  .kbd.inline { font-size: 10px; padding: 0 4px; border-bottom-width: 1px; background: transparent; }

  .topbar-right {
    display: flex; align-items: center; justify-content: flex-end; gap: 8px;
    flex-shrink: 0;
    min-width: 0;
  }
  .env-clock {
    display: inline-flex; align-items: center; gap: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text);
    padding: 4px 10px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    height: 28px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .env-clock .env {
    font-size: 10px;
    letter-spacing: 0.14em;
    font-weight: 600;
  }
  .env-clock .env.prod { color: var(--buy); }
  .env-clock .env.staging { color: var(--warn); }
  .env-clock .env.dev { color: var(--info); }
  .env-clock .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-4); }
  .env-clock.clickable { cursor: pointer; }
  .env-clock.clickable:hover { border-color: var(--border-strong); }

  /* ============================================================
     Main 2-pane layout: order list + active order workspace
     ============================================================ */
  .main {
    display: grid;
    grid-template-columns: 340px 1fr;
    min-height: 0;
    overflow: hidden;
  }
  .pane {
    display: flex; flex-direction: column;
    min-height: 0;
    background: var(--bg-1);
  }
  /* Visual hierarchy via background tint — outer panes slightly dimmer */
  .pane.dim { background: var(--bg-0); }
  .pane + .pane { border-left: 1px solid var(--border); }

  .pane-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-1);
    position: sticky; top: 0; z-index: 2;
    min-height: 36px;
  }
  .pane-title {
    font-size: 10.5px; font-weight: 600; letter-spacing: 0.14em;
    color: var(--text-3);
    text-transform: uppercase;
  }
  .pane-title .count {
    font-family: 'JetBrains Mono', monospace;
    margin-left: 6px;
    color: var(--text-2);
    background: var(--bg-3);
    padding: 1px 6px;
    border-radius: 3px;
    letter-spacing: 0;
    font-size: 10px;
  }

  /* ============================================================
     Left pane — orders list
     ============================================================ */
  .filter-row {
    display: flex; gap: 4px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-1);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .filter-row::-webkit-scrollbar { display: none; }
  .chip {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 999px;
    color: var(--text-2);
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex; align-items: center; gap: 6px;
  }
  .chip:hover { background: var(--bg-2); color: var(--text); }
  .chip.active {
    background: var(--bg-3);
    color: var(--text);
    border-color: var(--border);
  }
  .chip .chip-count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--text-3);
  }
  .chip.active .chip-count { color: var(--text-2); }

  .orders-list {
    flex: 1; overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
  }
  .orders-list::-webkit-scrollbar { width: 6px; }
  .orders-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

  .order-row {
    display: grid;
    grid-template-columns: 8px auto auto 1fr 58px;
    grid-template-rows: auto auto;
    gap: 2px 6px;
    align-items: center;
    height: 40px;
    padding: 0 10px 0 8px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    position: relative;
    border-left: 2px solid transparent;
  }
  .order-row:hover { background: var(--bg-2); }
  .order-row.active {
    background: var(--bg-3);
    border-left-color: var(--accent);
  }
  .order-row.active::after {
    content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 2px;
  }

  .status-dot {
    grid-row: 1 / span 2;
    width: 7px; height: 7px; border-radius: 50%;
    align-self: center;
  }
  .status-dot.pending { background: var(--warn); box-shadow: 0 0 6px var(--warn-bg); }
  .status-dot.pricing { background: var(--info); box-shadow: 0 0 6px var(--info-bg); animation: pulse 2s ease-in-out infinite; }
  .status-dot.in-progress { background: var(--info); }
  .status-dot.executed { background: var(--buy); }
  .status-dot.rejected { background: var(--sell); }

  @keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
  }

  .side-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9.5px; font-weight: 700;
    letter-spacing: 0.06em;
    padding: 1px 5px;
    border-radius: 2px;
    line-height: 1.4;
  }
  .side-badge.buy { background: var(--buy-bg); color: var(--buy); }
  .side-badge.sell { background: var(--sell-bg); color: var(--sell); }

  .order-isin {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    color: var(--text-3);
  }
  .order-name {
    grid-column: 2 / span 3;
    font-size: 12px;
    color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-weight: 500;
  }
  .order-qty {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-2);
    text-align: right;
    font-weight: 500;
  }
  .order-time {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--text-4);
    text-align: right;
    grid-row: 1;
    white-space: nowrap;
    min-width: 56px;
  }

  /* ============================================================
     Center pane
     ============================================================ */
  .center-scroll {
    flex: 1; overflow-y: auto; min-height: 0;
    scrollbar-width: thin;
  }
  .center-scroll::-webkit-scrollbar { width: 6px; }
  .center-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

  /* Band 1 — order summary (compressed single row + heading) */
  .summary {
    padding: 10px 16px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-1);
  }
  .summary-strip {
    display: flex;
    align-items: center;
    gap: 10px 18px;
    flex-wrap: wrap;
    margin-bottom: 8px;
    font-size: 11.5px;
    color: var(--text-2);
    row-gap: 4px;
  }
  .ss-item {
    display: inline-flex; align-items: center; gap: 6px;
    min-width: 0;
  }
  .ss-label {
    font-size: 9.5px; letter-spacing: 0.12em;
    color: var(--text-3); text-transform: uppercase;
    font-weight: 500;
  }
  .ss-value { color: var(--text); font-weight: 500; white-space: nowrap; }
  .ss-value.mono { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; }
  .ss-value.buy { color: var(--buy); }
  .ss-value.sell { color: var(--sell); }
  .ss-sep {
    width: 1px; height: 10px; background: var(--border);
    flex: 0 0 1px;
  }

  .copy-btn {
    width: 14px; height: 14px;
    border-radius: 3px;
    background: transparent;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .copy-btn:hover { color: var(--text); background: var(--bg-3); }
  .copy-btn svg { width: 11px; height: 11px; }

  .status-pill {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9.5px; font-weight: 600; letter-spacing: 0.1em;
    padding: 2px 7px;
    border-radius: 3px;
    border: 1px solid;
    display: inline-flex; align-items: center; gap: 5px;
  }
  .status-pill::before {
    content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor;
  }
  .status-pill.pricing { color: oklch(0.94 0.02 245); border-color: var(--info); background: var(--info-bg); }
  .status-pill.pending { color: var(--warn); border-color: var(--warn); background: var(--warn-bg); }
  .status-pill.in-progress { color: var(--info); border-color: var(--info); background: var(--info-bg); }
  .status-pill.executed { color: var(--buy); border-color: var(--buy); background: var(--buy-bg); }
  .status-pill.rejected { color: var(--sell); border-color: var(--sell); background: var(--sell-bg); }

  .instrument-heading {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.005em;
    color: var(--text);
    display: flex; align-items: baseline; gap: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .instrument-heading .sep {
    color: var(--text-4);
    font-weight: 400;
  }
  .instrument-heading .isin {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12.5px;
    color: var(--text-3);
    font-weight: 500;
  }
  .instrument-heading .ccy {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--text-2);
    font-weight: 600;
    letter-spacing: 0.04em;
  }

  /* Band 2 — quote entry (PRIMARY FOCUS, subtle tint) */
  .quote-band {
    padding: 14px 16px 14px;
    border-bottom: 1px solid var(--border);
    /* Subtle focus-zone tint — lighter than surrounding bg-1 in dark, warmer in light */
    background: color-mix(in oklch, var(--bg-1), var(--accent-bg) 8%);
    position: relative;
  }
  .quote-band::before {
    content: '';
    position: absolute; left: 0; top: 0; bottom: 0;
    width: 2px; background: var(--accent);
    opacity: 0.5;
  }
  .band-header {
    display: flex; align-items: baseline; justify-content: space-between;
    margin-bottom: 10px;
    gap: 12px;
    flex-wrap: nowrap;
    min-width: 0;
  }
  .band-header > .band-title { flex-shrink: 0; }
  .band-header > .band-sub { overflow: hidden; text-overflow: ellipsis; min-width: 0; flex-shrink: 1; }
  .band-title {
    font-size: 10px; letter-spacing: 0.14em;
    color: var(--text-3); text-transform: uppercase;
    font-weight: 600;
  }
  .band-sub {
    font-size: 10.5px; color: var(--text-4);
    font-family: 'JetBrains Mono', monospace;
  }

  /* Flat inline row — label above input, delta inline, prev caption below */
  .quote-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: nowrap;
    min-width: 0;
  }
  .quote-spacer { flex: 1 1 auto; min-width: 0; }
  .qfield {
    display: flex; flex-direction: column; gap: 3px;
    min-width: 0;
    flex: 0 0 auto;
  }
  .qfield .qf-input { width: 76px; }
  .qf-label {
    font-size: 9.5px; font-weight: 600;
    letter-spacing: 0.16em;
    color: var(--text-3);
    text-transform: uppercase;
    height: 14px;
  }
  .qf-label.bid { color: var(--buy); }
  .qf-label.ask { color: var(--sell); }
  .qf-input-wrap {
    display: inline-flex; align-items: stretch;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    height: 30px;
    transition: border-color .12s, background .12s;
  }
  .qf-input-wrap:focus-within { background: var(--bg-1); }
  .qfield.bid  .qf-input-wrap:focus-within { border-color: var(--buy); box-shadow: 0 0 0 1px var(--buy) inset; }
  .qfield.ask  .qf-input-wrap:focus-within { border-color: var(--sell); box-shadow: 0 0 0 1px var(--sell) inset; }
  .qfield.last .qf-input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
  .qfield.indicative .qf-input-wrap:focus-within { border-color: var(--border-strong); }

  .qf-input {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    background: transparent;
    border: none;
    color: var(--text);
    width: 80px;
    min-width: 0;
    padding: 0 10px;
    outline: none;
    letter-spacing: -0.01em;
  }
  .qf-delta {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    padding: 0 8px 0 4px;
    display: inline-flex; align-items: center;
    border-left: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
  }
  .qf-delta.up   { color: var(--buy); }
  .qf-delta.down { color: var(--sell); }
  .qf-delta.flat { color: var(--text-4); }
  .qf-prev {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--text-4);
    height: 14px;
    padding-left: 10px;
  }

  .ind-add {
    align-self: flex-end;
    margin-bottom: 17px;
    background: transparent;
    border: 1px dashed var(--border-strong);
    color: var(--text-3);
    height: 30px;
    padding: 0 12px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    font-family: 'IBM Plex Sans', sans-serif;
    white-space: nowrap;
    transition: color .12s, border-color .12s;
  }
  .ind-add:hover { color: var(--text); border-color: var(--text-3); }

  .quote-hints {
    display: flex; align-items: center; gap: 10px;
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    font-size: 10.5px;
    color: var(--text-4);
    flex-wrap: wrap;
  }
  .quote-hints .hint-item {
    display: inline-flex; align-items: center; gap: 5px;
    white-space: nowrap;
  }
  .quote-hints kbd {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9.5px; font-weight: 600;
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--text-2);
    padding: 1px 5px;
    border-radius: 3px;
    line-height: 1.2;
  }
  .quote-hints .hint-sep { color: var(--text-4); opacity: 0.5; }

  .stale-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10.5px;
    font-family: 'JetBrains Mono', monospace;
    white-space: nowrap;
    border: 1px solid;
  }
  .stale-chip .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
  .stale-chip.stale { color: var(--warn); border-color: color-mix(in oklch, var(--warn) 40%, var(--border)); background: var(--warn-bg); }
  .stale-chip.old   { color: var(--sell); border-color: color-mix(in oklch, var(--sell) 40%, var(--border)); background: var(--sell-bg); }

  .record-btn {
    background: var(--accent);
    color: oklch(0.14 0.01 250);
    border: 1px solid var(--accent);
    border-radius: 4px;
    padding: 0 14px;
    height: 30px;
    margin-bottom: 17px; /* align baseline with inputs (prev caption row) */
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    cursor: pointer;
    display: inline-flex; align-items: center; gap: 8px;
    font-family: 'IBM Plex Sans', sans-serif;
    transition: filter .12s, background .12s, border-color .12s;
    white-space: nowrap;
  }
  .record-btn:hover { filter: brightness(1.08); }
  .record-btn .hint {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px; font-weight: 500;
    opacity: 0.65;
    letter-spacing: 0.04em;
  }
  .record-btn.warn { background: var(--warn); border-color: var(--warn); color: oklch(0.14 0.01 250); }
  .record-btn.warn::before { content: '⚠'; font-size: 11px; }

  .staleness { display: none; }

  /* Band 3 — execution (SECONDARY) */
  .exec-band {
    padding: 12px 16px 14px;
    background: var(--bg-1);
  }
  .exec-actions {
    display: flex; gap: 6px;
    flex-wrap: wrap;
  }
  .btn {
    padding: 0 12px;
    height: 30px;
    border-radius: 4px;
    font-size: 11.5px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex; align-items: center; gap: 8px;
    transition: background .12s, border-color .12s, color .12s;
    font-family: 'IBM Plex Sans', sans-serif;
  }
  .btn .hint { font-family: 'JetBrains Mono', monospace; font-size: 10px; opacity: 0.6; letter-spacing: 0.04em; }
  .btn-primary {
    background: var(--buy);
    border: 1px solid var(--buy);
    color: oklch(0.14 0.01 250);
    font-weight: 600;
  }
  .btn-primary:hover { filter: brightness(1.08); }
  .btn-outline {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text);
  }
  .btn-outline:hover { background: var(--bg-2); border-color: var(--text-3); }
  .btn-outline.danger { color: var(--sell); border-color: color-mix(in oklch, var(--sell) 50%, var(--border)); }
  .btn-outline.danger:hover { background: var(--sell-bg); border-color: var(--sell); }
  .btn-outline.dim { color: var(--text-3); }

  .exec-inline {
    margin-top: 14px;
    padding: 14px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    display: none;
  }
  .exec-inline.open { display: block; }
  .exec-inline-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
  }
  .exec-inline-title {
    font-size: 10.5px; letter-spacing: 0.14em;
    color: var(--text-2); text-transform: uppercase;
    font-weight: 600;
  }
  .exec-inline-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 2fr auto;
    gap: 10px;
    align-items: end;
  }
  .field {
    display: flex; flex-direction: column; gap: 4px;
  }
  .field label {
    font-size: 9.5px; letter-spacing: 0.12em;
    color: var(--text-3); text-transform: uppercase;
    font-weight: 500;
  }
  .field input, .field textarea {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 8px;
    color: var(--text);
    outline: none;
    resize: none;
  }
  .field.wide input { font-family: 'IBM Plex Sans', sans-serif; font-size: 12px; }
  .field input:focus, .field textarea:focus { border-color: var(--accent); }
  .close-x {
    background: transparent; border: none; color: var(--text-3);
    cursor: pointer; font-size: 14px; line-height: 1;
    padding: 2px 6px; border-radius: 3px;
  }
  .close-x:hover { background: var(--bg-3); color: var(--text); }

  /* ============================================================
     Right pane — compact ref + history
     ============================================================ */
  .ref-section { border-bottom: 1px solid var(--border); flex: 0 0 auto; }
  .ref-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
    height: 36px;
  }
  .ref-head:hover { background: var(--bg-2); }
  .ref-head .chev {
    width: 10px; height: 10px; color: var(--text-3);
    transition: transform .15s;
  }
  .ref-section.collapsed .chev { transform: rotate(-90deg); }
  .ref-section.collapsed .ref-body { display: none; }

  .ref-body {
    padding: 2px 0 8px;
  }
  .ref-grid {
    display: flex; flex-direction: column;
  }
  .ref-line {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 8px;
    align-items: center;
    padding: 0 12px;
    height: 28px;
    border-top: 1px solid var(--border);
  }
  .ref-line:first-child { border-top: none; }
  .ref-k {
    font-size: 10.5px;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
  }
  .ref-v {
    font-size: 11.5px;
    color: var(--text);
    text-align: right;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .ref-v.mono { font-family: 'JetBrains Mono', monospace; font-size: 11px; }

  .history-wrap { display: flex; flex-direction: column; min-height: 0; flex: 1; }
  .history-table {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
  }
  .history-table::-webkit-scrollbar { width: 6px; }
  .history-table::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
  .hist-head-row, .hist-row {
    display: grid;
    grid-template-columns: 58px minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) 42px 22px;
    gap: 4px;
    align-items: center;
    padding: 0 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
  }
  .hist-head-row {
    height: 22px;
    color: var(--text-3);
    font-size: 9px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    background: var(--bg-1);
    position: sticky; top: 0;
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 600;
  }
  .hist-row {
    height: 24px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
  }
  .hist-row:hover { background: var(--bg-2); }
  .hist-row.flash { animation: flash 1.2s ease-out; }
  @keyframes flash {
    0% { background: var(--buy-bg); }
    100% { background: transparent; }
  }
  .hist-src {
    font-size: 8.5px; letter-spacing: 0.06em;
    padding: 1px 4px;
    border-radius: 2px;
    background: var(--bg-3);
    color: var(--text-3);
    text-align: center;
    font-weight: 600;
    justify-self: stretch;
  }
  .hist-who {
    color: var(--text-3);
    font-size: 10px;
    text-align: center;
  }
  .num-r { text-align: right; }
  .num-r.up { color: var(--buy); }
  .num-r.down { color: var(--sell); }

  /* ============================================================
     Tweaks panel
     ============================================================ */
  .tweaks {
    position: fixed;
    right: 16px; bottom: 16px;
    width: 280px;
    background: var(--bg-2);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 14px;
    z-index: 100;
    display: none;
    font-size: 12px;
  }
  .tweaks.open { display: block; }
  .tweaks h3 {
    margin: 0 0 10px; font-size: 10.5px; letter-spacing: 0.14em;
    color: var(--text-3); text-transform: uppercase; font-weight: 600;
    display: flex; justify-content: space-between; align-items: center;
  }
  .tweak-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 0;
    border-top: 1px solid var(--border);
  }
  .tweak-row label { color: var(--text-2); font-size: 11.5px; }
  .tweak-row select, .tweak-row input[type="color"] {
    background: var(--bg-1);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 3px 6px;
    border-radius: 3px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
  }
  .tweak-row input[type="color"] { padding: 0; width: 40px; height: 22px; }

  /* toast */
  .toast {
    position: fixed;
    right: 16px; top: 56px;
    background: var(--bg-2);
    border: 1px solid var(--border-strong);
    border-left: 3px solid var(--info);
    padding: 10px 14px;
    border-radius: 5px;
    font-size: 12px;
    color: var(--text);
    display: none;
    max-width: 320px;
    z-index: 50;
  }
  .toast.open { display: block; animation: slideIn .2s ease-out; }
  .toast-title { font-weight: 600; margin-bottom: 2px; font-size: 11.5px; }
  .toast-body { color: var(--text-2); font-size: 11px; }
  @keyframes slideIn {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
  }

  /* selection */
  ::selection { background: var(--accent-bg); color: var(--text); }

  /* flash state on record quote */
  .quote-flash {
    animation: quoteFlash .9s ease-out;
  }
  @keyframes quoteFlash {
    0% { background: var(--buy-bg); }
    100% { background: var(--bg-1); }
  }

  /* ============================================================
     Collapsible accordion sections (instrument details, history)
     ============================================================ */
  .accordion {
    border-top: 1px solid var(--border);
    background: var(--bg-1);
  }
  .accordion-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 9px 16px;
    cursor: pointer;
    user-select: none;
    gap: 12px;
    transition: background .1s;
  }
  .accordion-head:hover { background: var(--bg-2); }
  .accordion-head-left {
    display: flex; align-items: center; gap: 10px;
    min-width: 0;
  }
  .accordion-chev {
    width: 10px; height: 10px; color: var(--text-3);
    transition: transform .14s;
    flex-shrink: 0;
  }
  .accordion.open .accordion-chev { transform: rotate(90deg); }
  .accordion-title {
    font-size: 10.5px; font-weight: 600; letter-spacing: 0.14em;
    color: var(--text-2); text-transform: uppercase;
    white-space: nowrap;
  }
  .accordion-meta {
    font-size: 11px; color: var(--text-3);
    font-family: 'JetBrains Mono', monospace;
    white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
  }
  .accordion-kbd {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px; color: var(--text-4);
    flex-shrink: 0;
  }
  .accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height .14s ease;
  }
  .accordion.open .accordion-body { max-height: 520px; overflow: auto; }
  .accordion-inner { padding: 6px 16px 14px; }

  /* Compact two-column reference grid for instrument details */
  .details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    column-gap: 32px;
    row-gap: 4px;
  }
  .details-row {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 12px;
    padding: 3px 0;
    border-bottom: 1px dashed var(--border);
    font-size: 11.5px;
  }
  .details-k {
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 10px;
    white-space: nowrap;
  }
  .details-v {
    color: var(--text);
    white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
    text-align: right;
  }
  .details-v.mono { font-family: 'JetBrains Mono', monospace; font-size: 11px; }

  /* Inline history table inside accordion */
  .history-inline .hist-head-row,
  .history-inline .hist-row {
    display: grid;
    grid-template-columns: 70px 44px 36px 1fr 1fr 1fr;
    gap: 12px;
    align-items: center;
    padding: 0 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
  }
  .history-inline .hist-head-row {
    height: 22px;
    color: var(--text-3);
    font-size: 9.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 600;
  }
  .history-inline .hist-row {
    height: 24px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
  }
  .history-inline .hist-row:last-child { border-bottom: none; }
  .history-inline .hist-row:hover { background: var(--bg-2); }

  /* ============================================================
     Demo navigation — back-link injected on every demo page
     ============================================================ */
  .demo-home-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    margin-right: 12px;
    font: 500 12px/1 'IBM Plex Sans', system-ui, sans-serif;
    color: var(--text-2);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: transparent;
    transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
  }
  .demo-home-link:hover {
    color: var(--text);
    background: var(--bg-1);
    border-color: var(--text-3);
  }
  @media print {
    .demo-home-link { display: none !important; }
  }