:root {
    /* ========================================
       Core tokens
    ======================================== */
    --bg: #eef4fa;
    --surface: rgba(255, 255, 255, 0.92);
    --surface-strong: rgba(255, 255, 255, 0.97);
    --surface-soft: #f8fbff;
    --border: #dce6f0;
    --border-strong: #c9d7e4;
    --text: #16324f;
    --text-muted: #5f7287;
    --primary: #1d4f7a;
    --primary-dark: #163b5a;
    --accent: #dbeafe;
    --success: #1f7a4d;
    --danger: #b45151;
    --warning: #b7791f;

    --shadow-sm: 0 8px 20px rgba(17, 40, 68, 0.06);
    --shadow-md: 0 18px 40px rgba(17, 40, 68, 0.10);

    --radius-xs: 10px;
    --radius-sm: 14px;
    --radius: 18px;
    --radius-lg: 24px;

    --max-width: 1160px;
    --content-width: min(var(--max-width), calc(100% - 32px));

    --theme-bg-left: rgba(219, 234, 254, 0.70);
    --theme-bg-start: #f7faff;
    --theme-bg-mid: #f1f6fb;
    --theme-bg-end: #eef4fa;
    --theme-progress-start: #5b7290;
    --theme-progress-end: #243b53;
    --theme-nav-active-bg: #dbeafe;
    --theme-nav-hover-bg: #ffffff;
}

/* ========================================
   Theme variants
======================================== */
body.theme-default {
    --theme-bg-left: rgba(219, 234, 254, 0.70);
    --theme-bg-start: #f7faff;
    --theme-bg-mid: #f1f6fb;
    --theme-bg-end: #eef4fa;
    --theme-progress-start: #5b7290;
    --theme-progress-end: #243b53;
    --theme-nav-active-bg: #dbeafe;
    --theme-nav-hover-bg: #ffffff;
}

body.theme-soft {
    --theme-bg-left: rgba(244, 208, 220, 0.70);
    --theme-bg-start: #fff9fb;
    --theme-bg-mid: #fdf3f6;
    --theme-bg-end: #f7edf1;
    --theme-progress-start: #c08497;
    --theme-progress-end: #8f5a6d;
    --theme-nav-active-bg: #fdebf2;
    --theme-nav-hover-bg: #ffffff;
}

body.theme-forest {
    --theme-bg-left: rgba(181, 230, 203, 0.58);
    --theme-bg-start: #f6fff9;
    --theme-bg-mid: #eef9f1;
    --theme-bg-end: #e8f4ec;
    --theme-progress-start: #40916c;
    --theme-progress-end: #1b4332;
    --theme-nav-active-bg: #def5e7;
    --theme-nav-hover-bg: #ffffff;
}

body.theme-sunrise {
    --theme-bg-left: rgba(255, 216, 168, 0.65);
    --theme-bg-start: #fffaf4;
    --theme-bg-mid: #fff4ea;
    --theme-bg-end: #fef0e3;
    --theme-progress-start: #f08a5d;
    --theme-progress-end: #b85c38;
    --theme-nav-active-bg: #ffe7d3;
    --theme-nav-hover-bg: #ffffff;
}

body.theme-midnight {
    --theme-bg-left: rgba(142, 167, 255, 0.22);
    --theme-bg-start: #eef3fb;
    --theme-bg-mid: #e7edf7;
    --theme-bg-end: #dde6f3;
    --theme-progress-start: #64748b;
    --theme-progress-end: #334155;
    --theme-nav-active-bg: #dfe8f5;
    --theme-nav-hover-bg: #f8fbff;
}

body.theme-tarheel {
    --theme-bg-left: rgba(159, 208, 240, 0.55);
    --theme-bg-start: #f4fbff;
    --theme-bg-mid: #eef8fd;
    --theme-bg-end: #e7f2fa;
    --theme-progress-start: #4b9cd3;
    --theme-progress-end: #1f3f5b;
    --theme-nav-active-bg: #dceef9;
    --theme-nav-hover-bg: #ffffff;
}

body.theme-panthers {
    --theme-bg-left: rgba(124, 202, 245, 0.40);
    --theme-bg-start: #f4f8fb;
    --theme-bg-mid: #eef4f8;
    --theme-bg-end: #e6edf1;
    --theme-progress-start: #0085ca;
    --theme-progress-end: #000000;
    --theme-nav-active-bg: #d9edf9;
    --theme-nav-hover-bg: #ffffff;
}

/* ========================================
   Base
======================================== */
* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, var(--theme-bg-left) 0%, transparent 32%),
        linear-gradient(180deg, var(--theme-bg-start) 0%, var(--theme-bg-mid) 45%, var(--theme-bg-end) 100%);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
}

img {
    max-width: 100%;
    height: auto;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}

.container {
    max-width: none;
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
}

/* ========================================
   Shared shell
======================================== */
.app-shell {
    min-height: 100vh;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    backdrop-filter: blur(10px);
    background: rgba(244, 247, 251, 0.88);
    border-bottom: 1px solid rgba(220, 230, 240, 0.85);
}

.app-topbar-inner,
.app-main-inner {
    width: var(--content-width);
    margin: 0 auto;
}

.app-topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 72px;
}

.app-brand {
    flex: 1 1 auto;
    min-width: 220px;
}

.app-brand-link {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    color: inherit;
    text-decoration: none;
}

.app-brand-link:hover {
    text-decoration: none;
}

.app-brand-title {
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.05;
    color: var(--text);
    white-space: nowrap;
}

.app-brand-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-top: 4px;
}

.app-topbar-account {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 18px;
    flex: 0 0 auto;
    margin-left: auto;
}

.account-info {
    min-width: 0;
    text-align: right;
}

.account-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}

.account-email {
    margin-top: 2px;
    font-size: 0.92rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.app-topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-main {
    padding: 28px 0 40px;
}

.app-page-header {
    margin-bottom: 18px;
}

.app-page-header-copy {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.app-title,
.page-heading {
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
}

.app-title {
    font-size: clamp(1.95rem, 3.5vw, 2.75rem);
    line-height: 1.05;
}

.app-subtitle {
    margin: 0;
    max-width: 760px;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.65;
}

.page-section {
    margin-top: 0;
    padding-top: 0;
}

.page-heading-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 18px;
}

.page-heading {
    font-size: clamp(1.65rem, 3vw, 2.25rem);
    line-height: 1.1;
}

.page-heading-meta {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

.page-heading-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ========================================
   Shared panels / cards
======================================== */
.panel,
.form-card,
.auth-card,
.content-card,
.dashboard-card,
.history-panel,
.workout-stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

.panel,
.form-card,
.auth-card,
.content-card {
    padding: 22px;
    margin-bottom: 22px;
}

.panel-header {
    margin-bottom: 14px;
}

.panel-header h2,
.panel-title,
.content-card h2 {
    margin: 0;
    font-size: 1.08rem;
    font-weight: 700;
    color: var(--text);
}

.content-card > :first-child,
.form-card > :first-child,
.auth-card > :first-child {
    margin-top: 0;
}

/* ========================================
   Navigation
======================================== */
.mobile-nav-toggle-wrap {
    display: none;
    margin: 0 0 16px;
}

.mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 14px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
}

.mobile-nav-toggle:hover {
    background: #f8fbff;
}

.mobile-nav-toggle-icon {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 18px;
}

.mobile-nav-toggle-icon span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: var(--text);
}

.mobile-nav-toggle-text {
    line-height: 1;
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 0 0 28px;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.app-nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    background: rgba(255, 255, 255, 0.76);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 0.93rem;
    font-weight: 600;
    text-decoration: none;
    transition: 0.2s ease;
}

.app-nav a:hover {
    background: var(--theme-nav-hover-bg);
    color: var(--text);
    text-decoration: none;
}

.app-nav a.active {
    background: var(--theme-nav-active-bg);
    border-color: #bfd6ee;
    color: var(--text);
    box-shadow: inset 0 0 0 1px #d4e6f7;
}

/* ========================================
   Buttons
======================================== */
button,
.btn,
input[type="submit"],
input[type="button"],
input[type="reset"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.94rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: 0.2s ease;
}

button:hover,
.btn:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
input[type="reset"]:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 10px 22px rgba(29, 79, 122, 0.18);
}

.btn-primary:hover,
input.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-secondary,
button,
input[type="submit"],
input[type="button"],
input[type="reset"] {
    background: #ffffff;
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover,
button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
input[type="reset"]:hover {
    background: #f8fbff;
    border-color: var(--border);
}

.btn-sm {
    min-height: 38px;
    padding: 0 14px;
    font-size: 0.88rem;
}

.btn-danger {
    background: #d9534f;
    border-color: #d9534f;
    color: #ffffff;
}

.btn-danger:hover {
    background: #c9302c;
    border-color: #c9302c;
}

.button-row,
.history-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ========================================
   Forms
======================================== */
.form-wrap {
    max-width: 760px;
    min-width: 0;
    max-width: 100%;
}

.form-grid {
    display: grid;
    gap: 16px;
}

.form-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field-row {
    margin-bottom: 16px;
    min-width: 0;
    max-width: 100%;
}

form {
    min-width: 0;
    max-width: 100%;
}

label {
    display: block;
    margin-bottom: 6px;
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 700;
    max-width: 100%;
}

input,
select,
textarea {
    width: 100%;
    max-width: 100%;
    padding: 11px 12px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    background: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(29, 79, 122, 0.08);
}

textarea {
    min-height: 110px;
    resize: vertical;
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
}

input[type="date"] {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

.help-text,
.field-help,
.profile-setting-help,
.data-muted,
.history-panel-meta,
.progress-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.inline-form {
    margin: 0;
}

.validation-error,
.error-message {
    color: var(--danger);
    font-size: 0.92rem;
    font-weight: 600;
}

.success-message {
    color: var(--success);
    font-size: 0.92rem;
    font-weight: 600;
}

/* ========================================
   Tables / history
======================================== */
.table-wrap,
.history-table-wrap {
    overflow-x: auto;
}

table,
.history-table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
}

th,
td,
.history-table th,
.history-table td {
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
}

th,
td {
    padding: 12px 10px;
}

th,
.history-table th {
    background: rgba(247, 249, 252, 0.95);
    color: #7b8794;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td,
.history-table td {
    color: var(--text);
    font-size: 0.95rem;
}

tr:hover td {
    background: #f7fbff;
}

.history-panel {
    overflow: hidden;
}

.history-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    background: rgba(247, 249, 252, 0.9);
    border-bottom: 1px solid var(--border);
}

.history-panel-title {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--text);
}

.history-table th,
.history-table td {
    padding: 14px 16px;
    vertical-align: middle;
}

.history-table td {
    background: rgba(255, 255, 255, 0.78);
}

.history-table tr:last-child td {
    border-bottom: none;
}

.action-link {
    color: var(--primary);
    font-size: 0.92rem;
    font-weight: 700;
}

.data-strong {
    color: var(--text);
    font-weight: 700;
}

.note-cell[title] {
    cursor: help;
}

.history-empty,
.empty-message {
    padding: 20px;
}

.empty-message {
    margin: 0;
    background: var(--surface-soft);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-xs);
    color: var(--text-muted);
}

/* ========================================
   Dashboard
======================================== */
.dashboard-grid,
.dashboard-feature-grid,
.dashboard-lower-grid,
.dashboard-summary-grid,
.dashboard-streak-checks,
.dashboard-goal-bars,
.dashboard-feature-grid-2 {
    display: grid;
}

.dashboard-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.dashboard-grid-primary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 6px;
}

.dashboard-feature-grid {
    grid-template-columns: 1fr 1.3fr;
    gap: 16px;
    margin-bottom: 24px;
}

.dashboard-feature-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.dashboard-lower-grid {
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.dashboard-card {
    padding: 18px;
}

.dashboard-feature-card,
.dashboard-feature-card-wide {
    min-height: 220px;
}

.dashboard-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.dashboard-card-label,
.dashboard-card-code,
.dashboard-summary-name,
.goal-bar-label {
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dashboard-card-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #7b8794;
}

.dashboard-card-code {
    padding: 4px 8px;
    background: #eef3f8;
    border: 1px solid #dce5ef;
    border-radius: 8px;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1;
}

.dashboard-card-value {
    margin-bottom: 6px;
    color: var(--text);
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.dashboard-card-note {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.value-positive {
    color: var(--success);
}

.value-negative {
    color: var(--danger);
}

.dashboard-goal-progress {
    margin: 18px 0 10px;
}

.dashboard-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 18px;
    margin: 8px 0 16px;
}

.dashboard-summary-grid-single {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dashboard-summary-item,
.dashboard-streak-check {
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(91, 114, 144, 0.10);
    border-radius: 12px;
}

.dashboard-summary-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dashboard-summary-name {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

.dashboard-summary-value,
.dashboard-streak-value,
.leader-score {
    color: var(--text);
    font-weight: 800;
}

.dashboard-summary-value {
    font-size: 1.2rem;
}

.dashboard-streak-card {
    display: flex;
    flex-direction: column;
}

.dashboard-streak-value {
    margin-bottom: 8px;
    font-size: 1.9rem;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.dashboard-streak-checks {
    gap: 10px;
    margin: 18px 0 16px;
}

.dashboard-streak-check {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-weight: 700;
}

.dashboard-streak-check.is-complete {
    color: var(--text);
}

.dashboard-streak-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    min-width: 20px;
    height: 20px;
    background: #e9eff5;
    border-radius: 999px;
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 800;
}

.dashboard-streak-check.is-complete .dashboard-streak-icon {
    background: rgba(47, 125, 87, 0.14);
    color: var(--success);
}

.dashboard-goal-bars {
    gap: 14px;
    margin-top: 18px;
}

.goal-bar-block {
    display: grid;
    gap: 6px;
}

.goal-bar-label {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

/* ========================================
   Progress / charts
======================================== */
.progress-track {
    width: 100%;
    height: 12px;
    overflow: hidden;
    background: #e9eff5;
    border: 1px solid #dde6ee;
    border-radius: 999px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--theme-progress-start) 0%, var(--theme-progress-end) 100%);
    border-radius: 999px;
}

.chart-wrap {
    position: relative;
    min-height: 320px;
}

.chart-wrap-tall {
    min-height: 380px;
}

/* ========================================
   Auth pages
======================================== */
.auth-shell {
    width: min(560px, calc(100% - 24px));
    margin: 48px auto;
}

.auth-card {
    padding: 28px;
}

.auth-card h1,
.auth-card h2 {
    margin-top: 0;
    margin-bottom: 12px;
}

.auth-card p {
    color: var(--text-muted);
}

/* ========================================
   Profile
======================================== */
.profile-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.profile-card {
    text-align: center;
}

.profile-avatar-wrap {
    display: flex;
    justify-content: center;
    margin-top: 18px;
}

.profile-avatar {
    width: 180px;
    height: 180px;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(91, 114, 144, 0.14);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
}

.profile-avatar-placeholder,
.leader-avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    font-weight: 800;
}

.profile-avatar-placeholder {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 251, 255, 0.96) 100%);
    font-size: 3.2rem;
}

.profile-setting-row {
    margin: 10px 0 18px;
}

.profile-checkbox-line,
.agreement-line,
.danger-confirm {
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    cursor: pointer;
}

.profile-checkbox-line {
    gap: 12px;
}

.profile-checkbox-line input[type="checkbox"] {
    width: 16px !important;
    height: 16px !important;
}

.profile-checkbox-text {
    color: #2f3a4a;
    font-size: 15px;
    font-weight: 700;
}

/* ========================================
   Leaderboard
======================================== */
.leaderboard-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.leaderboard-list {
    display: grid;
}

.leader-row {
    display: grid;
    grid-template-columns: 44px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.leader-row:last-child {
    border-bottom: none;
}

.leader-rank {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 800;
}

.leader-user {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.leader-avatar {
    width: 42px;
    height: 42px;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(91, 114, 144, 0.14);
    border-radius: 12px;
}

.leader-avatar-placeholder {
    font-size: 1rem;
}

.leader-user-info {
    min-width: 0;
}

.leader-name {
    overflow: hidden;
    color: var(--text);
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leader-subtext {
    color: var(--text-muted);
    font-size: 0.86rem;
}

.leader-score {
    white-space: nowrap;
}

/* ========================================
   Goals
======================================== */
.goals-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

/* ========================================
   Footer / agreements / danger
======================================== */
.app-footer {
    padding: 32px 0 38px;
    color: var(--text-muted);
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    border-top: 1px solid rgba(220, 230, 240, 0.9);
    padding-top: 22px;
}

.footer-copy {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.footer-version {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
}

.footer-links {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-muted);
    font-weight: 500;
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--text);
    text-decoration: none;
}

.agreement-block {
    width: 100%;
    margin: 18px 0 20px;
}

.agreement-line {
    justify-content: flex-start;
    width: 100%;
    margin-bottom: 10px;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.5;
}

.agreement-line input[type="checkbox"],
.danger-confirm input[type="checkbox"] {
    width: auto !important;
    height: auto !important;
    min-width: 16px;
    margin: 0;
    flex: 0 0 auto;
}

.agreement-line span {
    display: inline-block;
    flex: 0 1 auto;
}

.agreement-line a {
    color: var(--primary);
    font-weight: 600;
}

.danger-zone {
    margin-top: 20px;
    border: 1px solid #e7b3b3;
}

.danger-title {
    color: #b94a4a;
}

/* ========================================
   Summary filters / utility pills
======================================== */
.summary-filter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    background: #f6f9fc;
    border: 1px solid var(--border);
    border-radius: 999px;
}

.summary-filter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 30px;
    padding: 0 12px;
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-decoration: none;
    border-radius: 999px;
    transition: all 0.2s ease;
}

.summary-filter-btn:hover {
    background: #e8f0f8;
    color: #1e3a5f;
    text-decoration: none;
}

.summary-filter-btn.active {
    background: var(--accent);
    box-shadow: inset 0 0 0 1px #bfd6ee;
    color: #16324f;
}

/* ========================================
   Exercise history helpers
======================================== */
.exercise-history-page .page-heading-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.exercise-history-page .exercise-summary-grid,
.exercise-history-page .exercise-feature-grid {
    margin-bottom: 20px;
}

/* ========================================
   Workout reminder page
======================================== */
.workout-reminder-page {
    max-width: 720px;
    margin: 0 auto;
    padding-top: 1rem;
    padding-bottom: 1.5rem;
}

.workout-reminder-card {
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    overflow: visible;
    border: 0;
}

.workout-header {
    margin-bottom: 1rem;
}

.workout-title {
    margin: 0 0 0.4rem;
    font-size: 1.9rem;
    line-height: 1.15;
    font-weight: 800;
    color: var(--text);
}

.workout-date {
    margin: 0;
    font-size: 1rem;
    color: var(--text-muted);
}

.workout-list {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    margin-top: 1.25rem;
}

.workout-stat-card {
    overflow: hidden;
}

.workout-stat-card-body {
    padding: 1rem 1.1rem;
}

.workout-stat-title {
    margin: 0 0 0.4rem;
    font-size: 1.05rem;
    line-height: 1.3;
    font-weight: 700;
    color: var(--text);
}

.workout-stat-value {
    margin: 0;
    font-size: 1rem;
    line-height: 1.4;
    font-weight: 500;
    color: var(--text-muted);
}

.workout-empty {
    margin: 1rem 0 0;
    color: var(--text-muted);
}

/* ========================================
   Utility classes
======================================== */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-0 {
    margin-top: 0 !important;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.mb-12 {
    margin-bottom: 12px !important;
}

.mb-16 {
    margin-bottom: 16px !important;
}

.mb-20 {
    margin-bottom: 20px !important;
}

.mb-24 {
    margin-bottom: 24px !important;
}

.w-full {
    width: 100%;
}

/* ========================================
   Responsive
======================================== */
@media (max-width: 1100px) {
    .dashboard-grid-primary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-feature-grid,
    .dashboard-lower-grid,
    .leaderboard-grid,
    .profile-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .dashboard-card-wide,
    .dashboard-feature-card-wide {
        grid-column: span 1;
    }

    .form-grid-3 {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .app-topbar {
        position: static;
    }

    .app-topbar-inner,
    .app-main-inner {
        width: calc(100% - 24px);
    }

    .app-topbar-inner,
    .page-heading-row,
    .history-panel-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .app-topbar-inner {
        gap: 14px;
        min-height: auto;
        padding: 14px 0;
    }

    .app-brand {
        min-width: 0;
        width: 100%;
    }

    .app-brand-title {
        font-size: 1.5rem;
        white-space: normal;
    }

    .app-topbar-account {
        width: 100%;
        justify-content: space-between;
        align-items: flex-start;
        flex-wrap: wrap;
        margin-left: 0;
    }

    .account-info {
        text-align: left;
    }

    .account-name,
    .account-email {
        white-space: normal;
    }

    .app-main {
        padding: 20px 0 30px;
    }

    .app-title {
        font-size: 1.9rem;
    }

    .mobile-nav-toggle-wrap {
        display: block;
    }

    .app-nav {
        display: none !important;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-bottom: 24px;
    }

    .app-nav.is-open {
        display: flex !important;
    }

    .app-nav a {
        justify-content: flex-start;
        min-height: 48px;
        padding: 0 14px;
        border-radius: 16px;
        background: rgba(255, 255, 255, 0.92);
    }

    .dashboard-grid-primary,
    .dashboard-summary-grid,
    .dashboard-summary-grid-single,
    .goals-grid,
    .form-grid-2,
    .form-grid-3 {
        grid-template-columns: 1fr;
    }

    .dashboard-card-value {
        font-size: 1.7rem;
    }

    .chart-wrap {
        min-height: 260px;
    }

    .leader-row {
        grid-template-columns: 34px 1fr;
    }

    .leader-score {
        grid-column: 2;
        margin-top: 4px;
    }

    .profile-avatar {
        width: 140px;
        height: 140px;
    }

    .workout-reminder-page {
        padding-top: 0.75rem;
        padding-bottom: 1rem;
    }

    .workout-title {
        font-size: 1.7rem;
    }

    .workout-date {
        font-size: 0.95rem;
    }

    .workout-stat-card {
        border-radius: 16px;
    }

    .workout-stat-card-body {
        padding: 0.95rem 1rem;
    }

    .workout-stat-title {
        font-size: 1rem;
    }

    .workout-stat-value {
        font-size: 0.95rem;
    }

    form {
        width: 100%;
    }

    .form-wrap,
    .form-card {
        width: 100%;
        overflow-x: hidden;
    }

    input[type="date"] {
        font-size: 16px;
    }
}

@media (max-width: 640px) {
    .footer-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .app-title {
        font-size: 1.7rem;
    }

    .app-subtitle {
        font-size: 0.96rem;
    }

    .auth-shell {
        width: calc(100% - 20px);
        margin: 24px auto;
    }

    .auth-card {
        padding: 22px;
    }
}

.macro-dashboard {
    display: grid;
    gap: 18px;
    margin-bottom: 24px;
}

.macro-dashboard-grid {
    display: grid;
    gap: 16px;
}

.macro-dashboard-grid-primary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.macro-dashboard-grid-secondary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.macro-card {
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px 22px;
}

.macro-card-primary {
    min-height: 160px;
}

.macro-card .dashboard-card-label {
    font-size: 0.82rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.macro-card .dashboard-card-value {
    font-size: clamp(2rem, 3vw, 2.8rem);
    line-height: 1.05;
}

.macro-card-secondary .dashboard-card-value {
    font-size: clamp(1.6rem, 2.2vw, 2.1rem);
}

.macro-card-subtext {
    margin-top: 12px;
    font-size: 0.95rem;
    color: #5f728c;
}

@media (max-width: 1024px) {
    .macro-dashboard-grid-primary,
    .macro-dashboard-grid-secondary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .macro-dashboard-grid-primary,
    .macro-dashboard-grid-secondary {
        grid-template-columns: 1fr;
    }

    .macro-card,
    .macro-card-primary {
        min-height: auto;
    }
}

.app-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 8px;
}

.app-nav-link,
.app-nav-trigger {
    appearance: none;
    border: 1px solid #c7d3df;
    background: rgba(255, 255, 255, 0.78);
    color: #4f6786;
    border-radius: 999px;
    padding: 12px 18px;
    font-size: 0.98rem;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    transition: all 0.18s ease;
}

.app-nav-link:hover,
.app-nav-trigger:hover {
    background: rgba(255, 255, 255, 0.96);
    border-color: #9fb7d1;
    color: #163c69;
    transform: translateY(-1px);
}

.app-nav-link.active,
.app-nav-dropdown.active-group > .app-nav-trigger {
    background: #c6d8ef;
    border-color: #9cb8d9;
    color: #163c69;
}

.app-nav-dropdown {
    position: relative;
}

.app-nav-caret {
    font-size: 0.8rem;
    opacity: 0.8;
}

.app-nav-menu {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    min-width: 220px;
    padding: 10px;
    border: 1px solid #cbd7e3;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 16px 36px rgba(16, 44, 79, 0.12);
    display: none;
    z-index: 1000;
}

.app-nav-dropdown:hover .app-nav-menu,
.app-nav-dropdown:focus-within .app-nav-menu {
    display: block;
}

.app-nav-menu-link {
    display: block;
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    text-decoration: none;
    color: #234c78;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.18s ease, color 0.18s ease;
}

.app-nav-menu-link:hover {
    background: #edf4fb;
    color: #163c69;
}

.app-nav-menu-link.active {
    background: #dce9f7;
    color: #163c69;
}

@media (max-width: 768px) {
    .app-nav {
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .app-nav.is-open {
        display: flex;
    }

    .app-nav-link,
    .app-nav-trigger {
        width: 100%;
        justify-content: space-between;
    }

    .app-nav-dropdown {
        width: 100%;
    }

    .app-nav-menu {
        position: static;
        display: none;
        min-width: 0;
        margin-top: 8px;
        box-shadow: none;
        border-radius: 16px;
        background: rgba(255, 255, 255, 0.72);
    }

    .app-nav-dropdown.is-open .app-nav-menu {
        display: block;
    }
}