/* ── Self-hosted Roboto font faces ── */
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/roboto-latin-ext-400-normal.woff2') format('woff2'),
         url('../fonts/roboto-latin-400-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('../fonts/roboto-latin-ext-500-normal.woff2') format('woff2'),
         url('../fonts/roboto-latin-500-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/roboto-latin-ext-700-normal.woff2') format('woff2'),
         url('../fonts/roboto-latin-700-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 900;
    font-display: swap;
    src: url('../fonts/roboto-latin-ext-900-normal.woff2') format('woff2'),
         url('../fonts/roboto-latin-900-normal.woff2') format('woff2');
}

/* ── Design tokens (from Stitch) ── */
:root {
    --primary: #705d00;
    --primary-dim: #625100;
    --primary-container: #ffe16d;
    --primary-fixed: #ffe16d;
    --on-primary: #fff7e6;
    --on-primary-container: #615100;
    --surface: #f9f9f9;
    --surface-dim: #d4dbdd;
    --surface-container: #ebeeef;
    --surface-container-low: #f2f4f4;
    --surface-container-high: #e4e9ea;
    --surface-container-lowest: #ffffff;
    --surface-variant: #dde4e5;
    --on-surface: #2d3435;
    --on-surface-variant: #5a6061;
    --outline: #757c7d;
    --outline-variant: #adb3b4;
    --error: #9e422c;
    --error-container: #fe8b70;
    --on-error: #fff7f6;
    --success: #10b981;
    --sidebar-width: 256px;
}

/* ── Reset & base ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    font-family: 'Roboto', sans-serif;
    background: var(--surface);
    color: var(--on-surface);
    overflow: hidden;
}

/* ── App shell: sidebar + main ── */
.app-shell { display: flex; height: 100vh; }

/* ── Sidebar ── */
.sidebar {
    display: none;
    flex-direction: column;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--surface-container-lowest);
    border-right: 1px solid rgba(173, 179, 180, 0.1);
}
@media (min-width: 768px) { .sidebar { display: flex; } }

.sidebar-brand { padding: 40px 32px 32px; }
.sidebar-brand h1 { font-size: 1.25rem; font-weight: 900; letter-spacing: -0.03em; line-height: 1.3; }
.sidebar-brand .version-tag {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--on-surface-variant);
    opacity: 0.6;
    margin-top: 4px;
}

.sidebar-nav { flex: 1; padding: 0 16px; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--on-surface);
    opacity: 0.7;
    transition: all 0.2s;
}
.sidebar-nav a:hover { color: var(--primary); opacity: 1; }
.sidebar-nav a.active {
    color: var(--primary);
    font-weight: 700;
    opacity: 1;
    background: rgba(112, 93, 0, 0.06);
    transform: translateX(4px);
}
.sidebar-nav a svg { width: 20px; height: 20px; flex-shrink: 0; }

.sidebar-footer {
    padding: 24px;
    border-top: 1px solid rgba(173, 179, 180, 0.1);
}
.sidebar-user { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.sidebar-user-avatar {
    width: 32px; height: 32px;
    background: var(--surface-variant);
    display: flex; align-items: center; justify-content: center;
}
.sidebar-user-avatar svg { width: 16px; height: 16px; color: var(--on-surface-variant); }
.sidebar-user-name { font-size: 0.75rem; font-weight: 700; }
.sidebar-user-role { font-size: 10px; color: var(--on-surface-variant); }
.sidebar-links a {
    display: flex; align-items: center; gap: 16px;
    padding: 8px; font-size: 0.75rem;
    color: var(--on-surface-variant);
    text-decoration: none; transition: color 0.2s;
}
.sidebar-links a:hover { color: var(--primary); }
.sidebar-links a svg { width: 16px; height: 16px; }

/* ── Main content area ── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--surface);
}
.main-content::-webkit-scrollbar { width: 4px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb { background: var(--outline-variant); }

/* ── Top bar ── */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    background: var(--surface-container-lowest);
    position: sticky;
    top: 0;
    z-index: 30;
}
.top-bar-title {
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--on-surface);
    opacity: 0.4;
}
.top-bar-subtitle { font-size: 10px; color: var(--on-surface-variant); }
.top-bar-actions { display: flex; align-items: center; gap: 24px; }

.live-badge {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 12px;
    background: var(--surface);
    border: 1px solid rgba(173, 179, 180, 0.2);
}
.live-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--primary);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.live-badge span {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.15em;
}

.top-bar-icons { display: flex; align-items: center; gap: 16px; }
.top-bar-icons button {
    background: none; border: none; cursor: pointer; padding: 4px;
    color: var(--on-surface-variant);
    transition: color 0.2s;
}
.top-bar-icons button:hover { color: var(--primary); }
.top-bar-icons svg { width: 20px; height: 20px; }

/* ── Content padding ── */
.content-area { padding: 32px; }
.content-area > * + * { margin-top: 48px; }
@media (max-width: 767px) { .content-area { padding-bottom: 96px; } }

/* ── Bento grid: top row ── */
.bento-top { display: grid; grid-template-columns: 1fr; gap: 32px; }
@media (min-width: 1024px) {
    .bento-top { grid-template-columns: 5fr 7fr; }
}

/* ── Prediction card ── */
.prediction-card {
    background: var(--surface-container-lowest);
    padding: 40px;
    border-left: 4px solid var(--primary);
    position: relative;
}
.prediction-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 32px; }
.prediction-label {
    font-size: 0.75rem; font-weight: 700;
    letter-spacing: 0.15em; text-transform: uppercase;
    color: var(--on-surface-variant); margin-bottom: 4px;
}
.prediction-updated { font-size: 10px; color: var(--on-surface-variant); opacity: 0.6; }

.signal-badge {
    font-size: 10px; font-weight: 700;
    padding: 4px 12px;
    text-transform: uppercase; letter-spacing: -0.03em;
}
.signal-badge.bearish { background: rgba(254, 139, 112, 0.2); color: var(--error-container); }
.signal-badge.bullish { background: rgba(16, 185, 129, 0.2); color: var(--success); }

.prediction-price { font-size: 3rem; font-weight: 900; letter-spacing: -0.02em; margin-bottom: 8px; }
.prediction-returns { display: flex; align-items: center; gap: 8px; font-size: 0.875rem; font-weight: 700; letter-spacing: -0.03em; }
.prediction-returns.negative { color: var(--error); }
.prediction-returns.positive { color: var(--success); }
.prediction-returns svg { width: 16px; height: 16px; }

.confidence-section {
    margin-top: 40px; padding-top: 24px;
    border-top: 1px solid rgba(173, 179, 180, 0.1);
}
.confidence-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.confidence-label { font-size: 0.75rem; color: var(--on-surface-variant); }
.confidence-value { font-size: 0.75rem; font-weight: 700; }
.confidence-bar { width: 100%; height: 4px; background: var(--surface-container); }
.confidence-fill { height: 100%; background: var(--primary); transition: width 0.6s ease; }

.indicator-row {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 12px; margin-top: 24px;
}
.indicator-item { text-align: center; }
.indicator-item-label { font-size: 10px; color: var(--on-surface-variant); text-transform: uppercase; letter-spacing: 0.1em; }
.indicator-item-value { font-size: 1rem; font-weight: 700; margin-top: 4px; }

/* ── Stats grid (right side of bento top) ── */
.stats-bento { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (min-width: 768px) { .stats-bento { grid-template-columns: repeat(4, 1fr); } }

.stat-box {
    background: var(--surface-container-low);
    padding: 24px;
    display: flex; flex-direction: column; justify-content: space-between;
}
.stat-box-label {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.15em;
    color: var(--on-surface-variant);
}
.stat-box-value { font-size: 1.875rem; font-weight: 900; margin-top: 16px; }
.stat-box-value.gold { color: var(--primary); }

.stat-full {
    grid-column: 1 / -1;
    background: var(--surface-container-low);
    padding: 32px;
    display: flex; align-items: center; justify-content: space-between; gap: 32px;
}
.stat-full-title {
    font-size: 0.75rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.15em;
    color: var(--on-surface-variant); margin-bottom: 8px;
}
.stat-full-desc { font-size: 0.875rem; color: var(--on-surface); opacity: 0.6; max-width: 420px; }
.stat-full-metric { text-align: right; flex-shrink: 0; }
.stat-full-big { font-size: 1.5rem; font-weight: 900; }
.stat-full-sub {
    font-size: 10px; text-transform: uppercase;
    letter-spacing: 0.15em; color: var(--on-surface-variant);
}

/* ── Chart sections ── */
.section-header {
    display: flex; justify-content: space-between;
    align-items: flex-end; margin-bottom: 24px;
}
.section-title { font-size: 1.125rem; font-weight: 700; letter-spacing: -0.02em; }
.section-subtitle { font-size: 0.75rem; color: var(--on-surface-variant); }

.time-range-btns { display: flex; gap: 8px; }
.time-range-btn {
    padding: 4px 16px;
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.15em;
    border: 1px solid rgba(173, 179, 180, 0.3);
    background: transparent; cursor: pointer;
    transition: all 0.2s;
}
.time-range-btn:hover { background: var(--surface-variant); }
.time-range-btn.active {
    border-color: var(--primary);
    background: rgba(255, 225, 109, 0.2);
    color: var(--primary);
}

.chart-panel {
    background: var(--surface-container-lowest);
    padding: 32px;
    position: relative;
    height: 320px;
}
.chart-panel canvas { width: 100% !important; height: 100% !important; }

.chart-legend { display: flex; gap: 24px; margin-top: 16px; }
.chart-legend-item { display: flex; align-items: center; gap: 8px; }
.chart-legend-line {
    width: 12px; height: 2px;
}
.chart-legend-line.solid { background: var(--on-surface); }
.chart-legend-line.dashed {
    background: none;
    border-top: 2px dashed var(--primary);
}
.chart-legend-text {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; color: var(--on-surface-variant);
}

/* (bottom-section-title removed -- all sections now full-width using .section-header) */

/* ── Model management ── */
.model-panel {
    background: var(--surface-container-lowest);
    padding: 32px;
    display: flex; flex-direction: column; gap: 32px;
}
.scheduler-row {
    display: flex; justify-content: space-between;
    align-items: center; flex-wrap: wrap; gap: 16px;
}
.scheduler-info { display: flex; align-items: center; gap: 12px; }
.scheduler-info svg { width: 24px; height: 24px; color: var(--primary); }
.scheduler-label-text {
    font-size: 0.75rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.15em;
}
.scheduler-status-text { font-size: 10px; font-weight: 900; color: var(--primary); }

.btn-row { display: flex; gap: 16px; flex-wrap: wrap; }

.btn-primary {
    background: var(--primary);
    color: var(--on-primary);
    border: none; cursor: pointer;
    padding: 8px 24px;
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.15em;
    font-family: 'Roboto', sans-serif;
    transition: opacity 0.2s;
}
.btn-primary:hover { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-outline {
    background: transparent;
    border: 1px solid rgba(173, 179, 180, 0.3);
    cursor: pointer;
    padding: 12px;
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.15em;
    font-family: 'Roboto', sans-serif;
    flex: 1;
    transition: all 0.2s;
    color: var(--on-surface);
}
.btn-outline:hover { background: var(--surface-variant); }
.btn-outline:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-outline.danger:hover { color: var(--error); }

.retrain-feedback {
    font-size: 0.85rem;
    padding: 10px 14px;
    display: none;
}
.retrain-feedback.info { background: rgba(59, 130, 246, 0.1); color: #3b82f6; display: block; }
.retrain-feedback.success { background: rgba(16, 185, 129, 0.1); color: var(--success); display: block; }
.retrain-feedback.error { background: rgba(158, 66, 44, 0.1); color: var(--error); display: block; }

/* ── Version table ── */
.version-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.version-table th {
    text-align: left; padding: 8px 6px;
    border-bottom: 1px solid rgba(173, 179, 180, 0.15);
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--on-surface-variant);
}
.version-table td {
    padding: 8px 6px;
    border-bottom: 1px solid rgba(173, 179, 180, 0.06);
}
.version-table tr.active-row td { color: var(--primary); }
.active-badge {
    background: rgba(255, 225, 109, 0.3);
    color: var(--primary);
    padding: 2px 8px; font-size: 0.7rem; font-weight: 700;
}

/* ── Footer ── */
.app-footer {
    padding: 48px 0 48px;
    border-top: 1px solid rgba(173, 179, 180, 0.1);
    opacity: 0.4;
    transition: opacity 0.3s;
}
.app-footer:hover { opacity: 1; }
.app-footer-inner { display: flex; justify-content: space-between; align-items: flex-start; gap: 32px; flex-wrap: wrap; }
.footer-notice-title {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.2em;
    margin-bottom: 12px;
}
.footer-notice-text { font-size: 11px; line-height: 1.6; max-width: 640px; }
.footer-meta { display: flex; gap: 40px; flex-shrink: 0; }
.footer-meta-label {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; margin-bottom: 4px;
}
.footer-meta-value { font-size: 10px; }

/* ── Loading / error states ── */
.loading { text-align: center; padding: 40px; color: var(--on-surface-variant); }
.loading-spinner {
    border: 3px solid rgba(112, 93, 0, 0.1);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 32px; height: 32px;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-msg { color: var(--error); text-align: center; padding: 20px; }

/* ── Language switcher (in top-bar) ── */
.lang-switcher {
    display: flex; gap: 4px;
    background: var(--surface-container-low);
    padding: 4px;
}
.lang-btn {
    background: transparent; border: none;
    color: var(--on-surface-variant);
    padding: 4px 10px; cursor: pointer;
    font-size: 0.75rem; font-weight: 500;
    font-family: 'Roboto', sans-serif;
    transition: all 0.2s;
}
.lang-btn:hover { color: var(--on-surface); background: rgba(173, 179, 180, 0.15); }
.lang-btn.active { background: rgba(255, 225, 109, 0.3); color: var(--primary); }

/* ── Mobile bottom nav ── */
.mobile-bottom-nav {
    display: flex; justify-content: space-around;
    align-items: center;
    position: fixed; bottom: 0; left: 0;
    width: 100%; height: 64px; z-index: 50;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(16px);
    border-top: 1px solid rgba(173, 179, 180, 0.1);
    padding: 0 16px;
}
@media (min-width: 768px) { .mobile-bottom-nav { display: none; } }
.mobile-bottom-nav a {
    display: flex; flex-direction: column;
    align-items: center; gap: 4px;
    text-decoration: none;
    color: var(--on-surface); opacity: 0.4;
    font-size: 8px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.15em;
}
.mobile-bottom-nav a.active { color: var(--primary); opacity: 1; border-top: 2px solid var(--primary); padding-top: 4px; }
.mobile-bottom-nav svg { width: 20px; height: 20px; }

/* ── Mobile FAB ── */
.mobile-fab {
    display: none; position: fixed;
    bottom: 96px; right: 24px;
    width: 56px; height: 56px;
    background: var(--primary); color: var(--on-primary);
    border: none; cursor: pointer; z-index: 40;
    align-items: center; justify-content: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}
@media (max-width: 767px) { .mobile-fab { display: flex; } }
.mobile-fab svg { width: 24px; height: 24px; }

/* ── Utilities ── */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
