/* =====================================================================
   TJ FINANCEIRO - Tema premium (dark)
   Paleta oficial:
     Fundo             #080D19
     Painéis           #101827
     Azul principal    #2563EB
     Azul claro        #60A5FA
     Texto             #EDF3FF
     Texto secundário  #8D9BB2
   ===================================================================== */

:root {
    --bg: #080D19;
    --bg-soft: #0B1220;
    --panel: #101827;
    --panel-2: #131C2E;
    --panel-3: #182238;
    --border: #1E2A42;
    --border-soft: #182337;
    --primary: #2563EB;
    --primary-light: #60A5FA;
    --primary-soft: rgba(37, 99, 235, .14);
    --text: #EDF3FF;
    --muted: #8D9BB2;
    --success: #22C55E;
    --success-soft: rgba(34, 197, 94, .14);
    --danger: #EF4444;
    --danger-soft: rgba(239, 68, 68, .14);
    --warn: #F59E0B;
    --warn-soft: rgba(245, 158, 11, .14);
    --info: #38BDF8;
    --info-soft: rgba(56, 189, 248, .14);
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 18px 40px rgba(0, 0, 0, .35);
    --sidebar-w: 264px;
    --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

/* Light theme */
[data-theme="light"] {
    --bg: #F8FAFC;
    --bg-soft: #F1F5F9;
    --panel: #FFFFFF;
    --panel-2: #F8FAFC;
    --panel-3: #F1F5F9;
    --border: #E2E8F0;
    --border-soft: #E2E8F0;
    --primary: #2563EB;
    --primary-light: #3B82F6;
    --primary-soft: rgba(37, 99, 235, .08);
    --text: #1E293B;
    --muted: #64748B;
    --success: #22C55E;
    --success-soft: rgba(34, 197, 94, .08);
    --danger: #EF4444;
    --danger-soft: rgba(239, 68, 68, .08);
    --warn: #F59E0B;
    --warn-soft: rgba(245, 158, 11, .08);
    --info: #0EA5E9;
    --info-soft: rgba(14, 165, 233, .08);
    --shadow: 0 18px 40px rgba(0, 0, 0, .12);
}

* { box-sizing: border-box; }

/* O atributo hidden deve sempre vencer o display dos componentes */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-light); text-decoration: none; }
a:hover { color: var(--text); }

h1, h2, h3, h4 { margin: 0 0 .35rem; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .98rem; }
p { margin: 0 0 .75rem; }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warn { color: var(--warn); }
.text-primary { color: var(--primary-light); }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

.skip-link {
    position: absolute; left: -9999px; top: 0;
    background: var(--primary); color: #fff; padding: .6rem 1rem; z-index: 999;
}
.skip-link:focus { left: 1rem; top: 1rem; }

/* ------------------------------------------------------------------ */
/* Estrutura                                                            */
/* ------------------------------------------------------------------ */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 40;
}

.main {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
}

.brand {
    display: flex; align-items: center; gap: .7rem;
    padding: 1.05rem 1.1rem;
    border-bottom: 1px solid var(--border-soft);
}
.brand-mark {
    display: grid; place-items: center;
    width: 40px; height: 40px; flex: 0 0 40px;
    border-radius: 12px;
    background: linear-gradient(140deg, var(--primary), #1E40AF);
    color: #fff; font-weight: 800; letter-spacing: .5px;
    box-shadow: 0 6px 18px rgba(37, 99, 235, .35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.brand-mark:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(37, 99, 235, .45);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: .95rem; }
.brand-text small { color: var(--muted); font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.space-switch {
    display: flex; gap: .35rem;
    padding: .8rem .8rem 0;
}
.space-option {
    flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
    padding: .5rem .4rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-soft);
    color: var(--muted);
    font-size: .8rem; font-weight: 600;
    transition: .15s ease;
}
.space-option:hover { color: var(--text); border-color: var(--primary); }
.space-option.is-active {
    background: var(--primary-soft);
    border-color: rgba(37, 99, 235, .55);
    color: var(--text);
}
.space-single {
    display: flex; align-items: center; gap: .45rem;
    margin: .8rem .8rem 0; padding: .5rem .7rem;
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
    color: var(--text); font-size: .8rem; font-weight: 600;
}

.nav { padding: .85rem .6rem 1.5rem; display: flex; flex-direction: column; gap: .12rem; }
.nav-label {
    margin: .9rem .55rem .3rem;
    font-size: .68rem; letter-spacing: .1em; text-transform: uppercase;
    color: var(--muted); font-weight: 700;
}
.nav-item {
    display: flex; align-items: center; gap: .65rem;
    padding: .55rem .65rem;
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-size: .86rem; font-weight: 500;
    transition: background .15s ease, color .15s ease, transform 0.15s ease;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item:hover .icon { transform: scale(1.08); }
.nav-item.is-active {
    background: var(--primary-soft);
    color: var(--text);
    font-weight: 650;
    box-shadow: inset 2px 0 0 var(--primary);
}
.nav-item.is-active .icon { transform: scale(1.05); }
.nav-item .icon { flex: 0 0 auto; transition: transform 0.15s ease; }

/* ------------------------------------------------------------------ */
/* Ícones SVG - Melhorias visuais e responsividade                     */
/* ------------------------------------------------------------------ */
.icon {
    display: inline-block;
    vertical-align: middle;
    max-width: 100%;
    height: auto;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.icon-hover:hover {
    transform: scale(1.1);
    opacity: 0.9;
}

.icon-pulse {
    animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.icon-spin {
    animation: iconSpin 1s linear infinite;
}

@keyframes iconSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.icon-bounce {
    animation: iconBounce 0.5s ease;
}

@keyframes iconBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* Ícones responsivos */
.icon-xs { width: 12px; height: 12px; }
.icon-sm { width: 16px; height: 16px; }
.icon-md { width: 20px; height: 20px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 32px; height: 32px; }
.icon-2xl { width: 48px; height: 48px; }

/* Responsividade para ícones em mobile */
@media (max-width: 640px) {
    .icon-responsive {
        width: calc(100% * 0.8);
        height: calc(100% * 0.8);
    }
}

/* High DPI/Retina display support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .icon {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* ------------------------------------------------------------------ */
/* Animações e efeitos visuais para ícones                               */
/* ------------------------------------------------------------------ */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }

}

.scale-in {
    animation: scaleIn 0.2s ease-out;
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* Efeito de brilho suave ao hover */
.icon-glow:hover {
    filter: drop-shadow(0 0 8px var(--primary-light));
}

/* Efeito de rotação ao clicar */
.icon-click:active {
    transform: rotate(5deg) scale(0.95);
}

/* Suporte para modo escuro em ícones coloridos */
@media (prefers-color-scheme: dark) {
    .icon-auto-color {
        filter: brightness(1.2);
    }
}

/* Redução de motion para usuários que preferem menos animação */
@media (prefers-reduced-motion: reduce) {
    .icon,
    .icon-hover,
    .icon-pulse,
    .icon-spin,
    .icon-bounce,
    .fade-in,
    .slide-in,
    .scale-in {
        animation: none !important;
        transition: none !important;
    }
}

.sidebar-foot {
    margin-top: auto;
    padding: .85rem;
    border-top: 1px solid var(--border-soft);
}
.user-mini { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.avatar {
    display: grid; place-items: center;
    width: 34px; height: 34px; flex: 0 0 34px;
    border-radius: 50%;
    background: var(--panel-3);
    border: 1px solid var(--border);
    color: var(--primary-light); font-weight: 700;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.avatar:hover {
    transform: scale(1.05);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.user-mini-info { display: flex; flex-direction: column; min-width: 0; }
.user-mini-info strong { font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-mini-info small { color: var(--muted); font-size: .72rem; }

/* ------------------------------------------------------------------ */
/* Topbar                                                              */
/* ------------------------------------------------------------------ */
.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: .8rem;
    padding: .7rem 1.25rem;
    background: rgba(8, 13, 25, .86);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.topbar-title { display: flex; flex-direction: column; min-width: 0; }
.topbar-title strong { font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-space { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }

.icon-btn {
    display: inline-grid; place-items: center;
    width: 38px; height: 38px;
    border-radius: var(--radius-sm);
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text); cursor: pointer;
    list-style: none;
}
.icon-btn::-webkit-details-marker { display: none; }
.icon-btn:hover { border-color: var(--primary); color: var(--primary-light); }
.icon-btn:active { transform: scale(0.95); }
.icon-btn .icon { transition: transform 0.2s ease; }
.icon-btn:hover .icon { transform: scale(1.1); }

.user-menu { position: relative; }
.menu-card {
    position: absolute; right: 0; top: calc(100% + .5rem);
    min-width: 230px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: .4rem;
    z-index: 50;
}
.menu-head { padding: .55rem .6rem .6rem; border-bottom: 1px solid var(--border-soft); margin-bottom: .3rem; display: flex; flex-direction: column; }
.menu-head strong { font-size: .85rem; }
.menu-head small { color: var(--muted); font-size: .75rem; }
.menu-item {
    display: flex; align-items: center; gap: .55rem;
    padding: .5rem .6rem; border-radius: 8px;
    color: var(--muted); font-size: .84rem;
}
.menu-item:hover { background: var(--panel-2); color: var(--text); }

.content { padding: 1.25rem; flex: 1 1 auto; max-width: 1500px; width: 100%; }

.app-foot {
    display: flex; justify-content: space-between; gap: 1rem;
    padding: .9rem 1.25rem;
    border-top: 1px solid var(--border-soft);
    color: var(--muted); font-size: .76rem;
}

/* ------------------------------------------------------------------ */
/* Cabeçalho de página                                                  */
/* ------------------------------------------------------------------ */
.page-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem;
}
.page-sub { color: var(--muted); font-size: .84rem; margin: 0; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ------------------------------------------------------------------ */
/* Cards / grids                                                        */
/* ------------------------------------------------------------------ */
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.05rem;
    margin-bottom: 1rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, .25);
}
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: .75rem; flex-wrap: wrap; margin-bottom: .85rem;
}
.card-head h2, .card-head h3 { margin: 0; }
.card-sub { color: var(--muted); font-size: .78rem; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

/* Animation on load */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.grid > *, .card {
    animation: slideUp 0.4s ease-out;
}

/* Staggered animation for grid items */
.grid > *:nth-child(1) { animation-delay: 0.05s; }
.grid > *:nth-child(2) { animation-delay: 0.1s; }
.grid > *:nth-child(3) { animation-delay: 0.15s; }
.grid > *:nth-child(4) { animation-delay: 0.2s; }

.kpi {
    background: linear-gradient(160deg, var(--panel), var(--panel-2));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.05rem;
    display: flex; flex-direction: column; gap: .35rem;
    position: relative; overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.kpi:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, .4);
}
.kpi::after {
    content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
    background: var(--primary);
    transition: width 0.3s ease;
}
.kpi:hover::after {
    width: 4px;
}
.kpi.kpi-success::after { background: var(--success); }
.kpi.kpi-danger::after { background: var(--danger); }
.kpi.kpi-warn::after { background: var(--warn); }
.kpi-label { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.kpi-value { font-size: 1.4rem; font-weight: 700; letter-spacing: -.02em; }
.kpi-hint { color: var(--muted); font-size: .76rem; }
.kpi-icon { position: absolute; right: .9rem; top: .9rem; color: var(--border); transition: transform 0.2s ease, color 0.2s ease; }
.kpi:hover .kpi-icon { transform: scale(1.1); color: var(--muted); }

/* ------------------------------------------------------------------ */
/* Botões                                                               */
/* ------------------------------------------------------------------ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .55rem .95rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
    font-size: .85rem; font-weight: 600; font-family: inherit;
    cursor: pointer; white-space: nowrap;
    transition: .15s ease;
}
.btn:hover { border-color: var(--primary); color: var(--text); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #1D4ED8; border-color: #1D4ED8; color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #04240F; }
.btn-danger { background: transparent; border-color: rgba(239, 68, 68, .5); color: #FCA5A5; }
.btn-danger:hover { background: var(--danger-soft); color: #FECACA; }
.btn-ghost { background: transparent; }
.btn-sm { padding: .35rem .6rem; font-size: .78rem; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-icon { padding: .38rem; width: 32px; height: 32px; }

/* ------------------------------------------------------------------ */
/* Formulários                                                          */
/* ------------------------------------------------------------------ */
.form-grid { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-full { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field label { font-size: .78rem; color: var(--muted); font-weight: 600; }
.field .req { color: var(--danger); }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="month"], input[type="search"], input[type="tel"],
input[type="file"], select, textarea {
    width: 100%;
    padding: .6rem .7rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-soft);
    color: var(--text);
    font-family: inherit; font-size: .88rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
input::placeholder, textarea::placeholder { color: #5C6B84; }
textarea { min-height: 84px; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 2rem; }
select[multiple] { background-image: none; padding-right: .7rem; min-height: 120px; }

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

.check-list { display: flex; flex-wrap: wrap; gap: .5rem .9rem; }
.check-item { display: inline-flex; align-items: center; gap: .4rem; font-size: .84rem; color: var(--text); }
.check-item input { margin: 0; }

fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .9rem; margin: 0 0 1rem; }
legend { padding: 0 .4rem; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; }

.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; align-items: center; }

.filter-bar {
    display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end;
    padding: .9rem; margin-bottom: 1rem;
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
}
.filter-bar .field { flex: 1 1 150px; }
.filter-bar .field.field-sm { flex: 0 1 130px; }

/* ------------------------------------------------------------------ */
/* Tabelas                                                              */
/* ------------------------------------------------------------------ */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
}
table.data { width: 100%; border-collapse: collapse; font-size: .85rem; min-width: 640px; }
table.data th, table.data td { padding: .65rem .8rem; text-align: left; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
table.data thead th {
    background: var(--panel-2);
    color: var(--muted);
    font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
    white-space: nowrap; position: sticky; top: 0;
}
table.data tbody tr:hover { background: var(--panel-2); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tfoot td { background: var(--panel-2); font-weight: 700; border-top: 1px solid var(--border); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .row-actions { display: flex; gap: .3rem; justify-content: flex-end; }
table.data tr.is-cancelled td { opacity: .5; text-decoration: line-through; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .4rem; vertical-align: middle; }

/* ------------------------------------------------------------------ */
/* Badges / alertas / progresso                                         */
/* ------------------------------------------------------------------ */
.badge {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .18rem .5rem; border-radius: 999px;
    font-size: .72rem; font-weight: 700; letter-spacing: .02em;
    border: 1px solid transparent;
}
.badge-ok { background: var(--success-soft); color: #86EFAC; border-color: rgba(34,197,94,.35); }
.badge-warn { background: var(--warn-soft); color: #FCD34D; border-color: rgba(245,158,11,.35); }
.badge-danger { background: var(--danger-soft); color: #FCA5A5; border-color: rgba(239,68,68,.35); }
.badge-muted { background: var(--panel-3); color: var(--muted); border-color: var(--border); }
.badge-info { background: var(--info-soft); color: #7DD3FC; border-color: rgba(56,189,248,.35); }

.alert {
    display: flex; align-items: flex-start; gap: .6rem;
    padding: .75rem .9rem; margin-bottom: 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--panel);
    font-size: .86rem;
}
.alert .icon { flex: 0 0 auto; margin-top: .1rem; transition: transform 0.2s ease; }
.alert:hover .icon { transform: scale(1.1); }
.alert-success { border-color: rgba(34,197,94,.4); background: var(--success-soft); }
.alert-error { border-color: rgba(239,68,68,.4); background: var(--danger-soft); }
.alert-warn { border-color: rgba(245,158,11,.4); background: var(--warn-soft); }
.alert-info { border-color: rgba(56,189,248,.4); background: var(--info-soft); }

.progress { height: 8px; border-radius: 999px; background: var(--panel-3); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s ease; }
.progress.is-warn > span { background: var(--warn); }
.progress.is-danger > span { background: var(--danger); }
.progress.is-ok > span { background: var(--success); }

.empty { padding: 1.6rem; text-align: center; color: var(--muted); font-size: .86rem; }
.empty .icon { color: var(--border); margin-bottom: .4rem; transition: transform 0.3s ease, color 0.3s ease; }
.empty:hover .icon { transform: scale(1.1); color: var(--muted); }

/* ------------------------------------------------------------------ */
/* Gráficos / listas                                                    */
/* ------------------------------------------------------------------ */
.chart-box { position: relative; width: 100%; height: 260px; }
.chart-box canvas { width: 100% !important; height: 100% !important; }
.legend { display: flex; flex-wrap: wrap; gap: .5rem .9rem; margin-top: .6rem; font-size: .78rem; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: .35rem; }

.list-clean { list-style: none; margin: 0; padding: 0; }
.list-clean li { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--border-soft); font-size: .86rem; }
.list-clean li:last-child { border-bottom: 0; }

/* ------------------------------------------------------------------ */
/* Autenticação                                                         */
/* ------------------------------------------------------------------ */
.auth-body {
    min-height: 100vh;
    display: grid; place-items: center;
    padding: 1.5rem;
    background:
        radial-gradient(900px 500px at 15% -10%, rgba(37, 99, 235, .18), transparent 60%),
        radial-gradient(700px 400px at 100% 100%, rgba(96, 165, 250, .12), transparent 60%),
        var(--bg);
}
.auth-card {
    width: 100%; max-width: 420px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 1.6rem;
    box-shadow: var(--shadow);
}
.auth-head { display: flex; flex-direction: column; align-items: center; gap: .6rem; text-align: center; margin-bottom: 1.2rem; }
.auth-head .brand-mark { width: 52px; height: 52px; flex: 0 0 52px; border-radius: 16px; font-size: 1.1rem; }
.auth-head h1 { font-size: 1.2rem; margin: 0; }
.auth-head p { color: var(--muted); font-size: .84rem; margin: 0; }
.auth-foot { margin-top: 1.2rem; text-align: center; font-size: .8rem; color: var(--muted); }
.auth-side { max-width: 420px; }

/* ------------------------------------------------------------------ */
/* Modal (dialog)                                                       */
/* ------------------------------------------------------------------ */
dialog.modal {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    color: var(--text);
    padding: 0;
    width: min(680px, calc(100vw - 2rem));
    box-shadow: var(--shadow);
}
dialog.modal::backdrop { background: rgba(3, 6, 14, .72); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.1rem; border-bottom: 1px solid var(--border); }
.modal-body { padding: 1.1rem; max-height: min(70vh, 640px); overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .9rem 1.1rem; border-top: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 1.02rem; }

/* ------------------------------------------------------------------ */
/* Utilitários e responsivo                                             */
/* ------------------------------------------------------------------ */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.flex-wrap { flex-wrap: wrap; }
.gap-sm { gap: .4rem; }
.gap { gap: .75rem; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.w-100 { width: 100%; }
.only-mobile { display: none; }
.sidebar-overlay { display: none; }

.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.tab {
    padding: .5rem .8rem; border-radius: 8px 8px 0 0;
    color: var(--muted); font-size: .85rem; font-weight: 600;
    border: 1px solid transparent; border-bottom: none;
}
.tab.is-active { color: var(--text); background: var(--panel); border-color: var(--border); margin-bottom: -1px; }

.pager { display: flex; gap: .3rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.pager a, .pager span {
    padding: .35rem .65rem; border-radius: 8px; border: 1px solid var(--border);
    background: var(--panel); color: var(--muted); font-size: .8rem;
}
.pager .is-active { background: var(--primary); border-color: var(--primary); color: #fff; }

@media (max-width: 1024px) {
    .only-mobile { display: inline-grid; }
    .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow); }
    .sidebar.is-open { transform: translateX(0); }
    .main { margin-left: 0; }
    .sidebar-overlay.is-visible { display: block; position: fixed; inset: 0; background: rgba(3,6,14,.6); z-index: 35; }
    .content { padding: 1rem; }
    .form-grid .span-2 { grid-column: span 1; }
}

@media (max-width: 640px) {
    .kpi-value { font-size: 1.2rem; }
    .topbar { padding: .6rem .8rem; }
    .page-head { align-items: flex-start; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1 1 auto; }
    .grid-4, .grid-3 { grid-template-columns: 1fr; }
}

@media print, .is-exporting-pdf {
    .sidebar, .topbar, .app-foot, .page-actions, .filter-bar, .no-print, .tabs { display: none !important; }
    .main { margin-left: 0 !important; }
    body { background: #fff !important; color: #111 !important; }
    .card, .table-wrap, .kpi { border-color: #ccc !important; background: #fff !important; color: #111 !important; box-shadow: none !important; }
    table.data th { background: #f1f5f9 !important; color: #111 !important; }
    a { color: #111 !important; }
    .kpi-value { color: #111 !important; }
    .kpi::after { display: none; }
    .page-head h1 { color: #111 !important; }
}

@media print {

/* ------------------------------------------------------------------ */
/* Theme Toggle                                                       */
/* ------------------------------------------------------------------ */
.theme-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px;
    border-radius: var(--radius-sm);
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text); cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.theme-toggle:hover { border-color: var(--primary); color: var(--primary-light); }

/* ------------------------------------------------------------------ */
/* Search Modal                                                       */
/* ------------------------------------------------------------------ */
#search-modal {
    max-width: 600px;
    padding: 0;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
#search-modal::backdrop {
    background: rgba(3, 6, 14, .72);
    backdrop-filter: blur(2px);
}
.search-header {
    display: flex; align-items: center; gap: .5rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}
#search-input {
    flex: 1;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .6rem .8rem;
    color: var(--text);
    font-size: 1rem;
}
#search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.search-body {
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
}
.search-result-item {
    display: flex; align-items: center; gap: .8rem;
    padding: .7rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s ease;
}
.search-result-item:hover {
    background: var(--panel-2);
}
.search-result-icon {
    flex: 0 0 auto;
    color: var(--muted);
}
.search-result-info {
    flex: 1;
    min-width: 0;
}
.search-result-title {
    font-weight: 600;
    color: var(--text);
}
.search-result-subtitle {
    font-size: .8rem;
    color: var(--muted);
}

/* ------------------------------------------------------------------ */
/* Quick Actions FAB                                                  */
/* ------------------------------------------------------------------ */
.quick-actions-fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    box-shadow: 0 8px 24px rgba(37, 99, 235, .4);
    cursor: pointer;
    display: grid;
    place-items: center;
    z-index: 100;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.quick-actions-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 32px rgba(37, 99, 235, .5);
}
.quick-actions-menu {
    position: fixed;
    bottom: 4rem;
    right: 2rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 200px;
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
}
.quick-actions-menu.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.quick-action-item {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .7rem 1rem;
    color: var(--text);
    text-decoration: none;
    transition: background 0.15s ease;
}
.quick-action-item:hover {
    background: var(--panel-2);
}
.quick-action-item:first-child {
    border-radius: var(--radius) var(--radius) 0 0;
}
.quick-action-item:last-child {
    border-radius: 0 0 var(--radius) var(--radius);
}

/* ------------------------------------------------------------------ */
/* Keyboard Help Overlay                                             */
/* ------------------------------------------------------------------ */
#keyboard-help {
    position: fixed;
    inset: 0;
    background: rgba(3, 6, 14, .85);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}
#keyboard-help.is-visible {
    opacity: 1;
    visibility: visible;
}
.keyboard-help-content {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow);
}
.keyboard-help-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}
.keyboard-shortcut {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .7rem 0;
    border-bottom: 1px solid var(--border-soft);
}
.keyboard-shortcut:last-child {
    border-bottom: none;
}
.keyboard-keys {
    display: flex;
    gap: .3rem;
}
.key {
    display: inline-block;
    padding: .2rem .5rem;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: monospace;
    font-size: .85rem;
    color: var(--muted);
}
.keyboard-close {
    margin-top: 1.5rem;
    text-align: center;
}

/* ------------------------------------------------------------------ */
/* Density Controls                                                   */
/* ------------------------------------------------------------------ */
[data-density="compact"] {
    --radius: 10px;
    --radius-sm: 6px;
}
[data-density="compact"] .card { padding: .7rem; }
[data-density="compact"] .kpi { padding: .7rem .8rem; }
[data-density="compact"] .kpi-value { font-size: 1.2rem; }
[data-density="compact"] table.data th, table.data td { padding: .4rem .6rem; }

[data-density="comfortable"] {
    --radius: 16px;
    --radius-sm: 12px;
}
[data-density="comfortable"] .card { padding: 1.4rem; }
[data-density="comfortable"] .kpi { padding: 1.3rem 1.4rem; }
[data-density="comfortable"] .kpi-value { font-size: 1.6rem; }
[data-density="comfortable"] table.data th, table.data td { padding: .9rem 1rem; }
