/* =========================================================
   SIESCON 360 — style.css
   Design system + responsividade completa
   ========================================================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --bg: #f3f5f7;
    --surface: #ffffff;
    --surface-2: #f7f9fb;
    --border: #d9e1e8;
    --text: #16201c;
    --muted: #5d6b73;
    --brand: #141a17;
    --accent: #6cb3e4;
    --accent-strong: #3f92cc;
    --ok: #1d8a5a;
    --warn: #c58a12;
    --danger: #c2453c;
    --shadow: 0 1px 2px rgba(16, 24, 32, .05), 0 8px 20px rgba(16, 24, 32, .05);
    --radius: 8px;
    --sidebar-w: 250px;
    --sidebar-w-collapsed: 66px;
    --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

[data-theme="dark"] {
    --bg: #0f1418;
    --surface: #161d23;
    --surface-2: #1b242b;
    --border: #2a353e;
    --text: #e8eef2;
    --muted: #9fb0bb;
    --brand: #e8eef2;
    --accent: #6cb3e4;
    --accent-strong: #8ec8f0;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px rgba(0, 0, 0, .35);
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    max-width: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: clamp(13px, .95vw, 15px);
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
}

body.modal-open {
    overflow: hidden;
}

.app {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

img {
    max-width: 100%;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
    max-width: 100%;
    min-width: 0;
}

h1,
h2,
h3,
h4 {
    margin: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* ---------------- SPLASH ---------------- */
.splash {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--bg);
    padding: 24px;
    text-align: center;
}

.splash-logo {
    height: clamp(44px, 8vw, 74px);
    width: auto;
    object-fit: contain;
}

[data-theme="dark"] .splash-logo,
[data-theme="dark"] .sidebar-logo,
[data-theme="dark"] .modal-logo,
[data-theme="dark"] .report-logo {
    filter: invert(1) brightness(1.7) hue-rotate(180deg);
}

.splash-title {
    font-weight: 800;
    font-size: clamp(1.2rem, 2.4vw, 1.8rem);
}

.splash-sub {
    color: var(--muted);
    font-size: .9rem;
}

.splash-bar {
    width: min(320px, 80vw);
    height: 5px;
    border-radius: 99px;
    background: var(--border);
    overflow: hidden;
}

.splash-bar span {
    display: block;
    height: 100%;
    width: 40%;
    border-radius: 99px;
    background: var(--accent);
    animation: slide 1.1s infinite ease-in-out;
}

@keyframes slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(300%); }
}

/* ---------------- TOPBAR / BRAND ---------------- */
.topbar {
    flex: 0 0 auto;
    z-index: 40;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 12px;
    padding: 8px clamp(10px, 2vw, 20px);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 0 rgba(16, 24, 32, .03);
    min-width: 0;
}

.brand {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    min-width: 0;
    flex: 1 1 260px;
}

.brand-logo {
    display: block;
    width: auto;
    height: clamp(38px, 5vw, 58px);
    max-width: min(220px, 34vw);
    object-fit: contain;
    flex-shrink: 0;
}

.brand-text {
    min-width: 0;
    text-align: left;
}

.brand-text strong,
.brand-text span {
    display: block;
    overflow-wrap: anywhere;
}

.brand-text strong {
    font-size: clamp(.95rem, 1.4vw, 1.15rem);
    letter-spacing: .2px;
}

.brand-text span {
    font-size: clamp(.7rem, 1vw, .82rem);
    color: var(--muted);
}

.topbar-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.period-chip {
    display: flex;
    flex-direction: column;
    padding: 4px 12px;
    border-radius: 99px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    min-width: 0;
    cursor: pointer;
}

.period-chip-label {
    font-size: .62rem;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--muted);
}

.period-chip-value {
    font-size: .78rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    cursor: pointer;
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background .15s, border-color .15s, transform .1s;
}

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

.btn:active {
    transform: translateY(1px);
}

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

[data-theme="dark"] .btn-primary {
    color: #08131b;
}

.btn-sm {
    padding: 5px 9px;
    font-size: .74rem;
}

.icon-btn {
    border: 1px solid transparent;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    padding: 6px 9px;
    font-size: 1rem;
    line-height: 1;
}

.icon-btn:hover {
    background: var(--surface-2);
    border-color: var(--border);
}

.menu-toggle {
    display: none;
}

/* ---------------- PANELS ---------------- */
.panel {
    flex: 0 0 auto;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 clamp(10px, 2vw, 20px) 16px;
    max-height: min(46dvh, 430px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 0 8px;
    min-width: 0;
}

.panel-head h2 {
    font-size: clamp(.9rem, 1.4vw, 1.05rem);
}

.panel-head-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.panel-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

#settingsPanel {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    max-height: none;
    overflow: hidden;
    padding: clamp(12px, 2vw, 24px);
    border-bottom: 0;
    background: rgba(8, 14, 18, .54);
    backdrop-filter: blur(6px);
}

#settingsPanel[hidden] {
    display: none;
}

#settingsPanel .panel-head,
#settingsPanel .panel-body {
    width: min(1120px, calc(100vw - 24px));
    background: var(--surface);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow);
}

#settingsPanel .panel-head {
    flex: 0 0 auto;
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
}

#settingsPanel .panel-head h2 {
    font-size: 1.08rem;
}

#settingsPanel .panel-body {
    flex: 0 1 auto;
    max-height: min(78dvh, 760px);
    overflow: auto;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow);
}

#settingsPanel .sub {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    color: var(--text);
}

#settingsPanel .sub:first-child {
    padding-top: 0;
    border-top: 0;
}

#settingsPanel .field-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

#settingsPanel .field {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
}

#settingsPanel input,
#settingsPanel select {
    background: var(--surface);
}

.settings-logo-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0;
}

.settings-logo-row .hint {
    flex: 1 1 260px;
}

#officeLogoPreview {
    max-width: 180px;
    max-height: 56px;
    object-fit: contain;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    min-width: 0;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
    max-width: 100%;
}

.field > span {
    font-size: clamp(.72rem, 1vw, .8rem);
    font-weight: 600;
    color: var(--muted);
    overflow-wrap: anywhere;
}

input,
select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
}

input:focus,
select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.chip {
    padding: 6px 11px;
    border-radius: 99px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    cursor: pointer;
    font-size: .76rem;
    font-weight: 600;
    white-space: normal;
    overflow-wrap: anywhere;
}

.chip:hover,
.chip.active {
    border-color: var(--accent);
    background: color-mix(in oklab, var(--accent) 18%, transparent);
}

.check-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 4px 12px;
    max-height: 170px;
    overflow: auto;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    min-width: 0;
}

.check-list-tall {
    max-height: 240px;
}

.check-list label {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    font-size: .78rem;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
    cursor: pointer;
}

.check-list input {
    width: auto;
    margin-top: 3px;
    flex-shrink: 0;
}

.hint {
    margin: 0;
    font-size: .76rem;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.sub {
    font-size: .84rem;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--muted);
    margin-top: 4px;
}

.settings-logo-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    min-width: 0;
}

.settings-logo-row img {
    width: auto;
    max-width: min(240px, 100%);
    max-height: 72px;
    object-fit: contain;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
}

.range-info {
    font-size: .78rem;
    color: var(--muted);
    overflow-wrap: anywhere;
}

/* ---------------- SHELL / SIDEBAR ---------------- */
.shell {
    display: flex;
    align-items: flex-start;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    min-width: 0;
}

.sidebar {
    position: static;
    align-self: flex-start;
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    height: 100%;
    max-height: none;
    overflow: auto;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: width .18s ease, flex-basis .18s ease;
}

.app.collapsed .sidebar {
    width: var(--sidebar-w-collapsed);
    flex-basis: var(--sidebar-w-collapsed);
}

.app.collapsed .nav-label,
.app.collapsed .sidebar-title,
.app.collapsed .sidebar-foot {
    display: none;
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    min-width: 0;
}

.sidebar-title {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    font-weight: 700;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    text-align: left;
    width: 100%;
    min-width: 0;
    font-size: .84rem;
    font-weight: 600;
}

.nav-item:hover {
    background: var(--surface-2);
}

.nav-item.active {
    background: color-mix(in oklab, var(--accent) 16%, transparent);
    border-color: color-mix(in oklab, var(--accent) 64%, var(--border));
    box-shadow: inset 3px 0 0 var(--accent-strong);
}

.nav-icon {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.nav-label {
    min-width: 0;
    overflow-wrap: anywhere;
}

.sidebar-foot {
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.sidebar-logo {
    width: 100%;
    max-width: 150px;
    height: auto;
    object-fit: contain;
    opacity: .8;
}

.scrim {
    display: none;
}

/* ---------------- MAIN ---------------- */
.main {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    height: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: clamp(12px, 2vw, 24px);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.module-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.module-head h1 {
    font-size: clamp(1.18rem, 2vw, 1.65rem);
    min-width: 0;
}

.module-head p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: clamp(.75rem, 1.1vw, .87rem);
    overflow-wrap: anywhere;
}

.head-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.dashboard-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

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

.section-head h2 {
    font-size: clamp(.88rem, 1.3vw, 1.08rem);
    font-weight: 800;
}

.section-head p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: .76rem;
}

/* ---------------- CARDS ---------------- */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    min-width: 0;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 13px 14px;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-wrap: anywhere;
    word-break: break-word;
    border-top: 3px solid transparent;
}

.section-kpis .card:nth-child(1) { border-top-color: var(--accent-strong); }
.section-kpis .card:nth-child(2) { border-top-color: var(--ok); }
.section-kpis .card:nth-child(3) { border-top-color: var(--warn); }
.section-kpis .card:nth-child(4) { border-top-color: var(--accent); }

.card-clickable {
    cursor: pointer;
    transition: border-color .15s, transform .1s, box-shadow .15s;
}

.card-clickable:hover,
.card-clickable:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 1px 2px rgba(16, 24, 32, .08), 0 10px 28px rgba(16, 24, 32, .1);
}

.card-clickable:active {
    transform: translateY(1px);
}

.card-title {
    font-size: clamp(.76rem, 1.05vw, .88rem);
    font-weight: 700;
    color: var(--muted);
    min-width: 0;
}

.card-value {
    font-size: clamp(1.28rem, 2vw, 2.05rem);
    font-weight: 800;
    line-height: 1.15;
    min-width: 0;
}

.card-sub {
    font-size: clamp(.7rem, 1vw, .8rem);
    color: var(--muted);
}

.tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 99px;
    font-size: .66rem;
    font-weight: 700;
    border: 1px solid var(--border);
    background: var(--surface-2);
}

.tag.real { border-color: var(--ok); color: var(--ok); }
.tag.proj { border-color: var(--accent-strong); color: var(--accent-strong); }
.tag.up { border-color: var(--ok); color: var(--ok); }
.tag.down { border-color: var(--danger); color: var(--danger); }

/* ---------------- CHARTS ---------------- */
.charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 12px;
    min-width: 0;
}

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px 12px 10px;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chart-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.chart-title {
    font-size: clamp(.84rem, 1.1vw, 1rem);
    font-weight: 700;
    min-width: 0;
    overflow-wrap: anywhere;
}

.chart-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
}

.chart-controls select {
    width: auto;
    min-width: 122px;
    max-width: 100%;
    flex: 1 1 122px;
    padding: 5px 8px;
    font-size: .74rem;
}

.chart-box {
    position: relative;
    width: 100%;
    min-width: 0;
    min-height: 280px;
    height: clamp(280px, 32vh, 390px);
}

.chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--muted);
    font-size: .85rem;
    padding: 20px;
    overflow-wrap: anywhere;
}

.chart-foot {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: .72rem;
    color: var(--muted);
    min-width: 0;
}

.legend-dash::before {
    content: "";
    display: inline-block;
    width: 22px;
    border-top: 2px dashed var(--accent-strong);
    margin-right: 5px;
    vertical-align: middle;
}

.legend-solid::before {
    content: "";
    display: inline-block;
    width: 22px;
    border-top: 2px solid var(--accent-strong);
    margin-right: 5px;
    vertical-align: middle;
}

/* ---------------- TABLES ---------------- */
.table-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: 10px;
}

table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    min-width: 620px;
    font-size: .8rem;
}

th,
td {
    padding: 8px 10px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface-2);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--muted);
    cursor: pointer;
}

td.text,
th.text {
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 260px;
}

tbody tr:hover td {
    background: var(--surface-2);
}

.freeze th:first-child,
.freeze td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--surface);
    box-shadow: 1px 0 0 var(--border);
    min-width: 170px;
}

.freeze th:first-child {
    z-index: 3;
    background: var(--surface-2);
}

.clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.expandable {
    cursor: pointer;
    border-bottom: 1px dotted var(--muted);
}

.cards-view {
    display: none;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
}

.row-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    background: var(--surface-2);
    min-width: 0;
    overflow-wrap: anywhere;
}

.row-card h4 {
    font-size: .85rem;
    margin-bottom: 6px;
}

.row-card dl {
    margin: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 8px;
    font-size: .76rem;
}

.row-card dt {
    color: var(--muted);
    min-width: 0;
    overflow-wrap: anywhere;
}

.row-card dd {
    margin: 0;
    font-weight: 700;
    text-align: right;
}

.col-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    padding: 8px;
    border: 1px dashed var(--border);
    border-radius: 10px;
    font-size: .74rem;
    min-width: 0;
}

.col-picker label {
    display: flex;
    align-items: center;
    gap: 5px;
    overflow-wrap: anywhere;
}

.col-picker input {
    width: auto;
}

.table-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 8px 2px 0;
    color: var(--muted);
    font-size: .76rem;
}

.pager-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.pager-controls label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.pager-controls select {
    width: auto;
    min-width: 72px;
    padding: 5px 8px;
    font-size: .74rem;
}

/* ---------------- ALERTS ---------------- */
.alerts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 10px;
}

.alert {
    border: 1px solid var(--border);
    border-left-width: 4px;
    border-radius: 12px;
    padding: 10px 12px;
    background: var(--surface);
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.alert.critical { border-left-color: var(--danger); }
.alert.warn { border-left-color: var(--warn); }
.alert.ok { border-left-color: var(--ok); }
.alert.info { border-left-color: var(--accent-strong); }

.alert b {
    display: block;
    font-size: .84rem;
}

.alert span {
    font-size: .76rem;
    color: var(--muted);
}

/* ---------------- MODAL / TOAST ---------------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(8, 14, 18, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    overflow: hidden;
}

.modal-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    width: min(980px, 100%);
    height: min(92dvh, calc(100dvh - 24px));
    max-height: calc(100dvh - 24px);
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.modal-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    min-width: 0;
    flex: 0 0 auto;
}

.modal-head h2 {
    flex: 1 1 auto;
    min-width: 0;
    font-size: clamp(.9rem, 1.6vw, 1.15rem);
}

.modal-logo {
    height: 30px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
}

.modal-body {
    padding: 14px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    min-height: 0;
    flex: 1 1 auto;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    z-index: 95;
    background: var(--brand);
    color: var(--bg);
    padding: 9px 16px;
    border-radius: 99px;
    font-size: .8rem;
    font-weight: 600;
    box-shadow: var(--shadow);
    max-width: 90vw;
    overflow-wrap: anywhere;
}

.foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: .74rem;
    min-width: 0;
    overflow-wrap: anywhere;
}

.report-header {
    display: none;
    align-items: center;
    gap: 12px;
}

.report-logo {
    height: 46px;
    width: auto;
    object-fit: contain;
}

/* ---------------- RESPONSIVE ---------------- */
@media (max-width: 1100px) {
    .charts {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
}

@media (max-width: 900px) {
    .menu-toggle {
        display: inline-flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 70;
        width: min(84vw, 290px);
        flex-basis: auto;
        max-height: 100vh;
        transform: translateX(-105%);
        transition: transform .2s ease;
        box-shadow: var(--shadow);
    }

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

    .app.menu-open .scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 60;
        background: rgba(8, 14, 18, .45);
    }

    .app.collapsed .sidebar {
        width: min(84vw, 290px);
    }

    .app.collapsed .nav-label,
    .app.collapsed .sidebar-title,
    .app.collapsed .sidebar-foot {
        display: revert;
    }

    .field-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }

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

    .section-head,
    .module-head {
        align-items: flex-start;
    }
}

@media (max-width: 640px) {
    .hide-xs {
        display: none;
    }

    .period-chip {
        order: 5;
        flex: 1 1 100%;
        align-items: flex-start;
    }

    .cards {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .section-head,
    .module-head,
    .head-actions,
    .chart-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .chart-box {
        min-height: 240px;
        height: 280px;
    }

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

    .check-list {
        grid-template-columns: 1fr;
    }

    .table-card.mobile-cards .table-responsive {
        display: none;
    }

    .table-card.mobile-cards .cards-view {
        display: grid;
    }
}

@media print {
    .topbar-actions,
    .sidebar,
    .panel,
    .chart-controls,
    .col-picker,
    .menu-toggle,
    .scrim,
    .foot {
        display: none !important;
    }

    .report-header {
        display: flex;
    }

    body {
        background: #fff;
    }

    .card,
    .chart-card,
    .table-card {
        break-inside: avoid;
        box-shadow: none;
    }
}

[hidden] {
    display: none !important;
}
