/* Easy API Trade design system. Colours are role tokens; the dark values are declared for
   both the OS setting and the theme toggle (data-theme on <html>). */

:root {
    color-scheme: light;
    --page: #f4f4f1;
    --surface: #fcfcfb;
    --surface-2: #f4f4f1;
    --surface-hover: #f0efec;
    --ink: #0b0b0b;
    --ink-2: #52514e;
    --muted: #6f6e69;
    --hairline: #e1e0d9;
    --axis: #c3c2b7;
    --border: rgba(11, 11, 11, 0.10);
    --border-strong: rgba(11, 11, 11, 0.22);
    --shadow: 0 1px 2px rgba(11, 11, 11, 0.05), 0 1px 1px rgba(11, 11, 11, 0.03);
    --shadow-pop: 0 8px 24px rgba(11, 11, 11, 0.14);

    --accent: #1c5cab;
    --accent-hover: #184f95;
    --accent-ink: #ffffff;
    --accent-soft: #e6f0fd;
    --link: #1c5cab;
    --focus: #2a78d6;
    --series-1: #2a78d6;

    --up: #006300;
    --up-soft: #e5f3e5;
    --down: #b3261e;
    --down-soft: #fbe9e7;
    --buy: #0b7a0b;
    --buy-hover: #096509;
    --sell: #c9302c;
    --sell-hover: #ad2622;
    --warn-ink: #6b4a00;
    --warn-soft: #fdf2d0;
    --flash-up: rgba(12, 163, 12, 0.14);
    --flash-down: rgba(208, 59, 59, 0.14);

    --code-bg: #16181d;
    --code-ink: #e7e9ee;
    --code-muted: #9aa1ad;

    --radius: 10px;
    --radius-sm: 6px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root:where(:not([data-theme="light"])) {
        color-scheme: dark;
        --page: #0d0d0d;
        --surface: #1a1a19;
        --surface-2: #232321;
        --surface-hover: #2a2a28;
        --ink: #ffffff;
        --ink-2: #c3c2b7;
        --muted: #9c9b94;
        --hairline: #2c2c2a;
        --axis: #383835;
        --border: rgba(255, 255, 255, 0.10);
        --border-strong: rgba(255, 255, 255, 0.24);
        --shadow: none;
        --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.5);

        --accent: #256abf;
        --accent-hover: #2a78d6;
        --accent-ink: #ffffff;
        --accent-soft: #14273f;
        --link: #86b6ef;
        --focus: #6da7ec;
        --series-1: #3987e5;

        --up: #3fc03f;
        --up-soft: #112a11;
        --down: #f0817a;
        --down-soft: #331614;
        --buy: #0b7a0b;
        --buy-hover: #0d8f0d;
        --sell: #c9302c;
        --sell-hover: #dd3d38;
        --warn-ink: #f6d27a;
        --warn-soft: #2e2508;
        --flash-up: rgba(12, 163, 12, 0.28);
        --flash-down: rgba(230, 103, 103, 0.28);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --surface-hover: #2a2a28;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #9c9b94;
    --hairline: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.24);
    --shadow: none;
    --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.5);

    --accent: #256abf;
    --accent-hover: #2a78d6;
    --accent-ink: #ffffff;
    --accent-soft: #14273f;
    --link: #86b6ef;
    --focus: #6da7ec;
    --series-1: #3987e5;

    --up: #3fc03f;
    --up-soft: #112a11;
    --down: #f0817a;
    --down-soft: #331614;
    --buy: #0b7a0b;
    --buy-hover: #0d8f0d;
    --sell: #c9302c;
    --sell-hover: #dd3d38;
    --warn-ink: #f6d27a;
    --warn-soft: #2e2508;
    --flash-up: rgba(12, 163, 12, 0.28);
    --flash-down: rgba(230, 103, 103, 0.28);
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--page);
    color: var(--ink);
    font: 15px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; line-height: 1.2; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 16px; line-height: 1.3; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: 4px;
}

[hidden] { display: none !important; }

.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ---------- Top bar ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar .container {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 56px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin-right: 16px;
    color: var(--ink);
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.01em;
}

.brand:hover { text-decoration: none; }
.brand svg { display: block; }

.nav { display: flex; align-items: center; gap: 2px; }

.nav a {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    color: var(--ink-2);
    font-weight: 550;
    font-size: 14px;
}

.nav a:hover { background: var(--surface-hover); color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); }

.nav .dev-link { color: var(--warn-ink); }

.topbar .spacer { flex: 1; }

.topbar .who {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink-2);
    font-size: 13px;
}

.topbar form { display: inline-flex; margin: 0; }

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink-2);
    cursor: pointer;
}

.icon-button:hover { background: var(--surface-hover); color: var(--ink); }
/* The toggle shows the theme it switches to: a moon in light, a sun in dark. */
.icon-sun { display: none; }
.icon-moon { display: block; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:where(:not([data-theme="light"])) .icon-sun { display: block; }
    :root:where(:not([data-theme="light"])) .icon-moon { display: none; }
}

/* ---------- Page frame ---------- */

main { flex: 1; padding: 28px 0 56px; }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.page-head p { margin-top: 4px; color: var(--ink-2); }

.footer {
    border-top: 1px solid var(--border);
    padding: 18px 0;
    color: var(--ink-2);
    font-size: 13px;
}

.footer .container { display: flex; gap: 16px; justify-content: space-between; flex-wrap: wrap; }

/* ---------- Cards ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--hairline);
}

.card-body { padding: 18px; }
.card-body > * + * { margin-top: 12px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--hairline); }

.stack > * + * { margin-top: 16px; }

/* ---------- Buttons ---------- */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--accent-ink);
    font: inherit;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.12s ease;
}

.button:hover { background: var(--accent-hover); text-decoration: none; }
.button:disabled { opacity: 0.5; cursor: not-allowed; }
.button.block { display: flex; width: 100%; }
.button.large { min-height: 44px; font-size: 15px; }
.button.small { min-height: 30px; padding: 0 10px; font-size: 13px; }

.button.secondary {
    background: var(--surface);
    border-color: var(--border-strong);
    color: var(--ink);
}

.button.secondary:hover { background: var(--surface-hover); }
.button.buy { background: var(--buy); color: #fff; }
.button.buy:hover { background: var(--buy-hover); }
.button.sell { background: var(--sell); color: #fff; }
.button.sell:hover { background: var(--sell-hover); }

.link-button {
    border: 0;
    padding: 0;
    background: none;
    color: var(--link);
    font: inherit;
    cursor: pointer;
}

.link-button:hover { text-decoration: underline; }

/* ---------- Forms ---------- */

.field + .field { margin-top: 14px; }

.field > label, .label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}

.input, select.input {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
}

.input::placeholder { color: var(--muted); }
.input:hover { border-color: var(--muted); }

.input:focus-visible, select.input:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 0;
    border-color: var(--focus);
}

input[type=number].input { font-variant-numeric: tabular-nums; }

/* An input with a unit before or after it, such as "$" or "SPY". */
.affix {
    display: flex;
    align-items: stretch;
    height: 40px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.affix:hover { border-color: var(--muted); }
.affix:focus-within { outline: 2px solid var(--focus); border-color: var(--focus); }

.affix .unit {
    display: flex;
    align-items: center;
    padding: 0 12px;
    color: var(--ink-2);
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
}

.affix .unit:first-child { padding-right: 0; }
.affix .unit:last-child { padding-left: 0; }

.affix input {
    flex: 1;
    min-width: 0;
    border: 0;
    padding: 0 12px;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-variant-numeric: tabular-nums;
}

.affix input:focus { outline: none; }

.hint { margin-top: 6px; color: var(--ink-2); font-size: 13px; }
.field-error { display: block; margin-top: 6px; color: var(--down); font-size: 13px; }
.field-error:empty { display: none; }

.inline-form { display: flex; gap: 10px; }
.inline-form > :first-child { flex: 1; min-width: 0; }

/* A row of radio buttons drawn as one segmented control. */
.segmented {
    display: flex;
    padding: 3px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.segmented label {
    flex: 1;
    position: relative;
    margin: 0;
    padding: 6px 10px;
    border-radius: 6px;
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
}

.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:hover { color: var(--ink); }

.segmented label:has(input:checked) {
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 0 0 1px var(--border), var(--shadow);
}

.segmented label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 1px; }
.segmented.side label:has(input[value="buy"]:checked) { background: var(--buy); color: #fff; box-shadow: none; }
.segmented.side label:has(input[value="sell"]:checked) { background: var(--sell); color: #fff; box-shadow: none; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.chip {
    padding: 3px 10px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-2);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.chip:hover { background: var(--surface-hover); color: var(--ink); }

/* ---------- Alerts ---------- */

.alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 14px;
}

.alert + * { margin-top: 16px; }
.alert svg { flex: 0 0 auto; margin-top: 2px; }
.alert .alert-text { flex: 1; min-width: 0; }
.alert.ok { background: var(--up-soft); color: var(--up); border-color: transparent; }
.alert.error { background: var(--down-soft); color: var(--down); border-color: transparent; }
.alert.warn { background: var(--warn-soft); color: var(--warn-ink); border-color: transparent; }
.alert a { color: inherit; text-decoration: underline; }
.alert ul { margin: 0; padding-left: 18px; }
.alert.validation-summary-valid { display: none; }

.alert .dismiss {
    flex: 0 0 auto;
    border: 0;
    padding: 0 2px;
    background: none;
    color: inherit;
    font-size: 18px;
    line-height: 1;
    opacity: 0.7;
    cursor: pointer;
}

.alert .dismiss:hover { opacity: 1; }

/* ---------- Badges ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 9px 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.open { background: var(--up-soft); color: var(--up); }
.badge.closed { background: var(--surface-2); color: var(--ink-2); }
.badge.closed::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }

.pill {
    display: inline-block;
    min-width: 42px;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}

.pill.buy { background: var(--up-soft); color: var(--up); }
.pill.sell { background: var(--down-soft); color: var(--down); }

.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--ink-2); }

.delta { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; white-space: nowrap; }
.delta .arrow { font-size: 0.8em; margin-right: 3px; }

/* ---------- Tables ---------- */

/* position: relative keeps absolutely positioned children (screen-reader text) inside the scroll area. */
.table-wrap { position: relative; overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; }

table.data th, table.data td {
    padding: 11px 14px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--hairline);
}

table.data th {
    padding-top: 9px;
    padding-bottom: 9px;
    color: var(--ink-2);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: var(--surface-2);
}

table.data th:first-child, table.data td:first-child { padding-left: 18px; }
table.data th:last-child, table.data td:last-child { padding-right: 18px; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--surface-hover); }
table.data .r { text-align: right; font-variant-numeric: tabular-nums; }
table.data .sub { display: block; color: var(--ink-2); font-size: 12px; }
table.data .actions { text-align: right; }
table.data .actions .button + .button { margin-left: 6px; }
table.data .actions .button { vertical-align: middle; }

.symbol { font-weight: 700; }

.empty {
    padding: 36px 18px;
    text-align: center;
    color: var(--ink-2);
}

.empty strong { display: block; margin-bottom: 4px; color: var(--ink); font-size: 15px; }

/* ---------- Dashboard ---------- */

.kpis {
    display: grid;
    grid-template-columns: 1.3fr 1fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.kpi { padding: 16px 18px; }
.kpi .kpi-label { color: var(--ink-2); font-size: 13px; font-weight: 550; }
.kpi .kpi-value { margin-top: 4px; font-size: 24px; font-weight: 650; letter-spacing: -0.01em; }
.kpi.primary .kpi-value { font-size: 34px; line-height: 1.15; }
.kpi .kpi-note { margin-top: 2px; color: var(--ink-2); font-size: 13px; }

.dash {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 16px;
    align-items: start;
}

.dash-side { position: sticky; top: 72px; }

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.section-head .segmented label { flex: 0 0 auto; padding: 4px 12px; }

.live { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: 13px; }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--axis); }
.live.on::before { background: #0ca30c; box-shadow: 0 0 0 3px var(--up-soft); }

.watchlist { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.watch {
    display: block;
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.watch:hover { border-color: var(--border-strong); text-decoration: none; }
.watch[aria-pressed="true"] { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.watch-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.watch-name { display: block; color: var(--ink-2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watch-mid { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: 10px; }
.watch-price { font-size: 20px; font-weight: 650; border-radius: 4px; }
.watch .delta { display: block; margin-top: 2px; }

.spark { display: block; width: 96px; height: 32px; flex: 0 0 auto; overflow: visible; }
.spark .spark-line { fill: none; stroke: var(--muted); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark .spark-dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }

.flash-up { animation: flash-up 0.7s ease-out; }
.flash-down { animation: flash-down 0.7s ease-out; }
@keyframes flash-up { from { background: var(--flash-up); } to { background: transparent; } }
@keyframes flash-down { from { background: var(--flash-down); } to { background: transparent; } }

@media (prefers-reduced-motion: reduce) {
    .flash-up, .flash-down { animation: none; }
}

/* Price chart */

.chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 16px 18px 0; }
.chart-title { display: flex; align-items: center; gap: 10px; }
.chart-price { margin-top: 2px; font-size: 28px; font-weight: 650; letter-spacing: -0.01em; }
.chart-sub { color: var(--ink-2); font-size: 13px; }

.chart { position: relative; padding: 8px 6px 4px 18px; }
.chart svg { display: block; width: 100%; height: 280px; outline-offset: -2px; }
.chart .grid line { stroke: var(--hairline); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .series-line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series-area { fill: var(--series-1); opacity: 0.1; }
.chart .end-dot, .chart .hover-dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; }
.chart .chart-empty { fill: var(--ink-2); font-size: 13px; }

.chart-tip {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 5;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow-pop);
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
}

.chart-tip strong { display: block; font-size: 14px; font-variant-numeric: tabular-nums; }
.chart-tip span { color: var(--ink-2); }

.chart-data { border-top: 1px solid var(--hairline); }
.chart-data summary { padding: 10px 18px; color: var(--ink-2); font-size: 13px; cursor: pointer; }
.chart-data summary:hover { color: var(--ink); }
.chart-data .table-wrap { max-height: 260px; overflow-y: auto; }

/* The dashboard's two parts: the whole site, then the signed-in account */

.section-title { font-size: 22px; line-height: 1.2; letter-spacing: -0.01em; }
.dash-section .page-head { margin-bottom: 16px; }
.dash-section + .dash-section { margin-top: 36px; padding-top: 28px; border-top: 1px solid var(--border-strong); }

/* Same columns as .dash, so the two parts line up. */
.system { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; }

.feed { display: flex; flex-direction: column; justify-content: center; padding: 16px 18px; }
.feed-label { color: var(--ink-2); font-size: 13px; font-weight: 550; }
.feed-state { display: flex; align-items: center; gap: 10px; margin-top: 4px; font-size: 24px; font-weight: 650; letter-spacing: -0.01em; }
.feed-state::before { content: ""; flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; background: var(--axis); }
.feed-state.on::before { background: #0ca30c; box-shadow: 0 0 0 4px var(--up-soft); }
.feed-note { margin-top: 2px; color: var(--ink-2); font-size: 13px; }

/* Site volume: the figure on the left, its bars on the right */

.volume { display: grid; grid-template-columns: minmax(200px, 1fr) minmax(0, 2fr); align-items: center; }
.volume-figure { padding: 16px 18px; }
.volume h3 { color: var(--ink-2); font-size: 13px; font-weight: 550; }
.volume-value { margin-top: 4px; font-size: 24px; font-weight: 650; letter-spacing: -0.01em; }
.volume-chart { position: relative; padding: 12px 18px 8px 6px; }
.volume-chart svg { display: block; width: 100%; height: 112px; outline-offset: 2px; cursor: default; }
.volume .bar { fill: var(--series-1); transition: opacity 0.12s; }
.volume .hovering .bar:not(.on) { opacity: 0.4; }
.volume .baseline { stroke: var(--axis); stroke-width: 1; }
.volume .axis text, .volume .peak { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.volume .peak { fill: var(--ink-2); font-weight: 600; }
.volume .chart-empty { fill: var(--ink-2); font-size: 13px; }
.volume .chart-data { grid-column: 1 / -1; }

/* The same figure as one line with small bars, for the home page */

.volume-mini { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.volume-mini-label { color: var(--ink-2); font-size: 12px; font-weight: 550; }
.volume-mini-value { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.volume-mini-value span { margin-left: 4px; color: var(--ink-2); font-size: 13px; font-weight: 400; letter-spacing: 0; }
.volume-spark { flex: 0 0 auto; width: 120px; height: 37px; }
.volume-spark path { fill: var(--series-1); }
.volume-spark line { stroke: var(--axis); stroke-width: 1; }

/* Order ticket */

.ticket .segmented.side label { padding: 8px 10px; font-size: 14px; }
.ticket .estimate { min-height: 20px; margin-top: 6px; color: var(--ink-2); font-size: 13px; }
.ticket [data-order-submit] { margin-top: 14px; }
.ticket-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--ink-2); }
.ticket-row strong { color: var(--ink); font-variant-numeric: tabular-nums; }

.meter { height: 6px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--series-1); }

/* ---------- Focused trading ---------- */

.focus-tools { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

/* A segmented control made of links: one page, switched by ticker. */
.segmented a {
    flex: 1;
    padding: 4px 14px;
    border-radius: 6px;
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
}

.segmented a:hover { color: var(--ink); text-decoration: none; }

.segmented a[aria-current="page"] {
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 0 0 1px var(--border), var(--shadow);
}

.chart-head .segmented { flex: 0 0 auto; }
.chart-head .segmented label { flex: 0 0 auto; padding: 4px 12px; }
.chart-price .num { display: inline-block; padding: 0 4px; margin-left: -4px; border-radius: 4px; }
/* The chart takes the height the rest of the page leaves, so the ticker, the
   position and the buttons are on screen together without scrolling. */
.focus .chart svg { height: clamp(180px, calc(100vh - 680px), 400px); }

/* Hairlines between the figures come from the grid's gap, so they stay right however
   the figures wrap. */
.stats-card { overflow: hidden; }
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; margin: 0; background: var(--hairline); }
.stat { padding: 14px 18px; min-width: 0; background: var(--surface); }
.stat dt { color: var(--ink-2); font-size: 13px; font-weight: 550; }
.stat dd { margin: 2px 0 0; font-size: 22px; font-weight: 650; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat dd small { font-size: 13px; font-weight: 600; letter-spacing: 0; }

.pad > * + * { margin-top: 0; }
.pad-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pad-result { min-height: 21px; margin-top: 10px; font-size: 14px; font-weight: 550; text-align: center; }
.pad-result.ok { color: var(--up); }
.pad-result.error { color: var(--down); }

/* Set once per sitting, so it sits under the buttons, out of the way. */
.pad-cash {
    display: grid;
    grid-template-columns: minmax(220px, 280px) auto minmax(0, 1fr);
    gap: 12px 24px;
    align-items: end;
    margin-top: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--hairline);
}

.pad-label { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.pad-label strong { margin-left: 2px; color: var(--ink); }
.pad-cash .chips { margin-top: 0; }
.pad-cash .hint { white-space: nowrap; }

/* The two actions of the page: a label and, under it, exactly what a click will do. */
.trade-button {
    flex-direction: column;
    gap: 1px;
    min-height: 76px;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 18px;
    white-space: normal;
}

.trade-button-sub { font-size: 13px; font-weight: 500; opacity: 0.92; }
.trade-button[aria-busy="true"] { cursor: progress; }

.callout {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--ink);
    font-size: 13px;
}

.callout svg { flex: 0 0 auto; margin-top: 1px; color: var(--link); }

/* ---------- Auth pages ---------- */

.auth { max-width: 420px; margin: 24px auto 0; }
.auth .card-body { padding: 28px; }
.auth h1 { font-size: 22px; }
.auth .lead { margin-top: 6px; color: var(--ink-2); }
.auth form { margin-top: 20px; }
.auth .button { margin-top: 20px; }
.auth-links { margin-top: 18px; text-align: center; color: var(--ink-2); font-size: 14px; }
.auth-links > * + *::before { content: "·"; margin: 0 8px; color: var(--muted); }
.auth .alert { margin-top: 16px; }
.auth .alert + form { margin-top: 16px; }
.auth form + form { margin-top: 10px; }
.auth form + form .button { margin-top: 0; }
.auth .key-box .button { margin-top: 0; }
.auth .alert .dismiss { margin-top: 0; }

.mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-bottom: 14px;
    border-radius: 12px;
    background: var(--accent-soft);
    color: var(--accent);
}

/* ---------- Landing ---------- */

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    gap: 40px;
    align-items: center;
    padding: 32px 0 44px;
}

.hero h1 { font-size: 44px; line-height: 1.08; letter-spacing: -0.025em; }
.hero .lead { margin-top: 16px; max-width: 520px; color: var(--ink-2); font-size: 18px; line-height: 1.5; }
.hero .cta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 26px; }
.hero .fine { margin-top: 14px; color: var(--ink-2); font-size: 13px; }

.eyebrow {
    display: inline-block;
    margin-bottom: 14px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

:root[data-theme="dark"] .eyebrow, :root[data-theme="dark"] .mark { color: var(--link); }
@media (prefers-color-scheme: dark) {
    :root:where(:not([data-theme="light"])) .eyebrow, :root:where(:not([data-theme="light"])) .mark { color: var(--link); }
}

.market-panel .watchlist { grid-template-columns: 1fr; gap: 0; }
.market-panel .watch { border: 0; border-radius: 0; box-shadow: none; border-bottom: 1px solid var(--hairline); cursor: default; }
.market-panel .watch:last-child { border-bottom: 0; }
.market-panel .watch-mid { margin-top: 6px; }

.features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.feature { padding: 22px; }
.feature h2 { margin: 12px 0 6px; font-size: 17px; }
.feature p { color: var(--ink-2); }
.feature a { display: inline-block; margin-top: 12px; font-weight: 600; }

.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin-top: 44px; padding-top: 32px; border-top: 1px solid var(--border); }
.step-n { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: var(--surface); font-size: 13px; font-weight: 700; }
.steps h3 { margin: 10px 0 4px; font-size: 15px; }
.steps p { color: var(--ink-2); }

/* ---------- Docs ---------- */

.docs { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 32px; align-items: start; }
.toc { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.toc a { padding: 6px 10px; border-radius: var(--radius-sm); color: var(--ink-2); }
.toc a:hover { background: var(--surface-hover); color: var(--ink); text-decoration: none; }
.docs section { scroll-margin-top: 76px; }
.docs section + section { margin-top: 20px; }
.docs .card-body p { max-width: 720px; }

code { font-family: var(--mono); font-size: 0.9em; }
:not(pre) > code { padding: 1px 5px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); }

.code { position: relative; }

.code pre {
    margin: 0;
    padding: 14px 16px;
    border-radius: 8px;
    background: var(--code-bg);
    color: var(--code-ink);
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.55;
    overflow-x: auto;
}

.code .c { color: var(--code-muted); }

.code .copy {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 3px 9px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--code-ink);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.code .copy:hover { background: rgba(255, 255, 255, 0.16); }

.method { display: inline-block; min-width: 44px; padding: 1px 6px; border-radius: 4px; font-family: var(--mono); font-size: 12px; font-weight: 700; text-align: center; }
.method.get { background: var(--accent-soft); color: var(--link); }
.method.post { background: var(--up-soft); color: var(--up); }

.key-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 8px;
    background: var(--code-bg);
    color: var(--code-ink);
}

.key-box code { flex: 1; min-width: 0; font-size: 14px; word-break: break-all; background: none; border: 0; padding: 0; }
.key-box .button { flex: 0 0 auto; }

/* ---------- Mock inbox ---------- */

.mail { padding: 16px 18px; border-bottom: 1px solid var(--hairline); }
.mail:last-child { border-bottom: 0; }
.mail-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mail-meta { color: var(--ink-2); font-size: 13px; }
.mail pre { margin: 10px 0 0; padding: 12px 14px; border-radius: 8px; background: var(--surface-2); font-family: var(--mono); font-size: 13px; white-space: pre-wrap; word-break: break-word; }

/* ---------- Pager ---------- */

.pager { display: flex; justify-content: flex-end; }

/* ---------- Responsive ---------- */

@media (max-width: 1000px) {
    /* One column. The two columns' blocks are interleaved so the order ticket
       follows the chart instead of sitting below everything. */
    .dash { display: flex; flex-direction: column; align-items: stretch; gap: 16px; }
    .dash > .stack, .dash-side { display: contents; }
    .dash > .stack > *, .dash-side > * { margin-top: 0; min-width: 0; }
    [data-block="markets"] { order: 1; }
    [data-block="chart"] { order: 2; }
    [data-block="ticket"] { order: 3; }
    [data-block="positions"] { order: 4; }
    [data-block="deposit"] { order: 5; }
    [data-block="orders"] { order: 6; }
    .system { grid-template-columns: minmax(0, 1fr); }
    .kpis { grid-template-columns: 1fr 1fr; }
    .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .stat:last-child { grid-column: span 2; }
    .pad-cash { grid-template-columns: minmax(220px, 280px) minmax(0, 1fr); }
    .pad-cash .callout { grid-column: 1 / -1; }
    .hero { grid-template-columns: 1fr; gap: 28px; padding-top: 12px; }
    .hero h1 { font-size: 36px; }
    .docs { grid-template-columns: minmax(0, 1fr); }
    .toc { position: static; flex-direction: row; flex-wrap: wrap; }
}

@media (max-width: 720px) {
    .container { padding: 0 16px; }
    .topbar .who { display: none; }
    /* Two rows: brand and account on top, the page links below, scrollable if needed. */
    .topbar .container { flex-wrap: wrap; height: auto; padding-top: 8px; row-gap: 4px; }
    .nav { order: 3; width: 100%; padding-bottom: 6px; overflow-x: auto; }
    .nav a { white-space: nowrap; }
    .nav a:first-child { margin-left: -10px; }
    .watchlist, .features, .steps { grid-template-columns: 1fr; }
    .kpis { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
    .kpi { padding: 14px; }
    .kpi .kpi-value, .kpi.primary .kpi-value { font-size: 22px; }
    .kpi .kpi-note { display: none; }
    .hero h1 { font-size: 30px; }
    .page-head { align-items: flex-start; }
    .section-title { font-size: 20px; }
    .dash-section + .dash-section { margin-top: 28px; padding-top: 22px; }
    table.data th, table.data td { padding-left: 12px; padding-right: 12px; }
    .chart svg, .focus .chart svg { height: 220px; }
    .volume { grid-template-columns: minmax(0, 1fr); }
    .volume-figure { padding: 14px 14px 0; }
    .volume-chart { padding: 8px 14px; }
    .chart-head { flex-wrap: wrap; }
    /* On a phone the figures shrink to two short rows, three then two, and the
       buttons say only the dollar amount, so the chart and the buttons fit together. */
    .stats { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .stat { grid-column: span 2; padding: 6px 12px 7px; }
    .stat:nth-child(n + 4) { grid-column: span 3; }
    .stat dt { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .stat dd { margin-top: 0; font-size: 14px; letter-spacing: 0; }
    .stat dd small { font-size: 11px; }
    .trade-button { min-height: 62px; font-size: 16px; }
    .trade-button-detail { display: none; }
    .pad-cash { grid-template-columns: minmax(0, 1fr); align-items: start; }
    .pad-cash .hint { white-space: normal; }
}
