:root {
    --green-950: #0b2f22;
    --green-900: #123f2c;
    --green-700: #157247;
    --green-600: #1e915a;
    --green-100: #e9f8ef;
    --yellow-500: #ffd044;
    --yellow-100: #fff6d8;
    --ink: #111827;
    --muted: #728096;
    --line: #e5edf1;
    --panel: #ffffff;
    --page: #f5f8fb;
    --shadow: 0 14px 38px rgba(27, 47, 37, 0.08);
}

body {
    background: var(--page);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.login-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(255, 200, 61, 0.24), transparent 32rem),
        linear-gradient(135deg, #f6fbf8 0%, #eef8f2 100%);
}

.content-wrapper,
.app-main {
    width: 100%;
    max-width: 1480px;
    padding: 26px 28px 40px;
    margin: 0 auto;
}

.page-shell {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 252px;
    padding: 18px 14px;
    background: #ffffff;
    border-right: 1px solid var(--line);
    box-shadow: 12px 0 32px rgba(29, 55, 43, 0.04);
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--green-900);
    text-decoration: none;
    padding: 6px 8px 20px;
    margin-bottom: 4px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--green-600), #52c884);
    color: #fff;
    font-weight: 800;
}

.brand small,
.workspace-label span,
.user-menu small,
.metric-card small,
.activity-row small {
    display: block;
    color: var(--muted);
    font-size: 0.75rem;
}

.sidebar-nav {
    display: grid;
    gap: 5px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 40px;
    padding: 0 11px;
    border-radius: 8px;
    color: #5b687b;
    font-size: 0.92rem;
    font-weight: 700;
    text-decoration: none;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: linear-gradient(135deg, var(--green-600), #2fbf74);
    color: #fff;
    box-shadow: 0 10px 24px rgba(30, 145, 90, 0.22);
}

.sidebar-nav i {
    width: 20px;
    text-align: center;
}

.content-shell {
    width: 100%;
    margin-left: 252px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 72px;
    padding: 12px 28px;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.workspace-label {
    min-width: 160px;
}

.top-search {
    flex: 1;
    align-items: center;
    gap: 10px;
    max-width: 540px;
    padding: 0 16px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    color: var(--muted);
}

.top-search input {
    border: 0;
    outline: 0;
    width: 100%;
    background: transparent;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.icon-btn,
.user-menu {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
}

.icon-btn {
    position: relative;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    color: var(--green-700);
    box-shadow: 0 8px 20px rgba(22, 48, 34, 0.04);
}

.notify-dot {
    position: absolute;
    top: 9px;
    right: 9px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 4px 10px 4px 5px;
}

.avatar {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--green-100), var(--yellow-100));
    color: var(--green-700);
    font-weight: 800;
}

.flash-area {
    margin-bottom: 18px;
}

.hero-panel,
.dashboard-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 30px;
    border: 1px solid #e0e9ee;
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
}

.dashboard-hero {
    min-height: 210px;
    background:
        linear-gradient(115deg, rgba(255, 255, 255, 0.96) 0%, rgba(249, 253, 251, 0.96) 56%, rgba(255, 246, 216, 0.8) 100%),
        linear-gradient(135deg, rgba(30, 145, 90, 0.12), rgba(255, 208, 68, 0.14));
    position: relative;
    overflow: hidden;
}

.dashboard-hero::after {
    content: "";
    position: absolute;
    right: -90px;
    top: -80px;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: rgba(30, 145, 90, 0.08);
}

.dashboard-hero > * {
    position: relative;
    z-index: 1;
}

.hero-panel h1,
.dashboard-hero h1,
.page-title h1 {
    margin: 0;
    font-size: clamp(2.15rem, 4vw, 3rem);
    line-height: 1.06;
    font-weight: 800;
    letter-spacing: 0;
}

.hero-panel p,
.dashboard-hero p,
.page-title p {
    margin: 8px 0 0;
    color: var(--muted);
    max-width: 660px;
}

.hero-actions,
.page-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    min-height: 210px;
    padding: 30px;
    margin-bottom: 24px;
    border: 1px solid #e0e9ee;
    border-radius: 8px;
    background:
        linear-gradient(115deg, rgba(255, 255, 255, 0.96) 0%, rgba(249, 253, 251, 0.96) 56%, rgba(255, 246, 216, 0.8) 100%),
        linear-gradient(135deg, rgba(30, 145, 90, 0.12), rgba(255, 208, 68, 0.14));
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.page-title::after {
    content: "";
    position: absolute;
    right: -90px;
    top: -80px;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: rgba(30, 145, 90, 0.08);
}

.page-title > * {
    position: relative;
    z-index: 1;
}

.page-title > div {
    min-width: min(100%, 320px);
}

.eyebrow {
    display: block;
    color: #2764ff;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 16px;
}

.dashboard-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
}

.stat-grid.compact {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-card,
.stat-card,
.table-card,
.form-card,
.activity-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.table-card {
    overflow: hidden;
}

.table-card .table-responsive {
    width: 100%;
}

.metric-card {
    position: relative;
    min-height: 132px;
    padding: 18px 18px 16px;
    overflow: hidden;
}

.metric-card::after {
    content: "";
    position: absolute;
    right: -30px;
    bottom: -40px;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: rgba(30, 145, 90, 0.05);
}

.metric-card strong {
    display: block;
    margin-top: 6px;
    font-size: 1.9rem;
    line-height: 1.1;
    color: #111827;
}

.metric-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    margin-bottom: 12px;
    border-radius: 8px;
    font-size: 1.1rem;
}

.metric-icon.green { background: #e5f7ee; color: #187247; }
.metric-icon.mint { background: #dff9ef; color: #16805d; }
.metric-icon.amber { background: #fff3ce; color: #ad7600; }
.metric-icon.blue { background: #e8f0ff; color: #3159d4; }
.metric-icon.rose { background: #ffe9ef; color: #c13e62; }
.metric-icon.gray { background: #eef2f6; color: #526075; }

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.section-heading h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
}

.modern-table {
    margin-bottom: 0;
}

.modern-table thead th {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.modern-table td {
    border-color: #eef3f1;
    padding-top: 0.95rem;
    padding-bottom: 0.95rem;
    color: #263244;
}

.modern-table tbody tr:hover {
    background: #fbfdfc;
}

.badge-soft,
.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 10px;
    border-radius: 8px;
    font-weight: 700;
}

.badge-soft,
.status-pill.actif {
    background: #e9f6ef;
    color: #146c43;
}

.status-pill.bloque {
    background: #fff1d6;
    color: #966300;
}

.activity-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.activity-row:last-child {
    border-bottom: 0;
}

.action-menu form,
.action-menu button {
    width: 100%;
}

.action-menu button {
    text-align: left;
}

.form-control,
.form-select,
.btn {
    border-radius: 8px;
}

.btn-success {
    background: var(--green-600);
    border-color: var(--green-600);
}

.btn-success:hover {
    background: var(--green-700);
    border-color: var(--green-700);
}

.btn-warning {
    background: var(--yellow-500);
    border-color: var(--yellow-500);
    color: #2d260f;
    font-weight: 700;
    box-shadow: 0 10px 22px rgba(255, 208, 68, 0.24);
}

.btn-light {
    border-color: var(--line);
    font-weight: 700;
    color: #334155;
}

.citizen-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 44px;
}

.citizen-avatar-placeholder,
.citizen-photo-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e8f1ec;
    color: #16643b;
}

.citizen-photo-thumbnail {
    display: inline-flex;
    width: 120px !important;
    height: 150px !important;
    border-radius: 14px;
    object-fit: cover;
    border: 1px solid #d8e0dc;
    max-width: 120px !important;
}

.citizen-photo-button {
    appearance: none;
    border: 0;
    padding: 0;
    background: transparent;
    color: #16643b;
    cursor: zoom-in;
}

.citizen-photo-button > span {
    display: block;
    margin-top: 0.45rem;
    font-size: 0.82rem;
    font-weight: 600;
}

.citizen-photo-modal-body {
    background: #f4f6f5;
}

.citizen-photo-full {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 75vh;
    margin: 0 auto;
    object-fit: contain;
    border-radius: 8px;
}

.citizen-photo-preview {
    width: 90px;
    height: 110px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid #d8e0dc;
}

.citizen-search-box {
    position: relative;
}

.citizen-search-results {
    position: absolute;
    z-index: 1050;
    top: 100%;
    right: 0.75rem;
    left: 0.75rem;
    max-height: 22rem;
    overflow-y: auto;
    border-radius: 8px;
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.18);
}

@media print {
    .sidebar,
    .topbar,
    .no-print {
        display: none !important;
    }

    body {
        background: #fff;
    }

    .container-fluid {
        width: 100%;
        padding: 0;
    }
}

@media (max-width: 1199px) {
    .stat-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 991px) {
    .sidebar {
        display: none;
    }

    .content-shell {
        margin-left: 0;
    }

    .topbar {
        padding: 12px 16px;
    }

    .app-main {
        padding: 18px;
    }
}

@media (max-width: 767px) {
    .hero-panel,
    .dashboard-hero,
    .page-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .hero-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .stat-grid,
    .stat-grid.compact {
        grid-template-columns: 1fr;
    }

    .hero-panel,
    .dashboard-hero,
    .page-title {
        padding: 24px;
    }

    .app-main {
        padding: 16px;
    }
}
