/* Global Design System - Electoral Intelligence */
:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #1e40af;
    --accent: #f59e0b;
    --success: #10b981;
    --danger: #f87171;
    --bg: #0b1120;
    --card-bg: rgba(30, 41, 59, 0.3);
    --card-border: rgba(255, 255, 255, 0.05);
    --text: #f8fafc;
    --text-dim: #64748b;
    --sidebar-bg: rgba(15, 23, 42, 0.97);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Typography & Hierarchy */
h1, .h1 { 
    font-size: 1.875rem; 
    font-weight: 800; 
    letter-spacing: -0.025em;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

h2, .h2 { 
    font-size: 1.5rem; 
    font-weight: 700; 
    color: #fff;
    margin-bottom: 1rem;
}

h3, .h3 { 
    font-size: 1.125rem; 
    font-weight: 600; 
    color: #f1f5f9;
    margin-bottom: 1.25rem;
}

p { color: var(--text-dim); font-size: 0.9375rem; margin-bottom: 1rem; }

.stat-value {
    font-size: 2.2rem;
    font-weight: 800;
    color: #fff;
    line-height: 1;
    margin-top: 0.25rem;
}

.stat-label {
    color: var(--text-dim);
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.08em;
}

.text-gradient {
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.kpi-box {
    margin-top: 0.75rem;
    border-radius: 0.85rem;
    padding: 1.25rem;
    border: 1px solid var(--card-border);
    transition: transform 0.2s;
}
.kpi-box:hover { transform: scale(1.02); }
.kpi-box .stat-label { font-size: 0.65rem; opacity: 0.8; margin-bottom: 0.25rem; }
.kpi-box .stat-value { font-size: 1.5rem; letter-spacing: -0.02em; }
.kpi-box.blue { background: rgba(59,130,246,0.05); border-left: 3px solid #3b82f6; }
.kpi-box.red { background: rgba(248,113,113,0.05); border-left: 3px solid #f87171; }
.kpi-box.green { background: rgba(52,211,153,0.05); border-left: 3px solid #34d399; }
.kpi-box.orange { background: rgba(245,158,11,0.05); border-left: 3px solid #f59e0b; }

/* Layout & Spacing */
.main-content {
    margin-left: 260px;
    padding: 2.5rem; /* Standardized Page Padding */
    min-height: 100vh;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem; /* Standardized Header Margin */
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--card-border);
}

.grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 2rem; /* Standardized Grid Gap */
}

/* Cards */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border-radius: 1.25rem;
    padding: 2rem; /* Standardized Card Padding */
    border: 1px solid var(--card-border);
    height: 100%;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.card:hover { 
    transform: translateY(-2px);
    border-color: rgba(59, 130, 246, 0.2);
    box-shadow: 0 10px 30px -10px rgba(0,0,0,0.5);
}

.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; }
.col-9 { grid-column: span 9; }
.col-12 { grid-column: span 12; }

/* Typography */
.text-gradient {
    font-size: 1.8rem;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-value {
    font-size: 2.2rem;
    font-weight: 800;
    color: #fff;
    line-height: 1;
    margin-top: 0.25rem;
}

.stat-label {
    color: var(--text-dim);
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.08em;
}

/* Forms */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

label {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--text-dim);
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    border: 1px solid var(--card-border);
    border-radius: 0.5rem;
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
}

select option {
    background: #1e293b;
    color: white;
}

/* Buttons */
.btn-pill {
    padding: 0.4rem 1rem;
    border-radius: 2rem;
    color: white;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-block;
    border: none;
    cursor: pointer;
    background: rgba(255,255,255,0.05);
}

.btn-pill:hover { background: rgba(255,255,255,0.1); color: white; }

.btn-pill.active {
    background: var(--primary);
    color: white;
}

.btn-primary {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

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

.btn-secondary {
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text-dim);
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

.btn-submit {
    background: var(--primary);
    color: white;
    padding: 0.85rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    transition: background 0.2s;
}

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

.btn-del {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.btn-del:hover { background: var(--danger); color: white; }

/* Tables */
.scroll-table {
    overflow-y: auto;
    margin-top: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--card-border);
    font-size: 0.9rem;
}

th {
    color: var(--text-dim);
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Badges */
.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.type-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
}

.cat-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.badge-green { background: rgba(52,211,153,0.15); color: #34d399; padding: 0.2rem 0.6rem; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-blue { background: rgba(59,130,246,0.15); color: #60a5fa; padding: 0.2rem 0.6rem; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }

/* Specific Utilities */
.stat-row { display: flex; gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap; }
.stat-card { flex: 1; min-width: 180px; background: rgba(30, 41, 59, 0.4); border-radius: 1rem; padding: 1.5rem; border: 1px solid var(--card-border); border-bottom: 3px solid var(--primary); transition: transform 0.2s; }
.stat-card:hover { transform: translateY(-4px); }

#map {
    height: 600px;
    border-radius: 0.75rem;
    background: rgba(0,0,0,0.2);
}

.insight-stat {
    flex: 1;
    background: rgba(0,0,0,0.2);
    padding: 1rem;
    border-radius: 0.5rem;
    text-align: center;
    border-bottom: 3px solid var(--primary);
}

/* Sidebar */
.sidebar {
    width: 260px;
    height: 100vh;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0; top: 0;
    z-index: 100;
    padding: 1.2rem 0.75rem;
}
.sidebar-header { margin-bottom: 1.2rem; padding: 0.5rem; }
.logo { font-size: 1.4rem; font-weight: 800; background: linear-gradient(135deg,#60a5fa,#3b82f6); -webkit-background-clip:text; -webkit-text-fill-color:transparent; letter-spacing:-0.05em; }
.logo-sub { font-size: 0.7rem; color: #475569; text-transform: uppercase; letter-spacing: 0.1em; margin-top: 2px; }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 0.15rem; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.55rem 1rem; border-radius: 0.75rem; color: #94a3b8; text-decoration: none; font-weight: 500; font-size: 0.875rem; transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1); margin: 0 0.25rem; }
.nav-item:hover { background: rgba(255,255,255,0.04); color: #fff; transform: translateX(4px); }
.nav-item.active { background: linear-gradient(90deg, rgba(59,130,246,0.15) 0%, rgba(59,130,246,0.05) 100%); color: #60a5fa; border-left: 3px solid #3b82f6; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.nav-item .icon { font-size: 1rem; }
.sidebar-footer { padding-top: 0.8rem; border-top: 1px solid rgba(255,255,255,0.05); display: flex; flex-direction: column; gap: 0.5rem; }
.user-pill { display: flex; align-items: center; gap: 0.75rem; padding: 0.3rem 0.5rem; }
.user-avatar { width: 34px; height: 34px; background: linear-gradient(135deg, #3b82f6, #1d4ed8); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; }
.user-name { font-size: 0.875rem; font-weight: 600; color: #f8fafc; }
.user-role { font-size: 0.65rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; }
.logout-btn { color: #f87171; text-decoration: none; font-size: 0.8rem; font-weight: 600; padding: 0.5rem 1rem; opacity: 0.8; transition: opacity 0.2s; border-radius: 0.5rem; }
.logout-btn:hover { opacity: 1; background: rgba(248,113,113,0.1); }

/* Login Page Specific */
.login-body { display:flex; justify-content:center; align-items:center; height:100vh; overflow:hidden; }
.login-body::before { content:''; position:fixed; top:-50%; left:-50%; width:200%; height:200%; background: radial-gradient(ellipse at 60% 40%, rgba(59,130,246,0.08) 0%, transparent 60%), radial-gradient(ellipse at 20% 80%, rgba(139,92,246,0.06) 0%, transparent 50%); pointer-events:none; }
.login-card { background:rgba(30,41,59,0.6); backdrop-filter:blur(24px); padding:3rem; border-radius:1.5rem; border:1px solid rgba(255,255,255,0.08); width:420px; box-shadow:0 40px 80px -20px rgba(0,0,0,0.6); animation: fadeUp 0.4s ease; position: relative; z-index: 10; }
@keyframes fadeUp { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:translateY(0); } }
.login-logo { text-align:center; margin-bottom:2rem; }
.login-logo-icon { font-size:2.5rem; margin-bottom:0.5rem; }
.login-title { font-size:1.6rem; font-weight:800; background:linear-gradient(135deg,#60a5fa,#3b82f6); -webkit-background-clip:text; -webkit-text-fill-color:transparent; text-align:center; }
.login-subtitle { color:#64748b; font-size:0.85rem; text-align:center; margin-top:0.25rem; }
.error-box { background:rgba(248,113,113,0.1); border:1px solid rgba(248,113,113,0.3); color:#f87171; padding:0.75rem 1rem; border-radius:0.5rem; font-size:0.875rem; margin-bottom:1.5rem; text-align:center; }
.login-hints { margin-top:1.5rem; padding-top:1.5rem; border-top:1px solid rgba(255,255,255,0.05); }
.hint-title { font-size:0.7rem; text-transform:uppercase; color:#334155; font-weight:600; letter-spacing:0.08em; margin-bottom:0.5rem; }
.hint-row { display:flex; gap:0.5rem; margin-bottom:0.3rem; }
/* Modal System */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(11, 17, 32, 0.85);
    backdrop-filter: blur(8px);
    display: none; align-items: center; justify-content: center;
    z-index: 1000; transition: all 0.3s;
}
.modal-content {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1.5rem;
    width: 90%; max-width: 800px;
    max-height: 90vh; overflow-y: auto;
    padding: 2.5rem;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}
.modal-close {
    position: absolute; top: 1.5rem; right: 1.5rem;
    color: #94a3b8; cursor: pointer; font-size: 1.5rem;
    transition: color 0.2s;
}
.modal-close:hover { color: #fff; }
.modal-header { margin-bottom: 2rem; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 1rem; }
.modal-header h2 { font-size: 1.8rem; font-weight: 800; color: #fff; }
.modal-body { color: #cbd5e1; line-height: 1.6; }

@media (max-width: 760px) {
    body {
        overflow-x: hidden;
    }

    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        max-height: 250px;
        padding: 0.85rem;
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }

    .sidebar-header {
        margin-bottom: 0.65rem;
        padding: 0.2rem 0.35rem;
    }

    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 0.35rem;
        padding-bottom: 0.25rem;
        scrollbar-width: thin;
    }

    .nav-item {
        flex: 0 0 auto;
        white-space: nowrap;
        margin: 0;
        padding: 0.52rem 0.75rem;
    }

    .nav-item:hover {
        transform: none;
    }

    .sidebar-footer {
        display: none;
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
        min-height: auto;
    }

    header {
        align-items: flex-start;
        flex-direction: column;
        gap: 1rem;
        margin-bottom: 1.25rem;
        padding-bottom: 1rem;
    }

    .grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .col-3,
    .col-4,
    .col-5,
    .col-6,
    .col-7,
    .col-8,
    .col-9,
    .col-12 {
        grid-column: 1 / -1;
    }

    .card {
        padding: 1rem;
        border-radius: 1rem;
    }

    h1,
    .h1 {
        font-size: 1.55rem;
    }

    h2,
    .h2 {
        font-size: 1.25rem;
    }

    input,
    select,
    textarea,
    button {
        font-size: 16px;
    }

    input,
    select,
    textarea {
        min-height: 44px;
    }

    .modal-content {
        width: calc(100% - 2rem);
        padding: 1.5rem;
        border-radius: 1rem;
    }
}
