:root {
  /* Precision Health — Cinza frio & Teal */
  --bg:     #D8DEE5;
  --bg-2:   #CDD4DC;
  --paper:  #F5F6F8;
  --line:   #DDE2E8;
  --line-2: #BEC9D4;

  --ink:    #1C2B3A;
  --ink-2:  #4A5E6E;
  --ink-3:  #7A8E9E;
  --ink-4:  #A0B3C4;

  /* accent — teal */
  --accent:   #3AAFA9;
  --accent-2: #DDF4F3;

  /* stage tones */
  --tone-neutral:  #8A9BAB;
  --tone-low:      #2E9B6E;
  --tone-mid:      #C08A10;
  --tone-high:     #C85A2A;
  --tone-critical: #B52020;

  --serif: 'Newsreader', 'Source Serif 4', Georgia, serif;
  --sans:  'Inter Tight', 'Inter', ui-sans-serif, system-ui, sans-serif;
  --mono:  'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  /* aliases — usados em history/login como fallback */
  --border:  var(--line);
  --hover:   var(--bg-2);
  --overlay: oklch(0.18 0.012 220 / 0.48);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; padding: 0; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
input, select { font-family: inherit; font-size: inherit; color: inherit; touch-action: manipulation; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ───────────────────────────── shell ────────────────────────────────────── */

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr;
  background:
    radial-gradient(1400px 700px at 85% -15%, oklch(0.96 0.040 210 / 0.75), transparent 58%),
    radial-gradient(1100px 600px at -5% 115%,  oklch(0.94 0.030 205 / 0.65), transparent 58%),
    radial-gradient(900px  500px at 45% 55%,   oklch(0.97 0.018 215 / 0.40), transparent 65%),
    /* dot grid */
    radial-gradient(circle, oklch(0.50 0.025 215 / 0.055) 0.6px, transparent 0.6px),
    var(--bg);
  background-size: auto, auto, auto, 22px 22px, auto;
}

/* ───────────────────────────── entrance animations ──────────────────────── */

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ───────────────────────────── header ───────────────────────────────────── */

.hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 40px;
  border-bottom: 0.5px solid var(--line);
  animation: slideDown 0.50s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.hd-mark { display: flex; align-items: center; gap: 12px; }
.hd-glyph {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  color: var(--ink);
  border: 0.5px solid var(--line-2);
  border-radius: 50%;
  background: var(--paper);
}
.hd-name {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.01em;
  font-variation-settings: 'opsz' 14;
}
.hd-sub {
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 1px;
}
.hd-meta { display: flex; align-items: center; gap: 24px; }
.hd-pat {
  font-size: 13px;
  color: var(--ink-2);
  display: flex; gap: 8px;
}
.hd-pat-name { font-weight: 500; color: var(--ink); }
.hd-reset {
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: 0.02em;
  padding: 6px 12px;
  border: 0.5px solid var(--line-2);
  border-radius: 999px;
  background: transparent;
  transition: all 0.18s ease;
}
.hd-reset:hover { color: var(--ink); background: var(--paper); border-color: var(--ink-3); }

/* ───────────────────────────── stepper ──────────────────────────────────── */

.stepper {
  display: flex;
  padding: 0 40px;
  gap: 0;
  border-bottom: 0.5px solid var(--line);
  overflow-x: auto;
  animation: slideDown 0.50s cubic-bezier(0.2, 0.8, 0.2, 1) 0.06s both;
}
.step {
  flex: 1; min-width: 140px;
  display: flex; align-items: baseline; gap: 10px;
  padding: 16px 18px 14px;
  border-bottom: 1.5px solid transparent;
  margin-bottom: -1px;
  text-align: left;
  color: var(--ink-4);
  transition: color 0.2s ease, border-color 0.2s ease;
  position: relative;
}
.step:not(:last-child)::after {
  content: '';
  position: absolute;
  right: 0; top: 50%;
  width: 0.5px; height: 20px;
  background: var(--line);
  transform: translateY(-50%);
}
.step-lbl {
  font-size: 13px;
  letter-spacing: -0.005em;
}
.step-lbl-short {
  display: none;
  font-size: 11px;
  letter-spacing: -0.005em;
}
.step.is-current { color: var(--ink); border-bottom-color: var(--ink); }
.step.is-current .step-idx { color: var(--accent); }
.step.is-done { color: var(--ink-2); }
.step.is-done .step-idx { color: var(--ink-3); }
.step.is-todo { cursor: not-allowed; }
.step:not(:disabled):hover { color: var(--ink); }

/* ───────────────────────────── stage / card ─────────────────────────────── */

.stage {
  display: grid;
  place-items: start center;
  padding: 56px 40px 80px;
}
.stage--single {
  display: block;
  padding: 40px 0 80px;
}

.card {
  width: min(720px, 100%);
  background: var(--paper);
  border: 0.5px solid var(--line);
  border-radius: 18px;
  padding: 44px 48px 28px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.85) inset,
    inset 0 2px 0 var(--accent),
    0 0 0 0.5px var(--line),
    0 40px 100px -40px rgba(40,30,10,0.22),
    0 8px 30px -10px rgba(40,30,10,0.08);
  animation: cardIn 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to   { opacity: 1; transform: none; }
}

.card-hd { margin-bottom: 32px; }
.card-eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.card-eyebrow::before {
  content: '';
  display: inline-block;
  width: 16px; height: 1px;
  background: var(--accent);
  opacity: 0.6;
  flex-shrink: 0;
}
.card-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 32px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
  font-variation-settings: 'opsz' 28;
  color: var(--ink);
  text-wrap: pretty;
}
.card-hint {
  font-size: 14px;
  color: var(--ink-2);
  margin: 0;
  max-width: 56ch;
  text-wrap: pretty;
}

.card-body { min-height: 280px; }

.card-ft {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 32px;
  padding-top: 22px;
  border-top: 0.5px solid var(--line);
}

/* ───────────────────────────── form bits ────────────────────────────────── */

.form { display: flex; flex-direction: column; gap: 22px; }
.form-row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 22px; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field-lbl {
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.inp {
  width: 100%;
  border: none;
  border-bottom: 0.5px solid var(--line-2);
  background: transparent;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.01em;
  padding: 6px 0 10px;
  outline: none;
  color: var(--ink);
  font-variation-settings: 'opsz' 18;
  transition: border-color 0.2s ease;
}
.inp::placeholder { color: var(--ink-4); }
.inp:focus { border-color: var(--accent); }

.inp-suffix {
  display: flex; align-items: baseline;
  border-bottom: 0.5px solid var(--line-2);
  gap: 8px;
}
.inp-suffix .inp { border: none; padding: 6px 0 10px; }
.inp-suffix > span {
  font-size: 13px;
  color: var(--ink-3);
  padding-bottom: 12px;
}

.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 0.5px solid var(--line-2);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
  background: oklch(0.97 0.008 215);
}
.seg-opt {
  padding: 8px 10px;
  font-size: 13px;
  color: var(--ink-2);
  border-radius: 7px;
  transition: all 0.15s ease;
}
.seg-opt:hover { color: var(--ink); }
.seg-opt.is-active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 0 0 0.5px var(--line-2);
}

/* ───────────────────────────── CID step ─────────────────────────────────── */

.cid { display: flex; flex-direction: column; gap: 18px; }
.cid-search {
  display: flex; align-items: center; gap: 12px;
  border: 0.5px solid var(--line-2);
  border-radius: 12px;
  padding: 12px 16px;
  background: oklch(0.985 0.005 215);
  transition: all 0.2s ease;
}
.cid-search:focus-within {
  border-color: var(--accent);
  background: var(--paper);
  box-shadow: 0 0 0 3px oklch(0.55 0.13 185 / 0.08);
}
.cid-search-icon { color: var(--ink-3); flex-shrink: 0; }
.cid-search-inp {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 15px;
  color: var(--ink);
}
.cid-search-inp::placeholder { color: var(--ink-4); }

.cid-results {
  display: flex; flex-direction: column;
  max-height: 360px;
  overflow-y: auto;
  border: 0.5px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
}
.cid-row {
  display: grid;
  grid-template-columns: 160px 1fr 24px;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  text-align: left;
  border-bottom: 0.5px solid var(--line);
  transition: background 0.12s ease;
}
.cid-row:last-child { border-bottom: none; }
.cid-row:hover { background: var(--bg-2); }
.cid-row.is-selected { background: oklch(0.96 0.04 210); }
.cid-row-codes { display: flex; gap: 5px; flex-wrap: wrap; }
.cid-code {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 3px 7px;
  background: oklch(0.94 0.012 215);
  border-radius: 4px;
  color: var(--ink-2);
  letter-spacing: 0.02em;
}
.cid-row.is-selected .cid-code { background: oklch(0.90 0.05 210); color: var(--ink); }
.cid-code-more { background: transparent; }
.cid-row-name {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 2px;
  font-variation-settings: 'opsz' 16;
}
.cid-row-desc {
  font-size: 12.5px;
  color: var(--ink-3);
}
.cid-row-arrow {
  font-size: 14px;
  color: var(--ink-4);
  text-align: center;
}
.cid-row.is-selected .cid-row-arrow { color: var(--accent); }
.cid-empty {
  padding: 28px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}

/* ───────────────────────────── TNM step ─────────────────────────────────── */

.tnm { display: flex; flex-direction: column; gap: 8px; }
.tnm-opt {
  display: grid;
  grid-template-columns: 80px 1fr 24px;
  align-items: center;
  gap: 18px;
  padding: 16px 20px;
  text-align: left;
  border: 0.5px solid var(--line-2);
  border-radius: 12px;
  background: var(--paper);
  transition: all 0.16s ease;
}
.tnm-opt:hover { border-color: var(--ink-3); transform: translateY(-1px); box-shadow: 0 4px 12px -4px rgba(10,20,40,0.10); }
.tnm-opt.is-active {
  border-color: var(--accent);
  background: oklch(0.990 0.015 210);
  box-shadow:
    0 0 0 3px oklch(0.55 0.13 185 / 0.10),
    0 4px 16px -4px oklch(0.55 0.13 185 / 0.14);
  transform: translateY(-1px);
}
.tnm-opt-tag {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variation-settings: 'opsz' 24;
}
.tnm-opt.is-active .tnm-opt-tag { color: var(--accent); }
.tnm-opt-desc {
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.45;
}
.tnm-opt-mark {
  font-size: 18px;
  color: var(--ink-4);
  text-align: center;
}
.tnm-opt.is-active .tnm-opt-mark { color: var(--accent); }

/* ───────────────────────────── result ───────────────────────────────────── */

.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--ink-3);
  font-size: 14px;
}

.result {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin: -8px -8px 0;
  border-radius: 14px;
  overflow: hidden;
  border: 0.5px solid var(--line);
  --tone: var(--tone-mid);
}
.result.tone-neutral { --tone: var(--tone-neutral); }
.result.tone-low { --tone: var(--tone-low); }
.result.tone-mid { --tone: var(--tone-mid); }
.result.tone-high { --tone: var(--tone-high); }
.result.tone-critical { --tone: var(--tone-critical); }

.result-summary {
  padding: 48px 36px 56px;
  background: var(--tone);
  color: oklch(0.985 0.003 215);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 340px;
  position: relative;
  overflow: hidden;
  text-align: left;
}
.result-summary-inner {
  display: inline-flex; flex-direction: column; align-items: flex-start;
  position: relative; z-index: 1;
}
.result-summary::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 80% 0%,  rgba(255,255,255,0.20), transparent 55%),
    radial-gradient(circle at 10% 90%, rgba(0,0,0,0.12),        transparent 50%);
  pointer-events: none;
  z-index: 0;
}
/* ghost number backdrop */
.result-ghost {
  position: absolute;
  right: -0.05em;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--serif);
  font-weight: 300;
  font-variation-settings: 'opsz' 72;
  font-size: 340px;
  line-height: 1;
  letter-spacing: -0.04em;
  color: rgba(255,255,255,0.07);
  pointer-events: none;
  user-select: none;
  z-index: 0;
  transition: color 0.6s ease;
}
.result.is-revealed .result-ghost { color: rgba(255,255,255,0.11); }

.result-eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.7);
  position: relative;
}

.result-stage {
  display: flex; align-items: baseline; justify-content: center;
  font-family: var(--serif);
  font-weight: 300;
  font-variation-settings: 'opsz' 60;
  line-height: 0.9;
  letter-spacing: -0.04em;
  position: relative;
}
.result-roman {
  font-size: 186px;
  display: inline-block;
  opacity: 0;
  transform: translateY(28px) scale(0.96);
  transition: opacity 0.75s cubic-bezier(0.16, 1, 0.3, 1) 0.10s,
              transform 0.75s cubic-bezier(0.16, 1, 0.3, 1) 0.10s;
  text-shadow: 0 8px 40px rgba(0,0,0,0.18);
}
.result-suffix {
  font-size: 68px;
  margin-left: 4px;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  transition: opacity 0.65s cubic-bezier(0.16, 1, 0.3, 1) 0.38s,
              transform 0.65s cubic-bezier(0.16, 1, 0.3, 1) 0.38s;
}
.result.is-revealed .result-roman,
.result.is-revealed .result-suffix {
  opacity: 1;
  transform: none;
}
.result.is-revealed .result-detail {
  animation: fadeUp 0.55s cubic-bezier(0.16, 1, 0.3, 1) 0.25s both;
}
.result-label {
  font-family: var(--mono);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: rgba(255,255,255,0.85);
  position: relative;
  margin-bottom: 6px;
  margin-left: 8px;
  align-self: flex-start;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s ease 0.05s, transform 0.5s ease 0.05s;
}
.result.is-revealed .result-label { opacity: 1; transform: none; }

.result-detail {
  padding: 32px 32px 28px;
  background: var(--paper);
  display: flex; flex-direction: column; gap: 22px;
}

.result-tnm {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.atom {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 14px 16px;
  border: 0.5px solid var(--line-2);
  border-radius: 10px;
  background: var(--bg-2);
}
.atom-k {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 4px;
}
.atom-v {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 400;
  color: var(--ink);
  line-height: 1;
  font-variation-settings: 'opsz' 22;
}

.result-list {
  display: flex; flex-direction: column;
  margin: 0;
  gap: 0;
}
.result-list > div {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 0.5px solid var(--line);
  font-size: 13px;
}
.result-list > div:last-child { border-bottom: none; }
.result-list dt {
  margin: 0;
  color: var(--ink-3);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  align-self: center;
}
.result-list dd { margin: 0; color: var(--ink); }

.result-disclaimer {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink-3);
  padding-top: 14px;
  border-top: 0.5px solid var(--line);
  text-wrap: pretty;
}

/* ───────────────────────────── buttons ──────────────────────────────────── */

.btn {
  font-size: 13.5px;
  letter-spacing: 0.005em;
  padding: 11px 22px;
  border-radius: 999px;
  transition: all 0.16s ease;
  font-weight: 500;
}
.btn-ghost { color: var(--ink-2); padding-left: 8px; }
.btn-ghost:hover:not(:disabled) { color: var(--ink); }
.btn-ghost:disabled { color: var(--ink-4); cursor: not-allowed; }

.btn-primary {
  background: var(--ink);
  color: oklch(0.985 0.005 215);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.btn-primary:hover:not(:disabled) {
  background: oklch(0.16 0.014 220);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.btn-primary:disabled {
  background: var(--line-2);
  color: var(--ink-4);
  cursor: not-allowed;
  box-shadow: none;
}

/* ───────────────────────────── single-page ──────────────────────────────── */

.single {
  width: min(820px, 100%);
  margin: 0 auto;
  padding: 0 40px;
  display: flex; flex-direction: column;
  gap: 56px;
}
.single-sec {
  background: var(--paper);
  border: 0.5px solid var(--line);
  border-radius: 14px;
  padding: 28px 32px;
}
.single-h {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.015em;
  margin: 0 0 20px;
  color: var(--ink);
  font-variation-settings: 'opsz' 18;
  padding-bottom: 14px;
  border-bottom: 0.5px solid var(--line);
}

/* ───────────────────────────── responsive ───────────────────────────────── */

@media (max-width: 720px) {
  .hd {
    padding: 14px max(20px, env(safe-area-inset-right)) 14px max(20px, env(safe-area-inset-left));
    flex-wrap: wrap;
    gap: 8px;
  }
  .hd-user { display: none; }
  .stepper {
    padding: 0 max(12px, env(safe-area-inset-left));
    -webkit-overflow-scrolling: touch;
  }
  .step { min-width: 52px; padding: 10px 6px; flex: 1; }
  .step-lbl { display: none; }
  .step-lbl-short { display: inline; }
  .stage {
    padding: 24px max(16px, env(safe-area-inset-right)) max(60px, calc(60px + env(safe-area-inset-bottom))) max(16px, env(safe-area-inset-left));
  }
  .stage--single {
    padding: 24px 0 max(60px, calc(60px + env(safe-area-inset-bottom)));
  }
  .card { padding: 24px 20px 20px; border-radius: 14px; }
  .card-title { font-size: 24px; }
  .card-body { min-height: auto; }
  .form-row { grid-template-columns: 1fr; }
  .result { grid-template-columns: 1fr; }
  .result-summary { min-height: 200px; padding: 32px 24px; }
  .result-roman { font-size: 110px; }
  .result-suffix { font-size: 44px; }
  .result-ghost { font-size: 220px; }
  .result-detail { padding: 24px 20px 20px; }
  .cid-row { grid-template-columns: 1fr; gap: 6px; }
  .cid-row-arrow { display: none; }
  .tnm-opt { grid-template-columns: 56px 1fr 20px; gap: 10px; padding: 14px 14px; min-height: 56px; }
  .tnm-opt-tag { font-size: 20px; }
  .single { padding: 0 max(16px, env(safe-area-inset-left)); gap: 32px; }
  .single-sec { padding: 20px 18px; }
  .card-ft { margin-top: 20px; padding-top: 16px; }
  .login-card { padding: 36px 28px 28px; }
}

@media (max-width: 480px) {
  .card { padding: 20px 16px 16px; border-radius: 12px; }
  .card-title { font-size: 22px; }
  .card-hint { font-size: 13px; }
  .tnm-opt { grid-template-columns: 44px 1fr; gap: 10px; }
  .tnm-opt-mark { display: none; }
  .result-roman { font-size: 90px; }
  .result-suffix { font-size: 36px; }
  .result-ghost { font-size: 180px; }
  .result-summary { padding: 28px 20px; min-height: 180px; }
  .result-detail { padding: 18px 16px 16px; gap: 16px; }
  .result-tnm { gap: 8px; }
  .atom { padding: 10px 12px; }
  .atom-v { font-size: 20px; }
  .step { min-width: 44px; padding: 8px 4px; }
  .hd-actions { gap: 2px; }
  .inp { font-size: 19px; }
  .single { gap: 24px; }
  .single-sec { padding: 18px 14px; }
  .login-card { padding: 28px 20px 24px; }
}


/* ─── LOGIN ──────────────────────────────────────────────────── */
.app-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  font-size: 14px;
  opacity: 0.5;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 390px;
  padding: 44px 40px 36px;
  background: var(--paper);
  border: none;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.85) inset,
    inset 0 2px 0 var(--accent),
    0 0 0 0.5px var(--line),
    0 40px 100px -40px rgba(40,30,10,0.22),
    0 8px 30px -10px rgba(40,30,10,0.08);
  animation: fadeUp 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.login-logo {
  margin-bottom: 8px;
  color: var(--accent);
  opacity: 0.85;
}

.login-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 26px;
  margin: 0;
  letter-spacing: -.025em;
  font-variation-settings: 'opsz' 22;
  color: var(--ink);
}

.login-sub {
  font-size: 12.5px;
  color: var(--ink-3);
  margin: 0 0 18px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-family: var(--mono);
}

.login-sent {
  text-align: center;
  font-size: 14px;
  line-height: 1.6;
}

.login-hint { opacity: 0.55; font-size: 13px; }

/* ─── AUTH TABS ──────────────────────────────────────────────── */
.auth-tabs {
  display: flex;
  width: 100%;
  border: 0.5px solid var(--line-2);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
  background: oklch(0.97 0.008 215);
  margin-bottom: 20px;
}
.auth-tab {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 7px;
  color: var(--ink-3);
  transition: all 0.15s ease;
  font-family: var(--sans);
  cursor: pointer;
}
.auth-tab:hover { color: var(--ink); }
.auth-tab.is-active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 0 0 0.5px var(--line-2);
}

/* ─── AUTH SWITCH HINT ───────────────────────────────────────── */
.auth-switch-hint {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--ink-3);
  text-align: center;
}
.auth-switch-link {
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}
.auth-switch-link:hover { opacity: 0.75; }

/* ─── REGISTER FORM ──────────────────────────────────────────── */
.reg-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
}
.reg-cpf-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.reg-cpf-inp { padding-right: 80px; }
.reg-cpf-badge {
  position: absolute;
  right: 0;
  bottom: 12px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: 999px;
  pointer-events: none;
}
.reg-cpf-badge.is-ok  { color: var(--tone-low);  background: oklch(0.93 0.06 145); }
.reg-cpf-badge.is-err { color: var(--tone-high); background: oklch(0.95 0.04 25); }
.reg-cpf-inp.is-valid  { border-color: var(--tone-low); }
.reg-cpf-inp.is-invalid { border-color: var(--tone-high); }
.reg-cpf-hint {
  font-size: 10.5px;
  color: var(--ink-4);
  margin-top: 4px;
}

.login-code-inp {
  font-size: 36px !important;
  letter-spacing: 0.18em;
  text-align: center;
  font-family: var(--mono) !important;
}

.login-error-box {
  width: 100%;
  background: oklch(0.97 0.03 25);
  border: 0.5px solid oklch(0.78 0.10 25);
  border-radius: 10px;
  padding: 12px 14px;
}
.login-error {
  color: oklch(0.40 0.16 25);
  font-size: 13px;
  margin: 0;
  line-height: 1.5;
}

/* ─── HEADER ACTIONS ─────────────────────────────────────────── */
.hd-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.hd-user {
  font-size: 12px;
  opacity: 0.45;
  padding: 0 6px;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── HISTÓRICO ──────────────────────────────────────────────── */
.history-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeUp 0.22s ease both;
}

@media (min-width: 600px) {
  .history-overlay { align-items: center; }
}

.history-panel {
  background: var(--paper);
  width: 100%;
  max-width: 620px;
  max-height: 80vh;
  border-radius: 20px 20px 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 0 0 0.5px var(--line),
    0 -20px 60px -10px rgba(40,30,10,0.18);
  animation: fadeUp 0.30s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@media (min-width: 600px) {
  .history-panel { border-radius: 20px; }
}

.history-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 0.5px solid var(--line);
  flex-shrink: 0;
}

.history-title {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 400;
  font-variation-settings: 'opsz' 16;
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--ink);
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
  overflow-y: auto;
  flex: 1;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 24px;
  border-bottom: 0.5px solid var(--line);
  transition: background .12s;
}

.history-item:last-child { border-bottom: none; }
.history-item:hover { background: var(--hover, rgba(0,0,0,.03)); }

.history-item-main {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.history-stage {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 400;
  font-variation-settings: 'opsz' 16;
  letter-spacing: -0.01em;
  min-width: 56px;
  text-align: center;
  padding: 5px 10px;
  border-radius: 8px;
  background: oklch(0.94 0.012 215);
  color: var(--ink-2);
  flex-shrink: 0;
  border: 0.5px solid var(--line-2);
}

.history-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.history-info strong {
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-meta {
  font-size: 12px;
  opacity: 0.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-date {
  font-size: 11px;
  opacity: 0.38;
}

.history-del {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  opacity: 0.25;
  padding: 4px 8px;
  border-radius: 6px;
  transition: opacity .12s, background .12s;
  flex-shrink: 0;
}

.history-del:hover { opacity: 0.7; background: rgba(200,0,0,.08); }

.history-item.is-confirming { background: rgba(200,0,0,.04); }

.history-del-confirm {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.history-del-prompt {
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
}
.history-del-yes,
.history-del-no {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  border: 0.5px solid var(--line-2);
  background: transparent;
  cursor: pointer;
  font-family: var(--sans);
  transition: all 0.14s ease;
}
.history-del-yes {
  color: oklch(0.42 0.18 25);
  border-color: oklch(0.72 0.12 25);
}
.history-del-yes:hover:not(:disabled) {
  background: oklch(0.42 0.18 25);
  color: white;
  border-color: oklch(0.42 0.18 25);
}
.history-del-yes:disabled { opacity: 0.5; cursor: not-allowed; }
.history-del-no  { color: var(--ink-3); }
.history-del-no:hover  { color: var(--ink); border-color: var(--ink-3); }

/* ─── HISTORY STAGE TONE COLORS ─────────────────────────────── */
.history-stage.tone-neutral  { color: var(--tone-neutral);  background: oklch(0.94 0.012 215);   border-color: oklch(0.86 0.015 215); }
.history-stage.tone-low      { color: oklch(0.38 0.12 145); background: oklch(0.93 0.060 145);  border-color: oklch(0.82 0.08 145); }
.history-stage.tone-mid      { color: oklch(0.42 0.10 75);  background: oklch(0.93 0.045 78);   border-color: oklch(0.82 0.06 76);  }
.history-stage.tone-high     { color: oklch(0.42 0.14 40);  background: oklch(0.95 0.045 38);   border-color: oklch(0.82 0.08 38);  }
.history-stage.tone-critical { color: oklch(0.38 0.18 25);  background: oklch(0.94 0.060 22);   border-color: oklch(0.80 0.10 22);  }

/* ─── PATIENT SIDEBAR (right panel) ─────────────────────────── */

.rsb {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 340px;
  background: var(--paper);
  border-left: 0.5px solid var(--line);
  z-index: 120;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.40s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -24px 0 80px -20px rgba(10,20,40,0.14);
}
.rsb.is-open { transform: none; }

/* header */
.rsb-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 16px;
  border-bottom: 0.5px solid var(--line);
  flex-shrink: 0;
}
.rsb-title {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 400;
  font-variation-settings: 'opsz' 16;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.rsb-close {
  font-size: 18px;
  color: var(--ink-4);
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.12s;
  line-height: 1;
}
.rsb-close:hover { color: var(--ink); background: var(--bg-2); }
.rsb-back {
  font-size: 11.5px;
  color: var(--ink-3);
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.12s;
  font-family: var(--sans);
}
.rsb-back:hover { color: var(--ink); background: var(--bg-2); }

/* list */
.rsb-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 6px 0;
}
.rsb-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  text-align: left;
  width: 100%;
  border-bottom: 0.5px solid var(--line);
  transition: background 0.12s;
}
.rsb-item:last-child { border-bottom: none; }
.rsb-item:hover { background: var(--bg-2); cursor: pointer; }

.rsb-item-stage {
  font-family: var(--serif);
  font-size: 14.5px;
  font-weight: 400;
  font-variation-settings: 'opsz' 14;
  min-width: 52px;
  text-align: center;
  padding: 4px 8px;
  border-radius: 7px;
  background: oklch(0.94 0.012 215);
  border: 0.5px solid var(--line-2);
  flex-shrink: 0;
  color: var(--ink-2);
}
.rsb-item-stage.tone-neutral  { color: oklch(0.42 0.02 215); background: oklch(0.94 0.012 215);  border-color: oklch(0.86 0.015 215); }
.rsb-item-stage.tone-low      { color: oklch(0.38 0.12 145); background: oklch(0.93 0.060 145); border-color: oklch(0.82 0.08 145); }
.rsb-item-stage.tone-mid      { color: oklch(0.42 0.10 75);  background: oklch(0.93 0.045 78);  border-color: oklch(0.82 0.06 76);  }
.rsb-item-stage.tone-high     { color: oklch(0.42 0.14 40);  background: oklch(0.95 0.045 38);  border-color: oklch(0.82 0.08 38);  }
.rsb-item-stage.tone-critical { color: oklch(0.38 0.18 25);  background: oklch(0.94 0.060 22);  border-color: oklch(0.80 0.10 22);  }

.rsb-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rsb-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rsb-item-meta {
  font-size: 11.5px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rsb-item-date {
  font-size: 10.5px;
  color: var(--ink-4);
  font-family: var(--mono);
  letter-spacing: 0.02em;
}
.rsb-item-arrow {
  color: var(--ink-4);
  font-size: 14px;
  flex-shrink: 0;
}

/* list footer */
.rsb-ft {
  padding: 14px 20px;
  border-top: 0.5px solid var(--line);
  flex-shrink: 0;
}
.rsb-ft-link {
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
  transition: opacity 0.14s;
  font-family: var(--sans);
}
.rsb-ft-link:hover { opacity: 0.7; }

/* detail view */
.rsb-detail {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  --tone: var(--tone-mid);
}
.rsb-detail.tone-neutral  { --tone: var(--tone-neutral); }
.rsb-detail.tone-low      { --tone: var(--tone-low); }
.rsb-detail.tone-mid      { --tone: var(--tone-mid); }
.rsb-detail.tone-high     { --tone: var(--tone-high); }
.rsb-detail.tone-critical { --tone: var(--tone-critical); }

.rsb-detail-summary {
  padding: 28px 24px 32px;
  background: var(--tone);
  color: oklch(0.985 0.003 215);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  animation: fadeUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.rsb-detail-summary::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 80% 0%, rgba(255,255,255,0.16), transparent 55%);
  pointer-events: none;
}
.rsb-detail-ghost {
  position: absolute;
  right: -0.05em; top: 50%;
  transform: translateY(-50%);
  font-family: var(--serif);
  font-weight: 300;
  font-variation-settings: 'opsz' 72;
  font-size: 160px;
  line-height: 1;
  letter-spacing: -0.04em;
  color: rgba(255,255,255,0.10);
  pointer-events: none;
  user-select: none;
}
.rsb-detail-label {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.60);
  margin-bottom: 4px;
  position: relative;
}
.rsb-detail-stage {
  font-family: var(--serif);
  font-weight: 300;
  font-variation-settings: 'opsz' 60;
  font-size: 72px;
  line-height: 0.9;
  letter-spacing: -0.04em;
  color: rgba(255,255,255,0.97);
  position: relative;
}
.rsb-detail-patient {
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255,255,255,0.92);
  margin-top: 14px;
  position: relative;
}
.rsb-detail-submeta {
  font-size: 12px;
  color: rgba(255,255,255,0.60);
  margin-top: 3px;
  position: relative;
}

.rsb-detail-body {
  padding: 20px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) 0.06s both;
}
.rsb-detail-tnm {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.rsb-detail-rows {
  border: 0.5px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.rsb-detail-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 0.5px solid var(--line);
}
.rsb-detail-row:last-child { border-bottom: none; }
.rsb-detail-row dt {
  margin: 0;
  color: var(--ink-3);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-family: var(--mono);
  align-self: center;
}
.rsb-detail-row dd {
  margin: 0;
  color: var(--ink);
  font-size: 12.5px;
  line-height: 1.4;
}

/* states */
.rsb-loading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-4);
  font-size: 13px;
}
.rsb-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}
.rsb-empty span:last-child { font-size: 12px; color: var(--ink-4); }

/* header active state */
.hd-reset.is-active {
  color: var(--accent);
  background: oklch(0.92 0.04 210);
  border-color: oklch(0.82 0.05 210);
}

/* responsive */
@media (max-width: 720px) {
  .rsb {
    width: 100%;
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ─── BTN-SAVE (resultado) ───────────────────────────────────── */
.result-actions { margin-top: 8px; }
.btn-save {
  font-size: 13.5px;
  letter-spacing: 0.005em;
  padding: 11px 24px;
  border-radius: 999px;
  font-weight: 500;
  transition: all 0.18s ease;
  border: 0.5px solid var(--line-2);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}
.btn-save:hover:not(:disabled) {
  border-color: var(--ink-3);
  background: var(--bg-2);
}
.btn-save:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-save-saving  { opacity: 0.65; }
.btn-save-saved   { color: var(--tone-low); border-color: var(--tone-low); }
.btn-save-error   { color: var(--tone-high); border-color: var(--tone-high); cursor: pointer; }

/* ─── TNM TYPE SELECTOR (clínico / patológico) ───────────────── */
.tnm-type {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tnm-type-lbl {
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.tnm-type-opts { display: flex; gap: 8px; flex-wrap: wrap; }
.tnm-type-opt {
  padding: 8px 18px;
  border-radius: 999px;
  border: 0.5px solid var(--line-2);
  background: transparent;
  font-size: 13px;
  color: var(--ink-2);
  transition: all 0.15s ease;
  cursor: pointer;
  font-family: var(--sans);
}
.tnm-type-opt:hover { color: var(--ink); border-color: var(--ink-3); }
.tnm-type-opt.is-on {
  background: var(--ink);
  color: oklch(0.985 0.005 215);
  border-color: var(--ink);
}

/* ─── RSB EDIT MODE ─────────────────────────────────────────── */

/* pencil button — appears in rsb-hd when detail is shown */
.rsb-edit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 0.5px solid var(--line-2);
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  transition: all 0.14s ease;
  margin-left: auto;
  flex-shrink: 0;
}
.rsb-edit-btn:hover {
  background: var(--bg-2);
  color: var(--accent);
  border-color: oklch(0.82 0.05 210);
}

/* summary block in editing state — dimmed so form takes focus */
.rsb-detail-summary--editing {
  opacity: 0.6;
  pointer-events: none;
}

/* badge showing original stage when computed stage differs */
.rsb-stage-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  color: var(--ink-3);
  background: oklch(0.90 0.010 215);
  border: 0.5px solid var(--line-2);
}

/* section wrapper inside edit form */
.rsb-edit-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 0.5px solid var(--line);
}
.rsb-edit-section:last-of-type { border-bottom: none; }

.rsb-edit-section-lbl {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-4);
}

/* generic field wrapper */
.rsb-edit-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

/* two-column and three-column row layouts */
.rsb-edit-row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.rsb-edit-row3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

/* field label */
.rsb-edit-lbl {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* text / number input */
.rsb-edit-inp {
  width: 100%;
  padding: 7px 10px;
  border-radius: 8px;
  border: 0.5px solid var(--line-2);
  background: var(--paper);
  font-size: 13px;
  color: var(--ink);
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
  outline: none;
}
.rsb-edit-inp:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2.5px oklch(0.55 0.13 185 / 0.12);
}

/* select element */
.rsb-edit-select {
  width: 100%;
  padding: 7px 10px;
  border-radius: 8px;
  border: 0.5px solid var(--line-2);
  background: var(--paper);
  font-size: 13px;
  color: var(--ink);
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23999' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}
.rsb-edit-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2.5px oklch(0.55 0.13 185 / 0.12);
}

/* segmented control */
.rsb-edit-seg {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.rsb-edit-seg-opt {
  flex: 1;
  padding: 6px 8px;
  border-radius: 7px;
  border: 0.5px solid var(--line-2);
  background: transparent;
  font-size: 12px;
  font-family: var(--sans);
  color: var(--ink-2);
  text-align: center;
  cursor: pointer;
  transition: all 0.13s ease;
  white-space: nowrap;
}
.rsb-edit-seg-opt:hover { border-color: var(--ink-3); color: var(--ink); }
.rsb-edit-seg-opt.is-on {
  background: var(--ink);
  color: oklch(0.985 0.005 215);
  border-color: var(--ink);
}

/* error message */
.rsb-edit-error {
  margin: 0 16px;
  padding: 8px 12px;
  border-radius: 8px;
  background: oklch(0.95 0.04 25);
  border: 0.5px solid oklch(0.82 0.08 25);
  color: var(--tone-critical);
  font-size: 12px;
  line-height: 1.4;
}

/* action row — cancel / save */
.rsb-edit-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px 16px;
}
.rsb-edit-cancel {
  flex: 1;
  padding: 9px 14px;
  border-radius: 9px;
  border: 0.5px solid var(--line-2);
  background: transparent;
  font-size: 13px;
  font-family: var(--sans);
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.14s ease;
}
.rsb-edit-cancel:hover:not(:disabled) {
  background: var(--bg-2);
  color: var(--ink);
  border-color: var(--ink-3);
}
.rsb-edit-cancel:disabled { opacity: 0.45; cursor: not-allowed; }

.rsb-edit-save {
  flex: 2;
  padding: 9px 14px;
  border-radius: 9px;
  border: 0.5px solid var(--accent);
  background: var(--accent);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--sans);
  color: oklch(0.985 0.005 215);
  cursor: pointer;
  transition: all 0.14s ease;
}
.rsb-edit-save:hover:not(:disabled) {
  background: oklch(0.45 0.14 185);
  border-color: oklch(0.45 0.14 185);
}
.rsb-edit-save:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Version Badge ──────────────────────────────────────────── */
.version-badge-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.version-badge-lbl {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.version-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
}
.version-badge--v8 {
  background: var(--bg-2);
  color: var(--ink-3);
  border: 1px solid var(--line-2);
}
.version-badge--v9 {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
}
.version-seg {
  display: flex;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line-2);
}
.version-opt {
  appearance: none;
  border: 0;
  background: var(--bg-2);
  color: var(--ink-3);
  font: 500 12px/1 var(--sans);
  padding: 5px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: background .12s;
}
.version-opt:hover { background: var(--line); }
.version-opt.is-on {
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 0 0 1.5px var(--line-2);
}
.version-opt--v9.is-on {
  background: #e8f5e9;
  color: #2e7d32;
  box-shadow: inset 0 0 0 1.5px #a5d6a7;
}
.version-opt-sub {
  font-size: 9px;
  font-weight: 400;
  opacity: .75;
}
.version-badge-note {
  font-size: 10.5px;
  color: #e65100;
  font-style: italic;
  width: 100%;
}

/* Callout substituindo o span simples — aparece abaixo do badge */
.version-badge-callout {
  margin-top: 8px;
  padding: 8px 10px;
  background: #fff3e0;
  border-left: 3px solid #e65100;
  border-radius: 4px;
  font-size: 11px;
  color: #bf360c;
  line-height: 1.5;
  width: 100%;
  box-sizing: border-box;
}

/* Banner de alerta de sítio (HPV+, etc.) */
.site-alert {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.55;
}
.site-alert--info {
  background: #e3f2fd;
  border-left: 3px solid #1565c0;
  color: #0d47a1;
}
.site-alert--warn {
  background: #fff8e1;
  border-left: 3px solid #f57f17;
  color: #e65100;
}

/* Nota contextual acima das opções TNM */
.tnm-step-note {
  margin-bottom: 10px;
  padding: 8px 11px;
  background: #f3f4f6;
  border-left: 3px solid #6b7280;
  border-radius: 4px;
  font-size: 11.5px;
  color: #374151;
  line-height: 1.55;
}

/* ─── PROFILE PANEL ──────────────────────────────────────────── */
.prof-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 360px;
  background: var(--paper);
  border-left: 0.5px solid var(--line);
  z-index: 130;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.40s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -24px 0 80px -20px rgba(10,20,40,0.14);
}
.prof-panel.is-open { transform: none; }

.prof-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 0.5px solid var(--line);
  flex-shrink: 0;
}
.prof-hd-title {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--ink);
  font-variation-settings: 'opsz' 16;
}
.prof-hd-close {
  width: 28px; height: 28px;
  border-radius: 7px;
  border: 0.5px solid var(--line-2);
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 15px;
  transition: all 0.14s;
}
.prof-hd-close:hover { background: var(--bg-2); color: var(--ink); }

.prof-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.prof-field { display: flex; flex-direction: column; gap: 5px; }
.prof-lbl {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.prof-inp {
  width: 100%;
  padding: 9px 12px;
  border-radius: 9px;
  border: 0.5px solid var(--line-2);
  background: var(--paper);
  font-size: 14px;
  color: var(--ink);
  font-family: var(--sans);
  transition: border-color 0.14s, box-shadow 0.14s;
  outline: none;
}
.prof-inp:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2.5px oklch(0.55 0.13 185 / 0.12);
}
.prof-hint {
  font-size: 11.5px;
  color: var(--ink-4);
  line-height: 1.4;
}
.prof-cpf-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 9px;
  border: 0.5px solid var(--line);
  background: var(--bg);
  font-size: 14px;
  color: var(--ink-3);
}

.prof-footer {
  padding: 14px 20px 20px;
  border-top: 0.5px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.prof-msg {
  font-size: 12.5px;
  padding: 9px 12px;
  border-radius: 8px;
  line-height: 1.4;
}
.prof-msg--ok   { background: oklch(0.93 0.06 145); color: oklch(0.35 0.12 145); }
.prof-msg--err  { background: oklch(0.95 0.04 25);  color: var(--tone-critical);  }
.prof-msg--info { background: var(--accent-2);      color: var(--ink-2);          }

.prof-save {
  width: 100%;
  padding: 10px;
  border-radius: 9px;
  border: none;
  background: var(--ink);
  color: oklch(0.985 0.005 215);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--sans);
  cursor: pointer;
  transition: all 0.16s;
}
.prof-save:hover:not(:disabled) { background: oklch(0.16 0.014 220); }
.prof-save:disabled { opacity: 0.5; cursor: not-allowed; }

.hd-user-btn {
  font-size: 13px;
  color: var(--ink-2);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: var(--sans);
  transition: color 0.14s;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: transparent;
}
.hd-user-btn:hover { color: var(--ink); text-decoration-color: var(--ink-3); }

@media (max-width: 720px) {
  .prof-panel { width: 100%; }
}
