/* Legendários UI — modern, static, responsive-by-breakpoints (non-fluid) */
:root {
    --footer: 56px;
    --bg: #0b0f14;
    --panel: #101826;
    --panel2: #0e1624;
    --text: #e6e7ea;
    --muted: #9aa3ad;
    --line: rgba(255, 255, 255, 0.08);
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
    --accent: #ff5a00;
    --accent2: #ff7a1a;
    --radius: 18px;
    --radius2: 14px;
    --sidebar: 280px;
    --topbar: 64px;
    --container: 1400px;
    --font:
        ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica,
        Arial;
}

* {
    box-sizing: border-box;
}
html,
body {
    height: 100%;
}
html,
body {
    overflow-x: hidden;
}
html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    background: var(--bg);
    color-scheme: dark;
}
html[data-theme="light"] {
    color-scheme: light;
}
body {
    margin: 0;
    font-size: 16px;
    line-height: 1.5;
    letter-spacing: 0.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-family: var(--font);
    background:
        radial-gradient(
            1200px 700px at 15% 10%,
            rgba(255, 90, 0, 0.08),
            transparent 55%
        ),
        radial-gradient(
            900px 600px at 80% 25%,
            rgba(255, 90, 0, 0.06),
            transparent 55%
        ),
        linear-gradient(180deg, #05070a 0%, #07090c 50%, #05070a 100%);
    color: var(--text);
}

/* ---------- App shell ---------- */
.app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
}
.sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    min-height: 100vh;
    padding: 18px 14px;
    background: linear-gradient(
        180deg,
        rgba(13, 17, 23, 0.92),
        rgba(11, 15, 20, 0.92)
    );
    border-right: 1px solid var(--line);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    transition:
        transform 0.22s ease,
        opacity 0.22s ease,
        border-color 0.22s ease;
}
.app.sidebar-collapsed {
    --sidebar: 0px;
    grid-template-columns: 0 1fr;
}
.app.sidebar-collapsed .sidebar {
    transform: translateX(-110%);
    opacity: 0;
    pointer-events: none;
}
.app.sidebar-collapsed .main {
    min-width: 0;
}
.app.sidebar-collapsed .container {
    width: calc(100vw - 40px);
    max-width: calc(100vw - 40px);
}
.app.sidebar-collapsed .page-footer {
    left: 0;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 16px;
    border-radius: var(--radius2);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.sidebar .brand img {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    object-fit: contain;
    background: rgba(0, 0, 0, 0.2);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}
.sidebar .brand .title {
    font-weight: 800;
    letter-spacing: 0.2px;
    line-height: 1.1;
}
.sidebar .brand .sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.nav {
    margin-top: 14px;
    padding: 8px;
    border-radius: var(--radius2);
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
}

.nav .section {
    margin: 10px 0;
}
.nav .section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: rgba(255, 255, 255, 0.55);
    margin: 12px 10px 8px;
}
.nav a,
.nav button,
.nav summary {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--text);
    text-decoration: none;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
}
.nav a:hover,
.nav button:hover,
.nav summary:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.06);
}
.nav a.active {
    background: rgba(255, 90, 0, 0.14);
    border-color: rgba(255, 90, 0, 0.28);
    box-shadow: 0 10px 26px rgba(255, 90, 0, 0.1);
}
.nav .muted {
    color: var(--muted);
    font-weight: 600;
}
.nav details {
    border-radius: 12px;
}
.nav details[open] > summary {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.06);
}
.nav summary {
    list-style: none;
}
.nav summary::-webkit-details-marker {
    display: none;
}
.nav details .subnav {
    margin: 6px 0 2px;
    padding-left: 10px;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
}
.nav details .subnav a {
    font-weight: 600;
    padding: 9px 12px;
    opacity: 0.92;
}

/* Footer in sidebar */
.sidebar .side-footer {
    margin-top: auto;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 90, 0, 0.35);
    background: rgba(255, 90, 0, 0.12);
    color: var(--accent2);
    font-size: 12px;
    font-weight: 800;
}

.alert-card {
    margin: 14px 0;
    border: 1px solid transparent;
}
.alert-card:first-child {
    margin-top: 0;
}
.alert-card.is-success {
    border-color: rgba(61, 220, 151, 0.35);
    background: rgba(61, 220, 151, 0.1);
}
.alert-card.is-error {
    border-color: rgba(255, 59, 59, 0.35);
    background: rgba(255, 59, 59, 0.1);
}
.alert-card.is-warn {
    border-color: rgba(255, 193, 7, 0.35);
    background: rgba(255, 193, 7, 0.1);
}
.alert-label {
    font-weight: 800;
}
.alert-card.is-success .alert-label {
    color: #b8ffd5;
}
.alert-card.is-error .alert-label {
    color: #ffb1b1;
}
.alert-card.is-warn .alert-label {
    color: #ffd978;
}
.text-uppercase {
    text-transform: uppercase;
}
.is-hidden {
    display: none !important;
}
.mt-8 {
    margin-top: 8px !important;
}
.mt-10 {
    margin-top: 10px !important;
}
.mt-12 {
    margin-top: 12px !important;
}
.mt-14 {
    margin-top: 14px !important;
}
.mt-16 {
    margin-top: 16px !important;
}
.mb-8 {
    margin-bottom: 8px !important;
}
.mb-10 {
    margin-bottom: 10px !important;
}
.mb-14 {
    margin-bottom: 14px !important;
}
.my-12 {
    margin: 12px 0 !important;
}
.w-full {
    width: 100%;
}
.row-end {
    align-items: flex-end;
}
.row-between {
    justify-content: space-between;
}
.row-wrap {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.row-inline {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}
.event-actions-cell {
    min-width: 156px;
}
.event-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    white-space: nowrap;
}
.event-actions form {
    margin: 0;
}
.event-action-btn {
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-size: 18px;
    line-height: 1;
}
.row-actions-end {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.mr-auto {
    margin-left: auto;
}
.grow-1 {
    flex: 1;
}
.grow-1-280 {
    flex: 1 1 280px;
}
.grow-1-320 {
    flex: 1 1 320px;
}
.grow-1-420 {
    flex: 1 1 420px;
}
.grow-2-200 {
    flex: 2 1 200px;
}
.min-w-0 {
    min-width: 0;
}
.min-w-160 {
    min-width: 160px;
}
.min-w-200 {
    min-width: 200px;
}
.min-w-280 {
    min-width: 280px;
}
.grid-gap-12 {
    gap: 12px;
}
.grid-cols-2-equal {
    grid-template-columns: 1fr 1fr;
}
.grid-cols-2-main {
    grid-template-columns: 2fr 1fr;
}
.grid-cols-3-auto {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid-span-all {
    grid-column: 1 / -1;
}
.panel-title {
    margin: 0 0 6px;
}
.kpi-money {
    font-size: 24px;
}
.kpi-amount {
    font-size: 28px;
    font-weight: 900;
}
.table-scroll-y {
    max-height: 220px;
    overflow: auto;
}
.map-frame {
    height: 440px;
    border-radius: 18px;
    overflow: hidden;
}
.legend-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 10px;
}
.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}
.legend-dot.is-volunteer {
    background: #2ecc71;
}
.legend-dot.is-station {
    background: #ff9800;
}
.map-marker {
    border-radius: 50%;
    border: 2px solid #fff;
}
.map-marker.is-station {
    width: 16px;
    height: 16px;
    background: #ff9800;
}
.map-marker.is-volunteer {
    width: 14px;
    height: 14px;
    background: #2ecc71;
}
.stack-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.surface-item {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.03);
}
.surface-item-title {
    font-weight: 800;
}
.surface-item-meta {
    margin-top: 4px;
}
.surface-item-actions {
    margin-top: 8px;
}
.form-inline {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.list-disc-spaced {
    margin: 8px 0 0;
    padding-left: 18px;
    line-height: 1.8;
}
.image-card {
    width: 100%;
    max-width: 360px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #fff;
    padding: 10px;
}
.list-compact {
    padding-left: 18px;
    margin: 0;
}
.muted-note {
    color: #666;
}
.muted-note.mt-2 {
    margin-top: 2px !important;
}
.muted-note.mt-8 {
    margin-top: 8px !important;
}
.section-card-tight {
    padding: 12px;
    margin-top: 14px;
}

.v20-head {
    margin-bottom: 14px;
}
.v20-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}
.v20-grid-2 {
    display: grid;
    grid-template-columns: 1.25fr 0.95fr;
    gap: 14px;
}
.v20-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}
.v20-kpi {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 130px;
    padding: 18px;
}
.v20-kpi .label {
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 6px;
}
.v20-kpi .value {
    font-size: 32px;
    font-weight: 900;
    line-height: 1.05;
    letter-spacing: -0.02em;
}
.v20-kpi .value.money {
    font-size: 24px;
}
.v20-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.v20-item {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.03);
    background: color-mix(in srgb, var(--panel) 82%, transparent);
}
.v20-item .t {
    font-weight: 800;
}
.v20-item .s {
    font-size: 12px;
    color: var(--muted);
}
.v20-inline-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.v20-live-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    font-size: 12px;
    color: var(--muted);
}
.v20-live-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #3ddc97;
    box-shadow: 0 0 0 0 rgba(61, 220, 151, 0.55);
    animation: v20pulse 2s infinite;
}
#mapa_v2 {
    height: 430px;
    border-radius: 18px;
    overflow: hidden;
}
@keyframes v20pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(61, 220, 151, 0.45);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(61, 220, 151, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(61, 220, 151, 0);
    }
}
@media (max-width: 1100px) {
    .v20-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .v20-grid-2,
    .grid-cols-2-main,
    .grid-cols-3-auto {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 700px) {
    .v20-grid-4 {
        grid-template-columns: 1fr;
    }
    .v20-kpi .value {
        font-size: 28px;
    }
}
[data-theme="light"] .v20-item {
    background: rgba(255, 255, 255, 0.9);
}

/* ---------- Main area ---------- */
.main {
    min-height: 100vh;
    min-width: 0;
}
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px;
    border-bottom: 1px solid var(--line);
    background: rgba(7, 9, 12, 0.78);
    backdrop-filter: blur(10px);
}
.topbar .left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.icon-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}
.topbar .crumb {
    font-weight: 800;
}
.topbar .crumb small {
    display: block;
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
    margin-top: 2px;
}
.topbar .crumb-title {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: rgba(255, 255, 255, 0.92);
}
.topbar .right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.topbar-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.03em;
    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease,
        transform 0.15s ease;
}
.topbar-link:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.14);
    color: var(--text);
    text-decoration: none;
    transform: translateY(-1px);
}
.topbar-link-accent {
    background: linear-gradient(
        180deg,
        rgba(255, 90, 0, 0.18),
        rgba(255, 90, 0, 0.12)
    );
    border-color: rgba(255, 90, 0, 0.32);
    color: #ffd2ba;
    box-shadow: 0 10px 24px rgba(255, 90, 0, 0.14);
}
.topbar-link-accent:hover {
    background: linear-gradient(
        180deg,
        rgba(255, 90, 0, 0.24),
        rgba(255, 90, 0, 0.16)
    );
    border-color: rgba(255, 122, 26, 0.42);
    color: #fff2ea;
}

.content {
    display: block;
    min-width: 0;
    padding: 20px 18px 26px;
    padding-bottom: calc(var(--footer) + 32px + env(safe-area-inset-bottom));
}

/* Vertical rhythm: default spacing between page blocks */
.container > * + * {
    margin-top: 18px;
}
.page {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Static (non-fluid) page width: steps by breakpoints */
.container {
    width: var(--container);
    max-width: calc(100vw - var(--sidebar) - 40px);
}

@media (max-width: 1400px) {
    .container {
        width: 1120px;
    }
}
@media (max-width: 1200px) {
    .container {
        width: 960px;
    }
}
@media (max-width: 1024px) {
    :root {
        --sidebar: 0px;
    }
    .app {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 300px;
        max-width: 86vw;
        transform: translateX(-110%);
        transition: transform 0.22s ease;
        z-index: 100;
        border-right: 1px solid var(--line);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.55);
        z-index: 90;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.22s ease;
    }
    .backdrop.open {
        opacity: 1;
        pointer-events: auto;
    }
    .main {
        grid-template-rows: var(--topbar) 1fr auto;
    }
    .container {
        width: 92vw;
        max-width: 92vw;
    }
}

/* ---------- Components ---------- */
.h1 {
    font-size: 30px;
    margin: 0 0 8px;
    letter-spacing: -0.01em;
}
.h2 {
    font-size: 20px;
    margin: 0 0 10px;
    letter-spacing: -0.005em;
}
h1,
h2,
h3 {
    margin: 0;
}
h1 {
    font-size: 28px;
    letter-spacing: -0.01em;
}
h2 {
    font-size: 20px;
    letter-spacing: -0.006em;
}
h3 {
    font-size: 16px;
    letter-spacing: -0.004em;
}
.card h1 {
    font-size: 26px;
    margin-bottom: 10px;
}
.card h2 {
    font-size: 20px;
    margin-bottom: 10px;
}
.card h3 {
    font-size: 15px;
    margin-bottom: 8px;
}
.small {
    color: var(--muted);
    font-size: 14px;
}

.card {
    background: rgba(13, 17, 23, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--radius);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.42);
    padding: 18px;
}

.card.soft {
    background: rgba(255, 255, 255, 0.02);
}
.card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

/* Static-by-breakpoints (no fluid stretching) */
@media (max-width: 1700px) {
    :root {
        --container: 1280px;
    }
}
@media (max-width: 1480px) {
    :root {
        --container: 1140px;
    }
}
@media (max-width: 1280px) {
    :root {
        --container: 980px;
    }
}
@media (max-width: 1100px) {
    :root {
        --container: calc(100vw - 28px);
        --sidebar: 0px;
    }
}
.grid {
    display: grid;
    gap: 16px;
}
.grid.tight {
    gap: 12px;
}
.grid.loose {
    gap: 20px;
}
.grid.kpis {
    grid-template-columns: repeat(3, 1fr);
}
.ops-kpis {
    grid-template-columns: repeat(4, 1fr);
}
.grid.main {
    grid-template-columns: 2fr 1fr;
    align-items: start;
}
.grid.main > * {
    min-width: 0;
}
.grid.main > .card {
    width: 100%;
}
@media (max-width: 1024px) {
    .grid.kpis {
        grid-template-columns: 1fr;
    }
    .ops-kpis {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 720px) {
    .grid.main {
        display: flex;
        flex-direction: column;
    }
    .ops-kpis {
        grid-template-columns: 1fr;
    }
}

.kpi-card {
    padding: 14px;
}
.kpi-label {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}
.kpi-value {
    font-size: 34px;
    font-weight: 800;
    margin-top: 8px;
}
.kpi-card .kpi-value {
    color: var(--text);
}
.kpi-card.emph {
    border-color: rgba(255, 90, 0, 0.25);
    box-shadow:
        0 10px 28px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(255, 90, 0, 0.08) inset;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.table-wrap {
    overflow: visible;
    border-radius: var(--radius2);
    border: 1px solid rgba(255, 255, 255, 0.07);
    width: 100%;
}
.table-wrap table {
    min-width: 0;
}
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
thead th {
    position: sticky;
    top: 0;
    background: rgba(8, 10, 14, 0.92);
    backdrop-filter: blur(10px);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--muted);
    padding: 12px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
tbody td {
    padding: 12px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    vertical-align: middle;
}
tbody tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.actions-cell {
    width: 1%;
    white-space: nowrap;
}
.actions-menu {
    position: relative;
    display: inline-block;
}
.actions-menu > summary {
    list-style: none;
    cursor: pointer;
}
.actions-menu > summary::-webkit-details-marker {
    display: none;
}
.actions-menu .menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 180px;
    background: rgba(13, 17, 23, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
    padding: 8px;
    z-index: 50;
}
.actions-menu .menu a,
.actions-menu .menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 10px;
    border-radius: 10px;
    color: var(--text);
    background: transparent;
    border: 0;
    font: inherit;
}
.actions-menu .menu a:hover,
.actions-menu .menu button:hover {
    background: rgba(255, 255, 255, 0.06);
}
.actions-menu .menu .danger {
    color: #ffb3a6;
}

/* legacy helpers: keep existing markup working */
.row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.col-4 {
    flex: 1 1 240px;
    min-width: 220px;
}
.col-6 {
    flex: 1 1 360px;
    min-width: 280px;
}
.col-12 {
    flex: 1 1 100%;
}

.btn,
.btn2 {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 90, 0, 0.3);
    background: rgba(255, 90, 0, 0.16);
    color: var(--accent2);
    font-weight: 900;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover,
.btn2:hover {
    background: rgba(255, 90, 0, 0.22);
    border-color: rgba(255, 90, 0, 0.4);
}
.btn.ghost {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
}

input,
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.18);
    color: var(--text);
    outline: none;
}
input:focus,
select:focus,
textarea:focus {
    border-color: rgba(255, 90, 0, 0.4);
    box-shadow: 0 0 0 3px rgba(255, 90, 0, 0.18);
}

table {
    width: 100%;
    border-collapse: collapse;
}
th,
td {
    text-align: left;
    padding: 10px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.92);
}
th {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.table-wrap {
    overflow: visible;
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.08);
    width: 100%;
}
.table-wrap table {
    min-width: 0;
}

.footer {
    margin-top: 16px;
    color: rgba(255, 255, 255, 0.55);
    font-size: 12px;
    padding: 10px 0;
}

/* Auth pages */
.auth-page {
    max-width: 520px;
    margin: 34px auto;
}
.auth-page h1 {
    margin: 0 0 6px;
    font-size: 28px;
}
.auth-page .row {
    margin-top: 14px;
}
.public-home {
    display: grid;
    gap: 18px;
}
.public-home-hero {
    padding: 24px 28px;
}
.public-home-eyebrow {
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--accent);
}
.public-home-hero h1 {
    margin: 0 0 8px;
    font-size: 40px;
}
.public-home-hero .small {
    margin: 0;
    max-width: 760px;
    line-height: 1.6;
}
.public-home-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}
.public-home-card {
    display: grid;
    gap: 12px;
    min-height: 180px;
    padding: 22px;
    text-decoration: none;
    color: inherit;
    transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.public-home-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 184, 92, 0.35);
    background: rgba(255, 184, 92, 0.08);
}
.public-home-icon {
    width: 52px;
    height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    font-size: 24px;
    background: rgba(255, 184, 92, 0.1);
    box-shadow: inset 0 0 0 1px rgba(255, 184, 92, 0.16);
}
.public-home-title {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0.01em;
}
.public-home-desc {
    color: var(--muted);
    line-height: 1.55;
}
@media (max-width: 1180px) {
    .public-home-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 760px) {
    .public-home-hero {
        padding: 18px 20px;
    }
    .public-home-hero h1 {
        font-size: 30px;
    }
    .public-home-grid {
        grid-template-columns: 1fr;
    }
    .public-home-card {
        min-height: 0;
    }
}

/* ---------- Forms polish ---------- */
label {
    display: block;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.75);
    margin: 10px 0 6px;
}
input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
select,
textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text);
    border-radius: 12px;
    padding: 11px 12px;
    outline: none;
}
input::placeholder,
textarea::placeholder {
    color: rgba(255, 255, 255, 0.35);
}
input:focus,
select:focus,
textarea:focus {
    border-color: rgba(255, 90, 0, 0.35);
    box-shadow: 0 0 0 3px rgba(255, 90, 0, 0.12);
}
.compact label {
    margin: 8px 0 6px;
}
.compact input,
.compact select,
.compact textarea {
    padding: 10px 12px;
}

/* ===== Polimento final global (títulos/subtítulos + botões consistentes) ===== */
.card h1,
.card h2 {
    margin: 0 0 18px;
    letter-spacing: 0.2px;
}
.card h1 + .small,
.card h2 + .small {
    display: block;
    margin-top: 0;
    margin-bottom: 26px;
    line-height: 1.55;
    opacity: 0.92;
}

/* Apply cadastro-style buttons everywhere by default (safe selector) */
button,
input[type="submit"],
input[type="button"],
a.btn,
a.btn2 {
    font: inherit;
}
button:not(.icon-btn):not(.btn):not(.btn2):not(.btnDanger):not(.btn-danger),
input[type="submit"]:not(.icon-btn):not(.btn):not(.btn2):not(.btnDanger):not(
        .btn-danger
    ),
input[type="button"]:not(.icon-btn):not(.btn):not(.btn2):not(.btnDanger):not(
        .btn-danger
    ) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 90, 0, 0.3);
    background: rgba(255, 90, 0, 0.16);
    color: var(--accent2);
    font-weight: 900;
    cursor: pointer;
    text-decoration: none;
}
button:not(.icon-btn):not(.btn):not(.btn2):not(.btnDanger):not(
        .btn-danger
    ):hover,
input[type="submit"]:not(.icon-btn):not(.btn):not(.btn2):not(.btnDanger):not(
        .btn-danger
    ):hover {
    background: rgba(255, 90, 0, 0.22);
    border-color: rgba(255, 90, 0, 0.4);
}

/* Danger button (Saída / Excluir) */
.btnDanger,
.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 60, 60, 0.35);
    background: rgba(255, 60, 60, 0.12);
    color: rgba(255, 150, 150, 0.95);
    font-weight: 900;
    cursor: pointer;
    text-decoration: none;
}
.btnDanger:hover,
.btn-danger:hover {
    background: rgba(255, 60, 60, 0.18);
    border-color: rgba(255, 60, 60, 0.45);
}

/* Disabled states still look like buttons (no 'sem cor') */
.btn[disabled],
.btn2[disabled],
.btnDanger[disabled],
.btn-danger[disabled],
button[disabled],
input[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    filter: saturate(0.85);
}

/* ===== Espaçamento de ações (corrige botões "em cima" do texto) ===== */
/* Wrapper opcional para grupos de botões */
.form-actions,
.button-group,
.actions,
.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

/* Quando o markup não tem wrapper, ainda damos respiro entre campo e botão */
input + button,
select + button,
textarea + button,
input + input[type="submit"],
select + input[type="submit"],
textarea + input[type="submit"],
input + a.btn,
select + a.btn,
textarea + a.btn,
input + a.btn2,
select + a.btn2,
textarea + a.btn2 {
    margin-top: 12px;
}

/* Margin top leve em botões dentro de cards (evita "colado"), sem afetar tabelas */
.card
    :is(
        button,
        input[type="submit"],
        input[type="button"],
        a.btn,
        a.btn2,
        .btnDanger,
        .btn-danger
    ) {
    margin-top: 8px;
}
table
    :is(
        button,
        input[type="submit"],
        input[type="button"],
        a.btn,
        a.btn2,
        .btnDanger,
        .btn-danger
    ),
.actions-cell
    :is(
        button,
        input[type="submit"],
        input[type="button"],
        a.btn,
        a.btn2,
        .btnDanger,
        .btn-danger
    ) {
    margin-top: 0;
}

@media (max-width: 720px) {
    .form-actions,
    .button-group,
    .actions,
    .btn-row {
        gap: 12px;
        margin-top: 18px;
    }
    /* Botões de formulário em mobile: fácil de tocar e sem grudar */
    .card
        form
        :is(
            button,
            input[type="submit"],
            input[type="button"],
            a.btn,
            a.btn2,
            .btnDanger,
            .btn-danger
        ) {
        width: 100%;
    }
}

/* Dashboard: more breathing room between title and subtitle already handled; add spacing between sections */
.card .section {
    margin-top: 18px;
}
@media (min-width: 1025px) {
    .grid.loose {
        gap: 26px;
    } /* more air on desktop */
}

/* Mobile: cadastros show only Nome + Nº + Ações */
@media (max-width: 720px) {
    table.cadastros-table th:nth-child(2),
    table.cadastros-table td:nth-child(2),
    table.cadastros-table th:nth-child(3),
    table.cadastros-table td:nth-child(3),
    table.cadastros-table th:nth-child(5),
    table.cadastros-table td:nth-child(5),
    table.cadastros-table th:nth-child(6),
    table.cadastros-table td:nth-child(6),
    table.cadastros-table th:nth-child(7),
    table.cadastros-table td:nth-child(7) {
        display: none;
    }
    table.cadastros-table th:nth-child(1) {
        width: 60%;
    }
    table.cadastros-table th:nth-child(4) {
        width: 18%;
    }
    table.cadastros-table th:nth-child(8) {
        width: 22%;
    }
    table.cadastros-table td:nth-child(1) {
        font-weight: 800;
    }
    table.cadastros-table td:nth-child(4) {
        white-space: nowrap;
    }
}

/* Mobile dashboard: avoid squished controls and force wrap nicely */
@media (max-width: 720px) {
    .row {
        flex-wrap: wrap;
    }
    .row > * {
        min-width: 0 !important;
    }
    .topbar {
        padding: 10px 12px;
    }
    .container {
        width: 94vw;
        max-width: 94vw;
    }
    .kpi-value {
        font-size: 30px;
    }
}

@media (max-width: 768px) {
}

@media (max-width: 768px) {
    /* Improve readability on iOS: avoid transparency showing text behind cards */
    .card {
        background: rgba(12, 16, 22, 0.94) !important;
        backdrop-filter: none !important;
    }
    .topbar {
        background: rgba(10, 12, 16, 0.96) !important;
        backdrop-filter: none !important;
    }
    /* Dashboard density */
    .page-dashboard .grid.main {
        gap: 16px !important;
    }
    .page-dashboard .grid.kpis {
        gap: 14px !important;
    }
    .kpi-card {
        padding: 16px !important;
    }
    /* Slightly increase spacing between title and subtitle */
    .page .card h1,
    .page .card h2 {
        margin-bottom: 16px !important;
    }
    .page .card .subtitle,
    .page .card .small:first-of-type {
        margin-bottom: 18px !important;
    }
    /* Brand logo a bit smaller on mobile */
    .sidebar .brand img {
        width: 46px !important;
        height: 46px !important;
        border-radius: 12px !important;
    }
}

/* === Mobile/iOS stability: avoid translucent layer bleed (Safari/iPhone) === */
@media (max-width: 1024px) {
    body::before {
        display: none !important;
        content: none !important;
        background: none !important;
    }
    .card,
    .topbar,
    .sidebar,
    .sheet,
    .modal,
    .modal-card {
        background: #0d1117 !important;
        -webkit-backdrop-filter: none !important;
        backdrop-filter: none !important;
    }
}
/* iOS Safari specific: disable backdrop/translucency even on larger widths */
@supports (-webkit-touch-callout: none) {
    body::before {
        display: none !important;
        content: none !important;
        background: none !important;
    }
    .card,
    .topbar,
    .sidebar {
        background: #0d1117 !important;
        -webkit-backdrop-filter: none !important;
        backdrop-filter: none !important;
    }
}

/* ---------- Timeline improvements ---------- */
.form-grid {
    display: grid;
    grid-template-columns: 260px 1fr auto;
    gap: 12px;
    align-items: end;
}
@media (max-width: 980px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

.limit-360 {
    max-height: 360px;
}
.limit-280 {
    max-height: 280px;
}
.list-scroll {
    max-height: 520px;
    overflow: auto;
}

.card h2 {
    letter-spacing: 0.2px;
}
.small {
    color: var(--muted);
}

/* === Fixed footer + internal scroll (main content) === */
.content {
    height: auto;
    min-height: calc(100vh - var(--topbar));
}
.content .container {
    min-width: 0;
    overflow: visible;
}
.content .footer {
    position: sticky;
    bottom: 0;
    margin-top: 0;
    padding: 12px 0;
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(8px);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* === Timeline page polish === */
.timeline-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}
.timeline-head .who h3 {
    margin: 0;
    font-size: 20px;
}
.timeline-head .who .muted {
    margin-top: 2px;
}
.timeline-head .total {
    text-align: right;
}
.timeline-head .total .value {
    font-size: 22px;
    font-weight: 900;
}
.form-grid .btn {
    height: 44px;
    padding: 0 18px;
}

.form-help .help-form-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    align-items: start;
}
.form-civil .civil-form-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    align-items: start;
}
.form-help .field-4 {
    grid-column: span 4;
}
.form-civil .field-4 {
    grid-column: span 4;
}
.form-help .field-6 {
    grid-column: span 6;
}
.form-civil .field-6 {
    grid-column: span 6;
}
.form-help .field-8 {
    grid-column: span 8;
}
.form-civil .field-8 {
    grid-column: span 8;
}
.form-help .field-full {
    grid-column: 1 / -1;
}
.form-civil .field-full {
    grid-column: 1 / -1;
}
.form-civil .section-head {
    margin: 20px 0 14px;
}
.form-civil .section-head:first-child {
    margin-top: 0;
}
.form-civil .policy-box,
.form-civil .check-stack {
    margin-top: 14px;
}
.form-civil .policy-box {
    padding: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.03);
}
.form-civil .check-stack {
    display: grid;
    gap: 12px;
}
.form-civil .check-stack label {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: start;
    gap: 10px 12px;
    margin: 0;
    padding: 14px 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
}
.form-civil .check-stack input[type="checkbox"] {
    width: auto;
    min-width: 0;
    max-width: none;
    height: auto;
    margin: 3px 0 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    justify-self: start;
    align-self: start;
}
.form-register {
    width: min(100%, 1480px);
    max-width: none;
    margin: 8px auto 32px;
}
.form-register .form-card {
    width: 100%;
    padding: 18px 30px 28px;
}
.form-register .section-head {
    margin: 26px 0 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.form-register .section-head:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}
.form-register .register-hero {
    margin-bottom: 18px;
}
.form-register .section-head h1,
.form-register .section-head h2 {
    margin: 0 0 6px;
}
.form-register .section-head .small {
    margin: 0;
    max-width: 760px;
    line-height: 1.55;
}
.form-register .register-form-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    align-items: start;
    gap: 16px;
}
.profile-form-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    align-items: start;
    gap: 16px;
}
.profile-form-grid > .col-12 {
    grid-column: 1 / -1;
}
.profile-form-grid > .col-6 {
    grid-column: span 6;
    min-width: 0;
}
.profile-form-grid > .col-4 {
    grid-column: span 4;
    min-width: 0;
}
.profile-form-grid > .col-3 {
    grid-column: span 3;
    min-width: 0;
}
.profile-form-grid > .col-2 {
    grid-column: span 2;
    min-width: 0;
}
.profile-form-grid > .col-1 {
    grid-column: span 1;
    min-width: 0;
}
.profile-form-grid input,
.profile-form-grid select,
.profile-form-grid textarea {
    min-width: 0;
}
.form-register .field-1 {
    grid-column: span 1;
}
.form-register .field-2 {
    grid-column: span 2;
}
.form-register .field-3 {
    grid-column: span 3;
}
.form-register .field-4 {
    grid-column: span 4;
}
.form-register .field-6 {
    grid-column: span 6;
}
.form-register .field-7 {
    grid-column: span 7;
}
.form-register .field-8 {
    grid-column: span 8;
}
.form-register .field-full {
    grid-column: 1 / -1;
}
.form-register .nested-register-grid {
    margin-top: 0;
}
.form-register .field {
    min-width: 0;
}
.form-register .field input,
.form-register .field select,
.form-register .field textarea {
    min-width: 0;
}
.register-toggle-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.register-toggle-card {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: start;
    gap: 10px 12px;
    width: 100%;
    margin: 0;
    padding: 14px 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
}
.register-toggle-card input[type="checkbox"] {
    width: auto;
    min-width: 0;
    max-width: none;
    height: auto;
    margin: 3px 0 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    justify-self: start;
    align-self: start;
}
.register-toggle-card span {
    min-width: 0;
    font-weight: 700;
    overflow-wrap: anywhere;
}
.form-help .field-help {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
}
.help-location-box {
    margin: 20px 0 8px;
    padding: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.03);
}
.help-geo-status {
    margin-top: 10px;
}
.help-geo-status.is-error {
    color: #ff8f8f;
}
.help-type-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}
.help-type-card {
    padding: 16px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    overflow: hidden;
    transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.help-type-card.is-active {
    border-color: rgba(255, 184, 92, 0.5);
    background: rgba(255, 184, 92, 0.08);
}
.help-type-head {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: start;
    gap: 10px 12px;
    width: 100%;
    max-width: 100%;
    font-weight: 700;
    cursor: pointer;
    white-space: normal;
}
.help-type-head input[type="checkbox"] {
    width: auto;
    min-width: 0;
    max-width: none;
    height: auto;
    margin: 3px 0 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    justify-self: start;
    align-self: start;
    flex: none;
}
.help-type-head span {
    min-width: 0;
    overflow-wrap: anywhere;
}
.help-detail-box {
    margin-top: 14px;
}
@media (max-width: 980px) {
    .form-civil .civil-form-grid {
        grid-template-columns: 1fr;
    }
    .form-civil .field-4,
    .form-civil .field-6,
    .form-civil .field-8,
    .form-civil .field-full {
        grid-column: auto;
    }
    .form-register .register-form-grid {
        grid-template-columns: 1fr;
    }
    .profile-form-grid {
        grid-template-columns: 1fr;
    }
    .form-register .form-card {
        padding: 22px 18px 26px;
    }
    .profile-form-grid > .col-12,
    .profile-form-grid > .col-6,
    .profile-form-grid > .col-4,
    .profile-form-grid > .col-3,
    .profile-form-grid > .col-2,
    .profile-form-grid > .col-1 {
        grid-column: auto;
    }
    .form-register .field-1,
    .form-register .field-2,
    .form-register .field-3,
    .form-register .field-4,
    .form-register .field-6,
    .form-register .field-7,
    .form-register .field-8,
    .form-register .field-full {
        grid-column: auto;
    }
    .register-toggle-grid {
        grid-template-columns: 1fr;
    }
    .form-help .help-form-grid {
        grid-template-columns: 1fr;
    }
    .form-help .field-4,
    .form-help .field-6,
    .form-help .field-8,
    .form-help .field-full {
        grid-column: auto;
    }
}
@media (max-width: 980px) {
    .timeline-head {
        align-items: flex-start;
    }
    .timeline-head .total {
        text-align: left;
    }
}

/* ===== Layout base fix: scroll interno + sidebar footer fixo ===== */
body {
    overflow: auto;
}
.app {
    min-height: 100vh;
    overflow: visible;
}
.sidebar {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}
.sidebar .nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    padding-right: 4px;
    padding-bottom: 12px;
    scrollbar-gutter: stable;
}
.sidebar .side-footer {
    flex: 0 0 auto;
    margin-top: 12px;
    background: linear-gradient(
        180deg,
        rgba(13, 17, 23, 0),
        rgba(13, 17, 23, 0.92) 30%,
        rgba(13, 17, 23, 0.98)
    );
    padding-top: 12px;
    padding-bottom: 2px;
}

.main {
    min-width: 0;
    overflow: visible;
}
.content {
    overflow: visible;
    min-width: 0;
}
.content > .container {
    min-width: 0;
}
.page-footer {
    position: fixed;
    left: var(--sidebar);
    right: 0;
    bottom: 0;
    z-index: 55;
    height: var(--footer);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 18px;
    border-top: 1px solid var(--line);
    background: rgba(7, 9, 12, 0.78);
    backdrop-filter: blur(10px);
    font-size: 13px;
    color: var(--muted);
}
.map-frame,
#mapa_v2,
.leaflet-container,
.leaflet-pane,
.leaflet-top,
.leaflet-bottom,
.leaflet-control-container {
    z-index: 1 !important;
}

@media (max-width: 720px) {
    .content {
        padding-bottom: calc(var(--footer) + 20px + env(safe-area-inset-bottom));
    }
    .page-footer {
        height: auto;
        min-height: var(--footer);
        padding-top: 10px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
        align-items: flex-start;
    }
    .page-footer .pf-left,
    .page-footer .pf-right {
        align-items: flex-start;
    }
    .list-scroll {
        max-height: none;
    }
}
.page-footer .pf-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.page-footer .pf-muted {
    color: var(--muted);
    font-weight: 700;
}
.page-footer .pf-sep {
    opacity: 0.6;
}

/* Tabelas longas: não estourar a página */
.table-wrap {
    max-height: none;
    overflow: visible;
    border: 1px solid var(--line);
    border-radius: var(--radius2);
    width: 100%;
}
.table-wrap table {
    margin: 0;
    min-width: 0;
}

.side-footer {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.side-brand {
    padding: 10px 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.18);
}
.side-brand-title {
    font-weight: 900;
    letter-spacing: 0.02em;
    font-size: 13px;
    color: var(--text);
}
.side-brand-sub {
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted);
}
.side-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
}
.side-user,
.side-logout {
    min-width: 0;
}
.side-user {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 0 4px;
    color: var(--text);
    line-height: 1.15;
    overflow: hidden;
}
.side-user strong {
    display: block;
    font-size: 15px;
    font-weight: 800;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.side-user small {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.side-logout {
    border-radius: 18px;
    border: 1px solid rgba(255, 122, 26, 0.28);
    background: linear-gradient(
        180deg,
        rgba(255, 122, 26, 0.16),
        rgba(255, 122, 26, 0.1)
    );
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    min-height: 48px;
    color: #ff9a54;
    text-decoration: none;
    font-weight: 700;
    white-space: nowrap;
}
.side-logout:hover {
    background: linear-gradient(
        180deg,
        rgba(255, 122, 26, 0.22),
        rgba(255, 122, 26, 0.14)
    );
    border-color: rgba(255, 122, 26, 0.4);
    color: #ffb37d;
}

@media (max-width: 1024px) {
    .sidebar {
        height: 100dvh;
        min-height: 100dvh;
    }
}
@media (max-width: 480px) {
    .side-actions {
        grid-template-columns: 1fr;
    }
    .side-logout {
        min-height: 48px;
    }
}

/* === Timeline card fixes === */
.tl-head {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: start;
}
.tl-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    text-align: right;
}
@media (max-width: 780px) {
    .tl-head {
        grid-template-columns: 1fr;
    }
    .tl-head .tl-right {
        text-align: left;
        align-items: flex-start;
    }
}
.tl-name {
    font-size: 20px;
    font-weight: 900;
    line-height: 1.15;
    /* Do not break names mid-word (only wrap on spaces; break very long tokens if needed) */
    word-break: normal;
    overflow-wrap: break-word;
}
.tl-total {
    font-size: 22px;
    font-weight: 900;
    line-height: 1.1;
}
.tl-search-grid {
    display: grid;
    grid-template-columns: minmax(240px, 340px) minmax(320px, 1fr) auto;
    gap: 14px;
    align-items: end;
    margin-top: 18px;
}
.tl-panel-title {
    margin: 0 0 6px;
}
.tl-section-card {
    padding: 12px;
    margin-top: 14px;
}
.tl-section-heading {
    font-weight: 800;
    margin-bottom: 8px;
}
.tl-results {
    margin-top: 14px;
}
.tl-results-label {
    margin-bottom: 8px;
}
.tl-revert-btn {
    width: 100%;
    margin-top: 10px;
}
.tl-list-name {
    font-weight: 700;
}
.tl-kpi-small {
    font-size: 16px;
}
.tl-empty-card {
    min-height: 160px;
}
.tl-empty-card .small {
    margin: 0;
    max-width: 62ch;
}
.tl-side-card {
    align-self: start;
    overflow: hidden;
}
.tl-side-card .list-scroll {
    margin-top: 12px;
    padding-right: 2px;
}
.tl-side-card .list-item {
    border-color: rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.03);
    box-shadow: none;
}
.tl-side-card .list-item + .list-item {
    margin-top: 0;
}
.tl-side-card .li-sub {
    line-height: 1.45;
}
@media (max-width: 1100px) {
    .tl-search-grid {
        grid-template-columns: 1fr;
    }
}
.kpi-card {
    min-height: 96px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.kpi-value {
    line-height: 1.1;
}
.kpi-small {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: none;
    overflow-wrap: anywhere;
}

/* ===============================
   Theme normalization (global)
   Ensures consistent typography/cards/forms across ALL pages
   =============================== */
:root {
    --radius-card: 18px;
    --radius-btn: 14px;
}

/* ------------------------------------------------
   Phase 1 UI normalization
   Typography + cards + list components
   ------------------------------------------------ */

/* Links: stop browser default blue for internal list/cards.
   Keep accent color for normal links; keep button/link components styled by their own classes. */
.content a {
    color: var(--accent2);
    text-decoration: none;
}
.content a:hover {
    text-decoration: underline;
}
.content a.list-item {
    color: inherit;
    text-decoration: none;
}
.content .card a:not(.btn):not(.btn2) {
    color: inherit;
    text-decoration: none;
}

/* List component (used by admin_timeline search + recent activity)
   Ensures full-width items that behave like cards */
.list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.list-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    min-width: 0; /* allows inner text ellipsis in flex/grid contexts */
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(255, 255, 255, 0.02);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
    color: var(--text);
    text-decoration: none;
}

/* Timeline: keep recent-activity items aligned (no weird wrapping / blue-link look) */
.list-item .li-title,
.list-item .li-sub {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.list-item:hover {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.03);
}
.list-item.muted {
    color: var(--muted);
}

/* Timeline: keep long names/lines aligned horizontally (no mid-word breaks)
   and avoid the browser default link look. */
.list-item .li-title,
.list-item .li-sub {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Card typography consistency */
.card {
    line-height: 1.55;
}
.card .muted,
.muted {
    color: var(--muted);
}
.card h1,
.card h2,
.card h3 {
    color: rgba(255, 255, 255, 0.94);
}

/* Typography */
.content,
.content * {
    font-family: var(--font);
}
.content h1,
.content h2,
.content h3 {
    letter-spacing: -0.01em;
}
.content h1 {
    font-size: 26px;
    margin: 0 0 14px;
}
.content h2 {
    font-size: 20px;
    margin: 0 0 12px;
}
.content h3 {
    font-size: 15px;
    margin: 0 0 10px;
}
.content p {
    margin: 0 0 10px;
    line-height: 1.5;
}

/* Cards */
.card {
    border-radius: var(--radius-card) !important;
}
.card .row {
    margin-top: 10px;
}

/* Tables */
.table,
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}
.table th,
.table td,
table th,
table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.table thead th,
table thead th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Forms */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    font-family: var(--font);
    border-radius: 12px;
}
.btn,
.btn2,
button.btn,
button.btn2 {
    border-radius: var(--radius-btn);
    font-weight: 800;
}

/* Footer — keep same visual language of topbar */
.page-footer {
    border-top: 1px solid var(--line);
}

/* ===== Dashboard moderno (apenas quando usado) ===== */
.dash-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}
.dash-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}
@media (max-width: 1200px) {
    .dash-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 640px) {
    .dash-actions {
        grid-template-columns: 1fr;
    }
}

.action-card {
    display: block;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    text-decoration: none;
    color: inherit;
    transition:
        transform 0.08s ease,
        border-color 0.08s ease,
        background 0.08s ease;
    min-height: 62px;
}
.action-card:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.05);
}
.action-card:active {
    transform: translateY(0);
}
.action-card .ac-title {
    font-weight: 700;
    letter-spacing: 0.2px;
}
.action-card .ac-sub {
    margin-top: 4px;
    font-size: 12px;
    opacity: 0.78;
}
.action-card.muted {
    pointer-events: none;
    opacity: 0.95;
}
.card.inner {
    padding: 14px;
}

/* Camera corporal */
.live-wrap {
    border-radius: var(--radius2);
    overflow: hidden;
    border: 1px solid var(--line);
    background: #000;
}
.live-video {
    width: 100%;
    height: auto;
    min-height: 320px;
    display: block;
}
@media (max-width: 980px) {
    .live-video {
        min-height: 240px;
    }
}

/* ===== Module polish 2026-01 ===== */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
    margin: 0 0 14px;
}
.page-head h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1.15;
    letter-spacing: -0.02em;
}
.card h2 {
    margin: 0 0 10px;
    font-size: 18px;
    letter-spacing: -0.01em;
}
.table-wrap {
    width: 100%;
    overflow: visible;
    border-radius: 14px;
    border: 1px solid var(--line);
}
table {
    width: 100%;
    border-collapse: collapse;
}
th,
td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
}
tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}
.row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.btn {
    cursor: pointer;
}
.btn,
.btn2 {
    user-select: none;
}
/* Melhor leitura em telas pequenas */
@media (max-width: 720px) {
    .page-head {
        align-items: flex-start;
        flex-direction: column;
    }
    .page-head h1 {
        font-size: 24px;
    }
}

/* ===================================================================
   Light mode — applied when <html data-theme="light">
   Preference is persisted in localStorage by theme-toggle.js
   =================================================================== */
[data-theme="light"] {
    --bg: #ffffff;
    --panel: #ffffff;
    --panel2: #ffffff;
    --text: #1a1d23;
    --muted: #5a6270;
    --line: rgba(0, 0, 0, 0.09);
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    --accent: #e04f00;
    --accent2: #c94800;
}

/* Body background */
[data-theme="light"] body {
    background:
        radial-gradient(
            1200px 700px at 15% 10%,
            rgba(255, 90, 0, 0.05),
            transparent 55%
        ),
        radial-gradient(
            900px 600px at 80% 25%,
            rgba(255, 90, 0, 0.04),
            transparent 55%
        ),
        linear-gradient(180deg, #ffffff 0%, #ffffff 100%);
    color: var(--text);
}

/* Sidebar */
[data-theme="light"] .sidebar {
    background: linear-gradient(
        180deg,
        rgba(248, 250, 252, 0.98),
        rgba(242, 246, 250, 0.98)
    );
    border-right-color: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .sidebar .brand {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.07);
}
[data-theme="light"] .sidebar .side-footer {
    border-color: rgba(0, 0, 0, 0.07);
    background: rgba(0, 0, 0, 0.03);
}

/* Nav items */
[data-theme="light"] .nav .section-title {
    color: rgba(0, 0, 0, 0.4);
}
[data-theme="light"] .nav a:hover,
[data-theme="light"] .nav button:hover,
[data-theme="light"] .nav summary:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.06);
}
[data-theme="light"] .nav a.active {
    background: rgba(255, 90, 0, 0.1);
    border-color: rgba(255, 90, 0, 0.22);
    box-shadow: none;
}
[data-theme="light"] .nav details[open] > summary {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.06);
}
[data-theme="light"] .nav details .subnav {
    border-left-color: rgba(0, 0, 0, 0.08);
}

/* Topbar */
[data-theme="light"] .topbar {
    background: rgba(255, 255, 255, 0.92);
    border-bottom-color: rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(10px);
}
[data-theme="light"] .topbar .crumb-title {
    color: #1a1d23;
}
[data-theme="light"] .topbar-link {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.08);
    color: var(--text);
}
[data-theme="light"] .topbar-link:hover {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.14);
}
[data-theme="light"] .topbar-link-accent {
    background: linear-gradient(
        180deg,
        rgba(224, 79, 0, 0.14),
        rgba(224, 79, 0, 0.09)
    );
    border-color: rgba(224, 79, 0, 0.22);
    color: #b84200;
    box-shadow: none;
}
[data-theme="light"] .topbar-link-accent:hover {
    background: linear-gradient(
        180deg,
        rgba(224, 79, 0, 0.18),
        rgba(224, 79, 0, 0.12)
    );
    border-color: rgba(224, 79, 0, 0.28);
    color: #8f3400;
}
[data-theme="light"] .icon-btn {
    border-color: rgba(0, 0, 0, 0.1);
    background: rgba(0, 0, 0, 0.03);
    color: var(--text);
}
[data-theme="light"] .icon-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}

/* Cards */
[data-theme="light"] .card {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.07);
}
[data-theme="light"] .card h1,
[data-theme="light"] .card h2,
[data-theme="light"] .card h3,
[data-theme="light"] .auth-page h1,
[data-theme="light"] .content h1,
[data-theme="light"] .content h2,
[data-theme="light"] .content h3 {
    color: #1a1d23;
}
[data-theme="light"] .card .small,
[data-theme="light"] .card .muted,
[data-theme="light"] .auth-page .small {
    color: #5a6270;
}
[data-theme="light"] .card:hover {
    border-color: rgba(0, 0, 0, 0.14);
}
[data-theme="light"] .card.soft {
    background: rgba(0, 0, 0, 0.02);
}
[data-theme="light"] .help-location-box,
[data-theme="light"] .help-type-card,
[data-theme="light"] .form-civil .policy-box,
[data-theme="light"] .form-civil .check-stack label,
[data-theme="light"] .register-toggle-card {
    background: #f4f6f8;
    border-color: rgba(0, 0, 0, 0.12);
}
[data-theme="light"] .help-type-card.is-active {
    background: #fff1e7;
    border-color: rgba(224, 79, 0, 0.28);
}

/* Inputs & selects */
[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea,
[data-theme="light"] input[type="text"],
[data-theme="light"] input[type="number"],
[data-theme="light"] input[type="password"],
[data-theme="light"] input[type="email"] {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.14);
    color: var(--text);
}
[data-theme="light"] input::placeholder,
[data-theme="light"] textarea::placeholder {
    color: rgba(0, 0, 0, 0.35);
}
[data-theme="light"] input:focus,
[data-theme="light"] select:focus,
[data-theme="light"] textarea:focus {
    border-color: rgba(224, 79, 0, 0.4);
    box-shadow: 0 0 0 3px rgba(224, 79, 0, 0.12);
}
[data-theme="light"] label {
    color: rgba(0, 0, 0, 0.65);
}

/* Tables */
[data-theme="light"] thead th {
    background: rgba(240, 244, 248, 0.98);
    border-bottom-color: rgba(0, 0, 0, 0.08);
    color: var(--muted);
}
[data-theme="light"] tbody td {
    border-bottom-color: rgba(0, 0, 0, 0.06);
}
[data-theme="light"] tbody tr:hover td {
    background: rgba(0, 0, 0, 0.02);
}
[data-theme="light"] .table-wrap {
    border-color: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] th,
[data-theme="light"] td {
    border-bottom-color: rgba(0, 0, 0, 0.06);
    color: var(--text);
}

/* Action menus */
[data-theme="light"] .actions-menu .menu {
    background: rgba(255, 255, 255, 0.99);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.14);
}
[data-theme="light"] .actions-menu .menu a,
[data-theme="light"] .actions-menu .menu button {
    color: var(--text);
}
[data-theme="light"] .actions-menu .menu a:hover,
[data-theme="light"] .actions-menu .menu button:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Buttons — keep accent colors, darken slightly */
[data-theme="light"] .btn,
[data-theme="light"] .btn2 {
    border-color: rgba(224, 79, 0, 0.28);
    background: rgba(224, 79, 0, 0.1);
    color: #c94800;
}
[data-theme="light"] .btn:hover,
[data-theme="light"] .btn2:hover {
    background: rgba(224, 79, 0, 0.16);
    border-color: rgba(224, 79, 0, 0.38);
}
[data-theme="light"]
    button:not(.icon-btn):not(.btn):not(.btn2):not(.btnDanger):not(.btn-danger),
[data-theme="light"]
    input[type="submit"]:not(.icon-btn):not(.btn):not(.btn2):not(
        .btnDanger
    ):not(.btn-danger) {
    border-color: rgba(224, 79, 0, 0.28);
    background: rgba(224, 79, 0, 0.1);
    color: #c94800;
}
[data-theme="light"]
    button:not(.icon-btn):not(.btn):not(.btn2):not(.btnDanger):not(
        .btn-danger
    ):hover {
    background: rgba(224, 79, 0, 0.16);
    border-color: rgba(224, 79, 0, 0.38);
}

/* Footer */
[data-theme="light"] .page-footer {
    background: rgba(255, 255, 255, 0.96);
    border-top-color: rgba(0, 0, 0, 0.06);
    box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.04);
}
[data-theme="light"] .sidebar .side-footer {
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0),
        rgba(255, 255, 255, 0.9) 28%,
        rgba(255, 255, 255, 0.98)
    );
}
[data-theme="light"] .content .footer {
    background: rgba(255, 255, 255, 0.92);
    border-top-color: rgba(0, 0, 0, 0.07);
}

/* Disable forced dark backgrounds on mobile when in light mode */
@media (max-width: 768px) {
    [data-theme="light"] .card,
    [data-theme="light"] .topbar {
        background: rgba(255, 255, 255, 0.97) !important;
    }
}
@media (max-width: 1024px) {
    [data-theme="light"] .card,
    [data-theme="light"] .topbar,
    [data-theme="light"] .sidebar {
        background: #ffffff !important;
    }
}
@supports (-webkit-touch-callout: none) {
    [data-theme="light"] .card,
    [data-theme="light"] .topbar,
    [data-theme="light"] .sidebar {
        background: #ffffff !important;
    }
}

/* Theme toggle button in topbar */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 16px;
    transition:
        color 0.15s,
        background 0.15s;
    padding: 0;
}
.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}
[data-theme="light"] .theme-toggle:hover {
    background: rgba(0, 0, 0, 0.06);
}

/* Language switcher */
.lang-switcher {
    display: inline-flex;
    gap: 4px;
    padding: 3px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.02);
}
.lang-switcher a {
    font-size: 12px;
    font-weight: 700;
    padding: 5px 8px;
    border-radius: 8px;
    border: 1px solid transparent;
    color: var(--muted);
    text-decoration: none;
    line-height: 1;
}
.lang-switcher a:hover {
    color: var(--text);
    border-color: var(--accent);
}
.lang-switcher a.active {
    color: var(--accent2);
    border-color: var(--accent);
    background: rgba(255, 90, 0, 0.1);
}
[data-theme="light"] .lang-switcher {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.08);
}
