:root {
    --bg: #f6f8f5;
    --surface: #ffffff;
    --surface-2: #eef4ee;
    --ink: #17211d;
    --muted: #627068;
    --line: #d8e0da;
    --green: #116149;
    --green-dark: #0b3e31;
    --amber: #c77d10;
    --red: #bd3b31;
    --blue: #2364aa;
    --shadow: 0 18px 44px rgba(20, 38, 31, 0.11);
}

* {
    box-sizing: border-box;
}

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

button,
input,
select,
textarea {
    font: inherit;
}

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 18px;
    background: #10241d;
    color: #eff8f3;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #e8f5eb;
    color: var(--green-dark);
    font-weight: 900;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    color: #a8bbb2;
    margin-top: 2px;
}

.main-nav {
    display: grid;
    gap: 6px;
}

.main-nav a {
    color: #c9d8d0;
    text-decoration: none;
    border-radius: 8px;
    padding: 11px 12px;
    font-size: 0.94rem;
}

.main-nav a:hover,
.main-nav a.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.10);
}

.source-box {
    margin-top: auto;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
}

.source-box span,
.source-box strong {
    display: block;
}

.source-box span {
    color: #a8bbb2;
    font-size: 0.8rem;
}

.workspace {
    padding: 28px;
    display: grid;
    gap: 20px;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.topbar h1 {
    margin: 0;
    font-size: clamp(1.7rem, 3vw, 2.45rem);
    line-height: 1.08;
}

.topbar p,
.section-head p {
    margin: 7px 0 0;
    color: var(--muted);
}

.primary-action,
.ghost-action,
.icon-button {
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    min-height: 42px;
}

.primary-action {
    background: var(--green);
    color: #ffffff;
    padding: 0 18px;
    font-weight: 800;
    box-shadow: 0 10px 24px rgba(17, 97, 73, 0.22);
}

.ghost-action {
    background: #eef4ee;
    color: var(--green-dark);
    padding: 0 16px;
    font-weight: 800;
}

.icon-button {
    width: 40px;
    background: #edf2ee;
    color: var(--ink);
    font-size: 1.5rem;
}

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

.kpi-strip article,
.section-panel,
.detail-panel,
.map-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.kpi-strip article {
    padding: 16px;
}

.kpi-strip span {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 750;
}

.kpi-strip strong {
    display: block;
    margin-top: 8px;
    font-size: 1.75rem;
}

.map-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 18px;
    min-height: 560px;
}

.map-panel {
    overflow: hidden;
    display: grid;
    grid-template-rows: auto minmax(440px, 1fr);
}

.map-toolbar {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}

.map-toolbar strong,
.map-toolbar span {
    display: block;
}

.map-toolbar span {
    color: var(--muted);
    font-size: 0.86rem;
    margin-top: 2px;
}

.filters {
    display: flex;
    gap: 8px;
}

select,
input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    padding: 10px 11px;
    outline: none;
}

select:focus,
input:focus,
textarea:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(17, 97, 73, 0.12);
}

#map {
    min-height: 440px;
}

.detail-panel {
    padding: 20px;
}

.panel-label {
    display: inline-block;
    color: var(--green);
    font-weight: 900;
    font-size: 0.74rem;
    text-transform: uppercase;
}

.detail-panel h2 {
    margin: 10px 0 8px;
    font-size: 1.35rem;
}

.detail-panel p {
    color: var(--muted);
    line-height: 1.55;
}

.detail-list {
    display: grid;
    gap: 10px;
    margin: 18px 0 0;
}

.detail-list div {
    padding: 12px;
    border-radius: 8px;
    background: var(--surface-2);
}

.detail-list dt {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 850;
}

.detail-list dd {
    margin: 4px 0 0;
    font-weight: 800;
}

.data-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
}

.section-panel {
    padding: 18px;
}

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

.section-head h2 {
    margin: 0;
    font-size: 1.22rem;
}

.road-list,
.intervention-list,
.summary-grid {
    display: grid;
    gap: 10px;
}

.road-item,
.intervention-item,
.summary-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 13px;
    background: #fbfdfb;
}

.road-item {
    width: 100%;
    cursor: pointer;
    color: inherit;
    text-align: left;
}

.road-item:hover {
    border-color: rgba(17, 97, 73, 0.42);
    background: #f5faf6;
}

.row-title {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-weight: 900;
}

.row-subtitle {
    color: var(--muted);
    margin-top: 4px;
    font-size: 0.9rem;
}

.progress {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #dce6df;
    margin-top: 12px;
}

.progress span {
    display: block;
    height: 100%;
    background: var(--green);
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: #e8f5eb;
    color: var(--green-dark);
    font-size: 0.76rem;
    font-weight: 900;
    white-space: nowrap;
}

.badge.alta,
.badge.critica {
    background: #fae7dd;
    color: #8d2f21;
}

.badge.media {
    background: #fff4d8;
    color: #7a5300;
}

.badge.em_andamento,
.badge.em_atendimento {
    background: #e6effc;
    color: #174b8e;
}

.reports-panel .section-head input {
    max-width: 360px;
}

.table-wrap {
    overflow-x: auto;
}

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

th,
td {
    padding: 12px 10px;
    border-top: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
    font-size: 0.92rem;
}

th {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
}

.report-dialog {
    width: min(760px, calc(100vw - 24px));
    border: 0;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 26px 80px rgba(8, 25, 17, 0.28);
}

.report-dialog::backdrop {
    background: rgba(11, 31, 24, 0.58);
}

.report-dialog form {
    padding: 20px;
}

.dialog-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.dialog-head h2,
.dialog-head p {
    margin: 0;
}

.dialog-head p {
    color: var(--muted);
    margin-top: 6px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 13px;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 800;
}

.wide {
    grid-column: 1 / -1;
}

.dialog-actions {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
}

.form-status {
    margin-top: 12px;
    color: var(--green-dark);
    font-weight: 800;
}

.leaflet-popup-content strong {
    display: block;
    margin-bottom: 3px;
}

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

    .sidebar {
        position: static;
        height: auto;
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
    }

    .main-nav {
        grid-auto-flow: column;
        overflow-x: auto;
    }

    .source-box {
        margin: 0 0 0 auto;
    }

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

@media (max-width: 720px) {
    .workspace {
        padding: 18px;
    }

    .topbar,
    .map-toolbar,
    .section-head,
    .dialog-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .kpi-strip,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .filters {
        flex-direction: column;
    }

    .source-box {
        width: 100%;
    }
}
