/* =============================================
   FitLog - Workout Tracker
   Dark theme, mobile-first, gym-friendly
   ============================================= */

:root {
    --bg: #0f0f1a;
    --bg-surface: #1a1a2e;
    --bg-card: #16213e;
    --bg-input: #1e2a45;
    --border: #2a3a5c;
    --primary: #4f8cff;
    --primary-dark: #3a6fd8;
    --accent: #e94560;
    --success: #2ecc71;
    --warning: #f39c12;
    --danger: #e74c3c;
    --text: #e8e8f0;
    --text-muted: #8892a8;
    --text-dim: #5a6478;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --bottom-nav-height: 64px;
}

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

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { opacity: 0.85; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ---- Navbar ---- */
.navbar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 100;
    overflow: visible;
    padding-top: env(safe-area-inset-top, 0px);
}

.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
    margin-right: 0.75rem;
}

.logo-icon {
    font-size: 1.5rem;
    color: var(--accent);
    flex-shrink: 0;
}
.logo-icon-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 4px;
    vertical-align: middle;
}

.nav-toggle {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform-origin: center;
}

/* Burger → X animation */
.nav-toggle.active span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle.active span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-toggle.active span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.nav-menu {
    position: absolute;
    top: calc(56px + env(safe-area-inset-top, 0px));
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0;
    z-index: 99;
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

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

.nav-link {
    display: block;
    padding: 0.75rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    transition: background 0.15s;
}

.nav-link:hover { background: var(--bg-card); color: var(--text); }
.nav-link.active { color: var(--primary); background: rgba(79, 140, 255, 0.08); }

.nav-divider { border-top: 1px solid var(--border); margin: 0.25rem 0; }

.nav-logout { color: var(--accent) !important; }

@media (min-width: 1100px) {
    .nav-toggle { display: none; }
    .nav-menu {
        position: static;
        display: flex;
        background: none;
        border: none;
        padding: 0;
        align-items: center;
        gap: 0;
        opacity: 1;
        transform: none;
        pointer-events: auto;
        transition: none;
        flex-shrink: 0;
    }
    .nav-link { padding: 0.5rem 0.6rem; border-radius: var(--radius-sm); font-size: 0.88rem; white-space: nowrap; }
    .nav-link.active { background: rgba(79, 140, 255, 0.12); }
    .nav-divider { border: none; width: 1px; height: 20px; background: var(--border); margin: 0 0.15rem; }
}

/* ---- Bottom Navigation (Mobile) ---- */
.bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    z-index: 100;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.7rem;
    gap: 2px;
    transition: color 0.15s;
}

.bottom-nav-item:hover,
.bottom-nav-item:active { color: var(--primary); }

.bottom-nav-icon {
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bottom-nav-icon svg {
    display: block;
}

.bottom-nav-primary {
    color: var(--accent);
}

.bottom-nav-primary .bottom-nav-icon {
    background: var(--accent);
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: -18px;
    font-size: 1.4rem;
    box-shadow: 0 4px 16px rgba(233, 69, 96, 0.45);
    transition: transform 0.15s, box-shadow 0.15s;
}

.bottom-nav-primary:active .bottom-nav-icon {
    transform: scale(0.92);
    box-shadow: 0 2px 8px rgba(233, 69, 96, 0.3);
}

@media (min-width: 1100px) {
    .bottom-nav { display: none; }
}

/* ---- Footer ---- */
.app-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    font-size: 0.75rem;
    color: var(--text-dim);
    border-top: 1px solid var(--border);
    margin-top: auto;
}
.app-footer a { color: var(--text-muted); font-weight: 600; }
.app-footer a:hover { color: var(--primary); }
.footer-heart { color: var(--accent); font-size: 0.85rem; }

@media (max-width: 1099px) {
    .app-footer { margin-bottom: var(--bottom-nav-height); }
}

/* ---- Main Content ---- */
.main-content {
    padding-bottom: 1rem;
    flex: 1 0 auto;
    animation: pageFadeIn 0.35s ease-out;
}

@keyframes pageFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 768px) {
    .main-content { padding-bottom: 2rem; }
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem;
}

/* ---- Alerts ---- */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin: 0.5rem 1rem;
    font-size: 0.9rem;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-success { background: rgba(46, 204, 113, 0.15); color: var(--success); border: 1px solid rgba(46, 204, 113, 0.3); }
.alert-error { background: rgba(231, 76, 60, 0.15); color: var(--danger); border: 1px solid rgba(231, 76, 60, 0.3); }

/* ---- Page Header ---- */
.page-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.page-header h2 {
    font-size: 1.35rem;
    font-weight: 700;
    flex: 1;
}

.page-actions { display: flex; gap: 0.5rem; }

.btn-back {
    color: var(--text-muted);
    font-size: 1.5rem;
    line-height: 1;
    padding: 0.25rem;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }

.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-outline.active { border-color: var(--primary); color: var(--primary); background: rgba(79, 140, 255, 0.1); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c0392b; }

.btn-danger-text { background: none; border: none; color: var(--text-dim); cursor: pointer; padding: 0.25rem 0.5rem; }
.btn-danger-text:hover { color: var(--danger); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.85rem 2rem; font-size: 1rem; }
.btn-block { width: 100%; }

/* ---- Cards ---- */
.form-card, .info-card, .stat-card, .workout-header-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

/* ---- Stats Grid ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stat-card { text-align: center; }
.stat-number { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-number-text { font-size: 1.15rem; word-break: break-word; line-height: 1.3; min-height: 2.4rem; display: flex; align-items: center; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-hint { font-size: 0.7rem; color: var(--text-dim); margin-top: 0.2rem; text-transform: none; letter-spacing: 0; }

/* ---- Date Filter ---- */
.date-filter { margin-bottom: 1.25rem; }
.date-filter-presets { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.date-filter-custom { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; align-items: end; }
.date-filter-custom label { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.25rem; display: block; }
.date-filter-custom .form-group { margin-bottom: 0; }
.date-filter-actions { display: flex; gap: 0.5rem; margin-top: 0.6rem; }
@media (max-width: 480px) { .date-filter-custom { grid-template-columns: 1fr; } }

/* ---- Client Grid ---- */
.client-grid { display: flex; flex-direction: column; gap: 0.5rem; }

.client-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    color: var(--text);
    transition: border-color 0.15s;
}

.client-card:hover { border-color: var(--primary); color: var(--text); }

.client-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.client-info { flex: 1; min-width: 0; }
.client-name { font-weight: 600; font-size: 0.95rem; }
.client-meta { font-size: 0.8rem; color: var(--text-muted); }
.client-arrow { color: var(--text-dim); font-size: 1.25rem; }

/* ---- Info Card ---- */
.info-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.info-item:last-child { border-bottom: none; }
.info-label { color: var(--text-muted); font-size: 0.85rem; }
.info-item-stacked { flex-direction: column; gap: 0.25rem; }

/* ---- Section ---- */
.section { margin-bottom: 1.5rem; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.section h3, .section-header h3 { font-size: 1.1rem; font-weight: 600; }
.section > h3 { margin-bottom: 0.75rem; }
.category-title { font-size: 0.95rem; color: var(--primary); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.5rem; }

/* ---- Workout List ---- */
.workout-list { display: flex; flex-direction: column; gap: 0.5rem; }

.workout-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    color: var(--text);
    transition: border-color 0.15s;
}

.workout-item:hover { border-color: var(--primary); color: var(--text); }

.workout-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    min-width: 70px;
    font-weight: 500;
}

.workout-detail { flex: 1; font-size: 0.9rem; }
.workout-title { display: block; font-size: 0.8rem; color: var(--text-muted); }

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success { background: rgba(46, 204, 113, 0.15); color: var(--success); }
.badge-warning { background: rgba(243, 156, 18, 0.15); color: var(--warning); }

/* ---- Forms ---- */
.form-group {
    margin-bottom: 1rem;
    min-width: 0;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    min-width: 0;
    padding: 0.65rem 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.95rem;
    font-family: var(--font);
    transition: border-color 0.15s;
}

/* Date inputs: strip native appearance so they respect width like text inputs */
.form-group input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.15);
}

.form-group select { -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238892a8'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

@media (max-width: 480px) {
    .form-row { grid-template-columns: 1fr; }
}

.form-row .flex-2 { grid-column: span 1; }

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

/* ---- Search Filter ---- */
.list-search {
    width: 100%;
    padding: 0.65rem 1rem 0.65rem 2.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    transition: border-color 0.2s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235a6478' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 0.75rem center;
}
.list-search:focus { outline: none; border-color: var(--primary); }
.list-search::placeholder { color: var(--text-dim); }

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state p { margin-bottom: 1rem; }

/* ---- Auth ---- */
.auth-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 1rem;
}
.auth-body .app-footer {
    width: 100%;
    margin-top: auto;
    border-top: none;
}

.auth-container {
    width: 100%;
    max-width: 380px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo .logo-icon { font-size: 3rem; }
.auth-logo h1 { font-size: 1.5rem; margin-top: 0.5rem; }
.auth-logo p { color: var(--text-muted); font-size: 0.9rem; }

.auth-form {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.auth-form .form-group { margin-bottom: 1.25rem; }

/* ============================================
   WORKOUT SPREADSHEET GRID
   ============================================ */

.workout-form { max-width: 100%; }

.exercise-block {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    overflow: hidden;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.exercise-block-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(79, 140, 255, 0.08);
    border-bottom: 1px solid var(--border);
}

.exercise-block-header .exercise-category {
    font-size: 0.7rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.exercise-select-wrapper {
    flex: 1;
    position: relative;
}

.exercise-search {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 600;
}

.exercise-search:focus {
    outline: none;
    border-color: var(--primary);
}

.exercise-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    max-height: 200px;
    overflow-y: auto;
    z-index: 50;
    margin-top: 4px;
    box-shadow: var(--shadow);
}

.exercise-dropdown.active { display: block; }

.exercise-dropdown-item {
    padding: 0.6rem 0.85rem;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.exercise-dropdown-item:hover,
.exercise-dropdown-item.highlighted { background: var(--bg-card); }

.exercise-dropdown-item .cat-label {
    font-size: 0.7rem;
    color: var(--text-dim);
}

.btn-remove-exercise {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
}

.btn-remove-exercise:hover { color: var(--danger); }

/* Sets Table */
.sets-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.sets-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.sets-table th {
    padding: 0.5rem 0.5rem;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.sets-table td {
    padding: 0.35rem 0.25rem;
    text-align: center;
    border-bottom: 1px solid rgba(42, 58, 92, 0.4);
    vertical-align: middle;
}

.sets-table tr:last-child td { border-bottom: none; }

.set-number {
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.85rem;
    width: 32px;
}

.sets-table input[type="number"] {
    width: 60px;
    padding: 0.45rem 0.35rem;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text);
    font-size: 0.95rem;
    text-align: center;
    font-family: var(--font);
    -webkit-appearance: textfield;
    -moz-appearance: textfield;
}

.sets-table input[type="number"]::-webkit-inner-spin-button,
.sets-table input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.sets-table input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(79, 140, 255, 0.08);
}

.weight-input { width: 70px !important; }

/* Previous weight hint */
.prev-hint {
    font-size: 0.75rem;
    color: var(--text-dim);
    white-space: nowrap;
    min-width: 70px;
}

.prev-hint .prev-weight {
    color: var(--warning);
    font-weight: 600;
}

.btn-remove-set {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem;
    line-height: 1;
}

.btn-remove-set:hover { color: var(--danger); }

.btn-add-set {
    display: block;
    width: 100%;
    padding: 0.5rem;
    background: none;
    border: none;
    border-top: 1px dashed var(--border);
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.85rem;
    font-family: var(--font);
    transition: color 0.15s;
}

.btn-add-set:hover { color: var(--primary); }

.btn-add-exercise {
    display: block;
    width: 100%;
    padding: 0.85rem;
    background: var(--bg-card);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    color: var(--primary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.15s;
}

.btn-add-exercise:hover {
    border-color: var(--primary);
    background: rgba(79, 140, 255, 0.05);
}

/* Undo/Redo Toolbar */
.undo-toolbar {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0;
    margin-bottom: 0.5rem;
}
.btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font);
}
.btn-icon:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-icon:disabled { opacity: 0.25; cursor: default; }
.undo-status {
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-left: 0.35rem;
}

/* Sticky Save */
.sticky-save {
    position: -webkit-sticky;
    position: sticky;
    bottom: calc(var(--bottom-nav-height) + 0.5rem);
    z-index: 10;
    margin-top: 1rem;
}

@media (min-width: 1100px) {
    .sticky-save { bottom: 1rem; }
}

/* Workout Show */
.exercise-block-view {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    overflow: hidden;
}

.exercise-block-view .exercise-block-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(79, 140, 255, 0.08);
    border-bottom: 1px solid var(--border);
}

.exercise-block-view .sets-table .weight-cell {
    color: var(--primary);
    font-weight: 600;
}

.exercise-block-view .sets-table .notes-cell {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: left;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workout-show-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ---- Exercise List ---- */
.exercise-list { display: flex; flex-direction: column; gap: 0.25rem; }

.exercise-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.85rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.exercise-name { font-size: 0.9rem; }

/* ---- Loading ---- */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Toast ---- */
.toast {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 80px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 200;
    font-size: 0.9rem;
    animation: toastIn 0.3s ease;
}

.toast.toast-success { border-color: var(--success); }
.toast.toast-error { border-color: var(--danger); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============================================
   PLANS (Programs, Diets, Supplements)
   ============================================ */

.plan-list { display: flex; flex-direction: column; gap: 0.5rem; }

.plan-card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    color: var(--text);
    transition: border-color 0.15s;
}

.plan-card:hover { border-color: var(--primary); color: var(--text); }

.plan-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.plan-card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.badge-default { background: rgba(136, 146, 168, 0.15); color: var(--text-muted); }

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.quick-action-btn {
    flex: 1;
    min-width: 100px;
    padding: 0.6rem 0.75rem;
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    transition: all 0.15s;
}

.quick-action-btn:hover {
    border-color: var(--primary);
    border-style: solid;
    color: var(--primary);
}

/* Macro Overview */
.macro-overview {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.macro-card {
    text-align: center;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.macro-protein { background: rgba(46, 204, 113, 0.08); border-color: rgba(46, 204, 113, 0.3); }
.macro-carbs { background: rgba(79, 140, 255, 0.08); border-color: rgba(79, 140, 255, 0.3); }
.macro-fat { background: rgba(243, 156, 18, 0.08); border-color: rgba(243, 156, 18, 0.3); }

.macro-value { font-size: 1.5rem; font-weight: 700; }
.macro-protein .macro-value { color: var(--success); }
.macro-carbs .macro-value { color: var(--primary); }
.macro-fat .macro-value { color: var(--warning); }

.macro-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.macro-bar-mini {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.35rem;
    font-size: 0.75rem;
}

.macro-p { color: var(--success); }
.macro-c { color: var(--primary); }
.macro-f { color: var(--warning); }

/* ---- Settings ---- */
.settings-section-title {
    font-size: 0.9rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 1.25rem 0 0.75rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
}

.settings-section-title:first-child { margin-top: 0; }

.form-hint {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-top: 0.3rem;
}

.upload-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.icon-preview-img {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    object-fit: contain;
}
.file-input {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}
.file-input::file-selector-button {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
    margin-right: 0.5rem;
}
.file-input::file-selector-button:hover {
    background: var(--bg-surface);
    border-color: var(--primary);
}

.logo-preview {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0.6rem 0.85rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
}

.logo-preview-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.logo-preview-content {
    font-size: 1.5rem;
    color: var(--accent);
    display: flex;
    align-items: center;
}

.logo-preview-content img {
    max-height: 32px;
    width: auto;
}

.logo-preview-content svg {
    max-height: 32px;
    width: auto;
}

/* ============================================
   ATHLETE STATISTICS
   ============================================ */

/* Weekly Frequency Chart */
.freq-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 120px;
    padding: 0.5rem 0;
}

.freq-bar-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}

.freq-bar {
    width: 100%;
    max-width: 28px;
    min-height: 4px;
    background: var(--primary);
    border-radius: 3px 3px 0 0;
    position: relative;
    transition: height 0.4s ease;
}

.freq-bar-wrap:last-child .freq-bar {
    background: var(--accent);
}

.freq-bar-val {
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
}

.freq-bar-label {
    font-size: 0.6rem;
    color: var(--text-dim);
    margin-top: 4px;
    white-space: nowrap;
}

/* Category Distribution */
.cat-dist { margin-top: 0.5rem; }

.cat-bar-track {
    display: flex;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    background: var(--bg-input);
}

.cat-bar-segment {
    transition: width 0.5s ease;
    min-width: 2px;
}

.cat-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-top: 0.65rem;
}

.cat-legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.cat-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cat-legend-pct {
    font-weight: 600;
    color: var(--text);
}

/* Stats category title - sticky */
.section > .category-title {
    position: -webkit-sticky;
    position: sticky;
    top: 56px;
    z-index: 10;
    background: var(--bg);
    padding: 0.5rem 0;
    margin-top: 0.75rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
}

/* Exercise Progression Cards */
.progression-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    margin-bottom: 0.65rem;
    overflow: hidden;
    animation: cardSlideUp 0.3s ease-out both;
}

.progression-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.progression-name {
    font-weight: 600;
    font-size: 0.92rem;
}

.progression-sessions {
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-left: 0.4rem;
}

.progression-pr {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.pr-weight {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
}

.pr-label {
    font-size: 0.65rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.trend-up { color: var(--success); font-size: 0.7rem; }
.trend-down { color: var(--danger); font-size: 0.7rem; }

/* Progression mini-chart */
.progression-chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 60px;
    margin-bottom: 2px;
}

.prog-bar-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}

.prog-bar {
    width: 100%;
    max-width: 24px;
    min-height: 4px;
    background: var(--primary);
    border-radius: 2px 2px 0 0;
    opacity: 0.6;
    transition: height 0.4s ease, opacity 0.2s;
}

.prog-bar-pr {
    opacity: 1;
    background: var(--success);
}

.prog-bar-wrap:last-child .prog-bar {
    opacity: 1;
}

.prog-bar-kg {
    font-size: 0.6rem;
    color: var(--text-dim);
    margin-top: 2px;
}

.progression-dates {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--text-dim);
    padding-top: 2px;
}

.progression-single {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 0.25rem 0;
}

/* ============================================
   PROGRAM → WORKOUT CONNECTION
   ============================================ */

/* Program badge bar on workout create page */
.program-badge-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    background: rgba(79, 140, 255, 0.1);
    border: 1px solid rgba(79, 140, 255, 0.25);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.88rem;
    color: var(--text);
    animation: cardSlideUp 0.3s ease-out;
}

.program-badge-icon {
    font-size: 1.1rem;
}

/* Day selection buttons on client profile */
.program-days-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border);
}

.program-day-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.7rem;
    background: rgba(79, 140, 255, 0.1);
    border: 1px solid rgba(79, 140, 255, 0.25);
    border-radius: 20px;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 600;
    transition: all 0.15s;
    white-space: nowrap;
}

.program-day-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Program link badge on workout show page */
.program-link-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.65rem;
    background: rgba(79, 140, 255, 0.1);
    border: 1px solid rgba(79, 140, 255, 0.2);
    border-radius: 20px;
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 500;
    transition: background 0.15s;
}

.program-link-badge:hover {
    background: rgba(79, 140, 255, 0.2);
    color: var(--primary);
}

/* ============================================
   ANIMATIONS & MICRO-INTERACTIONS
   ============================================ */

/* Staggered card entrance */
@keyframes cardSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.stat-card,
.client-card,
.plan-card,
.workout-item,
.exercise-item,
.exercise-block-view,
.info-card,
.form-card {
    animation: cardSlideUp 0.3s ease-out both;
}

.stat-card:nth-child(1), .client-card:nth-child(1), .plan-card:nth-child(1), .workout-item:nth-child(1) { animation-delay: 0.03s; }
.stat-card:nth-child(2), .client-card:nth-child(2), .plan-card:nth-child(2), .workout-item:nth-child(2) { animation-delay: 0.06s; }
.stat-card:nth-child(3), .client-card:nth-child(3), .plan-card:nth-child(3), .workout-item:nth-child(3) { animation-delay: 0.09s; }
.stat-card:nth-child(4), .client-card:nth-child(4), .plan-card:nth-child(4), .workout-item:nth-child(4) { animation-delay: 0.12s; }
.stat-card:nth-child(5), .client-card:nth-child(5), .plan-card:nth-child(5), .workout-item:nth-child(5) { animation-delay: 0.15s; }
.client-card:nth-child(n+6), .plan-card:nth-child(n+6), .workout-item:nth-child(n+6) { animation-delay: 0.18s; }

/* Button press feedback */
.btn:active,
.quick-action-btn:active {
    transform: scale(0.97);
}

/* Card tap/press feedback */
.client-card:active,
.plan-card:active,
.workout-item:active {
    transform: scale(0.985);
    transition: transform 0.1s ease;
}

/* Smooth focus glow on inputs */
.form-group input,
.form-group select,
.form-group textarea {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Active bottom nav item highlight */
.bottom-nav-item.active {
    color: var(--primary);
}

/* Nav link hover slide indicator */
.nav-link {
    position: relative;
}

/* Page header entrance */
.page-header {
    animation: pageFadeIn 0.3s ease-out;
}

/* Section stagger */
.section {
    animation: cardSlideUp 0.35s ease-out both;
}

.section:nth-of-type(1) { animation-delay: 0.05s; }
.section:nth-of-type(2) { animation-delay: 0.1s; }
.section:nth-of-type(3) { animation-delay: 0.15s; }

/* Auth form entrance */
.auth-container {
    animation: authFadeIn 0.5s ease-out;
}

@keyframes authFadeIn {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Smooth alert dismiss on click */
.alert {
    cursor: pointer;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* ---- Danger Zone ---- */
.danger-zone {
    margin-top: 2rem;
    padding: 1.25rem;
    border: 1px solid rgba(231, 76, 60, 0.25);
    border-radius: var(--radius);
    background: rgba(231, 76, 60, 0.05);
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
    .page-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1; }
    .sets-table input[type="number"] { width: 50px; padding: 0.4rem 0.2rem; }
    .weight-input { width: 58px !important; }
    .macro-overview { grid-template-columns: repeat(3, 1fr); gap: 0.35rem; }
    .macro-value { font-size: 1.2rem; }
}
