/* =====================================================================
   SysMatrix — folha de estilo compartilhada pelos 6 sistemas.
   Conceito visual: "camadas de rocha" — a faixa estratificada sob a
   barra superior repete os blocos escalonados da logo LabRES.
   ===================================================================== */

/* ---------- Fonte (servida localmente em static/fonts) ---------- */
@font-face {
    font-family: "Archivo";
    font-style: normal;
    font-weight: 100 900;
    font-stretch: 62% 125%;
    font-display: swap;
    src: url("fonts/archivo-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: "Archivo";
    font-style: normal;
    font-weight: 100 900;
    font-stretch: 62% 125%;
    font-display: swap;
    src: url("fonts/archivo-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Tokens ---------- */
:root {
    /* Verde (padrao) — derivado do verde-petroleo da logo LabRES */
    --bg: #eef2f0;
    --card: #ffffff;
    --surface-2: #f5f8f6;
    --line: #d6e0db;
    --line-strong: #bccbc4;
    --border: var(--line);
    --ink: #0e2a23;
    --muted: #536d65;
    --brand: #0e6650;
    --brand-2: #04453a;
    --brand-soft: #e3efe9;
    --ring: rgba(14, 102, 80, 0.28);
    --tint: 8 48 38;

    /* Estratos da logo (fixos em todos os temas) */
    --sand: #f2994a;
    --clay: #c7773d;

    --ok: #e2f3e8;
    --ok-ink: #17573a;
    --ok-line: #b5dcc4;
    --error: #fde8e7;
    --error-ink: #8a1f1b;
    --error-line: #f3bcb8;
    --danger: #b3362f;
    --danger-2: #8c2721;

    --font: "Archivo", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    --r-sm: 7px;
    --r-md: 10px;
    --r-lg: 14px;
    --r-xl: 18px;

    --shadow-sm: 0 1px 2px rgb(var(--tint) / 0.06);
    --shadow-md: 0 1px 2px rgb(var(--tint) / 0.05), 0 10px 28px -14px rgb(var(--tint) / 0.22);
    --shadow: 0 2px 6px rgb(var(--tint) / 0.06), 0 28px 60px -24px rgb(var(--tint) / 0.38);

    /* Compatibilidade com nomes antigos usados nos templates/graficos */
    --glow-1: var(--brand-soft);
    --glow-2: var(--brand-soft);

    --actions-col-width: 132px;
}

/* ===== Temas selecionaveis (trocados via data-theme no <html>) ===== */
[data-theme="rosa"] {
    --bg: #f8eff3;
    --card: #ffffff;
    --surface-2: #fcf6f9;
    --line: #efd6e1;
    --line-strong: #e0bccc;
    --ink: #3f1129;
    --muted: #8a5570;
    --brand: #c23a72;
    --brand-2: #8f2453;
    --brand-soft: #fbe6ef;
    --ring: rgba(194, 58, 114, 0.28);
    --tint: 110 24 62;
}

[data-theme="azul"] {
    --bg: #edf2f7;
    --card: #ffffff;
    --surface-2: #f5f8fb;
    --line: #d3e0ec;
    --line-strong: #b9cbdd;
    --ink: #0d2238;
    --muted: #4d6681;
    --brand: #2563a6;
    --brand-2: #17457a;
    --brand-soft: #e4eef8;
    --ring: rgba(37, 99, 166, 0.28);
    --tint: 16 44 80;
}

[data-theme="lavanda"] {
    --bg: #f2eff8;
    --card: #ffffff;
    --surface-2: #f8f6fc;
    --line: #e0d7ee;
    --line-strong: #cbbde3;
    --ink: #261a3d;
    --muted: #66588a;
    --brand: #6d48b8;
    --brand-2: #4d3189;
    --brand-soft: #eee8fa;
    --ring: rgba(109, 72, 184, 0.28);
    --tint: 52 34 100;
}

[data-theme="ambar"] {
    --bg: #f5f0e9;
    --card: #ffffff;
    --surface-2: #fbf8f3;
    --line: #ebdcc6;
    --line-strong: #dcc6a5;
    --ink: #3a2812;
    --muted: #7f6648;
    --brand: #9e6118;
    --brand-2: #74450f;
    --brand-soft: #f8eddb;
    --ring: rgba(158, 97, 24, 0.3);
    --tint: 90 58 18;
}

/* ---------- Base ---------- */
* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "kern" 1;
}

h1,
h2,
h3,
h4 {
    font-family: var(--font);
    font-stretch: 112%;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--ink);
}

h1 { font-size: 1.6rem; }
h2 { font-size: 1.12rem; }
h3 { font-size: 1rem; }

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    color: var(--brand-2);
}

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

::selection {
    background: var(--brand-soft);
    color: var(--brand-2);
}

/* ---------- Barra superior ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.2rem;
    padding: 0.7rem 1.5rem;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(1.4) blur(10px);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--brand-2);
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.brand-logo {
    width: auto;
    max-width: 128px;
    height: 30px;
    object-fit: contain;
}

.brand {
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
    padding-left: 0.75rem;
    border-left: 1px solid var(--line);
    font-stretch: 118%;
    font-size: 1.02rem;
    font-weight: 750;
    letter-spacing: -0.01em;
    color: var(--brand-2);
    white-space: nowrap;
}

.brand-abbr {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand-2);
    font-stretch: 100%;
    font-size: 0.78rem;
    font-weight: 650;
    letter-spacing: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.brand-sub {
    font-size: 0.72rem;
    color: var(--muted);
    letter-spacing: 0.01em;
}

.brand-funder-logo {
    height: 26px;
    width: auto;
    max-width: 96px;
    object-fit: contain;
    padding-left: 0.75rem;
    border-left: 1px solid var(--line);
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.15rem;
}

.main-nav a {
    position: relative;
    padding: 0.45rem 0.7rem;
    border-radius: var(--r-sm);
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 600;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.main-nav a:hover {
    color: var(--ink);
    background: var(--surface-2);
}

.main-nav a.active {
    color: var(--brand-2);
    background: var(--brand-soft);
}

/* Com o item "Simulador" o menu fica com 9 links: aperta um pouco para caber
   numa linha em telas comuns de notebook. */
@media (max-width: 1500px) {
    .main-nav {
        gap: 0;
    }

    .main-nav a {
        padding: 0.45rem 0.5rem;
        font-size: 0.89rem;
    }
}

.userbox {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 0.95rem;
}

.user-menu {
    position: relative;
}

.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
    border: 0;
    background: var(--brand-2);
    color: #fff;
    font-family: var(--font);
    font-stretch: 112%;
    font-size: 0.86rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 0 0 2px var(--card), 0 0 0 3px var(--line-strong);
    transition: box-shadow 0.15s ease;
}

.user-avatar:hover {
    box-shadow: 0 0 0 2px var(--card), 0 0 0 3px var(--brand);
}

.user-avatar:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--card), 0 0 0 5px var(--ring);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 0.6rem);
    right: 0;
    min-width: 256px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
    padding: 0.45rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transform-origin: top right;
    transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
    z-index: 40;
}

.user-menu.is-open .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-head {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.65rem 0.6rem 0.8rem;
    border-bottom: 1px solid var(--line);
}

.user-dropdown-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--brand-2);
    color: #fff;
    font-stretch: 112%;
    font-size: 0.95rem;
    font-weight: 700;
}

.user-dropdown-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.user-dropdown-name {
    font-size: 0.95rem;
    color: var(--ink);
    line-height: 1.2;
    word-break: break-word;
}

.user-dropdown-line {
    font-size: 0.82rem;
    color: var(--muted);
    word-break: break-word;
}

.user-dropdown-role {
    display: inline-flex;
    align-self: flex-start;
    margin-top: 0.25rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand-2);
    font-size: 0.74rem;
    font-weight: 650;
}

.user-dropdown-role.is-admin {
    background: #fcebd9;
    color: #8a4b12;
}

.user-dropdown-themes {
    margin-top: 0.45rem;
    padding: 0.6rem 0.6rem 0.7rem;
    border-radius: var(--r-md);
    background: var(--surface-2);
}

.user-dropdown-themes-top {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.6rem;
}

.user-dropdown-themes-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    color: var(--muted);
}

.user-dropdown-themes-label {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 600;
}

.user-dropdown-theme-name {
    margin-left: auto;
    color: var(--brand-2);
    font-size: 0.82rem;
    font-weight: 650;
}

.theme-swatches {
    display: flex;
    justify-content: space-between;
    gap: 0.45rem;
}

.user-dropdown-themes .theme-swatches button.theme-swatch {
    position: relative;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
    border: 2px solid var(--card);
    background: linear-gradient(135deg, var(--sw1) 0 50%, var(--sw2) 50% 100%);
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 0 0 1px rgb(0 0 0 / 0.08);
    transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.user-dropdown-themes .theme-swatches button.theme-swatch:hover {
    transform: scale(1.08);
    box-shadow: 0 0 0 1px rgb(0 0 0 / 0.12);
}

.user-dropdown-themes .theme-swatches button.theme-swatch.is-active {
    box-shadow: 0 0 0 2px var(--ink);
}

.user-dropdown-themes .theme-swatches button.theme-swatch.is-active::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 10px;
    margin: -7px 0 0 -3px;
    border: solid #ffffff;
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg);
}

.user-dropdown-link,
.user-dropdown-logout {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    margin-top: 0.25rem;
    padding: 0.6rem 0.65rem;
    border-radius: var(--r-sm);
    color: var(--ink);
    font-size: 0.9rem;
    font-weight: 550;
    transition: background-color 0.14s ease, color 0.14s ease;
}

.user-dropdown-link svg,
.user-dropdown-logout svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--muted);
}

.user-dropdown-link:hover {
    background: var(--brand-soft);
    color: var(--brand-2);
}

.user-dropdown-logout:hover {
    background: var(--error);
    color: var(--error-ink);
}

.user-dropdown-link:hover svg,
.user-dropdown-logout:hover svg {
    color: currentColor;
}

/* ---------- Layout ---------- */
.container {
    max-width: 2200px;
    margin: 0 auto;
    padding: 1.6rem 1.5rem 3rem;
}

.page-head {
    margin: 0.3rem 0 1.3rem;
}

.page-head h1 {
    margin: 0;
    font-size: clamp(1.45rem, 1.1rem + 1vw, 1.9rem);
    font-stretch: 118%;
    letter-spacing: -0.02em;
    color: var(--brand-2);
}

.page-head p {
    margin: 0.35rem 0 0;
    max-width: 72ch;
    color: var(--muted);
}

.card {
    display: block;
    text-align: left;
    padding: 1.35rem 1.4rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
}

.lift {
    animation: none;
}

.card h1,
.card h2,
.card h3 {
    margin-top: 0.1rem;
    margin-bottom: 0.9rem;
}

.card > h2:first-child,
.card > h3:first-child {
    margin-top: 0;
}

.section-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.9rem;
}

.section-title-row h1,
.section-title-row h2,
.section-title-row h3 {
    margin: 0;
    text-align: left;
}

.section-title-row h1 {
    font-size: 1.35rem;
    color: var(--brand-2);
}

.section-title-row button {
    margin-left: auto;
}

.narrow {
    max-width: 440px;
    margin: 8vh auto;
}

.login-card {
    padding: 1.8rem;
}

.login-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.login-logo {
    width: auto;
    max-width: 220px;
    height: 56px;
    object-fit: contain;
}

.login-hint {
    background: var(--surface-2);
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-md);
    padding: 0.5rem 0.7rem;
}

.login-hint p {
    margin: 0.3rem 0;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(290px, 360px) 1fr;
    gap: 1.1rem;
    align-items: start;
}

.chart-card {
    min-height: 360px;
}

.menu-actions {
    display: grid;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

/* ---------- Botoes ---------- */
.menu-btn,
button,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    padding: 0.58rem 1rem;
    font-family: var(--font);
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.2;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.menu-btn,
button:not(.btn-secondary) {
    background: var(--brand);
    color: #fff;
    cursor: pointer;
}

.menu-btn:hover,
button:not(.btn-secondary):hover {
    background: var(--brand-2);
    color: #fff;
}

button:not(.btn-secondary):active,
.menu-btn:active {
    transform: translateY(1px);
}

button:focus-visible,
.menu-btn:focus-visible,
.btn-secondary:focus-visible,
.btn-primary:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--ring);
}

/* Botoes de acao rapida do dashboard: lista discreta, nao uma pilha de blocos coloridos */
.menu-actions .menu-btn {
    justify-content: space-between;
    background: var(--surface-2);
    color: var(--ink);
    border-color: var(--line);
    font-weight: 600;
}

.menu-actions .menu-btn::after {
    content: "";
    width: 7px;
    height: 7px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    transform: rotate(45deg);
    opacity: 0.45;
}

.menu-actions .menu-btn:hover {
    background: var(--brand-soft);
    border-color: var(--line-strong);
    color: var(--brand-2);
}

.btn-secondary {
    display: inline-flex;
    padding: 0.58rem 1rem;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--brand-2);
    background: var(--card);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    text-align: center;
    text-decoration: none;
}

.btn-secondary:hover {
    background: var(--brand-soft);
    border-color: var(--brand);
    color: var(--brand-2);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    background: var(--brand);
    color: #fff;
    border: 1px solid transparent;
    padding: 0.72rem 1.3rem;
    border-radius: var(--r-md);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 650;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary:hover {
    background: var(--brand-2);
    color: #fff;
}

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

/* ---------- Estatisticas (legado) ---------- */
.stats {
    display: grid;
    gap: 0.7rem;
}

.stat-box {
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 0.7rem;
    display: grid;
    gap: 0.2rem;
    background: var(--surface-2);
}

.stats strong {
    font-size: 1.55rem;
    color: var(--brand-2);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.stats span,
.muted,
.hint {
    color: var(--muted);
}

/* ---------- Formularios ---------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 0.9rem;
    margin-bottom: 1.1rem;
}

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

/* Formularios de criacao/edicao: campos uniformes em grade de 3 colunas iguais.
   Campos "full" ocupam a linha toda. */
.modal-form.enhanced {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.9rem 1rem;
    align-items: end;
}

.modal-form.enhanced label {
    grid-column: span 1;
}

.modal-form.enhanced .field-xs,
.modal-form.enhanced .field-sm,
.modal-form.enhanced .field-md,
.modal-form.enhanced .field-lg {
    grid-column: span 1;
}

.modal-form.enhanced .field-full {
    grid-column: 1 / -1;
}

.modal-form.enhanced label > input,
.modal-form.enhanced label > select,
.modal-form.enhanced label > textarea {
    width: 100%;
    box-sizing: border-box;
}

.modal-form.enhanced > button[type="submit"] {
    grid-column: 1 / -1;
    justify-self: start;
}

@media (max-width: 980px) {
    .modal-form.enhanced {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .modal-form.enhanced > button[type="submit"] {
        grid-column: 1 / -1;
    }
}

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

label {
    display: grid;
    gap: 0.35rem;
    font-size: 0.84rem;
    color: var(--muted);
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    padding: 0.55rem 0.65rem;
    background: var(--card);
    color: var(--ink);
    font-family: var(--font);
    font-size: 0.92rem;
    font-weight: 450;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
    resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
    border-color: var(--muted);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--ring);
}

input[readonly] {
    background: var(--surface-2);
    color: var(--muted);
    border-style: dashed;
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
    accent-color: var(--brand);
}

input[type="file"] {
    padding: 0.4rem;
    background: var(--surface-2);
    border-style: dashed;
    cursor: pointer;
}

input[type="file"]::file-selector-button {
    margin-right: 0.7rem;
    padding: 0.38rem 0.75rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--card);
    color: var(--brand-2);
    font-family: var(--font);
    font-weight: 600;
    cursor: pointer;
}

::placeholder {
    color: var(--muted);
    opacity: 0.7;
}

/* ---------- Tabelas ---------- */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--card);
}

/* Tabelas de dados ocupam a altura da tela (menos a barra superior fixa): ao
   rolar a pagina ate a tabela, ela preenche a janela e o cabecalho fica fixo. */
.table-wrap-compact {
    --table-top-offset: 150px;
    max-height: max(320px, calc(100vh - var(--table-top-offset)));
    max-height: max(320px, calc(100dvh - var(--table-top-offset)));
    overflow: auto;
}

/* Antes encolhia a caixa ate a largura do conteudo; agora as tabelas de dados
   ocupam a largura toda do card (as colunas se espalham em telas largas). */
.table-wrap-fit {
    width: 100%;
    max-width: 100%;
}

/* Largura do conteudo, mas nunca menor que a caixa: tabelas com poucas colunas
   se espalham pela largura disponivel em vez de ficarem encostadas a esquerda. */
.table-wrap-compact table,
.table-wrap > table {
    width: max-content;
    min-width: 100%;
}

/* Ordenacao: cabecalhos clicaveis (exceto colunas de arquivos/imagens/acoes). */
th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable:hover {
    color: var(--brand);
}

th.sortable .sort-arrow {
    font-size: 0.8em;
    opacity: 0.85;
    white-space: nowrap;
}

/* Reordenacao de colunas por arrastar (salvo no navegador). */
th.col-draggable {
    cursor: grab;
    user-select: none;
}

th.col-draggable:active {
    cursor: grabbing;
}

th.col-dragging {
    opacity: 0.45;
}

th.col-drop-target {
    box-shadow: inset 3px 0 0 0 var(--brand);
}

table {
    width: max-content;
    border-collapse: separate;
    border-spacing: 0;
    min-width: max-content;
    table-layout: auto;
    text-align: center;
}

th,
td {
    border-bottom: 1px solid var(--line);
    text-align: center;
    vertical-align: middle;
    padding: 0.62rem;
    white-space: nowrap;
    font-size: 0.86rem;
}

td {
    font-variant-numeric: tabular-nums;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-2);
    color: var(--brand-2);
    font-size: 0.78rem;
    font-weight: 650;
    letter-spacing: 0.01em;
    border-bottom: 1px solid var(--line-strong);
}

tbody tr:nth-child(even) {
    background: var(--surface-2);
}

tbody tr:hover {
    background: var(--brand-soft);
}

tbody tr:last-child td {
    border-bottom: 0;
}

.table-wrap-compact th,
.table-wrap-compact td {
    padding: clamp(0.42rem, 0.3vw + 0.28rem, 0.66rem) clamp(0.4rem, 0.35vw + 0.28rem, 0.7rem);
    font-size: clamp(0.74rem, 0.22vw + 0.68rem, 0.9rem);
}

.table-wrap-compact th {
    font-size: clamp(0.7rem, 0.2vw + 0.64rem, 0.8rem);
}

.table-wrap-compact::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.table-wrap-compact::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: 999px;
    border: 2px solid var(--card);
}

.table-wrap-compact::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
}

.table-wrap-compact::-webkit-scrollbar-track {
    background: var(--card);
}

/* Colunas fixas a direita (status e acoes) */
.actions-col {
    position: sticky;
    right: 0;
    z-index: 2;
    min-width: var(--actions-col-width);
    width: var(--actions-col-width);
    max-width: var(--actions-col-width);
    background: var(--card);
    border-left: 0;
    box-shadow: inset 1px 0 0 var(--line);
}

th.actions-col,
td.actions-col {
    padding-left: 0.3rem;
    padding-right: 0.3rem;
}

.actions-col .action-group {
    flex-wrap: nowrap;
    justify-content: center;
}

th.actions-col {
    z-index: 3;
    background: var(--surface-2);
}

.actions-cell {
    background: var(--card);
}

tbody tr:nth-child(even) .actions-col,
tbody tr:nth-child(even) .status-col {
    background: var(--surface-2);
}

tbody tr:hover .actions-col,
tbody tr:hover .status-col {
    background: var(--brand-soft);
}

.status-col {
    position: sticky;
    right: calc(var(--actions-col-width) - 1px);
    z-index: 2;
    min-width: 112px;
    width: 112px;
    max-width: 112px;
    background: var(--card);
}

td.status-col,
th.status-col {
    padding-left: 0.35rem;
    padding-right: 0.35rem;
}

th.status-col {
    z-index: 3;
    background: var(--surface-2);
}

.action-group {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.action-group form {
    margin: 0;
}

.action-btn {
    padding: 0.34rem 0.55rem;
    border-radius: var(--r-sm);
    font-size: 0.76rem;
    line-height: 1.2;
}

.icon-btn {
    width: 2rem;
    height: 2rem;
    padding: 0;
    border-radius: var(--r-sm);
}

/* Botoes de icone nas tabelas: discretos ate o hover */
.icon-btn.btn-secondary,
.action-group .btn-secondary.icon-btn {
    background: transparent;
    border-color: var(--line);
    color: var(--brand-2);
}

.icon-btn.btn-secondary:hover {
    background: var(--brand-soft);
    border-color: var(--brand);
}

/* Publicar/despublicar e demais botoes de icone sem classe propria: mesmo peso
   visual dos vizinhos (editar/excluir), em vez de um bloco solido. */
.action-group button.icon-btn:not(.danger):not(.btn-secondary) {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--brand);
}

.action-group button.icon-btn:not(.danger):not(.btn-secondary):hover {
    background: var(--brand-soft);
    border-color: var(--brand);
    color: var(--brand-2);
}

/* Card dentro de card (ex.: filtros dentro da pagina): sem sombra dupla */
.card .card {
    box-shadow: none;
    background: var(--surface-2);
}

.card .card .chip-filter-row {
    background: var(--card);
}

.table-filter-card > .section-title-row,
.samples-filter-card > .section-title-row {
    margin-bottom: 0;
}

.table-filter-card,
.samples-filter-card {
    padding-top: 0.85rem !important;
    padding-bottom: 0.85rem !important;
}

.icon-svg {
    width: 1rem;
    height: 1rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.action-btn.danger,
button.danger,
.btn-danger {
    background: var(--card);
    color: var(--danger);
    border: 1px solid #ebc4c1;
}

.action-btn.danger:hover,
button.danger:hover,
.btn-danger:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border-radius: 999px;
    padding: 0.18rem 0.55rem;
    font-size: 0.74rem;
    font-weight: 650;
    white-space: nowrap;
}

.status-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-badge.published {
    background: var(--brand-soft);
    color: var(--brand-2);
    border: 1px solid var(--line);
}

.status-badge.unpublished {
    background: #f1f2f3;
    color: #5b6461;
    border: 1px solid #dadedd;
}

/* ---------- Filtros reutilizaveis ---------- */
.table-filter-card {
    width: 100%;
}

.table-filters-content {
    margin-top: 0.6rem;
}

.table-filters-content[hidden] {
    display: none !important;
}

.filters-toggle-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.filters-toggle-btn .filter-toggle-icon {
    width: 10px;
    height: 10px;
    display: inline-block;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-135deg) translate(-2px, -2px);
    transition: transform 0.2s ease;
}

.filters-toggle-btn.is-collapsed .filter-toggle-icon {
    transform: rotate(45deg) translate(-2px, -2px);
}

.table-filter-form {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    align-items: stretch;
}

.table-filters-grid {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    gap: 0.6rem;
    align-items: flex-start;
}

.table-filter-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.55rem;
}

@media (max-width: 700px) {
    .chip-filter-row {
        flex-basis: 100%;
        max-width: 100%;
    }
}

/* Chips de filtro (compartilhados). */
.chip-filter-row {
    display: grid;
    grid-template-rows: auto auto;
    gap: 0.45rem;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface-2);
    flex: 0 1 auto;
    min-width: 180px;
    max-width: 480px;
}

.chip-filter-title {
    font-size: 0.82rem;
    font-weight: 650;
    color: var(--ink);
}

.chip-filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    align-content: start;
}

.chip-filter {
    position: relative;
    display: inline-block;
}

.chip-filter input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.chip-filter span {
    display: inline-block;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    max-width: 220px;
    text-align: center;
    padding: 0.18rem 0.65rem;
    font-size: 0.76rem;
    font-weight: 550;
    color: var(--ink);
    background: var(--card);
    cursor: pointer;
    transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chip-filter span:hover {
    border-color: var(--brand);
}

.chip-filter input:checked + span {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.chip-filter input:focus-visible + span {
    box-shadow: 0 0 0 3px var(--ring);
}

/* ---------- Mensagens ---------- */
.messages {
    display: grid;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.msg {
    position: relative;
    padding: 0.65rem 0.85rem 0.65rem 1.05rem;
    border-radius: var(--r-md);
    border: 1px solid transparent;
    font-weight: 500;
}

.msg::before {
    content: "";
    position: absolute;
    left: 0.4rem;
    top: 0.55rem;
    bottom: 0.55rem;
    width: 3px;
    border-radius: 3px;
    background: currentColor;
    opacity: 0.6;
}

.msg.success {
    background: var(--ok);
    color: var(--ok-ink);
    border-color: var(--ok-line);
}

.msg.error {
    background: var(--error);
    color: var(--error-ink);
    border-color: var(--error-line);
}

/* ---------- Modais ---------- */
.modal {
    width: min(980px, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    background: var(--card);
    color: var(--ink);
}

.modal[open] {
    animation: modal-in 0.18s ease-out;
}

.modal::backdrop {
    background: rgb(var(--tint) / 0.42);
    backdrop-filter: blur(3px);
}

.modal-xl {
    width: min(1180px, calc(100vw - 2rem));
}

.image-modal {
    width: min(860px, calc(100vw - 2rem));
    max-width: calc(100vw - 2rem);
}

.image-preview-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface-2);
    padding: 0.8rem;
    min-height: 220px;
}

.image-preview-wrap img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: var(--r-sm);
}

.image-view-btn {
    padding: 0.36rem 0.6rem;
    border-radius: var(--r-sm);
    font-size: 0.76rem;
}

.image-carousel-btn {
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: var(--card);
    color: var(--brand-2);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.image-carousel-btn:hover {
    background: var(--brand-soft);
}

.image-carousel-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.image-counter {
    margin: 0.6rem 0 0;
    text-align: center;
    font-size: 0.86rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    margin-bottom: 1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--line);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.15rem;
    color: var(--brand-2);
}

.modal-form {
    margin-bottom: 0;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: translateY(6px) scale(0.99);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

/* Mantido para templates que ainda referenciam a animacao */
@keyframes fade-up {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* ---------- Graficos ---------- */
.button-group {
    display: flex;
    gap: 0.7rem;
    justify-content: center;
    flex-wrap: wrap;
}

.graph-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.graph-toolbar h3 {
    margin: 0;
    color: var(--brand-2);
    font-weight: 700;
}

.experiments-filter-card {
    margin-bottom: 0.9rem;
    padding: 1rem 1.1rem;
    border-radius: var(--r-lg);
    background: var(--surface-2);
    border: 1px solid var(--line);
    box-shadow: none;
}

.experiments-filter-card h3 {
    margin: 0;
}

.experiments-filter-form {
    grid-template-columns: repeat(6, minmax(140px, 1fr));
    align-items: end;
    margin-bottom: 0;
}

.experiments-filter-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.graph-modal-sm {
    width: min(460px, calc(100vw - 2rem));
}

.graph-modal-lg {
    width: min(1080px, calc(100vw - 2rem));
}

.graph-form-grid {
    display: grid;
    gap: 0.8rem;
}

.graph-canvas-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 0.5rem;
    background: var(--surface-2);
}

.graph-canvas-wrap canvas {
    display: block;
    width: 100%;
    height: auto;
    background: #ffffff;
    border-radius: var(--r-sm);
}

.graph-empty {
    margin: 0.8rem 0 0;
}

.graph-open-btn,
button.graph-open-btn {
    background: var(--card);
    color: var(--brand-2);
    border: 1px solid var(--line-strong);
    min-width: 128px;
}

.graph-open-btn:hover,
button.graph-open-btn:hover {
    background: var(--brand-soft);
    color: var(--brand-2);
    border-color: var(--brand);
}

.table-wrap .graph-open-btn,
.table-wrap button.graph-open-btn {
    min-width: 0;
    padding: 0.36rem 0.7rem;
    font-size: 0.8rem;
    border-radius: var(--r-sm);
}

.graph-soft-btn,
button.graph-soft-btn {
    background: var(--card);
    color: var(--brand-2);
    border: 1px solid var(--line-strong);
}

.graph-soft-btn:hover,
button.graph-soft-btn:hover {
    background: var(--brand-soft);
    color: var(--brand-2);
    border-color: var(--brand);
}

.graph-submit-btn,
button.graph-submit-btn {
    background: var(--brand);
    border-color: var(--brand);
    color: #ffffff;
    font-weight: 650;
}

.graph-submit-btn:hover,
button.graph-submit-btn:hover {
    background: var(--brand-2);
    color: #ffffff;
}

/* ---------- Configuracoes (admin) ---------- */
.admin-settings-grid {
    display: grid;
    grid-template-columns: minmax(360px, 1fr) minmax(480px, 1.35fr);
    align-items: start;
    gap: 1rem;
}

.admin-user-form {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    align-items: end;
}

.admin-log-filters {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    align-items: end;
}

.admin-download-form {
    margin-bottom: 0.8rem;
}

.admin-table-wrap table {
    width: 100%;
    min-width: 640px;
}

.admin-table-wrap th,
.admin-table-wrap td {
    padding: 0.5rem 0.55rem;
    font-size: 0.84rem;
}

.admin-table-wrap th {
    font-size: 0.76rem;
}

.admin-table-wrap td:last-child {
    max-width: 300px;
}

.user-actions-group {
    justify-content: center;
    flex-wrap: nowrap;
}

.password-modal {
    width: min(520px, calc(100vw - 2rem));
}

.password-modal-form {
    gap: 0.75rem;
}

.password-user-hint {
    margin: 0;
    font-weight: 600;
}

.admin-user-form > button,
.admin-log-filters > button {
    min-width: 160px;
    justify-self: start;
}

/* ---------- Dashboard: totais ---------- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0;
    margin-bottom: 1.2rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.stat-card {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    column-gap: 0.85rem;
    align-items: center;
    padding: 1.05rem 1.2rem;
    color: var(--ink);
    border-left: 1px solid var(--line);
    transition: background-color 0.15s ease;
}

.stat-card:first-child {
    border-left: 0;
}

.stat-card:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.stat-card-icon {
    grid-row: 1 / span 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--r-md);
    background: var(--brand-soft);
    color: var(--brand-2);
    font-size: 1.1rem;
    line-height: 1;
}

.stat-card-icon svg {
    width: 20px;
    height: 20px;
}

.stat-card strong {
    font-size: 1.75rem;
    font-stretch: 118%;
    font-weight: 700;
    color: var(--brand-2);
    line-height: 1;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.stat-card span:last-child {
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 550;
}

/* ---------- Dashboard: graficos ---------- */
.dashboard-charts {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.dashboard-charts .card,
.dashboard-grid > .card {
    margin-bottom: 0 !important;
}

.charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.doughnut-wrap {
    position: relative;
    width: 100%;
    height: 300px;
    margin-top: 0.4rem;
}

.doughnut-wrap canvas {
    max-height: 300px;
}

/* ---------- Botao Exportar ---------- */
.export-open-btn,
button.export-open-btn {
    width: 100%;
    gap: 0.5rem;
    background: var(--brand);
}

.export-open-icon {
    display: inline-flex;
}

/* ---------- Modal Exportar para Excel ---------- */
.export-modal {
    width: min(620px, calc(100vw - 2rem));
    padding: 0;
    overflow: hidden;
}

.export-modal-header {
    margin: 0;
    padding: 1.1rem 1.25rem;
    background: var(--brand-2);
    color: #fff;
    align-items: flex-start;
    border-bottom: 0;
    position: relative;
}

.export-modal-header::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: var(--brand-2);
}

.export-modal-title {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.export-modal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: var(--r-md);
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

.export-modal-title h2 {
    margin: 0;
    color: #fff;
    font-size: 1.15rem;
}

.export-modal-sub {
    margin: 0.15rem 0 0;
    font-size: 0.86rem;
    color: rgba(255, 255, 255, 0.8);
}

.export-close-x,
button.export-close-x {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: 0;
    width: 32px;
    height: 32px;
    border-radius: var(--r-sm);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}

.export-close-x:hover,
button.export-close-x:hover {
    background: rgba(255, 255, 255, 0.26);
}

.export-form {
    padding: 1.1rem 1.25rem 1.25rem;
}

.export-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}

.export-selectall {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--brand-2);
    cursor: pointer;
    margin: 0;
}

.export-selectall input {
    width: 1.05rem;
    height: 1.05rem;
    accent-color: var(--brand);
    cursor: pointer;
}

.export-count {
    font-size: 0.82rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.export-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
}

.export-option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    background: var(--card);
    cursor: pointer;
    transition: border-color 0.14s ease, background-color 0.14s ease;
    margin: 0;
}

.export-option:hover {
    border-color: var(--brand);
}

.export-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.export-option-check {
    flex-shrink: 0;
    width: 1.15rem;
    height: 1.15rem;
    border: 2px solid var(--line-strong);
    border-radius: 5px;
    background: var(--card);
    transition: background-color 0.14s ease, border-color 0.14s ease;
    position: relative;
}

.export-option input:checked ~ .export-option-check {
    background: var(--brand);
    border-color: var(--brand);
}

.export-option input:checked ~ .export-option-check::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 0;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.export-option input:focus-visible ~ .export-option-check {
    box-shadow: 0 0 0 3px var(--ring);
}

.export-option input:checked ~ .export-option-body .export-option-name {
    color: var(--brand-2);
}

.export-option:has(input:checked) {
    border-color: var(--brand);
    background: var(--brand-soft);
}

.export-option-body {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.export-option-name {
    font-weight: 650;
    font-size: 0.92rem;
    color: var(--ink);
}

.export-option-desc {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.3;
    font-weight: 450;
}

.export-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    margin-top: 1rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--line);
}

.export-submit {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.6rem 1.2rem;
    font-weight: 650;
}

.export-submit:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

@media (max-width: 560px) {
    .export-options {
        grid-template-columns: 1fr;
    }
}

/* ---------- Pagina Tomografia ---------- */
.tomo-form {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    max-width: 640px;
}

.tomo-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.tomo-field label {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--ink);
}

.tomo-field input[type="text"],
.tomo-field select,
.tomo-field input[type="file"] {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--card);
    font: inherit;
    color: var(--ink);
}

.tomo-field select {
    padding: 0.3rem;
}

.tomo-field select option {
    padding: 0.35rem 0.5rem;
}

.tomo-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.9rem;
    margin-top: 0.4rem;
}

.tomo-card {
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 0.85rem;
    background: var(--surface-2);
}

.tomo-card-head {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    margin-bottom: 0.6rem;
}

.tomo-card-head strong {
    color: var(--brand-2);
}

.tomo-card-head span {
    font-size: 0.82rem;
    color: var(--muted);
}

.tomo-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tomo-thumb {
    position: relative;
    width: 84px;
    height: 84px;
    border-radius: var(--r-md);
    overflow: hidden;
    border: 1px solid var(--line);
}

.tomo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tomo-thumb-del,
button.tomo-thumb-del {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 22px;
    height: 22px;
    line-height: 1;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(140, 39, 33, 0.9);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tomo-thumb-del:hover,
button.tomo-thumb-del:hover {
    background: var(--danger-2);
}

/* ---------- Componentes usados por paginas especificas ---------- */
.fluid-builder-card {
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 0.8rem;
    background: var(--surface-2);
}

.fluid-builder-title {
    margin: 0 0 0.55rem 0;
    font-size: 0.92rem;
    font-weight: 650;
    color: var(--ink);
}

.fluid-code-preview {
    margin: 0;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--card);
    color: var(--brand-2);
    font-family: var(--font);
    font-stretch: 112%;
    font-weight: 700;
    letter-spacing: 0.02em;
    word-break: break-all;
}

/* ---------- Responsivo ---------- */
/* O grafico de barras tem largura minima inline: as colunas usam minmax(0, ...)
   para ele rolar dentro do proprio card em vez de esticar a pagina. */
.dashboard-charts,
.chart-card,
.charts-row > .card {
    min-width: 0;
}

@media (min-width: 900px) {
    .dashboard-grid {
        grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
        gap: 1.2rem;
    }
}

@media (max-width: 1280px) {
    .topbar {
        flex-wrap: wrap;
        row-gap: 0.5rem;
    }

    .main-nav {
        order: 3;
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        margin: 0 -0.3rem;
        scrollbar-width: none;
    }

    .main-nav::-webkit-scrollbar {
        display: none;
    }

    .main-nav a {
        white-space: nowrap;
    }

    /* menu vai para uma segunda linha: a barra superior fica mais alta */
    .table-wrap-compact {
        --table-top-offset: 190px;
    }
}

@media (max-width: 980px) {
    :root {
        --actions-col-width: 128px;
    }

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

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

    .form-grid {
        grid-template-columns: repeat(2, minmax(140px, 1fr));
    }

    .status-col {
        min-width: 104px;
        width: 104px;
        max-width: 104px;
        right: var(--actions-col-width);
    }

    .admin-settings-grid {
        grid-template-columns: 1fr;
    }

    .experiments-filter-form {
        grid-template-columns: repeat(3, minmax(150px, 1fr));
    }

    .admin-table-wrap table {
        min-width: 560px;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-card {
        border-left: 0;
        border-top: 1px solid var(--line);
    }

    .stat-card:nth-child(-n + 2) {
        border-top: 0;
    }

    .stat-card:nth-child(even) {
        border-left: 1px solid var(--line);
    }
}

@media (max-width: 640px) {
    :root {
        --actions-col-width: 124px;
    }

    .topbar {
        padding: 0.6rem 1rem calc(0.6rem + 4px);
    }

    .brand-funder-logo {
        display: none;
    }

    .container {
        padding: 1rem 1rem 2.5rem;
    }

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

    .section-title-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .table-wrap-compact th,
    .table-wrap-compact td {
        font-size: 0.74rem;
        padding: 0.4rem 0.34rem;
    }

    .status-col {
        min-width: 96px;
        width: 96px;
        max-width: 96px;
        right: var(--actions-col-width);
    }

    .experiments-filter-form,
    .admin-user-form,
    .admin-log-filters {
        grid-template-columns: 1fr;
    }
}

/* Celular */
@media (max-width: 480px) {
    body {
        font-size: 15px;
    }

    .container {
        padding: 0.75rem 0.75rem 2rem !important;
    }

    .card,
    .experiments-filter-card {
        padding: 0.9rem !important;
        border-radius: var(--r-md) !important;
    }

    .section-title-row h1,
    .section-title-row h3 {
        font-size: 1.1rem !important;
    }

    .section-title-row,
    .graph-toolbar {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.4rem !important;
    }

    .form-grid,
    .experiments-filter-form {
        grid-template-columns: 1fr !important;
        gap: 0.6rem !important;
    }

    input,
    select {
        font-size: 1rem !important;
        padding: 0.5rem 0.55rem !important;
    }

    /* No celular a tabela nao ocupa a tela toda, para o dedo ainda conseguir
       rolar a pagina por fora dela. */
    .table-wrap-compact,
    .table-wrap {
        max-height: 70vh !important;
        max-height: 70dvh !important;
    }

    th,
    td,
    .table-wrap-compact th,
    .table-wrap-compact td {
        padding: 0.32rem 0.25rem !important;
        font-size: 0.74rem !important;
    }

    .action-btn,
    .icon-btn {
        width: 1.7rem !important;
        height: 1.7rem !important;
        padding: 0 !important;
    }

    .icon-svg {
        width: 0.9rem !important;
        height: 0.9rem !important;
    }

    .modal,
    .modal-xl,
    .graph-modal-lg,
    .graph-modal-sm,
    .image-modal {
        width: 98vw !important;
        min-width: unset !important;
        max-width: 99vw !important;
        padding: 0.75rem !important;
        border-radius: var(--r-lg) !important;
    }

    .export-modal {
        padding: 0 !important;
    }

    .modal-header h2 {
        font-size: 1.05rem !important;
    }

    .experiments-filter-actions {
        flex-direction: column !important;
        gap: 0.3rem !important;
        align-items: stretch !important;
    }

    .graph-canvas-wrap {
        padding: 0.2rem !important;
        min-height: 120px !important;
    }

    .graph-canvas-wrap canvas,
    #graphCanvas,
    #graphCanvas2 {
        width: 100% !important;
        height: 180px !important;
        min-width: unset !important;
    }

    .image-preview-wrap img {
        max-height: 38vh !important;
    }

    .stats-row {
        grid-template-columns: 1fr;
    }

    .stat-card,
    .stat-card:nth-child(even) {
        border-left: 0;
        border-top: 1px solid var(--line);
    }

    .stat-card:first-child {
        border-top: 0;
    }

    .stat-card:nth-child(2) {
        border-top: 1px solid var(--line);
    }
}

/* ---------- Busca rapida em tabelas (injetada pelo base.html) ---------- */
tr[hidden] {
    display: none !important;
}

.table-search {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.9rem;
    margin: 0 0 0.7rem;
}

.table-search-input {
    width: min(100%, 320px);
    padding: 0.5rem 0.7rem 0.5rem 2rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%23536d65' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat 0.65rem center;
    color: var(--ink);
    font: inherit;
    font-size: 0.9rem;
}

.table-search-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--ring);
}

.table-search-count {
    color: var(--muted);
    font-size: 0.84rem;
    font-variant-numeric: tabular-nums;
}

.table-search.is-empty .table-search-count {
    color: var(--error-ink);
    font-weight: 600;
}

/* ---------- Painel superadmin: busca e papeis ---------- */
.access-select.is-none {
    color: var(--muted);
    background-color: var(--surface-2);
}

.access-select.is-saved {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--ring);
}

.access-select.is-failed {
    border-color: var(--danger);
}

/* ---------- Simulador PVbt ---------- */
.pvbt-layout {
    display: grid;
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
    margin-bottom: 1rem;
}

.pvbt-form {
    position: sticky;
    top: 5rem;
    display: grid;
    gap: 1rem;
}

.pvbt-group {
    display: grid;
    gap: 0.8rem;
    margin: 0;
    padding: 0.9rem 0 0;
    border: 0;
    border-top: 1px solid var(--line);
}

.pvbt-group legend {
    padding: 0 0.4rem 0 0;
    color: var(--brand-2);
    font-stretch: 112%;
    font-weight: 700;
    font-size: 0.95rem;
}

.pvbt-field {
    display: grid;
    gap: 0.35rem;
}

.pvbt-warnings[hidden] {
    display: none;
}

.pvbt-field > label,
.pvbt-label {
    display: block;
    margin: 0;
    color: var(--ink);
    font-size: 0.86rem;
    font-weight: 650;
}

.pvbt-unit {
    color: var(--muted);
    font-weight: 500;
}

.pvbt-field .hint {
    margin: 0;
    font-size: 0.8rem;
}

.pvbt-results {
    display: grid;
    gap: 1rem;
    min-width: 0;
}

.pvbt-stats {
    grid-template-columns: repeat(3, 1fr);
    margin-bottom: 0;
}

#reliabilityStats {
    grid-template-columns: repeat(4, 1fr);
    margin-bottom: 1rem;
}

.pvbt-stats .stat-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
}

.pvbt-stats .stat-card:hover {
    background: transparent;
}

.pvbt-range {
    color: var(--muted);
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}

.pvbt-note {
    margin: 0;
    font-size: 0.86rem;
}

.pvbt-warnings {
    display: grid;
    gap: 0.4rem;
    margin: 0;
    padding: 0.75rem 1rem 0.75rem 2rem;
    border: 1px solid #f0c99a;
    border-radius: var(--r-md);
    background: #fdf3e6;
    color: #7a4a12;
    font-size: 0.9rem;
    font-weight: 550;
}

.pvbt-chart-card .section-title-row {
    margin-bottom: 0.6rem;
}

.pvbt-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.pvbt-chart-wrap {
    position: relative;
    height: clamp(300px, 46vh, 460px);
    padding: 0.6rem;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface-2);
}

.pvbt-chart-small {
    height: 300px;
}

.pvbt-chart-card .hint {
    margin: 0.6rem 0 1rem;
    font-size: 0.84rem;
}

.pvbt-table table td,
.pvbt-table table th {
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.pvbt-section {
    margin-bottom: 1rem;
}

.pvbt-prose {
    max-width: 80ch;
    margin: 0 0 1rem;
}

.pvbt-influence {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: 1.4rem;
    align-items: start;
    margin-bottom: 1rem;
}

.pvbt-influence h3 {
    margin: 0 0 0.3rem;
}

.pvbt-influence .hint {
    margin: 0 0 0.7rem;
    font-size: 0.84rem;
}

.pvbt-effects {
    display: grid;
    gap: 0.55rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.pvbt-effects li {
    display: grid;
    gap: 0.1rem;
    padding: 0.55rem 0.7rem;
    border-left: 3px solid var(--brand);
    background: var(--surface-2);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    font-size: 0.86rem;
    color: var(--muted);
}

.pvbt-effects strong {
    color: var(--ink);
}

.pvbt-floor td {
    color: var(--muted);
    font-style: italic;
}

.pvbt-details {
    margin-top: 1rem;
}

.pvbt-details summary {
    cursor: pointer;
    color: var(--brand);
    font-weight: 650;
}

.pvbt-details .hint {
    font-size: 0.84rem;
}

.pvbt-train-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.8rem;
}

.pvbt-log {
    max-height: 260px;
    overflow: auto;
    padding: 0.8rem;
    border-radius: var(--r-md);
    background: var(--surface-2);
    font-size: 0.78rem;
    white-space: pre-wrap;
}

.pvbt-empty h2 {
    margin-top: 0;
}

@media (max-width: 1000px) {
    .pvbt-layout,
    .pvbt-influence {
        grid-template-columns: 1fr;
    }

    .pvbt-form {
        position: static;
    }

    #reliabilityStats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .pvbt-stats {
        grid-template-columns: 1fr;
    }
}

/* ---------- Sistema de Dano a Formacao (extensao.py do sistema2) ---------- */
.dano-lead {
    max-width: 90ch;
    margin: -0.3rem 0 1rem;
    font-size: 0.92rem;
}

.dano-hint {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 500;
}

.dano-warn {
    color: var(--danger);
    font-weight: 650;
}

.dano-pre {
    max-width: 340px;
    white-space: pre-line;
    text-align: left;
    font-size: 0.85em;
}

.dano-actions,
.dano-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.dano-quick {
    margin: -0.4rem 0 1rem;
}

.dano-fieldset {
    margin: 0;
    padding: 0.8rem 0.9rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface-2);
}

.dano-fieldset legend {
    padding: 0 0.4rem;
    color: var(--brand-2);
    font-weight: 700;
    font-stretch: 110%;
}

/* Grade dos formularios do Dano: todas as caixas de uma fileira com a mesma
   altura e alinhadas no topo. O nome e a unidade do campo ficam numa linha so
   (.dano-lbl); dicas e arquivos atuais vem embaixo da caixa. Os seletores comecam
   com "form" para vencer ".modal-form.enhanced label" (que forca span 1). */
.dano-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 0.85rem 0.9rem;
    align-items: start;
}

form .dano-grid > label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
    margin: 0;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--ink);
    grid-column: auto;
}

form .dano-grid > label[hidden] {
    display: none;
}

.dano-lbl {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.dano-lbl small {
    margin-left: 0.2rem;
    color: var(--muted);
    font-size: 0.9em;
    font-weight: 500;
}

form .dano-grid > label > input:not([type="checkbox"]):not([type="file"]),
form .dano-grid > label > select {
    width: 100%;
    height: 2.6rem;
    margin: 0;
    box-sizing: border-box;
}

form .dano-grid > label > textarea {
    width: 100%;
    min-height: 5rem;
    box-sizing: border-box;
}

form .dano-grid > label > .dano-hint {
    font-weight: 500;
    line-height: 1.35;
}

form .dano-grid > label.dano-span2 {
    grid-column: span 2;
}

form .dano-grid > label.dano-span-all {
    grid-column: 1 / -1;
}

.dano-grid-top {
    padding: 0 0.9rem;
}

.dano-calc {
    background: var(--card) !important;
    color: var(--brand-2) !important;
    font-weight: 700;
    border-style: dashed !important;
}

.dano-inline {
    display: inline-flex !important;
    align-items: center;
    gap: 0.3rem;
}

.dano-inline input {
    width: auto;
}

.dano-edit-card {
    max-width: 1200px;
}

.dano-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.6rem;
    margin: 0 0 1rem;
}

.dano-summary > div {
    display: grid;
    gap: 0.15rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface-2);
}

.dano-summary strong {
    color: var(--brand-2);
    font-size: 1.35rem;
    font-stretch: 115%;
    font-variant-numeric: tabular-nums;
}

.dano-summary span {
    color: var(--muted);
    font-size: 0.82rem;
}

/* Cabecalho agrupado (Reologia | Propriedades | Retorta...): cada grupo e uma
   faixa colorida (tons alternados) e uma linha vertical marca o inicio de cada
   grupo ao longo da tabela inteira (classe .gs nas celulas). */
.dano-group-row th {
    position: static;
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
    background: var(--card);
    border-bottom: 0;
}

.dano-group-row th.dano-group {
    background: var(--brand-soft);
    border-bottom: 3px solid var(--brand);
    color: var(--brand-2);
    font-size: 0.82rem;
    font-weight: 750;
    letter-spacing: 0.01em;
}

.dano-group-row th.dano-group-alt {
    background: var(--surface-2);
    border-bottom-color: var(--brand-2);
}

table th.gs,
table td.gs {
    border-left: 2px solid var(--line-strong);
}

.dano-group-row th.gs {
    border-left: 2px solid var(--card);
}

.th-unit {
    display: block;
    font-size: 0.8em;
    font-weight: 400;
    opacity: 0.8;
}

.rp-badge {
    display: inline-block;
    min-width: 3.6rem;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
}

.rp-bom { background: #dff2e6; color: #17573a; }
.rp-medio { background: #fcefd6; color: #7a4a12; }
.rp-ruim { background: #fde3e1; color: #8a1f1b; }

.dano-legend {
    margin: 0.7rem 0 0;
    font-size: 0.82rem;
}

.dano-stats {
    grid-template-columns: repeat(6, 1fr);
}

.dano-stats .stat-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
}

.dano-charts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.dano-charts .card h2 {
    margin: 0 0 0.2rem;
    font-size: 1.05rem;
}

.dano-charts .hint {
    margin: 0 0 0.6rem;
    font-size: 0.84rem;
}

.dano-chart {
    position: relative;
    height: 300px;
}

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

.dano-empty h2 {
    margin-top: 0;
}

/* Formulacao do fluido: linhas componente / quantidade / unidade */
.dano-comp-head,
.dano-comp-row {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 0.9fr) 2.2rem;
    gap: 0.45rem;
    align-items: center;
}

.dano-comp-head {
    margin-bottom: 0.3rem;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 650;
}

.dano-comp-row + .dano-comp-row {
    margin-top: 0.4rem;
}

.dano-comp-row input {
    min-width: 0;
}

.dano-comp-add {
    margin-top: 0.7rem;
}

.dano-comp-copy {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.7rem;
    margin-bottom: 0.9rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px dashed var(--line-strong);
    font-size: 0.86rem;
    font-weight: 600;
}

.dano-comp-copy select {
    width: auto;
    min-width: 200px;
}

.dano-comp-list {
    display: grid;
    gap: 0.1rem;
    min-width: 230px;
    margin: 0;
    padding: 0;
    list-style: none;
    text-align: left;
    font-size: 0.84em;
}

.dano-comp-list li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.08rem 0;
    border-bottom: 1px dotted var(--line);
}

.dano-comp-list li:last-child {
    border-bottom: 0;
}

.dano-comp-list li span:last-child {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--brand-2);
    font-weight: 600;
}

.dano-sample-link {
    color: var(--brand);
    font-weight: 700;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
    cursor: pointer;
}

.dano-sample-link:hover,
.dano-sample-link:focus-visible {
    color: var(--brand-2);
    text-decoration-style: solid;
}

.dano-sample-info {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.45rem 1.2rem;
    margin: 0 0 1rem;
}

.dano-sample-info dt {
    color: var(--muted);
    font-size: 0.88rem;
}

.dano-sample-info dd {
    margin: 0;
    color: var(--ink);
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.dano-sample-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.dano-sample-gallery img {
    width: 120px;
    height: 90px;
    object-fit: cover;
    border-radius: var(--r-sm);
    border: 1px solid var(--line);
}

@media (max-width: 1100px) {
    .dano-stats {
        grid-template-columns: repeat(3, 1fr);
    }

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

@media (max-width: 640px) {
    .dano-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .dano-span2 {
        grid-column: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* =====================================================================
   Portal (gateway) — login, selecao de sistema e rodape institucional
   ===================================================================== */

/* ---------- Login ---------- */
body.is-auth .container {
    max-width: none;
    padding: 0 !important;
}

body.is-auth .messages {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 30;
    width: min(420px, calc(100vw - 2rem));
}

.auth {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(380px, 1fr);
    min-height: 100vh;
}

.auth-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    background: #04453a;
    color: #fff;
}

.auth-panel-text {
    padding: clamp(2rem, 6vw, 5rem) clamp(1.5rem, 5vw, 4.5rem) 1rem;
    max-width: 40rem;
}

.auth-kicker {
    margin: 0 0 1.2rem;
    color: #f6b57a;
    font-size: 0.95rem;
    font-weight: 600;
}

.auth-title {
    margin: 0;
    color: #fff;
    font-size: clamp(2.8rem, 2rem + 4vw, 5.6rem);
    font-stretch: 125%;
    font-weight: 800;
    line-height: 0.95;
    letter-spacing: -0.035em;
}

.auth-lead {
    margin: 1.4rem 0 0;
    max-width: 34ch;
    color: rgba(255, 255, 255, 0.78);
    font-size: 1.08rem;
    line-height: 1.55;
}

/* Template antigo (antes de reiniciar o servidor) ainda inclui a ilustracao */
.auth-panel .strata {
    display: none;
}

/* Sem a ilustracao, o texto fica centralizado na vertical */
.auth-panel {
    justify-content: center;
}

.auth-form-side {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.5rem;
    background: var(--card);
}

.auth-form-wrap {
    width: 100%;
    max-width: 360px;
}

.auth-logo {
    display: block;
    height: 44px;
    width: auto;
    max-width: 100%;
    margin-bottom: 2.2rem;
}

.auth-form-wrap h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--brand-2);
}

.auth-form-wrap > .muted {
    margin: 0.35rem 0 1.4rem;
}

.auth-form {
    gap: 1rem;
}

.auth-form button {
    margin-top: 0.3rem;
    padding: 0.75rem 1rem;
    font-size: 0.98rem;
}

/* ---------- Vinculo institucional (LabRES / DPET / UFRN) ---------- */
.affiliation {
    margin-top: 2.4rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--line);
}

.affiliation-logos {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    margin-bottom: 0.7rem;
}

.affiliation-logo {
    height: 34px;
    width: auto;
    max-width: 150px;
    object-fit: contain;
}

.affiliation-logo-dpet {
    height: 40px;
}

.affiliation-wordmark {
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 0 0.6rem;
    border: 1.5px solid var(--brand-2);
    border-radius: var(--r-sm);
    color: var(--brand-2);
    font-stretch: 125%;
    font-weight: 800;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
}

.affiliation p {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.5;
}

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

    .auth-panel-text {
        padding: 2rem 1.5rem 0.5rem;
    }

    .auth-title {
        font-size: 2.8rem;
    }

    .auth-lead {
        font-size: 1rem;
    }

    .auth-panel-text {
        padding-bottom: 2rem;
    }
}

/* ---------- Selecao de sistema ---------- */
.selector-head {
    margin-top: 0.6rem;
}

.system-card-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr));
    gap: 1rem;
}

.system-card {
    display: grid;
    grid-template-columns: 92px 1fr;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
    color: var(--ink);
    overflow: hidden;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.system-card:hover {
    color: var(--ink);
    border-color: var(--line-strong);
    box-shadow: var(--shadow);
}

.system-card:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--ring), var(--shadow-md);
}

/* Coluna com a sigla do projeto */
.system-card-core {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 1.1rem;
    background: var(--brand-2);
    transition: background-color 0.15s ease;
}

.system-card:hover .system-card-core {
    background: var(--brand);
}

.system-card-abbr {
    color: #fff;
    font-stretch: 125%;
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    text-align: center;
    padding: 0 0.3rem;
}

.system-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    padding: 1.1rem 1.25rem 1.15rem;
    min-width: 0;
}

.system-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    min-height: 36px;
}

.system-card-funder-logo {
    max-height: 34px;
    max-width: 160px;
    object-fit: contain;
}

.system-card-funder-name {
    font-weight: 650;
    color: var(--muted);
    font-size: 0.88rem;
}

.system-card-role {
    flex-shrink: 0;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand-2);
    font-size: 0.76rem;
    font-weight: 650;
}

.system-card h2 {
    margin: 0;
    font-size: 1rem;
    font-stretch: 100%;
    font-weight: 650;
    line-height: 1.4;
    letter-spacing: 0;
    color: var(--ink);
}

.system-card-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: auto;
    align-self: flex-start;
    padding: 0.5rem 0.9rem;
    border-radius: var(--r-md);
    background: var(--brand);
    color: #fff;
    font-weight: 650;
    font-size: 0.9rem;
    transition: background-color 0.15s ease;
}

.system-card:hover .system-card-cta {
    background: var(--brand-2);
}

.empty-state {
    text-align: center;
    padding: 2.5rem 1.5rem;
}

.empty-state h2 {
    margin: 0 0 0.4rem;
}

/* ---------- Rodape do portal ---------- */
.portal-foot {
    max-width: 2200px;
    margin: 0 auto;
    padding: 0 1.5rem 2rem;
}

.portal-foot p {
    margin: 0;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.82rem;
}

/* ---------- Painel superadmin ---------- */
.access-select {
    min-width: 140px;
    padding: 0.35rem 0.5rem;
    font-size: 0.84rem;
}

/* ---------- Ultimo sistema acessado ---------- */
.system-card.is-last {
    border-color: var(--brand);
    box-shadow: 0 0 0 1px var(--brand), var(--shadow-md);
}

.system-card-last {
    align-self: flex-start;
    margin-top: -0.4rem;
    color: var(--brand);
    font-size: 0.8rem;
    font-weight: 650;
}

.system-card-last[hidden] {
    display: none;
}
