/* ── Reset & base ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background: #f5f5f5;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1 { color: #2c3e50; margin-top: 0; }
h2 { color: #34495e; margin-top: 30px; }

/* ── Layout containers ───────────────────────────────────────────────────────── */
.container {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.container-narrow {
    max-width: 860px;
    margin: 24px auto;
    padding: 0 16px;
}

.container-wide {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 20px;
}

/* ── App header ────────────────────────────────────────────────────────────── */
.app-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    height: 54px;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #1a1a2e;
    flex-shrink: 0;
}
.header-logo { height: 26px; width: auto; }
.header-name { font-weight: 700; font-size: 1.05rem; letter-spacing: .02em; }
.header-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    color: rgba(0,0,0,.4);
    flex-shrink: 0;
}
.breadcrumb-sep  { color: rgba(0,0,0,.2); }
.breadcrumb-active { color: rgba(0,0,0,.75); font-weight: 500; }
.header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}
.header-recent {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: rgba(0,0,0,.4);
    white-space: nowrap;
    margin-right: 4px;
}
.recent-label { text-transform: uppercase; letter-spacing: .05em; font-size: 0.7rem; }
.recent-value  { color: rgba(0,0,0,.65); font-variant-numeric: tabular-nums; }
.header-logout-form { display: contents; }
.header-nav-link {
    color: rgba(0,0,0,.55);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 6px 12px;
    border-radius: 4px;
    transition: background .15s, color .15s;
}
.header-nav-link:hover { background: rgba(0,0,0,.05); color: #1a1a2e; }
.header-nav-link.active { color: #1a1a2e; background: rgba(0,0,0,.07); }
/* Active state for the settings gear (shares .notif-bell class) */
.notif-bell.active { color: #1a1a2e; background: rgba(0,0,0,.07); }

/* ── Site nav (shared by index + calendar) ───────────────────────────────────── */
.site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    text-align: center;
    justify-content: center;
}

/* ── Nav links & buttons ─────────────────────────────────────────────────────── */
.nav-links { display: flex; flex-wrap: wrap; gap: 10px; }

.nav-link {
    display: inline-block;
    padding: 10px 16px;
    background: #3498db;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background .15s;
}
.nav-link:hover { background: #2980b9; }
.nav-link.secondary { background: #ecf0f1; color: #2c3e50; }
.nav-link.secondary:hover { background: #dde1e3; }
.nav-link.sm { font-size: 0.88rem; padding: 7px 14px; }

/* ── Back link (settings) ────────────────────────────────────────────────────── */
.back-link {
    color: #3498db;
    text-decoration: none;
    font-size: 0.95rem;
    white-space: nowrap;
}
.back-link:hover { text-decoration: underline; }

/* ── Section (dashboard) ─────────────────────────────────────────────────────── */
.section {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #3498db;
}

/* ── Config items (dashboard) ────────────────────────────────────────────────── */
.config-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}
.config-item:last-child { border-bottom: none; }
.config-key { font-weight: 600; color: #2c3e50; }
.config-value {
    font-family: 'Courier New', monospace;
    background: #ecf0f1;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.9rem;
}

/* ── Table grid (dashboard) ──────────────────────────────────────────────────── */
.table-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    margin-top: 12px;
}
.table-item {
    background: white;
    padding: 10px 14px;
    border-radius: 5px;
    border: 1px solid #ddd;
}
.table-name { font-weight: 600; color: #2c3e50; font-size: 0.9rem; }
.table-count { color: #7f8c8d; font-size: 0.85rem; }

/* ── Error ───────────────────────────────────────────────────────────────────── */
.error {
    background: #fef0f0;
    border: 1px solid #e74c3c;
    color: #c0392b;
    padding: 15px;
    border-radius: 6px;
    margin: 20px 0;
}

/* ── Auth (login / signup) ───────────────────────────────────────────────────── */
.auth-page {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 16px;
}
.auth-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,.1);
    padding: 36px 40px;
    width: 100%;
    max-width: 400px;
}
.auth-title {
    margin: 0 0 24px;
    font-size: 1.4rem;
    color: #1a1a2e;
}
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.auth-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
    margin-top: 10px;
}
.auth-label:first-of-type { margin-top: 0; }
.auth-input {
    padding: 9px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    font-size: 0.95rem;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}
.auth-input:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52,152,219,.15);
}
.auth-submit {
    margin-top: 18px;
    width: 100%;
    padding: 10px;
    font-size: 1rem;
}
.auth-alt {
    margin: 18px 0 0;
    font-size: 0.9rem;
    color: #666;
    text-align: center;
}
.auth-alt a { color: #3498db; text-decoration: none; }
.auth-alt a:hover { text-decoration: underline; }

/* ── Header auth ─────────────────────────────────────────────────────────────── */
.header-user-email {
    font-size: 0.8rem;
    color: rgba(0,0,0,.5);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.header-logout-form {
    display: inline-flex;
    margin: 0;
    padding: 0;
}
.impersonation-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Card (settings) ─────────────────────────────────────────────────────────── */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,.1);
    padding: 24px;
    margin-bottom: 20px;
}
.card h2 {
    margin: 0 0 18px;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #7f8c8d;
    font-weight: 600;
}

/* ── Page header (settings) ──────────────────────────────────────────────────── */
.page-header { display: none; }

/* ── Field row ───────────────────────────────────────────────────────────────── */
.field-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.field-row label {
    font-weight: 500;
    min-width: 120px;
    color: #2c3e50;
}
select#timezone {
    padding: 7px 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.95rem;
    color: #2c3e50;
    background: #fafafa;
    max-width: 260px;
    width: 100%;
}
select#timezone:focus {
    outline: none;
    border-color: #3498db;
    background: white;
}

/* ── Toggle switch ───────────────────────────────────────────────────────────── */
.toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}
.toggle input[type="checkbox"] { display: none; }
.toggle-track {
    width: 42px;
    height: 24px;
    background: #ccc;
    border-radius: 12px;
    position: relative;
    transition: background .2s;
    flex-shrink: 0;
}
.toggle input:checked + .toggle-track { background: #27ae60; }
.toggle-thumb {
    position: absolute;
    width: 18px;
    height: 18px;
    top: 3px;
    left: 3px;
    background: white;
    border-radius: 50%;
    transition: left .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.toggle input:checked + .toggle-track .toggle-thumb { left: 21px; }
.toggle-label { font-size: 0.95rem; color: #2c3e50; }
.toggle:has(input:disabled) { cursor: default; opacity: .4; pointer-events: none; }

/* ── Provider list (settings) ────────────────────────────────────────────────── */
#provider-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.provider-card {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 7px;
    padding: 14px 16px;
    cursor: grab;
    transition: box-shadow .15s, opacity .15s;
}
.provider-card:active { cursor: grabbing; }
.provider-card.dragging {
    opacity: .4;
    box-shadow: 0 4px 16px rgba(0,0,0,.15);
}
.provider-card.drag-over {
    border-color: #3498db;
    background: #eaf4fb;
}
.provider-card.disabled-card { opacity: .7; }

/* Provider inline status (shown in header next to provider name) */
.provider-inline-status {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 1;
    min-width: 0;
    margin-left: 8px;
}
.provider-inline-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.provider-inline-status .status-dot.ok-dot      { background: #27ae60; }
.provider-inline-status .status-dot.error-dot   { background: #e74c3c; }
.provider-inline-status .status-dot.unknown-dot { background: #bbb; }
.status-inline-text {
    font-size: .78rem;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.status-info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    color: #aaa;
    font-size: .8rem;
    flex-shrink: 0;
    position: relative;
}
.status-info-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 7px);
    left: 50%;
    transform: translateX(-50%);
    background: #2c3e50;
    color: #fff;
    padding: 6px 9px;
    border-radius: 5px;
    font-size: .74rem;
    white-space: pre-wrap;
    max-width: 280px;
    min-width: 120px;
    text-align: left;
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s;
    z-index: 20;
    line-height: 1.45;
    box-shadow: 0 3px 10px rgba(0,0,0,.2);
}
.status-info-icon:hover::after { opacity: 1; }

/* Rate-limit warning banner inside provider card */
.provider-rate-limit {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 5px;
    font-size: .8rem;
    line-height: 1.4;
}
.provider-rate-limit.short-term {
    background: #fff8e1;
    border: 1px solid #f0c040;
    color: #7a5c00;
}
.provider-rate-limit.long-term {
    background: #fdecea;
    border: 1px solid #e57373;
    color: #8b1c1c;
}
.provider-rate-limit .rl-icon { font-size: 1rem; flex-shrink: 0; }
.provider-rate-limit a { color: inherit; text-decoration: underline; }

.provider-header {
    display: flex;
    align-items: center;
    gap: 12px;
}
.drag-handle {
    color: #bbb;
    font-size: 1.2rem;
    cursor: grab;
    flex-shrink: 0;
    line-height: 1;
}
.provider-name {
    font-weight: 600;
    font-size: 1rem;
    color: #2c3e50;
    flex-shrink: 0;
}
.provider-activity-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: #555;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 1px 7px;
    flex-shrink: 0;
    white-space: nowrap;
    min-width: 0;
}
.provider-activity-count:empty {
    display: none;
}
.provider-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #eee;
}

/* ── Editable text field (settings) ─────────────────────────────────────────── */
.editable-field {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    margin-top: 10px;
}
.editable-field .field-label {
    font-size: 0.82rem;
    color: #7f8c8d;
    font-weight: 500;
    white-space: nowrap;
    min-width: 38px;
}
.editable-field input[type="text"] {
    flex: 1;
    border: none;
    border-bottom: 1px dashed #bbb;
    background: transparent;
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.85rem;
    color: #2c3e50;
    padding: 2px 4px;
    outline: none;
    min-width: 0;
    transition: border-color .15s, background .15s;
    cursor: text;
}
.editable-field input[type="text"]:focus {
    border-bottom: 2px solid #3498db;
    background: #f0f4f8;
    border-radius: 3px 3px 0 0;
}
.editable-field input[type="text"]:not(:focus) { color: #555; }
.edit-hint {
    font-size: 0.75rem;
    color: #bbb;
    white-space: nowrap;
    pointer-events: none;
}
.editable-field input[type="text"]:focus ~ .edit-hint { display: none; }
.save-check {
    font-size: 0.9rem;
    color: #27ae60;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity .25s;
}
.save-check.visible { opacity: 1; }

/* ── Auto-save toast ────────────────────────────────────────────────────────── */
#status-msg {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s;
}
#status-msg:not(:empty) { opacity: 1; }
#status-msg.ok  { background: #eafaf1; color: #27ae60; box-shadow: 0 2px 8px rgba(39,174,96,.2); }
#status-msg.err { background: #fdedec; color: #e74c3c; box-shadow: 0 2px 8px rgba(231,76,60,.2); }

.drag-hint {
    font-size: 0.82rem;
    color: #95a5a6;
    margin-bottom: 10px;
}
.field-help {
    font-size: 0.82rem;
    color: #7f8c8d;
    line-height: 1.6;
    margin-bottom: 16px;
}
.provider-note {
    font-size: 0.78rem;
    color: #7f8c8d;
    line-height: 1.5;
    margin: 6px 0 4px;
    padding: 6px 8px;
    background: #f8f9fa;
    border-left: 2px solid #bdc3c7;
    border-radius: 2px;
}
.provider-note code {
    background: #eaecee;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.9em;
}

/* ── Calendar page ───────────────────────────────────────────────────────────── */
.load-more-bar {
    text-align: center;
    padding: 20px 0;
}
.btn-load-more {
    padding: 5px 16px;
    background: transparent;
    color: #8a96a3;
    border: 1px solid #d0d5da;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 400;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
    letter-spacing: 0.02em;
}
.btn-load-more:hover { background: #f0f4f8; border-color: #b0bec5; color: #2c3e50; }

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
}
.month-card {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border: 2px solid transparent;
}
.month-card.current { border-color: #3498db; }
.month-header {
    margin-bottom: 12px;
    color: #2c3e50;
    text-align: center;
}
.month-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: bold;
    font-size: 16px;
}
.total-label {
    font-size: 12px;
    font-weight: normal;
    opacity: 0.8;
    min-height: 16px;
}
.provider-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 6px;
    min-height: 36px;
}
.provider-status {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 6px 8px;
    border-radius: 4px;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    color: white;
}

.provider-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    flex: 1;
}

/* Footer strip at the bottom of each chiclet */
.provider-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    margin: 4px -8px -6px;
    padding: 3px 4px 3px 6px;
    border-top: 1px solid rgba(255,255,255,0.25);
    min-height: 22px;
}

/* Per-provider pull button — lives in footer, always visible */
.provider-pull-btn {
    background: rgba(0,0,0,0.20);
    border: none;
    color: rgba(255,255,255,0.85);
    cursor: pointer;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    line-height: 1.3;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    transition: background .15s;
}
.provider-pull-btn:hover:not(:disabled) { background: rgba(0,0,0,0.38); color: white; }
.provider-pull-btn:disabled { cursor: default; opacity: 0.55; }
/* Success state: show ✓ by default, swap to ⬇ on hover */
.provider-pull-btn.pull-btn-success .btn-icon-pull { display: none; }
.provider-pull-btn.pull-btn-success:hover:not(:disabled) .btn-icon-check { display: none; }
.provider-pull-btn.pull-btn-success:hover:not(:disabled) .btn-icon-pull { display: inline; }
/* Spinner inside provider pull button should use white tones */
.provider-pull-btn .spinner-sm {
    border-color: rgba(255,255,255,.25);
    border-top-color: rgba(255,255,255,.9);
}

/* Pull status indicator inside the footer */
.pcs {
    font-size: 10px;
    color: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    gap: 3px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
}
.pcs-active  { color: rgba(255,255,255,0.95); }
.pcs-error   { color: rgba(255,200,200,0.95); cursor: default; }
.pcs-spinner {
    display: inline-block;
    width: 8px;
    height: 8px;
    border: 1.5px solid rgba(255,255,255,.3);
    border-top-color: rgba(255,255,255,.9);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    flex-shrink: 0;
}

/* Big bare integer */
.activity-count-big {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.5px;
}

/* Fallback text label for logo-less providers */
.provider-name-label {
    font-size: 0.6rem;
    font-weight: 600;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: auto;
}

/* Provider logo */
.provider-logo-row { margin-top: auto; padding-top: 4px; }
.provider-logo-img {
    display: block;
    max-height: 24px;
    max-width: 90px;
    /* Turn all colours white so logo is readable on any brand-colour background */
    filter: brightness(0) invert(1);
    opacity: 0.9;
}

/* Not-synced = neutral gray */
.provider-status.not-synced { background: #aab0b8; opacity: 0.70; }

/* Per-provider synced colors */
.provider-status.provider-strava.synced       { background: #FC4C02; }
.provider-status.provider-garmin.synced       { background: #007CC3; }
.provider-status.provider-ridewithgps.synced  { background: #F96400; }
.provider-status.provider-intervalsicu.synced { background: #dd0447; }
.provider-status.provider-spreadsheet.synced  { background: #5a6b7c; }
.provider-status.provider-file.synced         { background: #7a7f84; }

.card-loading { color: #999; font-size: 12px; text-align: center; padding: 6px 0; }

.cal-stats {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.pull-btn {
    background: none;
    border: none;
    color: #aab;
    cursor: pointer;
    font-size: 13px;
    padding: 2px 5px;
    border-radius: 4px;
    line-height: 1;
    transition: color .15s, background .15s;
    flex-shrink: 0;
}
.pull-btn:hover:not(:disabled) { color: #3498db; background: #eaf4fb; }
.pull-btn:disabled { cursor: default; color: #ccc; }

.month-btn-group {
    display: flex;
    gap: 2px;
    align-items: center;
    flex-shrink: 0;
}

.reset-btn {
    background: none;
    border: none;
    color: #aab;
    cursor: pointer;
    font-size: 13px;
    padding: 2px 5px;
    border-radius: 4px;
    line-height: 1;
    transition: color .15s, background .15s;
    flex-shrink: 0;
}
.reset-btn:hover:not(:disabled) { color: #e74c3c; background: #fdecea; }
.reset-btn:disabled { cursor: default; color: #ccc; }

.sync-review-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #aab;
    cursor: pointer;
    font-size: 13px;
    padding: 2px 5px;
    border-radius: 4px;
    line-height: 1;
    text-decoration: none;
    transition: color .15s, background .15s;
    flex-shrink: 0;
}
.sync-review-link:hover { color: #27ae60; background: #eafaf1; }

.pull-status { font-size: 11px; text-align: center; }
.pull-status:not(:empty) { margin-top: 5px; min-height: 14px; }
.pull-status.ok      { color: #28a745; }
.pull-status.err     { color: #dc3545; }
.pull-status.running { color: #3498db; }
/* File pull status in settings (mirrors .pull-status) */
.file-pull-status { font-size: 11px; min-height: 14px; margin-top: 4px; }
.file-pull-status.ok      { color: #28a745; }
.file-pull-status.err     { color: #dc3545; }
.file-pull-status.running { color: #3498db; }
.pull-status.confirm { color: #e74c3c; display: flex; align-items: center; gap: 5px; justify-content: center; flex-wrap: wrap; }
.confirm-yes, .confirm-no {
    border: none;
    border-radius: 3px;
    padding: 1px 7px;
    font-size: 10px;
    cursor: pointer;
    font-weight: 500;
    line-height: 1.6;
}
.confirm-yes { background: #e74c3c; color: white; }
.confirm-yes:hover { background: #c0392b; }
.confirm-no  { background: #ecf0f1; color: #2c3e50; }
.confirm-no:hover { background: #dde1e3; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
    display: inline-block;
    width: 10px; height: 10px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: white;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    vertical-align: middle;
    margin-right: 4px;
}
.spinner-sm {
    border-color: rgba(52,152,219,.25);
    border-top-color: #3498db;
    margin-right: 0;
}

/* ── GarminAuth modal ───────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-overlay.hidden { display: none; }
.modal-box {
    background: white;
    border-radius: 10px;
    padding: 28px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 32px rgba(0,0,0,.22);
}
.modal-box h3 {
    margin: 0 0 4px;
    font-size: 1.05rem;
    color: #2c3e50;
}
.modal-subtitle {
    font-size: 0.82rem;
    color: #95a5a6;
    margin-bottom: 20px;
}
.modal-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 14px;
}
.modal-field label {
    font-size: 0.82rem;
    font-weight: 500;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.modal-field input {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.95rem;
    color: #2c3e50;
    background: #fafafa;
    outline: none;
    transition: border-color .15s, background .15s;
}
.modal-field input:focus {
    border-color: #3498db;
    background: white;
}
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}
.btn {
    padding: 8px 18px;
    border: none;
    border-radius: 5px;
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, opacity .15s;
}
.btn-primary { background: #3498db; color: white; }
.btn-primary:hover:not(:disabled) { background: #2980b9; }
.btn-primary:disabled { opacity: .55; cursor: default; }
.btn-secondary { background: #ecf0f1; color: #2c3e50; }
.btn-secondary:hover { background: #dde1e3; }
.btn-danger { background: #e74c3c; color: white; }
.btn-danger:hover:not(:disabled) { background: #c0392b; }
.btn-danger:disabled { opacity: .55; cursor: default; }

.card-danger {
    border: 1px solid #f5c6cb;
    background: #fff8f8;
}
.card-danger h2 { color: #c0392b; }
.danger-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    flex-wrap: wrap;
}
.danger-provider-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
}
.modal-error {
    font-size: 0.83rem;
    color: #e74c3c;
    margin-top: 10px;
    min-height: 18px;
    line-height: 1.4;
}
.modal-success {
    font-size: 0.83rem;
    color: #27ae60;
    margin-top: 10px;
    min-height: 18px;
}
.provider-auth-btn {
    margin-top: 10px;
    font-size: 0.82rem;
    padding: 5px 14px;
    border-radius: 4px;
    background: #3498db;
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: background .15s;
}
.provider-auth-btn:hover { background: #2980b9; }

/* Garmin-branded auth button */
.garmin-auth-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    font-size: 1rem;
    padding: 11px 22px;
    border-radius: 4px;
    background: #1B6ECD;
    color: #ffffff;
    border: none;
    cursor: pointer;
    font-weight: 700;
    letter-spacing: .015em;
    transition: background .15s;
}
.garmin-auth-btn:hover { background: #155bb0; }

/* Auth status chip — shown above OAuth connect buttons */
.auth-status-line { margin: 12px 0 0; }
.auth-status-chip {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 12px;
    letter-spacing: 0.03em;
}
.auth-status-chip.connected { background: #eaf6ef; color: #1e8449; border: 1px solid #a9dfbf; }
.auth-status-chip.not-connected { background: #f5f5f5; color: #888; border: 1px solid #ddd; }

/* Write-only provider badge — shown in provider card header */
.write-only-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
    border-radius: 4px;
    padding: 1px 6px;
    margin-left: 4px;
    vertical-align: middle;
}

/* Divider between regular and write-only providers */
.write-only-divider {
    margin: 12px 0 4px;
}
.write-only-divider hr {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 0 0 6px;
}
.write-only-divider-label {
    font-size: 0.78rem;
    color: #888;
    font-style: italic;
}

/* Disconnect button for write-only providers */
.strava-disconnect-btn {
    margin-top: 10px;
    font-size: 0.85rem;
}

/* Strava-branded auth button — uses official connect_with_strava.svg */
.strava-auth-btn {
    display: inline-block;
    margin-top: 14px;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
}
.strava-auth-btn img {
    display: block;
    height: 48px;
    width: auto;
}
.strava-auth-btn:hover { opacity: 0.85; }

/* RideWithGPS-branded auth button */
.ridewithgps-auth-btn {
    display: block;
    width: fit-content;
    margin-top: 14px;
    font-size: 1rem;
    padding: 11px 22px;
    border-radius: 4px;
    background: #F96400;
    color: #ffffff;
    border: none;
    cursor: pointer;
    font-weight: 700;
    letter-spacing: .015em;
    transition: background .15s;
}
.ridewithgps-auth-btn:hover { background: #D95500; }

.intervalsicu-auth-btn {
    display: block;
    width: fit-content;
    margin-top: 14px;
    font-size: 1rem;
    padding: 11px 22px;
    border-radius: 4px;
    background: #dd0447;
    color: #ffffff;
    border: none;
    cursor: pointer;
    font-weight: 700;
    letter-spacing: .015em;
    transition: background .15s;
}
.intervalsicu-auth-btn:hover { background: #b80339; }

/* Personal-credentials toggle — displayed subtly below the auth button */
.personal-creds-toggle-row {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}
.personal-creds-toggle-row .toggle-label {
    font-size: 0.8rem;
    color: #888;
}

.strava-redirect-note {
    margin-top: 10px;
    font-size: 0.8rem;
    color: #555;
    line-height: 1.5;
}
.strava-redirect-note code {
    background: #f0f0f0;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.78rem;
    word-break: break-all;
}

/* ── Footer ──────────────────────────────────────────────────────────────────── */
.app-footer {
    margin-top: auto;
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    background: #ffffff;
    text-align: center;
    font-size: 0.8rem;
    color: rgba(0,0,0,.45);
}
.app-footer a {
    color: rgba(0,0,0,.55);
    text-decoration: none;
}
.app-footer a:hover {
    color: #1a1a2e;
    text-decoration: underline;
}
.footer-sep {
    margin: 0 8px;
    color: rgba(0,0,0,.2);
}
.footer-attribution {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 10px;
}
.footer-logo-link {
    display: inline-flex;
    align-items: center;
    opacity: 0.85;
    transition: opacity 0.15s;
}
.footer-logo-link:hover {
    opacity: 1;
}
.footer-logo {
    height: auto;
    max-height: 22px;
    max-width: 140px;
    width: auto;
    display: block;
    vertical-align: middle;
}
/* The official Strava lockup is very wide; cap it so it doesn't dwarf the others */
.footer-logo-link[title="Powered by Strava"] .footer-logo {
    max-width: 110px;
}
/* Strava brand orange: #FC4C02 */
.attr-strava {
    color: #FC4C02 !important;
    font-weight: 600;
}
.attr-strava:hover {
    color: #d93f00 !important;
    text-decoration: underline;
}
/* Garmin brand blue: #007CC3 */
.attr-garmin {
    color: #007CC3 !important;
    font-weight: 600;
}
.attr-garmin:hover {
    color: #005f99 !important;
    text-decoration: underline;
}
/* RideWithGPS brand orange: #F96400 */
.attr-ridewithgps {
    color: #F96400 !important;
    font-weight: 600;
}
.attr-ridewithgps:hover {
    color: #D95500 !important;
    text-decoration: underline;
}

/* ── Provider attribution within calendar cards ─────────────────────────────── */
.provider-attr-row {
    margin-top: 4px;
    font-size: 0.65rem;
    line-height: 1.2;
}
.provider-attr {
    text-decoration: none;
    font-weight: 600;
    border-radius: 3px;
    padding: 1px 4px;
    display: inline-block;
}
.provider-attr.attr-strava {
    color: #FC4C02;
    border: 1px solid rgba(252,76,2,.35);
}
.provider-attr.attr-strava:hover { background: rgba(252,76,2,.08); }
.provider-attr.attr-garmin {
    color: #007CC3;
    border: 1px solid rgba(0,124,195,.35);
}
.provider-attr.attr-garmin:hover { background: rgba(0,124,195,.08); }
.provider-attr.attr-ridewithgps {
    color: #F96400;
    border: 1px solid rgba(249,100,0,.35);
}
.provider-attr.attr-ridewithgps:hover { background: rgba(249,100,0,.08); }

/* Attribution links inside synced (green) provider cards — use white */
.provider-status.synced .provider-attr {
    color: rgba(255,255,255,.9) !important;
    border-color: rgba(255,255,255,.4);
}
.provider-status.synced .provider-attr:hover {
    background: rgba(255,255,255,.15) !important;
}

/* ── Mini calendar grid inside chicklets ─────────────────────────────────────── */
.mini-cal {
    width: 100%;
    margin: 2px 0 1px;
}
.mini-cal-head,
.mini-cal-body {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
}
.mini-cal-head span {
    font-size: 0.48rem;
    font-weight: 700;
    text-align: center;
    opacity: 0.7;
    text-transform: uppercase;
    line-height: 1.4;
}
.mc-dot {
    display: block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    margin: 1px auto;
}
.mc-active {
    background: rgba(255,255,255,0.95);
}
.mc-dot.mc-empty {
    background: rgba(255,255,255,0.18);
}

/* ── Device name chip inside provider card ───────────────────────────────────── */
.provider-devices {
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}
.device-chip {
    display: inline-block;
    font-size: 0.62rem;
    padding: 1px 5px;
    border-radius: 3px;
    background: transparent;
    color: #007CC3;
    border: 1px solid rgba(0,124,195,.35);
    font-weight: 600;
    white-space: nowrap;
}
/* Inside synced provider cards, flip device chip to white */
.provider-status.synced .device-chip {
    color: rgba(255,255,255,.9);
    border-color: rgba(255,255,255,.4);
    background: rgba(255,255,255,.12);
}

/* ── Privacy / prose page ────────────────────────────────────────────────────── */
.prose {
    background: #fff;
    border-radius: 8px;
    padding: 32px 40px;
    box-shadow: 0 2px 10px rgba(0,0,0,.07);
    margin-bottom: 40px;
    line-height: 1.75;
}
.prose h1 { font-size: 1.7rem; margin-bottom: 4px; }
.prose h2 { font-size: 1.2rem; margin-top: 32px; padding-bottom: 4px; border-bottom: 1px solid #eee; }
.prose h3 { font-size: 1rem; margin-top: 24px; color: #444; }
.prose-lead { color: rgba(0,0,0,.4); font-size: 0.88rem; margin-top: 0; margin-bottom: 24px; }
.prose hr { border: none; border-top: 1px solid #eee; margin: 28px 0; }
.prose code {
    background: #f4f4f4;
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 0.88em;
}
.prose ul { padding-left: 1.5em; }
.prose li { margin-bottom: 4px; }
.attribution-block { margin: 8px 0 16px; }
.attribution-logo { height: 28px; vertical-align: middle; }
.attribution-pill {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85rem;
}
.garmin-pill {
    background: #007CC3;
    color: #fff;
    text-decoration: none;
}

/* ── Notifications ───────────────────────────────────────────────────────────── */
.notif-wrap {
    position: relative;
    flex-shrink: 0;
}
.notif-bell {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    color: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    transition: background .15s, color .15s;
    line-height: 1;
}
.notif-bell:hover,
.notif-bell-has-unread { color: #1a1a2e; }
.notif-bell:hover { background: rgba(0,0,0,.05); }
.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: #e74c3c;
    color: white;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    pointer-events: none;
}
.notif-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 320px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0,0,0,.13);
    z-index: 500;
    overflow: hidden;
}
.notif-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 9px;
    border-bottom: 1px solid #f0f0f0;
}
.notif-dropdown-title {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #7f8c8d;
}
.notif-read-all {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.78rem;
    color: #3498db;
    padding: 0;
    font-weight: 500;
}
.notif-read-all:hover { text-decoration: underline; }
.notif-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 360px;
    overflow-y: auto;
}
.notif-empty {
    padding: 20px 14px;
    text-align: center;
    font-size: 0.85rem;
    color: #aaa;
}
.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid #f5f5f5;
    transition: background .1s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:not(.notif-read) { background: #f8fafe; }
.notif-item.notif-error:not(.notif-read) { background: #fff8f8; }
.notif-msg {
    flex: 1;
    font-size: 0.84rem;
    color: #2c3e50;
    line-height: 1.45;
    word-break: break-word;
}
.notif-item.notif-read .notif-msg { color: #999; }
.notif-item.notif-error .notif-msg { color: #c0392b; }
.notif-item.notif-error.notif-read .notif-msg { color: #e0a0a0; }
.notif-meta {
    font-size: 0.74rem;
    color: #bbb;
    white-space: nowrap;
    padding-top: 2px;
    flex-shrink: 0;
}
.notif-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
    padding-top: 1px;
}
.notif-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.78rem;
    color: #bbb;
    padding: 2px 5px;
    border-radius: 3px;
    transition: color .15s, background .15s;
    line-height: 1;
}
.notif-btn:hover { background: rgba(0,0,0,.06); color: #555; }
.notif-btn-del:hover { color: #e74c3c; }

/* ── Month sync-review page ──────────────────────────────────────────────── */

.month-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}
.month-page-title { display: flex; flex-direction: column; gap: 4px; }
.back-link {
    font-size: 0.85rem;
    color: #666;
    text-decoration: none;
}
.back-link:hover { color: #333; }
.month-page-title h1 { margin: 0; font-size: 1.5rem; }
.month-page-subtitle { color: #888; font-weight: 400; font-size: 1.1rem; }

/* Sync status badge — shared base, used on both dashboard cards and the month header */
.month-sync-badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    vertical-align: middle;
    letter-spacing: 0.01em;
}
.month-sync-synced { background: #d4edda; color: #155724; }
.month-sync-action { background: #fff3cd; color: #7a5800; }
/* Larger variant in the sync-review page header */
#month-sync-badge { font-size: 13px; padding: 3px 10px; }

.btn-refresh {
    padding: 6px 14px;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: background .15s;
}
.btn-refresh:hover:not(:disabled) { background: #f0f0f0; }
.btn-refresh:disabled { opacity: 0.5; cursor: not-allowed; }

.page-status {
    padding: 10px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}
.page-status-info  { background: #e8f4fd; color: #1a6591; }
.page-status-error { background: #fde8e8; color: #912020; }

.section-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    padding: 20px 24px;
    margin-bottom: 20px;
}
.section-title { margin: 0 0 8px; font-size: 1.1rem; color: #2c3e50; }
.section-hint  { margin: 0 0 12px; font-size: 0.85rem; color: #666; }

/* Status badges used in the legend */
.badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: 600;
}
.badge-auth  { background: #27ae60; color: #fff; }
.badge-new   { background: #f39c12; color: #fff; }
.badge-wrong { background: #e74c3c; color: #fff; }

/* Sync comparison table */
.table-scroll { overflow-x: auto; }
.sync-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.82rem;
    white-space: nowrap;
}
.sync-table th,
.sync-table td {
    padding: 6px 10px;
    border: 1px solid #e0e0e0;
    text-align: left;
}
.sync-table thead th {
    background: #f5f5f5;
    font-weight: 600;
    color: #333;
}
.sync-table tbody tr:nth-child(even) { background: #fafafa; }
.sync-table tbody tr:hover { background: #f0f4ff; }

.cell-auth  { background: #d5f5e3 !important; }
.cell-new   { background: #fef9e7 !important; color: #85640a; }
.cell-wrong { background: #fde8e8 !important; color: #8b1a1a; }
.cell-start { font-variant-numeric: tabular-nums; color: #555; }
.cell-dist  { font-variant-numeric: tabular-nums; font-weight: 500; }
.empty-row  { text-align: center; color: #999; padding: 16px; font-style: italic; }

/* Icon links inside sync table ID cells */
.row-icon-link {
    display: inline-block;
    font-size: 0.75rem;
    color: #888;
    text-decoration: none;
    vertical-align: middle;
    padding: 0 2px;
    border-radius: 3px;
    line-height: 1;
    transition: color .15s, background .15s;
}
.row-icon-link:hover { color: #2c3e50; background: rgba(0,0,0,.07); }

/* Changes list */
.change-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
    flex-wrap: wrap;
}
.change-row:last-child { border-bottom: none; }
.change-row-done { opacity: 0.55; }

.change-desc {
    flex: 1;
    font-size: 0.88rem;
    min-width: 200px;
}
.change-actions { display: flex; gap: 6px; flex-shrink: 0; }
.change-status  { font-size: 0.8rem; flex-shrink: 0; min-width: 100px; }

.btn-accept {
    padding: 4px 12px;
    border-radius: 4px;
    border: 1px solid #219a52;
    cursor: pointer;
    font-size: 0.82rem;
    transition: background .15s;
    background: #27ae60;
    color: #fff;
}
.btn-accept:hover:not(:disabled) { background: #219a52; }
.btn-accept:disabled { opacity: 0.5; cursor: not-allowed; }

.change-status-pending { color: #888; }
.change-status-queued  { color: #2980b9; }
.change-status-done    { color: #27ae60; font-weight: 600; }
.change-status-error   { color: #e74c3c; }

.no-changes {
    text-align: center;
    color: #27ae60;
    font-size: 0.95rem;
    padding: 16px 0;
    margin: 0;
}
