:root {
    --brand-900: #001a3e;
    --brand-800: #001f49;
    --brand-700: #155e0e;
    --brand-600: #18752a;
    --brand-500: #efbd00;
    --brand-100: #fff4bd;
    --bg: #f2f5f2;
    --card: #ffffff;
    --text: #001f49;
    --muted: #64748b;
    --border: #e2e8f0;
    --success: #059669;
    --danger: #dc2626;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Inter, system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
}
a { color: var(--brand-700); text-decoration: none; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 280px;
    background: linear-gradient(180deg, #001a3e, #002b5d);
    color: #fff;
    padding: 1rem;
    position: fixed;
    inset: 0 auto 0 0;
    overflow-y: auto;
    z-index: 40;
    transform: translateX(0);
    transition: transform .25s ease;
}
.sidebar-brand {
    display: flex; gap: .75rem; align-items: center; padding: .5rem .25rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 1rem;
}
.sidebar-brand-text { min-width: 0; flex: 1; }
.sidebar-brand strong { display: block; font-size: 1rem; line-height: 1.25; }
.sidebar-brand span { font-size: .75rem; opacity: .8; }
.sidebar-close {
    display: none; align-items: center; justify-content: center;
    width: 36px; height: 36px; border: 0; border-radius: 10px;
    background: rgba(255,255,255,.12); color: #fff; cursor: pointer; flex-shrink: 0;
}
.sidebar-close:hover { background: rgba(255,255,255,.22); }
.sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(15, 41, 34, .45);
    z-index: 1100;
}
.sidebar-backdrop.is-visible { display: block; }
body.sidebar-open { overflow: hidden; }
.brand-icon {
    width: 42px; height: 42px; border-radius: 12px;
    background: rgba(255,255,255,.12);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
}
.brand-icon.lg { width: 56px; height: 56px; font-size: 1.5rem; margin: 0 auto 1rem; }
.admin-sg-mark {
    border-radius: 0; background: #efbd00; color: #001f49;
    font-family: Anton, Impact, sans-serif; font-size: 1rem; letter-spacing: .02em;
}
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; opacity: .65; margin: 1rem 0 .5rem; }
.nav-link {
    display: flex; align-items: center; gap: .65rem;
    padding: .7rem .85rem; border-radius: .75rem; color: rgba(255,255,255,.88);
    margin-bottom: .25rem; transition: .2s;
}
.nav-link:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-link.active { background: #155e0e; color: #fff; box-shadow: inset 4px 0 0 #efbd00; }

.app-main { flex: 1; margin-left: 280px; min-width: 0; }
.topbar {
    height: 64px; background: #fff; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 1rem; padding: 0 1rem; position: sticky; top: 0; z-index: 20;
    border-top: 3px solid #efbd00;
}
.menu-toggle {
    display: none; border: 0; background: var(--brand-100); color: var(--brand-800);
    width: 40px; height: 40px; border-radius: 10px; font-size: 1.2rem;
}
.topbar-title { min-width: 0; flex: 1 1 auto; overflow: hidden; }
.topbar-title strong {
    display: block; font-size: .95rem; line-height: 1.15;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-title span {
    display: block; font-size: .75rem; color: var(--muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.user-info { text-align: right; }
.user-info strong { display: block; font-size: .85rem; }
.badge-active { font-size: .68rem; color: var(--success); }
.btn-logout {
    width: 38px; height: 38px; border: 0; border-radius: 10px;
    background: #001f49; color: #fff; cursor: pointer;
}

.content-area { padding: 1rem; min-width: 0; overflow-x: hidden; }
[data-smart-filter-results] { min-width: 0; }
.mb-3 { margin-bottom: .75rem; }
.mb-4 { margin-bottom: 1.35rem; }
.mt-4 { margin-top: 1.35rem; }
.page-header { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.page-header h2 { margin: 0; font-size: 1.5rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.field-grow { flex: 1 1 240px; }
.field-actions { flex: 0 0 auto; }
.radio-row { display: flex; flex-wrap: wrap; gap: 1rem; }
.checkbox-inline { display: inline-flex; align-items: center; gap: .45rem; font-weight: 500; }
.permission-table-wrap { margin-top: .5rem; }
.permission-table th, .permission-table td { vertical-align: middle; }
.text-center { text-align: center; }
.input-compact { min-width: 130px; padding-top: .45rem; padding-bottom: .45rem; }

.card-panel {
    background: var(--card); border: 1px solid var(--border); border-radius: 16px;
    padding: 1rem; box-shadow: 0 8px 24px rgba(6,78,59,.06);
}
.card-title { margin: 0 0 .75rem; font-size: 1rem; }
.input-default {
    width: 100%; border: 1px solid #cbd5e1; border-radius: 10px;
    padding: .65rem .75rem; font: inherit; background: #fff;
}
.input-default:focus { outline: none; border-color: #155e0e; box-shadow: 0 0 0 3px rgba(21,94,14,.16); }
textarea.input-default { min-height: 110px; resize: vertical; line-height: 1.45; }
label, .label-default { display: block; font-size: .78rem; font-weight: 600; color: var(--muted); margin-bottom: .35rem; }

.btn-primary, .btn-secondary {
    display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
    padding: .65rem 1rem; border-radius: 10px; border: 0; cursor: pointer; font-weight: 600; text-decoration: none;
}
.btn-primary { background: linear-gradient(135deg, #155e0e, #248b37); color: #fff; }
.btn-primary:hover { background: #001f49; }
.btn-secondary { background: var(--brand-100); color: var(--brand-800); border: 1px solid #efbd00; }
.btn-sm { padding: .4rem .65rem; font-size: .82rem; }
.w-full { width: 100%; }

.filter-grid, .form-grid {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem;
}
.form-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.form-grid-3 .field.span-3 { grid-column: span 3; }
.field { min-width: 0; }
.field.span-2 { grid-column: span 2; }
.field.span-3 { grid-column: span 3; }
.field.span-4 { grid-column: span 4; }
.field.actions { display: flex; align-items: end; gap: .5rem; flex-wrap: wrap; }

.stats-grid {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem;
}
.stats-grid-5 {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}
.stats-grid-5 .stat-card {
    padding: .85rem .75rem;
}
.stats-grid-5 .stat-card span {
    font-size: .68rem;
    line-height: 1.25;
}
.stats-grid-5 .stat-card strong {
    font-size: 1.15rem;
    line-height: 1.2;
    word-break: break-word;
}
.stats-grid-6 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.stat-card {
    background: linear-gradient(135deg, #001f49, #155e0e);
    color: #fff; border-radius: 16px; padding: 1rem;
}
.stat-card span { display: block; font-size: .75rem; opacity: .85; }
.stat-card strong { font-size: 1.45rem; }

.charts-grid, .two-col-grid {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem;
}
.chart-box { height: 280px; position: relative; }

.table-wrap { overflow-x: auto; max-width: 100%; }
.table-default { width: 100%; border-collapse: collapse; }
.table-wrap .table-default { min-width: 640px; }
.table-default th, .table-default td { padding: .7rem; border-bottom: 1px solid var(--border); text-align: left; font-size: .88rem; vertical-align: top; }
.table-default th { background: #f8fafc; color: #475569; }

.table-compact {
    width: 100%; min-width: 0; border-collapse: collapse; table-layout: fixed;
}
.table-compact th, .table-compact td {
    padding: .55rem .35rem; border-bottom: 1px solid var(--border);
    font-size: .86rem; vertical-align: top; word-break: break-word;
}
.table-compact th { background: #f8fafc; color: #475569; text-align: left; }
.table-compact th:last-child, .table-compact td:last-child { text-align: right; white-space: nowrap; width: 72px; }

.report-premium-header { margin-bottom: .25rem; }
.report-premium-header h2 { margin: .15rem 0 0; }
.report-premium-badge {
    display: inline-block; margin: 0 0 .35rem; padding: .2rem .55rem;
    border-radius: 999px; background: var(--brand-100); color: var(--brand-800);
    font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}
.report-premium-subtitle { margin: .35rem 0 0; color: var(--muted); font-size: .86rem; }
.report-premium {
    display: flex;
    flex-direction: column;
    gap: 1.35rem;
    padding-top: .25rem;
}
.report-premium > .stats-grid,
.report-premium > .two-col-grid,
.report-premium > .card-panel {
    margin-bottom: 0 !important;
}
.report-card .card-title { margin-bottom: .65rem; }
.report-card-help { margin: 0 0 1rem; color: var(--muted); font-size: .82rem; }
.report-card { min-width: 0; }
.smart-filter-with-period { margin-bottom: 1.35rem !important; }

.status-pill { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.status-active { background: #dcfce7; color: #166534; }
.status-inactive { background: #fee2e2; color: #991b1b; }

.actions-cell { white-space: nowrap; }
.action-icon {
    display: inline-flex; width: 32px; height: 32px; align-items: center; justify-content: center;
    border-radius: 8px; border: 0; background: #f1f5f9; margin-right: .25rem;
}
.action-icon.wa { color: #16a34a; }
.action-icon.mail { color: #2563eb; }
.action-icon.edit { color: var(--brand-700); }
.action-icon.delete { color: var(--danger); }
.inline-form { display: inline; }

.pagination { display: flex; gap: .35rem; margin-top: 1rem; }
.pagination a {
    width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px; background: #fff; border: 1px solid var(--border); color: var(--text);
}
.pagination a.active { background: var(--brand-700); color: #fff; border-color: var(--brand-700); }

.alert { padding: .85rem 1rem; border-radius: 10px; margin-bottom: 1rem; }
.alert-success { background: #ecfdf5; color: #065f46; }
.alert-danger { background: #fef2f2; color: #991b1b; }

.tabs { display: flex; gap: .5rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.tab-btn {
    border: 0; background: transparent; padding: .75rem 1rem; cursor: pointer;
    border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600;
}
.tab-btn.active { color: var(--brand-700); border-bottom-color: var(--brand-700); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.toggle-group { display: flex; gap: .5rem; flex-wrap: wrap; }
.toggle-option {
    display: inline-flex; align-items: center; gap: .35rem; padding: .55rem .85rem;
    border: 1px solid var(--border); border-radius: 999px; cursor: pointer;
}
.form-actions { display: flex; justify-content: flex-end; margin-top: 1rem; }
.smart-filter { padding: 1rem 1.25rem; }
.smart-filter-wrap {
    position: relative; display: flex; align-items: center;
}
.smart-filter-icon {
    position: absolute; left: .85rem; color: var(--muted); pointer-events: none; z-index: 1;
}
.smart-filter-input { padding-left: 2.35rem; padding-right: 2.5rem; }
.smart-filter-clear {
    position: absolute; right: .45rem; color: var(--muted); display: inline-flex;
    align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 999px;
    border: 0; background: transparent; cursor: pointer; padding: 0;
}
.smart-filter-clear.is-hidden { display: none; }
.smart-filter-clear:hover { background: #f1f5f9; color: var(--text); }
[data-smart-filter-results].is-loading { opacity: .55; pointer-events: none; transition: opacity .15s ease; }
.filter-period-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .75rem;
    margin-top: .75rem;
}
.filter-period-help { margin: .5rem 0 0; }
.smart-filter-with-period > .field > .field-help { margin-bottom: 0; }
.field-autocomplete { position: relative; }
.field-help { margin: .35rem 0 0; font-size: .72rem; color: var(--muted); }
.field-autocomplete .autocomplete-list {
    position: absolute; z-index: 30; background: #fff; border: 1px solid var(--border);
    border-radius: 10px; width: 100%; max-height: 220px; overflow: auto; display: none;
    left: 0; top: calc(100% - 1.35rem); box-shadow: 0 8px 24px rgba(15, 23, 42, .12);
}
.field-autocomplete .autocomplete-list:empty { display: none !important; }
.field-autocomplete .field-help { position: relative; z-index: 1; }
.autocomplete-list.show { display: block; }
.autocomplete-item { padding: .65rem .75rem; cursor: pointer; }
.autocomplete-item:hover { background: var(--brand-100); }

.geo-map { height: 420px; border-radius: 12px; overflow: hidden; position: relative; z-index: 0; isolation: isolate; }
.geo-map .leaflet-container { z-index: 0 !important; }
.geo-map .leaflet-pane,
.geo-map .leaflet-top,
.geo-map .leaflet-bottom { z-index: 1 !important; }
.map-legend { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: .75rem; font-size: .85rem; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .35rem; }
.dot.leadership { background: #2563eb; }
.dot.led { background: var(--brand-600); }
.dot.collaborator { background: #16a34a; }
.dot.resident { background: #ea580c; }

.text-success { color: var(--success); font-weight: 700; }
.text-danger { color: var(--danger); font-weight: 700; }

.module-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.module-card {
    min-height: 230px; display: flex; flex-direction: column; position: relative; overflow: hidden;
    padding: 1.5rem; border-radius: 20px; color: #fff; box-shadow: 0 18px 40px rgba(15, 41, 34, .14);
    transition: transform .2s ease, box-shadow .2s ease;
}
.report-filter-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .75rem; }
.module-card:hover { color: #fff; transform: translateY(-4px); box-shadow: 0 24px 48px rgba(15, 41, 34, .2); }
.module-card-campaign { background: linear-gradient(145deg, #155e0e, #248b37); }
.module-card-amendments { background: linear-gradient(145deg, #001a3e, #003b77); }
.module-card-site { background: linear-gradient(145deg, #b48700, #efbd00); }
.module-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 15px; background: rgba(255,255,255,.16); font-size: 1.4rem; margin-bottom: 1.35rem; }
.module-card small { display: block; text-transform: uppercase; letter-spacing: .12em; opacity: .78; font-size: .65rem; font-weight: 800; }
.module-card strong { display: block; font-size: 1.3rem; margin: .2rem 0 .55rem; }
.module-card p { margin: 0; color: rgba(255,255,255,.82); line-height: 1.55; font-size: .86rem; }
.module-arrow { position: absolute; right: 1.35rem; top: 1.35rem; font-size: 1.2rem; }

.guest-body {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background:
        linear-gradient(120deg, rgba(0, 26, 62, .94), rgba(21, 94, 14, .73)),
        url('../site/login-background.png') center center / cover no-repeat fixed;
    padding: 1rem;
}
.login-wrap { width: 100%; max-width: 420px; }
.login-card {
    position: relative; overflow: hidden; background: rgba(255,255,255,.96); border-radius: 18px; padding: 2rem;
    border: 1px solid rgba(255,255,255,.7); border-top: 6px solid #efbd00;
    box-shadow: 0 24px 70px rgba(0,18,45,.42); backdrop-filter: blur(8px);
}
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand-lockup { display: inline-flex; align-items: center; gap: .7rem; text-align: left; }
.login-sg { width: 48px; height: 48px; display: grid; place-items: center; background: #efbd00; color: #001f49; font: 400 18px Anton, Impact, sans-serif; }
.login-brand-copy strong { display: block; color: #001f49; font: 400 19px/1 Anton, Impact, sans-serif; text-transform: uppercase; }
.login-brand-copy small { display: block; margin-top: 5px; color: #155e0e; font-size: .62rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.login-brand p { margin: .85rem 0 0; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.login-form label { display: block; margin: .75rem 0 .35rem; font-weight: 600; font-size: .85rem; }
.login-hint { margin-top: 1rem; font-size: .72rem; color: var(--muted); text-align: center; }
.login-hint i { color: #155e0e; margin-right: .25rem; }

@media (min-width: 1200px) {
    .stats-grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
    .module-grid { grid-template-columns: 1fr; }
    .report-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sidebar {
        transform: translateX(-100%);
        z-index: 1200;
        box-shadow: 8px 0 32px rgba(0, 0, 0, .18);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: inline-flex; }
    .app-main { margin-left: 0; }
    .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .topbar-title strong { font-size: .78rem; }
    .topbar-title span { font-size: .66rem; }
    .user-info strong { font-size: .78rem; }
    .stats-grid, .stats-grid-5, .stats-grid-6, .charts-grid, .two-col-grid, .filter-grid, .form-grid, .form-grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .stats-grid-5 {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
    .form-grid-3 .field.span-3 { grid-column: span 2; }
}
@media (max-width: 640px) {
    .report-filter-grid { grid-template-columns: 1fr; }
    .stats-grid, .stats-grid-5, .stats-grid-6, .charts-grid, .two-col-grid, .filter-grid, .form-grid, .form-grid-3 {
        grid-template-columns: 1fr;
    }
    .stats-grid-5 {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: .65rem;
        padding-bottom: .15rem;
    }
    .stats-grid-5 .stat-card {
        flex: 0 0 148px;
        min-width: 148px;
    }
    .filter-period-grid { grid-template-columns: 1fr; }
    .topbar { gap: .5rem; padding: 0 .65rem; }
    .topbar-title strong { font-size: .72rem; }
    .topbar-title span { display: block; font-size: .62rem; }
    .user-info strong { font-size: .72rem; max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .field.span-2, .field.span-3, .field.span-4, .form-grid-3 .field.span-3 { grid-column: span 1; }
    .page-header, .topbar-user .user-info { flex-direction: column; align-items: flex-start; }
    .user-info { text-align: left; }
}
