/* DPViewer — visor. Oscuro por uso: se lee imagen radiológica, la sala suele estar en penumbra. */
:root {
  --bg: #090d10; --surface: #0f1519; --surface-2: #141c21; --line: #1f2a30; --line-2: #2a3840;
  --text: #e3eaec; --text-2: #a9b8bd; --text-3: #7d8f96; --accent: #5fd4c0; --accent-ink: #062521;
  --warn: #f2c14e; --err: #ef7a6a; --radius: 8px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --font: "IBM Plex Sans", system-ui, sans-serif; --mono: "IBM Plex Mono", ui-monospace, monospace; --serif: "Fraunces", Georgia, serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 400 13px/1.45 var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; }
::selection { background: rgba(95, 212, 192, .32); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; } ::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.num, output, kbd { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* barra superior */
.top { height: 48px; display: flex; align-items: center; gap: 16px; padding: 0 12px 0 14px; border-bottom: 1px solid var(--line); background: var(--surface); position: relative; z-index: 3; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
.brand-mark { width: 24px; height: 24px; color: var(--accent); stroke: none; }
.brand-mark rect, .brand-mark path { stroke: currentColor; }
.brand-name { font: 600 16px/1 var(--serif); letter-spacing: -.01em; }
.brand-tld { color: var(--text-3); font-weight: 400; }
.study { display: flex; flex-direction: column; line-height: 1.2; padding-left: 16px; border-left: 1px solid var(--line); min-width: 0; }
.mar-badge { font: 500 11px/1 var(--mono); letter-spacing: .04em; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text-2); cursor: pointer; white-space: nowrap; transition: border-color .15s, color .15s, background .15s; }
.mar-badge:hover { border-color: var(--text-3); }
.mar-badge.on { border-color: var(--warn); color: var(--warn); background: rgba(242, 193, 78, .08); }
.mar .seg { margin-bottom: 6px; }
.mar-done { color: var(--text-2); }
.study b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.study span { color: var(--text-3); font: 400 11px var(--mono); }
.top-actions { margin-left: auto; display: flex; gap: 4px; align-items: center; }

.btn { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 7px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text); white-space: nowrap; transition: background .15s, border-color .15s, color .15s; text-decoration: none; }
.btn:hover { background: #1a242a; border-color: #36474f; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: #79e0cf; }
.btn.link { background: none; border: 0; color: var(--accent); padding: 0 4px; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.btn.icon { width: 32px; padding: 0; justify-content: center; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.lang { height: 32px; border-radius: 7px; border: 1px solid var(--line-2); background: var(--surface-2); padding: 0 6px; }

/* estructura */
.shell { display: grid; grid-template-columns: 76px 1fr 288px; height: calc(100vh - 48px); height: calc(100dvh - 48px); }
.rail { display: flex; flex-direction: column; gap: 2px; padding: 8px 6px; border-right: 1px solid var(--line); background: var(--surface); overflow-y: auto; }
.rail button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 2px 7px; border: 0; border-radius: 8px; background: none; color: var(--text-3); font-size: 10.5px; line-height: 1.15; text-align: center; transition: background .15s, color .15s; }
.rail button svg { width: 20px; height: 20px; }
.rail button:hover { color: var(--text); background: var(--surface-2); }
.rail button.on { color: var(--accent); background: rgba(95, 212, 192, .09); }
.stage-wrap { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.toolbar { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.toolbar.hidden { display: none; }
.tgroup { display: flex; align-items: center; gap: 2px; padding-right: 6px; margin-right: 2px; border-right: 1px solid var(--line); }
.tgroup:empty { display: none; }
.tgroup.right { margin-left: auto; border-right: 0; gap: 8px; }
.tgroup button { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 9px; border: 1px solid transparent; border-radius: 7px; background: none; color: var(--text-2); font-size: 12px; transition: background .15s, color .15s; }
.tgroup button.icon { width: 30px; padding: 0; justify-content: center; }
.tgroup button:hover { background: var(--surface-2); color: var(--text); }
.tgroup button.on { background: rgba(95, 212, 192, .12); border-color: rgba(95, 212, 192, .35); color: var(--accent); }
.mini { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 11.5px; }
.mini select { height: 28px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--surface-2); padding: 0 4px; font-size: 12px; }

.stage { flex: 1; display: grid; gap: 2px; background: #000; min-height: 0; padding: 2px; }
.g-1 { grid-template: 1fr / 1fr; }
.g-2 { grid-template: 1fr / 1fr 1fr; }
.g-3 { grid-template: 1fr / 1fr 1fr 1fr; }
.g-2x2 { grid-template: 1fr 1fr / 1fr 1fr; }
.g-pano { grid-template: 1fr 1fr / 1.3fr 1fr; }
.g-pano .slot[data-slot=pano] { grid-column: 1 / -1; }
.g-tmj { grid-template: 1fr 1fr / 1.15fr 1fr 1fr; }
.g-tmj .slot[data-slot=taxial] { grid-row: 1 / -1; }
.g-guided { grid-template: 1fr 1fr / 1.6fr 1fr; }
.g-guided .slot[data-slot=oblique] { grid-row: 1 / -1; }
.g-report { display: block; overflow: auto; background: var(--bg); }
.slot { position: relative; min-width: 0; min-height: 0; background: #05080a; }
.slot-empty { display: grid; place-items: center; background: var(--bg); text-align: center; padding: 24px; }
.slot-empty h2 { font: 500 26px/1.15 var(--serif); margin: 0 0 8px; letter-spacing: -.01em; }
.slot-empty p { color: var(--text-2); max-width: 52ch; margin: 0 auto 20px; }

.vp { position: absolute; inset: 0; overflow: hidden; touch-action: none; user-select: none; border-radius: 3px; }
.vp canvas { display: block; position: absolute; inset: 0; }
.vp.active { box-shadow: inset 0 0 0 1px rgba(95, 212, 192, .55); }
.vp-label { position: absolute; top: 8px; left: 10px; display: flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 500; color: var(--text-2); pointer-events: none; text-shadow: 0 1px 2px #000; }
.vp-dot { width: 7px; height: 7px; border-radius: 2px; }
.vp-info, .vp-corner { position: absolute; top: 8px; right: 10px; font: 400 11px var(--mono); color: var(--text-3); pointer-events: none; text-shadow: 0 1px 2px #000; }
.vp-corner { top: auto; bottom: 8px; left: 10px; right: auto; }
.vp-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-3); }
body[data-active-tool=dist] .vp canvas, body[data-active-tool=angle] .vp canvas, body[data-active-tool=seed] .vp canvas, body[data-active-tool=pin] .vp canvas, body[data-active-tool=curve] .vp canvas, body[data-active-tool=nav] .vp canvas { cursor: crosshair; }
body[data-active-tool=pan] .vp canvas { cursor: grab; } body[data-active-tool=erase] .vp canvas { cursor: not-allowed; } body[data-active-tool=text] .vp canvas { cursor: text; }
body[data-active-tool=wl] .vp canvas, body[data-active-tool=zoom] .vp canvas { cursor: ns-resize; }
.vp3d canvas { cursor: grab; }
.vp3d canvas:active { cursor: grabbing; }
.photo-overlay { position: absolute; left: 50%; top: 50%; max-width: 80%; max-height: 80%; pointer-events: none; mix-blend-mode: normal; transform-origin: center; }

/* panel lateral */
.panel { border-left: 1px solid var(--line); background: var(--surface); overflow-y: auto; }
.panel section { padding: 14px 16px 16px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.panel h3 { margin: 0; font: 600 11.5px/1.2 var(--font); color: var(--text); letter-spacing: .02em; }
.hint { margin: 0; color: var(--text-3); font-size: 12px; line-height: 1.5; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; margin: 0; font-size: 12px; }
.kv dt { color: var(--text-3); } .kv dd { margin: 0; text-align: right; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv.big dd { color: var(--text); font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-2); }
.field > span { display: flex; justify-content: space-between; gap: 8px; }
.field output { color: var(--text); font-size: 11.5px; }
.field select, .field textarea { border-radius: 6px; border: 1px solid var(--line-2); background: var(--surface-2); padding: 6px 8px; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; background: var(--line-2); border-radius: 3px; }
input[type=range]::-moz-range-track { height: 3px; background: var(--line-2); border-radius: 3px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5.5px; border-radius: 50%; background: var(--text); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line-2); }
input[type=range]::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: var(--text); border: 3px solid var(--surface); }
input[type=range]:hover::-webkit-slider-thumb { background: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); }
.check { display: flex; gap: 8px; align-items: flex-start; color: var(--text-2); font-size: 12px; cursor: pointer; }
.row { display: flex; flex-wrap: wrap; gap: 6px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.col .btn { justify-content: center; }
.seg { display: flex; padding: 2px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); }
.seg button { flex: 1; border: 0; background: none; color: var(--text-3); padding: 5px 4px; border-radius: 6px; font-size: 11.5px; transition: background .15s, color .15s; }
.seg button.on { background: var(--surface-2); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.mlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.mlist li { display: grid; grid-template-columns: 22px 1fr auto 24px; align-items: center; gap: 6px; padding: 4px 0 4px 2px; border-radius: 6px; cursor: pointer; font-size: 12px; color: var(--text-3); }
.mlist li b { font: 500 12px var(--mono); color: var(--warn); }
.mlist li.empty { display: block; line-height: 1.5; cursor: default; }
.mlist li.sel { background: rgba(61, 220, 106, .1); } .mlist li.sel b { color: #3ddc6a; }
.mlist li.off span, .mlist li.off b { opacity: .4; }
.mlist .eye { width: 22px; height: 22px; display: grid; place-items: center; color: var(--text-3); border-radius: 5px; }
.mlist .eye:hover { color: var(--text); } .mlist .eye svg { width: 15px; height: 15px; }
.mlist li.off .eye { opacity: .45; }
.x { width: 24px; height: 24px; display: grid; place-items: center; border: 0; background: none; color: var(--text-3); border-radius: 5px; }
.x:hover { background: var(--surface-2); color: var(--err); }
.x svg { width: 14px; height: 14px; }
.meshes { display: flex; flex-direction: column; gap: 10px; }
.mesh { border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.mesh-h { display: flex; align-items: center; gap: 8px; }
.mesh-h b { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw { width: 10px; height: 10px; border-radius: 3px; }
.chart { width: 100%; height: 150px; display: block; }

/* bienvenida */
.welcome { position: fixed; inset: 48px 0 0 0; display: grid; place-items: center; background: radial-gradient(1200px 600px at 50% 0%, #0f1a1e 0%, var(--bg) 60%); z-index: 2; padding: 20px; overflow: auto; }
.welcome[hidden] { display: none; }
.welcome-inner { width: min(640px, 100%); text-align: center; }
.drop { border: 1.5px dashed var(--line-2); border-radius: 18px; padding: 40px 32px 28px; background: rgba(15, 21, 25, .6); transition: border-color .2s var(--ease), background .2s var(--ease), transform .25s var(--ease); }
body.dragging .drop { border-color: var(--accent); background: rgba(95, 212, 192, .06); transform: scale(1.01); }
.drop-art { width: 200px; height: 120px; stroke: var(--line-2); stroke-width: 1.5; margin-bottom: 10px; }
.drop-art rect { fill: #0b1114; }
.drop-art .drop-x { stroke: var(--accent); opacity: .5; }
.drop-art .drop-c { fill: var(--accent); stroke: none; opacity: .9; }
.drop h1 { font: 500 30px/1.12 var(--serif); letter-spacing: -.015em; margin: 0 0 10px; text-wrap: balance; }
.drop p { color: var(--text-2); margin: 0 auto 22px; max-width: 54ch; font-size: 13.5px; text-wrap: pretty; }
.drop-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.drop-actions .btn { height: 38px; padding: 0 16px; }
.drop .check { justify-content: center; color: var(--text-3); }
.privacy { display: inline-flex; gap: 8px; align-items: center; color: var(--text-2); margin: 18px 0 6px; }
.privacy svg { color: var(--accent); width: 16px; height: 16px; }
.disclaimer { color: var(--text-3); font-size: 11.5px; max-width: 60ch; margin: 0 auto; }
body:not(.loaded) .panel, body:not(.loaded) .toolbar { visibility: hidden; }

/* progreso y avisos */
.busy { position: fixed; inset: 0; background: rgba(5, 8, 10, .55); display: grid; place-items: center; z-index: 20; backdrop-filter: blur(2px); }
.busy[hidden] { display: none; }
.busy-card { width: min(340px, 86vw); background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px; padding: 18px; box-shadow: 0 18px 48px rgba(0, 0, 0, .5); }
.busy-label { margin-bottom: 12px; color: var(--text); }
.bar { height: 3px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); transform-origin: left; transition: transform .25s var(--ease); }
.busy.indet .bar i { width: 35%; animation: indet 1.1s var(--ease) infinite; transform: none !important; }
@keyframes indet { from { margin-left: -35%; } to { margin-left: 100%; } }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 12px); opacity: 0; pointer-events: none; max-width: min(560px, 92vw); background: #1a242a; border: 1px solid var(--line-2); color: var(--text); padding: 10px 14px; border-radius: 10px; box-shadow: 0 12px 36px rgba(0, 0, 0, .45); transition: opacity .2s var(--ease), transform .25s var(--ease); z-index: 30; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.warn { border-color: rgba(242, 193, 78, .5); } .toast.err { border-color: rgba(239, 122, 106, .6); }
.flash { position: fixed; inset: 0; background: #fff; opacity: .16; pointer-events: none; z-index: 40; animation: flash .42s var(--ease) forwards; }
@keyframes flash { to { opacity: 0; } }

/* diálogos */
.sheet { border: 1px solid var(--line-2); border-radius: 14px; background: var(--surface); color: var(--text); padding: 22px; width: min(460px, 92vw); box-shadow: 0 24px 64px rgba(0, 0, 0, .55); }
.sheet.wide { width: min(720px, 94vw); }
.sheet::backdrop { background: rgba(3, 5, 6, .6); backdrop-filter: blur(3px); }
.sheet h2 { font: 500 22px/1.2 var(--serif); margin: 0 0 6px; }
.sheet h3 { font-size: 12px; margin: 0 0 8px; color: var(--text-2); }
.sheet p { color: var(--text-2); margin: 0 0 14px; }
.sheet ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.sheet ul b { color: var(--text); font-weight: 500; }
.keys { display: grid !important; grid-template-columns: 1fr 1fr; }
kbd { display: inline-block; min-width: 20px; text-align: center; padding: 1px 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; font-size: 11px; color: var(--text); }
.help-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; margin: 14px 0; }
.fine { font-size: 11.5px; color: var(--text-3) !important; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.series-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow: auto; }
.opts { border: 0; margin: 4px 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.opts legend { font-size: 12px; color: var(--text-2); padding: 0; margin-bottom: 8px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.opt:hover { border-color: var(--text-3); }
.opt:has(input:checked) { border-color: var(--accent); background: #13201e; }
.opt input { accent-color: var(--accent); margin: 3px 0 0; }
.opt span { display: flex; flex-direction: column; gap: 2px; }
.opt b { font-weight: 500; } .opt small { color: var(--text-3); font-size: 12px; }
.choice { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: 100%; text-align: left; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface-2); margin-bottom: 6px; transition: border-color .15s, background .15s; }
.choice:hover { border-color: var(--accent); background: #16211f; }
.choice b { font-weight: 500; } .choice span { color: var(--text-3); font-size: 12px; }

/* informe */
.report { max-width: 1040px; margin: 0 auto; padding: 28px 28px 60px; }
.report-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
.report-head h2 { font: 500 30px/1.1 var(--serif); margin: 0; letter-spacing: -.015em; }
.report-head p { color: var(--text-3); margin: 0; font-family: var(--mono); }
.notes textarea { min-height: 110px; resize: vertical; font-size: 13.5px; line-height: 1.55; background: var(--surface); }
.caps { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-top: 20px; }
.caps figure { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.caps img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: contain; background: #000; }
.caps figcaption { display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 10px; }
.caps figcaption input { flex: 1; min-width: 0; border: 0; background: none; padding: 4px 0; font-size: 12.5px; }
.cap-tools { display: flex; gap: 2px; } .cap-tools button { width: 26px; height: 26px; border: 0; border-radius: 6px; background: none; color: var(--text-3); display: grid; place-items: center; }
.cap-tools button:hover { background: var(--surface-2); color: var(--text); } .cap-tools svg { width: 14px; height: 14px; }
.caps-empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 50px 20px; border: 1.5px dashed var(--line-2); border-radius: 12px; color: var(--text-3); text-align: center; }
.caps-empty svg { width: 28px; height: 28px; }

/* tableta y móvil */
@media (max-width: 1100px) { .shell { grid-template-columns: 68px 1fr 248px; } .tgroup button span { display: none; } .tgroup button { padding: 0 7px; } }
@media (max-width: 820px) {
  body { overflow: auto; }
  .top { gap: 8px; } .top-actions .btn span, .study { display: none; }
  .shell { grid-template-columns: 1fr; grid-template-rows: auto auto minmax(0, 1fr); height: auto; min-height: calc(100dvh - 48px); }
  .rail { flex-direction: row; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; padding: 6px; order: 0; }
  .rail button { min-width: 72px; }
  .stage-wrap { height: 72dvh; order: 1; }
  .panel { order: 2; border-left: 0; border-top: 1px solid var(--line); }
  .g-2x2, .g-3, .g-pano, .g-tmj, .g-guided, .g-2 { grid-template: none; grid-auto-rows: minmax(240px, 1fr); grid-template-columns: 1fr; overflow-y: auto; }
  .g-pano .slot, .g-tmj .slot, .g-guided .slot { grid-column: auto !important; grid-row: auto !important; }
  .stage { overflow-y: auto; }
  .help-grid { grid-template-columns: 1fr; }
  .drop { padding: 28px 18px 22px; } .drop h1 { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
