/* ============================================================
   Linko — Premium Design System v2
   Inter font · Depth shadows · Micro-interactions · Dark mode
   ============================================================ */

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Brand */
    --primary:        #4F46E5;
    --primary-light:  #818CF8;
    --primary-dark:   #3730A3;
    --primary-glow:   rgba(79, 70, 229, 0.25);
    --success:        #10B981;
    --success-dark:   #059669;
    --warning:        #F59E0B;
    --danger:         #EF4444;
    --danger-dark:    #DC2626;
    --info:           #3B82F6;

    /* Surfaces — light mode */
    --bg:          #F1F5F9;
    --white:       #FFFFFF;
    --text:        #0F172A;
    --text-light:  #64748B;
    --text-muted:  #94A3B8;
    --border:      #E2E8F0;
    --border-focus: #4F46E5;

    /* Shadows — layered for depth */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
    --shadow:    0 1px 3px rgba(0,0,0,0.07), 0 4px 12px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 10px 20px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1), 0 4px 10px rgba(0,0,0,0.06);
    --shadow-xl: 0 20px 40px rgba(0,0,0,0.12), 0 8px 16px rgba(0,0,0,0.08);
    --shadow-glow: 0 0 0 3px var(--primary-glow);

    /* Radius */
    --radius-sm: 8px;
    --radius:    14px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    /* Semantic color surfaces */
    --surface-success:      #D1FAE5;
    --surface-success-text: #065F46;
    --surface-warning:      #FEF3C7;
    --surface-warning-text: #92400E;
    --surface-danger:       #FEE2E2;
    --surface-danger-text:  #991B1B;
    --surface-info:         #DBEAFE;
    --surface-info-text:    #1E40AF;
    --surface-neutral:      #F1F5F9;
    --surface-neutral-text: #475569;
    --surface-selected:     #EEF2FF;
    --surface-selected-text: var(--primary);

    /* Input */
    --input-bg: #FFFFFF;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition:      0.2s ease;
    --transition-slow: 0.35s ease;

    /* App shell */
    --app-header-height: 65px;
    --app-sidebar-width: 258px;
    --app-sidebar-collapsed-width: 76px;
}

/* ── Linko icons: custom SVG system, no device-dependent emoji UI ── */
.lk-icon,
.lk-sticker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    line-height: 1;
    vertical-align: -0.15em;
}

.lk-icon {
    width: 1.1em;
    height: 1.1em;
}

.lk-icon svg,
.lk-sticker svg {
    width: 100%;
    height: 100%;
    display: block;
}

.lk-icon svg {
    overflow: visible;
}

.lk-icon-lg {
    width: 2.4rem;
    height: 2.4rem;
}

.lk-icon-xl {
    width: 4rem;
    height: 4rem;
}

.lk-icon-soft {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 14px;
    color: var(--primary);
    background: linear-gradient(135deg, rgba(255, 138, 101, 0.13), rgba(99, 102, 241, 0.13));
}

.lk-icon-danger {
    color: var(--danger);
}

.lk-icon-warning {
    color: var(--warning);
}

.lk-icon-success {
    color: var(--success);
}

.lk-sticker {
    width: 52px;
    height: 52px;
}

/* ── Dark Theme ──────────────────────────────────────────────── */
[data-theme="dark"] {
    --bg:         #0A0F1E;
    --white:      #141C2E;
    --text:       #E2E8F0;
    --text-light: #94A3B8;
    --text-muted: #64748B;
    --border:     #1E2A40;
    --border-focus: #818CF8;
    --primary-light: #A5B4FC;
    --primary-glow: rgba(129, 140, 248, 0.2);

    --shadow-xs: 0 1px 2px rgba(0,0,0,0.3);
    --shadow:    0 1px 3px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.4), 0 10px 20px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.5), 0 4px 10px rgba(0,0,0,0.4);
    --shadow-xl: 0 20px 40px rgba(0,0,0,0.6), 0 8px 16px rgba(0,0,0,0.5);

    --surface-success:      rgba(16, 185, 129, 0.12);
    --surface-success-text: #6EE7B7;
    --surface-warning:      rgba(245, 158, 11, 0.12);
    --surface-warning-text: #FCD34D;
    --surface-danger:       rgba(239, 68, 68, 0.12);
    --surface-danger-text:  #FCA5A5;
    --surface-info:         rgba(59, 130, 246, 0.12);
    --surface-info-text:    #93C5FD;
    --surface-neutral:      rgba(100, 116, 139, 0.15);
    --surface-neutral-text: #CBD5E1;
    --surface-selected:     rgba(79, 70, 229, 0.18);
    --surface-selected-text: #A5B4FC;

    --input-bg: #111827;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv02','cv03','cv04','cv11';
}

/* ── Typography ────────────────────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.2; }
h2 { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.02em; }
h3 { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; }
p  { line-height: 1.65; }

/* ── Layout ────────────────────────────────────────────────── */
.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
}

.page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 14px;
    border: 1px solid var(--border);
    transition: box-shadow var(--transition), transform var(--transition);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    letter-spacing: -0.01em;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0);
    transition: background var(--transition-fast);
}

.btn:hover::after  { background: rgba(255,255,255,0.08); }
.btn:active        { transform: scale(0.97); }
.btn:active::after { background: rgba(0,0,0,0.08); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}
.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.45);
    transform: translateY(-1px);
}
.btn-primary:active { transform: scale(0.97) translateY(0); box-shadow: none; }

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, var(--success-dark) 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}
.btn-success:hover { box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4); transform: translateY(-1px); }

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, var(--danger-dark) 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}
.btn-danger:hover { box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4); transform: translateY(-1px); }

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text);
    box-shadow: var(--shadow-xs);
}
.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--surface-selected);
}

.btn-lg {
    padding: 18px 32px;
    font-size: 1.15rem;
    border-radius: var(--radius-lg);
}

.btn-disabled {
    opacity: 0.45;
    pointer-events: none;
}

.btn-group {
    display: flex;
    gap: 10px;
}
.btn-group .btn { flex: 1; }

/* ── Inputs ────────────────────────────────────────────────── */
.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 6px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.input {
    width: 100%;
    padding: 13px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    font-weight: 500;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
    outline: none;
    background: var(--input-bg);
    color: var(--text);
}

.input::placeholder { color: var(--text-muted); font-weight: 400; }

.input:focus {
    border-color: var(--border-focus);
    box-shadow: var(--shadow-glow);
    background: var(--white);
}

.input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--surface-neutral);
}

.country-phone {
    display: grid;
    grid-template-columns: minmax(132px, 0.42fr) minmax(0, 1fr);
    gap: 8px;
    align-items: stretch;
    width: 100%;
}

.country-phone-select {
    width: 100%;
    min-width: 0;
    border: 1.5px solid var(--auth-border, var(--border));
    border-radius: var(--radius, 14px);
    padding: 13px 10px;
    font: 700 0.86rem/1 'Inter', sans-serif;
    color: var(--auth-fg, var(--text));
    background: var(--input-bg, #fff);
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.country-phone-select:focus {
    border-color: var(--cool-2, var(--border-focus));
    box-shadow: var(--shadow-glow);
}

.country-phone-select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--surface-neutral);
}

.country-phone .input,
.country-phone .lk-input,
.country-phone .pi-input {
    min-width: 0;
}

.editable-field .country-phone {
    padding-right: 48px;
}

@media (max-width: 520px) {
    .country-phone {
        grid-template-columns: 1fr;
    }
    .editable-field .country-phone {
        padding-right: 0;
    }
    .editable-field .country-phone + .field-edit-toggle {
        top: 20px;
        transform: none;
    }
}

.editable-field {
    position: relative;
}

.editable-field .input {
    padding-right: 48px;
}

.field-edit-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-light);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.field-edit-toggle::before {
    content: "";
    width: 20px;
    height: 20px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.field-edit-toggle:hover,
.field-edit-toggle:focus-visible,
.field-edit-toggle.is-active {
    background: var(--surface-selected);
    color: var(--surface-selected-text);
    outline: none;
}

.field-edit-toggle.hidden {
    display: none;
}

.password-field {
    position: relative;
}

.password-field .input {
    padding-right: 48px;
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-light);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.password-toggle::before {
    content: "";
    width: 22px;
    height: 22px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E") center / contain no-repeat;
}

.password-toggle.is-visible::before {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.7 5.2A10.5 10.5 0 0 1 12 5c6.5 0 10 7 10 7a18.9 18.9 0 0 1-3.2 4.2'/%3E%3Cpath d='M14.1 14.1A3 3 0 0 1 9.9 9.9'/%3E%3Cpath d='M6.6 6.6C3.6 8.5 2 12 2 12s3.5 7 10 7a10.8 10.8 0 0 0 4.5-1'/%3E%3Cpath d='M3 3l18 18'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.7 5.2A10.5 10.5 0 0 1 12 5c6.5 0 10 7 10 7a18.9 18.9 0 0 1-3.2 4.2'/%3E%3Cpath d='M14.1 14.1A3 3 0 0 1 9.9 9.9'/%3E%3Cpath d='M6.6 6.6C3.6 8.5 2 12 2 12s3.5 7 10 7a10.8 10.8 0 0 0 4.5-1'/%3E%3Cpath d='M3 3l18 18'/%3E%3C/svg%3E");
}

.password-toggle:hover,
.password-toggle:focus-visible,
.password-toggle.is-visible {
    background: var(--surface-selected);
    color: var(--surface-selected-text);
    outline: none;
}

.input-lg {
    font-size: 1.75rem;
    text-align: center;
    letter-spacing: 12px;
    padding: 18px;
    font-weight: 700;
}

/* ── Status Badges ─────────────────────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 700;
    gap: 5px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.status-good     { background: var(--surface-success); color: var(--surface-success-text); }
.status-warning  { background: var(--surface-warning); color: var(--surface-warning-text); }
.status-critical { background: var(--surface-danger);  color: var(--surface-danger-text); }
.status-pending  { background: var(--surface-neutral); color: var(--surface-neutral-text); }
.status-vacation { background: var(--surface-info);    color: var(--surface-info-text); }

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.dot-good     { background: var(--success); box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3); }
.dot-warning  { background: var(--warning); box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3); }
.dot-critical { background: var(--danger);  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.3); }
.dot-pending  { background: var(--text-muted); }

/* ── Elderly-Specific Styles ───────────────────────────────── */
.elderly-page {
    background: var(--bg);
}

.elderly-greeting {
    text-align: center;
    padding: 28px 16px 16px;
}

.elderly-greeting h1 {
    font-size: 1.85rem;
    margin-bottom: 6px;
    background: linear-gradient(135deg, var(--text) 0%, var(--text-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.elderly-greeting p {
    color: var(--text-light);
    font-size: 1.05rem;
}

.elderly-question {
    text-align: center;
    padding: 24px 20px;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: -0.02em;
}

.mood-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    padding: 0 16px;
}

.mood-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    border-radius: var(--radius-lg);
    border: 2px solid var(--border);
    background: var(--white);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    box-shadow: var(--shadow-xs);
}

.mood-btn:active  { transform: scale(0.95); }
.mood-btn:hover   {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.mood-btn .emoji {
    font-size: 2.5rem;
    margin-bottom: 10px;
    transition: transform var(--transition);
}

.sos-wordmark {
    font-weight: 900;
    letter-spacing: 0.04em;
    line-height: 1;
    font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
}

.mood-btn .sos-wordmark {
    color: var(--danger);
    font-size: 2rem;
}

.mood-btn:hover .emoji { transform: scale(1.15); }

.mood-btn.selected {
    border-color: var(--primary);
    background: var(--surface-selected);
    color: var(--surface-selected-text);
    box-shadow: var(--shadow-glow);
}

.mood-btn.danger-option { border-color: rgba(239, 68, 68, 0.3); }
.mood-btn.danger-option:hover {
    border-color: var(--danger);
    background: var(--surface-danger);
    color: var(--surface-danger-text);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* Yes/No big buttons */
.yn-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    padding: 0 16px;
}

.yn-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    border-radius: var(--radius-lg);
    border: 2px solid var(--border);
    background: var(--white);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 1.25rem;
    font-weight: 700;
    font-family: inherit;
    box-shadow: var(--shadow-xs);
}

.yn-btn .icon {
    font-size: 3rem;
    margin-bottom: 8px;
    transition: transform var(--transition);
}

.yn-btn:hover .icon { transform: scale(1.15); }
.yn-btn:active { transform: scale(0.95); }

.yn-btn:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.yn-btn.selected-yes {
    border-color: var(--success);
    background: var(--surface-success);
    color: var(--surface-success-text);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.yn-btn.selected-no {
    border-color: var(--danger);
    background: var(--surface-danger);
    color: var(--surface-danger-text);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

/* ── SOS Button ────────────────────────────────────────────── */
.sos-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 70vh;
    padding: 32px;
}

.sos-button {
    width: 210px;
    height: 210px;
    border-radius: 50%;
    background: linear-gradient(135deg, #F87171 0%, var(--danger) 40%, var(--danger-dark) 100%);
    color: white;
    border: none;
    font-size: 1.5rem;
    font-weight: 800;
    font-family: inherit;
    cursor: pointer;
    box-shadow:
        0 0 0 0 rgba(239, 68, 68, 0.4),
        0 12px 40px rgba(239, 68, 68, 0.4),
        inset 0 2px 8px rgba(255,255,255,0.2);
    animation: sos-pulse 2.2s ease-in-out infinite;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition), box-shadow var(--transition);
    letter-spacing: 0.05em;
}

.sos-button:active {
    transform: scale(0.93);
    animation: none;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.5);
}

.sos-button .icon { font-size: 3rem; margin-bottom: 4px; }
.sos-button .sos-wordmark { font-size: 3.2rem; margin-bottom: 8px; }

@keyframes sos-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(239,68,68,0.5), 0 12px 40px rgba(239,68,68,0.4), inset 0 2px 8px rgba(255,255,255,0.2); }
    50%  { box-shadow: 0 0 0 24px rgba(239,68,68,0), 0 16px 50px rgba(239,68,68,0.5), inset 0 2px 8px rgba(255,255,255,0.2); }
    100% { box-shadow: 0 0 0 0 rgba(239,68,68,0),   0 12px 40px rgba(239,68,68,0.4), inset 0 2px 8px rgba(255,255,255,0.2); }
}

/* ── Bottom Navigation (Elderly) ───────────────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 8px 0 max(8px, env(safe-area-inset-bottom));
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 16px;
    border-radius: var(--radius-sm);
    transition: color var(--transition), background var(--transition);
    letter-spacing: 0.01em;
}

.nav-item:hover { color: var(--primary); background: var(--surface-selected); }

.nav-item .icon {
    font-size: 1.45rem;
    margin-bottom: 2px;
    transition: transform var(--transition);
}

.nav-item:hover .icon  { transform: translateY(-2px); }
.nav-item.active       { color: var(--primary); }
.nav-item.active .icon { transform: translateY(-1px); }
.nav-item.sos-nav      { color: var(--danger); }

/* ── Dashboard Header ──────────────────────────────────────── */
.dashboard-header {
    background: linear-gradient(145deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 28px 16px 24px;
    border-radius: 0 0 28px 28px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(79, 70, 229, 0.35);
}

.dashboard-header::before {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: rgba(255,255,255,0.07);
    pointer-events: none;
}

.dashboard-header::after {
    content: '';
    position: absolute;
    bottom: -60px;
    left: -20px;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
    pointer-events: none;
}

.dashboard-header h1 { color: white; position: relative; z-index: 1; }
.dashboard-header p  { color: rgba(255,255,255,0.75); position: relative; z-index: 1; }

.alert-count {
    background: var(--danger);
    color: white;
    padding: 2px 9px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
    animation: badge-pop 0.3s ease;
}

@keyframes badge-pop {
    0%   { transform: scale(0.5); opacity: 0; }
    75%  { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

/* ── Parent Cards ───────────────────────────────────────────── */
.parent-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    cursor: pointer;
    transition: box-shadow var(--transition), transform var(--transition);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.parent-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    border: 2px solid transparent;
    transition: border-color var(--transition);
    pointer-events: none;
}

.parent-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.parent-card:hover::before { border-color: var(--primary-glow); }

.parent-card:active {
    transform: scale(0.98);
    box-shadow: var(--shadow);
}

.parent-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.parent-name {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.parent-checkin-info {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
    color: var(--text-light);
}

.checkin-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.parent-last-seen {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 8px;
    font-weight: 500;
}

/* ── Alert Cards ───────────────────────────────────────────── */
.alert-card {
    background: var(--white);
    border-left: 4px solid var(--warning);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 14px 16px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    transition: box-shadow var(--transition), transform var(--transition);
    border-top: 1px solid var(--border);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.alert-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateX(2px);
}

.alert-card.emergency {
    border-left-color: var(--danger);
    background: var(--surface-danger);
}

.alert-card.critical { border-left-color: var(--danger); }

.alert-card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.alert-type {
    font-weight: 700;
    font-size: 0.88rem;
    letter-spacing: -0.01em;
}

.alert-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.alert-message {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 10px;
    line-height: 1.5;
}

/* ── Week Grid ─────────────────────────────────────────────── */
.week-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 5px;
    margin: 12px 0;
}

.week-day {
    text-align: center;
    padding: 8px 0;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    transition: transform var(--transition);
}

.week-day:hover { transform: scale(1.05); }

.week-day .label { display: block; color: var(--text-muted); margin-bottom: 4px; font-weight: 600; }
.week-day.done   { background: var(--surface-success); color: var(--surface-success-text); }
.week-day.missed { background: var(--surface-danger);  color: var(--surface-danger-text); }
.week-day.today  { border: 2px solid var(--primary); box-shadow: var(--shadow-glow); }
.week-day.future { background: var(--surface-neutral); color: var(--surface-neutral-text); }

/* ── Success Screen ────────────────────────────────────────── */
.success-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    padding: 32px;
    animation: fade-up 0.4s ease;
}

.success-icon {
    font-size: 5rem;
    margin-bottom: 16px;
    animation: bounce-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
}

.success-screen h2 { margin-bottom: 8px; }
.success-screen p  { color: var(--text-light); margin-bottom: 24px; }

/* ── Auth Styles ───────────────────────────────────────────── */
.auth-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 32px 16px;
    background: linear-gradient(160deg, var(--bg) 0%, #EEF2FF 50%, var(--bg) 100%);
    animation: fade-in 0.4s ease;
}

[data-theme="dark"] .auth-page {
    background: linear-gradient(160deg, var(--bg) 0%, #0D1329 50%, var(--bg) 100%);
}

.auth-logo {
    font-size: 3.2rem;
    margin-bottom: 8px;
    animation: bounce-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.auth-title {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 4px;
    letter-spacing: -0.03em;
}

.auth-subtitle {
    color: var(--text-light);
    margin-bottom: 32px;
    text-align: center;
    font-size: 0.95rem;
}

.auth-form {
    width: 100%;
    max-width: 400px;
}

.auth-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-light);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
}

.auth-footer a:hover { text-decoration: underline; }

/* ── Role Selection ────────────────────────────────────────── */
.role-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 24px 0;
}

.role-card {
    display: flex;
    align-items: center;
    padding: 20px;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition);
    gap: 16px;
    background: var(--white);
    box-shadow: var(--shadow-xs);
}

.role-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.role-card.selected {
    border-color: var(--primary);
    background: var(--surface-selected);
    color: var(--surface-selected-text);
    box-shadow: var(--shadow-glow);
}

.role-icon {
    font-size: 2rem;
    transition: transform var(--transition);
}

.role-card:hover .role-icon  { transform: scale(1.15); }
.role-info h3 { margin-bottom: 2px; }
.role-info p  { font-size: 0.85rem; color: var(--text-light); }

/* ── Toast / Notifications ─────────────────────────────────── */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 13px 24px 13px 18px;
    border-radius: var(--radius);
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    max-width: 90%;
    text-align: center;
    box-shadow: var(--shadow-xl);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    pointer-events: none;
    border: 1px solid rgba(255,255,255,0.15);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success { background: linear-gradient(135deg, var(--success), var(--success-dark)); }
.toast.error   { background: linear-gradient(135deg, var(--danger), var(--danger-dark)); }
.toast.warning { background: linear-gradient(135deg, #D97706, var(--warning)); color: white; }

/* ── Loading Spinner ───────────────────────────────────────── */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 24px auto;
}

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

.loading-text {
    text-align: center;
    color: var(--text-light);
    margin-top: 8px;
    font-size: 0.875rem;
}

.linko-loading-card {
    width: min(100%, 420px);
    margin: 20px auto;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

.linko-loading-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.12), rgba(16, 185, 129, 0.12));
    flex-shrink: 0;
    animation: linkoLoadPulse 1.4s ease-in-out infinite;
}

.linko-loading-mark img {
    width: 26px;
    height: 26px;
    display: block;
}

.linko-loading-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.linko-loading-copy strong {
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1.25;
}

.linko-loading-copy span {
    color: var(--text-light);
    font-size: 0.82rem;
    line-height: 1.35;
}

.linko-loading-dots {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.linko-loading-dots i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--primary);
    opacity: 0.35;
    animation: linkoLoadDot 1.1s ease-in-out infinite;
}

.linko-loading-dots i:nth-child(2) { animation-delay: 0.16s; }
.linko-loading-dots i:nth-child(3) { animation-delay: 0.32s; }

.connect-mode-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 12px 0 14px;
}

.connect-mode-card {
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    padding: 12px;
    text-align: left;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.connect-mode-card strong {
    display: block;
    color: var(--text);
    font-size: 0.92rem;
    margin-bottom: 3px;
}

.connect-mode-card span {
    display: block;
    color: var(--text-light);
    font-size: 0.78rem;
    line-height: 1.35;
}

.connect-mode-card.active {
    border-color: var(--primary);
    background: var(--surface-selected);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}

@media (max-width: 560px) {
    .connect-mode-grid { grid-template-columns: 1fr; }
}

@keyframes linkoLoadPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

@keyframes linkoLoadDot {
    0%, 100% { opacity: 0.3; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-2px); }
}

/* ── Select Input Fix ─────────────────────────────────────── */
/* Force-kill the browser's native chevron and replace with a single,
   explicitly-sized SVG. Tiling happens when background-size is absent
   on some browsers, so set it explicitly and never let it repeat. */
select.input,
select {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236B7280' d='M6 8L0 0h12z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 14px center !important;
    background-size: 12px 8px !important;
    padding-right: 36px;
    cursor: pointer;
}
select.input { background-color: var(--input-bg); }

[data-theme="dark"] select.input,
[data-theme="dark"] select {
    background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394A3B8' d='M6 8L0 0h12z'/%3E%3C/svg%3E") !important;
}

/* IE/old-Edge: hide the native arrow */
select::-ms-expand { display: none; }

/* Regular text/number inputs should NEVER inherit a select-style chevron */
input.input, textarea.input {
    background-image: none !important;
}

.input-with-unit {
    position: relative;
}

.input-with-unit .input {
    padding-right: 76px;
}

.input-unit {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 0.82rem;
    font-weight: 700;
    pointer-events: none;
}

.value-preview {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 7px;
    color: var(--primary);
    background: var(--surface-selected);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: 750;
}

/* ── Textarea ─────────────────────────────────────────────── */
textarea.input {
    resize: vertical;
    min-height: 80px;
    line-height: 1.6;
}

/* ── Utility ───────────────────────────────────────────────── */
.hidden  { display: none !important; }
.mt-8    { margin-top: 8px; }
.mt-16   { margin-top: 16px; }
.mt-24   { margin-top: 24px; }
.mb-8    { margin-bottom: 8px; }
.mb-16   { margin-bottom: 16px; }

/* ── Replaced-session full-screen state ─────────────────────── */
.session-replaced-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    min-height: 100vh;
    padding: 24px;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at 50% 0%, rgba(129,140,248,0.18), transparent 34%),
        rgba(248,250,252,0.96);
    color: var(--text);
}
[data-theme="dark"] .session-replaced-screen {
    background:
        radial-gradient(circle at 50% 0%, rgba(99,102,241,0.22), transparent 38%),
        rgba(10,15,30,0.97);
}
.session-replaced-card {
    width: min(100%, 460px);
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-xl);
    padding: 28px;
    text-align: center;
}
.session-replaced-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.1rem;
    margin-bottom: 18px;
}
.session-replaced-icon {
    width: 68px;
    height: 68px;
    margin: 0 auto 16px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--surface-selected);
    color: var(--surface-selected-text);
    font-size: 2rem;
}
.session-replaced-card h1 {
    font-size: clamp(1.45rem, 4vw, 2rem);
    line-height: 1.15;
    letter-spacing: 0;
    margin-bottom: 10px;
}
.session-replaced-card p {
    color: var(--text-light);
    line-height: 1.5;
}
.session-replaced-account {
    margin: 18px 0;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--surface-neutral);
    color: var(--text);
    font-weight: 700;
    overflow-wrap: anywhere;
}
.session-replaced-actions {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}
.session-replaced-note {
    margin-top: 14px;
    font-size: 0.85rem;
}
.mb-24   { margin-bottom: 24px; }
.text-center  { text-align: center; }
.text-light   { color: var(--text-light); }
.text-danger  { color: var(--danger); }
.text-sm      { font-size: 0.875rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8        { gap: 8px; }
.pb-80        { padding-bottom: 80px; }

/* ── State Cards (Elderly Home) ────────────────────────────── */
.state-card-success {
    background: linear-gradient(135deg, #D1FAE5 0%, #A7F3D0 100%);
    border-color: rgba(16, 185, 129, 0.2) !important;
}
.state-card-warning {
    background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
    border-color: rgba(245, 158, 11, 0.2) !important;
}
.state-card-danger {
    background: linear-gradient(135deg, #FEE2E2 0%, #FECACA 100%);
    border-color: rgba(239, 68, 68, 0.2) !important;
}
.state-card-info {
    background: linear-gradient(135deg, #DBEAFE 0%, #BFDBFE 100%);
    border-color: rgba(59, 130, 246, 0.2) !important;
}

.state-card-success .state-card-text { color: #065F46; font-weight: 600; }
.state-card-warning .state-card-text { color: #78350F; font-weight: 600; }
.state-card-danger  .state-card-text { color: #991B1B; font-weight: 600; }
.state-card-info    .state-card-text { color: #1E3A8A; font-weight: 600; }

[data-theme="dark"] .state-card-success,
[data-theme="dark"] .state-card-warning,
[data-theme="dark"] .state-card-danger,
[data-theme="dark"] .state-card-info {
    background: var(--white) !important;
    border: 1px solid var(--border) !important;
}

[data-theme="dark"] .state-card-success .state-card-text,
[data-theme="dark"] .state-card-warning .state-card-text,
[data-theme="dark"] .state-card-danger  .state-card-text,
[data-theme="dark"] .state-card-info    .state-card-text {
    color: var(--text) !important;
}

/* ── Theme Toggle Control ──────────────────────────────────── */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.theme-toggle-track {
    position: relative;
    width: 46px;
    height: 26px;
    background: var(--border);
    border-radius: 100px;
    transition: background var(--transition);
    flex-shrink: 0;
}

.theme-toggle-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
    transition: transform var(--transition);
}

.theme-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-toggle input[type="checkbox"]:checked + .theme-toggle-track {
    background: var(--primary);
}

.theme-toggle input[type="checkbox"]:checked + .theme-toggle-track::after {
    transform: translateX(20px);
}

.theme-toggle-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

/* ── Dark mode misc fixes ─────────────────────────────────── */
[data-theme="dark"] .btn-outline {
    border-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] .bottom-nav {
    background: rgba(20, 28, 46, 0.95);
    border-top-color: var(--border);
}

/* ── New status classes ──────────────────────────────────── */
.status-missed          { background: var(--surface-danger);  color: var(--surface-danger-text); }
.status-before_schedule { background: var(--surface-neutral); color: var(--surface-neutral-text); }
.dot-missed             { background: var(--danger); }
.dot-before_schedule    { background: var(--text-muted); }

/* ── Alert Strip on Parent Card ─────────────────────────────── */
.card-alert-strip {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    background: var(--surface-danger);
    color: var(--surface-danger-text);
    transition: opacity var(--transition), transform var(--transition);
    user-select: none;
    letter-spacing: 0.01em;
    /* Don't let long alert messages stretch the parent card past the
       viewport — clip with an ellipsis instead. */
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-alert-strip:hover { opacity: 0.82; transform: translateX(2px); }

.card-alert-strip.warn {
    background: var(--surface-warning);
    color: var(--surface-warning-text);
}

/* ── 30-day Activity Heatmap ─────────────────────────────────── */
.heatmap-wrapper {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.heatmap-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 7px;
}

.heatmap-title {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.heatmap-link {
    font-size: 0.72rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: opacity var(--transition);
}

.heatmap-link:hover { opacity: 0.75; text-decoration: underline; }

.heatmap-dots {
    display: grid;
    grid-template-columns: repeat(15, minmax(0, 1fr));
    gap: 3px;
}

.hd {
    aspect-ratio: 1;
    border-radius: 3px;
    cursor: pointer;
    transition: transform 0.1s ease;
    position: relative;
}

.hd:hover { transform: scale(1.7); z-index: 5; }

.hd-good     { background: var(--success); opacity: 0.85; }
.hd-warning  { background: var(--warning); opacity: 0.9; }
.hd-critical { background: var(--danger); }
.hd-missed   { background: var(--surface-danger); opacity: 0.8; }
.hd-empty    { background: var(--border); cursor: default; pointer-events: none; }

.hd.hd-today {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.heatmap-skeleton .hd {
    animation: hmap-pulse 1.4s ease-in-out infinite;
    background: var(--border);
    pointer-events: none;
    cursor: default;
}

@keyframes hmap-pulse {
    0%, 100% { opacity: 0.3; }
    50%       { opacity: 0.7; }
}

.hd-tooltip {
    position: fixed;
    background: var(--text);
    color: var(--bg);
    border-radius: var(--radius-sm);
    padding: 7px 12px;
    font-size: 0.77rem;
    font-weight: 600;
    pointer-events: none;
    z-index: 9999;
    box-shadow: var(--shadow-xl);
    line-height: 1.55;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.12s;
}

.hd-tooltip.visible { opacity: 1; }

/* ── Day Summary Page ────────────────────────────────────────── */
.day-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--primary);
    font-weight: 700;
    font-size: 0.875rem;
    margin-bottom: 16px;
    transition: gap var(--transition);
}

.day-back:hover { gap: 10px; }

.day-summary-meta {
    text-align: center;
    padding-bottom: 4px;
}

.day-summary-date-label {
    font-size: 0.8rem;
    color: var(--text-light);
    font-weight: 600;
    margin-top: 3px;
    letter-spacing: 0.02em;
}

.day-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0 20px;
}

.day-nav-btn {
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    cursor: pointer;
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    transition: all var(--transition);
    flex-shrink: 0;
}

.day-nav-btn:hover {
    background: var(--surface-selected);
    color: var(--surface-selected-text);
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.day-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.day-nav-label {
    flex: 1;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.mood-display {
    text-align: center;
    padding: 14px 0 12px;
}

.mood-emoji-lg {
    font-size: 2.8rem;
    line-height: 1;
    display: block;
    margin-bottom: 8px;
    animation: bounce-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.mood-label-pill {
    display: inline-block;
    padding: 5px 18px;
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.mood-label-pill.good      { background: var(--surface-success); color: var(--surface-success-text); }
.mood-label-pill.okay      { background: var(--surface-neutral); color: var(--surface-neutral-text); }
.mood-label-pill.bad       { background: var(--surface-warning); color: var(--surface-warning-text); }
.mood-label-pill.need_help { background: var(--surface-danger);  color: var(--surface-danger-text); }

.answer-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

.answer-row:last-child { border-bottom: none; }

.answer-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
    background: var(--surface-neutral);
}

.answer-text { flex: 1; min-width: 0; }
.answer-q    { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 2px; font-weight: 600; letter-spacing: 0.01em; text-transform: uppercase; }
.answer-v    { font-size: 0.92rem; font-weight: 700; }

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
}

.metric-row:last-child { border-bottom: none; }

.metric-lbl { font-size: 0.85rem; color: var(--text-light); font-weight: 500; }
.metric-val { font-size: 0.95rem; font-weight: 800; color: var(--text); letter-spacing: -0.01em; }

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

.wt-stat {
    text-align: center;
    padding: 12px 6px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.wt-val   { font-size: 1.3rem; font-weight: 800; color: var(--primary); letter-spacing: -0.02em; }
.wt-label { font-size: 0.68rem; color: var(--text-muted); font-weight: 600; margin-top: 3px; text-transform: uppercase; letter-spacing: 0.04em; }

.day-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-light);
}

.day-empty-icon { font-size: 2.5rem; margin-bottom: 12px; }

/* ── Keyframe Animations ─────────────────────────────────────── */
@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes fade-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes bounce-in {
    from { opacity: 0; transform: scale(0.6); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes slide-in-right {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Page entry animation for cards */
.card { animation: fade-up 0.3s ease both; }

/* Stagger children */
.container > .card:nth-child(1) { animation-delay: 0.04s; }
.container > .card:nth-child(2) { animation-delay: 0.08s; }
.container > .card:nth-child(3) { animation-delay: 0.12s; }
.container > .card:nth-child(4) { animation-delay: 0.16s; }
.container > .card:nth-child(5) { animation-delay: 0.20s; }

/* Reduce animations for accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================
   Linko — Shared Header, Profile Dropdown, Hamburger Drawer
   ============================================================ */

.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 80;
    background: rgba(255,255,255,0.96);
    color: var(--text);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(15,23,42,0.04);
    backdrop-filter: blur(18px);
    /* Respect the iOS status bar / Dynamic Island. Without this padding the
       sticky header extends UP behind the OS clock, the brand text collides
       with "11:04 ▾▮", and — worse — the avatar in the top-right is partly
       inside the status-bar tap region (which iOS reserves for scroll-to-
       top gestures), making it un-tappable. viewport-fit=cover is set in
       base.html so env() resolves correctly. */
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}
[data-theme="dark"] .app-header {
    background: rgba(10,15,30,0.94);
    border-bottom: 1px solid var(--border);
}

.app-header-inner {
    height: var(--app-header-height);
    max-width: none;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
    font-weight: 800;
    font-size: 1.18rem;
    letter-spacing: -0.02em;
}
.brand-logo { border-radius: 8px; display: block; width: 28px; height: 28px; }
.brand-name { color: inherit; }

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Alerts pill — replaces old 🔔 emoji */
.alerts-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--surface-neutral);
    color: var(--text);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1;
    position: relative;
    transition: background var(--transition-fast);
}
.alerts-pill:hover { background: var(--surface-selected); color: var(--surface-selected-text); }
.alerts-label { letter-spacing: 0.01em; }
.alerts-count {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.icon-btn {
    background: transparent;
    border: 0;
    color: inherit;
    font-size: 1rem;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    line-height: 1;
}
.icon-btn:hover { background: var(--surface-neutral); }

/* Avatar button */
.avatar-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    padding: 0;
    cursor: pointer;
    overflow: hidden;
    color: #fff;
}
.avatar-inner {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
}
.avatar-inner img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Hamburger */
.hamburger-btn {
    background: transparent;
    border: 0;
    color: inherit;
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
    line-height: 0;
    display: inline-flex;
}
.hamburger-btn:hover { background: var(--surface-neutral); }

/* Profile dropdown */
.header-menu { position: relative; }
.dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 240px;
    background: var(--white);
    color: var(--text);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity var(--transition-fast), transform var(--transition-fast), visibility 0s linear 0.15s;
    z-index: 90;
}
.dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity var(--transition-fast), transform var(--transition-fast), visibility 0s;
}
.dropdown-user { padding: 10px 12px 4px; }
.dropdown-user-name { font-weight: 700; font-size: 0.95rem; }
.dropdown-user-sub  { font-size: 0.8rem; color: var(--text-light); margin-top: 2px; }
.dropdown-sep {
    height: 1px;
    background: var(--border);
    margin: 6px 4px;
}
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 0;
    background: transparent;
    color: inherit;
    text-decoration: none;
    font-size: 0.93rem;
    cursor: pointer;
    text-align: left;
    position: relative;
    font-family: inherit;
}
.dropdown-item:hover,
.dropdown-item:focus-visible { background: var(--surface-neutral); outline: none; }
.dropdown-item.danger { color: var(--danger); }
.di-icon  { width: 20px; text-align: center; flex-shrink: 0; }
.di-label { flex: 1; }
.di-chevron {
    margin-left: auto;
    color: var(--text-light);
    font-size: 0.8rem;
}
.di-check {
    margin-left: auto;
    color: var(--primary);
    font-weight: 700;
    visibility: hidden;
}
/* Theme submenu */
.has-submenu { position: relative; }
.submenu {
    position: absolute;
    top: 0;
    right: calc(100% + 4px);
    min-width: 180px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(4px);
    transition: opacity var(--transition-fast), transform var(--transition-fast), visibility 0s linear 0.15s;
}
.submenu.open {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    transition: opacity var(--transition-fast), transform var(--transition-fast), visibility 0s;
}
@media (max-width: 640px) {
    .submenu {
        position: static;
        box-shadow: none;
        border: 0;
        padding: 4px 0 4px 28px;
        background: transparent;
        display: none;
    }
    .submenu.open { display: block; }
}

/* Hamburger drawer */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.55);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), visibility 0s linear 0.2s;
    z-index: 95;
}
.drawer-overlay.show {
    opacity: 1;
    visibility: visible;
    transition: opacity var(--transition);
}
.drawer {
    position: fixed;
    top: calc(var(--app-header-height) + env(safe-area-inset-top));
    right: 0;
    width: min(320px, 88vw);
    height: calc(100vh - var(--app-header-height) - env(safe-area-inset-top));
    background: var(--white);
    color: var(--text);
    box-shadow: -8px 0 24px rgba(0,0,0,0.15);
    transform: translateX(100%);
    transition: transform 0.25s ease;
    z-index: 100;
    display: flex;
    flex-direction: column;
    padding: 12px;
    overflow-y: auto;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 6px 12px;
}
.drawer-head .brand { color: var(--text); font-size: 1.1rem; }
.drawer-sep {
    height: 1px;
    background: var(--border);
    margin: 10px 4px;
}
.drawer-nav { display: flex; flex-direction: column; gap: 2px; }
.drawer-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.98rem;
    border: 0;
    background: transparent;
    width: 100%;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}
.drawer-link:hover,
.drawer-link.active {
    background: var(--surface-selected);
    color: var(--surface-selected-text);
}
.drawer-link .di-icon { width: 24px; font-size: 1.05rem; }
.drawer-chip {
    margin-left: auto;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface-success);
    color: var(--surface-success-text);
}

/* Modal shell (reused) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), visibility 0s linear 0.2s;
    z-index: 110;
}
.modal-overlay.open {
    opacity: 1;
    visibility: visible;
    transition: opacity var(--transition);
}
.modal {
    background: var(--white);
    color: var(--text);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 440px;
    /* Universal sizing — never taller than the viewport. Header sticks,
       body scrolls. Works for the create-event form (long) and short
       confirmation modals alike. */
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.modal-head h3 { margin: 0; }
.modal-body {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}
.modal-foot {
    display: flex;
    gap: 8px;
    padding: 12px 20px 16px;
    justify-content: flex-end;
}
.modal-foot .btn { width: auto; }

.care-ready-modal {
    max-width: 460px;
}
.care-ready-modal .modal-body {
    align-items: center;
    text-align: center;
    padding-top: 26px;
}
.care-ready-mark {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: var(--surface-selected);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
}
.care-ready-mark img {
    width: 36px;
    height: 36px;
}
.care-ready-modal h2 {
    margin: 8px 0 0;
    font-size: 1.45rem;
}
.care-ready-modal p {
    color: var(--text-light);
    margin: 0;
    line-height: 1.5;
}
.care-ready-summary {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 6px;
}
.care-ready-summary div {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--input-bg);
    padding: 12px;
    text-align: left;
}
.care-ready-summary span {
    display: block;
    color: var(--text-light);
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 4px;
}
.care-ready-summary strong {
    display: block;
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1.25;
}

/* ── Health Log Experience ─────────────────────────────────── */
.health-log-page {
    background:
        radial-gradient(circle at 82% 8%, rgba(79, 70, 229, 0.08), transparent 28%),
        linear-gradient(180deg, var(--bg) 0%, #F8FAFC 100%);
    min-height: calc(100vh - var(--app-header-height));
}

.health-shell {
    width: min(1120px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 28px 0 52px;
}

.health-topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 22px;
    align-items: start;
    margin-bottom: 18px;
}

.health-back {
    color: var(--primary);
    font-weight: 800;
    text-decoration: none;
    padding-top: 8px;
    white-space: nowrap;
}

.health-kicker {
    color: var(--text-light);
    font-size: 0.78rem;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
}

.health-topbar h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3.5rem);
    line-height: 1.02;
}

.health-topbar p {
    max-width: 660px;
    margin: 10px 0 0;
    color: var(--text-light);
    line-height: 1.55;
}

.health-hero {
    display: grid;
    grid-template-columns: minmax(240px, 0.9fr) minmax(0, 1.4fr);
    gap: 18px;
    align-items: center;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--white);
    box-shadow: var(--shadow-md);
    margin-bottom: 18px;
}

.health-pill {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--surface-selected);
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.health-hero h2 {
    margin: 0 0 4px;
    font-size: 1.2rem;
}

.health-hero p {
    margin: 0;
    color: var(--text-light);
}

.health-layout {
    display: grid;
    grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.health-entry-card {
    position: sticky;
    top: calc(var(--app-header-height) + 18px);
}

.health-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.health-section-head h3 {
    margin: 0 0 3px;
}

.health-section-head p {
    margin: 0;
    color: var(--text-light);
    font-size: 0.9rem;
}

.health-template-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}

.health-template-grid button {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--input-bg);
    color: var(--text);
    text-align: left;
    padding: 11px 12px;
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.health-template-grid button.active {
    border-color: var(--primary);
    background: var(--surface-selected);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.10);
}

.health-template-grid strong,
.health-template-grid span {
    display: block;
}

.health-template-grid span {
    color: var(--text-light);
    font-size: 0.78rem;
    margin-top: 2px;
}

.health-input-grid {
    display: grid;
    gap: 12px;
}

.health-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.health-field.hidden {
    display: none;
}

.health-field > span {
    color: var(--text-light);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.health-field small {
    color: var(--text-muted);
    font-weight: 800;
}

.bp-pair {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 8px;
    align-items: center;
}

.bp-pair b {
    color: var(--text-light);
    font-size: 1.15rem;
}

.health-save-btn {
    margin-top: 14px;
}

.health-metric-grid,
.health-reading-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.health-reading-metrics {
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
    margin-top: 12px;
}

.health-metric {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--input-bg);
    padding: 12px;
    min-height: 70px;
}

.health-metric span {
    display: block;
    color: var(--text-light);
    font-size: 0.75rem;
    font-weight: 800;
    margin-bottom: 6px;
}

.health-metric strong {
    display: block;
    color: var(--text);
    font-size: 1rem;
    line-height: 1.2;
}

.health-metric.muted {
    grid-column: 1 / -1;
    color: var(--text-light);
    display: flex;
    align-items: center;
}

.health-history-section {
    min-width: 0;
}

.health-reading-card,
.health-empty {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 16px;
    margin-bottom: 12px;
}

.health-reading-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.health-reading-head strong,
.health-reading-head span {
    display: block;
}

.health-reading-head span {
    color: var(--text-light);
    font-size: 0.82rem;
    margin-top: 2px;
}

.health-delete-btn {
    color: var(--danger);
    border-color: var(--border);
}

.health-note {
    margin: 12px 0 0;
    color: var(--text-light);
    line-height: 1.45;
}

.health-empty {
    color: var(--text-light);
    text-align: center;
    padding: 28px 18px;
}

body.elderly-page .health-topbar h1 {
    font-size: clamp(2.2rem, 7vw, 4rem);
}

body.elderly-page .health-template-grid button,
body.elderly-page .health-field .input,
body.elderly-page .health-save-btn {
    min-height: 54px;
}

@media (max-width: 768px) {
    .care-ready-summary {
        grid-template-columns: 1fr;
    }
    .health-shell {
        width: min(100% - 20px, 640px);
        padding-top: 18px;
    }
    .health-topbar,
    .health-hero,
    .health-layout {
        grid-template-columns: 1fr;
    }
    .health-entry-card {
        position: static;
    }
    .health-metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .health-template-grid {
        grid-template-columns: 1fr;
    }
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 0.82rem; color: var(--text-light); font-weight: 600; }

.label-with-info,
.setting-label-with-info,
.setting-title-with-info {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.input-group label.label-with-info,
.field .label-with-info {
    display: inline-flex;
}

.setting-label-with-info {
    flex-wrap: wrap;
}

.info-trigger {
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 999px;
    background: var(--surface-neutral);
    color: var(--text-light);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    cursor: pointer;
    padding: 0;
    vertical-align: middle;
    transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.info-trigger .lk-icon,
.info-trigger [data-lk-icon] {
    width: 14px;
    height: 14px;
}

.info-trigger:hover,
.info-trigger:focus-visible,
.info-trigger[aria-expanded="true"] {
    background: var(--surface-selected);
    color: var(--surface-selected-text);
    box-shadow: 0 0 0 3px var(--primary-glow);
    outline: none;
}

.info-popover {
    position: fixed;
    z-index: 5000;
    width: max-content;
    max-width: 320px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--white);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xl);
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.info-popover.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.info-popover strong {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.info-popover p {
    margin: 0;
    color: var(--text-light);
    font-size: 0.84rem;
    line-height: 1.45;
}

.info-popover small {
    display: block;
    margin-top: 8px;
    color: var(--surface-selected-text);
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.35;
}

.alert-info {
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--surface-info);
    color: var(--surface-info-text);
    font-size: 0.85rem;
}

/* Push content down for sticky header */
body.has-app-header {
    padding-top: calc(var(--app-header-height) + env(safe-area-inset-top));
}
body.has-app-header .page { padding-top: 0; }

/* ============================================================
   Linko — Dashboard hero + active alerts panel + elderly hero
   ============================================================ */

.dash-hero {
    margin-top: 18px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}
@media (min-width: 740px) {
    .dash-hero { grid-template-columns: 1fr 1fr; align-items: end; }
}
.dash-hero h1 { font-size: 1.45rem; letter-spacing: -0.02em; }
.dash-hero-text .text-light { letter-spacing: 0.02em; }

.dash-stats {
    display: grid;
    /* minmax(0, 1fr) so the 3 stat tiles always share the viewport width
       even when their content (e.g. "WEEKLY RESPONSE" label) has a wider
       intrinsic min-content. With plain `1fr 1fr 1fr` the grid's minimum
       width is sum-of-min-contents → overflows narrow phones. */
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.dash-stat {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 10px;
    text-align: left;
    box-shadow: var(--shadow-xs);
}
.dash-stat-val {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
}
.dash-stat-lbl {
    font-size: 0.73rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 4px;
}

/* Active alerts card */
.alerts-panel {
    border-left: 3px solid var(--danger);
    padding: 14px 16px;
    margin-top: 14px;
    /* Ensure long alert messages don't push the panel past the viewport
       on mobile — text rows already clip with ellipsis; this guards the
       panel container itself. */
    overflow: hidden;
    max-width: 100%;
}
.alerts-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.alerts-panel-title {
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--danger);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.alerts-panel-link {
    font-size: 0.78rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}
.alerts-panel-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    font-size: 0.9rem;
    border-top: 1px dashed var(--border);
}
.alerts-panel-row:first-of-type { border-top: 0; }
.alerts-panel-dot {
    width: 8px; height: 8px; border-radius: 50%;
    flex-shrink: 0;
}
.alerts-panel-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alerts-panel-time { font-size: 0.75rem; color: var(--text-light); flex-shrink: 0; }

/* Elderly hero card (check-in mockup) */
.elderly-hero {
    padding: 18px 16px 4px;
    max-width: 480px;
    margin: 0 auto;
}
.elderly-hero .greet-line {
    font-size: 0.85rem;
    color: var(--text-light);
}
.elderly-hero .name-line {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-top: 2px;
}

.checkin-stack {
    max-width: 480px;
    margin: 12px auto 0;
    padding: 0 16px;
    display: grid;
    gap: 12px;
}
.checkin-stack .ck-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--shadow-xs);
}

/* ============================================================
   Persistent Sidebar (desktop) + hamburger-drawer (mobile)
   Desktop ≥1024px: sidebar docks on the left, pushes content right
   Mobile  <1024px: same drawer slides in as overlay
   ============================================================ */

/* Move the hamburger to the LEFT of the brand */
.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Desktop: persistent sidebar replaces the overlay drawer */
@media (min-width: 1024px) {
    body.has-app-header {
        padding-left: var(--app-sidebar-width);
        transition: padding-left 0.2s ease;
    }
    body.sidebar-collapsed.has-app-header {
        padding-left: var(--app-sidebar-collapsed-width);
    }

    .app-header {
        padding-left: 0;
    }

    body.has-app-header .drawer-overlay { display: none; }

    /* Sidebar is always visible on desktop. Rules are scoped under
       `body.has-app-header` for specificity — no !important needed. */
    body.has-app-header .drawer {
        position: fixed;
        top: calc(var(--app-header-height) + env(safe-area-inset-top));       /* below the header */
        left: 0;
        right: auto;
        width: var(--app-sidebar-width);
        height: calc(100vh - var(--app-header-height) - env(safe-area-inset-top));
        box-shadow: 1px 0 2px rgba(0,0,0,0.05);
        border-right: 1px solid var(--border);
        transform: translateX(0);
        padding: 14px 10px;
        z-index: 50;
        background: var(--white);
        transition: width 0.2s ease, padding 0.2s ease;
    }
    body.has-app-header.sidebar-collapsed .drawer {
        width: var(--app-sidebar-collapsed-width);
        padding: 14px 6px;
    }
    /* Hide brand + close button in desktop sidebar (header already has them) */
    .drawer .drawer-head { display: none; }

    body.sidebar-collapsed .drawer-link span:not(.di-icon),
    body.sidebar-collapsed .drawer-chip {
        display: none;
    }
    body.sidebar-collapsed .drawer-link {
        justify-content: center;
        padding: 12px 6px;
    }

    /* Hamburger on desktop toggles collapsed vs full sidebar */
    .hamburger-btn { color: inherit; }
}

/* Mobile: hamburger opens drawer as before, but drawer slides from LEFT */
@media (max-width: 1023px) {
    .drawer {
        left: 0;
        right: auto;
        transform: translateX(-100%);
        box-shadow: 8px 0 24px rgba(0,0,0,0.15);
    }
    .drawer.open { transform: translateX(0); }
}

/* Make sure header content container respects the sidebar on desktop */
@media (min-width: 1024px) {
    .app-header-inner {
        max-width: none;
        padding-left: 24px;
    }
}

/* ============================================================
   Dashboard "Today's events" timeline widget
   ============================================================ */

.events-widget { position: relative; overflow: hidden; }
.events-widget h3 { letter-spacing: -0.01em; }

.ev-count-pill {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--surface-selected);
    color: var(--primary);
    line-height: 1;
}

.events-timeline {
    position: relative;
    display: grid;
    gap: 8px;
    padding: 4px 0;
}

.ev-row {
    display: grid;
    grid-template-columns: 72px 14px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--surface-neutral);
    transition: background var(--transition-fast);
    position: relative;
}
.ev-row:hover { background: var(--surface-selected); }
.ev-row.ev-done    { opacity: 0.72; background: var(--surface-success); }
.ev-row.ev-missed  { background: var(--surface-danger); }
.ev-row.ev-overdue { background: var(--surface-warning); }

.ev-time {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-light);
    text-align: right;
    letter-spacing: 0.02em;
    text-transform: lowercase;
    white-space: nowrap;
}

.ev-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 0 3px var(--white);
    justify-self: center;
}
.ev-row.ev-done .ev-dot    { background: var(--success) !important; }
.ev-row.ev-missed .ev-dot  { background: var(--danger) !important; }
.ev-row.ev-overdue .ev-dot { background: var(--warning) !important; }

.ev-body { min-width: 0; }

.ev-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text);
}
.ev-row.ev-done .ev-title { text-decoration: line-through; color: var(--text-light); }
.ev-emoji { font-size: 1rem; line-height: 1; flex-shrink: 0; }

.ev-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 2px;
    flex-wrap: wrap;
}

.ev-parent-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
}
.ev-parent-avatar {
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--primary-light);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}
.ev-parent-avatar img { width: 100%; height: 100%; object-fit: cover; }

.ev-status {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface-info);
    color: var(--surface-info-text);
}
.ev-status.done    { background: var(--surface-success); color: var(--surface-success-text); }
.ev-status.missed  { background: var(--surface-danger);  color: var(--surface-danger-text); }
.ev-status.overdue { background: var(--surface-warning); color: var(--surface-warning-text); }

.ev-action {
    padding: 6px 12px;
    font-size: 0.76rem;
    font-weight: 700;
    border-radius: 8px;
    background: var(--white);
    border: 1px solid var(--border);
    color: var(--primary);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    font-family: inherit;
    white-space: nowrap;
}
.ev-action:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

.events-empty {
    text-align: center;
    padding: 18px 10px 6px;
    color: var(--text-light);
}

@media (max-width: 540px) {
    .ev-row { grid-template-columns: 56px 10px 1fr; row-gap: 6px; }
    .ev-action { grid-column: 1 / -1; justify-self: start; margin-left: 66px; }
}

/* ============================================================
   RESPONSIVE SAFETY NET
   ────────────────────────────────────────────────────────────
   Global rules + per-component breakpoints that prevent overflow
   and keep the layout usable at 320px → 1920px without touching
   every individual template. Appended last so it wins specificity
   ties without !important.
   ============================================================ */

/* ── Never let the page scroll horizontally ─────────────────── */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

/* Images + SVGs scale with their container */
img, svg, video, canvas {
    max-width: 100%;
    height: auto;
}

/* Any long user-supplied string (name, email, phone, UUID) wraps
   instead of forcing horizontal scroll. Scoped to class names that
   commonly hold such content so we don't break tables / code blocks. */
.parent-name,
.text-light,
.alert-message,
.ev-title,
.dropdown-user-sub,
.q-subject,
.faq-answer,
details.faq-item .faq-answer,
.alerts-panel-text,
.checkin-item {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Flex children should be allowed to shrink below their intrinsic
   width when they contain long text (prevents "whole row overflow"
   when a single long token appears). */
.flex-between > *,
.parent-card-top > *,
.parent-card-top > div > div,   /* the name+phone block inside the avatar group */
.ev-row > .ev-body,
.alerts-panel-row > .alerts-panel-text,
.alerts-panel-head > .alerts-panel-title,
.drawer-link > span:not(.di-icon) {
    min-width: 0;
}

/* Status badge on parent cards must never grow past its content but
   must always be allowed to shrink the LEFT block (avatar+name+phone)
   so it doesn't get pushed off the right edge on small screens. */
.parent-card-top > .status-badge { flex-shrink: 0; max-width: 50%; }
.parent-card-top > div:first-child { flex: 1 1 0; min-width: 0; overflow: hidden; }
.parent-card-top > div:first-child > div:last-child { min-width: 0; overflow: hidden; }
.parent-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Phone viewport: hard clamp on every dashboard card ────────
   Below 540px we explicitly forbid any card or panel from being
   wider than its container, and let every nested flex row's
   children shrink. This is the catch-all so that any future card
   we add doesn't reintroduce the overflow bug. */
@media (max-width: 540px) {
    .card,
    .parent-card,
    .alerts-panel,
    .events-widget,
    .dash-hero,
    .container {
        max-width: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }
    /* Direct flex children of dashboard rows always allowed to shrink */
    .flex-between,
    .alerts-panel-head,
    .alerts-panel-row,
    .parent-card-top {
        min-width: 0;
        max-width: 100%;
    }
    .flex-between > *,
    .alerts-panel-head > *,
    .alerts-panel-row > *,
    .parent-card-top > * {
        min-width: 0;
    }
    /* Today's events card right-side button group: each button keeps its
       intrinsic width (so the label stays readable) but the GROUP shrinks. */
    .events-widget .flex-between > div:last-child {
        flex-shrink: 1;
        min-width: 0;
        flex-wrap: wrap;
        justify-content: flex-end;
    }
}

/* ── Reusable form-grid classes — replaces inline style="grid:1fr 1fr"
   in templates so those layouts can respect media queries. */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
@media (max-width: 540px) {
    .form-grid-2,
    .form-grid-3 { grid-template-columns: 1fr; }
}

/* Care-template chooser cards (schema_v20). 2x2 grid on wide, stacks
   under 540px. Each card is a labeled radio with emoji + title + sub. */
.template-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
@media (max-width: 540px) {
    .template-grid { grid-template-columns: 1fr; }
}
.template-card {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    background: var(--input-bg);
    transition: border-color var(--transition), background var(--transition);
}
.template-card:hover { border-color: var(--primary); }
.template-card input[type=radio] {
    /* Hide the actual radio — selection state is shown via border. */
    position: absolute; opacity: 0; pointer-events: none;
}
.template-card:has(input[type=radio]:checked) {
    border-color: var(--primary);
    background: var(--surface-selected, rgba(99, 102, 241, 0.08));
    box-shadow: 0 0 0 2px var(--primary) inset;
}
.template-card .tcard-emoji { width: 42px; height: 42px; margin-bottom: 4px; }
.template-card .tcard-title { font-weight: 700; font-size: 0.95rem; }
.template-card .tcard-sub   { font-size: 0.78rem; color: var(--text-light); }

/* Add-on chips. Multi-select wrapping row of pill-like checkboxes. */
.addons-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.addon-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1.5px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.85rem;
    background: var(--input-bg);
    user-select: none;
    transition: border-color var(--transition), background var(--transition);
}
.addon-chip input[type=checkbox] {
    /* Hide the box; visual state on the chip itself. */
    position: absolute; opacity: 0; pointer-events: none;
}
.addon-chip:hover { border-color: var(--primary); }
.addon-chip:has(input[type=checkbox]:checked) {
    border-color: var(--primary);
    background: var(--surface-selected, rgba(99, 102, 241, 0.12));
    color: var(--text);
    font-weight: 600;
}
.addon-chip.is-locked {
    /* Chip auto-checked because the primary template seeds it.
       Look slightly muted so users see "this is required by my template
       choice, not something I can toggle". */
    opacity: 0.7;
    cursor: default;
}

/* Date-range row: datetime-local inputs render their native picker UI
   and need ~280px each in en-IN locale ("dd/mm/yyyy, --:-- --" + icon).
   The standard form-grid-2 breakpoint at 540px is too tight — the right
   column overflows the card. Stack earlier specifically here. */
.date-range-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 720px) {
    .date-range-grid { grid-template-columns: 1fr; }
}

/* Ghost suggestion in time/text inputs — value is the deterministic
   jittered default; styling cues "this is a suggestion, type to override".
   Cleared via JS on first keystroke / focus-then-edit. */
.input.input-ghost {
    color: var(--text-muted);
    font-style: italic;
    opacity: 0.75;
}
.input.input-ghost:focus {
    /* On focus we keep the ghost styling until the user actually edits;
       a hint chip below the input explains what's happening. JS removes
       the class on first input event. */
    color: var(--text);
    opacity: 1;
}

/* ── Overlay components: dropdown + submenu must fit the viewport ── */
@media (max-width: 520px) {
    .dropdown {
        min-width: 0;
        width: calc(100vw - 24px);
        max-width: 320px;
        right: 8px;
    }
    /* On mobile, expand the theme submenu inline below the parent item
       (collapse-into-list pattern) instead of as an absolute popover.
       Absolute positioning here was overlaying Feedback/Log out, breaking
       the click target hierarchy. */
    .submenu {
        position: static;
        width: auto;
        min-width: 0;
        background: transparent;
        border: 0;
        box-shadow: none;
        padding: 4px 0 4px 28px;
        transform: none;
        opacity: 1;
        visibility: visible;
        display: none;
    }
    .submenu.open { display: block; }
}

/* ── Modal: fill viewport on small screens, centered on desktop ── */
@media (max-width: 480px) {
    .modal-overlay { padding: 8px; align-items: flex-end; }
    .modal {
        max-width: 100%;
        width: 100%;
        max-height: calc(100vh - 16px);
        overflow-y: auto;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
    .modal-head  { padding: 14px 16px; }
    .modal-body  { padding: 14px 16px; gap: 10px; }
    .modal-foot  { padding: 10px 16px 14px; flex-wrap: wrap; }
    .modal-foot .btn { flex: 1; min-width: 120px; }
}

/* ── Dashboard hero tiles: stack on very narrow, 3-up elsewhere ── */
@media (max-width: 420px) {
    .dash-stats { grid-template-columns: 1fr 1fr; }
    .dash-stats .dash-stat:nth-child(3) { grid-column: span 2; }
}

/* ── Parent quick-bar: stable avatar column, no hard-clipped text ── */
.parent-checkin-info { flex-wrap: wrap; }

/* ── Calendar grid: keep 7 columns but make cells taller + chips clip
       gracefully on narrow screens instead of overflowing sideways. */
@media (max-width: 540px) {
    .cal-grid  { gap: 3px; }
    .cal-cell  { padding: 4px; min-height: 64px; }
    .cal-date  { width: 22px; height: 22px; font-size: 0.72rem; }
    .cal-occ   { font-size: 0.62rem; padding: 1px 4px; }
    /* Hide all-but-one occurrence chip; "+N more" still renders. */
    .cal-cell .cal-occ:nth-of-type(n+2):not(:last-child) { display: none; }
}
@media (max-width: 380px) {
    .cal-toolbar > div:first-child h1 { font-size: 1.2rem; }
    .cal-toolbar select,
    .cal-toolbar .btn { font-size: 0.78rem; padding: 6px 10px; }
}

/* ── Heatmap: bigger touch targets on phones ──────────────── */
@media (max-width: 540px) {
    .heatmap-dots { grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
    .hd { min-width: 20px; min-height: 20px; }
}

/* ── Week grid (parent detail "This week") ─────────────────── */
@media (max-width: 420px) {
    .week-grid { gap: 4px; }
    .week-grid .week-day { font-size: 0.7rem; padding: 6px 2px; }
}

/* ── Alerts page action rows wrap cleanly ──────────────────── */
.alert-card .btn-group {
    flex-wrap: wrap;
}
/* NOTE: .alerts-panel-row used to live in the flex-wrap rule above.
   Removed because each row's text child has `white-space: nowrap` —
   wrapping pushed it onto its own line where it could grow past the
   viewport (defeating text-overflow: ellipsis). The row stays single-
   line; long text truncates with "…" inside the .alerts-panel-text. */
@media (max-width: 480px) {
    .alert-card .btn {
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
    }
}

/* ── Install page: QR card shouldn't force min-width ──────── */
@media (max-width: 540px) {
    .install-qr-card { position: static; padding: 20px; }
    .install-qr { width: 200px; height: 200px; }
}

/* ── Admin pages + forms: respect sidebar on desktop ──────── */
.admin-container,
.page > .container[style*="max-width:960px"],
.page > .container[style*="max-width:1000px"],
.page > .container[style*="max-width:1100px"] {
    padding-left: 16px;
    padding-right: 16px;
}

/* ── Feedback/FAQ pages ────────────────────────────────────── */
@media (max-width: 480px) {
    .faq-tabs { overflow-x: auto; flex-wrap: nowrap; white-space: nowrap; }
    .faq-tab  { flex-shrink: 0; padding: 10px 12px; font-size: 0.88rem; }
}

/* ── Drawer: tighter on ultra-narrow phones ─────────────────── */
@media (max-width: 360px) {
    .drawer { width: min(280px, 90vw); padding: 10px; }
    .drawer-link { padding: 10px 12px; font-size: 0.92rem; }
}

/* ── Header right cluster must not overflow on 320px ───────── */
@media (max-width: 420px) {
    .alerts-pill .alerts-label { display: none; }     /* icon-only on phones */
    .alerts-pill { padding: 6px 10px; }
    .app-header-inner { padding: 8px 12px; gap: 8px; }
    .brand { gap: 8px; font-size: 1.08rem; }
}
@media (max-width: 360px) {
    .avatar-btn { width: 32px; height: 32px; }
}

/* ── Parent cards: avoid collision between name + status badge ── */
.parent-card-top {
    flex-wrap: wrap;
    row-gap: 8px;
}
.parent-card-top > :first-child { min-width: 0; flex: 1 1 60%; }
.parent-card-top > :last-child  { flex-shrink: 0; }

/* ── Events widget on dashboard: compact on mobile ─────────── */
@media (max-width: 480px) {
    .events-widget .ev-meta { gap: 6px; }
    .events-widget .ev-status { padding: 1px 6px; font-size: 0.6rem; }
    .events-widget .ev-title { font-size: 0.88rem; }
}

/* ── Long form inputs never overflow their parent card ──── */
input.input, textarea.input, select.input {
    width: 100%;
    max-width: 100%;
}

/* ── Activity feed rows behave on narrow screens ───────────── */
#activity-feed > div,
.card > #activity-feed > div {
    flex-wrap: wrap;
}

/* ── SOS float: slightly smaller on phones so it doesn't block content ── */
@media (max-width: 380px) {
    #sos-float > a {
        width: 52px !important;
        height: 52px !important;
        font-size: 1.3rem !important;
    }
}

/* ── Tooltips never push off-screen ─────────────────────────── */
.hd-tooltip { max-width: calc(100vw - 16px); }

/* ============================================================
   Dashboard v2 — screenshot-aligned shell using existing data
   ============================================================ */
body.dashboard-v2 {
    --bg: #F4F7FB;
    --white: #FFFFFF;
    --text: #101828;
    --text-light: #667085;
    --text-muted: #98A2B3;
    --border: rgba(15, 23, 42, 0.1);
    --input-bg: #FFFFFF;
    --surface-neutral: rgba(15, 23, 42, 0.045);
    --surface-selected: rgba(79, 70, 229, 0.1);
    --surface-selected-text: #4338CA;
    --surface-danger: rgba(239, 68, 68, 0.1);
    --surface-danger-text: #B42318;
    --surface-warning: rgba(245, 158, 11, 0.12);
    --surface-warning-text: #B45309;
    --surface-success: rgba(16, 185, 129, 0.12);
    --surface-success-text: #027A48;
    --dash-shell-bg: linear-gradient(135deg, #F8FAFC 0%, #EFF6FF 48%, #F5F3FF 100%);
    --dash-card-bg: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.98));
    --dash-card-border: rgba(15, 23, 42, 0.1);
    --dash-card-shadow: 0 18px 45px rgba(15, 23, 42, 0.09), inset 0 1px 0 rgba(255,255,255,0.9);
    --dash-sidebar-bg: rgba(255, 255, 255, 0.96);
    --dash-sidebar-link: #475467;
    --dash-sidebar-active-bg: linear-gradient(135deg, rgba(79, 70, 229, 0.12), rgba(14, 165, 233, 0.1));
    --dash-sidebar-active-text: #312E81;
    --dash-header-control-bg: rgba(255, 255, 255, 0.82);
    --dash-topbar-bg: rgba(255, 255, 255, 0.94);
    --dash-ring-inner: #FFFFFF;
    --dash-soft-row: rgba(15, 23, 42, 0.045);
    background: var(--dash-shell-bg);
}

[data-theme="dark"] body.dashboard-v2 {
    --bg: #07101e;
    --white: #0d182a;
    --text: #edf3ff;
    --text-light: #a5b2c7;
    --text-muted: #6f7d94;
    --border: rgba(148, 163, 184, 0.18);
    --input-bg: rgba(15, 26, 45, 0.9);
    --surface-neutral: rgba(148, 163, 184, 0.08);
    --surface-selected: rgba(99, 102, 241, 0.18);
    --surface-selected-text: #b9c2ff;
    --surface-danger: rgba(239, 68, 68, 0.16);
    --surface-danger-text: #ff8d8d;
    --surface-warning: rgba(245, 158, 11, 0.15);
    --surface-warning-text: #ffd166;
    --surface-success: rgba(16, 185, 129, 0.16);
    --surface-success-text: #79e7bd;
    --dash-shell-bg: linear-gradient(135deg, #060a14 0%, #07101e 46%, #0b1727 100%);
    --dash-card-bg: linear-gradient(180deg, rgba(15, 29, 51, 0.92), rgba(11, 24, 43, 0.92));
    --dash-card-border: rgba(148, 163, 184, 0.18);
    --dash-card-shadow: 0 18px 45px rgba(0, 0, 0, 0.26), inset 0 1px 0 rgba(255,255,255,0.035);
    --dash-sidebar-bg: rgba(5, 11, 22, 0.96);
    --dash-sidebar-link: #b6c2d7;
    --dash-sidebar-active-bg: linear-gradient(135deg, rgba(59, 130, 246, 0.36), rgba(124, 58, 237, 0.36));
    --dash-sidebar-active-text: #fff;
    --dash-header-control-bg: rgba(15, 29, 51, 0.78);
    --dash-topbar-bg: rgba(5, 11, 22, 0.84);
    --dash-ring-inner: #0b1727;
    --dash-soft-row: rgba(148, 163, 184, 0.07);
}

body.dashboard-v2 .dashboard-page {
    padding: 8px clamp(16px, 2vw, 28px) 24px;
}

body.dashboard-v2 .dashboard-wide,
body.dashboard-v2 .dashboard-container {
    width: min(100%, 1540px);
    max-width: none;
    margin-left: auto;
    margin-right: auto;
    padding-left: 0;
    padding-right: 0;
}

body.dashboard-v2 .dash-hero {
    margin-top: 0;
    grid-template-columns: minmax(320px, 1fr) minmax(520px, 1.45fr);
    align-items: end;
}

body.dashboard-v2 .dash-hero h1 {
    font-size: clamp(1.9rem, 3vw, 2.65rem);
    letter-spacing: -0.02em;
}

body.dashboard-v2 .dash-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

body.dashboard-v2 .dash-stat,
body.dashboard-v2 .card,
body.dashboard-v2 .parent-card {
    background: var(--dash-card-bg);
    border-color: var(--dash-card-border);
    box-shadow: var(--dash-card-shadow);
}

body.dashboard-v2 .dash-stat {
    min-height: 96px;
    padding: 22px;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

body.dashboard-v2 .dash-stat::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--primary);
    opacity: 0.9;
}

body.dashboard-v2 .dash-stat:nth-child(2)::before {
    background: var(--danger);
}

body.dashboard-v2 .dash-stat:nth-child(3)::before {
    background: var(--warning);
}

body.dashboard-v2 .dash-stat-val {
    font-size: 1.75rem;
}

body.dashboard-v2 .dash-stat-lbl {
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.88rem;
}

body.dashboard-v2 #parent-bar {
    width: min(100%, 1540px);
    margin: 10px auto 0;
    padding-left: 0;
    padding-right: 0;
}

body.dashboard-v2 .parent-quick-link {
    color: var(--text);
    text-decoration: none;
    text-align: center;
    flex: 0 0 auto;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 58px;
    padding: 2px 4px;
    border-radius: 10px;
}

body.dashboard-v2 .parent-quick-link:hover .parent-quick-name {
    color: var(--primary);
}

body.dashboard-v2 .parent-quick-link:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
}

body.dashboard-v2 .parent-quick-avatar-wrap {
    position: relative;
    display: inline-flex;
}

body.dashboard-v2 .parent-quick-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-light);
    color: white;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    overflow: hidden;
    box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.28), 0 6px 14px rgba(15, 23, 42, 0.12);
}

body.dashboard-v2 .parent-quick-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

body.dashboard-v2 .parent-quick-avatar.status-good {
    box-shadow: 0 0 0 3px var(--success), 0 6px 14px rgba(15, 23, 42, 0.12);
}

body.dashboard-v2 .parent-quick-avatar.status-warning,
body.dashboard-v2 .parent-quick-avatar.status-pending {
    box-shadow: 0 0 0 3px var(--warning), 0 6px 14px rgba(15, 23, 42, 0.12);
}

body.dashboard-v2 .parent-quick-avatar.status-critical,
body.dashboard-v2 .parent-quick-avatar.status-missed {
    box-shadow: 0 0 0 3px var(--danger), 0 6px 14px rgba(15, 23, 42, 0.12);
}

body.dashboard-v2 .parent-quick-avatar.status-before_schedule {
    box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.32), 0 6px 14px rgba(15, 23, 42, 0.12);
}

body.dashboard-v2 .parent-quick-avatar.status-vacation {
    box-shadow: 0 0 0 3px #3B82F6, 0 6px 14px rgba(15, 23, 42, 0.12);
}

body.dashboard-v2 .parent-quick-alert-badge {
    position: absolute;
    top: -6px;
    left: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--danger);
    border: 2px solid var(--dash-card-bg);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.58rem;
    line-height: 1;
    font-weight: 800;
    box-shadow: 0 3px 8px rgba(239, 68, 68, 0.28);
}

body.dashboard-v2 .parent-quick-name {
    display: block;
    font-size: 0.7rem;
    color: var(--text);
    line-height: 1.2;
    white-space: nowrap;
    max-width: 68px;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.dashboard-v2 .dashboard-widgets {
    display: grid;
    grid-template-columns: minmax(430px, 0.95fr) minmax(620px, 1.45fr);
    gap: 20px;
    margin-top: 22px;
    align-items: stretch;
}

body.dashboard-v2 .dashboard-side-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

body.dashboard-v2 .dashboard-schedule-card,
body.dashboard-v2 .dashboard-side-grid > .card {
    margin: 0;
    border-radius: 8px;
}

body.dashboard-v2 .dashboard-schedule-card {
    min-height: 420px;
}

body.dashboard-v2 .alerts-panel {
    border-left: 1px solid var(--dash-card-border);
    padding: 20px;
}

body.dashboard-v2 .alerts-panel-title {
    color: var(--text);
    text-transform: none;
    letter-spacing: 0;
    font-size: 1rem;
}

body.dashboard-v2 .alerts-panel-row {
    padding: 12px 0;
    border-top-style: solid;
}

body.dashboard-v2 #family-activity-list > div {
    padding: 11px 0 !important;
}

body.dashboard-v2 .checkin-overview-body {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 20px;
    align-items: center;
    margin-top: 18px;
}

body.dashboard-v2 .checkin-ring {
    width: 128px;
    aspect-ratio: 1;
    border-radius: 50%;
    background:
        conic-gradient(var(--success) 0 calc(var(--checked) * 1%),
                       var(--danger) 0 calc((var(--checked) + var(--overdue)) * 1%),
                       var(--warning) 0 100%);
    display: grid;
    place-items: center;
}

body.dashboard-v2 .checkin-ring > div {
    width: 82px;
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--dash-ring-inner);
    display: grid;
    place-items: center;
    align-content: center;
}

body.dashboard-v2 .checkin-ring strong {
    font-size: 1.55rem;
    line-height: 1;
}

body.dashboard-v2 .checkin-ring span,
body.dashboard-v2 .checkin-legend {
    font-size: 0.78rem;
    color: var(--text-light);
}

body.dashboard-v2 .checkin-legend {
    display: grid;
    gap: 12px;
}

body.dashboard-v2 .checkin-legend div {
    display: grid;
    grid-template-columns: 10px 1fr auto;
    align-items: center;
    gap: 10px;
}

body.dashboard-v2 .legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

body.dashboard-v2 .legend-good { background: var(--success); }
body.dashboard-v2 .legend-danger { background: var(--danger); }
body.dashboard-v2 .legend-warning { background: var(--warning); }

body.dashboard-v2 .week-summary-row {
    border-left: 3px solid var(--week-tone);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    background: var(--dash-soft-row);
}

body.dashboard-v2 #parents-heading {
    margin-top: 34px;
}

body.dashboard-v2 #parents-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

body.dashboard-v2 #parents-list .spinner,
body.dashboard-v2 #parents-list .loading-text,
body.dashboard-v2 #parents-list > p {
    grid-column: 1 / -1;
}

body.dashboard-v2 .parent-card {
    margin: 0;
    border-radius: 8px;
    padding: 22px;
}

body.dashboard-v2 .heatmap-dots {
    grid-template-columns: repeat(30, minmax(0, 1fr));
    gap: 5px;
}

body.dashboard-v2 .hd {
    border-radius: 4px;
    min-width: 0;
    min-height: 0;
}

@media (min-width: 1024px) {
    body.dashboard-v2.has-app-header {
        padding-left: var(--app-sidebar-width);
    }

    body.dashboard-v2.sidebar-collapsed.has-app-header {
        padding-left: var(--app-sidebar-collapsed-width);
    }

    body.dashboard-v2 .app-header {
        background: rgba(255,255,255,0.96);
        border-bottom: 1px solid var(--border);
        box-shadow: 0 1px 2px rgba(15,23,42,0.04);
    }

    [data-theme="dark"] body.dashboard-v2 .app-header {
        background: rgba(10,15,30,0.94);
        border-bottom-color: var(--border);
        box-shadow: 0 1px 2px rgba(0,0,0,0.28);
    }

    body.dashboard-v2 .app-header-inner {
        justify-content: space-between;
        padding: 0 24px;
    }

    body.dashboard-v2 .header-left {
        display: flex;
    }

    body.dashboard-v2 .alerts-pill {
        width: auto;
        height: auto;
        padding: 6px 12px;
        justify-content: center;
        color: var(--text);
        background: var(--dash-header-control-bg);
        border: 1px solid var(--dash-card-border);
    }

    body.dashboard-v2 .alerts-label {
        display: inline;
    }

    body.dashboard-v2 .avatar-btn {
        width: 44px;
        height: 44px;
        border: 1px solid rgba(148, 163, 184, 0.24);
        background: linear-gradient(135deg, #6366f1, #7c3aed);
    }

    body.dashboard-v2.has-app-header .drawer,
    body.dashboard-v2.has-app-header.sidebar-collapsed .drawer {
        top: calc(var(--app-header-height) + env(safe-area-inset-top));
        width: var(--app-sidebar-width);
        height: calc(100vh - var(--app-header-height) - env(safe-area-inset-top));
        padding: 18px 12px;
        background: var(--dash-sidebar-bg);
        border-right: 1px solid var(--dash-card-border);
        box-shadow: 1px 0 2px rgba(0,0,0,0.05);
    }

    body.dashboard-v2.has-app-header.sidebar-collapsed .drawer {
        width: var(--app-sidebar-collapsed-width);
        padding: 18px 8px;
    }

    body.dashboard-v2 .drawer .drawer-head {
        display: none;
    }

    body.dashboard-v2.has-app-header.sidebar-collapsed .drawer-link span:not(.di-icon),
    body.dashboard-v2.has-app-header.sidebar-collapsed .drawer-chip {
        display: none;
    }

    body.dashboard-v2.has-app-header.sidebar-collapsed .drawer-link {
        justify-content: center;
        padding: 14px 8px;
    }

    body.dashboard-v2 .drawer-nav {
        gap: 8px;
    }

    body.dashboard-v2 .drawer-link {
        min-height: 52px;
        border-radius: 8px;
        color: var(--dash-sidebar-link);
        padding: 14px 16px;
    }

    body.dashboard-v2 .drawer-link:hover,
    body.dashboard-v2 .drawer-link.active {
        color: var(--dash-sidebar-active-text);
        background: var(--dash-sidebar-active-bg);
        box-shadow: inset 0 0 0 1px rgba(129, 140, 248, 0.35);
    }
}

@media (max-width: 1300px) {
    body.dashboard-v2 .dash-hero,
    body.dashboard-v2 .dashboard-widgets {
        grid-template-columns: 1fr;
    }

    body.dashboard-v2 .dashboard-side-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    body.dashboard-v2 .dashboard-page {
        padding: 14px 16px 24px;
    }

    body.dashboard-v2 .dash-stats,
    body.dashboard-v2 .dashboard-side-grid,
    body.dashboard-v2 #parents-list {
        grid-template-columns: 1fr;
    }

    body.dashboard-v2 .checkin-overview-body {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   Parent dashboard v3 — modular caregiver dashboard
   ============================================================ */
body.parent-dashboard-v3 {
    --pd-bg: #F6F8FB;
    --pd-card: rgba(255,255,255,0.96);
    --pd-border: rgba(15, 23, 42, 0.10);
    --pd-shadow: 0 16px 42px rgba(15, 23, 42, 0.08), inset 0 1px 0 rgba(255,255,255,0.82);
    --pd-soft-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    background: var(--pd-bg);
}

[data-theme="dark"] body.parent-dashboard-v3 {
    --pd-bg: #07101e;
    --pd-card: rgba(13, 24, 42, 0.94);
    --pd-border: rgba(148, 163, 184, 0.18);
    --pd-shadow: 0 16px 42px rgba(0,0,0,0.26), inset 0 1px 0 rgba(255,255,255,0.04);
    --pd-soft-shadow: 0 8px 24px rgba(0,0,0,0.22);
}

body.parent-dashboard-v3 .parent-dash-page {
    padding: 24px clamp(16px, 2.5vw, 32px) 32px;
}

body.parent-dashboard-v3 .parent-dash-shell {
    width: min(100%, 1540px);
    margin: 0 auto;
}

body.parent-dashboard-v3 .card {
    background: var(--pd-card);
    border: 1px solid var(--pd-border);
    border-radius: 18px;
    box-shadow: var(--pd-shadow);
}

body.parent-dashboard-v3 .parent-back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 14px;
}

body.parent-dashboard-v3 .parent-hero-card {
    padding: 24px;
    margin: 0 0 18px;
}

body.parent-dashboard-v3 .parent-hero-inner,
body.parent-dashboard-v3 .module-head,
body.parent-dashboard-v3 .setting-row,
body.parent-dashboard-v3 .setting-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

body.parent-dashboard-v3 .parent-identity {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
}

body.parent-dashboard-v3 .parent-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

body.parent-dashboard-v3 .parent-hero-avatar {
    width: 64px;
    height: 64px;
    border-radius: 999px;
    background: linear-gradient(135deg, #818CF8, #4F46E5);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 1.55rem;
    overflow: hidden;
}

body.parent-dashboard-v3 .parent-photo-edit {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
    border: 2px solid var(--white);
    box-shadow: var(--pd-soft-shadow);
    font-size: 0.8rem;
}

body.parent-dashboard-v3 .parent-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

body.parent-dashboard-v3 .parent-title-row h2 {
    margin: 0;
    font-size: clamp(1.35rem, 2vw, 1.75rem);
    letter-spacing: 0;
}

body.parent-dashboard-v3 .parent-identity p,
body.parent-dashboard-v3 .module-head p,
body.parent-dashboard-v3 .setting-row p,
body.parent-dashboard-v3 .setting-toggle-row small,
body.parent-dashboard-v3 .setting-subhead span {
    margin: 2px 0 0;
    color: var(--text-light);
    font-size: 0.86rem;
    line-height: 1.4;
}

body.parent-dashboard-v3 .parent-missed-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 5px 10px;
    background: var(--surface-danger);
    color: var(--surface-danger-text);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

body.parent-dashboard-v3 .parent-missed-pill::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

body.parent-dashboard-v3 .parent-missed-pill.calm {
    background: var(--surface-success);
    color: var(--surface-success-text);
}

body.parent-dashboard-v3 .hero-call-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border-radius: 12px;
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
    text-decoration: none;
    font-weight: 800;
    border: 1px solid rgba(16, 185, 129, 0.22);
}

body.parent-dashboard-v3 .parent-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

body.parent-dashboard-v3 .parent-stat-card {
    min-height: 132px;
    padding: 20px;
    display: grid;
    align-content: space-between;
    transition: transform var(--transition), box-shadow var(--transition);
}

body.parent-dashboard-v3 .parent-stat-card:hover,
body.parent-dashboard-v3 .parent-module-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 46px rgba(15, 23, 42, 0.10);
}

body.parent-dashboard-v3 .parent-stat-card .stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 900;
    font-size: 1.25rem;
}

body.parent-dashboard-v3 .parent-stat-alerts .stat-icon { background: var(--surface-danger); color: var(--danger); }
body.parent-dashboard-v3 .parent-stat-checkins .stat-icon { background: var(--surface-success); color: var(--success); }
body.parent-dashboard-v3 .parent-stat-family .stat-icon { background: rgba(59, 130, 246, 0.12); color: #2563EB; }
body.parent-dashboard-v3 .parent-stat-next .stat-icon { background: var(--surface-selected); color: var(--primary); }

body.parent-dashboard-v3 .parent-stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 1.5rem;
    line-height: 1;
}

body.parent-dashboard-v3 .parent-stat-card span {
    display: block;
    margin-top: 6px;
    color: var(--text);
    line-height: 1.35;
}

body.parent-dashboard-v3 .parent-stat-card a,
body.parent-dashboard-v3 .module-head a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.86rem;
}

body.parent-dashboard-v3 .parent-dashboard-grid {
    display: grid;
    gap: 18px;
    margin-bottom: 18px;
}

body.parent-dashboard-v3 .parent-dashboard-grid-top {
    grid-template-columns: minmax(330px, 0.95fr) minmax(420px, 1fr) minmax(420px, 1fr);
}

body.parent-dashboard-v3 .parent-dashboard-grid-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

body.parent-dashboard-v3 .parent-overview-stack {
    display: grid;
    gap: 18px;
}

body.parent-dashboard-v3 .parent-module-card {
    padding: 20px;
    margin: 0;
    min-width: 0;
    transition: transform var(--transition), box-shadow var(--transition);
}

body.parent-dashboard-v3 .module-head {
    margin-bottom: 14px;
    align-items: flex-start;
}

body.parent-dashboard-v3 .module-head h3,
body.parent-dashboard-v3 .quick-actions-band h3,
body.parent-dashboard-v3 .settings-group h4 {
    margin: 0;
    font-size: 1.02rem;
    letter-spacing: 0;
}

body.parent-dashboard-v3 .compact-btn {
    width: auto;
    min-height: 36px;
    padding: 7px 13px;
    font-size: 0.84rem;
    white-space: nowrap;
}

body.parent-dashboard-v3 .soft-empty {
    border: 1px solid var(--pd-border);
    background: var(--surface-neutral);
    color: var(--text-light);
    border-radius: 12px;
    padding: 14px;
    font-size: 0.92rem;
}

body.parent-dashboard-v3 .compact-checkin-info {
    flex-wrap: wrap;
    gap: 8px;
}

body.parent-dashboard-v3 .compact-checkin-info .checkin-item {
    padding: 7px 10px;
    border: 1px solid var(--pd-border);
    border-radius: 999px;
    background: var(--surface-neutral);
    font-size: 0.82rem;
}

body.parent-dashboard-v3 .week-grid {
    gap: 8px;
}

body.parent-dashboard-v3 .week-day {
    min-height: 56px;
    border-radius: 12px;
}

body.parent-dashboard-v3 .week-day .label {
    margin-bottom: 6px;
}

body.parent-dashboard-v3 .detail-alert-card {
    margin: 0 0 12px;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid rgba(239, 68, 68, 0.20);
    border-left: 4px solid var(--danger);
    background: linear-gradient(135deg, rgba(254,242,242,0.96), rgba(255,255,255,0.96));
    box-shadow: var(--pd-soft-shadow);
}

[data-theme="dark"] body.parent-dashboard-v3 .detail-alert-card {
    background: rgba(127, 29, 29, 0.22);
}

body.parent-dashboard-v3 .detail-alert-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    align-items: center;
}

body.parent-dashboard-v3 .detail-alert-actions > div {
    grid-column: 1 / -1;
}

body.parent-dashboard-v3 .alert-action-primary,
body.parent-dashboard-v3 .alert-action-secondary {
    width: auto;
    min-height: 36px;
    padding: 7px 10px;
    font-size: 0.8rem;
}

body.parent-dashboard-v3 #activity-feed > div,
body.parent-dashboard-v3 #caregivers-list > div,
body.parent-dashboard-v3 #questions-list > div,
body.parent-dashboard-v3 #care-list > div {
    border-bottom-color: var(--pd-border) !important;
}

body.parent-dashboard-v3 .quick-chip-wrap,
body.parent-dashboard-v3 .question-preview,
body.parent-dashboard-v3 .compact-form-panel {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--pd-border);
}

body.parent-dashboard-v3 .quick-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

body.parent-dashboard-v3 .quick-chip-row .btn {
    width: auto;
    min-height: 34px;
    padding: 6px 10px;
    font-size: 0.8rem;
}

body.parent-dashboard-v3 .question-preview {
    background: var(--surface-neutral);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 0.84rem;
}

body.parent-dashboard-v3 .parent-inline-panel,
body.parent-dashboard-v3 .parent-settings-card,
body.parent-dashboard-v3 .parent-danger-card {
    margin: 18px 0 0;
    padding: 20px;
}

body.parent-dashboard-v3 .quick-actions-band {
    margin: 22px 0;
}

body.parent-dashboard-v3 .quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-top: 12px;
}

body.parent-dashboard-v3 .quick-action {
    min-height: 58px;
    border-radius: 14px;
    border: 1px solid var(--pd-border);
    background: var(--pd-card);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    color: var(--text);
    text-decoration: none;
    font-weight: 800;
    box-shadow: var(--pd-soft-shadow);
    transition: transform var(--transition), box-shadow var(--transition);
}

body.parent-dashboard-v3 .quick-action:hover {
    transform: translateY(-2px);
    box-shadow: var(--pd-shadow);
}

body.parent-dashboard-v3 .quick-call { color: var(--success); background: rgba(16, 185, 129, 0.10); }
body.parent-dashboard-v3 .quick-call.is-disabled,
body.parent-dashboard-v3 .hero-call-btn.is-disabled {
    opacity: 0.55;
    pointer-events: none;
    color: var(--text-light);
    background: var(--surface-neutral);
    border-color: var(--border);
}
body.parent-dashboard-v3 .quick-health { color: var(--primary); background: var(--surface-selected); }
body.parent-dashboard-v3 .quick-safe { color: #0EA5E9; background: rgba(14, 165, 233, 0.10); }
body.parent-dashboard-v3 .quick-event { color: #EA580C; background: rgba(249, 115, 22, 0.10); }

body.parent-dashboard-v3 .settings-head {
    align-items: center;
    border-bottom: 1px solid var(--pd-border);
    padding-bottom: 16px;
}

body.parent-dashboard-v3 .settings-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

body.parent-dashboard-v3 .settings-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-top: 18px;
}

body.parent-dashboard-v3 .settings-group {
    min-width: 0;
}

body.parent-dashboard-v3 .settings-group h4 {
    margin-bottom: 10px;
}

body.parent-dashboard-v3 .setting-row,
body.parent-dashboard-v3 .setting-toggle-row,
body.parent-dashboard-v3 .setting-subhead {
    padding: 11px 0;
    border-top: 1px solid var(--pd-border);
}

body.parent-dashboard-v3 .setting-row:first-of-type,
body.parent-dashboard-v3 .setting-toggle-row:first-of-type {
    border-top: 0;
}

body.parent-dashboard-v3 .setting-row > div,
body.parent-dashboard-v3 .setting-toggle-row span {
    min-width: 0;
}

body.parent-dashboard-v3 .setting-row label,
body.parent-dashboard-v3 .setting-toggle-row strong,
body.parent-dashboard-v3 .input-group label {
    font-size: 0.86rem;
    font-weight: 750;
}

body.parent-dashboard-v3 .setting-row .input,
body.parent-dashboard-v3 .setting-row .input-with-unit,
body.parent-dashboard-v3 .setting-toggle-row + .input,
body.parent-dashboard-v3 .settings-group select,
body.parent-dashboard-v3 .settings-group .input-with-unit,
body.parent-dashboard-v3 .settings-group input[type="time"],
body.parent-dashboard-v3 .settings-group input[type="number"],
body.parent-dashboard-v3 .settings-group input[type="datetime-local"] {
    max-width: 210px;
}

body.parent-dashboard-v3 input[type="checkbox"] {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

body.parent-dashboard-v3 .setting-toggle-row {
    cursor: pointer;
}

body.parent-dashboard-v3 .setting-toggle-row small {
    display: block;
}

body.parent-dashboard-v3 .indented-setting {
    margin-left: 14px;
    padding-left: 14px;
    border-left: 2px solid var(--pd-border);
}

body.parent-dashboard-v3 .evening-checkin-toggle {
    margin-top: 6px;
    padding: 12px 14px;
    border: 1px solid var(--pd-border);
    border-radius: 14px;
    background: var(--surface-selected);
}

body.parent-dashboard-v3 .evening-slot-row {
    margin: 8px 0 2px;
    padding: 12px 14px;
    border: 1px solid var(--pd-border);
    border-radius: 14px;
    background: var(--white);
    box-shadow: var(--shadow-xs);
}

body.parent-dashboard-v3 .evening-slot-row > div {
    display: grid;
    gap: 4px;
}

body.parent-dashboard-v3 .compact-alert-grid,
body.parent-dashboard-v3 .compact-date-grid {
    gap: 8px;
    margin: 8px 0 10px;
}

body.parent-dashboard-v3 .health-toggle-grid {
    display: grid;
    gap: 8px;
}

body.parent-dashboard-v3 .health-toggle-grid label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 10px;
    border: 1px solid var(--pd-border);
    border-radius: 12px;
    background: var(--surface-neutral);
    font-weight: 650;
}

body.parent-dashboard-v3 .health-preset-grid {
    display: grid;
    gap: 8px;
    margin: 8px 0 10px;
}

body.parent-dashboard-v3 .health-preset-grid button {
    border: 1px solid var(--pd-border);
    border-radius: 12px;
    background: var(--white);
    color: var(--text);
    text-align: left;
    padding: 10px 12px;
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

body.parent-dashboard-v3 .health-preset-grid button:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

body.parent-dashboard-v3 .health-preset-grid strong,
body.parent-dashboard-v3 .health-preset-grid span {
    display: block;
}

body.parent-dashboard-v3 .health-preset-grid span {
    color: var(--text-light);
    font-size: 0.78rem;
    margin-top: 2px;
}

body.parent-dashboard-v3 .metric-manager {
    display: grid;
    gap: 8px;
    margin-top: 10px;
    container-type: inline-size;
    container-name: health-metrics;
}

body.parent-dashboard-v3 .metric-manager-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

body.parent-dashboard-v3 .health-metric-row {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(112px, 0.55fr) minmax(78px, auto) minmax(180px, 0.72fr) auto;
    align-items: center;
    gap: 8px;
}

body.parent-dashboard-v3 .metric-manager-head {
    color: var(--text-light);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

body.parent-dashboard-v3 .health-metric-row {
    padding: 10px;
    border: 1px solid var(--pd-border);
    border-radius: 12px;
    background: var(--white);
}

body.parent-dashboard-v3 .health-metric-row.is-disabled {
    opacity: 0.62;
    background: var(--surface-neutral);
}

body.parent-dashboard-v3 .health-metric-main strong,
body.parent-dashboard-v3 .health-metric-main span,
body.parent-dashboard-v3 .health-metric-row label span {
    display: block;
}

body.parent-dashboard-v3 .health-metric-main small {
    margin-left: 6px;
    color: var(--text-light);
    font-size: 0.78rem;
}

body.parent-dashboard-v3 .health-metric-main span,
body.parent-dashboard-v3 .health-metric-row label span {
    color: var(--text-light);
    font-size: 0.76rem;
}

body.parent-dashboard-v3 .health-metric-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: space-between;
    min-width: 0;
}

body.parent-dashboard-v3 .health-metric-row label input[type="checkbox"] {
    flex: 0 0 auto;
}

body.parent-dashboard-v3 .metric-range-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    min-width: 0;
}

body.parent-dashboard-v3 .metric-range-fields .input {
    width: 100%;
    min-width: 0;
    padding-inline: 14px;
}

body.parent-dashboard-v3 .custom-metric-box {
    margin-top: 12px;
    padding: 12px;
    border: 1px dashed var(--pd-border);
    border-radius: 14px;
    background: var(--surface-neutral);
}

body.parent-dashboard-v3 .custom-metric-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

body.parent-dashboard-v3 .setting-toggle-row.compact {
    margin: 10px 0;
    padding: 8px 0;
}

body.parent-dashboard-v3 .care-inline-add {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--pd-border);
}

body.parent-dashboard-v3 .care-inline-add summary {
    cursor: pointer;
    color: var(--primary);
    font-weight: 800;
    list-style: none;
}

body.parent-dashboard-v3 .care-inline-add summary::-webkit-details-marker {
    display: none;
}

body.parent-dashboard-v3 .care-inline-add summary::after {
    content: " +";
}

body.parent-dashboard-v3 .care-inline-add[open] summary {
    margin-bottom: 10px;
}

@media (max-width: 1280px) {
    body.parent-dashboard-v3 .parent-dashboard-grid-top,
    body.parent-dashboard-v3 .parent-dashboard-grid-cards,
    body.parent-dashboard-v3 .settings-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    body.parent-dashboard-v3 .parent-overview-stack,
    body.parent-dashboard-v3 .parent-settings-card .settings-group:last-child {
        grid-column: 1 / -1;
    }

    body.parent-dashboard-v3 .metric-manager-head {
        display: none;
    }

    body.parent-dashboard-v3 .health-metric-row {
        grid-template-columns: minmax(160px, 1fr) minmax(120px, auto) minmax(82px, auto);
    }

    body.parent-dashboard-v3 .metric-range-fields {
        grid-column: 1 / -1;
    }
}

@container health-metrics (max-width: 640px) {
    body.parent-dashboard-v3 .metric-manager-head {
        display: none;
    }

    body.parent-dashboard-v3 .health-metric-row {
        grid-template-columns: minmax(136px, 1fr) minmax(96px, 0.45fr) minmax(66px, auto) minmax(138px, 0.5fr) auto;
        align-items: center;
        gap: 8px;
    }

    body.parent-dashboard-v3 .metric-toggle span {
        font-size: 0.72rem;
    }

    body.parent-dashboard-v3 .metric-range-fields {
        grid-column: auto;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
    }

    body.parent-dashboard-v3 .metric-range-fields .input {
        padding-inline: 10px;
    }

    body.parent-dashboard-v3 .health-metric-row .icon-btn {
        grid-column: 1 / -1;
        justify-self: end;
    }
}

@container health-metrics (max-width: 430px) {
    body.parent-dashboard-v3 .health-metric-row {
        grid-template-columns: 1fr;
    }

    body.parent-dashboard-v3 .metric-toggle {
        justify-content: flex-start;
    }

    body.parent-dashboard-v3 .metric-range-fields {
        grid-column: 1 / -1;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 820px) {
    body.parent-dashboard-v3 .metric-manager-head,
    body.parent-dashboard-v3 .health-metric-row,
    body.parent-dashboard-v3 .custom-metric-grid {
        grid-template-columns: 1fr;
    }

    body.parent-dashboard-v3 .parent-dash-page {
        padding: 18px 14px 28px;
    }

    body.parent-dashboard-v3 .parent-back-link {
        display: none;
    }

    body.parent-dashboard-v3 .parent-hero-card,
    body.parent-dashboard-v3 .parent-module-card,
    body.parent-dashboard-v3 .parent-settings-card,
    body.parent-dashboard-v3 .parent-inline-panel,
    body.parent-dashboard-v3 .parent-danger-card {
        border-radius: 14px;
        padding: 16px;
    }

    body.parent-dashboard-v3 .parent-hero-inner {
        align-items: center;
    }

    body.parent-dashboard-v3 .parent-hero-avatar {
        width: 56px;
        height: 56px;
    }

    body.parent-dashboard-v3 .parent-title-row h2 {
        font-size: 1.35rem;
    }

    body.parent-dashboard-v3 .hero-call-btn {
        min-height: 42px;
        padding: 0 12px;
        font-size: 0.86rem;
    }

    body.parent-dashboard-v3 .parent-stat-grid,
    body.parent-dashboard-v3 .parent-dashboard-grid-cards,
    body.parent-dashboard-v3 .quick-actions-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    body.parent-dashboard-v3 .parent-dashboard-grid-top {
        grid-template-columns: 1fr;
    }

    body.parent-dashboard-v3 .parent-stat-card {
        min-height: 150px;
        padding: 16px;
    }

    body.parent-dashboard-v3 .parent-dashboard-grid {
        gap: 12px;
        margin-bottom: 12px;
    }

    body.parent-dashboard-v3 .parent-overview-stack,
    body.parent-dashboard-v3 .parent-alerts-module,
    body.parent-dashboard-v3 .parent-activity-module,
    body.parent-dashboard-v3 #caregivers-section,
    body.parent-dashboard-v3 #questions-card,
    body.parent-dashboard-v3 #care-section {
        grid-column: auto;
    }

    body.parent-dashboard-v3 .detail-alert-card {
        grid-column: 1 / -1;
    }

    body.parent-dashboard-v3 .detail-alert-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    body.parent-dashboard-v3 .settings-grid {
        grid-template-columns: 1fr;
    }

    body.parent-dashboard-v3 .settings-head,
    body.parent-dashboard-v3 .setting-row,
    body.parent-dashboard-v3 .setting-toggle-row {
        align-items: flex-start;
    }

    body.parent-dashboard-v3 .settings-head {
        flex-direction: column;
    }

    body.parent-dashboard-v3 .settings-actions {
        width: 100%;
        justify-content: stretch;
    }

    body.parent-dashboard-v3 .settings-actions .btn {
        flex: 1;
    }
}

@media (max-width: 560px) {
    body.parent-dashboard-v3 .parent-hero-inner {
        flex-direction: column;
        align-items: stretch;
    }

    body.parent-dashboard-v3 .hero-call-btn {
        width: 100%;
    }

    body.parent-dashboard-v3 .parent-stat-card {
        min-height: 138px;
    }

    body.parent-dashboard-v3 .parent-stat-card .stat-icon {
        width: 44px;
        height: 44px;
    }

    body.parent-dashboard-v3 .parent-dashboard-grid-cards {
        grid-template-columns: 1fr;
    }

    body.parent-dashboard-v3 .module-head {
        gap: 10px;
    }

    body.parent-dashboard-v3 .quick-action {
        min-height: 54px;
        font-size: 0.9rem;
    }

    body.parent-dashboard-v3 .setting-row {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    body.parent-dashboard-v3 .setting-row .input,
    body.parent-dashboard-v3 .setting-row .input-with-unit,
    body.parent-dashboard-v3 .settings-group select,
    body.parent-dashboard-v3 .settings-group .input-with-unit,
    body.parent-dashboard-v3 .settings-group input[type="time"],
    body.parent-dashboard-v3 .settings-group input[type="number"],
    body.parent-dashboard-v3 .settings-group input[type="datetime-local"] {
        max-width: none;
        width: 100%;
    }
}
