/* Suite shell and auth screens. Primitives only, so screens compose rather than restyle.
 * Dark-only for v1 (matches the company site and the app); tokens are semantic, so a light
 * theme stays additive later.
 */

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--gold); }

.skip-link {
    position: absolute;
    left: -9999px;
}
.skip-link:focus {
    left: var(--space-4);
    top: var(--space-4);
    background: var(--bg-card);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    z-index: 10;
}

/* ── top bar: the company site's blurred treatment ───────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;          /* at phone width the scope picker, the badge, the address and Sign out
                                 cannot share one row; without this the page scrolled sideways */
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-5);
    background: rgba(5, 5, 5, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.wordmark {
    font-family: var(--font-display);
    font-size: 1.05rem;
    letter-spacing: 0.04em;
    color: var(--gold);
    text-decoration: none;
}
.wordmark small {
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.8rem;
    letter-spacing: 0;
    margin-left: var(--space-2);
}

.topbar .spacer { flex: 1; }

#operator-link {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* The exchange scope (Android's "viewing" exchange). A label + select, because the choice must be
   readable at a glance: an unlabelled dropdown over exchanges is a guessing game. */
.scope {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.scope-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.scope select {
    background: var(--surface);
    color: var(--text);
    color-scheme: dark;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font: inherit;
    font-size: 0.88rem;
    max-width: 14rem;
}

/* What the scope is leaving out. One line, always above the Bots card: a view that can hide a dead
   bot is worse than no view. */
.scope-strip {
    margin: 0 0 var(--space-4);
    padding: var(--space-2) var(--space-3);
    border-left: 3px solid var(--gold);
    background: rgba(212, 175, 55, 0.08);
    color: var(--text-muted);
    font-size: 0.88rem;
    border-radius: var(--radius-sm);
}

@media (max-width: 640px) {
    .scope-label { display: none; }
    .scope select { max-width: 9rem; }
}

/* ── layout ──────────────────────────────────────────────────────────────────── */
main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-7) var(--space-5) var(--space-8);
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-6);
    max-width: 460px;
    margin: 0 auto;
}
.panel.wide { max-width: 900px; }

h1, h2 {
    font-family: var(--font-display);
    color: var(--gold);
    letter-spacing: 0.02em;
    font-weight: 600;
    margin: 0 0 var(--space-3);
}
h1 { font-size: 1.7rem; }
h2 { font-size: 1.15rem; margin-top: var(--space-5); }

p { color: var(--text-secondary); margin: 0 0 var(--space-4); }
small, .meta { color: var(--text-secondary); font-size: 0.82rem; }

/* ── forms ───────────────────────────────────────────────────────────────────── */
.field { margin-bottom: var(--space-4); }
label {
    display: block;
    margin-bottom: var(--space-2);
    font-size: 0.92rem;
    font-weight: 500;
}
input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"] {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: #08080a;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
}
input:focus-visible {
    outline: none;
    border-color: var(--gold);
    box-shadow: var(--focus-ring);
}

button {
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 10px;
    padding: var(--space-3) var(--space-5);
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
button:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.primary {
    border: none;
    color: #050505;
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
}
.primary:hover { background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 100%); transform: translateY(-2px); }

.secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}
.secondary:hover { border-color: var(--gold); color: var(--gold); }
/* The kill switch must not look like a normal action: it closes positions at market. */
.danger {
    background: transparent;
    border: 1px solid rgba(192, 57, 43, 0.6);
    color: var(--loss);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
}
.danger:hover { background: rgba(192, 57, 43, 0.12); border-color: var(--loss); }

.actions { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-5); }

/* A button that reads as a link. Used where the control navigates within the page: a real <button>
   is honest to a screen reader, an <a href="#"> is a promise the page does not keep. */
.link-like {
    background: none;
    border: none;
    padding: 0;
    color: var(--gold);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}
.link-like:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 2px; }

/* ── feedback ───────────────────────────────────────────────────────────────── */
.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: 10px;
    font-size: 0.9rem;
    margin-bottom: var(--space-4);
}
.alert-error { background: rgba(192, 57, 43, 0.12); border: 1px solid rgba(192, 57, 43, 0.35); color: #e74c3c; }
.alert-ok { background: rgba(39, 174, 96, 0.12); border: 1px solid rgba(39, 174, 96, 0.35); color: #2ecc71; }
.alert-warn { background: rgba(243, 156, 18, 0.12); border: 1px solid rgba(243, 156, 18, 0.35); color: var(--warn); }
[hidden] { display: none !important; }

/* ── recovery codes and secrets ─────────────────────────────────────────────── */
.code-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    color: var(--gold);
    margin: var(--space-3) 0;
}
.code-block {
    background: #08080a;
    border: 1px dashed var(--gold);
    border-radius: 10px;
    padding: var(--space-3);
    font-family: var(--font-mono);
    word-break: break-all;
    color: var(--gold);
    margin: var(--space-3) 0;
}

/* Enrolment QR: the svg carries its own white background and quiet zone (a scanner needs both), and a
 * viewBox so it scales to this width instead of being clipped at the edge. */
.qr-frame { margin: var(--space-3) 0; width: 100%; max-width: 240px; }
.qr-frame svg { display: block; width: 100%; height: auto; }
.qr-frame[hidden] { display: none; }

/* ── suite launcher cards ───────────────────────────────────────────────────── */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-4);
    margin-top: var(--space-5);
}
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-5);
    transition: border-color 0.2s ease, background 0.2s ease;
}
.card:hover { background: var(--bg-card-hover); border-color: var(--border-strong); }
.card h3 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    color: var(--gold);
    margin: 0 0 var(--space-2);
}
.card p { margin-bottom: var(--space-3); }
.card a.primary {
    display: inline-block;
    text-decoration: none;
    padding: var(--space-2) var(--space-4);
    border-radius: 10px;
}
.card.soon { opacity: 0.6; }
/* A control the phone disables rather than hides is dimmed here too: it stays readable, so the user
   can see what exists and why it is unavailable. */
.dim { opacity: 0.55; }

/* ── status pill (environment / state) ──────────────────────────────────────── */
.pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 2px var(--space-3);
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.pill.live { border-color: rgba(192, 57, 43, 0.5); color: #e74c3c; }
.pill.live .dot { background: var(--loss); }
.pill.paper { border-color: rgba(45, 156, 219, 0.5); color: var(--info); }
.pill.paper .dot { background: var(--info); }

@media (max-width: 768px) {
    main { padding: var(--space-5) var(--space-4) var(--space-7); }
    .panel { padding: var(--space-5); }
    .code-list { grid-template-columns: 1fr; }
    .topbar { padding: var(--space-3) var(--space-4); }
}

/* ── PnL view (plan section 21) ─────────────────────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin: var(--space-4) 0;
}
.segmented { display: inline-flex; gap: var(--space-2); }
.segmented button { padding: var(--space-2) var(--space-3); font-size: 0.85rem; }
/* The selected range/filter/tab. Keyed on the **attribute**, not the `.active` class: the class is a
   detail of how the row is written, while `aria-pressed` / `aria-selected` is the half a person relying on
   a screen reader is told. The chart's chips are the one group outside `.segmented`, so their toolbar is
   named explicitly. `web/spa/selection.js` is the only writer of both halves. */
.segmented button[aria-pressed="true"],
.segmented button[aria-selected="true"],
#dash-chart-card .toolbar button[aria-pressed="true"] {
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(201, 162, 39, 0.08);
}
select {
    background: #08080a;
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: var(--space-2) var(--space-3);
    font-family: inherit;
    /* The closed control is ours; the **popup list** is drawn by the OS. Without this the list opened
       white with our light text on it - "the names are barely visible". `color-scheme` is what tells
       the browser to render its own widgets (the dropdown, the scrollbar) with the dark palette. */
    color-scheme: dark;
    /* An empty select (no exchange bound yet) would otherwise collapse to an arrow. */
    min-width: 12rem;
}
/* A control the phone disables rather than hides: dimmed and inert, but still readable, so the user can
   see what exists and why it is unavailable. */
button:disabled,
input:disabled,
select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--space-3);
    margin: var(--space-4) 0;
}
.stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-variant-numeric: tabular-nums;
}
.chart { width: 100%; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: var(--space-3); }
.chart-small { border-top: none; }
.chart-tooltip {
    position: relative;
    margin-top: calc(-1 * var(--space-5));
    margin-left: var(--space-3);
    display: inline-block;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: var(--space-1) var(--space-3);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { text-align: left; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-secondary); }

/* ── breakdown legend (section 21.2) ────────────────────────────────────────── */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin: var(--space-3) 0 var(--space-4);
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.legend-item { display: inline-flex; align-items: center; gap: var(--space-2); }
/* An author `display` rule outranks the user-agent [hidden] rule. */
.legend[hidden] { display: none; }
.legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex: none;
}

#pnl-groups h2, #pnl-calendar-section h2 { margin-top: var(--space-6); }

/* ── calendar heatmap (section 21.2) ────────────────────────────────────────── */
:root { --cal-cell: 14px; --cal-gap: 3px; }

.calendar-row { display: flex; gap: var(--space-2); margin: var(--space-3) 0; }
.calendar-scroll { overflow-x: auto; padding-bottom: var(--space-2); max-width: 100%; }
.cal-weekdays {
    display: grid;
    grid-template-rows: repeat(7, var(--cal-cell));
    gap: var(--cal-gap);
    font-size: 0.6rem;
    line-height: var(--cal-cell);
    color: var(--text-muted);
    padding-top: 18px; /* clear the month labels above the grid */
}
.cal-months {
    display: grid;
    gap: var(--cal-gap);
    font-size: 0.6rem;
    color: var(--text-muted);
    height: 16px;
    margin-bottom: 2px;
    /* Labels sit in one 14px column and spill right, which is fine: months are 4-5 columns
       apart, so they never collide. */
    white-space: nowrap;
    overflow: visible;
}
.calendar {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(7, var(--cal-cell));
    gap: var(--cal-gap);
}
.cal-cell {
    width: var(--cal-cell);
    height: var(--cal-cell);
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.04);
}
.cal-blank { background: transparent; }
.cal-flat { border: 1px solid var(--border); }
.calendar-empty { display: block; color: var(--text-muted); font-size: 0.85rem; }
details summary { cursor: pointer; margin-top: var(--space-3); }
details[open] summary { margin-bottom: var(--space-3); }
/* A row that expands in place (a trade's prices, a scan's details) must be reachable by keyboard, and
   the summary is the only focusable part of it. */
details summary:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 2px; }

/* One scan cycle, `[FUTURES] Scanned 12 pairs — 3 trades` on the left and its time on the right. */
.scan-entry {
    border-bottom: 1px solid var(--border);
    padding: var(--space-2) 0;
}
.scan-entry > summary {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    justify-content: space-between;
    margin: 0;
    list-style-position: inside;
}
.scan-entry[open] > summary { margin-bottom: var(--space-2); }
.scan-when { color: var(--text-muted); font-size: 0.85rem; }
.row-detail summary { margin: 0; color: var(--text-muted); font-size: 0.85rem; }
.row-detail .detail-list {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--space-1) var(--space-3);
    margin: var(--space-1) 0 0;
    font-size: 0.85rem;
}
.row-detail .detail-list dt { color: var(--text-muted); }
.row-detail .detail-list dd { margin: 0; }

/* ── in-card tablist (Activity's report types) ─────────────────────────────────────────────────── */
/* Scoped on purpose: the global `[role="tab"]` rules in shell.css style the navigation rail (bordered
   rows with a card background). These are the same semantics inside a card, so they override the layout
   and keep the selected state as an underline plus the accent colour, never colour alone. */
.tablist {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: var(--space-3) 0;
    border-bottom: 1px solid var(--border-strong);
}
.tablist [role="tab"] {
    display: inline-flex;
    align-items: center;
    min-height: 0;
    gap: 0;
    padding: var(--space-2) var(--space-3);
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font: inherit;
    cursor: pointer;
}
.tablist [role="tab"]:hover { color: var(--text-primary); }
.tablist [role="tab"][aria-selected="true"] {
    background: transparent;
    border-bottom-color: var(--gold);
    color: var(--text-primary);
    font-weight: 600;
}
.tablist [role="tab"] .tab-count {
    margin-left: 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* The drawdown strip sits under the equity curve and is not a second price chart; the heading and the
   smaller type say so. */
.chart-small-heading {
    margin: var(--space-3) 0 var(--space-1);
    color: var(--text-muted);
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
