/* ============================================================
   COMMUNITY BRIDGE WV – IDMS  |  styles.css
   Design preserved from demo (customer approved).
   New sections marked with  ── NEW ──
   ============================================================ */

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

:root {
    --primary:        #5DADE2;
    --primary-dark:   #3498DB;
    --primary-deeper: #2E86AB;
    --success:        #10b981;
    --success-dark:   #059669;
    --danger:         #ef4444;
    --danger-dark:    #dc2626;
    --warning:        #f59e0b;

    --gray-50:  #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-900: #111827;

    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2rem;
    --space-xl: 3rem;

    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;

    --shadow-sm: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,.1), 0 10px 10px -5px rgba(0,0,0,.04);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
}

/* ── Layout ─────────────────────────────────────────────────── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

/* ── Header ─────────────────────────────────────────────────── */
.header {
    background: linear-gradient(135deg, #ffffff 0%, #5DADE2 50%, #2E86AB 100%);
    color: white;
    padding: var(--space-md) 0;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.logo-image { width: 56px; height: auto; }

.logo-text h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: white;
    margin-bottom: 0.15rem;
    text-shadow: 0 1px 2px rgba(0,0,0,.15);
}

.logo-text p {
    font-size: 0.8rem;
    opacity: 0.9;
    color: white;
}

/* Header live stats */
.header-stats {
    display: flex;
    gap: var(--space-md);
    align-items: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255,255,255,.18);
    border-radius: var(--radius-md);
    padding: 0.4rem 1rem;
    min-width: 70px;
}

.stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: white;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
}

/* ── NEW: User Menu ──────────────────────────────────────────── */
.user-menu { position: relative; }

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-md);
    background: rgba(255,255,255,.18);
    transition: background .2s;
}

.user-info:hover { background: rgba(255,255,255,.28); }

.user-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,.35);
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex; align-items: center; justify-content: center;
}

.user-name  { font-size: 0.85rem; font-weight: 600; color: white; }
.user-chevron { font-size: 0.7rem; color: white; opacity: .8; }

.user-role-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.role-admin      { background: #fde68a; color: #92400e; }
.role-manager    { background: #bbf7d0; color: #065f46; }
.role-data_entry { background: rgba(255,255,255,.3); color: white; }

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    overflow: hidden;
    border: 1px solid var(--gray-200);
    z-index: 200;
}

.dropdown-item {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--gray-700);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background .15s;
}

.dropdown-item:hover { background: var(--gray-50); }

/* ── Main Content ───────────────────────────────────────────── */
.main-content { padding: var(--space-xl) 0; }

/* ── Views ──────────────────────────────────────────────────── */
.view           { display: none; }
.view.active    { display: block; }

.view-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

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

/* ── Home – Welcome ─────────────────────────────────────────── */
.welcome-section {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.welcome-section h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.subtitle { color: var(--gray-600); font-size: 1rem; }

/* ── Action Cards ───────────────────────────────────────────── */
.action-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.action-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: transform .2s, box-shadow .2s;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.action-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--primary-deeper));
}

.action-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary);
}

.card-icon  { font-size: 2.2rem; margin-bottom: 0.75rem; }

.action-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--gray-900);
}

.action-card p {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: var(--space-sm);
}

.card-arrow {
    color: var(--primary);
    font-size: 1.2rem;
    font-weight: 700;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem 1.4rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all .2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-deeper));
    color: white;
    border-color: transparent;
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-deeper));
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border-color: var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); }

.btn-success { background: var(--success); color: white; border-color: transparent; }
.btn-success:hover { background: var(--success-dark); }

.btn-danger  { background: var(--danger); color: white; border-color: transparent; }
.btn-danger:hover  { background: var(--danger-dark); }

.btn-export  { background: var(--success); color: white; border-color: transparent; }
.btn-export:hover  { background: var(--success-dark); }

.btn-add {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.btn-add:hover { background: var(--primary-dark); }

.btn-small, .btn-sm { padding: 0.35rem 0.75rem; font-size: 0.82rem; }

.btn-full { width: 100%; }

.btn-link {
    background: none;
    border: none;
    color: var(--primary-dark);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.25rem 0;
    text-decoration: underline;
}

.btn-remove {
    background: none;
    border: 1px solid var(--gray-300);
    color: var(--danger);
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
}
.btn-remove:hover { background: #fef2f2; border-color: var(--danger); }

.btn-copy {
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
}

.back-btn {
    background: white;
    border: 2px solid var(--gray-200);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-700);
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
}
.back-btn:hover { background: var(--gray-50); border-color: var(--gray-300); }

.btn-clear-selection {
    background: none;
    border: 1px solid var(--gray-300);
    color: var(--gray-600);
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
    margin-left: auto;
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--space-lg);
}

.form-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-xs);
    border-bottom: 2px solid var(--gray-100);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-md) var(--space-lg);
    margin-bottom: var(--space-md);
}

.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group.full-width { grid-column: 1 / -1; }

label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gray-700);
    letter-spacing: .01em;
}

input[type="text"],
input[type="tel"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="password"],
select,
textarea {
    padding: 0.6rem 0.85rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: 0.92rem;
    font-family: inherit;
    color: var(--gray-900);
    background: white;
    transition: border-color .2s, box-shadow .2s;
    width: 100%;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(93,173,226,.15);
}

textarea { resize: vertical; min-height: 80px; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    padding-top: 1.4rem; /* align with other form-group inputs */
}

.checkbox-label input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }

.form-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 2px solid var(--gray-100);
    flex-wrap: wrap;
}

/* ── Search ─────────────────────────────────────────────────── */
.search-section { margin-bottom: var(--space-lg); }

.search-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.search-container { position: relative; }

.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: border-color .2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(93,173,226,.15);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: white;
    border: 2px solid var(--gray-200);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    max-height: 320px;
    overflow-y: auto;
}

.search-result-item {
    padding: 0.85rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--gray-100);
    transition: background .15s;
}
.search-result-item:hover { background: var(--gray-50); }
.search-result-item:last-child { border-bottom: none; }

.result-name  { font-weight: 600; font-size: 0.95rem; color: var(--gray-900); }
.result-details { font-size: 0.82rem; color: var(--gray-600); margin-top: 0.15rem; }
.result-meta  { font-size: 0.78rem; color: var(--gray-400); margin-top: 0.1rem; }

/* Selected family/org banner */
.selected-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #ecfdf5;
    border: 2px solid #6ee7b7;
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    margin-top: 0.75rem;
}

.banner-icon { font-size: 1.2rem; color: var(--success); }

.banner-text strong { display: block; font-size: 0.9rem; color: var(--gray-900); }
.banner-text span   { font-size: 0.82rem; color: var(--gray-600); }

/* County autocomplete */
.county-container { position: relative; }

.county-results {
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: white;
    border: 2px solid var(--gray-200);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 50;
    max-height: 200px;
    overflow-y: auto;
}

.county-result-item {
    padding: 0.6rem 0.85rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background .15s;
}
.county-result-item:hover { background: var(--gray-100); }

/* ── Household Members Table ────────────────────────────────── */
.household-section { margin-bottom: var(--space-lg); }

.section-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
}

.section-header-row h4 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-900);
}

.members-table-header {
    display: grid;
    grid-template-columns: 2fr 0.6fr 0.8fr 1fr 1fr 0.7fr 0.7fr 0.7fr 0.5fr;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--gray-100);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: .03em;
}

.member-row {
    display: grid;
    grid-template-columns: 2fr 0.6fr 0.8fr 1fr 1fr 0.7fr 0.7fr 0.7fr 0.5fr;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid var(--gray-100);
    align-items: center;
}

.member-row input, .member-row select {
    padding: 0.35rem 0.5rem;
    font-size: 0.82rem;
    border: 1px solid var(--gray-200);
}

/* ── Needs Section ──────────────────────────────────────────── */
.needs-section {
    background: var(--gray-50);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
}

.needs-section h4 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: var(--space-sm);
    color: var(--gray-700);
}

/* ── Distribution Type Selector ─────────────────────────────── */
.dist-type-selector { margin-bottom: var(--space-md); }

.dist-type-buttons {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.dist-type-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    background: white;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--gray-600);
    cursor: pointer;
    transition: all .2s;
}

.dist-type-btn.active {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(93,173,226,.08), rgba(46,134,171,.08));
    color: var(--primary-deeper);
}

.dist-type-btn:hover:not(.active) { border-color: var(--gray-300); background: var(--gray-50); }

.dist-type-icon { font-size: 1.3rem; }

/* ── RC Distribution Items ──────────────────────────────────── */
.add-item-header {
    display: grid;
    grid-template-columns: 1.4fr 2fr 0.55fr 0.65fr 80px;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--gray-100);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    margin-bottom: 0;
}

.header-col {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: .03em;
}

.header-col.small { text-align: center; }
.header-col-btn   { } /* spacer for Add button */

.add-item-row {
    display: grid;
    grid-template-columns: 1.4fr 2fr 0.55fr 0.65fr 80px;
    gap: 0.5rem;
    align-items: start;
    padding: 0.5rem 0;
    margin-bottom: var(--space-sm);
}

.item-input { font-size: 0.88rem; }
.item-input.small { text-align: center; }

/* Items added list */
.items-list-container { margin-top: var(--space-sm); }

.items-list-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.item-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: 0.6rem 0.75rem;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    margin-bottom: 0.4rem;
    border: 1px solid var(--gray-200);
}

.item-details {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
    flex: 1;
}

.item-detail { font-size: 0.82rem; }
.item-detail strong { display: block; color: var(--gray-600); font-size: 0.72rem; text-transform: uppercase; }
.item-detail span   { color: var(--gray-900); font-weight: 500; }

.total-value-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-deeper));
    color: white;
    border-radius: var(--radius-md);
    margin-top: var(--space-sm);
    font-size: 0.95rem;
    font-weight: 600;
}

.total-value-card strong { font-size: 1.2rem; }

/* ── Food Pantry Form ───────────────────────────────────────── */
.fp-form { }

.fp-instructions {
    font-size: 0.85rem;
    color: var(--gray-600);
    margin-bottom: var(--space-md);
}

.fp-groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.fp-group {
    background: var(--gray-50);
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.fp-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.85rem;
    background: var(--primary);
    color: white;
}

.fp-group-header strong { font-size: 0.9rem; }
.fp-group-total         { font-size: 0.78rem; opacity: .9; }

.fp-group-items { padding: 0.5rem; }

.fp-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.35rem 0.4rem;
    border-bottom: 1px solid var(--gray-200);
}

.fp-item-row:last-child { border-bottom: none; }
.fp-item-row label { font-size: 0.82rem; font-weight: 400; color: var(--gray-700); flex: 1; }

.fp-qty-input {
    width: 65px;
    text-align: center;
    padding: 0.3rem 0.4rem;
    font-size: 0.85rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
}

.fp-grand-total-card { margin-top: var(--space-sm); }

/* ── Distribution metadata row ─────────────────────────────── */
.dist-meta-row {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: var(--space-md);
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 2px solid var(--gray-100);
}

/* ── Family / Org card (after selection) ────────────────────── */
.family-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--space-lg);
    border-left: 4px solid var(--primary);
}

.family-card h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-700);
    margin-bottom: var(--space-sm);
}

.family-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-sm);
}

.info-item strong { display: block; font-size: 0.72rem; text-transform: uppercase; color: var(--gray-400); letter-spacing: .04em; }
.info-item span   { font-size: 0.9rem; font-weight: 500; color: var(--gray-900); }

/* ── Past Visits ────────────────────────────────────────────── */
.visits-section {
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 2px solid var(--gray-100);
}

.visits-section h4 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: var(--space-sm);
    color: var(--gray-700);
}

.visit-item {
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.85rem;
    margin-bottom: 0.4rem;
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
    font-size: 0.85rem;
    border: 1px solid var(--gray-200);
}

/* ── Reports ────────────────────────────────────────────────── */
.report-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}

.report-tab {
    padding: 0.55rem 1.1rem;
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--gray-600);
    transition: all .2s;
}

.report-tab.active {
    border-color: var(--primary);
    color: var(--primary-deeper);
    background: rgba(93,173,226,.07);
}

.report-tab:hover:not(.active) { border-color: var(--gray-300); }

.report-controls { margin-bottom: var(--space-lg); }

.report-date-row {
    display: flex;
    gap: var(--space-md);
    align-items: flex-end;
    flex-wrap: wrap;
}

.report-date-row .form-group { min-width: 160px; }

.report-actions-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    flex-wrap: wrap;
    padding-bottom: 0.05rem;
}

/* Report stat cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-md) var(--space-lg);
    box-shadow: var(--shadow-md);
}

.stat-card-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--gray-600);
    margin-bottom: 0.4rem;
}

.stat-card-value {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--primary);
}

.report-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--space-lg);
}

.report-card h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: var(--space-md);
}

/* Category breakdown rows */
.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    background: var(--gray-50);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: background .15s;
}
.category-item:hover { background: var(--gray-100); }

.category-info strong { display: block; font-size: 0.95rem; }
.category-info span   { color: var(--gray-600); font-size: 0.85rem; }

.category-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.category-details        { display: none; }
.category-details.open   { display: block; }

/* County report table */
.county-table {
    width: 100%;
    border-collapse: collapse;
}

.county-table th {
    background: var(--gray-100);
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-300);
}

.county-table td       { padding: 0.75rem 1rem; border-bottom: 1px solid var(--gray-200); }
.county-table .num     { text-align: center; font-weight: 600; color: var(--primary); }
.county-table .totals  { background: linear-gradient(135deg, var(--primary), var(--primary-deeper)); color: white; font-weight: 700; }
.county-table .totals td { border-bottom: none; }

/* Total value card */
.total-report-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-deeper));
    color: white;
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-xl);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

.total-report-card .total-info span   { display: block; font-size: 0.85rem; opacity: .9; margin-bottom: 0.4rem; }
.total-report-card .total-info strong { font-size: 2.5rem; font-weight: 800; }
.total-report-card .total-icon        { font-size: 3.5rem; opacity: .45; }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: var(--space-sm);
}

.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fcd34d; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #93c5fd; }

/* ── Toast ──────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-900);
    color: white;
    padding: 0.85rem 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 9999;
    max-width: 90vw;
    text-align: center;
    transition: opacity .3s;
}

.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.hidden  { display: none; }

/* ── Loading Screen ─────────────────────────────────────────── */
.loading-screen {
    position: fixed;
    inset: 0;
    background: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.loading-spinner {
    width: 44px; height: 44px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin-bottom: 1rem;
}

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

/* ── NEW: Login Page ────────────────────────────────────────── */
body.login-body {
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 50%, #c7d2fe 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-wrapper {
    width: 100%;
    max-width: 440px;
    padding: var(--space-md);
}

.setup-wrapper { max-width: 560px; }

.login-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-xl);
}

.setup-card { padding: var(--space-lg); }

.login-logo {
    text-align: center;
    margin-bottom: var(--space-lg);
}

.login-logo img { width: 80px; height: auto; margin-bottom: 0.75rem; }

.login-logo h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: 0.25rem;
}

.login-logo p { font-size: 0.85rem; color: var(--gray-600); }

.login-form { display: flex; flex-direction: column; gap: var(--space-sm); }

/* 2FA prompt */
.two-fa-prompt {
    text-align: center;
    padding: var(--space-md) 0 var(--space-sm);
}

.two-fa-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }

.two-fa-prompt h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.two-fa-prompt p { font-size: 0.88rem; color: var(--gray-600); }

/* Big code input */
.code-input {
    text-align: center;
    font-size: 2rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.5rem;
    padding: 0.75rem !important;
}

/* Email fallback link */
.fallback-form   { text-align: center; margin-top: var(--space-sm); }
.fallback-text   { font-size: 0.82rem; color: var(--gray-400); margin-bottom: 0.2rem; }

/* ── NEW: 2FA Setup Steps ───────────────────────────────────── */
.setup-steps  { display: flex; flex-direction: column; gap: var(--space-lg); }

.setup-step {
    display: flex;
    gap: var(--space-md);
    align-items: flex-start;
}

.step-number {
    width: 34px; height: 34px;
    min-width: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-weight: 700;
    font-size: 1rem;
    display: flex; align-items: center; justify-content: center;
}

.step-content { flex: 1; }

.step-content h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.step-content p { font-size: 0.87rem; color: var(--gray-600); margin-bottom: 0.6rem; }

.qr-container {
    text-align: center;
    padding: var(--space-md);
    background: var(--gray-50);
    border-radius: var(--radius-md);
    border: 2px dashed var(--gray-300);
    margin-bottom: 0.75rem;
}

.qr-code { border-radius: var(--radius-sm); }

.manual-entry { margin-top: 0.5rem; }
.manual-entry summary { font-size: 0.82rem; color: var(--primary-dark); cursor: pointer; }

.manual-key {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
}

.manual-key code {
    font-family: monospace;
    font-size: 1rem;
    letter-spacing: .15em;
    color: var(--gray-900);
    flex: 1;
}

.manual-note { font-size: 0.78rem; color: var(--gray-500); margin-top: 0.4rem; }

/* ── Utility ────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ════════════════════════════════════════════════════════════
   ADMIN PANEL
   ════════════════════════════════════════════════════════════ */

/* ── Shared form helpers (used across admin + login) ────────── */
.form-control {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--gray-900);
    background: #fff;
    transition: border-color 0.15s;
    box-sizing: border-box;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
select.form-control { cursor: pointer; }

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

.btn-block { width: 100%; justify-content: center; }

/* ── Generic white card wrapper ─────────────────────────────── */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

/* ── Admin tables ───────────────────────────────────────────── */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.admin-table th {
    background: var(--gray-50);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--gray-600);
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}
.admin-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--gray-50); }

.table-loading {
    padding: 2rem;
    text-align: center;
    color: var(--gray-500);
    font-size: 0.875rem;
}

.actions-cell {
    white-space: nowrap;
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

/* ── Status badges ───────────────────────────────────────────── */
.status-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.status-active   { background: #d1fae5; color: #065f46; }
.status-inactive { background: #fee2e2; color: #991b1b; }

/* ── Modals ─────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-card {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem 0;
}
.modal-header h3 { margin: 0; font-size: 1.1rem; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--gray-500);
    cursor: pointer;
    padding: 0 .25rem;
}
.modal-close:hover { color: var(--gray-900); }
.modal-card form { padding: 1.25rem 1.5rem 0; }
.modal-footer {
    padding: 1rem 1.5rem 1.25rem;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    border-top: 1px solid var(--gray-100);
    margin-top: 1.25rem;
}

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0,0,0,.15);
    max-width: 340px;
}
.toast-success { background: #065f46; color: #fff; }
.toast-error   { background: #991b1b; color: #fff; }

/* ── Misc admin helpers ─────────────────────────────────────── */
.btn-warning {
    background: #f59e0b;
    color: #fff;
    border: none;
}
.btn-warning:hover { background: #d97706; }

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }

/* ── Print Styles ───────────────────────────────────────────── */
@media print {
    .no-print { display: none !important; }
    .header   { box-shadow: none; position: static; }
    body      { background: white; }
    .form-card, .report-card { box-shadow: none; border: 1px solid var(--gray-200); }
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    .header-stats   { display: none; }
    .action-cards   { grid-template-columns: 1fr; }
    .form-grid      { grid-template-columns: 1fr; }
    .add-item-header,
    .add-item-row   { grid-template-columns: 1fr; gap: 0.4rem; }
    .members-table-header,
    .member-row     { grid-template-columns: 1fr 1fr; }
    .dist-meta-row  { grid-template-columns: 1fr; }
    .report-date-row { flex-direction: column; align-items: stretch; }
    .report-actions-row { flex-direction: column; }
    .login-card     { padding: var(--space-lg) var(--space-md); }
    .fp-groups-grid { grid-template-columns: 1fr; }
    .user-name, .user-role-badge { display: none; }
}
