/* ============================================
   MAMATRACK — Styles (Rose Theme + Glassmorphism)
   Ghana ANC Register + DSS
   ============================================ */

/* ─────────────────────────────────────────────
   CSS Variables
   ───────────────────────────────────────────── */
:root {
    /* Brand Colors - Rose Theme */
    --primary: #9C2760;
    --primary-lt: #C7537E;
    --primary-dark: #6B1440;
    --primary-bg: #FDF0F5;
    
    /* Glass effects */
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px rgba(156, 39, 96, 0.12);
    
    /* Semantic Colors */
    --success: #059669;
    --success-bg: #ECFDF5;
    --warning: #D97706;
    --warning-bg: #FFFBEB;
    --danger: #DC2626;
    --danger-bg: #FEF2F2;
    --info: #0284C7;
    --info-bg: #F0F9FF;

    /* Neutrals */
    --text: #1F2937;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --border: rgba(229, 231, 235, 0.8);
    --border-lt: rgba(243, 244, 246, 0.8);
    --bg: rgba(255, 255, 255, 0.9);
    --bg-alt: rgba(249, 250, 251, 0.9);
    --bg-dark: #F3F4F6;

    /* Risk Levels */
    --risk-low: #059669;
    --risk-low-bg: #ECFDF5;
    --risk-mod: #D97706;
    --risk-mod-bg: #FFF7ED;
    --risk-high: #DC2626;
    --risk-high-bg: #FEF2F2;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(156, 39, 96, 0.05);
    --shadow-md: 0 4px 12px rgba(156, 39, 96, 0.1);
    --shadow-lg: 0 10px 25px rgba(156, 39, 96, 0.15);

    /* Safe Areas */
    --safe-top: env(safe-area-inset-top);
    --safe-bottom: env(safe-area-inset-bottom);
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text);
    background: linear-gradient(135deg, #FDF0F5 0%, #F8E1EA 30%, #FCE4EC 60%, #FFF0F5 100%);
    background-attachment: fixed;
    min-height: 100vh;
    min-height: 100dvh;
    overscroll-behavior: none;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 30% 20%, rgba(199, 83, 126, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(156, 39, 96, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ─────────────────────────────────────────────
   App Header
   ───────────────────────────────────────────── */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    padding-top: calc(var(--safe-top) + var(--space-md));
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 20px rgba(156, 39, 96, 0.25);
}

.header-brand {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-brand svg {
    width: 28px;
    height: 28px;
}

.header-title {
    flex: 1;
    font-size: 1.125rem;
    font-weight: 600;
}

.header-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-full);
    color: white;
    cursor: pointer;
    transition: background 0.2s;
}

.header-btn:hover {
    background: rgba(255,255,255,0.15);
}

.header-btn svg {
    width: 22px;
    height: 22px;
}

.header-actions {
    display: flex;
    gap: var(--space-xs);
}

/* ─────────────────────────────────────────────
   App Main Content
   ───────────────────────────────────────────── */
.app-main {
    flex: 1;
    padding: var(--space-md);
    padding-bottom: calc(70px + var(--safe-bottom) + var(--space-md));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ─────────────────────────────────────────────
   App Navigation
   ───────────────────────────────────────────── */
.app-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    justify-content: space-around;
    padding: var(--space-sm);
    padding-bottom: calc(var(--safe-bottom) + var(--space-sm));
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    box-shadow: 0 -4px 20px rgba(156, 39, 96, 0.08);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-xs) var(--space-sm);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-item svg {
    width: 22px;
    height: 22px;
}

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

.nav-item.active svg {
    color: var(--primary);
}

/* ─────────────────────────────────────────────
   Auth Screen
   ───────────────────────────────────────────── */
.auth-screen {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.auth-logo {
    text-align: center;
    color: white;
    margin-bottom: var(--space-xl);
}

.auth-logo svg {
    width: 72px;
    height: 72px;
    margin-bottom: var(--space-md);
}

.auth-logo h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: var(--space-xs);
}

.auth-logo p {
    opacity: 0.8;
    font-size: 0.9rem;
}

.auth-form {
    width: 100%;
    max-width: 320px;
    padding: var(--space-lg);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--glass-border);
}

.auth-hint {
    margin-top: var(--space-md);
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.pin-input {
    font-size: 1.5rem;
    letter-spacing: 0.5em;
    text-align: center;
    padding: var(--space-md);
    font-family: monospace;
}

/* Auth Mode Tabs */
.auth-tabs {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-lg);
    background: var(--bg);
    border-radius: var(--radius-md);
    padding: var(--space-xs);
    width: 100%;
    max-width: 320px;
}

.auth-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-tab:hover {
    background: var(--bg-elevated);
}

.auth-tab.active {
    background: var(--primary);
    color: white;
}

.auth-tab svg {
    width: 18px;
    height: 18px;
}

.auth-footer {
    margin-top: var(--space-xl);
    text-align: center;
    color: rgba(255,255,255,0.7);
}

/* ─────────────────────────────────────────────
   Forms — Mobile-First Vertical Layout
   ───────────────────────────────────────────── */
.form-section {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
    border: 1px solid rgba(255,255,255,0.3);
    box-shadow: var(--shadow-md);
}

.form-group {
    margin-bottom: var(--space-lg);
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: var(--space-sm);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-input {
    width: 100%;
    padding: 16px 18px;
    font-size: 1rem;
    color: var(--text);
    background: rgba(255,255,255,0.9);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    transition: all 0.25s ease;
    box-shadow: 0 2px 8px rgba(156, 39, 96, 0.06);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px var(--primary-bg), 0 4px 12px rgba(156, 39, 96, 0.12);
    transform: translateY(-1px);
}

.form-input::placeholder {
    color: var(--text-muted);
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%239C2760' d='M8 10L3 5h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 44px;
    cursor: pointer;
}

textarea.form-input {
    resize: vertical;
    min-height: 100px;
    line-height: 1.6;
}

/* Single column by default for mobile */
.form-row {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

/* Two columns on larger screens */
@media (min-width: 480px) {
    .form-row {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-row.cols-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .form-row.cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 640px) {
    .form-row.cols-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Pill/Chip Selection — Tap-Friendly */
.pill-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.pill-option {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    min-width: 60px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(255,255,255,0.8);
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.pill-option:hover {
    border-color: var(--primary-lt);
    background: white;
}

.pill-option:active {
    transform: scale(0.96);
}

.pill-option.selected {
    color: white;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(156, 39, 96, 0.3);
}

.pill-option input[type="radio"],
.pill-option input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* Toggle Pills (Yes/No) */
.toggle-pills {
    display: flex;
    gap: var(--space-sm);
}

.toggle-pills .pill-option {
    flex: 1;
    text-align: center;
}

/* Checkbox Cards */
.checkbox-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 16px;
    background: rgba(255,255,255,0.8);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.checkbox-item:hover {
    border-color: var(--primary-lt);
    background: white;
}

.checkbox-item:active {
    transform: scale(0.98);
}

.checkbox-item.checked,
.checkbox-item:has(input:checked) {
    background: linear-gradient(135deg, var(--primary-bg) 0%, #FCE4EC 100%);
    border-color: var(--primary);
}

.checkbox-item input[type="checkbox"] {
    width: 24px;
    height: 24px;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.checkbox-item span {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text);
}

/* Input with button */
.input-with-btn {
    display: flex;
    gap: var(--space-sm);
}

.input-with-btn .form-input {
    flex: 1;
}

/* Section Labels */
.section-label {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: var(--space-lg) 0 var(--space-md);
    padding-left: var(--space-sm);
}

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

/* ─────────────────────────────────────────────
   Buttons — Mobile-Optimized
   ───────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 14px 24px;
    min-height: 52px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.97);
}

.btn svg {
    width: 20px;
    height: 20px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(156, 39, 96, 0.25);
}

.btn-primary:hover {
    box-shadow: 0 6px 16px rgba(156, 39, 96, 0.35);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: scale(0.97) translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: var(--text);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    background: white;
    border-color: var(--primary-lt);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #047857 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #B91C1C 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}

.btn-danger:hover {
    box-shadow: 0 6px 16px rgba(220, 38, 38, 0.35);
}

.btn-danger-outline {
    background: transparent;
    color: var(--danger);
    border: 2px solid var(--danger);
}

.btn-danger-outline:hover {
    background: var(--danger-bg);
}

.btn-ghost {
    background: transparent;
    color: var(--primary);
    padding: 10px 16px;
    min-height: auto;
}

.btn-ghost:hover {
    background: var(--primary-bg);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.875rem;
}

.btn-sm svg {
    width: 16px;
    height: 16px;
}

/* FAB */
.fab {
    position: fixed;
    right: var(--space-md);
    bottom: calc(80px + var(--safe-bottom));
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 50;
    transition: transform 0.2s;
}

.fab:hover {
    transform: scale(1.05);
}

.fab svg {
    width: 24px;
    height: 24px;
}

/* ─────────────────────────────────────────────
   Cards
   ───────────────────────────────────────────── */
.card {
    background: var(--bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-body {
    padding: var(--space-md);
}

.card-header {
    padding: var(--space-md);
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border-lt);
    font-weight: 600;
}

.card-accent {
    border: 2px solid var(--primary);
    background: linear-gradient(135deg, rgba(229, 62, 62, 0.05) 0%, rgba(255, 255, 255, 1) 100%);
}

/* ─────────────────────────────────────────────
   Access Code Section
   ───────────────────────────────────────────── */
.access-code-section {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
}

.access-code-display {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

.access-code-value {
    font-family: 'Courier New', monospace;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 0.1em;
}

.access-code-actions {
    display: flex;
    gap: var(--space-sm);
}

.access-code-hint {
    margin-top: var(--space-sm);
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0;
}

.input-with-btn {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.input-with-btn .form-input {
    flex: 1;
    font-family: monospace;
}

/* ─────────────────────────────────────────────
   Facility Banner
   ───────────────────────────────────────────── */
.facility-banner {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-lt) 100%);
    border-radius: var(--radius-lg);
    color: white;
    margin-bottom: var(--space-md);
}

.banner-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.2);
    border-radius: var(--radius-full);
}

.banner-icon svg {
    width: 28px;
    height: 28px;
}

.banner-text {
    flex: 1;
}

.banner-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.banner-sub {
    opacity: 0.85;
    font-size: 0.875rem;
}

/* Report Facility Banner */
.report-facility-banner {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-lt) 100%);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    color: white;
    text-align: center;
    margin-bottom: var(--space-md);
}

.banner-header {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.85;
}

.report-facility-banner .banner-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: var(--space-xs) 0;
}

.banner-meta {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--space-md);
    font-size: 0.875rem;
    opacity: 0.9;
}

.banner-meta span {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.banner-meta svg {
    width: 16px;
    height: 16px;
}

/* ─────────────────────────────────────────────
   Stat Grid
   ───────────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.stat-tile {
    background: var(--bg);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    text-align: center;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.2s;
}

.stat-tile:hover {
    transform: translateY(-2px);
}

.stat-icon {
    margin-bottom: var(--space-xs);
    color: var(--primary);
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.stat-value.danger {
    color: var(--danger);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: var(--space-xs);
}

.stat-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.stat-tile.danger {
    background: var(--danger-bg);
}

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

.stat-tile.warning {
    background: var(--warning-bg);
}

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

.stat-tile.info {
    background: var(--info-bg);
}

.stat-tile.info .stat-icon {
    color: var(--info);
}

/* ─────────────────────────────────────────────
   Action Grid
   ───────────────────────────────────────────── */
.action-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: var(--bg);
    border: 1px solid var(--border-lt);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--primary-bg);
    border-color: var(--primary);
    color: var(--primary);
}

.action-btn svg {
    width: 24px;
    height: 24px;
    color: var(--primary);
}

/* ─────────────────────────────────────────────
   Section Labels
   ───────────────────────────────────────────── */
.section-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin: var(--space-md) 0 var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.section-label .count {
    font-weight: 400;
    color: var(--text-muted);
}

.section-label.text-danger {
    color: var(--danger);
}

.section-label.text-warning {
    color: var(--warning);
}

.section-label.text-info {
    color: var(--info);
}

/* ─────────────────────────────────────────────
   List Group
   ───────────────────────────────────────────── */
.list-group {
    background: var(--bg);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.list-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-lt);
    cursor: pointer;
    transition: background 0.2s;
}

.list-item:last-child {
    border-bottom: none;
}

.list-item:hover {
    background: var(--bg-alt);
}

.list-avatar {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
}

.list-avatar svg {
    width: 22px;
    height: 22px;
}

.list-avatar.risk-low {
    background: var(--risk-low-bg);
    color: var(--risk-low);
}

.list-avatar.risk-mod {
    background: var(--risk-mod-bg);
    color: var(--risk-mod);
}

.list-avatar.risk-high {
    background: var(--risk-high-bg);
    color: var(--risk-high);
}

.list-content {
    flex: 1;
    min-width: 0;
}

.list-title {
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.list-meta {
    text-align: right;
}

.list-meta small {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ─────────────────────────────────────────────
   Badges
   ───────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    text-transform: uppercase;
}

.badge-low {
    background: var(--risk-low-bg);
    color: var(--risk-low);
}

.badge-mod {
    background: var(--risk-mod-bg);
    color: var(--risk-mod);
}

.badge-high {
    background: var(--risk-high-bg);
    color: var(--risk-high);
}

/* ─────────────────────────────────────────────
   Patient Header
   ───────────────────────────────────────────── */
.patient-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg);
    background: var(--bg);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-sm);
}

.patient-header.risk-high {
    border-left: 4px solid var(--risk-high);
}

.patient-header.risk-mod {
    border-left: 4px solid var(--risk-mod);
}

.patient-header.risk-low {
    border-left: 4px solid var(--risk-low);
}

.patient-avatar {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-bg);
    border-radius: var(--radius-full);
    color: var(--primary);
}

.patient-avatar svg {
    width: 28px;
    height: 28px;
}

.patient-info {
    flex: 1;
}

.patient-info h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.patient-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.risk-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.risk-badge.badge-high {
    background: var(--risk-high-bg);
    color: var(--risk-high);
}

.risk-badge.badge-mod {
    background: var(--risk-mod-bg);
    color: var(--risk-mod);
}

.risk-badge.badge-low {
    background: var(--risk-low-bg);
    color: var(--risk-low);
}

.risk-score {
    font-size: 1.5rem;
    line-height: 1;
    margin-top: 2px;
}

/* Patient Mini Header */
.patient-mini-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    background: var(--primary-bg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
}

.patient-mini-header strong {
    color: var(--primary-dark);
}

.patient-mini-header span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ─────────────────────────────────────────────
   Detail Grid
   ───────────────────────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
}

.detail-grid.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.detail-item {
    display: flex;
    flex-direction: column;
}

.detail-item.span-2 {
    grid-column: span 2;
}

.detail-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.detail-value {
    font-weight: 500;
    color: var(--text);
}

.detail-value.text-danger {
    color: var(--danger);
    font-weight: 600;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border-lt);
}

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

/* ─────────────────────────────────────────────
   DSS Alerts
   ───────────────────────────────────────────── */
.dss-alerts {
    margin-bottom: var(--space-md);
}

.alert-card {
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
}

.alert-card.danger {
    background: var(--danger-bg);
    border-left: 4px solid var(--danger);
}

.alert-card.warning {
    background: var(--warning-bg);
    border-left: 4px solid var(--warning);
}

.alert-card.info {
    background: var(--info-bg);
    border-left: 4px solid var(--info);
}

.alert-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-xs);
}

.alert-header svg {
    width: 18px;
    height: 18px;
}

.alert-card.danger .alert-header {
    color: var(--danger);
}

.alert-card.warning .alert-header {
    color: var(--warning);
}

.alert-card.info .alert-header {
    color: var(--info);
}

.alert-card p {
    font-size: 0.875rem;
    color: var(--text);
}

/* ─────────────────────────────────────────────
   Risk List
   ───────────────────────────────────────────── */
.risk-list {
    list-style: none;
}

.risk-list li {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-xs) 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.risk-list li svg {
    width: 14px;
    height: 14px;
    color: var(--danger);
    flex-shrink: 0;
    margin-top: 4px;
}

/* Risk Bar */
.risk-bar {
    display: flex;
    height: 8px;
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--space-md);
}

.risk-segment {
    transition: flex 0.3s;
}

.risk-segment.low {
    background: var(--risk-low);
}

.risk-segment.mod {
    background: var(--risk-mod);
}

.risk-segment.high {
    background: var(--risk-high);
}

.risk-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    margin-right: var(--space-xs);
}

.risk-dot.low {
    background: var(--risk-low);
}

.risk-dot.mod {
    background: var(--risk-mod);
}

.risk-dot.high {
    background: var(--risk-high);
}

/* ─────────────────────────────────────────────
   Visit Timeline
   ───────────────────────────────────────────── */
.visit-timeline {
    position: relative;
    padding-left: 24px;
}

.visit-timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.visit-item {
    position: relative;
    padding: var(--space-md);
    padding-left: var(--space-lg);
    background: var(--bg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    box-shadow: var(--shadow-sm);
}

.visit-marker {
    position: absolute;
    left: -17px;
    top: 20px;
    width: 12px;
    height: 12px;
    background: var(--bg);
    border: 2px solid var(--primary);
    border-radius: var(--radius-full);
}

.visit-item.initial .visit-marker {
    width: 16px;
    height: 16px;
    left: -19px;
    background: var(--primary);
}

.visit-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.visit-title {
    font-weight: 500;
    color: var(--text);
}

.visit-detail {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.visit-detail small {
    opacity: 0.8;
}

/* ─────────────────────────────────────────────
   Action Buttons Row
   ───────────────────────────────────────────── */
.action-buttons {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
}

.action-buttons .btn {
    flex: 1;
}

/* ─────────────────────────────────────────────
   Search & Filters
   ───────────────────────────────────────────── */
.search-bar {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg);
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    margin-bottom: var(--space-md);
}

.search-bar svg {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.search-bar input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 1rem;
    color: var(--text);
}

.search-bar input:focus {
    outline: none;
}

.filter-chips {
    display: flex;
    gap: var(--space-sm);
    overflow-x: auto;
    padding-bottom: var(--space-sm);
    margin-bottom: var(--space-md);
    -webkit-overflow-scrolling: touch;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 6px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

.chip svg {
    width: 14px;
    height: 14px;
}

.chip:hover {
    background: var(--bg-alt);
}

.chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* ─────────────────────────────────────────────
   Reports
   ───────────────────────────────────────────── */
.report-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: var(--bg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
}

.report-header svg {
    width: 20px;
    height: 20px;
    color: var(--primary);
}

.report-header select {
    flex: 1;
}

.pill-tabs {
    display: flex;
    gap: var(--space-xs);
    padding: var(--space-xs);
    background: var(--bg-dark);
    border-radius: var(--radius-full);
    margin-bottom: var(--space-md);
}

.pill {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: none;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.pill.active {
    background: var(--bg);
    color: var(--primary);
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

/* DHIMS Form */
.dhims-section-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) 0;
    font-weight: 600;
    color: var(--primary);
    border-bottom: 1px solid var(--border-lt);
    margin-bottom: var(--space-md);
}

.dhims-section-header svg {
    width: 18px;
    height: 18px;
}

.dhims-subsection {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin: var(--space-md) 0 var(--space-sm);
}

.dhims-subsection svg {
    width: 14px;
    height: 14px;
}

.dhims-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border-lt);
}

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

.dhims-label {
    flex: 1;
    font-size: 0.875rem;
}

.dhims-label small {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.auto-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: var(--space-xs);
    padding: 2px 6px;
    background: #0D9488;
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.6rem;
    font-weight: 600;
    vertical-align: middle;
}

.auto-badge svg {
    width: 10px;
    height: 10px;
}

.dhims-input {
    width: 80px;
    padding: var(--space-sm);
    text-align: center;
    font-size: 1rem;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.dhims-input.auto {
    background: #CCFBF1;
    border-color: #0D9488;
    color: #0D9488;
}

.dhims-input:focus {
    outline: none;
    border-color: var(--primary);
}

.dhims-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
}

.dhims-grid.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.dhims-cell {
    text-align: center;
}

.dhims-cell label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.dhims-cell input {
    width: 100%;
    padding: var(--space-sm);
    text-align: center;
    font-size: 1rem;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.dhims-cell input.auto {
    background: #CCFBF1;
    border-color: #0D9488;
    color: #0D9488;
}

.dhims-legend {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm);
    background: var(--bg-alt);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-md);
    font-size: 0.75rem;
}

.manual-note {
    color: var(--text-muted);
}

/* ─────────────────────────────────────────────
   Alerts Page
   ───────────────────────────────────────────── */
.alert-summary {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.alert-count {
    flex: 1;
    padding: var(--space-md);
    background: var(--bg);
    border-radius: var(--radius-md);
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.alert-count .count {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

.alert-count .label {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.alert-count.danger {
    background: var(--danger-bg);
}

.alert-count.danger .count {
    color: var(--danger);
}

.alert-count.warning {
    background: var(--warning-bg);
}

.alert-count.warning .count {
    color: var(--warning);
}

.alert-count.info {
    background: var(--info-bg);
}

.alert-count.info .count {
    color: var(--info);
}

.alert-item {
    border-left: 4px solid transparent;
}

.alert-item.danger {
    border-left-color: var(--danger);
    background: var(--danger-bg);
}

.alert-item.warning {
    border-left-color: var(--warning);
    background: var(--warning-bg);
}

.alert-flags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-top: var(--space-xs);
}

.flag {
    padding: 2px 6px;
    background: rgba(0,0,0,0.08);
    border-radius: var(--radius-sm);
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.flag.more {
    font-style: italic;
}

/* ─────────────────────────────────────────────
   Alert Banners
   ───────────────────────────────────────────── */
.alert-banner {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
}

.alert-banner svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.alert-banner.info {
    background: var(--info-bg);
    color: var(--info);
}

.alert-banner.info div {
    color: var(--text);
}

.alert-banner.warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.alert-banner.warning div {
    color: var(--text);
}

.alert-banner.mt-3 {
    margin-top: var(--space-md);
}

/* ─────────────────────────────────────────────
   Settings
   ───────────────────────────────────────────── */
.settings-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg);
    background: var(--bg);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-md);
}

.settings-avatar {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-bg);
    border-radius: var(--radius-full);
    color: var(--primary);
}

.settings-avatar svg {
    width: 28px;
    height: 28px;
}

.settings-info h3 {
    font-size: 1.125rem;
}

.settings-info p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.settings-section {
    background: var(--bg);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: var(--space-md);
}

.settings-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-lt);
    cursor: pointer;
    transition: background 0.2s;
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-item:hover {
    background: var(--bg-alt);
}

.settings-item svg {
    width: 22px;
    height: 22px;
    color: var(--text-secondary);
}

.settings-item span {
    flex: 1;
}

.settings-item .caret {
    color: var(--text-muted);
}

.settings-item.danger {
    color: var(--danger);
}

.settings-item.danger svg {
    color: var(--danger);
}

/* ─────────────────────────────────────────────
   Empty State
   ───────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: var(--space-xl) var(--space-lg);
    color: var(--text-secondary);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}

.empty-state p {
    margin-bottom: var(--space-md);
}

.empty-state small {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ─────────────────────────────────────────────
   Toast
   ───────────────────────────────────────────── */
#toast-container {
    position: fixed;
    top: calc(var(--safe-top) + 70px);
    left: var(--space-md);
    right: var(--space-md);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: var(--text);
    color: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    transform: translateY(-20px);
    opacity: 0;
    transition: all 0.3s;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast svg {
    width: 20px;
    height: 20px;
}

.toast-success {
    background: var(--success);
}

.toast-error {
    background: var(--danger);
}

.toast-warning {
    background: var(--warning);
}

/* ─────────────────────────────────────────────
   Modal
   ───────────────────────────────────────────── */
#modal-container {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
}

#modal-container.show {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
}

.modal {
    position: relative;
    width: 100%;
    max-width: 320px;
    background: var(--bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-lt);
}

.modal-header h3 {
    font-size: 1.125rem;
}

.modal-body {
    padding: var(--space-md);
}

.modal-body p {
    color: var(--text-secondary);
}

.modal-footer {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: var(--bg-alt);
}

.modal-footer .btn {
    flex: 1;
}

/* ─────────────────────────────────────────────
   Loading & Spinner
   ───────────────────────────────────────────── */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

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

/* Error */
.error {
    text-align: center;
    padding: var(--space-lg);
    color: var(--danger);
}

.error svg {
    width: 32px;
    height: 32px;
    margin-bottom: var(--space-sm);
}

.error-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    text-align: center;
}

.error-screen svg {
    width: 64px;
    height: 64px;
    color: var(--danger);
    margin-bottom: var(--space-md);
}

/* ─────────────────────────────────────────────
   Animations
   ───────────────────────────────────────────── */
.anim-fade {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ─────────────────────────────────────────────
   Icon Sizing
   ───────────────────────────────────────────── */
svg {
    width: 20px;
    height: 20px;
}

.icon-lg {
    width: 32px;
    height: 32px;
}

.icon-xl {
    width: 48px;
    height: 48px;
}

/* ─────────────────────────────────────────────
   Responsive
   ───────────────────────────────────────────── */
@media (min-width: 640px) {
    .stat-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .action-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .checkbox-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 768px) {
    .app-main {
        max-width: 600px;
        margin: 0 auto;
    }
}

/* ─────────────────────────────────────────────
   Offline Indicator
   ───────────────────────────────────────────── */
.offline-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    padding-top: calc(var(--safe-top) + var(--space-sm));
    background: var(--warning);
    color: white;
    font-size: 0.8rem;
    font-weight: 500;
}

.offline-bar.show {
    display: flex;
}

/* ─────────────────────────────────────────────
   Patient Portal
   ───────────────────────────────────────────── */
.patient-header {
    background: linear-gradient(135deg, #ec4899 0%, #be185d 100%);
}

.patient-portal {
    background: linear-gradient(180deg, #fdf2f8 0%, #fff 100%);
    min-height: 100vh;
}

.patient-portal .card {
    border-left: 4px solid var(--primary);
}

.patient-portal .card-danger {
    border-left-color: var(--error);
    background: #fef2f2;
}

.pregnancy-stats {
    display: flex;
    gap: var(--space-lg);
    justify-content: center;
    padding: var(--space-md) 0;
}

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

.tips-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tips-list li {
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.tips-list li:last-child {
    border-bottom: none;
}

.danger-list {
    list-style: disc;
    padding-left: var(--space-lg);
    margin: var(--space-sm) 0;
}

.danger-list li {
    padding: var(--space-xs) 0;
    color: var(--error);
    font-weight: 500;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

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

body.offline .app-header {
    top: 36px;
}

body.offline .app-main {
    padding-top: calc(var(--space-md) + 36px);
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    :root {
        --text: #F9FAFB;
        --text-secondary: #D1D5DB;
        --text-muted: #9CA3AF;
        --border: #374151;
        --border-lt: #1F2937;
        --bg: #111827;
        --bg-alt: #1F2937;
        --bg-dark: #374151;
    }

    .auth-form {
        background: var(--bg-alt);
    }

    .dhims-input.auto,
    .dhims-cell input.auto {
        background: #134E4A;
        border-color: #0D9488;
    }
}
