/* Opioides & Corticoides Fácil — Código Onco
   Identidade visual padrão Código Onco (slate/sky, Inter, JetBrains Mono, suporte dark/light mode com contraste AA) */
:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #273548;
  --line: #3b4a60;
  --line-soft: #2c3a4f;
  --text: #f1f5f9;
  --muted: #cbd5e1;
  --faint: #94a3b8;
  --accent: #818cf8;
  --accent-soft: rgba(129, 140, 248, 0.15);
  --on-accent: #0f172a;

  /* Cores semânticas */
  --c-forte: #a5b4fc;
  --c-forte-bg: rgba(99, 102, 241, 0.16);
  --c-fraco: #fcd34d;
  --c-fraco-bg: rgba(245, 158, 11, 0.16);
  --c-cort: #6ee7b7;
  --c-cort-bg: rgba(16, 185, 129, 0.16);
  --c-alert: #fca5a5;
  --c-alert-bg: rgba(239, 68, 68, 0.14);
  --c-warn: #fde68a;
  --c-warn-bg: rgba(217, 119, 6, 0.15);

  --f-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r: 12px;
  --shadow: 0 1px 3px rgba(2, 6, 23, 0.4);
  color-scheme: dark;
}

:root[data-mode="light"] {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --line: #cbd5e1;
  --line-soft: #e2e8f0;
  --text: #0f172a;
  --muted: #334155;
  --faint: #64748b;
  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.10);
  --on-accent: #ffffff;

  --c-forte: #4338ca;
  --c-forte-bg: #eef2ff;
  --c-fraco: #b45309;
  --c-fraco-bg: #fef3c7;
  --c-cort: #047857;
  --c-cort-bg: #ecfdf5;
  --c-alert: #b91c1c;
  --c-alert-bg: #fef2f2;
  --c-warn: #92400e;
  --c-warn-bg: #fffbeb;

  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { font-size: 16px; }
@media (min-width: 980px) { html { font-size: 17px; } }

body {
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.55 var(--f-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--accent); text-underline-offset: 2px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; text-wrap: balance; }
.mono { font-family: var(--f-mono); }

/* Topo / Header */
.top {
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 40;
}
.top-in {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brandrow { display: flex; align-items: center; gap: 12px; min-width: 0; }
.homelink { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo-box {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex: none;
}
.logo-box svg { width: 24px; height: 24px; }
.brand { display: grid; gap: 1px; min-width: 0; }
.brand b { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.015em; line-height: 1.15; }
.brand .subt { color: var(--muted); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tools { display: flex; align-items: center; gap: 8px; flex: none; }
.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
}
.pill-btn:hover { border-color: var(--accent); color: var(--accent); }
.pill-btn svg { width: 16px; height: 16px; flex: none; }

/* Main wrap */
.main-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

/* Navegação por Abas Principais (Sem corte horizontal) */
.main-nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 12px;
}
.nav-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.94rem;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.nav-tab-btn:hover {
  color: var(--text);
  border-color: var(--line);
}
.nav-tab-btn.active {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}
.nav-tab-btn svg { width: 18px; height: 18px; }

/* Calculadoras - Layout em Duas Colunas */
.calc-container {
  display: grid;
  grid-template-columns: minmax(320px, 460px) minmax(340px, 1fr);
  gap: 24px;
  align-items: start;
}
@media (max-width: 860px) {
  .calc-container { grid-template-columns: 1fr; }
}

.calc-panel {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 22px;
  box-shadow: var(--shadow);
}
.panel-header {
  margin-bottom: 18px;
}
.panel-header h2 {
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-header p {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 4px 0 0;
}

/* Formulário de Cálculo */
.form-group {
  margin-bottom: 18px;
}
.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--faint);
  margin-bottom: 6px;
}
.form-control, .form-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.98rem;
  font-family: inherit;
  transition: border-color 0.15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  outline: none;
}
.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Seletor de TCI (Tolerância Cruzada Incompleta) */
.tci-group {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 12px;
}
.tci-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 8px;
}
@media (max-width: 480px) {
  .tci-options { grid-template-columns: 1fr 1fr; }
}
.tci-btn {
  padding: 8px 6px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
}
.tci-btn:hover { border-color: var(--accent); color: var(--text); }
.tci-btn.active {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
  font-weight: 700;
}

/* Caixa de Resultados Verticalizada (Requisito Estrito do Gabriel) */
.result-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.result-header {
  padding: 16px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.result-header h3 {
  font-size: 1.15rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Lista verticalizada spec-box */
.spec-box {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.spec-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0;
  padding: 0;
}
.spec-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.spec-label {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--faint);
  margin: 0;
}
.spec-val {
  font-size: 1.05rem;
  color: var(--text);
  margin: 0;
  line-height: 1.45;
}
.spec-val b { font-weight: 700; color: var(--accent); }
.spec-val.highlight {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--accent);
  font-family: var(--f-mono);
}

/* Destaque da Dose de Resgate */
.rescue-box {
  margin: 16px 20px;
  padding: 16px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 8px;
}
.rescue-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--accent);
  font-size: 0.95rem;
  margin-bottom: 8px;
}
.rescue-val {
  font-size: 1.15rem;
  font-weight: 800;
  font-family: var(--f-mono);
  color: var(--text);
  margin-bottom: 6px;
}
.rescue-desc {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

/* Caixas de Alerta Clínico */
.alert-box {
  margin: 16px 20px;
  padding: 14px 16px;
  border-radius: 8px;
  font-size: 0.88rem;
  line-height: 1.45;
}
.alert-warning {
  background: var(--c-warn-bg);
  border: 1px solid rgba(217, 119, 6, 0.3);
  color: var(--text);
}
.alert-danger {
  background: var(--c-alert-bg);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--text);
}
.alert-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  margin-bottom: 4px;
}
.alert-warning .alert-head { color: var(--c-warn); }
.alert-danger .alert-head { color: var(--c-alert); }

/* Badges e Tags com cores coerentes */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
}
.badge-forte { background: var(--c-forte-bg); color: var(--c-forte); border: 1px solid rgba(99, 102, 241, 0.3); }
.badge-fraco { background: var(--c-fraco-bg); color: var(--c-fraco); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-corticoide { background: var(--c-cort-bg); color: var(--c-cort); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-via { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); font-family: var(--f-mono); font-size: 0.75rem; }

/* Lista de passos clínicos com contadores circulares CSS (Sem duplicação) */
.step-list {
  list-style: none;
  counter-reset: step-cnt;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.step-list li {
  position: relative;
  padding-left: 38px;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--muted);
}
.step-list li::before {
  counter-increment: step-cnt;
  content: counter(step-cnt);
  position: absolute;
  left: 0;
  top: 1px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.step-list li strong { color: var(--text); }

/* Tabela Rápida de Conversão */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.quick-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}
.quick-table th {
  background: var(--surface-2);
  color: var(--faint);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.quick-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
}
.quick-table tr:last-child td { border-bottom: none; }
.quick-table tr:hover td { background: var(--surface-2); }

/* Cards de Fármacos e Toxicidades */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
  margin-top: 20px;
}
.drug-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}
.drug-card:hover { border-color: var(--line); }
.drug-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

/* Guia Cards */
.guide-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.guide-card h2 {
  font-size: 1.3rem;
  margin-bottom: 14px;
  color: var(--text);
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 8px;
}
.guide-highlight {
  background: var(--surface-2);
  border-left: 4px solid var(--accent);
  padding: 14px 18px;
  margin: 16px 0;
  border-radius: 0 8px 8px 0;
  font-size: 0.94rem;
  line-height: 1.55;
}

/* Rodapé */
.foot {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
  color: var(--faint);
  font-size: 0.85rem;
  text-align: center;
}

/* Recursos de navegação do padrão v2 */
.library-tools { display:flex; align-items:center; flex-wrap:wrap; gap:8px; margin:0 0 16px; padding:12px; border:1px solid var(--line-soft); border-radius:var(--r); background:var(--surface); }
.library-tools label { font-weight:700; }
.library-tools input { flex:1 1 240px; min-height:42px; padding:8px 12px; border:1px solid var(--line); border-radius:8px; background:var(--bg); color:var(--text); }
#micLibrary { min-width:42px; min-height:42px; border:1px solid var(--line); border-radius:8px; background:var(--surface-2); color:var(--text); cursor:pointer; }
#micLibrary[hidden] { display:none; }
.card-acts { display:flex; flex-wrap:wrap; gap:8px; margin-top:10px; }
.act-btn { border:1px solid var(--line); border-radius:8px; padding:6px 10px; background:var(--surface-2); color:var(--text); cursor:pointer; }
.fav-btn[aria-pressed="true"] { color:var(--accent); border-color:var(--accent); }
#toast { position:fixed; bottom:22px; left:50%; transform:translateX(-50%); z-index:100; padding:10px 16px; border-radius:10px; background:var(--text); color:var(--bg); opacity:0; pointer-events:none; transition:opacity .2s; }
#toast.show { opacity:1; }
