/* ============================================================
   CII — Centro de Inteligência Investigativa
   Tema escuro, inspirado em plataformas de análise/inteligência.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Space+Mono:wght@400;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #0F1318;
  --panel: #161B21;
  --panel-alt: #1C232B;
  --border: #262E37;
  --text: #E7EAEE;
  --muted: #8B94A0;
  --accent: #F2B705;
  --accent-2: #2DD4BF;
  --danger: #E4574C;
  --warn: #F2B705;
  --radius: 8px;
  --font-ui: 'Inter', sans-serif;
  --font-display: 'Space Grotesk', sans-serif;
  --font-mono: 'Space Mono', monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font-ui); }
#app { min-height: 100vh; }
a { color: var(--accent-2); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #333c46; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

button { font-family: var(--font-ui); cursor: pointer; }
input, select, textarea {
  font-family: var(--font-ui); background: var(--panel-alt); border: 1px solid var(--border);
  color: var(--text); border-radius: 5px; padding: 8px 10px; font-size: 13px; width: 100%; margin-bottom: 10px;
}
textarea { min-height: 70px; resize: vertical; }
label { font-size: 11.5px; color: var(--muted); display: block; margin-bottom: 4px; margin-top: 4px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.mono { font-family: var(--font-mono); }
.right { text-align: right; }
.accent { color: var(--accent); }

/* -------- botões -------- */
.btn { border-radius: 6px; padding: 9px 14px; font-size: 12.5px; font-weight: 600; border: 1px solid transparent; }
.btn-primary { background: var(--accent); color: #0F1318; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 5px 9px; font-size: 11.5px; }
.form-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* -------- marca -------- */
.brand-header { display: flex; align-items: center; gap: 14px; padding: 22px 0 26px; }
.brand-header.small { padding: 16px 12px; gap: 10px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #c98f04);
  color: #0F1318; font-family: var(--font-display); font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.brand-header.small .brand-mark { width: 30px; height: 30px; font-size: 11px; }
.brand-title { font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.brand-header.small .brand-title { font-size: 14px; }
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* -------- tela de casos -------- */
.cases-shell { max-width: 980px; margin: 0 auto; padding: 20px 24px 60px; }
.cases-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.cases-toolbar h1 { font-family: var(--font-display); font-size: 22px; margin: 0; }
.cases-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.case-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; cursor: pointer; transition: border-color .15s; }
.case-card:hover { border-color: var(--accent); }
.case-card-name { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.case-card-desc { color: var(--muted); font-size: 12.5px; margin-bottom: 10px; min-height: 32px; }
.case-card-meta { font-size: 11px; color: var(--muted); margin-bottom: 10px; }
.empty-state { grid-column: 1/-1; color: var(--muted); padding: 40px 0; text-align: center; }

/* -------- shell do caso -------- */
.case-shell { display: flex; min-height: 100vh; }
.case-sidebar { width: 250px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.case-name-box { margin: 4px 14px 10px; padding: 8px 10px; background: var(--panel-alt); border-radius: 6px; font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-sidebar nav { flex: 1; padding: 4px 8px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 6px; font-size: 13px; color: var(--muted); cursor: pointer; margin-bottom: 2px; }
.nav-item:hover { color: var(--text); }
.nav-item.active { background: var(--panel-alt); color: var(--accent); }
.nav-icon { width: 16px; text-align: center; opacity: .8; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
.case-main { flex: 1; padding: 24px 30px 60px; overflow-y: auto; max-height: 100vh; }
.screen-title { font-family: var(--font-display); font-size: 21px; margin: 0 0 16px; }

/* -------- painéis e cards -------- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.panel.warn { border-color: var(--danger); color: #ffb4ad; }
.panel h3 { margin-top: 0; font-family: var(--font-display); font-size: 15px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }

.stat-row { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.stat-card { flex: 1; min-width: 150px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat-num { font-family: var(--font-mono); font-size: 22px; color: var(--accent); }
.stat-label { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

.steps { padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.9; }
.steps strong { color: var(--text); }

/* -------- tabelas -------- */
.table-scroll { overflow-x: auto; }
.tbl { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.tbl th, .tbl td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; white-space: nowrap; }
.tbl thead th { background: var(--panel-alt); color: var(--accent); font-family: var(--font-mono); font-weight: 700; font-size: 11.5px; }
.tbl.small th, .tbl.small td { padding: 4px 8px; font-size: 11.5px; }
.tbl tbody tr:nth-child(4n+3) { background: rgba(255,255,255,0.015); }
.detail-row td { background: #0F1318; padding: 10px 16px !important; }
.detail-box { padding: 4px 0; }
.cell-edit { margin: 0; padding: 3px 5px; font-size: 12.5px; }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input { max-width: 320px; margin-bottom: 0; }

/* -------- badges -------- */
.badge { display: inline-block; background: var(--panel-alt); color: var(--accent-2); border-radius: 4px; padding: 2px 8px; font-size: 10.5px; }
.badge.warn { background: #3A2A12; color: var(--accent); }

/* -------- importação / mapeamento -------- */
.mapping-meta { display: flex; gap: 14px; }
.mapping-meta label { flex: 1; }
.mapping-grid { max-height: 360px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; padding: 8px; margin: 10px 0; }
.mapping-row { display: flex; align-items: center; gap: 10px; padding: 5px 4px; }
.mapping-col-name { flex: 1; font-size: 12.5px; font-family: var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mapping-row select, .mapping-row input { margin-bottom: 0; flex: 1; }

/* -------- hipóteses / alertas -------- */
.hyp-list { display: flex; flex-direction: column; gap: 10px; }
.hyp-card { border: 1px solid var(--border); border-left: 4px solid var(--muted); border-radius: 6px; padding: 12px 14px; background: var(--panel-alt); }
.hyp-card.gravidade-alta { border-left-color: var(--danger); }
.hyp-card.gravidade-media { border-left-color: var(--accent); }
.hyp-card.gravidade-baixa { border-left-color: var(--accent-2); }
.hyp-tag { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); text-transform: uppercase; margin-bottom: 6px; }
.hyp-text { font-size: 13px; line-height: 1.5; }
.hyp-actions { margin-top: 8px; display: flex; gap: 8px; align-items: center; }

/* -------- rede -------- */
#networkGraph { background: var(--panel-alt); }

/* -------- dossiê -------- */
.dossie-preview { background: #fff; color: #1a1a1a; border-radius: var(--radius); overflow: hidden; margin-top: 16px; }
.dossie { padding: 40px 46px; font-family: 'Inter', sans-serif; }
.dossie-header { border-bottom: 3px solid #0F1318; padding-bottom: 16px; margin-bottom: 24px; }
.dossie-kicker { font-family: var(--font-mono); font-size: 11px; letter-spacing: 1px; color: #555; }
.dossie h1 { font-family: var(--font-display); font-size: 26px; margin: 4px 0; }
.dossie-sub { font-size: 12px; color: #555; }
.dossie section { margin-bottom: 26px; }
.dossie h2 { font-size: 16px; border-bottom: 1px solid #ddd; padding-bottom: 6px; }
.dossie table { border-collapse: collapse; width: 100%; font-size: 11.5px; margin-top: 8px; }
.dossie th, .dossie td { border: 1px solid #ccc; padding: 5px 8px; text-align: left; }
.dossie th { background: #f2f2f2; }
.dossie ul, .dossie ol { font-size: 13px; line-height: 1.7; }

/* -------- toast -------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel-alt); border: 1px solid var(--border); color: var(--text);
  padding: 10px 18px; border-radius: 8px; font-size: 12.5px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 999; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.warn { border-color: var(--danger); }

.loading { padding: 40px; text-align: center; color: var(--muted); }

@media print {
  .case-sidebar, .panel .form-actions { display: none !important; }
  .case-main { max-height: none; overflow: visible; }
  body { background: #fff; }
}

@media (max-width: 860px) {
  .case-shell { flex-direction: column; }
  .case-sidebar { width: 100%; }
  .case-sidebar nav { display: flex; flex-wrap: wrap; }
  .nav-item { flex: 1 1 45%; }
}
