/* ========== RESET & BASE ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --primary: #1a5632;
    --primary-light: #2a7a48;
    --primary-dark: #0e3a20;
    --accent: #c8102e;
    --accent-light: #e63950;
    --gold: #d4a017;
    --bg: #f0f2f5;
    --card: #ffffff;
    --text: #1a1a2e;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --sidebar-w: 260px;
    --topbar-h: 60px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --radius: 8px;
}
html { font-size: 14px; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); display: flex; min-height: 100vh; }

/* ========== SIDEBAR ========== */
.sidebar {
    width: var(--sidebar-w); background: var(--primary-dark); color: #fff;
    display: flex; flex-direction: column; position: fixed; top: 0; left: 0;
    height: 100vh; z-index: 100; transition: transform 0.3s;
}
.sidebar-header { padding: 16px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon {
    width: 40px; height: 40px; background: var(--accent); border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 16px; color: #fff; flex-shrink: 0;
}
.logo-text strong { display: block; font-size: 12px; line-height: 1.3; }
.logo-text span { font-size: 10px; opacity: 0.7; }
.nav-menu { list-style: none; flex: 1; overflow-y: auto; padding: 8px 0; }
.nav-item {
    display: flex; align-items: center; gap: 10px; padding: 11px 20px;
    cursor: pointer; font-size: 13px; transition: all 0.2s; color: rgba(255,255,255,0.7);
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.15); color: #fff; border-right: 3px solid var(--gold); }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.1); }
.user-info { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.user-avatar {
    width: 34px; height: 34px; background: var(--gold); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12px; color: var(--primary-dark);
}
.user-info span { opacity: 0.6; display: block; }

/* ========== MAIN CONTENT ========== */
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; }
.topbar {
    height: var(--topbar-h); background: var(--card); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 24px; gap: 16px;
    position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow);
}
.menu-toggle { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text); }
.page-title { font-size: 18px; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.search-box input {
    padding: 8px 14px; border: 1px solid var(--border); border-radius: 20px;
    font-size: 13px; width: 220px; outline: none; transition: border 0.2s;
}
.search-box input:focus { border-color: var(--primary); }
.notifications { position: relative; cursor: pointer; font-size: 20px; }
.notif-badge {
    position: absolute; top: -6px; right: -8px; background: var(--accent);
    color: #fff; font-size: 10px; width: 18px; height: 18px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.page-container { padding: 20px 24px; flex: 1; }
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ========== KPI CARDS ========== */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi-card {
    background: var(--card); border-radius: var(--radius); padding: 18px;
    box-shadow: var(--shadow); border-left: 4px solid #ccc;
}
.kpi-green { border-left-color: #22c55e; }
.kpi-blue { border-left-color: #3b82f6; }
.kpi-orange { border-left-color: #f59e0b; }
.kpi-red { border-left-color: var(--accent); }
.kpi-purple { border-left-color: #8b5cf6; }
.kpi-teal { border-left-color: #14b8a6; }
.kpi-label { font-size: 12px; color: var(--text-light); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-value { font-size: 26px; font-weight: 700; line-height: 1.2; }
.kpi-change { font-size: 11px; color: var(--text-light); margin-top: 6px; }
.kpi-change.up { color: #22c55e; }
.kpi-change.up::before { content: "\25B2 "; }
.kpi-change.down { color: var(--accent); }
.kpi-change.down::before { content: "\25BC "; }

/* ========== CARDS & GRIDS ========== */
.card { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; color: var(--primary-dark); }
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ========== TABLES ========== */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-header h2 { font-size: 20px; font-weight: 700; }
.filters-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters-bar select, .filters-bar input {
    padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 13px; background: #fff; outline: none;
}
.table-container { overflow-x: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
    background: var(--primary-dark); color: #fff; padding: 10px 14px;
    text-align: left; font-weight: 600; white-space: nowrap;
}
.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.data-table tbody tr:hover { background: #f8f9fa; }

/* ========== BUTTONS ========== */
.btn {
    padding: 8px 18px; border: none; border-radius: 6px; font-size: 13px;
    font-weight: 600; cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-secondary { background: #e5e7eb; color: var(--text); }
.btn-secondary:hover { background: #d1d5db; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { background: var(--accent); color: #fff; }

/* ========== BADGES ========== */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 12px;
    font-size: 11px; font-weight: 600;
}
.badge-green { background: #dcfce7; color: #166534; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-orange { background: #fef3c7; color: #92400e; }
.badge-red { background: #fce7e7; color: #991b1b; }
.badge-purple { background: #f3e8ff; color: #6b21a8; }
.badge-gray { background: #f3f4f6; color: #374151; }

/* ========== PROGRESS BARS ========== */
.agenda-progress { display: flex; flex-direction: column; gap: 14px; }
.agenda-item { display: flex; align-items: center; gap: 12px; }
.agenda-item > span { min-width: 200px; font-size: 13px; font-weight: 500; }
.progress-bar { flex: 1; height: 24px; background: #e5e7eb; border-radius: 12px; overflow: hidden; }
.progress-fill {
    height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 12px; display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 11px; font-weight: 700; transition: width 1s ease;
}

/* ========== COUNTY GRID ========== */
.county-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.county-card {
    padding: 10px 14px; border-radius: 6px; font-size: 12px; font-weight: 600;
    text-align: center; border: 1px solid var(--border);
}
.county-card.operational { background: #dcfce7; color: #166534; border-color: #86efac; }
.county-card.opening { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.county-card.planned { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

/* ========== SERVICE LIST ========== */
.service-list { list-style: none; }
.service-list li { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.service-list li::before { content: "\2713"; color: var(--primary); font-weight: 700; }

/* ========== WORKFLOW PIPELINE ========== */
.workflow-pipeline { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; padding: 20px 0; }
.pipeline-stage {
    background: var(--bg); border: 2px solid var(--primary); border-radius: var(--radius);
    padding: 16px 24px; text-align: center; min-width: 120px;
}
.pipeline-stage h4 { font-size: 12px; color: var(--text-light); margin-bottom: 6px; }
.pipeline-count { font-size: 28px; font-weight: 800; color: var(--primary); }
.pipeline-arrow { font-size: 24px; color: var(--primary); }
.stage-complete { background: var(--primary); }
.stage-complete h4, .stage-complete .pipeline-count { color: #fff; }

/* ========== MODALS ========== */
.modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 200; align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--card); border-radius: 12px; width: 90%; max-width: 600px;
    max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 18px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-light); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full-width { grid-column: span 2; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-light); }
.form-group input, .form-group select, .form-group textarea {
    padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 13px; font-family: inherit; outline: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); }

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
    .grid-2col { grid-template-columns: 1fr; }
    .agenda-item { flex-direction: column; align-items: flex-start; }
    .agenda-item > span { min-width: auto; }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .search-box { display: none; }
    .kpi-row { grid-template-columns: 1fr 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .form-group.full-width { grid-column: span 1; }
    .filters-bar { flex-direction: column; }
    .workflow-pipeline { flex-direction: column; }
    .pipeline-arrow { transform: rotate(90deg); }
}
