/* Impacto Causal — reaproveita o design system das outras ferramentas. */
:root[data-theme="dark"]{
  --bg:#0A0A0A; --bg-elevated:#111110; --surface:#151513; --surface-hover:#1D1D1A;
  --border:#2A2A26; --border-soft:#1E1E1B;
  --text:#F3F2ED; --text-dim:#948F84; --text-faint:#5C584F;
  --accent:#D83831; --accent-text:#FF6156; --accent-soft:rgba(216,56,49,.16); --accent-soft-strong:rgba(216,56,49,.30);
  --grid-line:rgba(243,242,237,.07);
  --success:#3FAE6B; --success-soft:rgba(63,174,107,.14);
  --warn:#D89A38; --warn-soft:rgba(216,154,56,.14);
  --blue:#5B8DEF; --blue-soft:rgba(91,141,239,.16);
}
:root[data-theme="light"]{
  --bg:#FBFAF8; --bg-elevated:#FFFFFF; --surface:#FFFFFF; --surface-hover:#F3F2ED;
  --border:#E4E2DB; --border-soft:#ECEAE3;
  --text:#14130F; --text-dim:#716C61; --text-faint:#A8A297;
  --accent:#D83831; --accent-text:#B72B25; --accent-soft:rgba(216,56,49,.08); --accent-soft-strong:rgba(216,56,49,.16);
  --grid-line:rgba(20,19,15,.08);
  --success:#2F8F55; --success-soft:rgba(47,143,85,.10);
  --warn:#B57A1F; --warn-soft:rgba(181,122,31,.10);
  --blue:#3E6FD0; --blue-soft:rgba(62,111,208,.10);
}
*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
body{ background:var(--bg); color:var(--text); font-family:'Inter',system-ui,sans-serif; -webkit-font-smoothing:antialiased; transition:background .35s ease,color .35s ease; }
.mono{ font-family:'IBM Plex Mono',ui-monospace,monospace; }
a{ color:inherit; text-decoration:none; }
button{ font-family:inherit; cursor:pointer; }
input,select,textarea{ font-family:inherit; }
:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; border-radius:4px; }

.app{ max-width:1120px; margin:0 auto; padding:24px 20px 80px; }

header.top{ display:flex; align-items:flex-start; justify-content:space-between; gap:20px; padding-bottom:22px; border-bottom:1px solid var(--border-soft); margin-bottom:26px; flex-wrap:wrap; }
.brand{ display:flex; align-items:center; gap:14px; }
.brand-mark{ width:40px; height:40px; border-radius:10px; background:var(--accent); display:flex; align-items:center; justify-content:center; flex-shrink:0; position:relative; overflow:hidden; color:#fff; }
.brand-mark::after{ content:""; position:absolute; inset:0; background:repeating-linear-gradient(115deg,rgba(255,255,255,.16) 0 2px,transparent 2px 7px); }
.brand-mark svg{ position:relative; z-index:1; width:20px; height:20px; }
.brand-text h1{ margin:0; font-size:19px; font-weight:700; letter-spacing:.01em; }
.brand-text p{ margin:2px 0 0; font-size:12px; color:var(--text-dim); max-width:52ch; }
.top-right{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.live-pill{ display:flex; align-items:center; gap:7px; padding:7px 12px; border:1px solid var(--border); border-radius:100px; font-size:11.5px; color:var(--text-dim); }
.live-dot{ width:7px; height:7px; border-radius:50%; background:var(--accent); }
.icon-btn{ width:36px; height:36px; border-radius:9px; border:1px solid var(--border); background:var(--surface); display:flex; align-items:center; justify-content:center; color:var(--text); transition:all .2s ease; }
.icon-btn:hover{ background:var(--surface-hover); border-color:var(--text-faint); }
.icon-btn svg{ width:17px; height:17px; }

.section-label{ display:flex; align-items:center; gap:10px; margin:0 0 14px; font-size:11.5px; text-transform:uppercase; letter-spacing:.1em; color:var(--text-faint); font-weight:600; }
.section-label .num{ color:var(--accent); }
.section-label::after{ content:""; flex:1; height:1px; background:var(--border-soft); }
.panel{ background:var(--surface); border:1px solid var(--border); border-radius:16px; padding:22px; margin-bottom:22px; }
.panel-title{ margin:0 0 14px; font-size:15px; font-weight:700; display:flex; align-items:baseline; gap:10px; flex-wrap:wrap; }
.provider-caption{ font-size:11.5px; font-weight:500; color:var(--text-faint); }

/* upload */
.dropzone{ min-height:140px; border:1.5px dashed var(--border); border-radius:14px; background:var(--bg-elevated); display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px; text-align:center; padding:20px; cursor:pointer; transition:all .2s ease; }
.dropzone:hover,.dropzone.drag-over{ border-color:var(--accent); background:var(--accent-soft); }
.dropzone svg{ width:26px; height:26px; color:var(--text-faint); }
.dropzone p{ margin:0; font-size:13px; color:var(--text-dim); }
.dropzone .hint{ font-size:11.5px; color:var(--text-faint); max-width:60ch; }
.dropzone input{ display:none; }
.dropzone.has-file{ border-style:solid; border-color:var(--success); background:var(--success-soft); }
.model-link{ display:inline-flex; align-items:center; gap:6px; font-size:12px; color:var(--text-dim); margin-top:10px; }
.model-link:hover{ color:var(--accent-text); }
.model-link svg{ width:13px; height:13px; }

/* config */
.cfg-hint{ margin:0 0 16px; font-size:12.5px; color:var(--text-dim); }
.cfg-grid{ display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-bottom:16px; }
.field{ display:flex; flex-direction:column; gap:6px; margin-bottom:6px; }
.field label{ font-size:12px; font-weight:600; color:var(--text-dim); }
.field label .opt{ color:var(--text-faint); font-weight:400; }
.field select, .field input[type=text], .field input[type=date]{ background:var(--bg-elevated); border:1px solid var(--border); color:var(--text); font-size:13px; padding:9px 11px; border-radius:9px; }
.field select:focus, .field input:focus{ outline:2px solid var(--accent); outline-offset:-1px; }
.field-hint{ font-size:11px; color:var(--text-faint); line-height:1.5; }
.control-list{ display:flex; flex-wrap:wrap; gap:8px; margin-top:4px; }
.control-opt{ display:flex; align-items:center; gap:7px; font-size:12.5px; padding:7px 11px; border:1px solid var(--border); border-radius:9px; background:var(--bg-elevated); cursor:pointer; }
.control-opt input{ width:14px; height:14px; }
.control-opt.on{ border-color:var(--accent); background:var(--accent-soft); }

.periodo-box{ display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-top:16px; }
.periodo{ border:1px solid var(--border); border-radius:12px; padding:12px 14px; background:var(--bg-elevated); }
.periodo-tag{ font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; padding:2px 8px; border-radius:100px; }
.periodo-tag.pre{ background:var(--blue-soft); color:var(--blue); }
.periodo-tag.pos{ background:var(--accent-soft); color:var(--accent-text); }
.periodo-inputs{ display:flex; gap:10px; margin-top:10px; flex-wrap:wrap; }
.periodo-inputs label{ display:flex; align-items:center; gap:6px; font-size:11.5px; color:var(--text-faint); }
.periodo-inputs input{ background:var(--surface); border:1px solid var(--border); color:var(--text); font-size:12px; padding:6px 8px; border-radius:7px; }

.provider-row{ display:flex; align-items:center; gap:12px; margin-top:18px; flex-wrap:wrap; }
.provider-label{ font-size:12px; color:var(--text-dim); font-weight:600; }
.provider-toggle{ display:inline-flex; border:1px solid var(--border); border-radius:100px; padding:3px; background:var(--bg-elevated); }
.provider-btn{ border:none; background:transparent; color:var(--text-dim); font-size:12px; font-weight:600; padding:6px 14px; border-radius:100px; }
.provider-btn.active{ background:var(--accent); color:#fff; }
.gemini-warning{ margin-top:12px; border:1px solid var(--warn); background:var(--warn-soft); border-radius:10px; padding:12px 14px; }
.gemini-warning p{ margin:0 0 8px; font-size:12px; color:var(--text); }
.checkbox-line{ display:flex; align-items:center; gap:8px; font-size:12.5px; }

.btn-primary{ display:inline-flex; align-items:center; gap:8px; background:var(--accent); color:#fff; border:none; padding:11px 22px; font-size:13.5px; font-weight:600; border-radius:10px; }
.btn-primary:hover{ background:#c53129; }
.btn-primary:disabled{ opacity:.5; cursor:not-allowed; }
.btn-secondary{ background:var(--surface); border:1px solid var(--border); color:var(--text); padding:10px 18px; font-size:13px; font-weight:600; border-radius:9px; }
.btn-secondary:hover{ border-color:var(--text-faint); }

#errorBox{ display:none; }
#errorBox.active{ display:block; background:var(--warn-soft); border:1px solid var(--warn); color:var(--warn); font-size:13px; padding:12px 16px; border-radius:10px; margin-bottom:20px; }
#loading{ display:none; align-items:center; gap:12px; font-size:13px; color:var(--text-dim); padding:16px 0 24px; }
#loading.active{ display:flex; }
.spinner{ width:18px; height:18px; border:2px solid var(--border); border-top-color:var(--accent); border-radius:50%; animation:spin .8s linear infinite; }
@keyframes spin{ to{ transform:rotate(360deg); } }

/* resultado */
.verdict{ border:1px solid var(--border); border-left:3px solid var(--text-faint); border-radius:12px; padding:14px 16px; font-size:13.5px; font-weight:600; margin-bottom:18px; background:var(--surface); }
.verdict.sig{ border-left-color:var(--success); }
.verdict.nosig{ border-left-color:var(--warn); }

.stat-row{ display:grid; grid-template-columns:repeat(4,1fr); gap:12px; margin-bottom:22px; }
.stat-card{ background:var(--surface); border:1px solid var(--border); border-radius:14px; padding:16px; display:flex; flex-direction:column; gap:4px; }
.stat-label{ font-size:10.5px; text-transform:uppercase; letter-spacing:.05em; color:var(--text-faint); font-weight:600; }
.stat-value{ font-family:'Space Grotesk',sans-serif; font-size:24px; font-weight:700; letter-spacing:-.01em; }
.stat-value.pos{ color:var(--success); }
.stat-value.neg{ color:var(--accent-text); }
.stat-sub{ font-size:10.5px; color:var(--text-faint); font-family:'IBM Plex Mono',monospace; }

.chart-wrap{ width:100%; overflow-x:auto; }
.chart-wrap svg{ display:block; width:100%; height:auto; min-width:520px; }
.chart-cols{ display:grid; grid-template-columns:1fr 1fr; gap:22px; }
.legend{ display:flex; flex-wrap:wrap; gap:16px; margin-top:12px; font-size:11px; color:var(--text-dim); }
.legend i.sw{ display:inline-block; width:14px; height:3px; border-radius:2px; margin-right:5px; vertical-align:middle; }
.sw-actual{ background:var(--text); }
.sw-cf{ background:var(--blue); }
.sw-band{ background:var(--blue-soft); height:10px !important; border-radius:3px; }
.sw-cut{ background:var(--accent); }

.ci-table{ width:100%; border-collapse:collapse; font-size:12.5px; min-width:420px; }
.ci-table th{ text-align:left; padding:8px 10px; font-size:10px; text-transform:uppercase; letter-spacing:.05em; color:var(--text-faint); font-weight:600; border-bottom:1px solid var(--border); }
.ci-table td{ padding:9px 10px; border-bottom:1px solid var(--border-soft); }
.ci-table td.num-col, .ci-table th.num-col{ text-align:right; font-family:'IBM Plex Mono',monospace; }
.ci-table tr:last-child td{ border-bottom:none; }
.ci-table .row-h{ font-weight:600; color:var(--text-dim); }

.resumo-body{ font-size:13px; line-height:1.7; color:var(--text-dim); white-space:pre-wrap; }
#narrativaBody h4{ margin:14px 0 6px; font-size:13px; }
#narrativaBody p{ margin:0 0 8px; font-size:13px; line-height:1.65; color:var(--text-dim); }
#narrativaBody ul{ margin:4px 0 8px; padding-left:20px; }
#narrativaBody li{ font-size:12.5px; line-height:1.6; color:var(--text-dim); margin-bottom:3px; }
.narr-warn{ font-size:12.5px; color:var(--warn); background:var(--warn-soft); border:1px solid var(--warn); border-radius:9px; padding:10px 12px; }

.actions-row{ margin-top:6px; }
footer.foot{ margin-top:40px; padding-top:18px; border-top:1px solid var(--border-soft); display:flex; justify-content:space-between; flex-wrap:wrap; gap:8px; font-size:11px; color:var(--text-faint); }

@media (max-width:820px){
  .cfg-grid, .periodo-box, .chart-cols, .stat-row{ grid-template-columns:1fr; }
}
