:root {
    --bg: #0B0B0F;
    --surface: #15151C;
    --text: #EDEDF2;
    --text-muted: #8A8A96;
    --positive: #5DCAA5;
    --negative: #F09595;
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.page {
    max-width: 480px;
    margin: 0 auto;
    padding: calc(64px + env(safe-area-inset-top)) 20px calc(96px + env(safe-area-inset-bottom));
}

.app-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg);
    padding: calc(12px + env(safe-area-inset-top)) 20px 12px;
    max-width: 480px;
    margin: 0 auto;
}

.app-logo {
    height: 22px;
    width: auto;
    border-radius: 4px;
    display: block;
}

.hamburger-btn {
    width: auto;
    background: none;
    border: none;
    color: var(--text);
    padding: 4px;
    margin: 0;
    cursor: pointer;
    display: flex;
}

.menu-panel {
    position: fixed;
    top: calc(54px + env(safe-area-inset-top));
    right: 20px;
    background: var(--surface);
    border-radius: 12px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 40;
    min-width: 170px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.menu-panel.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.menu-panel a,
.menu-panel-logout {
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    padding: 10px 12px;
    border-radius: 8px;
    background: none;
    border: none;
    text-align: left;
    width: 100%;
    cursor: pointer;
}

.menu-panel-logout {
    color: var(--negative);
}

.menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: none;
}

.menu-backdrop.open {
    display: block;
}

.bottom-tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    background: var(--surface);
    border-top: 1px solid #26262E;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    max-width: 480px;
    margin: 0 auto;
}

.bottom-tabbar .tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-muted);
    text-decoration: none;
    padding: 8px 0;
    font-size: 11px;
}

.bottom-tabbar .tab.active {
    color: var(--positive);
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
}

.muted {
    color: var(--text-muted);
    font-size: 13px;
}

.hero {
    font-size: 58px;
    font-weight: 500;
    letter-spacing: -2px;
    color: var(--positive);
    margin: 8px 0 2px;
}

.hero.negative {
    color: var(--negative);
}

.sport-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 14px;
}

.sport-card {
    text-align: center;
    padding: 12px 4px;
}

.sport-card-value {
    font-size: 17px;
    font-weight: 500;
    color: var(--positive);
    margin: 5px 0 0;
}

.sport-card-value.negative {
    color: var(--negative);
}

.metric-line {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 13px;
}

.metric-line.centered {
    justify-content: center;
}

.metric-line .metric-icon {
    color: var(--text-muted);
    display: inline-flex;
    flex-shrink: 0;
}

.badge {
    background: #3A2E14;
    color: #FAC775;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 8px;
}

button {
    background: #1D1D25;
    color: var(--text);
    border: none;
    border-radius: 12px;
    padding: 12px;
    font-size: 14px;
    width: 100%;
    cursor: pointer;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.bar-row {
    margin-bottom: 12px;
}

.bar-track {
    background: #1D1D25;
    border-radius: 6px;
    height: 10px;
    overflow: hidden;
    margin: 4px 0;
}

.bar-fill {
    height: 100%;
    border-radius: 6px;
}

.bar-fill.this-year {
    background: var(--positive);
}

.bar-fill.last-year {
    background: #4A4A56;
}

.positive {
    color: var(--positive);
}

.negative {
    color: var(--negative);
}

.metric-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 13px;
}

.metric-table th {
    text-align: right;
    font-weight: 400;
    color: var(--text-muted);
    font-size: 10.5px;
    padding-bottom: 6px;
    white-space: normal;
    line-height: 1.3;
}

.metric-table td {
    text-align: right;
    padding: 6px 0 6px 6px;
    border-top: 1px solid #232329;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.metric-table th:first-child,
.metric-table td:first-child {
    text-align: left;
}

.metric-table-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
}

.metric-table-total td {
    border-top: 1px solid #3A3A44;
    font-weight: 600;
    color: var(--text);
}

.metric-table-total .metric-table-label {
    color: var(--text);
}

.pager-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.pager-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text);
    text-decoration: none;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
}

.pager-btn:active {
    background: #1D1D25;
}

.pager-btn.disabled {
    color: var(--text-muted);
    opacity: 0.35;
    cursor: default;
}

.pager-label {
    color: var(--text-muted);
    font-size: 12px;
    margin: 0;
    text-align: center;
}

.info-disclosure {
    margin-top: 6px;
}

.info-disclosure summary {
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    padding: 2px 0;
    width: fit-content;
}

.info-disclosure summary:hover {
    color: var(--text);
}

.info-disclosure p {
    color: var(--text-muted);
    font-size: 12px;
    margin: 8px 0 0;
}

.message-stack {
    max-width: 480px;
    margin: calc(64px + env(safe-area-inset-top)) auto 0;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message-banner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.4;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.message-banner--error {
    background: #3A1414;
    color: #F8B4B4;
    border: 1px solid #5C1E1E;
}

.message-banner--success {
    background: #0F2A21;
    color: #9FE1CB;
    border: 1px solid #17553F;
}

.message-banner--info,
.message-banner--warning,
.message-banner--debug {
    background: #1D1D25;
    color: var(--text);
    border: 1px solid #2C2C36;
}

.message-banner-text {
    flex: 1;
}

.message-banner-dismiss {
    background: none;
    border: none;
    color: inherit;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    width: auto;
    cursor: pointer;
    opacity: 0.7;
}

.message-banner-dismiss:hover {
    opacity: 1;
}

.sync-stale-warning {
    color: #F09595;
    font-size: 12px;
    margin-top: 10px;
    padding: 10px 12px;
    background: #2A1414;
    border-radius: 10px;
}

.sync-error-block {
    margin-top: 10px;
    padding: 10px 12px;
    background: #2A1414;
    border-radius: 10px;
}

.sync-error-title {
    color: #F09595;
    font-weight: 500;
    margin: 0;
}

.sync-error-detail {
    color: #F09595;
    font-size: 12px;
    margin: 6px 0 0;
    opacity: 0.85;
}

main a {
    color: var(--positive);
}

.auth-card {
    text-align: center;
}

.auth-card h1 {
    margin: 0 0 4px;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0 0 20px;
}

.auth-card form {
    text-align: left;
}

.auth-card form p {
    margin: 0 0 14px;
}

.auth-card form label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.auth-card form input[type="text"],
.auth-card form input[type="email"],
.auth-card form input[type="password"] {
    width: 100%;
    background: #1D1D25;
    border: 1px solid #2C2C36;
    border-radius: 10px;
    padding: 12px 14px;
    color: var(--text);
    font-size: 14px;
}

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

.auth-card form .helptext,
.auth-card form ul {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin: 6px 0 0;
    padding: 0 0 0 16px;
}

.auth-card form ul li {
    margin-bottom: 2px;
}

.auth-card form ul.errorlist {
    list-style: none;
    padding: 0;
    margin: 0 0 6px;
    color: var(--negative);
    font-size: 12px;
}

.auth-links {
    margin-top: 16px;
    font-size: 13px;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 12px;
    margin: 20px 0;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #232329;
}

.btn-strava {
    background: #FC4C02;
    color: #fff;
}

.activity-list {
    margin-top: 10px;
}

.activity-row {
    padding: 10px 0;
    border-top: 1px solid #232329;
}

.activity-row:first-child {
    border-top: none;
    padding-top: 0;
}

.activity-row:last-child {
    padding-bottom: 0;
}

.activity-row-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.activity-row-name {
    font-size: 14px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.activity-row-sub {
    font-size: 12px;
    margin: 3px 0 0;
}

.activity-strava-link {
    flex-shrink: 0;
    font-size: 12px;
    color: #FC4C02;
    font-weight: 500;
    text-decoration: none;
}
