/* ==========================================================================
   Medicina Bucal · Dra. Fernanda Valdivia
   Sistema visual derivado del logotipo:
   azul marino #24476E (trazo principal), rosa #F0649A (acento), papel #F7F7F2.
   ========================================================================== */

:root {
  --navy: #24476e;
  --navy-800: #1b3654;
  --navy-600: #335a86;
  --navy-100: #dfe7f1;
  --navy-50: #eef3f8;

  --pink: #f0649a;          /* acentos, iconos, marcas gráficas */
  --pink-text: #b8326a;     /* rosa para texto (contraste AA sobre blanco) */
  --pink-100: #fde3ee;
  --pink-50: #fff3f8;

  --paper: #f7f7f2;
  --surface: #ffffff;
  --ink: #1d2b3a;
  --muted: #5b6778;
  --subtle: #8a94a3;
  --line: #e4e4dc;
  --line-strong: #d3d3c8;

  --ok: #2e7d5b;
  --ok-bg: #e6f4ec;
  --warn: #9a5b00;
  --warn-bg: #fdf1dc;
  --err: #b42318;
  --err-bg: #fdecea;

  --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(29 43 58 / 0.05), 0 4px 16px rgb(29 43 58 / 0.05);
  --sidebar-w: 264px;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.55 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-serif); color: var(--navy); margin: 0; line-height: 1.2; }
h1 { font-size: clamp(1.6rem, 2.4vw, 2rem); font-weight: 600; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--navy-600); }
code, .mono { font-family: var(--font-mono); font-size: 0.86em; }

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

.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 50;
  background: var(--navy); color: #fff; padding: 8px 12px; border-radius: var(--radius-sm);
}
.skip-link:focus { left: 8px; }

/* ---------- Estructura ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 28px;
  padding: 24px 18px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; padding: 0 6px; }
.brand__mark { width: 44px; height: 44px; flex: none; }
.brand__text { display: flex; flex-direction: column; }
.brand__name { font: 600 1.28rem/1.1 var(--font-serif); }
.brand__navy { color: var(--navy); }
.brand__pink { color: var(--pink); }
.brand__doctor { font: 500 0.78rem/1.4 var(--font-sans); color: var(--navy); margin-top: 3px; letter-spacing: 0.01em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-weight: 500;
  position: relative;
}
.nav__item svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav__item:hover { background: var(--navy-50); color: var(--navy); }
.nav__item[aria-current="page"] { background: var(--navy-50); color: var(--navy); }
.nav__item[aria-current="page"]::before {
  content: ""; position: absolute; left: -18px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--pink);
}

.sidebar__foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding: 0 6px; }
.user-chip { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-top: 1px solid var(--line); padding-top: 16px; }
.user-chip + .sidebar__foot { margin-top: 0; }
.user-chip__avatar { width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--navy); color: #fff; font: 600 0.78rem var(--font-sans); }
.user-chip__text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-chip__name { font-size: 0.85rem; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip__role { font-size: 0.76rem; color: var(--muted); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--paper); }
.login__card { width: 100%; max-width: 420px; padding: 32px 28px; display: flex; flex-direction: column; gap: 14px; }
.login__brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login__brand > div { display: flex; flex-direction: column; }
.login__sub { font-size: 0.8rem; color: var(--muted); }
.login__title { font: 600 1.45rem/1.2 var(--font-serif); color: var(--navy); }
.login__lead { font-size: 0.9rem; color: var(--muted); }
.login__form { display: flex; flex-direction: column; gap: 14px; }
.login__submit { justify-content: center; }
.login__roles { display: grid; gap: 10px; }
.login__qr { align-self: center; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); min-height: 200px; min-width: 200px; display: grid; place-items: center; }
.login__key code { font-family: var(--font-mono); word-break: break-all; }
.table--static tbody tr { cursor: default; }
.sidebar__legal { font-size: 0.76rem; color: var(--subtle); line-height: 1.5; }

.content { min-width: 0; display: flex; flex-direction: column; }
.main { padding: 32px clamp(16px, 3.2vw, 44px) 64px; max-width: 1320px; width: 100%; outline: none; }

.demo-banner {
  background: var(--warn-bg); color: var(--warn);
  border-bottom: 1px solid #f3dcb2;
  padding: 9px clamp(16px, 3.2vw, 44px); font-size: 0.86rem;
}

/* ---------- Encabezado de página ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.page-head__text { display: flex; flex-direction: column; gap: 6px; max-width: 70ch; }
.page-head__eyebrow { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--pink-text); }
.page-head__lead { color: var(--muted); }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 0.88rem; color: var(--muted); text-decoration: none; margin-bottom: 14px; }
.back-link:hover { color: var(--navy); }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 0; }
.card__body { padding: 18px 22px 22px; }
.card__body > * + * { margin-top: 16px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.grid-detail { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 22px; align-items: start; }
.sticky { position: sticky; top: 24px; }

/* ---------- Formularios ---------- */
[hidden] { display: none !important; } /* las clases con display no deben ganarle al atributo */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-weight: 600; font-size: 0.88rem; color: var(--ink); }
.field__hint { font-size: 0.8rem; color: var(--muted); }
.field__row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.field__error { font-size: 0.8rem; color: var(--err); overflow-wrap: anywhere; }
.field__error:empty { display: none; }

.input, .textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: #fdfdfb; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 10px 12px; transition: border-color .15s, box-shadow .15s;
}
.input { font-family: var(--font-mono); font-size: 0.92rem; height: 46px; } /* misma altura en text, date y select */
.textarea { min-height: 300px; resize: vertical; line-height: 1.6; }
.input:hover, .textarea:hover { border-color: var(--subtle); }
.input:focus, .textarea:focus { outline: none; border-color: var(--navy-600); box-shadow: 0 0 0 3px var(--navy-100); background: #fff; }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--err); }

.counter { font-size: 0.78rem; color: var(--subtle); font-variant-numeric: tabular-nums; }
.counter.is-low { color: var(--warn); }

.privacy-note {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--navy-50); color: var(--navy-800);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 0.83rem;
}
.privacy-note svg { width: 17px; height: 17px; flex: none; margin-top: 2px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.actions--end { justify-content: flex-end; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 0.9rem/1 var(--font-sans); padding: 11px 18px; border-radius: 999px;
  border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn--primary { background: var(--navy); color: #fff; }
.btn--primary:hover { background: var(--navy-800); }
.btn--secondary { background: var(--surface); color: var(--navy); border-color: var(--line-strong); }
.btn--secondary:hover { border-color: var(--navy-600); }
.btn--ghost { background: transparent; color: var(--navy-600); padding-inline: 8px; }
.btn--ghost:hover { color: var(--navy); text-decoration: underline; }
.btn--sm { padding: 7px 12px; font-size: 0.82rem; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Proceso de certificación ---------- */
.pipeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.step { display: grid; grid-template-columns: 34px 1fr; gap: 14px; position: relative; padding-bottom: 20px; }
.step:last-child { padding-bottom: 0; }
.step:not(:last-child)::after {
  content: ""; position: absolute; left: 16px; top: 36px; bottom: 2px; width: 2px; background: var(--line);
}
.step.is-done:not(:last-child)::after { background: var(--navy-100); }
.step__icon {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--paper); border: 1px solid var(--line-strong); color: var(--subtle);
  font: 600 0.82rem var(--font-sans);
}
.step__icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.step__title { font-weight: 600; color: var(--ink); }
.step__desc { font-size: 0.84rem; color: var(--muted); }
.step__status { font-size: 0.8rem; font-weight: 600; margin-top: 2px; }
.step.is-active .step__icon { background: var(--navy); border-color: var(--navy); color: #fff; }
.step.is-active .step__status { color: var(--navy-600); }
.step.is-done .step__icon { background: var(--navy-50); border-color: var(--navy-100); color: var(--navy); }
.step.is-pending .step__icon { background: var(--warn-bg); border-color: #f3dcb2; color: var(--warn); }
.step.is-pending .step__status { color: var(--warn); }
.step.is-error .step__icon { background: var(--err-bg); border-color: #f5c6c1; color: var(--err); }
.step.is-error .step__status { color: var(--err); }

/* ---------- Estados / chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font: 600 0.76rem/1 var(--font-sans); padding: 5px 10px; border-radius: 999px; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--err { background: var(--err-bg); color: var(--err); }
.badge--biopsy { background: var(--pink-100); color: var(--pink-text); }
.badge--muted { background: var(--paper); color: var(--muted); border: 1px solid var(--line); }
.badge--muted::before { display: none; }

.alert { border-radius: var(--radius-sm); padding: 12px 14px; font-size: 0.88rem; display: flex; gap: 10px; }
.alert svg, .back-link svg {
  width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.alert svg { margin-top: 1px; }
.back-link svg { width: 16px; height: 16px; }
.alert--err { background: var(--err-bg); color: var(--err); }
.alert--warn { background: var(--warn-bg); color: var(--warn); }
.alert--ok { background: var(--ok-bg); color: var(--ok); }

/* ---------- Estadísticas ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { padding: 16px 18px; }
.stat__label { font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.stat__value { font: 600 1.9rem/1.15 var(--font-serif); color: var(--navy); margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat--pink .stat__value { color: var(--pink-text); }

/* ---------- Tabla ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.search { position: relative; flex: 1 1 260px; max-width: 360px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; fill: none; stroke: var(--subtle); stroke-width: 2; stroke-linecap: round; }
.search .input { padding-left: 34px; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th {
  text-align: left; font-size: 0.74rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); padding: 12px 22px; background: #fbfbf8; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 14px 22px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr { cursor: pointer; transition: background .12s; }
.table tbody tr:hover { background: var(--navy-50); }
.table tbody tr:last-child td { border-bottom: none; }
.table .cell-date { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.table .cell-exp { font-family: var(--font-mono); font-size: 0.84rem; color: var(--navy); white-space: nowrap; }
.table .cell-dx { max-width: 420px; }
.table .cell-dx small { display: block; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.table .cell-note { display: block; margin-top: 2px; font-size: 0.76rem; font-weight: 600; color: var(--warn); }
@media (max-width: 1280px) { /* iPad horizontal: que quepan las 6 columnas */
  .table th, .table td { padding-inline: 14px; }
  .table .cell-date { white-space: normal; min-width: 100px; }
}
.row-link { color: inherit; text-decoration: none; font-weight: 500; }

.empty { text-align: center; padding: 56px 24px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty img { width: 56px; opacity: 0.85; }

/* ---------- Hoja clínica (espejo de la historia clínica en papel) ---------- */
.sheet__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 22px 26px; border-bottom: 1px solid var(--line); }
.sheet__meta { display: flex; flex-direction: column; gap: 4px; }
.sheet__exp { font-family: var(--font-mono); font-size: 0.86rem; color: var(--muted); }
.sheet__lead { padding: 20px 26px; background: linear-gradient(90deg, var(--pink-50), transparent 70%); border-bottom: 1px solid var(--line); }
.sheet__lead-label { font-size: 0.74rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--pink-text); margin-bottom: 6px; }
.sheet__lead p { font: 500 1.05rem/1.55 var(--font-serif); color: var(--ink); }

.section { padding: 20px 26px; border-bottom: 1px solid var(--line); }
.section:last-child { border-bottom: none; }
.section__title { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.section__num {
  font: 600 0.74rem/1 var(--font-sans); color: var(--pink-text); background: var(--pink-50);
  border: 1px solid var(--pink-100); padding: 4px 7px; border-radius: 6px; letter-spacing: 0.03em;
}
.section__text { white-space: pre-wrap; }

.dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; margin: 0; }
.dl div { display: flex; flex-direction: column; gap: 2px; }
.dl dt { font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.dl dd { margin: 0; }
.nd { color: var(--subtle); font-style: italic; }

.lesions { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.lesions th { text-align: left; font-size: 0.76rem; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line-strong); }
.lesions td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.lesions td:first-child { font-weight: 600; color: var(--navy); width: 30%; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.chip { background: var(--navy-50); color: var(--navy-800); border: 1px solid var(--navy-100); padding: 5px 11px; border-radius: 999px; font-size: 0.84rem; }

/* Odontograma FDI */
.odonto { margin-top: 16px; }
.odonto__label { font-size: 0.78rem; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.odonto__grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)) 8px repeat(8, minmax(0, 1fr)); gap: 3px; max-width: 650px; }
.odonto__grid.is-deciduous { grid-template-columns: repeat(5, minmax(0, 1fr)) 8px repeat(5, minmax(0, 1fr)); max-width: 410px; margin-top: 10px; }
.odonto__gap { border-left: 1px solid var(--line-strong); margin-left: 3px; }
.tooth {
  aspect-ratio: 1 / 1.15; display: grid; place-items: center;
  font: 500 0.7rem var(--font-mono); color: var(--subtle);
  background: #fbfbf8; border: 1px solid var(--line); border-radius: 6px;
}
.tooth.is-hit { background: var(--pink); border-color: var(--pink); color: #fff; font-weight: 600; }
.odonto__divider { grid-column: 1 / -1; height: 1px; background: var(--line-strong); margin: 3px 0; }

/* ---------- Auditoría ---------- */
.audit__row { display: flex; flex-direction: column; gap: 4px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.audit__row:last-child { border-bottom: none; padding-bottom: 0; }
.audit__row:first-child { padding-top: 0; }
.audit__label { font-size: 0.76rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.hash { display: flex; align-items: flex-start; gap: 8px; }
.hash code { word-break: break-all; color: var(--navy-800); background: var(--paper); padding: 6px 8px; border-radius: 6px; flex: 1; line-height: 1.5; }
.icon-btn { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: var(--navy); border-color: var(--navy-100); }
.icon-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.checks { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-direction: column; gap: 10px; }
.check { display: grid; grid-template-columns: 24px 1fr; gap: 10px; align-items: start; font-size: 0.9rem; }
.check__icon { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; }
.check__icon svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.check--ok .check__icon { background: var(--ok-bg); color: var(--ok); }
.check--err .check__icon { background: var(--err-bg); color: var(--err); }
.check--na .check__icon { background: var(--paper); color: var(--subtle); }
.check small { display: block; color: var(--muted); }

.verdict { display: flex; gap: 14px; align-items: center; padding: 16px 18px; border-radius: var(--radius-sm); }
.verdict svg { width: 30px; height: 30px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.verdict strong { font: 600 1.05rem var(--font-serif); display: block; }
.verdict--ok { background: var(--ok-bg); color: var(--ok); }
.verdict--err { background: var(--err-bg); color: var(--err); }
.verdict--warn { background: var(--warn-bg); color: var(--warn); }

.how { counter-reset: how; list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.how li { counter-increment: how; display: grid; grid-template-columns: 30px 1fr; gap: 12px; font-size: 0.9rem; color: var(--muted); }
.how li::before {
  content: counter(how); width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--pink-50); color: var(--pink-text); font-weight: 600; border: 1px solid var(--pink-100);
}
.how strong { color: var(--ink); display: block; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--navy-800); color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 0.86rem; box-shadow: 0 8px 24px rgb(0 0 0 / 0.18); z-index: 40;
}

/* ---------- Carga ---------- */
.skeleton { background: linear-gradient(90deg, #efefe9 25%, #f7f7f2 37%, #efefe9 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 6px; height: 14px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- Responsivo ---------- */
@media (max-width: 1180px) {
  .grid-detail { grid-template-columns: 1fr; }
  .sticky { position: static; }
}
@media (max-width: 1020px) {
  .grid-2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center;
    gap: 12px; padding: 10px 16px; border-right: none; border-bottom: 1px solid var(--line);
  }
  .brand__doctor, .sidebar__foot { display: none; }
  .user-chip { margin: 0; padding: 0; border: none; order: 3; }
  .user-chip__text, .user-chip__avatar { display: none; }
  .brand__mark { width: 36px; height: 36px; }
  .brand__name { font-size: 1.05rem; }
  .nav { flex-direction: row; margin-left: auto; gap: 0; }
  .nav__item { padding: 8px 10px; font-size: 0; gap: 0; }
  .nav__item svg { width: 21px; height: 21px; }
  .nav__item[aria-current="page"]::before { left: 8px; right: 8px; top: auto; bottom: -11px; width: auto; height: 3px; border-radius: 3px 3px 0 0; }
  .main { padding-top: 22px; }
  .dl { grid-template-columns: 1fr; }
  .section, .sheet__head, .sheet__lead { padding-inline: 18px; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .table td { padding: 2px 0; border: none; }
  .table .cell-dx { max-width: none; }
  .odonto__grid { gap: 2px; }
  .tooth { font-size: 0.58rem; border-radius: 4px; }
  .odonto__grid { grid-template-columns: repeat(8, minmax(0, 1fr)) 4px repeat(8, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition: none !important; }
}

/* ==========================================================================
   Historia clínica: formulario completo
   ========================================================================== */
.form-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 26px; align-items: start; }
.form-index { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 2px; }
.form-index__title { font-size: 0.74rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 10px 8px; }
.form-index a {
  display: grid; grid-template-columns: 26px 1fr; gap: 8px; align-items: center;
  padding: 7px 10px; border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; font-size: 0.87rem;
}
.form-index a:hover { background: var(--navy-50); color: var(--navy); }
.form-index a.is-current { background: var(--surface); color: var(--navy); font-weight: 600; box-shadow: var(--shadow); }
.form-index__num { font: 600 0.72rem var(--font-sans); color: var(--pink-text); text-align: center; }
.form-index a.has-error { color: var(--err); }
.form-index a.has-error .form-index__num { color: var(--err); }

.form-stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.form-section { scroll-margin-top: 20px; container-type: inline-size; }
.form-section__head { display: flex; gap: 12px; align-items: flex-start; padding: 20px 24px 0; }
.form-section__head .section__num { margin-top: 3px; }
.form-section__desc { font-size: 0.85rem; color: var(--muted); margin-top: 3px; }
.form-section__body { padding: 18px 24px 24px; display: flex; flex-direction: column; gap: 18px; }
.subhead { font: 600 0.8rem var(--font-sans); letter-spacing: 0.06em; text-transform: uppercase; color: var(--navy-600); padding-top: 6px; border-top: 1px dashed var(--line); }
.subhead:first-child { border-top: none; padding-top: 0; }

.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px 18px; }
.fields--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-all { grid-column: 1 / -1; }
.req { color: var(--pink-text); margin-left: 2px; }
.input.is-text { font-family: var(--font-sans); font-size: 0.93rem; }
.input.is-upper { text-transform: uppercase; }
.input.is-upper::placeholder { text-transform: none; }
.field-stack { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.input:disabled { opacity: .6; cursor: not-allowed; }
.textarea.is-short { min-height: 84px; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.derived { font-size: 0.82rem; color: var(--navy-600); font-weight: 500; }
.derived:empty { display: none; }

/* Controles segmentados (Sí / No / Ex) */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px; background: #fdfdfb; align-self: flex-start; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { padding: 6px 14px; border-radius: 999px; font-size: 0.84rem; font-weight: 500; color: var(--muted); cursor: pointer; user-select: none; }
.seg label:hover { color: var(--navy); }
.seg input:checked + label { background: var(--navy); color: #fff; }
.seg input:focus-visible + label { outline: 3px solid var(--pink); outline-offset: 1px; }

.checks-inline { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.check-inline { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; cursor: pointer; }
.check-inline input { width: 17px; height: 17px; accent-color: var(--navy); }

/* Tabla de antecedentes patológicos */
.pat-table { width: 100%; border-collapse: collapse; }
.pat-table th { text-align: left; font-size: 0.74rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; padding: 0 10px 8px; }
.pat-table td { padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
.pat-table td:first-child { font-weight: 500; width: 34%; padding-left: 0; }
.pat-table td:nth-child(2) { width: 1%; white-space: nowrap; }
@container (max-width: 640px) {
  .fields--2 { grid-template-columns: 1fr; }
  .pat-table thead { display: none; }
  .pat-table, .pat-table tbody, .pat-table tr, .pat-table td { display: block; width: auto !important; }
  .pat-table tr { padding: 10px 0; border-top: 1px solid var(--line); }
  .pat-table td { border: none; padding: 4px 0; }
}

/* Filas repetibles */
.repeater { display: flex; flex-direction: column; gap: 12px; }
.repeater-row { position: relative; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 52px 14px 14px; background: #fdfdfb; }
.repeater-row .icon-btn { position: absolute; top: 10px; right: 10px; }
.repeater-empty { font-size: 0.86rem; color: var(--subtle); font-style: italic; }

/* Campos sugeridos por la IA */
.is-ai .input, .is-ai .textarea, .is-ai .seg, .input.is-ai, .textarea.is-ai { border-color: var(--pink); background: var(--pink-50); }
.ai-tag { font: 600 0.66rem/1 var(--font-sans); color: var(--pink-text); background: var(--pink-100); padding: 3px 6px; border-radius: 4px; margin-left: 6px; letter-spacing: 0.04em; vertical-align: 1px; }

.ai-panel { background: linear-gradient(135deg, var(--pink-50), var(--surface) 60%); border-color: var(--pink-100); }
.ai-panel summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 24px; }
.ai-panel summary::-webkit-details-marker { display: none; }
.ai-panel summary h2 { display: flex; align-items: center; gap: 10px; }
.ai-panel summary h2 svg { width: 20px; height: 20px; fill: none; stroke: var(--pink); stroke-width: 2; stroke-linecap: round; }
.ai-panel__chev { color: var(--muted); font-size: 0.85rem; }
.ai-panel[open] .ai-panel__chev::after { content: "Ocultar"; }
.ai-panel:not([open]) .ai-panel__chev::after { content: "Mostrar"; }
.ai-panel .textarea { min-height: 150px; }

/* Odontograma editable */
.odonto-edit .tooth { cursor: pointer; font-family: var(--font-mono); padding: 0; }
.odonto-edit .tooth:hover { border-color: var(--navy-600); color: var(--navy); }
.tooth.is-marked { background: var(--navy); border-color: var(--navy); color: #fff; }
.tooth.is-lesion { background: var(--pink); border-color: var(--pink); color: #fff; }
.tooth.is-absent { background: transparent; border-style: dashed; color: var(--line-strong); text-decoration: line-through; }
.tooth.is-ref { box-shadow: inset 0 0 0 2px var(--pink); }
.tooth.is-selected { outline: 3px solid var(--pink); outline-offset: 1px; }
.odonto-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.78rem; color: var(--muted); margin-top: 10px; }
.odonto-legend span { display: inline-flex; align-items: center; gap: 6px; }
.odonto-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; border: 1px solid var(--line); }
.odonto-editor { margin-top: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; background: var(--paper); }
.odonto-findings { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.odonto-findings li { font-size: 0.82rem; background: var(--surface); border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; }
.odonto-findings b { font-family: var(--font-mono); color: var(--navy); margin-right: 4px; }

/* Barra de envío */
.submit-bar {
  position: sticky; bottom: 0; z-index: 15; margin-top: 8px;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: rgb(255 255 255 / 0.96); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 -4px 20px rgb(29 43 58 / 0.08);
}
.submit-bar__msg { font-size: 0.86rem; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.submit-bar__msg.is-err { color: var(--err); }
.submit-bar__msg a { color: inherit; }

.consent { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fdfdfb; cursor: pointer; }
.consent input { width: 19px; height: 19px; margin-top: 2px; accent-color: var(--navy); flex: none; }
.consent[aria-invalid="true"] { border-color: var(--err); }

/* Vista de historia (solo lectura) */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 24px; margin: 0; }
.kv div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kv dt { font-size: 0.76rem; font-weight: 600; color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv .span-all { grid-column: 1 / -1; }
.sheet__patient { font: 600 1.35rem/1.2 var(--font-serif); color: var(--navy); }
.sheet__sub { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.86rem; color: var(--muted); }
.empty-note { color: var(--subtle); font-style: italic; font-size: 0.9rem; }
.consent-note { font-size: 0.86rem; color: var(--muted); }
.signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 36px; }
.signatures div { border-top: 1px solid var(--ink); padding-top: 6px; text-align: center; font-size: 0.82rem; color: var(--muted); }
.print-only { display: none; }

@media (max-width: 1280px) {
  .form-layout { grid-template-columns: 1fr; }
  .form-index { position: static; flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
  .form-index__title { display: none; }
  .form-index a { white-space: nowrap; grid-template-columns: auto auto; }
}
@media (max-width: 820px) {
  .form-section__head, .form-section__body { padding-inline: 16px; }
  .submit-bar { border-radius: 0; margin-inline: -16px; }
  .submit-bar .actions { width: 100%; }
  .submit-bar .btn--primary { flex: 1; }
}

@media print {
  body { background: #fff; font-size: 12px; }
  .sidebar, .demo-banner, .back-link, .no-print, .toast { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid-page; }
  .grid-detail { display: block; }
  .section { break-inside: avoid; }
  .print-only { display: block; }
  .tooth.is-marked, .tooth.is-lesion { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.field[data-invalid] .input, .field[data-invalid] .textarea, .field[data-invalid] .seg { border-color: var(--err); }
.section .kv + .kv, .section .kv + .table-wrap, .section .table-wrap + .table-wrap, .section .table-wrap + .kv { margin-top: 16px; }
@media (max-width: 820px) {
  .submit-bar { padding: 10px 16px; }
  .submit-bar__msg:not(.is-err) { display: none; }
  .submit-bar .actions { flex-wrap: nowrap; }
}

/* ==========================================================================
   Odontograma con simbología
   ========================================================================== */
.odg { display: flex; flex-direction: column; gap: 14px; }
.odg-scroll { overflow-x: auto; padding-bottom: 4px; display: flex; flex-direction: column; gap: 18px; }
.odg-chart { min-width: 620px; max-width: 1000px; }
.odg-row { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)) 10px repeat(8, minmax(0, 1fr)); gap: 3px; align-items: end; }
.odg-row.is-deciduous { grid-template-columns: repeat(5, minmax(0, 1fr)) 10px repeat(5, minmax(0, 1fr)); max-width: 540px; }
.odg-chart:has(.is-deciduous) { min-width: 400px; }
.odg-mid { align-self: stretch; border-left: 1.5px solid var(--line-strong); margin-left: 4px; }
.odg-occlusal-line { height: 1.5px; background: var(--line-strong); margin: 6px 0; }
.odg-cell {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 3px 1px;
  background: none; border: 1px solid transparent; border-radius: 8px; font: inherit; color: inherit;
}
button.odg-cell { cursor: pointer; }
button.odg-cell:hover { background: var(--navy-50); }
.odg-cell.is-selected { border-color: var(--pink); background: var(--pink-50); }
.odg-tooth { width: 100%; max-width: 56px; height: auto; display: block; overflow: visible; }
.odg-num { font: 500 0.76rem var(--font-mono); color: var(--muted); display: inline-flex; align-items: center; gap: 2px; padding: 0 3px; border-radius: 4px; }
.odg-num.is-ref { color: var(--pink-text); font-weight: 700; box-shadow: inset 0 -2px 0 var(--pink); }
.odg-note-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--navy-600); }
.odg-chart.is-editable .odg-surface { cursor: crosshair; transition: stroke .1s; }
.odg-chart.is-editable .odg-surface:hover { stroke: var(--navy); stroke-width: 2; }
.odg-icon { width: 20px; height: 20px; flex: none; }

.odg-palette { display: flex; flex-wrap: wrap; gap: 10px 18px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fdfdfb; }
.odg-palette__group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.odg-palette__label { width: 100%; font: 600 0.7rem var(--font-sans); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.odg-tool {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 6px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: 500 0.8rem var(--font-sans); cursor: pointer;
}
.odg-tool:hover { border-color: var(--navy-600); }
.odg-tool.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
.odg-tool.is-active .odg-icon rect:first-child { fill: #fff; }
.odg-tool__glyph { width: 20px; text-align: center; font-size: 0.95rem; line-height: 1; }
.odg-hint { font-size: 0.84rem; color: var(--navy-600); font-weight: 500; }
.odg-deciduous { align-self: flex-start; font-size: 0.85rem; }

.odg-panel { border: 1px solid var(--pink-100); background: linear-gradient(135deg, var(--pink-50), var(--surface) 55%); border-radius: var(--radius-sm); padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.odg-panel__head { display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: center; }
.odg-panel__pic .odg-tooth { max-width: 56px; }
.odg-surf-table { border-collapse: collapse; font-size: 0.84rem; }
.odg-surf-table th, .odg-surf-table td { padding: 6px 10px; text-align: center; border-bottom: 1px solid var(--line); }
.odg-surf-table thead th { font-size: 0.74rem; color: var(--muted); font-weight: 600; }
.odg-surf-table tbody th { text-align: left; font-weight: 500; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.odg-surf-table input { width: 17px; height: 17px; accent-color: var(--navy); }
.odg-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.odg-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 6px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); font: 500 0.8rem var(--font-sans); color: var(--ink); cursor: pointer; }
.odg-chip.is-on { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); background: var(--navy-50); }

.odg-legend { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.78rem; color: var(--muted); }
.odg-legend li { display: inline-flex; align-items: center; gap: 5px; }
.odg-legend .odg-icon { width: 16px; height: 16px; }
.odg-totals { font-size: 0.84rem; color: var(--navy-800); font-weight: 500; }
.odg-list { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.odg-list li { font-size: 0.8rem; background: var(--surface); border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; }
.odg-list b { font-family: var(--font-mono); color: var(--navy); margin-right: 6px; }
.odg-list em { color: var(--muted); }
.is-ai-block .odg-palette { border-color: var(--pink); }

@media print {
  .odg-tooth, .odg-icon { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .odg-chart { min-width: 0; }
}
.odg-swipe { display: none; font-size: 0.78rem; color: var(--subtle); }
@media (max-width: 820px) {
  .odg-palette { flex-wrap: nowrap; overflow-x: auto; padding: 10px; gap: 14px; scrollbar-width: thin; }
  .odg-palette__group { flex-wrap: nowrap; flex: none; }
  .odg-palette__label { width: auto; margin-right: 2px; }
  .odg-tool { white-space: nowrap; }
  .odg-swipe { display: block; }
}

/* ==========================================================================
   Escritura con Apple Pencil
   ========================================================================== */
.step-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 22px; max-width: 760px; }
.step-tab {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font: inherit; color: var(--muted);
}
.step-tab strong { display: block; color: var(--ink); font-size: .95rem; }
.step-tab small { display: block; font-size: .78rem; }
.step-tab__num { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--paper); border: 1px solid var(--line-strong); font-weight: 600; flex: none; }
.step-tab.is-active { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
.step-tab.is-active .step-tab__num { background: var(--navy); border-color: var(--navy); color: #fff; }

.ink-step { display: flex; flex-direction: column; gap: 20px; max-width: 1100px; }
.ink-card { overflow: hidden; }
.ink-card__head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 22px 12px; }
.ink-card__head .section__num { margin-top: 3px; }
.ink-card__head > div { flex: 1; }
.ink-card__more { margin-left: auto; }

/* Papel: renglones que escalan con la zona (44 unidades lógicas por renglón) */
.ink-pad {
  --ink-k: 1;
  position: relative; width: 100%; background-color: #fffefb;
  background-image: repeating-linear-gradient(to bottom,
    transparent 0, transparent calc(44px * var(--ink-k) - 1px),
    #e7eaf0 calc(44px * var(--ink-k) - 1px), #e7eaf0 calc(44px * var(--ink-k)));
  background-position: 0 calc(10px * var(--ink-k));
  border-top: 1px solid var(--line);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.ink-pad::before { content: ""; position: absolute; top: 0; bottom: 0; left: calc(22px * var(--ink-k)); border-left: 1px solid rgb(240 100 154 / .25); pointer-events: none; }
.ink-pad__guides { position: absolute; inset: 0; pointer-events: none; }
.ink-block-sep { position: absolute; left: 0; right: 0; border-top: 1.5px solid #dfe3ea; }
.ink-label {
  position: absolute; left: calc(30px * var(--ink-k)); font-size: max(11px, calc(13px * var(--ink-k)));
  color: var(--subtle); font-weight: 500; letter-spacing: .01em; white-space: nowrap;
}
.ink-pad__canvas { position: absolute; inset: 0; touch-action: pan-y pinch-zoom; cursor: crosshair; }
body.ink-finger .ink-pad__canvas, body.ink-finger .odg-ink__canvas { touch-action: none; }

/* Barra fija inferior (como Notas de iPad) */
.ink-bar {
  position: sticky; bottom: 12px; z-index: 15; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 10px 6px 10px; background: rgb(255 255 255 / .96); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 999px; box-shadow: 0 10px 30px rgb(29 43 58 / .14);
}
.ink-bar__end { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.ink-toolbar { display: flex; align-items: center; gap: 6px; }
.ink-toolbar__sep { width: 1px; height: 28px; background: var(--line); margin: 0 4px; }
.ink-tool {
  min-width: 58px; height: 56px; padding: 4px 6px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  cursor: pointer; border: 1px solid transparent; background: transparent; color: var(--ink); font-size: 1.15rem;
}
.ink-tool__icon { display: grid; place-items: center; height: 26px; }
.ink-tool__label { font: 600 .68rem var(--font-sans); color: var(--muted); letter-spacing: .01em; }
.ink-tool:hover { background: var(--paper); }
.ink-tool.is-active { border-color: var(--navy-100); background: var(--navy-50); }
.ink-tool.is-active .ink-tool__label { color: var(--navy); }
.ink-tool[disabled] { opacity: .4; cursor: default; }
.ink-tool__dot { width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgb(255 255 255 / .6); }
.btn--lg { padding: 14px 24px; font-size: 1rem; }
.ink-reading { display: flex; align-items: center; gap: 10px; color: var(--navy); font-size: .88rem; }
.ink-reading strong { display: block; }
.ink-reading span { color: var(--muted); }

/* Odontograma con lápiz */
.odg-ink { padding: 0 22px 22px; }
.odg-ink .odg-hint { margin: 0; }
.odg-ink__scroll { padding: 0 0 6px; }
.odg-ink__stage { position: relative; min-width: 760px; padding: 40px 0; }
.odg-ink .odg-chart { max-width: none; min-width: 0; }
.odg-ink .odg-chart + .odg-chart { margin-top: 18px; }
.odg-ink .odg-tooth { max-width: none; }
.odg-ink .odg-cell { padding: 2px 0; }
.odg-ink__canvas { position: absolute; inset: 0; z-index: 2; touch-action: pan-x pan-y; cursor: crosshair; }
.odg-ink__fx { position: absolute; inset: 0; z-index: 3; pointer-events: none; }

.odg-ink-toolbar { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0 0 12px; }
.odg-ink-tool {
  display: inline-flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 16px 8px 10px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); font: inherit; color: var(--ink); text-align: left;
}
.odg-ink-tool strong { display: block; font-size: .9rem; line-height: 1.1; }
.odg-ink-tool small { display: block; font-size: .72rem; color: var(--muted); }
.odg-ink-tool.is-active { border-color: var(--navy); box-shadow: 0 0 0 3px var(--navy-100); background: var(--navy-50); }
.odg-ink-tool.is-disabled { opacity: .45; }
.odg-ink-dot { width: 26px; height: 26px; border-radius: 50%; box-shadow: inset 0 0 0 3px rgb(255 255 255 / .55); }
.odg-ink-glyph { width: 26px; text-align: center; font-size: 1.2rem; }
.odg-ink-help { margin-left: auto; font-size: .82rem; color: var(--muted); }
.odg-ink-help summary { cursor: pointer; font-weight: 600; color: var(--navy-600); padding: 8px 4px; }
.odg-ink-help ul { position: absolute; z-index: 20; right: 0; margin: 6px 0 0; padding: 12px 16px 12px 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); line-height: 1.7; }

.odg-ink-bubble {
  position: absolute; transform: translate(-50%, -100%); pointer-events: auto; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 8px 6px 6px; border-radius: 999px;
  background: var(--navy-800); color: #fff; font-size: .8rem; box-shadow: 0 6px 18px rgb(0 0 0 / .2);
  animation: bubbleIn .18s ease-out; transition: opacity .3s;
}
.odg-ink-bubble.is-below { transform: translate(-50%, 0); }
.odg-ink-bubble.is-warn { background: #7a4a00; }
.odg-ink-bubble.is-leaving { opacity: 0; }
.odg-ink-bubble__n { font: 600 .72rem var(--font-mono); background: rgb(255 255 255 / .16); border-radius: 999px; padding: 2px 7px; }
.odg-ink-bubble button { font: 600 .76rem var(--font-sans); color: #fff; background: rgb(255 255 255 / .16); border: 0; border-radius: 999px; padding: 4px 10px; cursor: pointer; }
@keyframes bubbleIn { from { opacity: 0; margin-top: 6px; } to { opacity: 1; margin-top: 0; } }
.odg-ink .odg-panel { margin-top: 14px; }

.transcript summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; }
.transcript summary::-webkit-details-marker { display: none; }
.transcript summary h2 { display: flex; align-items: center; gap: 10px; }
.transcript summary h2 svg { width: 20px; height: 20px; fill: none; stroke: var(--pink); stroke-width: 2; }
.transcript { margin-bottom: 20px; border-color: var(--pink-100); }
.transcript dd { white-space: pre-wrap; }

@media (max-width: 820px) {
  .step-tabs { grid-template-columns: 1fr 1fr; }
  .step-tab small { display: none; }
  .ink-bar { border-radius: var(--radius); bottom: 6px; }
  .ink-tool { width: 42px; height: 42px; }
  .ink-card__head { padding-inline: 16px; }
  .odg-ink { padding-inline: 16px; }
  .odg-ink-tool small { display: none; }
}

.detail-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.manuscript summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; }
.manuscript summary::-webkit-details-marker { display: none; }
.ink-original-fig { margin: 16px 0 0; }
.ink-original-fig figcaption { font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.ink-original { width: 100%; height: auto; display: block; background: #fffefb; border: 1px solid var(--line); border-radius: var(--radius-sm); }
@media print { .manuscript { display: block; } .manuscript[open] summary { display: none; } }


/* Barra lateral reducida a iconos: en iPad horizontal (hasta 1280 px) en todas las
   pantallas, y hasta 1480 px en modo escritura para dar más espacio al papel. */
@media (min-width: 821px) and (max-width: 1280px) {
  .shell { grid-template-columns: 76px 1fr; }
  .sidebar { padding: 20px 10px; align-items: center; }
  .brand { padding: 0; }
  .brand__text, .sidebar__foot { display: none; }
  .nav__item { font-size: 0; gap: 0; justify-content: center; padding: 12px; }
  .nav__item svg { width: 22px; height: 22px; }
  .nav__item[aria-current="page"]::before { left: -10px; }
  .main { padding-inline: 22px; }
  .user-chip { flex-direction: column; padding-inline: 0; }
  .user-chip__text { display: none; }
}
@media (min-width: 821px) and (max-width: 1480px) {
  body.is-ink-mode .shell { grid-template-columns: 76px 1fr; }
  body.is-ink-mode .sidebar { padding: 20px 10px; align-items: center; }
  body.is-ink-mode .brand { padding: 0; }
  body.is-ink-mode .brand__text, body.is-ink-mode .sidebar__foot { display: none; }
  body.is-ink-mode .nav__item { font-size: 0; gap: 0; justify-content: center; padding: 12px; }
  body.is-ink-mode .nav__item svg { width: 22px; height: 22px; }
  body.is-ink-mode .nav__item[aria-current="page"]::before { left: -10px; }
  body.is-ink-mode .main { padding-inline: 22px; }
  body.is-ink-mode .user-chip { flex-direction: column; padding-inline: 0; }
  body.is-ink-mode .user-chip__text { display: none; }
}
body.is-ink-mode .ink-step { max-width: none; }
