/* =========================================================
   Dent Pocket — sistema visual
   Porcelana clínica + tinta verde azulada. Claro / oscuro.
   ========================================================= */

:root {
  --bg: #F4F1EA;
  --surface: #FFFFFF;
  --surface-2: #F8F6F1;
  --surface-3: #EFEBE2;
  --ink: #102A2B;
  --ink-2: #4B5D5E;
  --ink-3: #8A9696;
  --line: #E4DFD4;
  --line-strong: #CFC8BA;
  --accent: #0E8C7F;
  --accent-ink: #FFFFFF;
  --accent-soft: #DDF2EE;
  --brand: #0B3B3C;
  --danger: #E5484D;
  --info: #3E7BFA;
  --tooth: #FFFDF7;
  --stage-bg: radial-gradient(1200px 600px at 50% 0%, #FFFFFF 0%, #F7F4EC 60%, #F1EDE3 100%);
  --shadow-sm: 0 1px 2px rgba(16, 42, 43, .06), 0 1px 1px rgba(16, 42, 43, .04);
  --shadow-md: 0 8px 24px -8px rgba(16, 42, 43, .18), 0 2px 6px rgba(16, 42, 43, .06);
  --shadow-lg: 0 24px 60px -20px rgba(16, 42, 43, .35);
  --radius: 14px;
  --radius-sm: 10px;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --logo-fg: #F7F5F0;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1416; --surface: #111D20; --surface-2: #152428; --surface-3: #1B2E33;
    --ink: #E6EFEE; --ink-2: #A9BAB8; --ink-3: #6E8483; --line: #203338; --line-strong: #2C454B;
    --accent: #3DD6C3; --accent-ink: #062422; --accent-soft: #123A37; --brand: #3DD6C3;
    --tooth: #F3EEE2; --stage-bg: radial-gradient(1200px 600px at 50% 0%, #13262A 0%, #0F1A1E 60%, #0B1416 100%);
    --shadow-md: 0 8px 24px -8px rgba(0,0,0,.5); --shadow-lg: 0 24px 60px -20px rgba(0,0,0,.7);
    --logo-fg: #0B1416;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B1416; --surface: #111D20; --surface-2: #152428; --surface-3: #1B2E33;
  --ink: #E6EFEE; --ink-2: #A9BAB8; --ink-3: #6E8483; --line: #203338; --line-strong: #2C454B;
  --accent: #3DD6C3; --accent-ink: #062422; --accent-soft: #123A37; --brand: #3DD6C3;
  --tooth: #F3EEE2; --stage-bg: radial-gradient(1200px 600px at 50% 0%, #13262A 0%, #0F1A1E 60%, #0B1416 100%);
  --shadow-md: 0 8px 24px -8px rgba(0,0,0,.5); --shadow-lg: 0 24px 60px -20px rgba(0,0,0,.7);
  --logo-fg: #0B1416;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { flex: none; }
kbd {
  font-family: var(--mono); font-size: 11px; padding: 1px 5px; border-radius: 5px;
  border: 1px solid var(--line-strong); border-bottom-width: 2px; background: var(--surface); color: var(--ink-2);
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------- Layout ---------------- */
.app {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 360px;
  grid-template-rows: 64px minmax(0, 1fr);
  grid-template-areas: "top top top" "left stage right";
  height: 100vh;
  height: 100dvh;
}
.topbar { grid-area: top; }
.panel-left { grid-area: left; }
.stage { grid-area: stage; }
.panel-right { grid-area: right; }

/* ---------------- Topbar ---------------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--brand); }
.brand-mark { width: 34px; height: 34px; color: var(--brand); }
.brand-name { font-weight: 500; font-size: 18px; letter-spacing: -.02em; color: var(--ink); }
.brand-name b { font-weight: 800; color: var(--brand); }
.patient-chip {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 5px 14px 5px 5px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); cursor: pointer;
  max-width: 340px;
}
.patient-chip:hover { border-color: var(--line-strong); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 13px; flex: none;
}
.chip-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.chip-text b { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-text small { color: var(--ink-3); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

/* ---------------- Botones ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: 10px;
  border: 1px solid transparent; background: var(--surface-2);
  font-weight: 650; font-size: 13.5px; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .08s, color .15s;
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn.primary { background: var(--brand); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: var(--accent-ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: var(--accent-ink); } }
.btn.primary:hover { filter: brightness(1.1); }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.outline { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn.outline:hover { border-color: var(--ink-3); }
.btn.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn.icon-only { width: 38px; padding: 0; justify-content: center; }
.btn.tiny { height: 30px; padding: 0 10px; font-size: 12.5px; gap: 6px; border-radius: 8px; }
.btn.tiny svg { width: 14px; height: 14px; }
.btn:disabled { opacity: .35; pointer-events: none; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* ---------------- Menú exportar ---------------- */
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: 300px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; z-index: 50;
  animation: pop .14s ease-out;
}
.menu button {
  display: flex; gap: 12px; align-items: center; width: 100%;
  padding: 10px 12px; border: 0; background: none; border-radius: 10px; text-align: left;
}
.menu button:hover, .menu button:focus-visible { background: var(--surface-2); }
.menu button svg { width: 20px; height: 20px; color: var(--accent); }
.menu button span { display: flex; flex-direction: column; }
.menu button small { color: var(--ink-3); font-size: 12px; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ---------------- Paneles ---------------- */
.panel {
  background: var(--surface);
  overflow-y: auto;
  scrollbar-width: thin;
}
.panel-left { border-right: 1px solid var(--line); padding: 18px 18px 24px; }
.panel-right { border-left: 1px solid var(--line); }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 800; }

.patient-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 10px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 11.5px; font-weight: 700; color: var(--ink-2); }
.field input, .field select, .field textarea, .input {
  width: 100%; border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 9px; padding: 8px 10px; font-size: 13.5px; outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.field textarea, textarea.input { resize: vertical; min-height: 58px; line-height: 1.4; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field.name input { font-size: 16px; font-weight: 700; padding: 10px 12px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 18px 0 14px; }
.stat {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.stat b { display: block; font-size: 22px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.stat span { font-size: 11.5px; color: var(--ink-3); font-weight: 600; }
.stat.red b { color: var(--danger); }
.stat.blue b { color: var(--info); }
.stat.wide { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline; }
.stat.wide b { font-size: 17px; }

.legend { border-top: 1px solid var(--line); padding-top: 12px; }
.legend summary { cursor: pointer; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); list-style: none; }
.legend summary::-webkit-details-marker { display: none; }
.legend summary::after { content: '＋'; float: right; }
.legend[open] summary::after { content: '－'; }
.legend-group { margin-top: 10px; }
.legend-group h4 { margin: 0 0 6px; font-size: 11.5px; color: var(--ink-2); }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); padding: 2px 0; }
.legend-item i { width: 12px; height: 12px; border-radius: 4px; flex: none; }

/* ---------------- Escenario ---------------- */
.stage {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--stage-bg);
  overflow-y: auto;
}
.stage-toolbar {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 20px 0;
}
.segmented {
  display: inline-flex; padding: 4px; gap: 2px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.segmented button {
  display: inline-flex; align-items: center; gap: 7px;
  border: 0; background: none; padding: 7px 12px; border-radius: 9px;
  font-weight: 700; font-size: 13px; color: var(--ink-2);
}
.segmented button svg { width: 17px; height: 17px; }
.segmented button[aria-selected="true"], .segmented button[aria-checked="true"] {
  background: var(--brand); color: #fff;
}
:root[data-theme="dark"] .segmented button[aria-selected="true"], :root[data-theme="dark"] .segmented button[aria-checked="true"] { color: var(--accent-ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .segmented button[aria-selected="true"], :root:not([data-theme="light"]) .segmented button[aria-checked="true"] { color: var(--accent-ink); } }
.segmented.small button { padding: 6px 10px; font-size: 12.5px; }

.brushbar {
  flex: none;
  display: flex; align-items: center; gap: 10px; margin: 12px 20px 0;
  padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-sm); overflow-x: auto; scrollbar-width: none;
}
.brush-mode {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2);
  padding: 7px 12px; border-radius: 10px; font-weight: 800; font-size: 13px;
}
.brush-mode svg { width: 17px; height: 17px; }
.brush-mode[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.brush-swatches { display: flex; gap: 6px; flex: none; }
.swatch {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 5px 11px 5px 6px; font-size: 12.5px; font-weight: 650; color: var(--ink-2);
  transition: border-color .12s, background .12s;
}
.swatch i { width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); }
.swatch kbd { font-size: 10px; padding: 0 4px; margin-left: 2px; }
.swatch:hover { border-color: var(--line-strong); }
.swatch[aria-pressed="true"] { border-color: var(--ink); background: var(--surface-2); color: var(--ink); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--sw); }
.swatch.eraser i { background: repeating-linear-gradient(45deg, var(--line-strong) 0 3px, transparent 3px 6px); border: 1px solid var(--line-strong); }
.swatch-sep { width: 1px; background: var(--line); margin: 4px 2px; flex: none; }

.canvas-wrap {
  position: relative; flex: 1 0 auto; min-height: 420px;
  display: flex; align-items: center; justify-content: center;
  padding: 10px 20px;
}
.canvas {
  width: 100%; max-width: calc(var(--zoom, 1) * 760px);
  transition: max-width .25s ease;
}
.canvas[data-view="grid"] { max-width: calc(var(--zoom, 1) * 980px); }
.canvas[data-view="closed"] { max-width: calc(var(--zoom, 1) * 900px); }
.canvas .odonto-svg { width: 100%; height: auto; display: block; max-height: calc(var(--zoom, 1) * (100dvh - 260px)); overflow: visible; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.canvas[data-view="grid"] .odonto-svg, .canvas[data-view="closed"] .odonto-svg { max-height: none; }
.canvas .tooth { cursor: pointer; }
.canvas .tooth .tooth-body { transition: filter .15s; }
.canvas .tooth:hover .tooth-body { filter: brightness(.94) drop-shadow(0 0 1.2px var(--accent)); }
.canvas.brushing .surf:hover { fill: var(--brush-color, var(--accent)); fill-opacity: .55; }
.canvas.brushing.tooth-brush .tooth:hover .tooth-body { filter: drop-shadow(0 0 1.6px var(--brush-color)); }
.canvas.brushing .tooth { cursor: crosshair; }
.canvas .tooth-label { cursor: pointer; }
.canvas .tooth.pulse .tooth-body { animation: pulse 1.2s ease-out; }
@keyframes pulse { 0% { filter: drop-shadow(0 0 0 var(--accent)); } 35% { filter: drop-shadow(0 0 3px var(--accent)) brightness(1.05); } 100% { filter: none; } }
.canvas.reveal .tooth { animation: reveal .5s both cubic-bezier(.2,.8,.2,1); }
@keyframes reveal { from { opacity: 0; } }

.empty-hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  width: min(560px, calc(100% - 40px)); text-align: center;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 14px; padding: 10px 16px; box-shadow: var(--shadow-md);
  font-size: 13px; color: var(--ink-2);
}
.empty-hint p { margin: 2px 0; }
.muted { color: var(--ink-3); }
.zoom { position: absolute; right: 18px; top: 10px; display: flex; flex-direction: column; gap: 4px; }
.zoom .btn { background: var(--surface); border: 1px solid var(--line); height: 32px; width: 32px; }
.zoom .btn svg { width: 16px; height: 16px; }

/* ---------------- Resumen (tabs) ---------------- */
.summary {
  margin: 0 20px 20px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); flex: none;
}
.tabs { display: flex; gap: 2px; padding: 6px 6px 0; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button {
  border: 0; background: none; padding: 10px 14px; font-weight: 700; font-size: 13px; color: var(--ink-3);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center; margin-left: 4px; }
.badge:empty { display: none; }
.tab-body { padding: 12px 16px 16px; max-height: 360px; overflow-y: auto; }
.empty-row { color: var(--ink-3); padding: 14px 4px; text-align: center; font-size: 13px; }

.find-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.find-card {
  text-align: left; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px;
  padding: 10px 12px; display: flex; gap: 10px; align-items: flex-start; transition: border-color .12s;
}
.find-card:hover { border-color: var(--accent); }
.find-card .num { font-family: var(--mono); font-weight: 600; font-size: 15px; padding: 2px 8px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.find-card .what { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.find-card .name { font-size: 11.5px; color: var(--ink-3); font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 650; padding: 2px 8px 2px 6px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); }
.tag i { width: 8px; height: 8px; border-radius: 50%; }
.find-card .note { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.plan-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.plan-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 800; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.plan-table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.plan-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.plan-table tfoot td { font-weight: 800; border-bottom: 0; }
.tooth-pill { font-family: var(--mono); font-weight: 600; border: 1px solid var(--line); background: var(--surface-2); padding: 2px 7px; border-radius: 7px; }
.status {
  border: 0; font-size: 12px; font-weight: 750; border-radius: 99px; padding: 3px 10px 3px 8px;
  display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); color: var(--ink-2);
}
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--st); }

.visits { display: flex; flex-direction: column; gap: 10px; }
.visit-new { display: grid; grid-template-columns: 150px 1fr auto; gap: 8px; align-items: start; }
.visit { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; padding: 10px 0; border-top: 1px dashed var(--line); }
.visit time { font-family: var(--mono); font-size: 12px; color: var(--ink-3); padding-top: 2px; }
.visit p { margin: 0; white-space: pre-wrap; }

/* ---------------- Inspector ---------------- */
.inspector-empty { padding: 40px 28px; text-align: center; color: var(--ink-2); }
.inspector-empty .illus { width: 120px; height: 120px; margin-bottom: 8px; }
.inspector-empty h3 { margin: 6px 0; color: var(--ink); font-size: 18px; }
.inspector-empty p { margin: 0 0 16px; font-size: 13.5px; }
.tips { list-style: none; padding: 14px; margin: 0; text-align: left; font-size: 12.5px; background: var(--surface-2); border-radius: 12px; display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--line); }

.inspector-body { padding: 16px 18px 28px; display: flex; flex-direction: column; gap: 18px; }
.ins-head { display: flex; align-items: center; gap: 12px; }
.ins-num {
  font-family: var(--mono); font-weight: 600; font-size: 26px; line-height: 1;
  padding: 10px 12px; border-radius: 14px; background: var(--brand); color: #fff; letter-spacing: -.02em;
}
:root[data-theme="dark"] .ins-num { color: var(--accent-ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ins-num { color: var(--accent-ink); } }
.ins-title { flex: 1; min-width: 0; }
.ins-title h3 { margin: 0; font-size: 16px; line-height: 1.25; }
.ins-title small { color: var(--ink-3); font-size: 12px; }
.ins-nav { display: flex; gap: 2px; }
.ins-nav .btn { width: 32px; height: 32px; }
.ins-section h4 { margin: 0 0 8px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 800; display: flex; justify-content: space-between; align-items: center; }
.ins-section h4 small { text-transform: none; letter-spacing: 0; font-weight: 600; }
.ins-tooth { display: grid; grid-template-columns: 170px 1fr; gap: 14px; align-items: center; }
.inspector-svg { width: 170px; height: 170px; display: block; }
.inspector-svg .surf { cursor: pointer; transition: fill-opacity .12s; }
.inspector-svg .surf:hover { fill: var(--brush-color, var(--accent)); fill-opacity: .5; }
.surf-list { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.surf-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px; border-radius: 8px; background: var(--surface-2); }
.surf-row b { font-weight: 700; }
.surf-row span { color: var(--ink-3); font-size: 12px; display: inline-flex; align-items: center; gap: 5px; }
.surf-row span i { width: 9px; height: 9px; border-radius: 50%; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 5px 11px 5px 7px; font-size: 12.5px; font-weight: 650; color: var(--ink-2);
  transition: all .12s;
}
.chip i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--c); }
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip[aria-pressed="true"] { background: color-mix(in srgb, var(--c) 14%, var(--surface)); border-color: var(--c); color: var(--ink); }
.chip[aria-pressed="true"] i { background: var(--c); }
.chip.mixed i { background: linear-gradient(90deg, var(--c) 50%, transparent 50%); }

.actions-list { display: flex; flex-direction: column; gap: 6px; }
.action {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; align-items: center;
  padding: 8px 8px 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2);
}
.action.done .a-text { text-decoration: line-through; color: var(--ink-3); }
.a-check {
  width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--line-strong); background: var(--surface);
  display: grid; place-items: center; padding: 0;
}
.a-check svg { width: 14px; height: 14px; opacity: 0; }
.action.done .a-check { background: var(--info); border-color: var(--info); color: #fff; }
.action.done .a-check svg { opacity: 1; }
.action.curso .a-check { border-color: #D4A017; }
.a-text { font-size: 13px; min-width: 0; overflow-wrap: anywhere; }
.a-cost { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.icon-btn { border: 0; background: none; color: var(--ink-3); width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; padding: 0; }
.icon-btn:hover { background: var(--surface-3); color: var(--danger); }
.icon-btn svg { width: 15px; height: 15px; }
.action-add { display: grid; grid-template-columns: 1fr 96px auto; gap: 6px; margin-top: 6px; }
.suggest { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.suggest button { border: 1px dashed var(--line-strong); background: none; border-radius: 99px; font-size: 11.5px; padding: 3px 9px; color: var(--ink-2); }
.suggest button:hover { border-style: solid; border-color: var(--accent); color: var(--accent); }

.multi-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.multi-head .tooth-pill { font-size: 13px; }

/* ---------------- Modal ---------------- */
.modal { border: 0; padding: 0; background: transparent; max-width: min(620px, calc(100vw - 24px)); width: 100%; }
.modal::backdrop { background: rgba(8, 20, 22, .45); backdrop-filter: blur(3px); }
.modal-card {
  background: var(--surface); color: var(--ink); border-radius: 18px; box-shadow: var(--shadow-lg);
  padding: 22px; display: flex; flex-direction: column; gap: 14px; animation: pop .16s ease-out;
  max-height: calc(100dvh - 32px); overflow-y: auto;
}
.modal-card h3 { margin: 0; font-size: 19px; letter-spacing: -.01em; }
.modal-card p { margin: 0; color: var(--ink-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.drop-area {
  border: 2px dashed var(--line-strong); border-radius: 14px; padding: 26px; text-align: center;
  background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.drop-area:hover, .drop-area.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-area svg { width: 34px; height: 34px; color: var(--accent); }
.drop-area b { display: block; margin-top: 6px; font-size: 15px; }
.drop-area small { color: var(--ink-3); }
.paste-box { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; background: var(--surface-2); }
.paste-box summary { cursor: pointer; font-size: 13px; color: var(--ink-2); }
.paste-box[open] { display: flex; flex-direction: column; gap: 8px; }
.paste-box[open] summary { margin-bottom: 2px; }
.paste-box .btn { align-self: flex-end; }
.ai-steps { margin: 4px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--ink-2); }
.ai-steps a { color: var(--accent); font-weight: 700; }
.ai-steps .btn { align-self: auto; }
.formats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px; font-size: 12.5px; }
.formats div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; border: 1px solid var(--line); }
.formats b { display: block; font-size: 12.5px; }
.formats span { color: var(--ink-3); font-size: 11.5px; }
.report { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; font-size: 13px; border: 1px solid var(--line); }
.report ul { margin: 6px 0 0; padding-left: 18px; color: var(--ink-2); max-height: 120px; overflow: auto; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice label { border: 1px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; display: flex; gap: 10px; align-items: flex-start; }
.choice label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice small { display: block; color: var(--ink-3); }
.template-links { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; }
.template-links a { color: var(--accent); font-weight: 700; }

/* ---------------- Drop / toasts ---------------- */
.dropzone {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 20%, rgba(8,20,22,.5)); backdrop-filter: blur(4px);
}
.dropzone > div { background: var(--surface); padding: 36px 48px; border-radius: 22px; text-align: center; border: 2px dashed var(--accent); box-shadow: var(--shadow-lg); }
.dropzone svg { width: 44px; height: 44px; color: var(--accent); }
.dropzone p { font-size: 18px; font-weight: 800; margin: 10px 0 4px; }
.dropzone small { color: var(--ink-3); }
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px;
  font-weight: 650; font-size: 13.5px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: center;
  animation: toast-in .2s ease-out;
}
.toast.error { background: var(--danger); color: #fff; }
.toast button { background: none; border: 0; color: inherit; text-decoration: underline; font-weight: 800; padding: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

.drawer-scrim { display: none; }
.sheet-handle { display: none; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1280px) {
  .app { grid-template-columns: minmax(0, 1fr) 340px; grid-template-areas: "top top" "stage right"; }
  .panel-left {
    position: fixed; top: 64px; left: 0; bottom: 0; width: min(340px, 92vw); z-index: 40;
    transform: translateX(-102%); transition: transform .25s ease; box-shadow: var(--shadow-lg);
  }
  .app.drawer-open .panel-left { transform: none; }
  .app.drawer-open .drawer-scrim { display: block; position: fixed; inset: 64px 0 0 0; background: rgba(8,20,22,.35); z-index: 35; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "stage"; }
  .topbar { gap: 8px; padding: 0 10px; }
  .brand-name { display: none; }
  .top-actions .btn span { display: none; }
  .top-actions .btn:not(.icon-only) { width: 38px; padding: 0; justify-content: center; }
  #btnUndo, #btnRedo, .sep { display: none; }
  .patient-chip { flex: 1; max-width: none; }
  .stage-toolbar { padding: 10px 12px 0; }
  .segmented button span { display: none; }
  .segmented button { padding: 7px 10px; }
  .brushbar { margin: 10px 12px 0; }
  .canvas-wrap { padding: 6px 8px; min-height: 340px; }
  .summary { margin: 0 12px 110px; }
  .panel-right {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; max-height: 56dvh;
    border-left: 0; border-top: 1px solid var(--line); border-radius: 20px 20px 0 0;
    box-shadow: 0 -20px 50px -20px rgba(0,0,0,.35);
    transform: translateY(calc(100% - 64px)); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  }
  .app.sheet-open .panel-right { transform: none; }
  .sheet-handle { display: block; width: 44px; height: 5px; border-radius: 9px; background: var(--line-strong); margin: 8px auto 0; }
  .inspector-empty { padding: 14px 20px; }
  .inspector-empty .illus, .inspector-empty .tips { display: none; }
  .inspector-empty h3 { font-size: 15px; }
  .inspector-empty p { font-size: 12.5px; }
  .ins-tooth { grid-template-columns: 140px 1fr; }
  .inspector-svg { width: 140px; height: 140px; }
  .visit-new { grid-template-columns: 1fr; }
  .visit { grid-template-columns: 1fr auto; }
  .visit time { grid-column: 1 / -1; }
  .choice { grid-template-columns: 1fr; }
  .zoom { display: none; }
  .canvas-wrap { flex-direction: column; }
  .empty-hint { position: static; transform: none; width: 100%; margin-top: 8px; }
}

/* ---------------- Informe para imprimir ---------------- */
.print-report { display: none; }
@media print {
  @page { size: letter; margin: 14mm; }
  body { background: #fff; color: #111; }
  .app, .toasts, .dropzone, .modal { display: none !important; }
  .print-report { display: block; font-size: 11px; color: #1b2526; }
  .pr-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid #0B3B3C; padding-bottom: 8px; margin-bottom: 12px; }
  .pr-brand { font-size: 22px; font-weight: 800; color: #0B3B3C; }
  .pr-sub, .pr-date { color: #5B6770; }
  .pr-patient h2 { margin: 0 0 6px; font-size: 18px; }
  .pr-patient dl { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px 14px; margin: 0 0 8px; }
  .pr-patient dt { font-size: 9px; text-transform: uppercase; letter-spacing: .06em; color: #7b8587; }
  .pr-patient dd { margin: 0; font-weight: 600; }
  .pr-patient p { margin: 4px 0; }
  .pr-charts { display: grid; grid-template-columns: 1fr 1.5fr; gap: 16px; align-items: center; margin: 12px 0; break-inside: avoid; }
  .pr-charts svg { width: 100%; height: auto; }
  .pr-arch svg { max-height: 120mm; }
  .pr-stats { display: flex; gap: 14px; color: #5B6770; margin-bottom: 6px; }
  .pr-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0 10px; }
  .pr-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-report h3 { font-size: 13px; color: #0E8C7F; margin: 14px 0 6px; break-after: avoid; }
  .print-report table { width: 100%; border-collapse: collapse; }
  .print-report th { text-align: left; background: #0B3B3C; color: #fff; padding: 5px 7px; font-size: 10px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-report td { border-bottom: 1px solid #e3ded3; padding: 5px 7px; vertical-align: top; }
  .print-report tr { break-inside: avoid; }
  .print-report .num { text-align: right; }
  .print-report .tot td { font-weight: 800; border-bottom: 0; }
  .print-report svg * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pr-sign { margin-top: 40px; width: 260px; break-inside: avoid; }
  .pr-sign .line { border-top: 1px solid #333; margin-bottom: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
