:root {
    --bg-color: #0f2027;
    --bg-card: #0d1f2d;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #ffffff;
    --text-primary: #ffffff;
    --text-muted: #9ca3af;
    --accent: #00C9FF;
    --border: rgba(255, 255, 255, 0.15);
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
    color: var(--text-main);
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar */
nav {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 100;
}

nav h2 {
    margin: 0;
    font-size: 1.5em;
    color: var(--accent);
    cursor: pointer;
}

.nav-links {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 4px;
}

.nav-links > a,
.nav-links > div > a,
.nav-submenu-wrapper > a {
    color: var(--text-main);
    text-decoration: none;
    padding: 6px 12px;
    font-weight: bold;
    cursor: pointer;
    white-space: nowrap;
    border-radius: 6px;
    transition: background 0.15s;
}

.nav-links > a:hover,
.nav-submenu-wrapper > a:hover {
    background: rgba(255,255,255,0.07);
}

/* Container Principal */
.container {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Cards e Glassmorphism */
.card {
    background: var(--glass-bg);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    width: 100%;
    max-width: 600px;
    text-align: center;
    margin-bottom: 20px;
    display: none;
}

.card.active {
    display: block;
}

.dashboard-card {
    max-width: 80%;
}

.config-card {
    max-width: 900px;
    min-height: calc(100vh - 160px);
    text-align: left;
    box-sizing: border-box;
}

/* Formulários e Botões */
input,
select,
textarea {
    width: 100%;
    padding: 12px;
    margin: 5px 0 15px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
    color: white;
    box-sizing: border-box;
    font-family: monospace;
}

option {
    background: var(--bg-card);
    color: var(--text-primary);
}

textarea {
    height: 80px;
    resize: vertical;
}

.btn {
    display: inline-block;
    padding: 12px 24px;
    background: linear-gradient(90deg, #00C9FF 0%, #92FE9D 100%);
    color: #0f2027;
    text-decoration: none;
    border-radius: 8px;
    font-weight: bold;
    border: none;
    cursor: pointer;
    width: 100%;
    transition: transform 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn-small {
    width: auto;
    padding: 8px 16px;
    font-size: 0.9em;
    margin-bottom: 15px;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
}

/* Grid para Formulário de Configuração */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    text-align: left;
    margin-bottom: 20px;
}

.form-group label {
    font-size: 0.85em;
    color: var(--accent);
    font-weight: bold;
    display: block;
}

.form-section-title {
    grid-column: span 2;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 5px;
    margin-top: 15px;
    color: white;
}

/* Tabela de Tarefas */
.dashboard-header-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 10px;
    gap: 10px;
    flex-wrap: wrap;
}

.dashboard-header-actions input,
.dashboard-header-actions .filtro-cns input {
    height: 34px;
    margin: 0;
    padding: 0 10px;
    width: 160px;
    box-sizing: border-box;
}

.dashboard-header-actions .btn {
    margin-bottom: 0;
    height: 34px;
    display: flex;
    align-items: center;
}

.monitor-controls input {
    height: 34px;
    margin: 0;
    padding: 0 10px;
    width: 160px;
    box-sizing: border-box;
}

.monitor-controls .btn {
    margin-bottom: 0;
    height: 34px;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.monitor-controls .countdown-badge {
    height: 34px;
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    text-align: left;
}

th,
td {
    padding: 12px;
    border-bottom: 1px solid var(--glass-border);
}

td {
    font-size: 0.8em;
}

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

.status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.7em;
    background: rgba(255, 255, 255, 0.1);
}

.ocr-badge {
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 0.68em;
    font-weight: 600;
    background: rgba(0,201,255,0.12);
    color: #67e8f9;
    letter-spacing: 0.03em;
}

/* --- Paginação --- */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-top: 20px;
    flex-wrap: nowrap;
}

.pagina-info {
    font-size: 0.82em;
    color: var(--text-muted);
    white-space: nowrap;
    padding: 0 6px;
}

.btn-page {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--glass-border);
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.85em;
    white-space: nowrap;
}

.btn-page-icon {
    padding: 5px 9px;
    font-size: 1em;
    line-height: 1;
}

.btn-page:hover:not(:disabled) {
    background: rgba(0, 201, 255, 0.3);
}

.btn-page:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pagina-select {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    padding: 5px 6px;
    font-size: 0.82em;
    cursor: pointer;
    width: auto;
    margin: 0;
    margin-left: 8px;
}

.pagina-select option { background: #1a2a3a; }

/* Tabela de tempos médios */
#tabela-tempos th { color: var(--accent); font-size: 0.8em; }
#tabela-tempos td { font-size: 0.82em; }

.tempo-bar-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tempo-bar {
    height: 6px;
    border-radius: 4px;
    background: var(--accent);
    min-width: 4px;
    transition: width 0.3s;
}

.tempo-bar.lento { background: #fb923c; }
.tempo-bar.muito-lento { background: #f87171; }

/* Filtro de tempo (funil) */
.filtro-tempo-wrapper {
    position: relative;
}

.btn-funil {
    height: 34px;
    padding: 0 12px;
    background: rgba(255,255,255,0.07);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1em;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-funil:hover { border-color: var(--accent); color: var(--accent); }
.btn-funil.ativo  { border-color: var(--accent); color: var(--accent); background: rgba(0,201,255,0.12); }

.funil-badge {
    font-size: 0.72em;
    background: var(--accent);
    color: #0f2027;
    border-radius: 8px;
    padding: 1px 6px;
    font-weight: bold;
}

.funil-painel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #1a3040;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 14px;
    z-index: 200;
    width: 300px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    display: none;
}

.funil-painel.aberto { display: block; }

.funil-tipos {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.funil-tipo-btn {
    flex: 1;
    padding: 5px 8px;
    border-radius: 6px;
    border: 1px solid var(--glass-border);
    background: rgba(255,255,255,0.05);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.78em;
    text-align: center;
    transition: all 0.15s;
}

.funil-tipo-btn:hover,
.funil-tipo-btn.sel { background: rgba(0,201,255,0.15); color: var(--accent); border-color: var(--accent); }

.funil-valores {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 36px;
}

.funil-val-btn {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--glass-border);
    background: rgba(255,255,255,0.05);
    color: var(--text-main);
    cursor: pointer;
    font-size: 0.8em;
    transition: all 0.15s;
}

.funil-val-btn:hover,
.funil-val-btn.sel { background: rgba(0,201,255,0.2); border-color: var(--accent); color: var(--accent); }

.funil-limpar {
    margin-top: 12px;
    width: 100%;
    padding: 5px;
    border-radius: 6px;
    border: 1px solid rgba(248,113,113,0.4);
    background: none;
    color: #f87171;
    cursor: pointer;
    font-size: 0.78em;
    transition: all 0.15s;
}

.funil-limpar:hover { background: rgba(248,113,113,0.1); }

/* Monitor / Dashboard */
.monitor-card {
    max-width: 900px;
    text-align: left;
}

.monitor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.monitor-header h2 { margin: 0; }

.monitor-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.countdown-badge {
    font-size: 0.8em;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 12px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 18px 10px;
    text-align: center;
    transition: background 0.15s, border-color 0.15s;
}

.stat-card.clickable:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
}

.stat-value {
    font-size: 2.2em;
    font-weight: bold;
    color: var(--accent);
    line-height: 1;
}

.stat-andamento .stat-value { color: #fb923c; }
.stat-ok .stat-value        { color: #22c55e; }
.stat-erro .stat-value      { color: #f87171; }

.stat-label {
    font-size: 0.72em;
    color: var(--text-muted);
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.chart-container {
    position: relative;
    height: 420px;
}

.filtro-cns {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Seção Detalhe */
.detalhe-card {
    max-width: 98%;
    width: 98%;
    text-align: left;
}

.detalhe-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--glass-border);
    flex-wrap: wrap;
}

.detalhe-header .btn {
    margin-bottom: 0;
}

.detalhe-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}

.detalhe-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
}

.detalhe-tag {
    background: rgba(255,255,255,0.07);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.85em;
    color: var(--text-main);
}

.detalhe-body {
    display: grid;
    grid-template-columns: 190px 1fr;
    gap: 16px;
    height: calc(100vh - 260px);
    min-height: 500px;
}

.detalhe-split {
    display: flex;
    overflow: hidden;
    gap: 0;
}

.detalhe-lista {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
    border-right: 1px solid var(--glass-border);
    padding-right: 12px;
}

.detalhe-lista-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.detalhe-lista-header input {
    margin: 0;
    padding: 6px 10px;
    font-size: 0.82em;
    height: auto;
}

#lista-matriculas {
    overflow-y: auto;
    flex: 1;
}

.mat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    margin-bottom: 6px;
    transition: background 0.15s;
}

.mat-item:hover {
    background: rgba(255,255,255,0.05);
}

.mat-item.selected {
    background: rgba(0, 201, 255, 0.1);
    border-color: var(--accent);
}

.mat-numero {
    font-weight: bold;
    font-size: 0.95em;
}

.status-mini {
    font-size: 0.65em;
    padding: 2px 6px;
    border-radius: 8px;
    width: fit-content;
}

.status-mini.ok  { background: rgba(34,197,94,0.2);  color: #22c55e; }
.status-mini.err { background: rgba(239,68,68,0.2);  color: #f87171; }
.status-mini.proc{ background: rgba(251,146,60,0.2); color: #fb923c; }

.detalhe-viewer {
    flex: 1 1 auto;
    min-width: 180px;
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: rgba(0,0,0,0.2);
}

.resize-handle-v {
    flex-shrink: 0;
    width: 5px;
    margin: 0 4px;
    border-radius: 3px;
    background: var(--glass-border);
    cursor: col-resize;
    transition: background 0.15s;
}
.resize-handle-v:hover,
.resize-handle-v.is-dragging {
    background: var(--accent);
}

.pdf-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 0.9em;
}

.detalhe-json {
    flex-shrink: 0;
    width: 440px;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-left: 1px solid var(--glass-border);
    padding-left: 14px;
    overflow: hidden;
}

.json-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    flex-shrink: 0;
}

.tab-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8em;
    white-space: nowrap;
    transition: all 0.15s;
}

.tab-btn.active, .tab-btn:hover {
    background: rgba(0, 201, 255, 0.15);
    color: var(--accent);
    border-color: var(--accent);
}

.btn-copiar-json {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 8px;
    line-height: 0;
}

.btn-copiar-json.copiado {
    color: #22c55e;
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.12);
}

.json-viewer {
    flex: 1;
    overflow-y: auto;
    background: rgba(0,0,0,0.35);
    padding: 14px;
    border-radius: 8px;
    font-size: 0.76em;
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    word-break: break-word;
    color: #e2e8f0;
    margin: 0;
    line-height: 1.5;
}

/* Diff viewer */
.diff-viewer {
    white-space: pre-wrap;
    word-break: break-word;
}
.diff-legenda {
    display: flex;
    gap: 16px;
    margin-bottom: 10px;
    font-size: 0.78em;
}
.diff-leg-del { color: #fca5a5; }
.diff-leg-ins { color: #86efac; }
.diff-line {
    display: block;
    padding: 1px 4px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.76em;
    line-height: 1.5;
}
.diff-del { background: rgba(239,68,68,0.18); color: #fca5a5; }
.diff-ins { background: rgba(34,197,94,0.18); color: #86efac; }
.diff-eq  { color: #e2e8f0; }

.diff-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.diff-mode-btn {
    font-size: 0.75em;
    padding: 2px 10px;
    opacity: 0.75;
}
.diff-mode-btn:hover { opacity: 1; }

.diff-fullscreen-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0,0,0,0.82);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.diff-fullscreen-inner {
    background: #1e2535;
    border-radius: 10px;
    width: 100%;
    max-width: 1400px;
    height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
.diff-fullscreen-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}
.diff-fullscreen-titulo {
    font-size: 0.9em;
    font-weight: 600;
    color: #94a3b8;
}
.diff-fullscreen-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 18px;
    white-space: pre-wrap;
    word-break: break-word;
}

.diff-split-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Courier New', monospace;
    font-size: 0.76em;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    table-layout: fixed;
}
.diff-split-table thead th {
    padding: 4px 6px;
    font-size: 0.85em;
    color: #94a3b8;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    text-align: left;
    font-weight: 600;
    width: 50%;
}
.diff-split-table td {
    padding: 1px 6px;
    vertical-align: top;
    width: 50%;
}
.diff-split-table tr:nth-child(even) .diff-split-eq { background: rgba(255,255,255,0.02); }
.diff-split-del  { background: rgba(239,68,68,0.18); color: #fca5a5; }
.diff-split-ins  { background: rgba(34,197,94,0.18); color: #86efac; }
.diff-split-eq   { color: #e2e8f0; }
.diff-split-empty { background: rgba(0,0,0,0.15); }

/* Timeline */
.timeline-viewer {
    flex: 1;
    overflow-y: auto;
    padding: 10px 4px;
}

.tl-item {
    display: flex;
    gap: 10px;
    margin-bottom: 6px;
    align-items: flex-start;
    font-size: 0.78em;
}

.tl-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
    margin-top: 3px;
}

.tl-dot.err { background: #f87171; }
.tl-dot.ok  { background: #22c55e; }
.tl-dot.proc{ background: #fb923c; }

.tl-line {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
}

.tl-status {
    color: var(--text-main);
    font-weight: bold;
}

.tl-ts {
    color: var(--text-muted);
    font-size: 0.88em;
}

.tl-dur {
    display: inline-block;
    margin-left: 6px;
    background: rgba(255,255,255,0.07);
    border-radius: 6px;
    padding: 0 6px;
    color: var(--accent);
    font-size: 0.85em;
}

.tl-dur.lento { color: #fb923c; }

/* Aba Propriedade */
.prop-viewer {
    flex: 1;
    overflow-y: auto;
    padding: 10px 4px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    font-size: 0.8em;
}

.prop-section-title {
    font-size: 0.72em;
    font-weight: bold;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: .07em;
    margin-bottom: 6px;
}

/* Tabela de proprietários */
.prop-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1em;
}
.prop-table th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    padding: 4px 6px;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.9em;
}
.prop-table td {
    padding: 4px 6px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: var(--text-main);
    vertical-align: top;
}
.prop-table td.pct {
    color: var(--accent);
    font-weight: bold;
    white-space: nowrap;
    text-align: right;
}
.prop-conjuge {
    color: var(--text-muted);
    font-size: 0.85em;
}
.prop-cpf {
    color: var(--text-muted);
    font-size: 0.82em;
    font-family: monospace;
    margin-top: 1px;
}
.prop-regime-col {
    vertical-align: top;
    padding-top: 5px;
    white-space: nowrap;
}
.prop-soma {
    margin-top: 6px;
    font-size: 0.82em;
    color: var(--text-muted);
    text-align: right;
}
.prop-soma-warn {
    color: #fb923c;
    font-weight: bold;
}
.prop-regime {
    font-size: 0.78em;
    color: var(--text-muted);
    background: rgba(255,255,255,0.07);
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    padding: 1px 6px;
    white-space: nowrap;
}

/* Ônus */
.onus-item {
    display: flex;
    gap: 8px;
    align-items: baseline;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.onus-badge {
    background: rgba(251,146,60,0.15);
    border: 1px solid rgba(251,146,60,0.4);
    color: #fb923c;
    border-radius: 5px;
    padding: 1px 7px;
    font-size: 0.85em;
    white-space: nowrap;
    flex-shrink: 0;
}
.onus-nome { color: var(--text-main); }
.onus-proto { color: var(--text-muted); font-size: 0.82em; font-style: italic; }
.onus-data { color: var(--text-muted); font-size: 0.88em; margin-left: auto; white-space: nowrap; }

/* Cadeia dominial */
.cadeia-ato {
    border-left: 2px solid var(--glass-border);
    padding-left: 10px;
    margin-bottom: 8px;
}
.cadeia-ato-header {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 3px;
}
.cadeia-ato-id {
    font-weight: bold;
    color: var(--accent);
    font-size: 0.9em;
    white-space: nowrap;
}
.cadeia-ato-nome { color: var(--text-main); }
.cadeia-ato-data { color: var(--text-muted); font-size: 0.85em; }
.cadeia-ato-cancelado { border-left-color: #f87171; opacity: 0.5; }
.cadeia-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 4px;
    font-size: 0.9em;
}
.cadeia-table td {
    padding: 2px 6px;
    vertical-align: middle;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.cadeia-table tr:last-child td { border-bottom: none; }
.cadeia-td-nome  { color: var(--text-main); }
.cadeia-td-pct   { color: var(--accent); font-weight: 600; text-align: right; white-space: nowrap; width: 52px; }
.cadeia-td-area  { color: var(--text-muted); font-size: 0.88em; white-space: nowrap; }
.cadeia-tipo-saiu   { color: #f87171; font-size: 0.78em; font-weight: bold; }
.cadeia-tipo-entrou { color: #22c55e; font-size: 0.78em; font-weight: bold; }
.cadeia-tipo-saldo  { color: var(--text-muted); font-size: 0.78em; font-weight: bold; }

/* Validação badge */
.validacao-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 600;
}
.validacao-ok    { background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.35); color: #22c55e; }
.validacao-warn  { background: rgba(251,146,60,0.12); border: 1px solid rgba(251,146,60,0.35); color: #fb923c; }
.validacao-unk   { background: rgba(156,163,175,0.12); border: 1px solid rgba(156,163,175,0.3); color: #9ca3af; }
.validacao-inc   { margin-top: 6px; font-size: 0.88em; color: #fb923c; }
.validacao-obs   { margin-top: 4px; font-size: 0.85em; color: var(--text-muted); font-style: italic; }

.json-key  { color: #93c5fd; }
.json-str  { color: #86efac; }
.json-num  { color: #fbbf24; }
.json-bool { color: #f87171; }

/* Modal de status */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay.hidden { display: none; }

.modal-box {
    background: #1a3040;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 28px;
    width: 640px;
    max-width: 95vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 { margin: 0; color: var(--accent); }

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.4em;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

.modal-close:hover { color: white; }

.modal-body {
    overflow-y: auto;
    flex: 1;
}

.modal-body table { margin-top: 0; }

.modal-body td, .modal-body th { padding: 9px 10px; }

.modal-row-link {
    color: var(--accent);
    cursor: pointer;
    font-size: 0.82em;
    background: none;
    border: none;
    text-decoration: underline;
    padding: 0;
}

.modal-row-link:hover { opacity: 0.8; }
/* ===== INFRAESTRUTURA ===== */
.infra-card {
    max-width: 98%;
    text-align: left;
    min-height: calc(100vh - 160px);
    box-sizing: border-box;
}

/* Área das tabs: altura mínima para não saltar ao trocar aba */
.infra-tabs-area {
    min-height: 420px;
}

.infra-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.infra-header h2 { margin: 0; }

.infra-tabs { display: flex; gap: 6px; }
.infra-tab-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 0.82em;
    cursor: pointer;
    transition: all 0.15s;
}
.infra-tab-btn.active, .infra-tab-btn:hover {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

/* Grid de servidores de recursos */
.recursos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.recurso-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: box-shadow 0.2s;
}
.recurso-card:hover { box-shadow: 0 0 0 1px var(--accent-muted, rgba(0,201,255,0.25)); }
.recurso-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}
.recurso-card.colapsado .recurso-card-header { margin-bottom: 0; }
.recurso-card-body { /* visible by default */ }
.recurso-card.colapsado .recurso-card-body { display: none; }
.recurso-card-titulo-area { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.recurso-card-header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.recurso-mini-stats { display: flex; gap: 10px; font-size: 0.75em; font-weight: bold; }
.card-seta { font-size: 0.72em; color: var(--text-muted); transition: transform 0.2s; user-select: none; }
.recurso-card.colapsado .card-seta { transform: rotate(180deg); }
.recurso-card-titulo { font-weight: bold; font-size: 0.95em; }
.recurso-card-tipo {
    font-size: 0.72em;
    background: rgba(0,201,255,0.1);
    color: var(--accent);
    border-radius: 6px;
    padding: 2px 8px;
}
.recurso-card-tipo.offline {
    background: rgba(248,113,113,0.15);
    color: #f87171;
}
.recurso-secao { margin-bottom: 12px; }
.recurso-secao-titulo {
    font-size: 0.72em;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.recurso-secao-titulo svg { opacity: 0.75; flex-shrink: 0; }
.recurso-info { font-size: 0.82em; color: var(--text-muted); margin-bottom: 4px; }
.recurso-barra-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}
.recurso-barra-bg {
    flex: 1;
    height: 6px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    overflow: hidden;
}
.recurso-barra-fill {
    height: 100%;
    border-radius: 4px;
    background: #22c55e;
    transition: width 0.4s;
}
.recurso-barra-fill.alerta  { background: #f59e0b; }
.recurso-barra-fill.critico { background: #ef4444; }
.recurso-pct { font-size: 0.78em; color: var(--text-primary); min-width: 34px; text-align: right; }

.disco-item { margin-bottom: 6px; }

/* Processos */
.proc-tabela {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78em;
    margin-top: 6px;
}
.proc-tabela th {
    color: var(--text-muted);
    font-weight: 600;
    text-align: left;
    padding: 3px 6px;
    border-bottom: 1px solid var(--border);
}
.proc-tabela td { padding: 3px 6px; }
.proc-tabela tr:hover td { background: rgba(255,255,255,0.04); }
.proc-cpu-bar {
    display: inline-block;
    height: 5px;
    border-radius: 3px;
    background: var(--accent);
    vertical-align: middle;
    margin-right: 4px;
    opacity: 0.8;
}

/* Consumo da aplicação */
.app-consumo-bar {
    background: rgba(0,201,255,0.06);
    border: 1px solid rgba(0,201,255,0.2);
    border-radius: 10px;
    padding: 12px 16px;
}
.app-consumo-titulo {
    font-size: 0.72em;
    color: var(--accent);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}
.app-consumo-inner {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}
.app-consumo-grupo {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 180px;
}
.app-consumo-grupo-nome {
    font-size: 0.78em;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.app-consumo-grupo-nome svg { opacity: 0.8; flex-shrink: 0; }
.app-consumo-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8em;
    color: var(--text-muted);
}
.app-consumo-item span.val {
    color: var(--text-primary);
    font-weight: 600;
    min-width: 50px;
}

/* --- Nova Tarefa: Dropzone --- */
.nt-dropzone {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.nt-dropzone:hover,
.nt-dropzone.drag-over {
    border-color: var(--accent);
    background: rgba(0, 201, 255, 0.05);
}
.nt-arquivo-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--glass-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    margin-bottom: 6px;
    font-size: 0.82em;
}
.nt-arquivo-item span { color: var(--text-muted); margin-left: 6px; }
.nt-arquivo-remove {
    background: none;
    border: none;
    color: #f87171;
    cursor: pointer;
    font-size: 1em;
    padding: 0 4px;
    line-height: 1;
}

/* Prompts editor */
.prompts-editor {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 16px;
    height: 520px;
}

.prompts-lista {
    list-style: none;
    padding: 0;
    margin: 0;
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    overflow-y: auto;
}

.prompt-item {
    padding: 12px 14px;
    font-size: 0.85em;
    cursor: pointer;
    color: var(--text-muted);
    border-bottom: 1px solid var(--glass-border);
    transition: background 0.15s, color 0.15s;
}

.prompt-item:last-child { border-bottom: none; }

.prompt-item:hover {
    background: rgba(0,201,255,0.07);
    color: var(--text-primary);
}

.prompt-item.ativo {
    background: rgba(0,201,255,0.12);
    color: var(--accent);
    font-weight: 600;
}

.prompts-painel {
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.prompt-textarea {
    flex: 1;
    width: 100%;
    min-height: 400px;
    background: rgba(0,0,0,0.25);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 12px;
    font-family: 'Courier New', monospace;
    font-size: 0.82em;
    line-height: 1.6;
    resize: vertical;
    box-sizing: border-box;
}

.prompt-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

/* Modal de histórico de prompts */
.modal-box-wide {
    width: 1100px;
    max-width: 96vw;
    height: 88vh;
}

.modal-historico-body {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 16px;
    overflow: hidden;
    min-height: 0;
}

.historico-lista-wrap {
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.historico-lista {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

#historico-paginacao {
    border-top: 1px solid var(--glass-border);
    padding: 8px;
    margin-top: 0 !important;
    flex-shrink: 0;
}

.historico-item {
    padding: 10px 12px;
    cursor: pointer;
    color: var(--text-muted);
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.82em;
    transition: background 0.15s, color 0.15s;
}

.historico-item:last-child { border-bottom: none; }

.historico-item:hover {
    background: rgba(0,201,255,0.07);
    color: var(--text-primary);
}

.historico-item.ativo {
    background: rgba(0,201,255,0.12);
    color: var(--accent);
}

.historico-item .historico-data {
    display: block;
    font-weight: 600;
}

.historico-item .historico-usuario {
    display: block;
    font-size: 0.85em;
    opacity: 0.75;
    margin-top: 2px;
}

.historico-diff-wrap {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.historico-diff-container {
    flex: 1;
    overflow: auto;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: #0d1f2d;
}

.historico-diff-container .d2h-wrapper { background: transparent; }
.historico-diff-container .d2h-file-header,
.historico-diff-container .d2h-file-list-header,
.historico-diff-container .d2h-files-diff,
.historico-diff-container .d2h-diff-table { color: #1a1a1a; }

/* Nav dropdowns */
.nav-submenu-wrapper { position: relative; }

.nav-submenu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: var(--bg-card, #1a2a3a);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 6px 0;
    min-width: 180px;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.nav-submenu.aberto { display: block; }

.nav-submenu a {
    display: block;
    padding: 9px 16px;
    cursor: pointer;
    font-size: 0.87em;
    color: var(--text-primary);
    white-space: nowrap;
}

.nav-submenu a:hover { background: rgba(255,255,255,0.07); }

.nav-user-area {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.nav-user-btn {
    background: none;
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.87em;
    padding: 5px 12px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background 0.15s, border-color 0.15s;
}

.nav-user-btn:hover {
    background: rgba(255,255,255,0.07);
    border-color: var(--accent);
}

.nav-user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-card, #1a2a3a);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 6px 0;
    min-width: 160px;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.nav-user-dropdown.aberto { display: block; }

.nav-user-dropdown a {
    display: block;
    padding: 9px 16px;
    cursor: pointer;
    font-size: 0.87em;
    color: var(--text-primary);
    white-space: nowrap;
}

.nav-user-dropdown a:hover { background: rgba(255,255,255,0.07); }

/* Home Dashboard */
.home-card { max-width: 1000px; text-align: left; }

.home-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.home-header h2 { margin: 0; }

.home-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.home-controls .btn {
    margin-bottom: 0;
    height: 34px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
}

.home-section-title {
    font-size: 0.75em;
    color: var(--accent);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin: 22px 0 10px;
}

.home-admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.home-admin-card {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 14px 12px;
    text-align: center;
}

.hac-value { font-size: 1.9em; font-weight: bold; color: var(--accent); }
.hac-label { font-size: 0.75em; color: var(--text-muted); margin-top: 4px; }

.home-workers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
}

.home-worker-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 10px 12px;
}

.hwc-name  { font-size: 0.72em; color: var(--text-muted); margin-bottom: 4px; }
.hwc-count { font-size: 1.3em; font-weight: bold; }

.home-infra-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.home-infra-mini {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 14px;
}

.him-label { font-size: 0.75em; color: var(--text-muted); margin-bottom: 6px; }
.him-value { font-size: 1.6em; font-weight: bold; }

.him-bar {
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
}

.him-bar-fill { height: 100%; border-radius: 2px; transition: width 0.4s; }

.home-docs-row { display: flex; gap: 12px; }

.home-docs-card {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 18px 24px;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.home-docs-card:hover {
    background: rgba(0,201,255,0.08);
    border-color: var(--accent);
}

.hdc-icon  { font-size: 2em; margin-bottom: 6px; }
.hdc-label { font-size: 0.8em; color: var(--text-muted); }
