:root {
    --primary-color: #06B6D4; /* Vibrant Cyan Teal */
    --primary-hover: #0891B2;
    --primary-gradient: linear-gradient(135deg, #00D2D3 0%, #06B6D4 50%, #0284C7 100%);
    --primary-glass: rgba(6, 182, 212, 0.16);
    --secondary-color: #0E7490; /* Deep Teal Cyan */
    --bg-color: #ECFEFF; /* Soft Cyan/Teal Tint */
    --card-bg: rgba(255, 255, 255, 0.82);
    --glass-bg: rgba(255, 255, 255, 0.78);
    --glass-border: rgba(255, 255, 255, 0.9);
    --glass-shadow: 0 8px 32px 0 rgba(6, 182, 212, 0.18);
    --text-main: #0F172A;
    --text-muted: #64748B;
    --danger-color: #EF4444;
    --danger-light: rgba(254, 226, 226, 0.8);
    --warning-color: #F59E0B;
    --warning-light: rgba(254, 243, 199, 0.8);
    --success-color: #10B981;
    --success-light: rgba(209, 250, 229, 0.8);
    --border-color: rgba(165, 243, 252, 0.7);
    --shadow-sm: 0 2px 8px 0 rgba(6, 182, 212, 0.08);
    --shadow-md: 0 8px 24px -4px rgba(6, 182, 212, 0.16), 0 4px 8px -2px rgba(0, 0, 0, 0.04);
    --radius-md: 16px;
    --radius-lg: 22px;
    --font-family: 'Prompt', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
    font-family: var(--font-family); 
    font-size: 16px; 
    background: linear-gradient(135deg, #ECFEFF 0%, #E0F2FE 50%, #F0FDFA 100%);
    background-attachment: fixed;
    color: var(--text-main); 
    line-height: 1.6; 
    -webkit-font-smoothing: antialiased; 
    min-height: 100vh;
}
.container { max-width: 600px; margin: 0 auto; padding: 15px; }

/* HEADER */
.app-header { 
    background: linear-gradient(135deg, rgba(0, 210, 211, 0.92) 0%, rgba(6, 182, 212, 0.94) 50%, rgba(2, 132, 199, 0.92) 100%); 
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: white; 
    padding: 16px 15px; 
    text-align: center; 
    border-bottom-left-radius: 24px; 
    border-bottom-right-radius: 24px; 
    box-shadow: 0 8px 24px rgba(6, 182, 212, 0.3); 
    border-bottom: 1.5px solid rgba(255, 255, 255, 0.4);
    display: none; 
}
.app-header h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: 5px; text-shadow: 1px 1px 3px rgba(0,0,0,0.2); }
.app-header .subtitle { font-size: 0.95rem; opacity: 0.95; font-weight: 500; }

/* VIEWS */
.view { display: none; animation: fadeIn 0.25s ease-in-out; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* GLASSMORPHISM CARDS */
.card { 
    background: var(--glass-bg); 
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-radius: var(--radius-lg); 
    padding: 20px; 
    box-shadow: var(--glass-shadow); 
    margin-bottom: 20px; 
    border: 1.5px solid var(--glass-border); 
}
.login-card { text-align: center; padding: 40px 20px; margin-top: 40px; }
.login-card h2 { margin-bottom: 10px; color: var(--primary-color); font-size: 1.5rem; font-weight: 700; }
.login-card p { color: var(--text-muted); margin-bottom: 25px; font-size: 1rem; }

/* TYPOGRAPHY & UTILS */
.section-title { 
    font-size: 1.15rem; 
    font-weight: 600; 
    color: #FFFFFF; 
    background: linear-gradient(90deg, #00D2D3 0%, #06B6D4 50%, #0284C7 100%); 
    margin: -20px -20px 15px -20px; 
    padding: 13px 20px; 
    border-top-left-radius: var(--radius-lg); 
    border-top-right-radius: var(--radius-lg); 
    display: flex; 
    align-items: center; 
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.25); 
}
.header-action { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; margin-top: 10px; padding: 0 5px; }
.header-action h2 { font-size: 1.3rem; font-weight: 700; color: var(--text-main); }
.mt-2 { margin-top: 10px; }
.help-text { font-size: 0.85rem; color: var(--text-muted); margin-top: 5px; }
.text-danger { color: var(--danger-color); }
.text-primary { color: var(--primary-color); }

/* FORMS */
.form-group { margin-bottom: 15px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 8px; color: var(--text-main); font-size: 0.95rem; }
.form-control { 
    width: 100%; 
    padding: 12px 15px; 
    border: 1.5px solid rgba(165, 243, 252, 0.8); 
    border-radius: var(--radius-md); 
    font-family: inherit; 
    font-size: 1rem; 
    line-height: 1.5; 
    transition: all 0.25s ease; 
    background-color: rgba(255, 255, 255, 0.85); 
    backdrop-filter: blur(8px);
}
select.form-control, select { padding: 10px 14px; min-height: 50px; height: auto !important; line-height: 1.5 !important; font-family: 'Prompt', 'Sarabun', sans-serif; }
select option { padding: 8px 12px; font-size: 1rem; line-height: 1.5; }
.form-control:focus { 
    outline: none; 
    border-color: var(--primary-color); 
    box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.2); 
    background-color: #FFFFFF; 
}
.form-control-lg { padding: 12px 15px; font-size: 1.05rem; }
.input-readonly { background-color: rgba(241, 245, 249, 0.8); font-weight: 600; text-align: center; }

/* GRID ROWS */
.form-row { display: flex; gap: 10px; margin-bottom: 15px; }
.form-row .half { flex: 1; margin-bottom: 0; }
.date-picker-row select { flex: 1; }

/* BUTTONS */
.btn { display: inline-flex; justify-content: center; align-items: center; padding: 12px 20px; font-family: inherit; font-size: 1rem; font-weight: 600; border: none; border-radius: var(--radius-md); cursor: pointer; transition: all 0.2s; text-align: center; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { 
    background: linear-gradient(135deg, #00D2D3 0%, #06B6D4 50%, #0284C7 100%); 
    color: white; 
    box-shadow: 0 6px 18px rgba(6, 182, 212, 0.35); 
    border: 1px solid rgba(255, 255, 255, 0.3);
}
.btn-primary:hover:not(:disabled) { 
    background: linear-gradient(135deg, #00B4B5 0%, #0891B2 50%, #0369A1 100%); 
    transform: translateY(-2px); 
    box-shadow: 0 8px 22px rgba(6, 182, 212, 0.45);
}
.btn-outline { background-color: rgba(255, 255, 255, 0.7); border: 1.5px solid var(--border-color); color: var(--text-main); backdrop-filter: blur(8px); }
.btn-outline:hover { background-color: #FFFFFF; }
.btn-block { width: 100%; }
.btn-lg { padding: 16px; font-size: 1.1rem; }
.btn-sm { padding: 8px 12px; font-size: 0.9rem; }
.btn-pulse { animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0.45); } 70% { box-shadow: 0 0 0 12px rgba(6, 182, 212, 0); } 100% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0); } }

/* TARGET CARDS */
.target-list { display: flex; flex-direction: column; gap: 12px; }
.target-card { 
    background: rgba(255, 255, 255, 0.85); 
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-md); 
    padding: 16px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    box-shadow: 0 4px 16px rgba(6, 182, 212, 0.08); 
    border: 1.5px solid rgba(255, 255, 255, 0.9); 
    border-left: 6px solid transparent; 
    transition: all 0.25s ease; 
}
.target-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.target-card.pending { border-left-color: var(--warning-color); }
.target-card.screened { border-left-color: var(--success-color); }
.target-info h4 { margin-bottom: 5px; font-size: 1.15rem; font-weight: 700; color: var(--text-main); }
.target-info p { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 8px; }

/* BADGES */
.badge { display: inline-block; padding: 5px 10px; border-radius: 10px; font-size: 0.8rem; font-weight: 600; box-shadow: inset 0 1px 2px rgba(255,255,255,0.5); backdrop-filter: blur(4px); }
.badge-warning { background-color: var(--warning-light); color: #92400E; border: 1px solid #FDE68A; }
.badge-success { background-color: var(--success-light); color: #065F46; border: 1px solid #A7F3D0; }
.badge-danger { background-color: var(--danger-light); color: #991B1B; border: 1px solid #FECACA; }
.badge-gray { background-color: rgba(243, 244, 246, 0.8); color: #374151; border: 1px solid #E5E7EB; }

/* STATS */
.stats-card { 
    display: flex; 
    background: rgba(255, 255, 255, 0.8); 
    backdrop-filter: blur(14px);
    border-radius: var(--radius-lg); 
    padding: 20px 15px; 
    margin-bottom: 25px; 
    box-shadow: var(--shadow-md); 
    justify-content: space-around; 
    text-align: center; 
    border: 1.5px solid rgba(255, 255, 255, 0.9); 
}
.stat-item { display: flex; flex-direction: column; }
.stat-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--primary-color); line-height: 1; }
.stat-success .stat-value { color: var(--success-color); }
.stat-warning .stat-value { color: var(--warning-color); }

/* CUSTOM RADIO/CHECKBOX */
.radio-group, .checkbox-group { display: flex; flex-direction: column; gap: 10px; }
.radio-group { flex-direction: row; }
.radio-card { flex: 1; border: 1.5px solid rgba(165, 243, 252, 0.8); border-radius: var(--radius-md); padding: 10px; text-align: center; cursor: pointer; transition: all 0.2s; background: rgba(255, 255, 255, 0.7); backdrop-filter: blur(8px); }
.radio-card input { display: none; }
.radio-card span { font-weight: 500; color: var(--text-muted); }
.radio-card:has(input:checked) { background: #ECFEFF; border-color: var(--primary-color); }
.radio-card:has(input:checked) span { color: var(--primary-color); font-weight: 700; }
.checkbox-item { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1.5px solid rgba(165, 243, 252, 0.8); border-radius: var(--radius-md); background: rgba(255, 255, 255, 0.7); }
.checkbox-item input { width: 18px; height: 18px; accent-color: var(--primary-color); }

/* AGE DISPLAY */
.age-display-box { background: linear-gradient(135deg, #ECFEFF 0%, #CFFAFE 100%); border-radius: var(--radius-md); padding: 15px; text-align: center; font-weight: 600; color: #0891B2; font-size: 1.1rem; margin-top: 15px; border: 1.5px dashed #22D3EE; box-shadow: 0 4px 12px rgba(6, 182, 212, 0.12); }
.age-number { font-size: 1.5rem; font-weight: 700; }

/* PERSON INFO CARD */
.person-info-card { background: rgba(255, 255, 255, 0.85); border-left: 5px solid var(--primary-color); padding: 15px 20px; }
.person-name { font-size: 1.2rem; color: var(--text-main); margin-bottom: 5px; }
.person-meta { display: flex; gap: 10px; flex-wrap: wrap; }

/* SPECIFIC SECTIONS */
.locked-content { display: none; }
.measurement-box { background: rgba(255, 255, 255, 0.8); padding: 15px; border-radius: var(--radius-md); margin-bottom: 15px; border: 1.5px solid rgba(165, 243, 252, 0.6); backdrop-filter: blur(8px); }
.result-badge { margin-top: 10px; padding: 10px; text-align: center; border-radius: var(--radius-md); font-weight: 600; font-size: 1rem; }
.total-score-box { background: rgba(255, 255, 255, 0.8); border: 1.5px solid #BAE6FD; padding: 15px; text-align: center; border-radius: var(--radius-md); margin-top: 15px; }
.total-score-box strong { font-size: 1.5rem; color: var(--primary-color); }

/* ALERTS & LOADING */
.alert { padding: 15px; border-radius: var(--radius-md); font-weight: 500; margin-bottom: 15px; display: flex; gap: 10px; backdrop-filter: blur(8px); }
.alert-danger { background-color: var(--danger-light); color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background-color: var(--warning-light); color: #92400E; }
.alert-success { background-color: var(--success-light); color: #065F46; }
.loading-text { text-align: center; padding: 30px; color: var(--text-muted); font-style: italic; }

/* BOTTOM NAVIGATION (VIBRANT CYAN TEAL GLASSMORPHISM) */
.bottom-nav { 
    position: fixed; 
    bottom: 12px; 
    left: 50%; 
    transform: translateX(-50%); 
    width: calc(100% - 24px); 
    max-width: 440px; 
    background: rgba(255, 255, 255, 0.85); 
    display: flex; 
    justify-content: space-around; 
    align-items: center;
    padding: 8px 10px; 
    box-shadow: 0 12px 36px rgba(6, 182, 212, 0.22), 0 4px 12px rgba(0,0,0,0.05); 
    z-index: 1000; 
    border: 1.5px solid rgba(255, 255, 255, 0.9); 
    border-radius: 28px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
.nav-item { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    background: transparent; 
    border: none; 
    padding: 8px 4px; 
    cursor: pointer; 
    color: #94A3B8; 
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1); 
    border-radius: 20px; 
    margin: 0 3px; 
}
.nav-item.active { 
    color: #ffffff; 
    background: linear-gradient(135deg, #00D2D3 0%, #06B6D4 50%, #0284C7 100%); 
    box-shadow: 0 6px 18px rgba(6, 182, 212, 0.42);
}
.nav-item.active .nav-icon { 
    transform: translateY(-1px) scale(1.1); 
}
.nav-item.active .nav-icon svg {
    stroke: #ffffff;
}
.nav-icon { 
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 3px; 
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1); 
}
.nav-icon svg {
    width: 24px;
    height: 24px;
    stroke: #64748B;
    transition: stroke 0.25s ease;
}
.nav-text { 
    font-size: 0.78rem; 
    font-weight: 700; 
    font-family: var(--font-family); 
    letter-spacing: 0.2px;
}

/* DASHBOARD GRIDS */
.dashboard-grid { display: grid; grid-template-columns: 1fr; gap: 20px; margin-bottom: 20px; }
.chart-card h3 { font-size: 1rem; margin-bottom: 15px; text-align: center; color: var(--text-main); }
.chart-container { position: relative; width: 100%; max-height: 250px; }

/* Progress Bars */
.progress-item { margin-bottom: 15px; }
.progress-header { display: flex; justify-content: space-between; font-size: 0.9rem; margin-bottom: 5px; font-weight: 500; }
.progress-bar-bg { width: 100%; height: 10px; background-color: #E5E7EB; border-radius: 5px; overflow: hidden; }
.progress-bar-fill { height: 100%; background-color: var(--primary-color); border-radius: 5px; transition: width 1s ease-in-out; }

/* ADL Card UI (Matching Screenshot) */
.adl-item-card {
    background: #FFFFFF;
    border: 1.5px solid #E2E8F0;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
}
.adl-item-title {
    font-size: 15px;
    font-weight: 700;
    color: #1E293B;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.adl-radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.adl-option-card {
    display: flex;
    align-items: center;
    background: #FFFFFF;
    border: 1.5px solid #CBD5E1;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #334155;
    cursor: pointer;
    transition: all 0.2s ease;
}
.adl-option-card:hover {
    border-color: #94A3B8;
    background: #F8FAFC;
}
.adl-option-card input[type="radio"] {
    margin-right: 12px;
    accent-color: #4F46E5;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.adl-option-card:has(input:checked) {
    border-color: #4F46E5;
    background: #F0FDF9;
    color: #4F46E5;
    font-weight: 600;
    box-shadow: 0 0 0 1px #4F46E5;
}

/* Responsive Grid for Desktop & Mobile Edge-to-Edge */
@media (min-width: 768px) {
    .container { max-width: 800px; }
    .dashboard-grid { grid-template-columns: 1fr 1fr; }
    .bottom-nav { max-width: 440px; left: 50%; transform: translateX(-50%); }
    .login-wrapper-card {
        border-radius: 28px;
        box-shadow: 0 16px 36px rgba(2, 132, 199, 0.15);
        border: 1px solid #E0F2FE;
        overflow: hidden;
        max-width: 420px;
        margin: 10px auto;
    }
}

@media (max-width: 767px) {
    html, body {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow-x: hidden;
        background: linear-gradient(135deg, #ECFEFF 0%, #E0F2FE 50%, #F0FDFA 100%) !important;
    }
    .container {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    .app-header {
        border-radius: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 14px 16px !important;
    }
    .vhv-banner-card {
        border-radius: 0 0 20px 20px !important;
        margin: 0 0 14px 0 !important;
        padding: 16px !important;
        width: 100% !important;
    }
    .search-bar {
        padding: 0 12px !important;
        margin-bottom: 12px !important;
    }
    #vhv-summary-stats {
        padding: 0 12px !important;
        margin: 12px 0 16px 0 !important;
    }
    #target-list-container {
        padding: 0 10px !important;
    }
    .bottom-nav {
        width: 100% !important;
        max-width: 100% !important;
        bottom: 0 !important;
        left: 0 !important;
        transform: none !important;
        border-radius: 20px 20px 0 0 !important;
        border-top: 1.5px solid rgba(255, 255, 255, 0.9) !important;
        padding: 6px 8px 14px 8px !important;
        background: rgba(255, 255, 255, 0.9) !important;
        backdrop-filter: blur(16px) !important;
    }
    #view-login {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        min-height: 100vh;
    }
    .login-wrapper-card {
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        width: 100% !important;
    }
    .login-top-section {
        width: 100% !important;
        padding: 24px 16px 18px !important;
    }
    .login-bottom-section {
        flex: 1;
        width: 100% !important;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 22px 20px 28px !important;
    }
    #view-target-list, #view-screening, #view-dashboard, #view-followup-list, #view-followup-form, #view-report {
        padding: 0 0 90px 0 !important;
        width: 100% !important;
    }
}

/* ==========================================
   Hide Netlify Drawer & Floating Badge
   ========================================== */
#nl-badge-frame,
iframe#nl-badge-frame,
iframe[title*="Netlify"],
iframe[title*="Powered by Netlify"],
#netlify-modal-bg,
.netlify-badge,
[data-netlify-deploy-id],
iframe[src*="netlify"],
div[class*="netlify-drawer"],
#netlify-drawer-root,
netlify-drawer,
div[class*="nl-"],
[id*="nl-badge"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    width: 0 !important;
    height: 0 !important;
    max-width: 0 !important;
    max-height: 0 !important;
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    z-index: -999999 !important;
}

/* Modal Follow-up Detail Table Formatting */
#modal-village-followup-detail table th,
#modal-village-followup-detail table td {
    white-space: nowrap !important;
}
#modal-village-followup-detail table td:nth-child(2) {
    white-space: normal !important;
}
#modal-village-followup-detail .progress-header > * {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spin-icon {
    display: inline-block;
    animation: spin 0.8s linear infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.35; transform: scale(0.8); }
}

.pulse-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 6px #22c55e;
    animation: pulse-dot 2s infinite ease-in-out;
    vertical-align: middle;
}
