@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ---------------------------------------------------------------
   Tokens
   Subject: a solo-operator crypto trading terminal. The design
   language borrows from a quant's ledger, not a consumer crypto
   app — restrained color, numbers set in mono, structure that
   reads as data rather than decoration.
----------------------------------------------------------------*/
:root {
    --ink:            #14181C;
    --panel:          #1B2027;
    --panel-raised:   #20262E;
    --border:         #2A323C;
    --text:           #E7EAEE;
    --text-muted:     #8B95A3;
    --text-faint:     #5B6472;

    --buy:            #4FA787;
    --buy-dim:        #345A4C;
    --sell:           #C1666B;
    --sell-dim:       #5B3A3D;
    --live:           #D9A34A;

    --font-ui:   'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-data: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;

    --radius: 3px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--ink);
    color: var(--text);
    font-family: var(--font-ui);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

code {
    font-family: var(--font-data);
    background: var(--panel-raised);
    padding: 0.1em 0.4em;
    border-radius: var(--radius);
    font-size: 0.9em;
}

/* ---------------------------------------------------------------
   Auth (login / setup) — the one bold moment in the product.
----------------------------------------------------------------*/
.auth-body {
    min-height: 100vh;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
}

@media (max-width: 860px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
}

.auth-hero {
    position: relative;
    background: radial-gradient(120% 140% at 15% 20%, #1E2530 0%, #14181C 60%);
    border-right: 1px solid var(--border);
    padding: 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}

.auth-hero-top .auth-mark {
    margin-bottom: 48px;
}

.auth-hero-readout {
    font-family: var(--font-data);
}

.auth-hero-readout .pair {
    color: var(--text-muted);
    font-size: 13px;
    letter-spacing: 0.02em;
    margin: 0 0 10px;
}

.auth-hero-readout .price {
    font-size: 64px;
    font-weight: 500;
    line-height: 1;
    color: var(--text);
    margin: 0;
}

.auth-hero-readout .price .cents { color: var(--text-faint); }

.auth-hero-readout .delta {
    margin-top: 14px;
    font-size: 15px;
    color: var(--buy);
}

.pulse-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--buy);
    margin-right: 8px;
    animation: pulse 2.2s ease-in-out infinite;
}

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

.auth-hero-strip {
    display: flex;
    gap: 28px;
    font-family: var(--font-data);
    font-size: 12px;
    color: var(--text-faint);
    padding-top: 24px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.auth-hero-strip span b { color: var(--text-muted); font-weight: 500; }

.auth-hero-foot {
    font-size: 13px;
    color: var(--text-faint);
    max-width: 40ch;
    line-height: 1.6;
}

.auth-shell > main,
.auth-shell {
    display: grid;
}

.auth-card-col {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.auth-card {
    width: 100%;
    max-width: 380px;
}

.auth-mark {
    font-family: var(--font-data);
    font-size: 12px;
    color: var(--text-faint);
    margin: 0 0 28px;
}

.auth-title {
    font-size: 26px;
    font-weight: 600;
    margin: 0 0 8px;
    letter-spacing: -0.01em;
}

.auth-sub {
    color: var(--text-muted);
    font-size: 14.5px;
    line-height: 1.6;
    margin: 0 0 28px;
}

.auth-error {
    background: rgba(193, 102, 107, 0.12);
    border: 1px solid var(--sell-dim);
    color: #E3A2A5;
    font-size: 13.5px;
    padding: 10px 14px;
    border-radius: var(--radius);
    margin: 0 0 20px;
}

.auth-form { display: flex; flex-direction: column; gap: 6px; }

.auth-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 16px;
}

.auth-input {
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font-data);
    font-size: 14.5px;
    padding: 11px 13px;
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.15s ease;
}

.auth-input:focus {
    border-color: var(--live);
}

.auth-submit {
    margin-top: 26px;
    background: var(--text);
    color: var(--ink);
    border: none;
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 14.5px;
    padding: 12px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    transition: opacity 0.15s ease;
}

.auth-submit:hover { opacity: 0.85; }

.auth-submit--link { width: 100%; }

.auth-foot-note {
    margin-top: 22px;
    font-size: 12.5px;
    color: var(--text-faint);
    line-height: 1.6;
}

/* ---------------------------------------------------------------
   Dashboard shell
----------------------------------------------------------------*/
.app-shell {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--panel);
    border-right: 1px solid var(--border);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
}

.sidebar-mark {
    font-family: var(--font-data);
    font-size: 13px;
    color: var(--text);
    padding: 0 10px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
}

.sidebar-mark span { color: var(--text-faint); }

.nav-group-label {
    font-size: 11px;
    color: var(--text-faint);
    padding: 14px 10px 6px;
    letter-spacing: 0.03em;
}

.nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 10px;
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text-muted);
    text-decoration: none;
}

.nav-link:hover { background: var(--panel-raised); color: var(--text); }

.nav-link.active {
    background: var(--panel-raised);
    color: var(--text);
    box-shadow: inset 2px 0 0 var(--live);
}

.nav-link .tag {
    font-family: var(--font-data);
    font-size: 10px;
    color: var(--text-faint);
    border: 1px solid var(--border);
    padding: 1px 6px;
    border-radius: 999px;
}

.sidebar-foot {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 13px;
}

.sidebar-user {
    color: var(--text-muted);
    margin-bottom: 10px;
}

.sidebar-user b { color: var(--text); font-weight: 500; }

.logout-link {
    color: var(--text-faint);
    text-decoration: none;
    font-size: 13px;
}

.logout-link:hover { color: var(--sell); }

.main {
    padding: 30px 40px 60px;
    max-width: 1100px;
}

.main-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 6px;
}

.main-title {
    font-size: 22px;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.01em;
}

.main-date {
    font-family: var(--font-data);
    font-size: 12.5px;
    color: var(--text-faint);
}

.main-sub {
    color: var(--text-muted);
    font-size: 14px;
    margin: 0 0 32px;
}

/* Hero status readout */
.status-hero {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    padding: 26px 28px;
    margin-bottom: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
}

.status-hero-label {
    font-size: 12.5px;
    color: var(--text-muted);
    margin: 0 0 8px;
}

.status-hero-value {
    font-family: var(--font-data);
    font-size: 34px;
    font-weight: 500;
    margin: 0;
    color: var(--live);
}

.status-hero-value .unit {
    font-size: 16px;
    color: var(--text-faint);
    margin-left: 8px;
}

.status-hero-note {
    max-width: 42ch;
    font-size: 13.5px;
    color: var(--text-muted);
    line-height: 1.6;
    text-align: right;
}

/* Stat cards */
.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 40px;
}

.stat-cell {
    background: var(--panel);
    padding: 18px 20px;
}

.stat-cell-label {
    font-size: 12px;
    color: var(--text-faint);
    margin: 0 0 8px;
}

.stat-cell-value {
    font-family: var(--font-data);
    font-size: 20px;
    color: var(--text);
    margin: 0;
}

.stat-cell-value.buy { color: var(--buy); }
.stat-cell-value.sell { color: var(--sell); }
.stat-cell-value.muted { color: var(--text-faint); }

/* Section headings */
.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 0 0 14px;
}

.section-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}

.section-hint {
    font-size: 12.5px;
    color: var(--text-faint);
}

/* Phase ledger — a genuine sequence, so numbering earns its place */
.ledger {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 40px;
}

.ledger-row {
    display: grid;
    grid-template-columns: 40px 1fr 130px;
    align-items: center;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
}

.ledger-row:last-child { border-bottom: none; }

.ledger-num {
    font-family: var(--font-data);
    font-size: 12.5px;
    color: var(--text-faint);
}

.ledger-body b {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.ledger-body span {
    display: block;
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 2px;
}

.pill {
    justify-self: end;
    font-family: var(--font-data);
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--text-faint);
}

.pill.done { color: var(--buy); border-color: var(--buy-dim); }
.pill.active { color: var(--live); border-color: var(--live); }

/* Empty state */
.empty-panel {
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 30px 24px;
    color: var(--text-muted);
    font-size: 13.5px;
    line-height: 1.7;
}

.empty-panel b { color: var(--text); }

/* ---------------------------------------------------------------
   Backtesting (Phase 6) — run form, alert, results table.
----------------------------------------------------------------*/
.buy  { color: var(--buy); }
.sell { color: var(--sell); }

.bt-alert {
    border: 1px solid var(--sell-dim);
    background: rgba(193, 102, 107, 0.08);
    color: var(--sell);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 13.5px;
    margin-bottom: 20px;
}

.bt-form {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: end;
    border: 1px solid var(--border);
    background: var(--panel);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 32px;
}

.bt-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 140px;
}

.bt-field label {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-faint);
}

.bt-field select,
.bt-field input {
    background: var(--panel-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-data);
    font-size: 13.5px;
    padding: 9px 10px;
}

.bt-field select:focus,
.bt-field input:focus {
    outline: none;
    border-color: var(--text-faint);
}

.bt-field--submit { min-width: auto; }
.bt-field--submit .auth-submit { padding: 10px 22px; width: auto; }

.bt-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 32px;
}

.bt-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-data);
    font-size: 12.5px;
    white-space: nowrap;
}

.bt-table th {
    text-align: left;
    padding: 10px 14px;
    background: var(--panel-raised);
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 10.5px;
    font-weight: 500;
    border-bottom: 1px solid var(--border);
}

.bt-table td {
    padding: 9px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
}

.bt-table tbody tr:last-child td { border-bottom: none; }
.bt-table tbody tr:hover td { background: var(--panel-raised); }

/* ---------------------------------------------------------------
   Phase 8 — chart panel, per-pair grid, pagination
----------------------------------------------------------------*/
.chart-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    padding: 20px;
    margin-bottom: 32px;
    height: 300px;
    position: relative;
}

.chart-panel canvas { max-height: 100%; }

.pair-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 32px;
}

.pair-cell {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    padding: 14px 16px;
}

.pair-cell-name {
    font-family: var(--font-data);
    font-size: 13px;
    color: var(--text);
    margin: 0 0 8px;
}

.pair-cell-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-faint);
    margin-bottom: 3px;
}

.pair-cell-row b { font-family: var(--font-data); color: var(--text-muted); }
.pair-cell-row b.buy { color: var(--buy); }
.pair-cell-row b.sell { color: var(--sell); }

.paginator {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 16px 0 32px;
    font-family: var(--font-data);
    font-size: 12.5px;
}

.paginator a, .paginator span {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    text-decoration: none;
}

.paginator a:hover { border-color: var(--text-faint); color: var(--text); }
.paginator .current { border-color: var(--live); color: var(--live); }
.paginator .disabled { opacity: 0.35; pointer-events: none; }

/* ---------------------------------------------------------------
   Phase 9 — AI context notes
----------------------------------------------------------------*/
.ai-config-warning {
    border: 1px solid var(--live);
    background: rgba(217, 163, 74, 0.08);
    color: var(--live);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 13.5px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.ai-config-warning code { color: var(--text); }

.ai-pair-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
    margin-bottom: 32px;
}

.ai-note-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    padding: 18px 20px;
    margin-bottom: 16px;
}

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

.ai-note-pair {
    font-family: var(--font-data);
    font-size: 13px;
    color: var(--text);
}

.ai-note-time {
    font-family: var(--font-data);
    font-size: 11.5px;
    color: var(--text-faint);
}

.ai-note-body {
    font-size: 13.5px;
    line-height: 1.7;
    color: var(--text-muted);
    white-space: pre-wrap;
}

.pill.failed  { color: var(--sell); border-color: var(--sell-dim); }
.pill.pending { color: var(--live); border-color: var(--live); }

/* ---------------------------------------------------------------
   Phase 10 — exchange execution (manual approval)
----------------------------------------------------------------*/
.exec-safety-banner {
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 13.5px;
    line-height: 1.6;
    margin-bottom: 20px;
    border: 1px solid var(--live);
    background: rgba(217, 163, 74, 0.08);
    color: var(--live);
}

.exec-safety-banner.armed {
    border-color: var(--sell);
    background: rgba(193, 102, 107, 0.08);
    color: var(--sell);
}

.exec-safety-banner code { color: var(--text); }
.exec-safety-banner ul { margin: 8px 0 0; padding-left: 18px; }
.exec-safety-banner li { margin-bottom: 3px; }

.exec-request-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    padding: 18px 20px;
    margin-bottom: 16px;
}

.exec-request-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.exec-request-pair {
    font-family: var(--font-data);
    font-size: 14px;
    color: var(--text);
}

.exec-request-meta {
    font-family: var(--font-data);
    font-size: 11.5px;
    color: var(--text-faint);
}

.exec-request-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.exec-request-grid div { font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-faint); }
.exec-request-grid b { display: block; font-family: var(--font-data); font-size: 13.5px; color: var(--text-muted); margin-top: 3px; }

.exec-request-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.exec-request-actions input[type="text"] {
    background: var(--panel-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-data);
    font-size: 13px;
    padding: 9px 10px;
    min-width: 260px;
    flex: 1;
}

.exec-request-actions input[type="text"]:focus { outline: none; border-color: var(--text-faint); }

.exec-btn-approve {
    background: var(--sell-dim);
    border: 1px solid var(--sell);
    color: var(--text);
    border-radius: var(--radius);
    padding: 9px 16px;
    font-size: 13px;
    font-family: var(--font-ui);
    cursor: pointer;
}

.exec-btn-approve:disabled { opacity: 0.4; cursor: not-allowed; }

.exec-btn-reject {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius);
    padding: 9px 16px;
    font-size: 13px;
    font-family: var(--font-ui);
    cursor: pointer;
}

.exec-btn-reject:hover { border-color: var(--text-faint); color: var(--text); }

@media (max-width: 760px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .main { padding: 24px 20px 50px; }
}
