/* Clínica Arena — identidade visual
   Base: teal de roupa cirúrgica + branco clínico. Cores de significado: triagem de Manchester.
   Tipografia: Archivo (variável em largura) — larga nos títulos, normal no texto. */
@import url("https://fonts.googleapis.com/css2?family=Archivo:wdth,wght@62..125,400..800&display=swap");

:root {
  --scrub: #0e4f5c;
  --scrub-2: #13697a;
  --scrub-ink: #072f37;
  --gaze: #eef3f2;
  --paper: #ffffff;
  --ink: #14262b;
  --muted: #5b6f74;
  --line: #d3dedc;
  --brass: #b7832a;
  --vermelho: #d33a3a;
  --laranja: #e5812a;
  --amarelo: #e3bd2f;
  --verde: #3a9a58;
  --azul: #3b6fc4;
  --ok: #2f8a50;
  --bad: #c43636;
  --radius: 10px;
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-variation-settings: "wdth" 100;
  background: var(--gaze);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-variation-settings: "wdth" 118; line-height: 1.12; margin: 0 0 .5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.9rem); font-weight: 800; }
h2 { font-size: 1.45rem; font-weight: 750; }
h3 { font-size: 1.08rem; font-weight: 700; }
p { margin: 0 0 .8em; max-width: 68ch; }
a { color: var(--scrub-2); }
small, .muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--amarelo); outline-offset: 2px; border-radius: 4px; }

/* ---------- Botões e campos ---------- */
button, .btn {
  font: inherit; font-weight: 650; cursor: pointer; border: 0; border-radius: 8px;
  padding: .7em 1.15em; background: var(--scrub); color: #fff; text-decoration: none;
  display: inline-flex; align-items: center; gap: .5em; line-height: 1.2;
}
button:hover, .btn:hover { background: var(--scrub-2); }
button:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--scrub); box-shadow: inset 0 0 0 1.5px var(--scrub); }
.btn-ghost:hover { background: rgba(14, 79, 92, .07); }
.btn-danger { background: var(--bad); }
.btn-small { padding: .42em .8em; font-size: .9rem; }
input, select, textarea {
  font: inherit; width: 100%; padding: .65em .8em; border: 1.5px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink);
}
textarea { min-height: 120px; resize: vertical; }
label { display: block; font-weight: 600; font-size: .92rem; margin: .7em 0 .3em; }
.row { display: flex; gap: .8rem; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }

/* ---------- Estrutura do app ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.rail {
  background: var(--scrub-ink); color: #cfe2e0; padding: 1.2rem .8rem; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: .2rem;
}
.brand { display: flex; align-items: center; gap: .55rem; color: #fff; font-weight: 800; font-variation-settings: "wdth" 125;
  font-size: 1.12rem; padding: .2rem .5rem 1.1rem; text-decoration: none; }
.brand svg { flex: none; }
.rail a.nav {
  color: #cfe2e0; text-decoration: none; padding: .62rem .75rem; border-radius: 8px; display: flex; gap: .7rem;
  align-items: center; font-weight: 600;
}
.rail a.nav:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.rail a.nav.on { background: var(--scrub); color: #fff; box-shadow: inset 3px 0 0 var(--amarelo); }
.rail .foot { margin-top: auto; font-size: .82rem; color: #8fb0ad; padding: .5rem; }
main.view { padding: 2rem clamp(1rem, 3vw, 2.6rem) 5rem; max-width: 1180px; width: 100%; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; bottom: 0; top: auto; height: auto; width: 100%; flex-direction: row; z-index: 20;
    padding: .35rem; justify-content: space-around; overflow-x: auto; }
  .rail .brand, .rail .foot { display: none; }
  .rail a.nav { flex-direction: column; gap: .1rem; font-size: .68rem; padding: .45rem .3rem; min-width: 0; flex: 1; }
  .rail a.nav span { display: none; }
  .rail a.nav.on span { display: block; }
  .rail a.nav.on { box-shadow: inset 0 3px 0 var(--amarelo); }
  main.view { padding-bottom: 6rem; }
}

/* ---------- Blocos ---------- */
.panel { background: var(--paper); border-radius: var(--radius); padding: 1.3rem 1.4rem; border: 1px solid var(--line); }
.stack > * + * { margin-top: 1rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.chart-row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.tag { display: inline-block; font-size: .78rem; font-weight: 650; padding: .18em .6em; border-radius: 99px;
  background: #e3ecea; color: var(--scrub); }
.tag.demo { background: #fbf1dc; color: #7a5410; }
.tag.ok { background: #e1f1e6; color: var(--ok); }
.tag.bad { background: #f8e1e1; color: var(--bad); }
.empty { text-align: center; padding: 2.4rem 1rem; color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: .8rem 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
table { width: 100%; border-collapse: collapse; font-size: .94rem; }
th { text-align: left; font-weight: 650; color: var(--muted); font-size: .84rem; padding: .5rem .5rem; border-bottom: 1.5px solid var(--line); }
td { padding: .6rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.me td { background: #fdf6e3; font-weight: 650; }

/* ---------- Traçado de ECG (assinatura) ---------- */
.ecg { width: 100%; height: 64px; display: block; }
.ecg path { fill: none; stroke: var(--amarelo); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.ecg.draw path { stroke-dasharray: 6000; stroke-dashoffset: 6000; animation: trace 2.2s ease-out .2s forwards; }
@keyframes trace { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .ecg.draw path { animation: none; stroke-dashoffset: 0; } }

/* Faixa de XP no formato de tira de monitor */
.xpstrip { position: relative; height: 34px; border-radius: 8px; background: #0b3b45; overflow: hidden; }
.xpstrip .fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, rgba(227, 189, 47, .0), rgba(227, 189, 47, .28)); }
.xpstrip svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.xpstrip svg path { fill: none; stroke: var(--amarelo); stroke-width: 1.8; }
.xpstrip .ghost path { stroke: rgba(255, 255, 255, .14); }

/* ---------- Cabeçalho do aluno ---------- */
.monitor { background: var(--scrub-ink); color: #e8f2f0; border-radius: 14px; padding: 1.4rem 1.6rem; }
.monitor h1 { color: #fff; margin-bottom: .2rem; }
.monitor .vitals { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1rem; margin: 1.1rem 0; }
.monitor .v b { display: block; font-size: 1.9rem; font-variation-settings: "wdth" 70; font-weight: 700; color: #fff; line-height: 1; }
.monitor .v span { font-size: .84rem; color: #9fc1bd; }
.monitor .v.streak b { color: var(--amarelo); }

/* ---------- Jogo: caso clínico ---------- */
.chart-head { display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: start; }
.wristband { display: inline-flex; gap: .8rem; align-items: center; background: #fff; border: 1.5px solid var(--line);
  border-left: 6px solid var(--scrub); border-radius: 8px; padding: .55rem .9rem; }
.clock { font-variation-settings: "wdth" 70; font-size: 2rem; font-weight: 700; color: var(--scrub); line-height: 1; }
.clock.late { color: var(--bad); }
.vitalbar { display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; background: var(--scrub-ink); color: #fff;
  border-radius: 8px; padding: .7rem 1rem; font-variant-numeric: tabular-nums; }
.vitalbar span { color: #9fc1bd; font-size: .8rem; margin-right: .3rem; }
.steps { display: flex; gap: .3rem; flex-wrap: wrap; margin: 1rem 0; }
.steps button { background: #fff; color: var(--muted); box-shadow: inset 0 0 0 1.5px var(--line); font-size: .9rem; }
.steps button.on { background: var(--scrub); color: #fff; box-shadow: none; }
.steps button.done { color: var(--scrub); box-shadow: inset 0 0 0 1.5px var(--scrub); }
.pick { display: grid; gap: .5rem; }
.pick button { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); justify-content: space-between;
  text-align: left; font-weight: 500; }
.pick button:hover { box-shadow: inset 0 0 0 1.5px var(--scrub); background: #f6faf9; }
.pick button.sel { box-shadow: inset 0 0 0 2px var(--scrub); background: #e8f2f0; font-weight: 650; }
.pick button.right { box-shadow: inset 0 0 0 2px var(--ok); background: #e7f4ea; }
.pick button.wrong { box-shadow: inset 0 0 0 2px var(--bad); background: #fbeaea; }
.reveal { border-left: 3px solid var(--scrub); padding: .3rem 0 .3rem .9rem; margin: .4rem 0 .2rem; color: var(--ink); }
.cost { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.score-big { font-size: 4.2rem; font-weight: 800; font-variation-settings: "wdth" 62; line-height: .9; color: var(--scrub); }
.bars .b { display: grid; grid-template-columns: 110px 1fr 40px; gap: .6rem; align-items: center; margin: .35rem 0; font-size: .92rem; }
.bars .t { height: 8px; background: #e3ecea; border-radius: 9px; overflow: hidden; }
.bars .t i { display: block; height: 100%; background: var(--scrub); }

/* ---------- Plantão ---------- */
.board { display: grid; grid-template-columns: 300px 1fr; gap: 1rem; }
@media (max-width: 860px) { .board { grid-template-columns: 1fr; } }
.queue .pt { display: grid; grid-template-columns: 8px 1fr auto; gap: .7rem; align-items: center; background: #fff;
  border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem .6rem 0; margin-bottom: .5rem; cursor: pointer;
  width: 100%; text-align: left; color: var(--ink); font-weight: 500; }
.queue .pt .bar { height: 100%; border-radius: 8px 0 0 8px; background: #c9d6d4; align-self: stretch; }
.queue .pt.cur { box-shadow: inset 0 0 0 2px var(--scrub); }
.queue .pt.dead { opacity: .5; text-decoration: line-through; }
.queue .pt.doneit { opacity: .6; }
.c-vermelho { background: var(--vermelho) !important; } .c-laranja { background: var(--laranja) !important; }
.c-amarelo { background: var(--amarelo) !important; } .c-verde { background: var(--verde) !important; }
.c-azul { background: var(--azul) !important; }
.triage { display: grid; grid-template-columns: repeat(5, 1fr); gap: .4rem; }
.triage button { color: #fff; text-transform: none; font-size: .88rem; padding: .7em .3em; justify-content: center; }
.triage button.c-amarelo { color: var(--ink); }
.triage button.sel { outline: 3px solid var(--ink); outline-offset: 2px; }
.wait { font-variant-numeric: tabular-nums; font-size: .82rem; color: var(--muted); }
.wait.hot { color: var(--bad); font-weight: 700; }

/* ---------- Radar ---------- */
.radar text { font-size: 11px; fill: var(--muted); font-family: var(--font); }

/* ---------- Avisos ---------- */
#toast { position: fixed; right: 1rem; bottom: 1rem; z-index: 100; display: grid; gap: .5rem; max-width: 360px; }
#toast div { background: var(--ink); color: #fff; padding: .8rem 1rem; border-radius: 8px; font-size: .94rem; }
#toast div.err { background: var(--bad); }
#toast div.gold { background: var(--brass); }
@media (max-width: 860px) { #toast { bottom: 5rem; } }

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: var(--scrub-ink); }
.auth { background: #fff; border-radius: 14px; padding: 2rem; width: min(420px, 100%); }
.auth .brand { color: var(--scrub-ink); padding: 0 0 1rem; }
.tabs { display: flex; gap: .3rem; border-bottom: 1.5px solid var(--line); margin-bottom: 1rem; }
.tabs button { background: none; color: var(--muted); border-radius: 0; padding: .6em .9em; box-shadow: none; }
.tabs button.on { color: var(--scrub); box-shadow: inset 0 -3px 0 var(--scrub); }
.code-big { font-variation-settings: "wdth" 70; font-size: 3.6rem; font-weight: 800; letter-spacing: .12em; color: var(--scrub); }
.hide { display: none !important; }
