:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --ink: #172033;
    --muted: #667085;
    --line: #d9e2ef;
    --brand: #0f766e;
    --brand-2: #1d4ed8;
    --accent: #f59e0b;
    --danger: #dc2626;
    --shadow: 0 12px 30px rgba(23, 32, 51, 0.12);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    font-size: 14px;
    letter-spacing: 0;
}

a {
    color: var(--brand-2);
}

.skip-link {
    position: fixed;
    left: 14px;
    top: 10px;
    z-index: 2000;
    transform: translateY(-140%);
    border-radius: 8px;
    padding: 9px 12px;
    background: var(--ink);
    color: #ffffff;
    font-weight: 800;
    text-decoration: none;
}

.skip-link:focus {
    transform: translateY(0);
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 0 rgba(23, 32, 51, 0.04);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 220px;
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--brand);
    color: #fff;
    font-weight: 800;
}

.brand h1 {
    margin: 0;
    font-size: 19px;
    line-height: 1.1;
}

.brand span {
    color: var(--muted);
    font-size: 12px;
}

.tabs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px;
    background: #edf2f7;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.tab-btn {
    appearance: none;
    border: 0;
    border-radius: 6px;
    padding: 8px 12px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-weight: 650;
}

.tab-btn:hover {
    color: var(--ink);
}

.tab-btn.active {
    background: var(--panel);
    color: var(--ink);
    box-shadow: 0 1px 3px rgba(23, 32, 51, 0.12);
}

.status-pill {
    min-width: 230px;
    max-width: 36vw;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: #fbfdff;
}

.workspace {
    min-height: 0;
}

.view {
    display: none;
    height: calc(100vh - 66px);
}

.view.active {
    display: block;
}

.home-layout {
    height: 100%;
    overflow: auto;
    padding: 18px;
}

.home-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    gap: 14px;
    margin-bottom: 14px;
}

.home-intro {
    position: relative;
    min-height: 280px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
    overflow: hidden;
    background: linear-gradient(135deg, #ffffff 0%, #f8fbff 58%, #eef8f3 100%);
    box-shadow: var(--shadow);
}

.home-intro::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 4px;
    background: linear-gradient(90deg, var(--brand), var(--brand-2), var(--accent));
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 9px;
    border: 1px solid rgba(15, 118, 110, 0.22);
    border-radius: 999px;
    color: var(--brand);
    background: rgba(15, 118, 110, 0.08);
    font-size: 12px;
    font-weight: 800;
}

.home-intro h2 {
    max-width: 760px;
    margin: 18px 0 12px;
    font-size: 30px;
    line-height: 1.12;
}

.home-intro p,
.home-panel p,
.section-head p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
}

.quick-actions .btn {
    min-width: 130px;
    padding: 0 14px;
}

.home-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-content: start;
}

.home-summary .metric {
    min-height: 86px;
}

.home-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.home-panel {
    min-height: 150px;
}

.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
}

.section-head h2 {
    margin-bottom: 4px;
}

.variant-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.variant-card {
    appearance: none;
    display: grid;
    gap: 8px;
    min-height: 132px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 13px;
    background: #fbfdff;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
}

.variant-card strong {
    font-size: 15px;
}

.variant-card span {
    color: var(--muted);
    line-height: 1.45;
}

.variant-card small {
    align-self: end;
    color: var(--brand);
    font-weight: 800;
}

.variant-card:hover,
.variant-card.active {
    border-color: rgba(15, 118, 110, 0.48);
    background: #f4fbf8;
    box-shadow: 0 8px 18px rgba(15, 118, 110, 0.12);
}

.map-layout {
    display: grid;
    grid-template-columns: minmax(390px, 420px) minmax(0, 1fr);
    height: 100%;
    min-height: 0;
}

.sidebar {
    overflow-x: hidden;
    overflow-y: auto;
    border-right: 1px solid var(--line);
    background: var(--panel);
    padding: 14px;
    min-width: 0;
}

.map-wrap {
    position: relative;
    min-width: 0;
    min-height: 0;
}

#map {
    width: 100%;
    height: 100%;
    background: #dde7f0;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(23, 32, 51, 0.05);
}

.sidebar .panel {
    overflow: hidden;
}

.panel h2 {
    margin: 0 0 10px;
    font-size: 15px;
}

.field {
    display: grid;
    gap: 6px;
    margin-bottom: 10px;
}

.field label,
.check-row span,
.metric-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.tech-meta {
    display: block;
    margin-top: 2px;
    color: #8492a6;
    font-size: 11px;
    font-weight: 600;
}

select,
input[type="datetime-local"],
input[type="number"],
input[type="range"] {
    width: 100%;
    min-width: 0;
}

select,
input[type="datetime-local"],
input[type="number"] {
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 7px 9px;
    background: #fbfdff;
    color: var(--ink);
}

input[type="range"] {
    accent-color: var(--brand);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.button-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.btn {
    min-height: 36px;
    padding: 7px 9px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    font-weight: 700;
    line-height: 1.2;
    white-space: normal;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(23, 32, 51, 0.12);
}

.btn.primary {
    border-color: var(--brand);
    background: var(--brand);
    color: #fff;
}

.btn.danger {
    border-color: var(--danger);
    color: var(--danger);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.check-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid #eef2f7;
}

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

.check-row input {
    accent-color: var(--brand);
    flex: 0 0 auto;
}

.check-row span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.sidebar .grid-2 {
    grid-template-columns: 1fr;
}

.sidebar .legend {
    grid-template-columns: 1fr;
}

.sidebar .button-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sidebar .mono {
    display: block;
    max-width: 100%;
    overflow-wrap: anywhere;
    white-space: normal;
}

.legend {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
}

.legend-item span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.swatch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--brand);
    flex: 0 0 auto;
}

.collector-dot {
    width: 14px;
    height: 14px;
    border: 3px solid #ffffff;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.22);
    flex: 0 0 auto;
}

.capacity-line {
    width: 22px;
    height: 5px;
    border-radius: 999px;
    background: var(--brand-2);
    box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.12);
    flex: 0 0 auto;
}

.collector-icon {
    background: transparent;
    border: 0;
}

.collector-pulse {
    position: relative;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
}

.collector-pulse::before,
.collector-pulse::after {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: rgba(220, 38, 38, 0.24);
    animation: collectorPulse 1.8s ease-out infinite;
}

.collector-pulse::after {
    animation-delay: 0.65s;
}

.collector-pulse span {
    position: relative;
    z-index: 1;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: var(--danger);
    color: #ffffff;
    font-size: 10px;
    font-weight: 900;
    box-shadow: 0 6px 18px rgba(220, 38, 38, 0.34);
}

@keyframes collectorPulse {
    0% {
        transform: scale(0.78);
        opacity: 0.78;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.metrics {
    position: absolute;
    left: 14px;
    bottom: 14px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    gap: 8px;
    width: min(760px, calc(100% - 28px));
    pointer-events: none;
}

.metric {
    border: 1px solid rgba(217, 226, 239, 0.92);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
    padding: 9px;
    box-shadow: var(--shadow);
}

.metric-value {
    display: block;
    margin-top: 3px;
    font-size: 18px;
    font-weight: 800;
}

.reports-layout,
.data-layout {
    height: 100%;
    overflow: auto;
    padding: 18px;
}

.report-toolbar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    align-items: end;
    margin-bottom: 14px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1120px;
}

th,
td {
    padding: 9px 10px;
    border-bottom: 1px solid #edf2f7;
    text-align: left;
    white-space: nowrap;
}

th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    color: var(--muted);
    font-size: 12px;
    z-index: 1;
}

.data-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 12px;
}

.mono {
    font-family: "SFMono-Regular", Consolas, monospace;
}

.insight {
    border: 1px solid var(--line);
    border-left-width: 4px;
    border-radius: 7px;
    padding: 9px 10px;
    margin-bottom: 8px;
    background: #fbfdff;
}

.insight.warning {
    border-left-color: var(--danger);
}

.insight.info {
    border-left-color: var(--brand-2);
}

.insight.success {
    border-left-color: var(--brand);
}

.leaflet-container {
    font: inherit;
}

.noscript-seo {
    margin: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: #ffffff;
    color: var(--ink);
}

.noscript-seo h2 {
    margin: 0 0 10px;
    font-size: 18px;
}

.noscript-seo p,
.noscript-seo li {
    color: var(--muted);
    line-height: 1.55;
}

@media (max-width: 980px) {
    .topbar {
        align-items: stretch;
        flex-direction: column;
    }

    .status-pill {
        max-width: none;
        width: 100%;
    }

    .view {
        height: auto;
        min-height: calc(100vh - 148px);
    }

    .home-hero,
    .home-grid {
        grid-template-columns: 1fr;
    }

    .map-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        max-height: 48vh;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .map-wrap {
        height: 70vh;
    }

    .metrics,
    .summary-grid,
    .report-toolbar,
    .home-summary,
    .data-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 620px) {
    .tabs,
    .button-row,
    .grid-2,
    .legend,
    .metrics,
    .summary-grid,
    .report-toolbar,
    .home-summary,
    .variant-grid,
    .data-grid {
        grid-template-columns: 1fr;
    }

    .tabs {
        display: grid;
    }
}
