/* ==========================================================================
   Design System CSC: Sentinel UI Spec
   Tema Claro no :root (ativado à noite) e Tema Escuro em .dark (ativado
   das 07:00 às 16:59 pela automação em ui.js).
   ========================================================================== */
:root {
    --font-heading: 'Sora', sans-serif;
    --font-body: 'Sora', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Marca (constante nos dois temas) */
    --blue-deep: #1B0DAE;
    --blue-royal: #3D2FD4;
    --brand-gradient: linear-gradient(135deg, #1B0DAE 0%, #3D2FD4 55%, #3A7BD5 100%);

    /* Tema Claro (Sentinel) */
    --bg-color: #f8f9fc;
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(0, 0, 0, 0.08);
    --glass-bevel: inset 0 1px 0 rgba(255, 255, 255, 0.5);
    --text-primary: #101828;
    --text-secondary: #475467;
    --blue: #3D2FD4;
    --blue-50: #eef4ff;
    --cyan: #00D2FF;
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.06);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);

    /* Superfícies e estados derivados */
    --surface-2: #eef1f6;
    --row-alt: rgba(0, 0, 0, 0.02);
    --row-hover: rgba(61, 47, 212, 0.07);
    --input-bg: rgba(0, 0, 0, 0.02);
    --input-border: rgba(0, 0, 0, 0.13);
    --accent-soft: rgba(61, 47, 212, 0.45);

    /* Status */
    --success: #137333;
    --success-soft: rgba(19, 115, 51, 0.12);
    --warning: #B06000;
    --warning-soft: rgba(176, 96, 0, 0.14);
    --danger: #C4320A;
    --danger-soft: rgba(196, 50, 10, 0.12);
    --neutral-soft: rgba(0, 0, 0, 0.06);

    /* Aliases de compatibilidade (nomes antigos usados pelo restante do CSS) */
    --blue-light: var(--blue);
    --blue-100: var(--blue);
    --primary: var(--blue);
    --primary-hover: var(--blue-royal);
    --primary-gradient: var(--brand-gradient);
    --card-bg: var(--glass-bg);
    --text-main: var(--text-primary);
    --text-muted: var(--text-secondary);
    --border-color: var(--glass-border);
    --gray-900: var(--text-primary);
    --gray-500: var(--text-secondary);
    --gray-400: var(--text-secondary);
    --gray-100: var(--surface-2);
    --gray-50: var(--bg-color);

    --border-radius: 12px;
    --transition: all 0.2s ease;
}

.dark {
    /* Tema Escuro (Sentinel) — ativo das 07:00 às 16:59 */
    --bg-color: #141416;
    --glass-bg: rgba(20, 20, 25, 0.6);
    --glass-border: rgba(255, 255, 255, 0.07);
    --glass-bevel: inset 0 1px 0 rgba(255, 255, 255, 0.15);
    --text-primary: #f4f4f7;
    --text-secondary: #9aa0a6;
    --blue: #6D5FF0;
    --blue-50: rgba(109, 95, 240, 0.14);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.5), 0 0 32px rgba(109, 95, 240, 0.04);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);

    --surface-2: #1b1b21;
    --row-alt: rgba(255, 255, 255, 0.02);
    --row-hover: rgba(109, 95, 240, 0.08);
    --input-bg: rgba(255, 255, 255, 0.03);
    --input-border: rgba(255, 255, 255, 0.10);
    --accent-soft: rgba(109, 95, 240, 0.45);

    --success: #34D399;
    --success-soft: rgba(19, 115, 51, 0.25);
    --warning: #FBBF24;
    --warning-soft: rgba(176, 96, 0, 0.25);
    --danger: #F87171;
    --danger-soft: rgba(196, 50, 10, 0.18);
    --neutral-soft: rgba(255, 255, 255, 0.06);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* Fundo liso e sóbrio — sem gradientes, sem efeitos */
.ambient-background {
    position: fixed;
    inset: 0;
    z-index: -2;
    background: var(--bg-color);
}

/* Formas antigas de fundo desativadas (substituídas pelo ambient-background) */
.background-shape,
.blob {
    display: none;
}

/* Painéis (dashboard/relatórios) alinham o conteúdo ao topo */
body.panel-bg {
    align-items: stretch;
    justify-content: flex-start;
}

/* ==========================================================================
   Container Principal
   ========================================================================== */
.container {
    width: 100%;
    max-width: 1280px;
    padding: 2rem;
    margin: 2rem;
}

header,
.header {
    text-align: center;
    margin-bottom: 3rem;
}

header .logo,
.header .logo {
    font-size: 3rem;
    color: var(--blue-100);
    margin-bottom: 1rem;
    display: inline-block;
}

/* Logo CSC (SVG) no cabeçalho */
.header .logo-icon {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    width: 80px;
    height: 80px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    box-shadow: var(--shadow-md);
}

.header .logo-icon svg {
    width: 64px;
    height: 64px;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

header h1,
.header h1 {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
    color: var(--gray-900);
}

header p,
.header p {
    color: var(--text-muted);
    font-size: 1.05rem;
    max-width: 520px;
    margin: 0 auto;
}

/* Links de navegação do cabeçalho */
.header a {
    color: var(--blue-100);
}

/* ==========================================================================
   Área de Upload
   ========================================================================== */
.upload-area {
    background: var(--card-bg);
    border: 2px dashed rgba(61, 47, 212, 0.55);
    border-radius: var(--border-radius);
    padding: 4rem 2rem;
    text-align: center;
    transition: var(--transition);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-md);
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.upload-area:hover, .upload-area.dragover {
    background: var(--surface-2);
    border-color: var(--blue-light);
}

#file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-icon {
    font-size: 4rem;
    color: var(--blue-light);
    margin-bottom: 1rem;
    opacity: 0.9;
}

.upload-area h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    pointer-events: none;
}

.upload-area p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    pointer-events: none;
}

/* ==========================================================================
   Botões
   ========================================================================== */
button {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 1rem;
    padding: 0.7rem 1.4rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--brand-gradient);
    color: white;
}

.btn-primary:hover {
    filter: brightness(1.15);
}

.btn-success {
    background: #16A34A;
    color: white;
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    margin-top: 1rem;
}

.btn-success:hover {
    background: #15803D;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   Inputs (padrão glass do Assinador)
   ========================================================================== */
input[type="text"],
input[type="password"],
input[type="date"],
input[type="search"] {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    color: white;
    font-family: inherit;
    font-weight: 500;
    outline: none;
    transition: var(--transition);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="search"]:focus {
    border-color: var(--blue-light);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 0 3px rgba(61, 47, 212, 0.25);
}

input::placeholder {
    color: var(--gray-400);
}

/* Ícone do calendário nativo legível no dark */
input[type="date"] {
    color-scheme: dark;
}

/* ==========================================================================
   Lista de Arquivos e Estados
   ========================================================================== */
.hidden {
    display: none !important;
}

.file-list-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-top: 2rem;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.file-list-container h4 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.file-list {
    list-style: none;
    margin-bottom: 1.5rem;
}

.file-list li {
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    font-size: 0.95rem;
}

.file-list li i {
    color: var(--blue-light);
    margin-right: 0.75rem;
    font-size: 1.2rem;
}

/* ==========================================================================
   Loader
   ========================================================================== */
.loader-container {
    text-align: center;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 3rem;
    margin-top: 2rem;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.spinner,
.loader {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(61, 47, 212, 0.25);
    border-top-color: var(--blue-light);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loader-container h3,
.loader-container h4 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.loader-container p {
    color: var(--text-muted);
}

/* ==========================================================================
   Resultados (Cards)
   ========================================================================== */
.results-container {
    margin-top: 2rem;
}

.results-container h4 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--success);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.result-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-top: 4px solid var(--blue-light);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: var(--transition);
}

.result-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.result-card.error {
    border-top-color: var(--danger);
}

.result-header {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.result-header i {
    font-size: 1.5rem;
    color: var(--blue-light);
    margin-right: 0.75rem;
}

.result-card.error .result-header i {
    color: var(--danger);
}

.result-header h5 {
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-body p {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.result-body strong {
    color: var(--text-main);
    font-weight: 600;
}

.result-body .badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(61, 47, 212, 0.18);
    color: var(--blue-100);
    margin-bottom: 0.5rem;
}

.folder-path {
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.8rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    word-break: break-all;
}

tbody tr {
    transition: all 0.2s ease;
}

tbody tr:hover {
    background: rgba(61, 47, 212, 0.10) !important;
}

/* ==========================================================================
   Footer
   ========================================================================== */
footer {
    text-align: center;
    margin-top: 4rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.badge-doc {
    background: rgba(61, 47, 212, 0.18);
    color: var(--blue-100);
    border: none;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    display: inline-block;
}

/* ==========================================================================
   Layout com Menu Lateral (Sidebar)
   ========================================================================== */
.layout-wrapper {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
}

.sidebar {
    width: 260px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    flex-shrink: 0;
}

.sidebar h3 {
    font-size: 1.05rem;
    color: var(--blue-100);
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.sidebar-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-list li {
    padding: 0.75rem 0.85rem;
    margin-bottom: 0.5rem;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    font-size: 0.92rem;
    gap: 0.5rem;
}

.sidebar-label {
    flex: 1;
    line-height: 1.4;
    overflow-wrap: break-word;
    word-break: normal;
}

.sidebar-label i {
    width: 20px;
    text-align: center;
    margin-right: 0.3rem;
}

.sidebar-list li:hover {
    background: rgba(61, 47, 212, 0.15);
    color: var(--blue-100);
}

.sidebar-list li.active {
    background: var(--blue-light);
    color: white;
    font-weight: 600;
}

.sidebar-list li .badge-count {
    background: rgba(255, 255, 255, 0.08);
    padding: 0.1rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-family: var(--font-mono);
}

.sidebar-list li.active .badge-count {
    background: rgba(255, 255, 255, 0.25);
}

.main-content {
    flex-grow: 1;
    min-width: 0; /* Impede que a tabela estoure o flex */
}

/* ==========================================================================
   Página de Relatórios
   ========================================================================== */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.chart-card {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.chart-card h3 {
    text-align: center;
    color: var(--text-main);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* ==========================================================================
   Cabeçalho da área de resultados e botão secundário
   ========================================================================== */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.results-header h3 {
    font-size: 1.5rem;
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

/* ==========================================================================
   Navegação do topo (pills consistentes em todas as páginas internas)
   ========================================================================== */
.top-bar .nav-links a {
    display: inline-block;
    padding: 0.45rem 0.85rem;
    border-radius: 10px;
    margin-left: 0.35rem;
    color: var(--text-main);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}
.top-bar .nav-links a:hover {
    background: var(--blue-50);
    color: var(--blue-100);
}

/* ==========================================================================
   Acessibilidade e refinamentos globais (skill ui-ux-design)
   ========================================================================== */

/* Foco visível para navegação por teclado */
:focus-visible {
    outline: 2px solid var(--blue-light);
    outline-offset: 2px;
    border-radius: 4px;
}

::selection {
    background: rgba(61, 47, 212, 0.5);
    color: #fff;
}

/* Controles nativos no tema escuro */
input[type="checkbox"] {
    accent-color: var(--blue-light);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

input[type="file"] {
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.88rem;
}

input[type="file"]::file-selector-button {
    background: rgba(255, 255, 255, 0.04);
    color: var(--blue-100);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.5rem 0.9rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    margin-right: 0.75rem;
    transition: var(--transition);
}

input[type="file"]::file-selector-button:hover {
    background: rgba(61, 47, 212, 0.2);
}

/* Scrollbars discretas no tema escuro */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--input-border) transparent;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: #344054;
    border-radius: 8px;
    border: 2px solid var(--gray-50);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* Botões desabilitados nunca "pulam" nem brilham */
button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
    filter: none !important;
    box-shadow: none !important;
}

/* Estado vazio de listas/tabelas */
.estado-vazio {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}
.estado-vazio i {
    display: block;
    font-size: 2rem;
    margin-bottom: 0.6rem;
    color: var(--gray-400);
}

/* ==========================================================================
   Toasts (feedback não-bloqueante — substitui alert())
   ========================================================================== */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-width: 380px;
}

.toast {
    background: var(--surface-2);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--blue-light);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    color: var(--text-main);
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast i { margin-top: 2px; }
.toast.toast-sucesso { border-left-color: #34D399; }
.toast.toast-sucesso i { color: #34D399; }
.toast.toast-erro { border-left-color: #F87171; }
.toast.toast-erro i { color: #F87171; }
.toast.saindo {
    opacity: 0;
    transform: translateX(16px);
    transition: all 0.3s ease;
}

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

/* ==========================================================================
   Animações de entrada (telas internas) — sutis, com stagger
   ========================================================================== */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeRow {
    from { opacity: 0; }
    to { opacity: 1; }
}

.anim-in {
    opacity: 0;
    animation: fadeUp 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.anim-d1 { animation-delay: 0.08s; }
.anim-d2 { animation-delay: 0.16s; }
.anim-d3 { animation-delay: 0.24s; }
.anim-d4 { animation-delay: 0.32s; }

/* Cards de resumo entram em cascata */
.summary-cards .summary-card {
    animation: fadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
.summary-cards .summary-card:nth-child(1) { animation-delay: 0.10s; }
.summary-cards .summary-card:nth-child(2) { animation-delay: 0.18s; }
.summary-cards .summary-card:nth-child(3) { animation-delay: 0.26s; }

/* Itens da sidebar (injetados via JS) entram em cascata */
.sidebar-list li {
    animation: fadeUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
.sidebar-list li:nth-child(1) { animation-delay: 0.05s; }
.sidebar-list li:nth-child(2) { animation-delay: 0.10s; }
.sidebar-list li:nth-child(3) { animation-delay: 0.15s; }
.sidebar-list li:nth-child(4) { animation-delay: 0.20s; }
.sidebar-list li:nth-child(5) { animation-delay: 0.25s; }
.sidebar-list li:nth-child(6) { animation-delay: 0.30s; }
.sidebar-list li:nth-child(7) { animation-delay: 0.35s; }
.sidebar-list li:nth-child(n+8) { animation-delay: 0.40s; }

/* Linhas de tabela (o JS define o delay por linha) */
tr.anim-row {
    opacity: 0;
    animation: fadeRow 0.35s ease forwards;
}

/* Cards de resultado do upload */
.results-grid .result-card {
    animation: fadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

/* ==========================================================================
   Responsividade
   ========================================================================== */
@media (max-width: 900px) {
    .layout-wrapper { flex-direction: column; }
    .sidebar { width: 100%; }
    .container { padding: 1rem; margin: 1rem; }
}

@media (max-width: 640px) {
    .dashboard-container {
        width: calc(100% - 1.5rem) !important;
        padding: 1.25rem !important;
        margin: 0.9rem auto !important;
    }
    .top-bar h2 { font-size: 1.25rem; }
    .top-bar .nav-links { width: 100%; display: flex; flex-wrap: wrap; gap: 0.25rem; }
    .top-bar .nav-links a { margin-left: 0; padding: 0.4rem 0.65rem; font-size: 0.85rem; }
    .search-box { max-width: 100% !important; flex-basis: 100%; }
    .charts-grid { grid-template-columns: 1fr; }
    .summary-cards { grid-template-columns: 1fr; }
    .header h1 { font-size: 2rem; }
    .header p { font-size: 0.95rem; }
    .upload-area { padding: 2.5rem 1.25rem; }
    .form-grid { grid-template-columns: 1fr !important; }
}

/* Respeita usuários que preferem menos movimento */
@media (prefers-reduced-motion: reduce) {
    .ambient-background { animation: none; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   Sentinel UI: Glassmorphic HUD Cards
   ========================================================================== */
body .dashboard-container,
.summary-card,
.chart-card,
.panel,
.result-card,
.file-list-container,
.loader-container {
    background: var(--glass-bg);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-bevel), var(--shadow-lg);
    border-radius: 12px;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
}

.upload-area {
    background: var(--glass-bg);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    box-shadow: var(--glass-bevel), var(--shadow-lg);
}

/* ==========================================================================
   Sentinel UI: HUD Glow Brackets (cantos ciano no hover)
   ========================================================================== */
.summary-card, .chart-card, .panel, .result-card {
    position: relative;
}

.summary-card::after,
.chart-card::after,
.panel::after,
.result-card::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 2;
    background:
        linear-gradient(to right, var(--blue) 16px, transparent 16px) 0 0 / 100% 1px no-repeat,
        linear-gradient(to bottom, var(--blue) 16px, transparent 16px) 0 0 / 1px 100% no-repeat,
        linear-gradient(to left, var(--blue) 16px, transparent 16px) 100% 0 / 100% 1px no-repeat,
        linear-gradient(to bottom, var(--blue) 16px, transparent 16px) 100% 0 / 1px 100% no-repeat,
        linear-gradient(to right, var(--blue) 16px, transparent 16px) 0 100% / 100% 1px no-repeat,
        linear-gradient(to top, var(--blue) 16px, transparent 16px) 0 100% / 1px 100% no-repeat,
        linear-gradient(to left, var(--blue) 16px, transparent 16px) 100% 100% / 100% 1px no-repeat,
        linear-gradient(to top, var(--blue) 16px, transparent 16px) 100% 100% / 1px 100% no-repeat;
}

.summary-card:hover::after,
.chart-card:hover::after,
.panel:hover::after,
.result-card:hover::after {
    opacity: 1;
}

/* ==========================================================================
   Sentinel UI: Chips de status tematizados (claro/escuro)
   ========================================================================== */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}
.chip-ok     { background: var(--success-soft); color: var(--success); }
.chip-erro   { background: var(--danger-soft);  color: var(--danger); }
.chip-aviso  { background: var(--warning-soft); color: var(--warning); }
.chip-neutro { background: var(--neutral-soft); color: var(--text-secondary); }

/* ==========================================================================
   Sentinel UI: Esteira de Status (Infinite Marquee Ticker)
   ========================================================================== */
@keyframes marquee {
    0% { transform: translate3d(0, 0, 0); }
    100% { transform: translate3d(-50%, 0, 0); }
}
@keyframes pulseGlow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

body.tem-ticker { padding-bottom: 48px; }

.ticker-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 48px;
    background-color: rgba(10, 10, 12, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    overflow: hidden;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 9999;
}

.ticker-clock {
    height: 100%;
    background-color: #121216;
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    font-family: var(--font-mono);
    font-weight: 600;
    color: #f4f4f7;
    z-index: 100;
    flex-shrink: 0;
    font-size: 0.9rem;
}

.ticker-dot {
    color: #8B7FFF;
    animation: pulseGlow 2s infinite;
    margin-right: 6px;
}

.ticker-marquee-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    align-items: center;
    height: 100%;
}

.ticker-marquee-wrapper {
    display: flex;
    gap: 5rem;
    align-items: center;
    white-space: nowrap;
    animation: marquee 65s linear infinite;
    padding-left: 2rem;
}

.ticker-item {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    color: #d0d3da;
}
.ticker-item b { color: #f4f4f7; }

.ticker-badge {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: rgba(109, 95, 240, 0.18);
    color: #A29BFF;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

@media (max-width: 640px) {
    .ticker-clock { padding: 0 12px; font-size: 0.8rem; }
}
@media (prefers-reduced-motion: reduce) {
    .ticker-marquee-wrapper { animation: none; }
}

/* ==========================================================================
   Tela de Loading (Splash) — identidade CSC
   ========================================================================== */
.splash-csc {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.1rem;
    transition: opacity 0.45s ease, visibility 0.45s ease;
}

.splash-csc.oculto {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.splash-csc svg {
    width: 76px;
    height: 88px;
}

.splash-csc svg rect {
    animation: splashPulse 1.3s ease-in-out infinite;
}
.splash-csc svg rect:nth-of-type(2) { animation-delay: 0.18s; }
.splash-csc svg rect:nth-of-type(3) { animation-delay: 0.36s; }

@keyframes splashPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

.splash-nome {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.05rem;
    letter-spacing: 0.03em;
    color: var(--text-primary);
}

.splash-barra {
    width: 150px;
    height: 3px;
    background: var(--neutral-soft);
    border-radius: 2px;
    overflow: hidden;
}

.splash-barra span {
    display: block;
    height: 100%;
    width: 40%;
    background: var(--brand-gradient);
    border-radius: 2px;
    animation: splashSlide 1.1s ease-in-out infinite;
}

@keyframes splashSlide {
    0% { transform: translateX(-110%); }
    100% { transform: translateX(360%); }
}

/* ==========================================================================
   Fila de processamento em tempo real (upload)
   ========================================================================== */
.fila-container {
    background: var(--glass-bg);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-bevel), var(--shadow-lg);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 2rem;
}

.fila-nota {
    color: var(--text-secondary);
    font-size: 0.82rem;
    margin-bottom: 1.1rem;
}

.fila-item {
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 0.9rem 1rem;
    margin-bottom: 0.7rem;
    background: var(--row-alt);
}

.fila-arquivo {
    font-size: 0.92rem;
    margin-bottom: 0.6rem;
    word-break: break-all;
}
.fila-arquivo i { color: var(--blue); margin-right: 0.3rem; }
.fila-arquivo .mono { color: var(--text-secondary); font-size: 0.78rem; }

.fila-etapas {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.fila-etapa {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.28rem 0.7rem;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
    background: var(--neutral-soft);
    color: var(--text-secondary);
    white-space: nowrap;
}
.fila-etapa.ativa {
    background: var(--blue-50);
    color: var(--blue);
    border: 1px solid var(--accent-soft);
}
.fila-etapa.feita {
    background: var(--success-soft);
    color: var(--success);
}
.fila-etapa.concluida {
    background: var(--success-soft);
    color: var(--success);
    border: 1px solid var(--success-soft);
}
.fila-seta { color: var(--text-secondary); opacity: 0.5; font-size: 0.7rem; }

.fila-detalhe {
    margin-top: 0.5rem;
    font-size: 0.76rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}
