:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-hover: #232735;
    --border: #2a2e3a;
    --text: #e4e6eb;
    --text-muted: #8b8fa3;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --green: #22c55e;
    --red: #ef4444;
    --yellow: #eab308;
    --orange: #f97316;
    --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* Navbar */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.nav-brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.nav-links { display: flex; gap: 1.5rem; }

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    padding: 0.25rem 0;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.nav-links a.active,
.nav-links a:hover {
    color: var(--text);
    border-bottom-color: var(--primary);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Goal Page */
.goal-page { max-width: 800px; margin: 0 auto; }
.goal-page h1 { margin-bottom: 0.5rem; }
.goal-page h2 { margin: 1.5rem 0 1rem; }

.subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

.active-goal-card {
    background: var(--surface);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.active-goal-card h3 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.goal-form .form-group { margin-bottom: 1.5rem; }

.goal-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.goal-form textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
}

.goal-form textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.hint {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-lg { padding: 0.8rem 2rem; font-size: 1.05rem; }
.btn-secondary { background: var(--surface-hover); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; margin-left: auto; }

/* Dashboard Header */
.dashboard-header { margin-bottom: 1.5rem; }

.dashboard-header h1 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
}

.data-freshness {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.analysis-card {
    background: var(--surface);
    border-left: 3px solid var(--primary);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 1rem 1.25rem;
    margin: 1rem 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.priority-card {
    background: rgba(234, 179, 8, 0.08);
    border-left: 3px solid var(--yellow);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 1rem 1.25rem;
    margin: 0.75rem 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.priority-card strong {
    color: var(--yellow);
}

/* Dashboard Controls */
.dashboard-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    flex-wrap: wrap;
}

.control-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.window-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.window-btn {
    padding: 0.35rem 0.85rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.window-btn:hover {
    border-color: var(--primary);
    color: var(--text);
}

.window-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Sort Controls */
.sort-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.sort-select {
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface-hover);
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238b8fa3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    padding-right: 1.5rem;
}

.sort-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Metric Categories */
.metric-category {
    margin-bottom: 2rem;
}

.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
    user-select: none;
}

.category-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.category-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface-hover);
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
}

.category-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 1.25rem;
    transition: all 0.25s ease;
}

.category-grid.collapsed {
    display: none;
}

/* Metric Cards */
.metric-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: border-color 0.2s;
}

.metric-card:hover {
    border-color: var(--primary);
}

.metric-card.priority-high {
    border-left: 3px solid var(--green);
}

.metric-card.priority-medium {
    border-left: 3px solid var(--yellow);
}

.metric-card.priority-low {
    border-left: 3px solid var(--text-muted);
}

.metric-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
}

.metric-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.metric-card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

/* Status Badges (replaces trend badges) */
.status-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    text-transform: uppercase;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.status-good { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.status-acceptable { background: rgba(234, 179, 8, 0.15); color: var(--yellow); }
.status-needs-improvement { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.status-none { display: none; }

/* Metric Values */
.metric-current-row {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
}

.metric-current {
    font-size: 1.6rem;
    font-weight: 700;
}

.metric-unit {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 0.15rem;
}

.target-range {
    font-size: 0.8rem;
    color: var(--green);
    font-weight: 500;
}

/* Charts */
.metric-chart-container {
    height: 170px;
    margin: 0.5rem 0;
}

/* Learn More Expandable */
.metric-explanation {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.metric-explanation summary {
    cursor: pointer;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    list-style: none;
}

.metric-explanation summary::-webkit-details-marker {
    display: none;
}

.learn-more-icon {
    font-size: 0.9rem;
}

.metric-explanation .detail-section {
    margin-top: 0.5rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.metric-explanation .detail-section strong {
    color: var(--text);
    display: block;
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
}

.metric-explanation .detail-section p {
    margin: 0;
}

.metric-explanation .detail-section code.metric-formula {
    display: block;
    background: var(--bg-muted, #f5f5f5);
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Succinct Tips */
.metric-tips {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.metric-tips ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.metric-tips li {
    font-size: 0.78rem;
    color: var(--text-muted);
    padding: 0.2rem 0;
    padding-left: 1rem;
    position: relative;
    line-height: 1.4;
}

.metric-tips li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--primary);
}

.explore-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    opacity: 0.7;
    margin-top: 0.35rem;
    font-style: italic;
}

/* ===== TODAY VIEW (Training Readiness) ===== */
.today-view {
    max-width: 600px;
    margin: 0 auto;
}

.readiness-hero {
    text-align: center;
    padding: 2rem 1rem;
}

.readiness-ring {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: conic-gradient(
        var(--ring-color) calc(var(--ring-pct) * 3.6deg),
        var(--border) calc(var(--ring-pct) * 3.6deg)
    );
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    position: relative;
}

.readiness-ring::before {
    content: "";
    position: absolute;
    inset: 12px;
    border-radius: 50%;
    background: var(--bg);
}

.readiness-score {
    font-size: 2.5rem;
    font-weight: 800;
    position: relative;
    z-index: 1;
    line-height: 1;
}

.readiness-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    position: relative;
    z-index: 1;
    margin-top: 0.25rem;
}

.readiness-recommendation {
    color: var(--text-muted);
    font-size: 0.95rem;
    max-width: 400px;
    margin: 0 auto;
}

/* Components */
.readiness-components {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin: 1rem 0;
}

.readiness-components h3 {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.component-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.component-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    align-items: center;
}

.component-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    grid-column: 1;
    grid-row: 1;
}

.component-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    grid-column: 2;
    grid-row: 1;
    text-align: right;
}

.component-bar-track {
    grid-column: 1 / -1;
    grid-row: 2;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.component-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* Today Tips */
.today-tips {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin: 1rem 0;
}

.today-tips h3 {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.today-tips ul {
    list-style: none;
    padding: 0;
}

.today-tips li {
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
    line-height: 1.4;
}

.today-tips li:last-child {
    border-bottom: none;
}

.today-tips li strong {
    color: var(--text);
}

.today-action {
    text-align: center;
    margin-top: 1.5rem;
}

/* States */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-state h2 { margin-bottom: 0.75rem; }
.empty-state p { color: var(--text-muted); margin-bottom: 1.5rem; }

.loading {
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

/* Upload Page */
.upload-page { max-width: 700px; margin: 0 auto; }
.upload-page h1 { margin-bottom: 0.5rem; }

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--surface);
    margin: 1.5rem 0;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-icon {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
    font-weight: 300;
}

.upload-text { font-size: 1.1rem; font-weight: 600; }
.upload-hint { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.25rem; }

.upload-status {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin: 1rem 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.status-success { background: rgba(34, 197, 94, 0.1); border: 1px solid var(--green); color: var(--green); }
.status-error { background: rgba(239, 68, 68, 0.1); border: 1px solid var(--red); color: var(--red); }
.status-loading { background: rgba(99, 102, 241, 0.1); border: 1px solid var(--primary); color: var(--primary); }

.upload-instructions {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 2rem;
}

.upload-instructions h3 { margin-bottom: 1rem; font-size: 1rem; }

.upload-instructions ol {
    padding-left: 1.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.upload-instructions li { margin-bottom: 0.5rem; }
.upload-instructions strong { color: var(--text); }

/* Auth Pages */
.auth-page { max-width: 420px; margin: 2rem auto; }
.auth-page h1 { text-align: center; margin-bottom: 1.5rem; }

.auth-form .form-group { margin-bottom: 1.25rem; }

.auth-form label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
}

.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="text"] {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.auth-link {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

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

.auth-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--red);
    color: var(--red);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Settings Page */
.settings-page { max-width: 700px; margin: 0 auto; }
.settings-page h1 { margin-bottom: 1.5rem; }

.settings-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}

.settings-card h3 { margin-bottom: 0.75rem; font-size: 1rem; }

.token-display {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.65rem 1rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    word-break: break-all;
    color: var(--primary);
    margin: 0.5rem 0;
}

/* Setup Page */
.setup-page { max-width: 750px; margin: 0 auto; }
.setup-page > h1 { margin-bottom: 0.5rem; }
.setup-subtitle { color: var(--text-muted); margin-bottom: 2rem; }

.setup-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.setup-card h2 { margin-bottom: 0.75rem; font-size: 1.15rem; }
.setup-highlight { border-color: var(--primary); }

.url-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.65rem 1rem;
    margin: 0.75rem 0;
    word-break: break-all;
}
.url-box code {
    flex: 1;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.8rem;
    color: var(--primary);
}

.setup-warn {
    font-size: 0.8rem;
    color: var(--yellow);
    margin-top: 0.25rem;
}

.step {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}
.step:last-child { border-bottom: none; }

.step-num {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.step-content h3 { font-size: 0.95rem; margin-bottom: 0.35rem; }
.step-content p { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.35rem; }
.step-content ul, .step-content ol { font-size: 0.85rem; color: var(--text-muted); padding-left: 1.25rem; margin: 0.35rem 0; }
.step-content li { margin-bottom: 0.25rem; }
.step-content code { background: var(--bg); padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.8rem; }

.metric-list { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.metric-chip {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.btn-copy-inline {
    background: none;
    border: 1px solid var(--border);
    color: var(--primary);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
}
.btn-copy-inline:hover { background: var(--surface-hover); }

.setup-card details { margin-bottom: 0.75rem; }
.setup-card summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.5rem 0;
}
.setup-card details p { font-size: 0.85rem; color: var(--text-muted); padding: 0.25rem 0 0.5rem 0; }

/* Responsive */
@media (max-width: 768px) {
    .container { padding: 1rem; }
    .category-grid {
        grid-template-columns: 1fr;
    }
    .dashboard-controls {
        flex-wrap: wrap;
    }
    .window-selector {
        gap: 0.35rem;
    }
    .window-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }
    .sort-controls {
        margin-left: 0;
    }
    .readiness-ring {
        width: 130px;
        height: 130px;
    }
    .readiness-score {
        font-size: 2rem;
    }
}
