/**
 * ລະບົບແບບຟອມປະເມີນມາດຕະຖານຄອບຄົວພົ້ນທຸກ (ດຳລັດ 348/ລບ)
 * Modern, High-Performance, Print-Optimized Stylesheet
 */

:root {
    --primary: #0f4c81;
    --primary-light: #2563eb;
    --primary-dark: #0a3156;
    --primary-bg: #eff6ff;
    
    --success: #10b981;
    --success-dark: #059669;
    --success-bg: #ecfdf5;
    
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --danger-bg: #fef2f2;
    
    --developed: #8b5cf6;
    --developed-bg: #f5f3ff;

    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

    --font-lao: 'Noto Sans Lao', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ================= RESET & BASE ================= */
html {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

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

body {
    font-family: var(--font-lao);
    background-color: #f1f5f9;
    color: var(--gray-800);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    position: relative;
}

.app-layout {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

input, select, textarea, button {
    font-family: inherit;
    font-size: 0.95rem;
}

/* ================= HEADER ================= */
.app-header {
    background: linear-gradient(135deg, #0b2545 0%, #134074 100%);
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(11, 37, 69, 0.18);
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.header-main-bar {
    padding: 0.75rem 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
}

.header-nav-bar {
    background: rgba(11, 37, 69, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 0.45rem 2rem;
    width: 100%;
}

.header-container {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex-shrink: 0;
    min-width: 0;
}

.brand-text-wrap {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.emblem-icon {
    font-size: 2rem;
    line-height: 1;
    flex-shrink: 0;
}

.header-brand h1 {
    font-size: 1.18rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0;
    color: #ffffff;
    white-space: nowrap;
}

.header-brand .subtitle {
    font-size: 0.8rem;
    color: #94a3b8;
    margin: 0.1rem 0 0 0;
    white-space: nowrap;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.header-controls .btn {
    white-space: nowrap;
    font-size: 0.84rem;
    padding: 0.42rem 0.85rem;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

.header-controls .btn-outline {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.28);
    color: #ffffff;
}

.header-controls .btn-outline:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.45);
    color: #ffffff;
}

.header-controls .btn-primary {
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

/* Network Status Indicator Pill */
.net-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.net-status-pill.online {
    background: rgba(16, 185, 129, 0.18);
    border: 1px solid rgba(16, 185, 129, 0.45);
    color: #6ee7b7;
}

.net-status-pill.offline {
    background: rgba(245, 158, 11, 0.22);
    border: 1px solid rgba(245, 158, 11, 0.55);
    color: #fcd34d;
}

.net-status-pill .net-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.net-status-pill.online .net-dot {
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
    animation: pulseDot 2s infinite ease-in-out;
}

.net-status-pill.offline .net-dot {
    background: #f59e0b;
    box-shadow: 0 0 8px #f59e0b;
}

@keyframes pulseDot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.75; }
}

/* Cloud Sync Status Indicator Pill */
.cloud-sync-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.cloud-sync-pill.synced {
    background: rgba(59, 130, 246, 0.18);
    border: 1px solid rgba(59, 130, 246, 0.45);
    color: #93c5fd;
}

.cloud-sync-pill.syncing {
    background: rgba(245, 158, 11, 0.22);
    border: 1px solid rgba(245, 158, 11, 0.55);
    color: #fcd34d;
}

.cloud-sync-pill.syncing .cloud-sync-icon {
    display: inline-block;
    animation: spinSync 1.2s infinite linear;
}

.cloud-sync-pill.error {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: #fca5a5;
}

@keyframes spinSync {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* PWA Install Button */
.btn-install {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #ffffff;
    border: none;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
    animation: installBounce 3s infinite ease-in-out;
}

.btn-install:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.45);
}

@keyframes installBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

/* User Pill & Button */
.user-pill-wrap {
    display: inline-flex;
}

.btn-user {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-user:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.user-avatar-icon {
    font-size: 1.15rem;
    line-height: 1;
}

.user-info-text {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.user-display-name {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-admin {
    background: #f59e0b;
    color: #78350f;
    border: 1px solid #fbbf24;
}

.badge-collector {
    background: #3b82f6;
    color: #ffffff;
    border: 1px solid #60a5fa;
}

/* User Card in Modal */
.current-user-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
}

.user-avatar-large {
    width: 48px;
    height: 48px;
    background: var(--primary-bg);
    border: 2px solid var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* User Quick List in Switch Modal */
.user-quick-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.user-quick-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #ffffff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-quick-item:hover {
    background: var(--gray-50);
    border-color: var(--primary-light);
    transform: translateX(2px);
}

.user-quick-item.active {
    background: var(--primary-bg);
    border-color: var(--primary);
}

/* Add User Form */
.add-user-form-grid {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr auto;
    gap: 0.65rem;
    align-items: flex-end;
}

@media (max-width: 768px) {
    .add-user-form-grid {
        grid-template-columns: 1fr;
    }
}

.draft-status-indicator {
    font-size: 0.8rem;
    color: var(--success-dark);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    background: var(--success-bg);
    border-radius: var(--radius-full);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

/* ================= MODE SWITCHER (F1 vs F2) ================= */
.mode-switcher-wrap {
    display: inline-flex;
    background: rgba(255, 255, 255, 0.12);
    padding: 3px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(255, 255, 255, 0.2);
    gap: 4px;
    flex-shrink: 0;
}

.mode-tab-btn {
    background: transparent;
    border: none;
    color: #cbd5e1;
    padding: 0.4rem 1.15rem;
    border-radius: var(--radius-full);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    white-space: nowrap;
}

.mode-tab-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
}

.mode-tab-btn.active {
    background: #ffffff;
    color: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.mode-info-tag {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: #93c5fd;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 0.25rem 0.85rem;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

/* ================= VIEW SWITCHING ================= */
.view-section {
    display: none !important;
}

.view-section.active {
    display: grid !important;
}

/* ================= VILLAGE STATS CARDS GRID ================= */
.stats-cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin: 1.25rem 0;
}

.stat-card {
    background: #ffffff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 1.25rem 1rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
    border-top: 4px solid var(--primary-light);
}

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

.stat-card-success {
    border-top-color: var(--success);
    background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 60%);
}

.stat-card-danger {
    border-top-color: var(--danger);
    background: linear-gradient(180deg, #fef2f2 0%, #ffffff 60%);
}

.stat-card-purple {
    border-top-color: var(--developed);
    background: linear-gradient(180deg, #f5f3ff 0%, #ffffff 60%);
}

.stat-icon {
    font-size: 1.6rem;
    margin-bottom: 0.35rem;
}

.stat-val {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.1;
    color: var(--gray-900);
    font-family: 'Outfit', var(--font-lao);
}

.stat-lbl {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-600);
    margin-top: 0.25rem;
}

.stat-sub {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.2rem;
}

/* ================= LAYOUT ================= */
.main-container {
    max-width: 1440px;
    margin: 1.75rem auto;
    padding: 0 1.5rem;
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1.75rem;
    align-items: start;
}

.form-wrapper {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    border: 1px solid var(--gray-200);
}

/* ================= STEPPER NAVIGATION ================= */
.stepper-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.step-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    color: var(--gray-600);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.step-item:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.step-item.active {
    background: var(--primary-bg);
    border-color: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.step-item.completed .step-num {
    background: var(--success);
    color: white;
}

.step-num {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: var(--gray-300);
    color: var(--gray-700);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.step-item.active .step-num {
    background: var(--primary);
    color: white;
}

.step-title {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ================= PANES ================= */
.form-step-pane {
    display: none;
    animation: fadeIn 0.3s ease;
}

.form-step-pane.active {
    display: block;
}

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

.pane-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--gray-100);
}

.pane-header h2 {
    font-size: 1.25rem;
    color: var(--gray-900);
    font-weight: 700;
}

.pane-desc {
    font-size: 0.9rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

/* ================= CARDS & SECTIONS ================= */
.card-section {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 1.05rem;
    color: var(--primary-dark);
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sub-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
    background: rgba(15, 76, 129, 0.05);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    margin: 1.25rem 0 0.85rem 0;
}

/* ================= FORM GRIDS & CONTROLS ================= */
.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    margin-bottom: 1rem;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    margin-bottom: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.4rem;
}

.req {
    color: var(--danger);
    font-weight: bold;
}

.hint {
    font-size: 0.75rem;
    color: var(--gray-500);
    font-weight: normal;
}

input[type="text"],
input[type="tel"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background-color: #ffffff;
    color: var(--gray-900);
    transition: all 0.2s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.input-readonly {
    background-color: var(--gray-100);
    color: var(--gray-600);
    cursor: not-allowed;
}

.input-inline {
    display: flex;
    gap: 0.5rem;
}

/* ================= MEMBER CARDS ================= */
.members-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.member-card {
    background: #ffffff;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s;
}

.member-card:hover {
    border-color: var(--primary-light);
}

.member-card-header {
    background: var(--gray-100);
    padding: 0.85rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--gray-200);
}

.member-card-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.member-index-badge {
    background: var(--primary);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
}

.member-card-title h4 {
    font-size: 1rem;
    color: var(--gray-800);
}

.text-muted {
    color: var(--gray-500);
    font-weight: normal;
}

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

.member-card-body {
    padding: 1.25rem;
    transition: max-height 0.3s ease;
}

.member-card-body.collapsed {
    display: none;
}

/* ================= 6 STANDARDS CARDS ================= */
.standard-card {
    background: #ffffff;
    border: 1px solid var(--gray-300);
    border-left: 5px solid var(--danger);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.standard-card.passed {
    border-left-color: var(--success);
    background: rgba(240, 253, 244, 0.3);
}

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

.standard-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.standard-badge {
    background: var(--gray-200);
    color: var(--gray-800);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
}

.standard-card.passed .standard-badge {
    background: var(--success);
    color: white;
}

.standard-title-wrap h3 {
    font-size: 1.1rem;
    color: var(--gray-900);
    font-weight: 700;
}

.standard-note {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-bottom: 1.25rem;
}

.status-chip {
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.status-pass {
    background: var(--success-bg);
    color: var(--success-dark);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-fail {
    background: var(--danger-bg);
    color: var(--danger-dark);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.indicators-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.granular-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    background: #f8fafc;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.asset-checklist-box {
    background: #f8fafc;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.asset-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.asset-chips label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: #ffffff;
    border: 1px solid var(--gray-300);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}

.asset-chips label:hover {
    border-color: var(--primary-light);
    background: var(--primary-bg);
}

.indicator-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.indicator-item:hover {
    background: #eef2f6;
}

.indicator-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    accent-color: var(--primary-light);
    flex-shrink: 0;
    cursor: pointer;
}

.indicator-text {
    font-size: 0.9rem;
    color: var(--gray-800);
    line-height: 1.5;
}

.quick-standard-summary {
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 700;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
}

/* ================= LIVE SIDEBAR ================= */
.live-sidebar {
    position: sticky;
    top: 5.5rem;
}

.live-card {
    background: #ffffff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

.live-title {
    font-size: 1rem;
    color: var(--gray-800);
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.live-status-badge {
    text-align: center;
    padding: 0.85rem;
    border-radius: var(--radius-md);
    font-size: 1.15rem;
    font-weight: 800;
    margin-bottom: 1.25rem;
    letter-spacing: 0.02em;
    transition: all 0.3s ease;
}

.status-poverty-free {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.status-poor {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3);
}

.status-developed {
    background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(139, 92, 246, 0.3);
}

.live-meter-wrap {
    margin-bottom: 1.25rem;
}

.meter-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--gray-600);
    margin-bottom: 0.4rem;
}

.progress-bar-bg {
    height: 10px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary-light);
    border-radius: var(--radius-full);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.standards-mini-checklist {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--gray-200);
}

.mini-std-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    color: var(--gray-600);
    padding: 0.25rem 0.4rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.mini-std-item.mini-pass {
    color: var(--gray-900);
    font-weight: 600;
}

.mini-icon {
    font-size: 0.9rem;
}

.live-criteria-box {
    background: var(--gray-50);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--gray-600);
    border-left: 3px solid var(--primary);
    margin-bottom: 1.25rem;
}

.live-action-btns {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* ================= STEP 4: REPORT SHEET ================= */
.report-sheet {
    background: #ffffff;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-md);
    padding: 2.5rem 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

.report-header-lao {
    text-align: center;
    margin-bottom: 2rem;
}

.national-motto {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--gray-800);
    line-height: 1.4;
}

.emblem-center {
    font-size: 1.2rem;
    margin: 0.5rem 0;
}

.report-title {
    font-size: 1.35rem;
    color: var(--primary-dark);
    font-weight: 800;
    margin-top: 0.75rem;
    line-height: 1.4;
}

.sub-report-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray-600);
}

.report-summary-box {
    background: var(--gray-50);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.report-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem 1.25rem;
    font-size: 0.9rem;
}

.report-grid strong {
    color: var(--gray-700);
}

.result-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    border-radius: var(--radius-md);
    margin-bottom: 2rem;
    color: #ffffff;
}

.banner-poverty_free {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
}

.banner-poor {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
}

.banner-developed {
    background: linear-gradient(135deg, #6d28d9 0%, #8b5cf6 100%);
}

.result-icon-wrap {
    font-size: 3rem;
}

.result-info {
    flex: 1;
    margin: 0 1.5rem;
}

.result-tag {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.9;
}

.result-status-text {
    font-size: 1.75rem;
    font-weight: 800;
    margin: 0.2rem 0;
}

.result-desc-text {
    font-size: 0.95rem;
    opacity: 0.95;
}

.score-circle-box {
    text-align: center;
    background: rgba(255, 255, 255, 0.15);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    backdrop-filter: blur(4px);
}

.score-circle {
    display: flex;
    align-items: baseline;
    justify-content: center;
}

.score-val {
    font-size: 2.2rem;
    font-weight: 800;
}

.score-max {
    font-size: 1.2rem;
    opacity: 0.8;
}

.score-lbl {
    font-size: 0.75rem;
    display: block;
    margin-top: 0.2rem;
}

.report-table-section {
    margin-bottom: 2rem;
}

.report-table-section h3 {
    font-size: 1.05rem;
    color: var(--gray-900);
    margin-bottom: 0.75rem;
}

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

.standards-table th, .standards-table td {
    padding: 0.75rem 1rem;
    border: 1px solid var(--gray-300);
}

.standards-table th {
    background: var(--gray-100);
    font-weight: 700;
    color: var(--gray-800);
}

.badge-count {
    background: var(--gray-100);
    color: var(--gray-700);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.recommendations-box {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    margin-bottom: 2.5rem;
}

.recommendations-box h4 {
    font-size: 0.95rem;
    color: #92400e;
    margin-bottom: 0.5rem;
}

.recommendations-box ul {
    margin-left: 1.5rem;
    font-size: 0.9rem;
    color: #78350f;
}

.recommendations-box li {
    margin-bottom: 0.4rem;
}

.rec-success {
    list-style-type: none;
    margin-left: -1rem;
    color: var(--success-dark);
}

.signatures-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    text-align: center;
    margin-top: 2rem;
    font-size: 0.9rem;
}

.sig-space {
    height: 70px;
}

/* ================= BUTTONS ================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}

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

.btn-secondary {
    background: #e2e8f0;
    color: var(--gray-800);
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.btn-success {
    background: var(--success);
    color: #ffffff;
}

.btn-success:hover {
    background: var(--success-dark);
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
}

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

.btn-outline {
    background: transparent;
    border-color: var(--gray-300);
    color: var(--gray-700);
}

.btn-outline:hover {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

.pane-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-200);
}

.header-action-group {
    display: flex;
    gap: 0.75rem;
}

/* ================= MODAL & TABLE ================= */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: #ffffff;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 1050px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.modal-header {
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.25rem;
    color: var(--gray-900);
}

.btn-close {
    background: transparent;
    border: none;
    font-size: 1.75rem;
    color: var(--gray-500);
    cursor: pointer;
}

.modal-body {
    padding: 1.5rem 1.75rem;
    overflow-y: auto;
}

.records-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.search-wrap {
    flex: 1;
}

.export-btns {
    display: flex;
    gap: 0.5rem;
}

.table-responsive {
    overflow-x: auto;
}

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

.records-table th, .records-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.records-table th {
    background: var(--gray-100);
    text-align: left;
    font-weight: 700;
    color: var(--gray-700);
}

/* ================= PRINT STYLES ================= */
@media print {
    body {
        background: #ffffff;
        color: #000000;
        padding: 0;
    }

    .app-header,
    .stepper-nav,
    .live-sidebar,
    .pane-actions,
    .header-action-group,
    .modal-overlay,
    #btnAddMember,
    .btn-collapse-member,
    .btn-remove-member,
    .records-toolbar {
        display: none !important;
    }

    .main-container {
        display: block !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .form-wrapper {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
    }

    /* Print household report when not printing village report */
    body:not(.printing-village) #viewF2Container {
        display: none !important;
    }

    body:not(.printing-village) #viewF1Container {
        display: block !important;
    }

    body:not(.printing-village) .form-step-pane {
        display: none !important;
    }

    body:not(.printing-village) #stepPane4 {
        display: block !important;
    }

    /* Print village report when printing village report */
    body.printing-village #viewF1Container {
        display: none !important;
    }

    body.printing-village #viewF2Container {
        display: block !important;
    }

    body.printing-village #viewF2Container .card-section {
        display: none !important;
    }

    body.printing-village #viewF2Container .pane-header {
        display: none !important;
    }

    body.printing-village #printableVillageReport {
        display: block !important;
    }

    .report-sheet {
        border: none;
        box-shadow: none;
        padding: 0;
        margin: 0;
    }

    .result-banner {
        color: #000000 !important;
        border: 2px solid #000000;
        background: none !important;
    }

    .result-status-text {
        color: #000000;
    }

    .status-chip {
        border: 1px solid #000000;
    }
}

/* ================= RESPONSIVE DESIGN (PC, IPAD/TABLET & MOBILE) ================= */

/* Base touch improvements */
@media (hover: none) and (pointer: coarse) {
    .btn, .mode-tab-btn, .step-item, .vlg-std-check, .checkbox-custom, input, select, textarea {
        min-height: 44px;
    }
}

/* 1. Standard Laptops & MacBooks (max-width: 1366px) */
@media (max-width: 1366px) {
    .header-main-bar {
        padding: 0.65rem 1.25rem;
    }

    .header-nav-bar {
        padding: 0.35rem 1.25rem;
    }

    .header-brand h1 {
        font-size: 1.05rem;
    }

    .header-brand .subtitle {
        font-size: 0.74rem;
    }

    .header-controls {
        gap: 0.4rem;
    }

    .header-controls .btn {
        padding: 0.35rem 0.65rem;
        font-size: 0.8rem;
        height: 35px;
    }

    .net-status-pill,
    .cloud-sync-pill {
        padding: 0.25rem 0.6rem;
        font-size: 0.78rem;
    }

    .user-info-text .user-display-name {
        max-width: 110px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mode-info-tag {
        max-width: 440px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .main-container {
        grid-template-columns: 1fr 310px;
        gap: 1.25rem;
        padding: 0 1.25rem;
    }
}

/* 2. Compact Laptops & iPad Pro Landscape (max-width: 1200px) */
@media (max-width: 1200px) {
    .header-main-bar {
        padding: 0.55rem 1rem;
    }

    .header-nav-bar {
        padding: 0.35rem 1rem;
    }

    .header-brand .subtitle {
        display: none;
    }

    .header-controls .btn {
        padding: 0.32rem 0.55rem;
        font-size: 0.78rem;
    }

    .mode-info-tag {
        display: none;
    }

    .main-container {
        grid-template-columns: 1fr 290px;
        gap: 1rem;
        padding: 0 1rem;
    }

    .header-container {
        padding: 0 0.5rem;
    }

    .stats-cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.85rem;
    }
}

/* 2. iPad / Tablets (max-width: 1024px) */
@media (max-width: 1024px) {
    .header-main-bar {
        padding: 0.65rem 1rem;
    }

    .header-main-bar .header-container {
        flex-direction: column;
        align-items: stretch;
        gap: 0.65rem;
    }

    .header-brand {
        justify-content: flex-start;
    }

    .header-brand h1 {
        font-size: 1.15rem;
        white-space: normal;
    }

    .header-brand .subtitle {
        white-space: normal;
    }

    .header-controls {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 0.45rem;
    }

    .header-controls .btn {
        flex: 1 1 auto;
        justify-content: center;
        min-height: 40px;
    }

    .header-nav-bar {
        padding: 0.4rem 1rem;
    }

    .nav-container {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .mode-switcher-wrap {
        width: 100%;
        display: flex;
    }

    .mode-tab-btn {
        flex: 1;
        justify-content: center;
        padding: 0.5rem 0.65rem;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .mode-info-tag {
        display: none;
    }

    .pane-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.85rem;
    }

    .header-action-group {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        width: 100%;
    }

    .header-action-group .btn {
        flex: 1 1 auto;
        justify-content: center;
        min-height: 44px;
    }

    .main-container {
        grid-template-columns: 1fr;
        padding: 0 1rem;
        margin: 1.25rem auto;
    }

    .live-sidebar {
        position: static;
        margin-top: 1.5rem;
    }

    .live-sidebar .live-card {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1.25rem;
        align-items: center;
    }

    .live-sidebar .standards-mini-checklist {
        grid-column: span 2;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.4rem;
    }

    .stepper-nav {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.5rem;
    }

    .step-item {
        padding: 0.65rem 0.6rem;
    }

    .step-title {
        font-size: 0.8rem;
    }

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

    .stats-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 3. Small Tablets & Large Phones (max-width: 768px) */
@media (max-width: 768px) {
    /* Mobile iOS input zoom fix */
    input[type="text"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px !important;
        min-height: 44px;
    }

    .header-main-bar {
        padding: 0.65rem 0.75rem;
    }

    .header-nav-bar {
        padding: 0.35rem 0.75rem;
    }

    .header-brand h1 {
        font-size: 1.05rem;
    }

    .subtitle {
        font-size: 0.75rem;
    }

    .mode-tab-btn {
        padding: 0.45rem 0.4rem;
        font-size: 0.8rem;
    }

    .header-controls {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 0.45rem;
    }

    .header-controls .btn {
        flex: 1 1 calc(50% - 0.45rem);
        justify-content: center;
        text-align: center;
        min-height: 44px;
        font-size: 0.85rem;
    }

    .header-controls #btnNewAssessment {
        flex: 1 1 100%;
    }

    .net-status-pill {
        flex: 1 1 100%;
        justify-content: center;
    }

    .form-wrapper {
        padding: 1.5rem 1rem;
    }

    .stepper-nav {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
        margin-bottom: 1.25rem;
        padding-bottom: 1rem;
    }

    .form-grid-3, 
    .form-grid-2 {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .report-grid {
        grid-template-columns: 1fr;
    }

    .records-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.65rem;
    }

    .records-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.45rem;
        width: 100%;
    }

    .records-actions .btn {
        width: 100%;
        justify-content: center;
        font-size: 0.82rem;
    }

    .stats-cards-grid {
        grid-template-columns: 1fr;
    }

    .live-sidebar .live-card {
        grid-template-columns: 1fr;
    }

    .live-sidebar .standards-mini-checklist {
        grid-column: span 1;
        grid-template-columns: 1fr;
    }

    /* Modal Mobile Adjustments */
    .modal-overlay {
        padding: 0.75rem;
    }

    .modal-content {
        max-height: 92vh;
        width: 100%;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-header h2 {
        font-size: 1.1rem;
    }

    .modal-body {
        padding: 1rem 0.75rem;
    }

    .table-container,
    .modal-table-container,
    .village-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        display: block;
        width: 100%;
    }

    table {
        min-width: 680px;
    }
}

/* 4. Compact Mobile Phones (max-width: 480px) */
@media (max-width: 480px) {
    .app-header {
        padding: 0.75rem 0.75rem;
    }

    .header-brand {
        gap: 0.65rem;
    }

    .emblem-icon {
        font-size: 1.75rem;
    }

    .header-brand h1 {
        font-size: 1.02rem;
        line-height: 1.25;
    }

    .subtitle {
        font-size: 0.72rem;
    }

    .mode-tab-btn {
        font-size: 0.78rem;
        padding: 0.45rem 0.35rem;
        gap: 0.25rem;
    }

    .main-container {
        padding: 0 0.5rem;
        margin: 0.75rem auto;
    }

    .form-wrapper {
        padding: 1rem 0.65rem;
        border-radius: var(--radius-md);
    }

    .pane-header h2 {
        font-size: 1.1rem;
    }

    .pane-desc {
        font-size: 0.82rem;
    }

    .stepper-nav {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.35rem;
    }

    .step-item {
        padding: 0.45rem 0.4rem;
        gap: 0.35rem;
    }

    .step-num {
        width: 24px;
        height: 24px;
        font-size: 0.75rem;
    }

    .step-title {
        font-size: 0.75rem;
    }

    .input-inline {
        flex-direction: column;
        gap: 0.4rem;
    }

    /* Step 2: Member Cards on Mobile */
    .member-card {
        padding: 0.85rem 0.65rem;
        border-radius: var(--radius-md);
        margin-bottom: 0.85rem;
    }

    .member-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .member-card-actions {
        width: 100%;
        justify-content: space-between;
        border-top: 1px dashed var(--gray-200);
        padding-top: 0.4rem;
    }

    .sub-section-title {
        font-size: 0.85rem;
        padding: 0.4rem 0.6rem;
    }

    /* Step 3: 6 Standards & Indicators on Mobile */
    .standard-card {
        padding: 0.85rem 0.65rem;
        border-radius: var(--radius-md);
    }

    .standard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.4rem;
    }

    .indicator-item {
        padding: 0.75rem 0.5rem;
        gap: 0.65rem;
        min-height: 48px;
    }

    .indicator-item input[type="checkbox"],
    .vlg-std-check {
        width: 22px;
        height: 22px;
        min-width: 22px;
        margin-top: 2px;
    }

    .indicator-text {
        font-size: 0.82rem;
        line-height: 1.4;
    }

    /* Actions bottom bar on mobile */
    .pane-actions {
        flex-direction: column-reverse;
        gap: 0.65rem;
        align-items: stretch;
    }

    .pane-actions .btn {
        width: 100%;
        justify-content: center;
        min-height: 46px;
    }

    .header-action-group {
        flex-direction: column;
        gap: 0.5rem;
    }

    /* Mobile Bottom-sheet Modal */
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .modal-content {
        border-radius: 18px 18px 0 0;
        max-height: 94vh;
        width: 100%;
    }

    .records-actions {
        grid-template-columns: 1fr;
    }

    /* Safe Area Inset support for iPhone home indicator */
    body {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}
