/* Tokens compartilhados pelos ambientes da plataforma e dos clientes. */
:root {
    --background: #f3f5f8;
    --surface: #ffffff;
    --sidebar: #142336;
    --sidebar-active: #263c55;
    --text: #192b3e;
    --muted: #5d6d7e;
    --border: #dfe5ec;
    --accent: #165fbe;
    --radius: 12px;
    --sidebar-width: 250px;
}

* {
    box-sizing: border-box;
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    color: var(--text);
    background: var(--background);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a {
    color: var(--accent);
}

a:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid #3384ea;
    outline-offset: 4px;
}

/* Estrutura global: navegação lateral e área de trabalho. */
.shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    max-width: 100%;
    min-height: 100vh;
    min-width: 0;
    overflow-x: hidden;
}

.sidebar {
    display: flex;
    flex-direction: column;
    padding: 28px 18px;
    color: #ffffff;
    background: var(--sidebar);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 42px;
    color: #ffffff;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 10px;
    background: #316fb5;
    font-size: 23px;
    font-weight: 700;
}

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

.brand small {
    margin-top: 2px;
    color: #b8c7d8;
    font-size: 12px;
}

.nav-label {
    margin: 0 10px 12px;
    color: #aebed0;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.navigation {
    display: grid;
    gap: 6px;
}

.nav-link {
    padding: 12px;
    border-radius: 8px;
    color: #d7e1ed;
    text-decoration: none;
}

.nav-link:hover,
.nav-link[aria-current="page"] {
    color: #ffffff;
    background: var(--sidebar-active);
}

.sidebar-note {
    margin-top: auto;
    padding: 40px 10px 0;
    color: #b8c7d8;
    font-size: 12px;
}

.sidebar-note strong {
    color: #e4ecf6;
}

.sidebar-note p {
    margin-bottom: 0;
}

.workspace {
    display: flex;
    flex-direction: column;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 74px;
    padding: 18px 36px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.context {
    font-size: 13px;
    font-weight: 600;
}

.badge {
    padding: 5px 10px;
    border: 1px solid #d9b75d;
    border-radius: 6px;
    color: #74540b;
    background: #fff7de;
    font-size: 12px;
    white-space: nowrap;
}

.content {
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
    padding: 36px;
    flex: 1;
}

.page-heading {
    margin-bottom: 28px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
}

h1 {
    margin: 0;
    font-size: clamp(26px, 3vw, 34px);
    line-height: 1.2;
    letter-spacing: -0.025em;
}

.description {
    margin: 10px 0 0;
    color: var(--muted);
}

/* Indicadores e painéis. */
.metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 26px;
}

.metric,
.panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.metric {
    padding: 22px;
}

.metric h2 {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

.metric-value {
    margin: 14px 0 8px;
    font-size: clamp(23px, 2.3vw, 30px);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.metric-note {
    color: var(--muted);
    font-size: 11px;
}

.panel {
    overflow: hidden;
}

.panel-heading {
    padding: 22px 24px;
}

.panel-heading h2,
.info-panel h2 {
    margin: 0;
    font-size: 17px;
}

.panel-heading p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}

th,
td {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    white-space: nowrap;
}

th {
    color: var(--muted);
    background: #f8fafc;
    font-size: 12px;
    font-weight: 600;
}

tbody tr:hover {
    background: #f8fafc;
}

.info-panel {
    margin-top: 24px;
    padding: 22px 24px;
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    background: #e9f0fa;
}

.info-panel p {
    max-width: 800px;
    margin: 8px 0 0;
    color: #40556e;
    font-size: 13px;
}

.footer {
    padding: 20px 36px;
    color: var(--muted);
    font-size: 12px;
}

.empty-state {
    padding: 28px;
}

.button {
    display: inline-block;
    padding: 10px 16px;
    border-radius: 7px;
    color: #ffffff;
    background: var(--accent);
    text-decoration: none;
}

/* Recursos de acessibilidade. */
.skip-link {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 10;
    padding: 10px 16px;
    color: #ffffff;
    background: var(--accent);
    transform: translateY(-200%);
}

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

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Em telas intermediárias, os indicadores ocupam uma coluna. */
@media (max-width: 1050px) {
    .metrics {
        grid-template-columns: 1fr;
    }
}

/* Mobile: navegação superior e espaçamentos mais compactos. */
@media (max-width: 900px) {
    .shell {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr);
    }

    .sidebar {
        min-width: 0;
        padding: 14px 16px;
    }

    .brand {
        gap: 10px;
        margin-bottom: 12px;
    }

    .brand-mark {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        font-size: 20px;
    }

    .brand small,
    .nav-label,
    .sidebar-note,
    .metric-note {
        display: none;
    }

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

    .nav-link {
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 0;
        min-height: 44px;
        padding: 10px 8px;
        font-size: 13px;
        text-align: center;
        overflow-wrap: anywhere;
    }

    .topbar {
        gap: 10px;
        min-height: 58px;
        padding: 12px 16px;
    }

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

    .badge {
        flex-shrink: 0;
        padding: 4px 8px;
    }

    .content {
        padding: 22px 16px;
    }

    .page-heading {
        margin-bottom: 20px;
    }

    .eyebrow {
        margin-bottom: 6px;
    }

    .description {
        margin-top: 8px;
        font-size: 14px;
    }

    .metrics {
        gap: 10px;
        margin-bottom: 20px;
    }

    .metric {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
        align-items: center;
        gap: 12px;
        min-width: 0;
        padding: 16px;
    }

    .metric h2 {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .metric-value {
        min-width: 0;
        margin: 0;
        font-size: 22px;
        line-height: 1.3;
        text-align: right;
    }

    .panel-heading {
        padding: 16px;
    }

    .table-scroll table {
        table-layout: fixed;
    }

    .table-scroll th,
    .table-scroll td {
        padding: 12px 8px;
        vertical-align: top;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .table-scroll th:nth-child(1) {
        width: 36%;
    }

    .table-scroll th:nth-child(2) {
        width: 37%;
    }

    .table-scroll th:nth-child(3) {
        width: 27%;
    }

    .info-panel {
        margin-top: 20px;
        padding: 16px;
    }

    .footer {
        padding: 16px;
    }

    .empty-state {
        padding: 20px;
    }
}

@media (max-width: 360px) {
    .metric {
        grid-template-columns: minmax(0, 1fr);
        gap: 6px;
    }

    .metric-value {
        text-align: left;
    }
}

/* Navegação escalável: grupos com submenu e indicação visual por seta. */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.sidebar-header .brand {
    min-width: 0;
}

.menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: 1px solid #4c6178;
    border-radius: 8px;
    color: #ffffff;
    background: transparent;
    cursor: pointer;
}

.menu-toggle:hover,
.menu-toggle:focus-visible {
    background: var(--sidebar-active);
}

.menu-toggle-icon {
    font-size: 20px;
    line-height: 1;
}

.nav-section-label {
    margin-top: 28px;
}

.nav-group {
    min-width: 0;
}

.nav-group-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 44px;
    padding: 12px;
    border-radius: 8px;
    color: #d7e1ed;
    cursor: pointer;
    list-style: none;
}

.nav-group-summary::-webkit-details-marker {
    display: none;
}

.nav-group-summary:hover,
.nav-group[open] > .nav-group-summary {
    color: #ffffff;
    background: var(--sidebar-active);
}

.nav-arrow {
    color: #aebed0;
    font-size: 18px;
    line-height: 1;
    transition: transform 160ms ease;
}

.nav-group[open] .nav-arrow {
    transform: rotate(180deg);
}

.nav-submenu {
    display: grid;
    gap: 3px;
    margin: 3px 0 3px 12px;
    padding-left: 10px;
    border-left: 1px solid #466078;
}

.nav-sub-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 10px;
    font-size: 13px;
}

.nav-sub-link small {
    color: #9eb0c3;
    font-size: 10px;
    white-space: nowrap;
}

.nav-link-disabled {
    color: #8fa1b4;
    cursor: not-allowed;
}

.nav-link-disabled:hover {
    color: #8fa1b4;
    background: transparent;
}

@media (max-width: 900px) {
    .sidebar-header {
        width: 100%;
    }

    .menu-toggle {
        display: grid;
        place-items: center;
    }

    .sidebar-navigation {
        display: none;
        width: 100%;
        padding-top: 14px;
    }

    .sidebar-navigation.is-open {
        display: block;
    }

    .sidebar-navigation .navigation {
        grid-template-columns: minmax(0, 1fr);
    }

    .nav-section-label {
        margin-top: 18px;
    }

    .nav-group-summary {
        min-height: 44px;
    }

    .nav-submenu {
        margin-left: 8px;
    }

    .sidebar {
        position: relative;
        z-index: 20;
    }

    .sidebar-header .brand {
        margin-bottom: 0;
    }

    .sidebar-navigation {
        position: absolute;
        top: 100%;
        right: 0;
        left: 0;
        z-index: 30;
        max-height: calc(100vh - 74px);
        padding: 16px;
        overflow-y: auto;
        border-top: 1px solid #2e4862;
        background: var(--sidebar);
        box-shadow: 0 14px 24px rgb(11 27 44 / 24%);
    }

    .sidebar-navigation .nav-label {
        display: block;
        margin: 0 4px 8px;
    }

    .sidebar-navigation .nav-section-label {
        margin-top: 22px;
    }

    .sidebar-navigation .navigation {
        grid-template-columns: minmax(0, 1fr);
    }

    .sidebar-navigation .nav-link,
    .sidebar-navigation .nav-group-summary {
        justify-content: space-between;
        min-height: 46px;
        padding: 11px 12px;
        text-align: left;
    }

    .sidebar-navigation .nav-group-summary {
        background: #1b3148;
    }

    .sidebar-navigation .nav-group[open] > .nav-group-summary {
        background: var(--sidebar-active);
    }

    .sidebar-navigation .nav-submenu {
        margin: 4px 0 6px 10px;
        padding-left: 10px;
    }

    .sidebar-navigation .nav-sub-link {
        min-height: 40px;
        padding: 8px 10px;
        font-size: 13px;
    }
}