:root {
  --bg: #f4f7f8;
  --card: #ffffff;
  --ink: #12212b;
  --mut: #5b6b75;
  --line: #d5dee3;
  --acc: #0a6b7c;
  --acc2: #e6f3f5;
  --red: #b3261e;
  --amb: #8a5a00;
  --grn: #1b6b3a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1a20;
    --card: #17262e;
    --ink: #e8f0f3;
    --mut: #93a5af;
    --line: #2b3f49;
    --acc: #4fc3d6;
    --acc2: #12333b;
    --red: #ff8a80;
    --amb: #ffca6b;
    --grn: #7fdc9f;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
header { padding: 14px 16px 0; max-width: 980px; margin: auto; }
h1 { font-size: 1.25rem; margin: 0 0 10px; }
.tabs { display: flex; gap: 6px; }
.tabs button { flex: 1; padding: 10px; border: 1px solid var(--line); border-bottom: none; border-radius: 8px 8px 0 0; background: transparent; color: var(--mut); font: inherit; font-weight: 600; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--acc); }
main { max-width: 980px; margin: auto; padding: 0 16px 24px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 0 0 10px 10px; padding: 16px; margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: 1.8fr 1fr; gap: 20px; }
@media (max-width: 720px) { .grid { grid-template-columns: 1fr; } }
label { display: block; font-weight: 600; margin: 12px 0 4px; font-size: 0.92rem; }
input, select { width: 100%; padding: 9px; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
:focus-visible { outline: 3px solid var(--acc); outline-offset: 1px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.seg { display: flex; gap: 6px; margin-top: 4px; }
.seg button, .btn, .sug button { padding: 9px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); font: inherit; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--acc); border-color: var(--acc); color: var(--card); font-weight: 600; }
.btn.pri { background: var(--acc); border-color: var(--acc); color: var(--card); font-weight: 600; width: 100%; margin-top: 14px; }
.btn.sec { background: var(--acc2); border-color: var(--acc); color: var(--acc); font-weight: 600; margin-top: 10px; width: 100%; }
.sug { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.sug button { font-size: 0.85rem; }
.res { margin-top: 16px; padding: 14px; border-left: 5px solid var(--acc); background: var(--acc2); border-radius: 6px; }
.big { font-size: 2.6rem; font-weight: 700; color: var(--acc); line-height: 1.1; }
.mut { color: var(--mut); font-size: 0.9rem; }
.info { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: 0.95rem; }
.info p { margin: 6px 0; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 0.82rem; font-weight: 600; border: 1px solid currentColor; }
.ok { color: var(--grn); }
.lo { color: var(--amb); }
.hi { color: var(--red); }
.warn { margin-top: 10px; padding: 10px; border: 1px solid var(--amb); border-radius: 6px; color: var(--amb); font-weight: 600; }
.err { color: var(--red); font-weight: 600; }
.item { border: 1px solid var(--line); border-left: 5px solid var(--acc); border-radius: 8px; padding: 12px; margin: 10px 0; }
.item h4 { margin: 0 0 4px; color: var(--acc); }
.item .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
h3 { margin: 16px 0 4px; font-size: 1rem; }
footer { max-width: 980px; margin: auto; padding: 0 16px 24px; color: var(--mut); font-size: 0.82rem; }
[hidden] { display: none !important; }

/* ===== Dual Interactive Cards (Dose <-> Vazão) ===== */
.dual-cards {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: stretch;
  margin-top: 16px;
}

.calc-card {
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}

.calc-card.active-source {
  border-color: var(--acc);
  background: var(--card);
  box-shadow: 0 4px 12px rgba(10, 107, 124, 0.08);
}

.calc-card.computed-target {
  background: var(--acc2);
  border-color: transparent;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.card-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mut);
  margin: 0;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.2;
  white-space: nowrap; /* Mantém a frase em uma linha só para não quebrar */
}

.active-source .mode-badge {
  background: var(--acc);
  color: var(--card);
}

.computed-target .mode-badge {
  background: var(--line);
  color: var(--ink);
}

.input-big-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  margin-bottom: 10px;
}

.calc-card.active-source .input-big-wrap {
  border-color: var(--acc);
}

.input-big-wrap input {
  border: none;
  background: transparent;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--acc);
  padding: 2px 0;
  width: 100%;
  outline: none;
}

.input-big-wrap .unit-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--mut);
  white-space: nowrap;
}

.card-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quick-chips button {
  flex: 1;
  padding: 5px 8px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

.quick-chips button:hover {
  border-color: var(--acc);
  color: var(--acc);
}

.swap-divider {
  display: flex;
  align-items: center;
  justify-content: center;
}

.swap-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--acc2);
  color: var(--acc);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  user-select: none;
}

@media (max-width: 600px) {
  .dual-cards {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .swap-divider {
    padding: 2px 0;
  }
  .swap-circle {
    transform: rotate(90deg);
  }
}

/* ===== Slider de Titulação na BIC ===== */
.range-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 2px;
}

.range-wrap input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: var(--line);
  border-radius: 99px;
  outline: none;
  padding: 0;
  margin: 6px 0;
  border: none;
  cursor: pointer;
}

.range-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--acc);
  border: 3px solid var(--card);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.25);
  cursor: grab;
  transition: transform 0.1s;
}

.range-wrap input[type="range"]::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.15);
}

.range-wrap input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--acc);
  border: 3px solid var(--card);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.25);
  cursor: grab;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--mut);
  font-weight: 600;
}

/* ===== Cabeçalho de Identificação do Paciente (Plano Terapêutico) ===== */
.patient-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 0 16px;
  padding: 12px 14px;
  background: var(--acc2);
  border: 1px solid var(--line);
  border-left: 5px solid var(--acc);
  border-radius: 8px;
}

.patient-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}

.patient-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.metric-pill {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.95rem;
  color: var(--mut);
}

.metric-pill b {
  color: var(--acc);
  font-weight: 700;
  font-size: 1.02rem;
}
