:root {
    --bg: #f3f6fb;
    --card: #ffffff;
    --text: #172033;
    --muted: #667085;
    --line: #d8e0ec;
    --primary: #0ea37f;
    --primary-dark: #08745b;
    --danger: #b42318;
    --shadow: 0 18px 45px rgba(15, 23, 42, .08);
    --radius: 22px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top left, #e4fbf5, transparent 34%), var(--bg);
    color: var(--text);
}

.topbar {
    min-height: 280px;
    padding: 42px clamp(20px, 5vw, 80px);
    background: linear-gradient(135deg, rgba(8, 31, 46, .94), rgba(4, 99, 82, .88));
    color: #fff;
    display: flex;
    justify-content: space-between;
    gap: 24px;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: .16em;
    font-size: 12px;
    font-weight: 800;
    color: #7df5d6;
    margin-bottom: 14px;
}

.topbar h1 {
    font-size: clamp(36px, 6vw, 68px);
    line-height: .95;
    margin: 0 0 16px;
    letter-spacing: -0.06em;
}

.topbar p {
    max-width: 680px;
    font-size: 18px;
    line-height: 1.55;
    margin: 0;
    color: rgba(255, 255, 255, .82);
}

.badge {
    align-self: flex-start;
    padding: 10px 16px;
    border: 1px solid rgba(255,255,255,.28);
    border-radius: 999px;
    background: rgba(255,255,255,.12);
    font-weight: 800;
}

.wrap {
    width: min(1180px, calc(100% - 32px));
    margin: -72px auto 40px;
}

.hero,
.card {
    background: var(--card);
    border: 1px solid rgba(216, 224, 236, .9);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.hero {
    padding: 34px;
    margin-bottom: 18px;
}

.hero h2 {
    margin: 0 0 8px;
    font-size: 30px;
    letter-spacing: -0.04em;
}

.hero p {
    margin: 0;
    color: var(--muted);
    line-height: 1.65;
}

.card {
    padding: 24px;
    margin-bottom: 18px;
}

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

label {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

label:nth-child(4),
label:nth-child(5) {
    grid-column: span 2;
}

label span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

input {
    width: 100%;
    height: 46px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0 14px;
    font: inherit;
    outline: none;
    background: #fff;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(14, 163, 127, .12);
}

.actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 6px;
}

button,
.button-link {
    border: 0;
    border-radius: 14px;
    background: var(--primary);
    color: #fff;
    padding: 13px 18px;
    font-weight: 900;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
}

button:hover { background: var(--primary-dark); }

button.secondary,
.button-link {
    color: var(--text);
    background: #eef3f8;
}

button.secondary:hover,
.button-link:hover {
    background: #dce7f2;
}

button.small {
    padding: 10px 13px;
    font-size: 13px;
}

.status {
    padding: 16px 18px;
    border-radius: 18px;
    margin-bottom: 18px;
    font-weight: 800;
    background: #ecfdf3;
    color: #067647;
    border: 1px solid #abefc6;
}

.status.error {
    background: #fff1f3;
    color: var(--danger);
    border-color: #fecdd6;
}

.hidden { display: none !important; }

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

.card-head h3 {
    margin: 0 0 4px;
    font-size: 22px;
}

.card-head p {
    margin: 0;
    color: var(--muted);
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 18px;
}

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

th,
td {
    padding: 14px 15px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
    text-align: left;
}

th {
    background: #f8fafc;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
}

td {
    font-size: 14px;
    line-height: 1.45;
}

td.objeto { max-width: 430px; }

pre {
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 560px;
    overflow: auto;
    background: #0b1220;
    color: #d7e3ff;
    padding: 18px;
    border-radius: 18px;
    font-size: 12px;
    line-height: 1.55;
}

.source-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}

.source-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 26px;
    border-radius: var(--radius);
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    color: var(--text);
    text-decoration: none;
    transition: transform .18s ease, box-shadow .18s ease;
}

.source-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 22px 55px rgba(15, 23, 42, .12);
}

.source-card span {
    color: var(--primary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .12em;
    font-weight: 900;
}

.source-card strong {
    font-size: 24px;
    letter-spacing: -0.04em;
}

.source-card small {
    color: var(--muted);
    font-size: 14px;
}

footer {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto 40px;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

@media (max-width: 900px) {
    .grid-form { grid-template-columns: 1fr 1fr; }

    label:nth-child(4),
    label:nth-child(5) {
        grid-column: span 2;
    }
}

@media (max-width: 640px) {
    .topbar {
        min-height: 250px;
        padding: 30px 20px;
    }

    .wrap {
        width: calc(100% - 20px);
        margin-top: -46px;
    }

    .hero,
    .card {
        padding: 20px;
    }

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

    label:nth-child(4),
    label:nth-child(5) {
        grid-column: span 1;
    }

    .card-head { flex-direction: column; }
}

.city-hero {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 24px;
}

.mini-kpis {
    display: grid;
    grid-template-columns: repeat(3, minmax(95px, 1fr));
    gap: 12px;
    min-width: 340px;
}

.mini-kpis div {
    padding: 18px;
    border-radius: 18px;
    background: #f8fafc;
    border: 1px solid var(--line);
}

.mini-kpis strong {
    display: block;
    font-size: 30px;
    letter-spacing: -0.05em;
}

.mini-kpis span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 18px;
}

.action-card {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 24px;
    border-radius: var(--radius);
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text);
}

.action-card.primary-action {
    background: linear-gradient(135deg, #0ea37f, #075f4c);
    color: #fff;
    border: 0;
}

.action-card span {
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: 11px;
    font-weight: 900;
    color: var(--primary);
}

.action-card.primary-action span,
.action-card.primary-action small {
    color: rgba(255,255,255,.78);
}

.action-card strong {
    font-size: 23px;
    letter-spacing: -0.04em;
}

.action-card small {
    color: var(--muted);
    line-height: 1.45;
}

.module-section {
    margin-bottom: 24px;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: end;
    margin: 20px 0 12px;
}

.section-head h3 {
    margin: 0 0 4px;
    font-size: 26px;
    letter-spacing: -0.04em;
}

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

.module-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.module-card {
    padding: 22px;
    border-radius: 20px;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: 0 12px 32px rgba(15, 23, 42, .06);
}

.module-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.pill,
.dict {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 900;
}

.status-integrado {
    background: #dcfae6;
    color: #067647;
}

.status-mapeado {
    background: #eef4ff;
    color: #3538cd;
}

.status-estudo {
    background: #fff6db;
    color: #946200;
}

.status-erro {
    background: #ffe4e8;
    color: #b42318;
}

.status-inativo {
    background: #f2f4f7;
    color: #667085;
}

.dict {
    background: #f8fafc;
    color: #475467;
    border: 1px solid var(--line);
}

.module-card h4 {
    margin: 0 0 10px;
    font-size: 20px;
    letter-spacing: -0.03em;
}

.module-card p {
    margin: 0 0 18px;
    color: var(--muted);
    font-size: 13px;
}

.module-card code {
    padding: 3px 7px;
    border-radius: 8px;
    background: #f2f4f7;
    color: #344054;
}

.module-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.module-actions a {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 12px;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 900;
}

.module-actions a.ghost {
    background: #eef3f8;
    color: var(--text);
}

@media (max-width: 980px) {
    .city-hero {
        flex-direction: column;
    }

    .mini-kpis,
    .quick-actions,
    .module-grid {
        grid-template-columns: 1fr 1fr;
        min-width: 0;
    }
}

@media (max-width: 640px) {
    .mini-kpis,
    .quick-actions,
    .module-grid {
        grid-template-columns: 1fr;
    }
}

.detail-grid {
    grid-template-columns: repeat(4, 1fr);
}

.object-box {
    margin-top: 16px;
    padding: 18px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: #f8fafc;
}

.object-box span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.object-box p {
    margin: 0;
    color: #344054;
    line-height: 1.65;
}

.alert-card {
    border-color: #fdb022;
    background: linear-gradient(180deg, #fff, #fffbeb);
}

.timeline-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.timeline-list div {
    padding: 16px;
    border-radius: 16px;
    border: 1px solid #fedf89;
    background: #fff;
}

.timeline-list strong {
    display: block;
    margin-bottom: 6px;
    color: #93370d;
}

.timeline-list p {
    margin: 0;
    color: #344054;
    line-height: 1.55;
}

@media (max-width: 900px) {
    .detail-grid,
    .timeline-list {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 640px) {
    .detail-grid,
    .timeline-list {
        grid-template-columns: 1fr;
    }
}
