:root {
    --bg: var(--tg-theme-bg-color, #ffffff);
    --text: var(--tg-theme-text-color, #000000);
    --hint: var(--tg-theme-hint-color, #999999);
    --button: var(--tg-theme-button-color, #2481cc);
    --button-text: var(--tg-theme-button-text-color, #ffffff);
    --secondary-bg: var(--tg-theme-secondary-bg-color, #f0f0f0);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    padding: 0 12px 24px;
    max-width: 480px;
    margin: 0 auto;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    padding: 12px 0;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 10;
}

.tab-btn {
    flex: 1;
    padding: 8px 4px;
    border: none;
    border-radius: 8px;
    background: var(--secondary-bg);
    color: var(--hint);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--button);
    color: var(--button-text);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Readiness gauge */
.gauge-container {
    display: flex;
    justify-content: center;
    padding: 16px 0;
}

.gauge {
    position: relative;
    width: 160px;
    height: 160px;
}

.gauge canvas { width: 100%; height: 100%; }

.gauge-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.gauge-score {
    font-size: 36px;
    font-weight: 700;
    line-height: 1;
}

.gauge-text {
    font-size: 12px;
    color: var(--hint);
    margin-top: 2px;
}

/* Metric cards */
.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}

.metric-card {
    background: var(--secondary-bg);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
}

.metric-value {
    font-size: 22px;
    font-weight: 700;
}

.metric-label {
    font-size: 11px;
    color: var(--hint);
    margin-top: 2px;
}

/* Section cards */
.card {
    background: var(--secondary-bg);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}

.card-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 8px;
}

.card p, .card pre {
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
}

/* Progress bars */
.progress-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.progress-label {
    width: 50px;
    font-size: 13px;
    font-weight: 600;
}

.progress-bar {
    flex: 1;
    height: 10px;
    background: var(--bg);
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.5s ease;
}

.progress-fill.swim { background: #3b82f6; }
.progress-fill.bike { background: #22c55e; }
.progress-fill.run  { background: #f59e0b; }

.progress-pct {
    width: 40px;
    font-size: 13px;
    text-align: right;
}

/* Charts */
.chart-container {
    background: var(--secondary-bg);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
}

.chart-container canvas {
    width: 100% !important;
    max-height: 250px;
}

/* Week table */
.week-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.week-table th {
    text-align: left;
    padding: 6px 4px;
    border-bottom: 1px solid var(--hint);
    color: var(--hint);
    font-weight: 500;
}

.week-table td {
    padding: 8px 4px;
    border-bottom: 1px solid var(--secondary-bg);
}

/* Countdown */
.countdown {
    text-align: center;
    padding: 16px;
    font-size: 20px;
    font-weight: 700;
}

.countdown span { color: var(--button); }

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--hint);
}

/* No data */
.no-data {
    text-align: center;
    padding: 24px;
    color: var(--hint);
    font-size: 14px;
}
