:root {
    --bg: #f4f5fb;
    --surface: #ffffff;
    --surface-soft: #f8f8fe;
    --surface-strong: #fcfbff;
    --line: rgba(114, 107, 194, 0.14);
    --text: #12284b;
    --muted: #6e7c96;
    --accent: #726bc2;
    --accent-soft: #e9e7fb;
    --accent-strong: #5f57b4;
    --success: #20b26b;
    --shadow: 0 18px 40px rgba(32, 46, 104, 0.08);
    --sidebar-shadow: 0 10px 30px rgba(38, 27, 109, 0.22);
}

html {
    font-size: 16px;
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background: linear-gradient(180deg, #f7f8fd 0%, var(--bg) 100%);
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

a {
    color: var(--accent-strong);
}

.app-layout-shell {
    display: grid;
    grid-template-columns: 228px minmax(0, 1fr);
    min-height: 100vh;
}

.mobile-sidebar-backdrop {
    display: none;
}

.app-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 1.5rem 1rem;
    background: linear-gradient(180deg, #746bca 0%, #6a62c1 100%);
    color: #fff;
    box-shadow: var(--sidebar-shadow);
}

.sidebar-brand {
    display: grid;
    justify-items: center;
    gap: 0.9rem;
    padding: 1rem 0.75rem 1.25rem;
    text-align: center;
}

.sidebar-logo-wrap {
    width: 112px;
    display: flex;
    justify-content: center;
}

.sidebar-logo {
    width: 100%;
    height: auto;
    display: block;
}

.sidebar-brand-text {
    display: grid;
    gap: 0.2rem;
    justify-items: center;
}

    .sidebar-brand-text strong {
        font-size: 1.15rem;
        font-weight: 700;
        letter-spacing: -0.02em;
    }

    .sidebar-brand-text span {
        color: rgba(255, 255, 255, 0.78);
        font-size: 0.92rem;
    }

.sidebar-nav,
.sidebar-footer {
    display: grid;
    gap: 0.35rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 0.8rem 1rem;
    border-radius: 14px;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.18s ease, transform 0.18s ease;
}

    .sidebar-link:hover,
    .sidebar-link:focus,
    .sidebar-link-secondary {
        background: rgba(255, 255, 255, 0.14);
        color: #fff;
    }

.sidebar-footer {
    margin-top: auto;
}

.app-main-area {
    min-width: 0;
    padding: 1rem 1.25rem 1.5rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.15rem;
}

.mobile-menu-button {
    display: none;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid #dfe4f0;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 6px 18px rgba(27, 40, 84, 0.08);
}

    .mobile-menu-button i {
        font-size: 1rem;
        color: #6e7c96;
        transition: transform 0.18s ease;
    }

    .mobile-menu-button:hover,
    .mobile-menu-button:focus {
        background: #f8f9fe;
        border-color: #d2d8e9;
    }

    .mobile-menu-button[aria-expanded="true"] i {
        transform: rotate(180deg);
    }

.topbar-search {
    flex: 1;
    max-width: 420px;
}

    .topbar-search input {
        width: 100%;
        min-height: 46px;
        padding: 0.8rem 1rem;
        border: 1px solid #dde2f1;
        border-radius: 999px;
        background: #f5f6fb;
        color: var(--muted);
        font-size: 0.98rem;
    }

.topbar-system {
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 600;
}

.app-shell {
    padding: 0;
}

.hero-panel,
.map-card,
.panel-card,
.data-table-panel {
    border: 1px solid #e2e6f2;
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.hero-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(240px, 0.8fr);
    gap: 1.25rem;
    padding: 1.6rem;
    margin-bottom: 1.25rem;
}

.eyebrow,
.section-label,
.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.hero-copy h1 {
    margin: 0.8rem 0 0.5rem;
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1.05;
    letter-spacing: -0.04em;
    font-weight: 700;
}

.hero-summary {
    max-width: 72ch;
    color: var(--muted);
    font-size: 1rem;
}

.hero-highlights {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 1.2rem;
}

    .hero-highlights span {
        padding: 0.75rem 0.9rem;
        border-radius: 16px;
        background: var(--surface-soft);
        border: 1px solid #edf0f7;
        color: var(--muted);
    }

.hero-stats {
    display: grid;
    gap: 0.9rem;
}

.stat-card {
    display: grid;
    gap: 0.35rem;
    align-content: center;
    min-height: 120px;
    padding: 1.15rem;
    border-radius: 18px;
    background: var(--surface);
    border: 1px solid #e2e6f2;
    color: var(--text);
}

    .stat-card strong {
        font-size: 2rem;
        line-height: 1;
        font-weight: 700;
    }

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(320px, 0.95fr);
    gap: 1.25rem;
}

.map-card,
.panel-card,
.data-table-panel {
    padding: 1.35rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.map-actions {
    display: grid;
    justify-items: end;
    gap: 0.85rem;
}

.map-action-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.section-header h2 {
    margin: 0.35rem 0 0;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.section-header p {
    max-width: 26ch;
    margin: 0;
    color: var(--muted);
}

.map-canvas {
    min-height: 560px;
    border-radius: 18px;
    border: 1px solid #e1e5f2;
    overflow: hidden;
    background: #eef1fb;
}

.map-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-top: 0.8rem;
    flex-wrap: wrap;
}

.map-status {
    color: var(--muted);
    font-size: 0.92rem;
}

.active-source-chip {
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    background: #f0effd;
    color: var(--accent-strong);
    font-weight: 700;
}

.data-source-button,
.source-confirm-button {
    border: 1px solid transparent;
    border-radius: 12px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    padding: 0.72rem 1.1rem;
    box-shadow: 0 8px 20px rgba(114, 107, 194, 0.18);
}

    .data-source-button:hover,
    .data-source-button:focus,
    .source-confirm-button:hover,
    .source-confirm-button:focus {
        background: var(--accent-strong);
        color: #fff;
    }

    .source-confirm-button:disabled {
        opacity: 0.55;
        cursor: not-allowed;
    }

.sidebar-stack {
    display: grid;
    gap: 1.25rem;
}

.generic-chart {
    display: grid;
    gap: 0.8rem;
}

.chart-empty,
.table-empty {
    color: var(--muted);
    text-align: center;
    padding: 1rem;
}

.chart-bar {
    display: grid;
    gap: 0.35rem;
}

.chart-bar-label {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.chart-bar-track {
    height: 10px;
    border-radius: 999px;
    background: #eef0fb;
    overflow: hidden;
}

.chart-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), #908ae0);
}

.layer-list,
.source-list {
    display: grid;
    gap: 0.9rem;
}

.layer-item,
.source-card {
    padding: 1rem;
    border-radius: 18px;
    background: var(--surface-strong);
    border: 1px solid #e7ebf6;
}

.layer-toggle {
    display: flex;
    gap: 0.9rem;
    align-items: flex-start;
}

    .layer-toggle input,
    .form-check-input {
        margin-top: 0.35rem;
        transform: scale(1.15);
        accent-color: var(--accent);
    }

    .layer-toggle strong,
    .source-card h3 {
        display: block;
        margin-bottom: 0.25rem;
        font-family: "Segoe UI", Tahoma, Arial, sans-serif;
        font-size: 0.98rem;
        font-weight: 700;
    }

.layer-meta,
.source-card p,
.source-card dd,
.source-topline {
    color: var(--muted);
}

.layer-meta {
    margin-top: 0.45rem;
    font-size: 0.92rem;
}

.source-topline {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-bottom: 0.9rem;
    font-size: 0.88rem;
}

.source-card dl,
.source-card dd,
.source-card dt {
    margin: 0;
}

.source-card dl {
    margin-top: 1rem;
}

.source-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

    .source-actions a {
        font-weight: 700;
        text-decoration: none;
    }

.source-card.is-dimmed {
    opacity: 0.45;
}

.data-table-panel {
    margin-top: 1.25rem;
}

.generic-data-table th {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.generic-data-table td {
    vertical-align: middle;
    color: var(--text);
}

.source-modal {
    border: 1px solid #e2e6f2;
    border-radius: 22px;
    background: var(--surface-strong);
}

.modal-header,
.source-modal-footer {
    border-color: #e9edf6;
    padding: 1.2rem 1.35rem;
}

.modal-body {
    padding: 1.35rem;
}

.modal-label {
    display: block;
    margin-bottom: 0.6rem;
    font-weight: 700;
    color: var(--accent-strong);
}

.source-select {
    min-height: 3rem;
    border-radius: 14px;
    border-color: #dfe4f0;
}

    .source-select:focus {
        border-color: var(--accent);
        box-shadow: 0 0 0 0.2rem rgba(114, 107, 194, 0.16);
    }

.read-mode-group {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid #e7ebf6;
    border-radius: 16px;
    background: #fafaff;
}

    .read-mode-group .form-check + .form-check {
        margin-top: 0.75rem;
    }

.source-details-card {
    margin-top: 1rem;
    padding: 1.1rem;
    border-radius: 18px;
    background: #fafaff;
    border: 1px solid #e7ebf6;
}

    .source-details-card h3 {
        margin-bottom: 0.65rem;
    }

.source-details-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
    margin-top: 1rem;
}

.source-details-item {
    padding: 0.9rem;
    border-radius: 14px;
    background: #fff;
    border: 1px solid #eaedf7;
}

    .source-details-item strong {
        display: block;
        margin-bottom: 0.25rem;
        color: var(--accent-strong);
    }

.source-placeholder {
    margin: 0;
    color: var(--muted);
}

.print-only {
    display: none;
}

.print-caption {
    margin-top: 0.8rem;
    color: var(--muted);
    font-size: 0.95rem;
}

.map-popup,
.popup-result {
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

.popup-result {
    margin-top: 0.65rem;
}

.toast-container {
    z-index: 1080;
}

.info-page {
    max-width: 900px;
}

@media (max-width: 1100px) {
    .app-layout-shell {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(82vw, 280px);
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
    }

        .app-sidebar.is-open {
            transform: translateX(0);
        }

    .mobile-sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 22, 53, 0.34);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.22s ease;
        z-index: 1040;
    }

        .mobile-sidebar-backdrop.is-open {
            opacity: 1;
            pointer-events: auto;
        }

    .mobile-menu-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 991px) {
    .hero-panel,
    .content-grid {
        grid-template-columns: 1fr;
    }

    .section-header {
        flex-direction: column;
    }

        .section-header p {
            max-width: none;
        }

    .map-actions {
        justify-items: start;
    }

    .map-action-buttons {
        justify-content: flex-start;
    }

    .source-details-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        flex-wrap: wrap;
        align-items: center;
    }

    .topbar-search {
        max-width: calc(100% - 62px);
        flex: 1;
    }
}

@media (max-width: 767px) {
    .app-main-area {
        padding: 0.9rem;
    }

    .topbar {
        justify-content: flex-start;
    }

    .topbar-title {
        width: 100%;
        order: 3;
    }

    .hero-panel,
    .map-card,
    .panel-card,
    .data-table-panel {
        padding: 1rem;
        border-radius: 18px;
    }

    .map-canvas {
        min-height: 420px;
    }

    .hero-copy h1 {
        font-size: 2.2rem;
    }
}

@page {
    size: A4 landscape;
    margin: 12mm;
}

@media print {
    body {
        background: #fff;
    }

    .app-sidebar,
    .topbar,
    .hero-panel,
    .sidebar-stack,
    .modal,
    .map-actions,
    .map-toolbar,
    .data-table-panel,
    .toast-container {
        display: none !important;
    }

    .app-layout-shell,
    .app-main-area,
    .app-shell,
    .content-grid,
    .map-card {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0;
        box-shadow: none;
        border: 0;
        background: #fff;
    }

    .content-grid {
        display: block;
    }

    .map-card {
        page-break-inside: avoid;
    }

    .map-canvas {
        min-height: 170mm;
        height: 170mm;
        border-radius: 0;
        border: 1px solid #d7dbec;
    }

    .print-only {
        display: block;
    }
}
