/* ── Design tokens ──────────────────────────────────────────────── */
:root {
    --red:         #CF0A2C;
    --red-d:       #A50823;
    --red-bg:      rgba(207,10,44,0.07);
    --black:       #000000;
    --page-bg:     #F5F4F1;
    --sidebar-bg:  #FFFFFF;
    --sidebar-w:   228px;
    --surface:     #FFFFFF;
    --border:      #E8E6E1;
    --border-2:    #F0EEE9;
    --text-1:      #1A1A1A;
    --text-2:      #555555;
    --text-3:      #999999;
    --success:     #16A34A;
    --success-bg:  #DCFCE7;
    --danger:      #DC2626;
    --danger-bg:   #FEE2E2;
    --warning:     #B45309;
    --warning-bg:  #FEF3C7;
    --info:        #1D4ED8;
    --info-bg:     #EFF6FF;
    --radius:      10px;
    --radius-lg:   16px;
    --radius-xl:   20px;
    --font:        Helvetica, Arial, sans-serif;
    --sh-sm:       0 1px 4px rgba(0,0,0,0.07);
    --sh-md:       0 4px 20px rgba(0,0,0,0.10);
    --t:           0.15s;
    --ease:        cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text-1);
    background: var(--page-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
img { display: block; max-width: 100%; height: auto; }
a { color: var(--red); text-decoration: none; transition: color var(--t) var(--ease); }
a:hover { color: var(--red-d); text-decoration: underline; }
ul, ol { list-style: none; }
h1,h2,h3,h4 { line-height: 1.15; font-weight: 700; }

/* ── App shell (sidebar + content) ─────────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform var(--t) var(--ease);
}

.sidebar-logo-wrap {
    padding: 20px 18px 14px;
    border-bottom: 1px solid var(--border-2);
}
.sidebar-logo-img {
    height: 64px;
    width: auto;
    display: block;
    max-width: 220px;
    object-fit: contain;
}

.sidebar-section-label {
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--text-3);
    text-transform: uppercase;
    padding: 18px 18px 6px;
}

.sidebar-nav {
    flex: 1;
    padding: 0 10px;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--text-2);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: background var(--t), color var(--t);
    margin-bottom: 2px;
    border-left: 3px solid transparent;
}
.sidebar-link:hover {
    background: var(--border-2);
    color: var(--text-1);
    text-decoration: none;
}
.sidebar-link.is-active {
    background: var(--red-bg);
    color: var(--red);
    font-weight: 600;
    border-left-color: var(--red);
}
.sidebar-link svg { flex-shrink: 0; opacity: 0.7; }
.sidebar-link.is-active svg { opacity: 1; }

/* Countdown card */
.sidebar-countdown {
    margin: 12px 10px;
    background: var(--red);
    border-radius: var(--radius);
    padding: 14px 16px;
    color: #fff;
}
.sc-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    opacity: 0.7;
    margin-bottom: 4px;
}
.sc-days {
    font-size: 1.75rem;
    font-weight: 900;
    line-height: 1;
    margin-bottom: 2px;
}
.sc-days span {
    font-size: 0.8rem;
    font-weight: 500;
    opacity: 0.85;
}
.sc-sub {
    font-size: 0.7rem;
    opacity: 0.65;
    margin-top: 6px;
}

/* Sidebar logout */
.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px 18px;
    font-size: 0.8rem;
    color: var(--text-3);
    text-decoration: none;
    transition: color var(--t);
}
.sidebar-logout:hover { color: var(--red); text-decoration: none; }
.sidebar-logout svg { opacity: 0.6; }

/* ── Page wrapper ───────────────────────────────────────────────── */
.page-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ── Mobile topbar (hidden on desktop) ─────────────────────────── */
.mobile-topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 90;
}
.mobile-logo-img {
    height: 32px;
    width: auto;
    margin: -4px -6px;
    max-width: 180px;
    object-fit: contain;
}
.sidebar-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 38px;
    height: 38px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
}
.sidebar-toggle:hover { background: var(--border-2); }
.sidebar-toggle span {
    display: block;
    height: 2px;
    background: var(--text-1);
    border-radius: 2px;
    transition: transform var(--t), opacity var(--t);
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
}
.sidebar-overlay.is-active { display: block; }

/* ── Page main ──────────────────────────────────────────────────── */
.page-main {
    flex: 1;
    padding: 28px 32px 48px;
    max-width: 1060px;
    width: 100%;
}

/* ── Page heading ───────────────────────────────────────────────── */
.page-heading {
    margin-bottom: 24px;
}
.page-eyebrow {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 4px;
}
.page-title {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--text-1);
}

/* Topbar user chip (appears in heading row on desktop) */
.heading-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}
.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--black);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}
.user-info { text-align: right; }
.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-1);
    line-height: 1.2;
}
.user-role {
    font-size: 0.72rem;
    color: var(--text-3);
    line-height: 1.2;
}

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--sh-sm);
    border: 1px solid var(--border);
    padding: 24px;
}
.card + .card { margin-top: 16px; }

/* ── Flash messages ─────────────────────────────────────────────── */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 20px;
    border-left: 3px solid;
}
.flash-success { background: var(--success-bg); color: var(--success); border-color: var(--success); }
.flash-error   { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger);  }
.flash-info    { background: var(--info-bg);    color: var(--info);    border-color: var(--info);    }
.flash-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning); }

/* ── Dashboard: hero grid ───────────────────────────────────────── */
.dash-hero {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 16px;
    margin-bottom: 16px;
}

/* Stat hero card */
.hero-stat-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--sh-sm);
    padding: 28px 32px;
}
.hsc-eyebrow {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 10px;
}
.hsc-stats {
    display: flex;
    gap: 40px;
    margin-top: 4px;
}
.hsc-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.hsc-stat-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
}
.hsc-stat-val {
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    color: var(--text-1);
    line-height: 1;
}
.hsc-stat-unit {
    font-size: 0.75rem;
    color: var(--text-3);
    font-weight: 500;
}
.hsc-divider {
    width: 1px;
    background: var(--border);
    align-self: stretch;
}
.hsc-meta {
    margin-top: 16px;
    font-size: 0.8rem;
    color: var(--text-3);
}
.hsc-meta strong { color: var(--text-2); }
.hsc-note {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-3);
    font-style: italic;
}

/* Motivational red card */
.hero-motive-card {
    background: var(--red);
    border-radius: var(--radius-lg);
    padding: 28px 26px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
    min-height: 180px;
}
.hmc-deco {
    position: absolute;
    bottom: -30px;
    right: -30px;
    width: 130px;
    height: 130px;
    border: 24px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    pointer-events: none;
}
.hmc-deco-2 {
    position: absolute;
    top: -40px;
    right: 40px;
    width: 80px;
    height: 80px;
    border: 14px solid rgba(255,255,255,0.07);
    border-radius: 50%;
    pointer-events: none;
}
.hmc-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.65);
    margin-bottom: 8px;
}
.hmc-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: #fff;
    line-height: 1.25;
    letter-spacing: -0.02em;
    margin-bottom: 20px;
}
.hmc-title em { font-style: italic; }
.hmc-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    color: var(--red);
    font-size: 0.82rem;
    font-weight: 700;
    padding: 9px 18px;
    border-radius: 50px;
    text-decoration: none;
    width: fit-content;
    transition: opacity var(--t);
    border: none;
    cursor: pointer;
}
.hmc-btn:hover { opacity: 0.88; text-decoration: none; color: var(--red); }

/* ── Submission summary chips ───────────────────────────────────── */
.submission-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.ss-chip {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 16px 18px;
    box-shadow: var(--sh-sm);
}
.ss-chip-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 6px;
}
.ss-chip-val {
    font-size: 1.625rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    line-height: 1;
}
.ss-chip-val.c-success { color: var(--success); }
.ss-chip-val.c-warning { color: var(--warning); }
.ss-chip-val.c-danger  { color: var(--danger); }
.ss-chip-val.c-default { color: var(--text-1); }

/* ── History table ──────────────────────────────────────────────── */
.history-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--sh-sm);
    overflow: hidden;
}
.history-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-2);
}
.history-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-1);
}
.history-card-meta {
    font-size: 0.78rem;
    color: var(--text-3);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
}
.history-table th {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-3);
    padding: 10px 24px;
    text-align: left;
    background: var(--border-2);
    border-bottom: 1px solid var(--border);
}
.history-table td {
    padding: 14px 24px;
    border-bottom: 1px solid var(--border-2);
    font-size: 0.875rem;
    color: var(--text-1);
    vertical-align: middle;
}
.history-table tbody tr:last-child td { border-bottom: none; }
.history-table tbody tr:hover { background: #FAFAF8; }

.activity-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}
.activity-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.activity-icon.run { background: rgba(207,10,44,0.1); color: var(--red); }
.activity-icon.swim { background: rgba(29,78,216,0.1); color: var(--info); }
.activity-name { font-weight: 600; font-size: 0.875rem; }
.activity-date { font-size: 0.775rem; color: var(--text-3); margin-top: 1px; }

.dist-val { font-weight: 700; font-size: 0.95rem; }
.dist-unit { font-size: 0.75rem; color: var(--text-3); font-weight: 400; }

/* ── Badges ─────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 50px;
    white-space: nowrap;
}
.badge::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.badge-verified { background: var(--success-bg); color: var(--success); }
.badge-verified::before { background: var(--success); }
.badge-rejected { background: var(--danger-bg); color: var(--danger); }
.badge-rejected::before { background: var(--danger); }
.badge-review   { background: var(--warning-bg); color: var(--warning); }
.badge-review::before { background: var(--warning); }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--t), opacity var(--t), box-shadow var(--t);
    white-space: nowrap;
}
.btn-primary {
    background: var(--red);
    color: #fff;
}
.btn-primary:hover { background: var(--red-d); color: #fff; text-decoration: none; }
.btn-secondary {
    background: var(--border-2);
    color: var(--text-2);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); color: var(--text-1); text-decoration: none; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 0.8rem; }

/* ── Activity picker (log-entry) ───────────────────────────────── */
.activity-picker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 24px;
}
.activity-picker input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.activity-picker-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 22px 20px;
    border-radius: var(--radius-lg);
    border: 2px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    transition: border-color var(--t), background var(--t), box-shadow var(--t);
    user-select: none;
    position: relative;
}
.activity-picker-card:hover {
    border-color: var(--red);
    box-shadow: var(--sh-sm);
}
input[type="radio"]:checked + .activity-picker-card {
    border-color: var(--red);
    background: rgba(207,10,44,0.04);
    box-shadow: 0 0 0 3px rgba(207,10,44,0.12);
}
.apc-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}
.apc-icon.run  { background: rgba(207,10,44,0.1);  color: var(--red); }
.apc-icon.swim { background: rgba(29,78,216,0.1);  color: var(--info); }
.apc-name { font-size: 1rem; font-weight: 700; color: var(--text-1); }
.apc-desc { font-size: 0.8rem; color: var(--text-3); line-height: 1.4; }
input[type="radio"]:checked + .activity-picker-card .apc-name { color: var(--red); }

/* ── Forms ──────────────────────────────────────────────────────── */
.form-section {
    margin-bottom: 28px;
}
.form-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-2);
}
.form-group {
    margin-bottom: 18px;
}
.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem;
    color: var(--text-1);
    background: #fff;
    transition: border-color var(--t), box-shadow var(--t);
    outline: none;
}
.form-group input:focus,
.form-group select:focus {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(207,10,44,0.1);
}
.form-group input::placeholder { color: var(--text-3); }
.field-error {
    font-size: 0.78rem;
    color: var(--danger);
    margin-top: 5px;
    font-weight: 500;
}
.form-hint {
    font-size: 0.775rem;
    color: var(--text-3);
    margin-top: 5px;
}
.input-unit-wrap { position: relative; }
.input-unit-wrap input { padding-right: 3.5rem; }
.input-unit {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-3);
    pointer-events: none;
}

/* ── File upload ────────────────────────────────────────────────── */
.file-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    background: var(--page-bg);
    padding: 32px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--t), background var(--t);
    position: relative;
}
.file-upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}
.file-upload-area:hover,
.file-upload-area.is-dragover {
    border-color: var(--red);
    background: rgba(207,10,44,0.03);
}
.upload-icon {
    width: 46px;
    height: 46px;
    margin: 0 auto 12px;
    color: var(--text-3);
}
.upload-icon svg { width: 100%; height: 100%; }
.upload-cta { font-size: 0.9rem; color: var(--text-2); margin-bottom: 4px; }
.upload-cta strong { color: var(--text-1); }
.upload-meta { font-size: 0.775rem; color: var(--text-3); }
.file-chosen { font-size: 0.82rem; color: var(--red); font-weight: 600; margin-top: 8px; display: none; }
.file-preview {
    max-width: 100%;
    max-height: 180px;
    margin: 12px auto 0;
    border-radius: var(--radius);
    display: none;
    object-fit: contain;
    box-shadow: var(--sh-sm);
}

/* ── Loading overlay ────────────────────────────────────────────── */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(245,244,241,0.88);
    z-index: 999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    backdrop-filter: blur(4px);
}
.loading-overlay.is-active { display: flex; }
.loading-spinner {
    width: 44px;
    height: 44px;
    border: 3.5px solid rgba(207,10,44,0.2);
    border-top-color: var(--red);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-label { font-size: 1rem; font-weight: 700; color: var(--text-1); }
.loading-sublabel { font-size: 0.82rem; color: var(--text-3); }

/* ── Family view ────────────────────────────────────────────────── */
.family-hero {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 16px;
    margin-bottom: 16px;
}
.family-stat-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--sh-sm);
    padding: 28px 32px;
}
.family-dark-card {
    background: #111827;
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 180px;
    position: relative;
    overflow: hidden;
}
.fdc-deco {
    position: absolute;
    bottom: -20px;
    right: -20px;
    width: 100px;
    height: 100px;
    border: 18px solid rgba(255,255,255,0.05);
    border-radius: 50%;
}
.fdc-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.4);
    margin-bottom: 8px;
}
.fdc-avatars {
    display: flex;
    gap: -4px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 6px;
}
.member-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    border: 2px solid #111827;
    color: #fff;
    flex-shrink: 0;
}
.fdc-tagline {
    font-size: 1.1rem;
    font-weight: 800;
    color: #fff;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.member-list {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--sh-sm);
    overflow: hidden;
}
.member-list-header {
    padding: 18px 24px 14px;
    border-bottom: 1px solid var(--border-2);
    font-size: 0.95rem;
    font-weight: 700;
}
.member-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border-2);
    transition: background var(--t);
}
.member-row:last-child { border-bottom: none; }
.member-row:hover { background: #FAFAF8; }
.member-row.is-you { background: rgba(207,10,44,0.03); }
.member-row-info { flex: 1; min-width: 0; }
.member-row-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-1);
}
.member-row-sub {
    font-size: 0.75rem;
    color: var(--text-3);
}
.member-row-stats {
    display: flex;
    gap: 20px;
    text-align: right;
}
.member-row-stat { }
.member-row-stat-val {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-1);
    line-height: 1;
}
.member-row-stat-lbl {
    font-size: 0.68rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.member-row.total-row {
    background: rgba(207,10,44,0.05);
    font-weight: 700;
}
.member-row.total-row .member-row-name { color: var(--red); }
.member-row.total-row .member-row-stat-val { color: var(--red); }

/* ── Section header row ─────────────────────────────────────────── */
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-1);
}

/* ── Table utilities ────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-3);
    padding: 8px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    background: var(--border-2);
}
td {
    padding: 12px 16px;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-2);
    color: var(--text-1);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAFAF8; }

/* ── Utility ────────────────────────────────────────────────────── */
.text-muted { color: var(--text-3); }
.text-small { font-size: 0.8rem; }
.d-flex { display: flex; align-items: center; gap: 10px; }
.mt-0 { margin-top: 0; }
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-3);
}
.empty-state p { margin-bottom: 14px; }

/* ── Login page ─────────────────────────────────────────────────── */
.login-page {
    display: grid;
    grid-template-columns: 56% 44%;
    min-height: 100vh;
}
.login-brand {
    background: var(--black);
    padding: 3.5rem 4rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    position: relative;
    overflow: hidden;
}
.lb-dec-1 {
    position: absolute;
    top: -80px;
    right: -80px;
    width: 360px;
    height: 360px;
    border: 60px solid rgba(207,10,44,0.12);
    border-radius: 50%;
}
.lb-dec-2 {
    position: absolute;
    top: 80px;
    right: 80px;
    width: 180px;
    height: 180px;
    border: 30px solid rgba(207,10,44,0.07);
    border-radius: 50%;
}
.lb-dec-dots {
    position: absolute;
    top: 260px;
    left: 0;
    right: 0;
    height: 120px;
    background-image: radial-gradient(circle, rgba(255,255,255,0.15) 1px, transparent 1px);
    background-size: 11px 11px;
    pointer-events: none;
}
.lb-inner { position: relative; z-index: 1; }
.lb-logo-card {
    background: #ffffff;
    border-radius: 8px;
    padding: 12px 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2.5rem;
    align-self: flex-start;
}
.lb-logo-img {
    height: 52px;
    width: auto;
    display: block;
    max-width: 300px;
    object-fit: contain;
    margin: -8px -10px;
}
.lb-bar {
    width: 48px;
    height: 4px;
    background: var(--red);
    margin-bottom: 1.5rem;
    border-radius: 2px;
}
.lb-eyebrow {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.13em;
    color: rgba(255,255,255,0.4);
    margin-bottom: 0.5rem;
}
.lb-title {
    font-size: 2.875rem;
    font-weight: 900;
    line-height: 1.08;
    letter-spacing: -0.025em;
    color: #fff;
    margin-bottom: 1.25rem;
}
.lb-desc {
    color: rgba(255,255,255,0.48);
    font-size: 0.925rem;
    line-height: 1.65;
    margin-bottom: 2rem;
}
.lb-date-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: rgba(207,10,44,0.18);
    border: 1px solid rgba(207,10,44,0.38);
    color: rgba(255,100,130,0.95);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.5rem 0.875rem;
    border-radius: 50px;
}
.login-form-panel {
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 2.5rem;
}
.lf-inner { width: 100%; max-width: 360px; }
.lf-eyebrow {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--red);
    margin-bottom: 0.5rem;
}
.lf-heading {
    font-size: 1.875rem;
    font-weight: 900;
    letter-spacing: -0.025em;
    color: var(--text-1);
    margin-bottom: 2rem;
}
.lf-footer { margin-top: 1.5rem; font-size: 0.82rem; color: var(--text-3); text-align: center; }

/* ── Admin pages ────────────────────────────────────────────────── */
.admin-wrap { max-width: 100%; }
.admin-table-wrap { overflow-x: auto; }

.admin-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}
.admin-stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
}
.admin-stat-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-3);
    margin-bottom: 6px;
}
.admin-stat-value {
    font-size: 1.875rem;
    font-weight: 900;
    color: var(--text-1);
    line-height: 1;
}
.admin-stat-value.red { color: var(--red); }
.admin-stat-sub { font-size: 0.72rem; color: var(--text-3); margin-top: 4px; }

.page-header { margin-bottom: 24px; }
.page-header h1 {
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    color: var(--text-1);
    margin-bottom: 4px;
}
.page-header p { color: var(--text-3); font-size: 0.875rem; margin: 0; }

.admin-search-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    align-items: center;
}
.admin-search-input {
    flex: 1;
    min-width: 200px;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: var(--surface);
    color: var(--text-1);
    outline: none;
}
.admin-search-input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(207,10,44,.08); }

.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    transition: all var(--t);
    white-space: nowrap;
}
.filter-pill:hover { border-color: var(--red); color: var(--red); text-decoration: none; }
.filter-pill.active { background: var(--red); color: #fff; border-color: var(--red); }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.admin-table th {
    text-align: left;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-3);
    padding: 8px 12px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.admin-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-1);
    vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover td { background: var(--bg); }
.admin-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.admin-table .muted { color: var(--text-3); font-size: 0.8rem; }

.rank-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px; height: 26px;
    border-radius: 50%;
    font-size: 0.78rem;
    font-weight: 700;
    background: var(--border);
    color: var(--text-2);
    flex-shrink: 0;
}
.rank-num.gold   { background: #FFD700; color: #7A5800; }
.rank-num.silver { background: #C0C0C0; color: #555; }
.rank-num.bronze { background: #CD7F32; color: #fff; }

.winners-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}
.winners-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.winners-panel-head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.winners-panel-title { font-size: 0.875rem; font-weight: 700; color: var(--text-1); }
.winners-panel-sub   { font-size: 0.75rem; color: var(--text-3); margin-left: auto; }

.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px; height: 32px;
    padding: 0 8px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid var(--border);
    color: var(--text-2);
    background: var(--surface);
}
.pagination a:hover { border-color: var(--red); color: var(--red); }
.pagination .current { background: var(--red); color: #fff; border-color: var(--red); }
.pagination .disabled { opacity: 0.4; pointer-events: none; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .dash-hero { grid-template-columns: 1fr; }
    .hero-motive-card { min-height: 140px; }
    .family-hero { grid-template-columns: 1fr; }
    .submission-summary { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        z-index: 200;
    }
    .sidebar.is-open { transform: translateX(0); }
    .mobile-topbar { display: flex; }
    .sidebar-toggle { display: flex; }
    .page-main { padding: 20px 16px 40px; }
    .activity-picker { grid-template-columns: 1fr; }
    .heading-row { flex-direction: column; align-items: flex-start; }
    .user-chip { display: none; }
}

@media (max-width: 600px) {
    .login-page { grid-template-columns: 1fr; }
    .login-brand { display: none; }
    .submission-summary { grid-template-columns: repeat(2, 1fr); }
    .history-table th:nth-child(5),
    .history-table td:nth-child(5) { display: none; }
    .hsc-stats { gap: 20px; flex-wrap: wrap; }
    .member-row-stats { gap: 12px; }
    .lb-logo-card { margin-bottom: 1.5rem; padding: 10px 16px; }
    .lb-logo-img { height: 42px; }
}

/* ═══════════════════════════════════════════════════════════════════
   Rewards, achievements & redemption
   ═══════════════════════════════════════════════════════════════════ */

/* Avatar as a button (redemption-code trigger) */
.user-avatar-btn {
    border: none;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
    transition: box-shadow var(--t) var(--ease), transform var(--t) var(--ease);
}
.user-avatar-btn:hover,
.user-avatar-btn:focus-visible {
    box-shadow: 0 0 0 3px var(--red-bg);
    transform: translateY(-1px);
    outline: none;
}

/* Medal badges — conventional gold/silver/bronze accents (as on Winners) */
.medal-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 3px 10px;
    border-radius: 50px;
    border: 1px solid transparent;
}
.medal-gold   { background: #FEF3C7; color: #92600A; border-color: #F1C24B; }
.medal-silver { background: #F1F2F4; color: #5A6270; border-color: #CBD2DB; }
.medal-bronze { background: #F6E7DA; color: #8A521F; border-color: #D9AE86; }
.medal-none   { background: var(--border-2); color: var(--text-3); }

/* Category label chip */
.reward-cat {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 50px;
}
.reward-cat.run  { background: #FEE2E2; color: var(--red); }
.reward-cat.swim { background: #DBEAFE; color: #1D4ED8; }

.reward-scope-note {
    font-size: 0.85rem;
    color: var(--text-2);
    background: var(--red-bg);
    border-left: 3px solid var(--red);
    padding: 10px 14px;
    border-radius: 8px;
    margin: 0 0 16px;
}

.rewards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.reward-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}
.reward-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 14px;
}
.reward-distance { display: flex; align-items: baseline; gap: 6px; margin-bottom: 12px; }
.reward-distance-val { font-size: 1.9rem; font-weight: 900; color: var(--text-1); letter-spacing: -0.02em; }
.reward-distance-unit { font-size: 0.8rem; color: var(--text-3); }

.reward-progress { margin-bottom: 14px; }
.reward-progress-bar {
    height: 8px;
    background: var(--border-2);
    border-radius: 50px;
    overflow: hidden;
    margin-bottom: 8px;
}
.reward-progress-bar span {
    display: block;
    height: 100%;
    background: var(--red);
    border-radius: 50px;
    transition: width var(--t) var(--ease);
}
.reward-progress-label { font-size: 0.82rem; color: var(--text-2); margin: 0; }

.reward-gifts { border-top: 1px solid var(--border-2); padding-top: 12px; }
.reward-gifts-label,
.redeem-gifts-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    margin: 0 0 6px;
}
.reward-gift-list,
.redeem-gift-list {
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
}
.reward-gift-list li,
.redeem-gift-list li {
    font-size: 0.9rem;
    color: var(--text-1);
    padding: 4px 0 4px 22px;
    position: relative;
}
.reward-gift-list li::before,
.redeem-gift-list li::before {
    content: "🎁";
    position: absolute;
    left: 0;
    font-size: 0.85rem;
}
.reward-status {
    font-size: 0.82rem;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 8px;
}
.reward-status.collected { background: var(--success-bg); color: var(--success); }
.reward-status.pending   { background: #FEF3C7; color: #92600A; }
.reward-hint { font-size: 0.85rem; color: var(--text-2); margin: 4px 0 0; }

/* ── Redemption code modal ─────────────────────────────────────────── */
.code-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}
.code-modal.is-open { display: flex; }
.code-modal-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 28px 24px 24px;
    width: 100%;
    max-width: 360px;
    text-align: center;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.code-modal-close {
    position: absolute;
    top: 10px;
    right: 14px;
    border: none;
    background: none;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--text-3);
    cursor: pointer;
}
.code-modal-close:hover { color: var(--text-1); }
.code-modal-eyebrow {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-3);
    margin: 0 0 8px;
}
.code-modal-code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--red);
    margin: 0 0 10px;
}
.code-modal-note { font-size: 0.85rem; color: var(--text-2); margin: 0 0 18px; }

/* ═══════════════════════════════════════════════════════════════════
   Public redemption page (redeem.php)
   ═══════════════════════════════════════════════════════════════════ */
.redeem-body {
    background: var(--bg, #F7F6F3);
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 32px 18px;
}
.redeem-shell { width: 100%; max-width: 440px; }
.redeem-logo { text-align: center; margin-bottom: 20px; }
.redeem-logo img { height: 54px; width: auto; }
.redeem-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.06);
}
.redeem-title { font-size: 1.4rem; font-weight: 900; margin: 0 0 6px; letter-spacing: -0.02em; }
.redeem-intro { font-size: 0.9rem; color: var(--text-2); margin: 0 0 18px; }
.redeem-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    margin-bottom: 6px;
}
.redeem-input {
    width: 100%;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-align: center;
    text-transform: uppercase;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    padding: 14px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-1);
}
.redeem-input:focus { outline: none; border-color: var(--red); }

.redeem-eyebrow {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    margin: 0 0 2px;
}
.redeem-name { font-size: 1.3rem; font-weight: 900; margin: 0 0 2px; letter-spacing: -0.01em; }
.redeem-group { font-size: 0.85rem; color: var(--text-2); margin: 0 0 16px; }
.redeem-empty { text-align: center; padding: 20px 0; }
.redeem-empty p { margin: 4px 0; }

.redeem-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 14px;
}
.redeem-item-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}
.redeem-restart {
    display: block;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-3);
    margin-top: 16px;
}
.redeem-footer { text-align: center; font-size: 0.75rem; color: var(--text-3); margin-top: 20px; }

/* Success screen */
.redeem-success { text-align: center; }
.redeem-check {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: var(--success-bg);
    color: var(--success);
    font-size: 2.2rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}
.redeem-success h1 { font-size: 1.4rem; font-weight: 900; margin: 0 0 6px; }
.redeem-sub { font-size: 0.95rem; color: var(--text-2); margin: 0 0 18px; }
.redeem-award {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 18px;
}
.redeem-note-ok   { font-size: 0.85rem; color: var(--success); font-weight: 600; margin: 6px 0 0; }
.redeem-note-warn { font-size: 0.85rem; color: #92600A; font-weight: 600; margin: 6px 0 0; }
.redeem-more-form { margin-top: 16px; }
