/*
 * The design system, such as it is.
 *
 * Two audiences read these pages: someone deciding whether to trust the product
 * with a clinical record, and someone using it for the fourth hour today. Both
 * want the same thing — quiet. So: one accent, generous line height, no
 * animation that moves anything a cursor is aimed at, and a dark scheme that is
 * honoured rather than approximated, because notes get written at night.
 */

:root {
  color-scheme: light dark;

  --ink: #16211f;
  --ink-soft: #4c5b58;
  --muted: #6d7b78;
  --bg: #fbfcfb;
  --surface: #ffffff;
  --surface-2: #f2f5f4;
  --line: #dfe6e3;

  /* Teal rather than the usual product blue: it reads as clinical without
     reading as a hospital, and it stays legible on both schemes. */
  --accent: #14746f;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ef;

  --ok: #1c7a4f;
  --warn: #9a6206;
  --danger: #a52c2c;
  --ok-soft: #e2f2ea;
  --warn-soft: #fbf0da;
  --danger-soft: #f8e5e5;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(16, 32, 30, 0.05), 0 8px 24px rgba(16, 32, 30, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8efed;
    --ink-soft: #b3c1be;
    --muted: #8a9a96;
    --bg: #0d1413;
    --surface: #141c1b;
    --surface-2: #1b2524;
    --line: #263331;

    --accent: #4cbcb0;
    --accent-ink: #04211f;
    --accent-soft: #16302e;

    --ok: #56c48c;
    --warn: #d8a33e;
    --danger: #e08585;
    --ok-soft: #152a21;
    --warn-soft: #2c2416;
    --danger-soft: #2c1a1a;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.65 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { line-height: 1.2; letter-spacing: -0.018em; margin: 0 0 0.5em; }
h1 { font-size: clamp(30px, 5vw, 46px); }
h2 { font-size: clamp(22px, 3vw, 30px); }
h3 { font-size: 19px; }
h4 { font-size: 16px; }
p { margin: 0 0 1em; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

hr { border: 0; border-top: 1px solid var(--line); margin: 32px 0; }

code, pre { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; font-size: 0.92em; }

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

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header .inner,
.site-footer .inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  gap: 22px;
}

.wordmark {
  font-weight: 650;
  font-size: 19px;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-decoration: none;
}
.wordmark:hover { text-decoration: none; }

.site-nav { display: flex; gap: 20px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.site-nav a { color: var(--ink-soft); text-decoration: none; font-size: 15px; }
.site-nav a:hover { color: var(--accent); }

main { max-width: 1080px; margin: 0 auto; padding: 56px 22px 72px; }
main.narrow { max-width: 680px; }

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  margin-top: 40px;
}
.site-footer .inner { flex-wrap: wrap; }
.site-footer a { color: var(--muted); }

/* ── Marketing content ─────────────────────────────────────────────────── */

.hero { max-width: 760px; }
.hero .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 14px;
}
.hero .lede { font-size: clamp(17px, 2.2vw, 20px); color: var(--ink-soft); max-width: 62ch; }

.cta-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 28px 0 0; }

.grid { display: grid; gap: 20px; margin: 40px 0; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
}
.card h3 { margin-bottom: 6px; }
.card p:last-child { margin-bottom: 0; }
.card p { color: var(--ink-soft); font-size: 15px; }

.card ul { margin: 0; padding-left: 18px; color: var(--ink-soft); font-size: 15px; }
.card li { margin-bottom: 4px; }

.section { margin: 64px 0; }
.section > p { max-width: 68ch; color: var(--ink-soft); }

.note {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 14px 18px;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 15px;
}
.note p:last-child { margin-bottom: 0; }

/* ── Controls ──────────────────────────────────────────────────────────── */

button, .button {
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 1.3;
}
button:hover, .button:hover { border-color: var(--accent); text-decoration: none; }
button:disabled { opacity: 0.55; cursor: progress; }

button.primary, .button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
button.primary:hover, .button.primary:hover { filter: brightness(1.08); }

button.ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
button.ghost:hover { background: var(--surface-2); border-color: transparent; }

button.danger { color: var(--danger); }
button.danger:hover { border-color: var(--danger); }

button.small, .button.small { padding: 5px 10px; font-size: 13.5px; }

:where(button, a, input, select, textarea):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Forms ─────────────────────────────────────────────────────────────── */

.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 13.5px; font-weight: 550; color: var(--ink-soft); margin-bottom: 5px; }
.field-hint { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }

input, select, textarea {
  font: inherit;
  font-size: 15px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}
textarea { resize: vertical; min-height: 84px; line-height: 1.6; }
input[type="checkbox"] { width: auto; }

.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 16px; }

.form-error {
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14.5px;
  margin: 0 0 14px;
}

.form-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow);
}

/* ── Badges, tables, empties ───────────────────────────────────────────── */

.badge {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 550;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-soft);
  white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td .button, td button { white-space: nowrap; }

.empty {
  color: var(--muted);
  background: var(--surface-2);
  border-radius: var(--radius-lg);
  padding: 26px;
  text-align: center;
  font-size: 15px;
  margin: 0;
}

/* ── Feedback launcher ─────────────────────────────────────────────────── */

/* Anchored bottom-right on every page, under the toast's z-index so a
   confirmation is never hidden behind the button that produced it. */
.feedback-launcher {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  padding: 8px 15px;
  font-size: 14px;
  border-radius: 999px;
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow);
}
.feedback-launcher:hover { color: var(--accent); }

@media print { .feedback-launcher { display: none; } }

/* ── Dialog and toast ──────────────────────────────────────────────────── */

dialog.sheet {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  padding: 26px;
  width: min(560px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}
dialog.sheet::backdrop { background: rgba(9, 18, 17, 0.5); }
dialog.sheet h2 { font-size: 21px; margin-bottom: 18px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 20px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 14.5px;
  box-shadow: var(--shadow);
  z-index: 100;
}
.toast-erro { background: var(--danger); color: #fff; }

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rise 160ms ease-out; }
  @keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ── Guides ────────────────────────────────────────────────────────────── */

.guide-list { list-style: none; padding: 0; margin: 40px 0; display: grid; gap: 16px; }
.guide-list h2 { font-size: 21px; margin-bottom: 8px; }
.guide-list h2 a { color: var(--ink); text-decoration: none; }
.guide-list h2 a:hover { color: var(--accent); }

.guide-meta { color: var(--muted); font-size: 14px; }
.guide .section { margin: 44px 0; }
.guide .section > ul { color: var(--ink-soft); padding-left: 20px; max-width: 68ch; }
.guide .section > ul li { margin-bottom: 6px; }

.guide-example {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 16px;
  background: var(--surface-2);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  font-size: 15px;
  margin: 0 0 1em;
}
.guide-example dt { font-weight: 650; color: var(--accent); }
.guide-example dd { margin: 0; color: var(--ink-soft); }

.guide-sources { padding-left: 20px; font-size: 15px; color: var(--ink-soft); }
.guide-sources li { margin-bottom: 6px; overflow-wrap: anywhere; }

.guide-cta { margin-top: 56px; }
.guide-cta h2 { font-size: 21px; }

/* ── Modelos ───────────────────────────────────────────────────────────── */

/* The sheet is paper on screen too: white, black ink, in either scheme, so
   what you see is what prints. */
.template-actions { margin: 8px 0 24px; }
.template-sheet {
  background: #fff;
  color: #16211f;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 44px;
  font-size: 15px;
  line-height: 1.5;
}
.template-sheet .sheet-title { font-size: 21px; margin: 0 0 20px; text-align: center; }
.template-sheet .sheet-heading { font-size: 15.5px; margin: 22px 0 8px; break-after: avoid; }
.template-sheet .sheet-text { margin: 0 0 8px; }
.sheet-blank { display: flex; align-items: flex-end; gap: 8px; margin: 0 0 12px; break-inside: avoid; }
.sheet-label { font-weight: 550; flex: none; max-width: 60%; }
.sheet-line { display: block; flex: 1; min-width: 40px; height: 1.6em; border-bottom: 1px solid #6d7b78; }
.sheet-box { flex-direction: column; align-items: stretch; gap: 0; }
.sheet-box .sheet-label { max-width: none; }
.sheet-box .sheet-line { flex: none; }
.sheet-check { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 0 0 12px; break-inside: avoid; }
.sheet-option { display: inline-flex; align-items: center; gap: 6px; }
.sheet-checkbox { display: inline-block; width: 13px; height: 13px; border: 1px solid #16211f; border-radius: 2px; }
.sheet-signature { display: flex; flex-wrap: wrap; gap: 12px 32px; margin: 16px 0 8px; break-inside: avoid; }
.sheet-sign { flex: 1 1 200px; font-size: 13.5px; color: #4c5b58; }
.sheet-sign .sheet-line { height: 2.4em; margin-bottom: 4px; }

@media (max-width: 600px) {
  .template-sheet { padding: 24px 18px; }
}

@page { size: A4; margin: 12mm 16mm; }

@media print {
  /* Only the sheet: no frame, no explanation, no call to action. */
  .template-page .site-header,
  .template-page .site-footer,
  .template-page main > :not(.template-sheet),
  .toast { display: none !important; }
  .template-page main { max-width: none; margin: 0; padding: 0; }
  .template-page { background: #fff; }
  .template-sheet { border: 0; box-shadow: none; padding: 0; font-size: 9.5pt; line-height: 1.35; }
  .template-sheet .sheet-title { font-size: 14pt; margin-bottom: 4mm; }
  .template-sheet .sheet-heading { font-size: 10.5pt; margin: 4mm 0 1.5mm; }
  .sheet-blank, .sheet-check { margin-bottom: 2mm; }
  .sheet-line { border-bottom-color: #000; height: 6.5mm; }
  .sheet-sign .sheet-line { height: 10mm; }
  /* Identification and clinical data on separate sheets, to be kept apart. */
  .sheet-new-page { break-before: page; }
}

/* ── Demonstração ──────────────────────────────────────────────────────── */

/* Not sticky: the site header already is, and its height changes as its links
   wrap. The current step is named in the panel heading on every screen size. */
.demo-nav {
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  margin: 28px 0 24px;
}
.demo-nav ol { list-style: none; padding: 0; margin: 0 0 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.demo-nav ol a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink-soft); text-decoration: none; font-size: 14.5px; background: var(--surface);
}
.demo-nav ol a[aria-current="step"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.demo-nav-n {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 999px;
  background: var(--surface-2); font-size: 12.5px; font-weight: 650;
}
.demo-nav ol a[aria-current="step"] .demo-nav-n { background: var(--accent); color: var(--accent-ink); }
.demo-nav-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.demo-nav-actions > span:not([hidden]) { display: contents; }

.demo-panel h3 { margin-top: 24px; }
.demo-panel-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: space-between; margin-bottom: 14px; }
.demo-area { font-size: 13.5px; color: var(--muted); font-weight: 550; }
.demo-panel h2 { scroll-margin-top: 90px; }
.demo-panel h2:focus { outline: none; }
.demo-choice { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-top: 16px; }
.demo-choice .field { margin: 0; }
.demo-material { background: var(--surface-2); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.demo-material p { margin: 6px 0 0; }
.demo-steps { padding-left: 20px; max-width: 68ch; }
.demo-steps li { margin-bottom: 14px; scroll-margin-top: 90px; }
.demo-steps p { color: var(--ink-soft); }

/* ── Mensagens de consulta ─────────────────────────────────────────────── */

.message-purposes { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
.message-purpose { display: flex; gap: 10px; align-items: baseline; margin-bottom: 8px; cursor: pointer; }
.message-purpose input { width: auto; flex: none; }
.message-purpose .field-hint { display: inline; margin: 0; }
.message-actions { margin: 0 0 8px; }
.message-starter { margin-bottom: 16px; }
.message-starter h3 { margin-bottom: 2px; }
.message-text { white-space: pre-line; overflow-wrap: anywhere; color: var(--ink); }
