/* =====================================================================
   Gestión · angelcm — interfaz del panel con la identidad de angelcm.com
   ===================================================================== */
:root, :root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0a0c10; --bg-2: #0d1015; --surface: #111419; --surface-2: #161a21; --surface-3: #1c212a;
    --ink: #f2f4f7; --text-2: #b6bfcb; --muted: #8d97a5; --line: #222831; --line-2: #323a46;
    --acc: #5ec4d3; --acc-2: #8ae0ea; --acc-soft: rgba(94, 196, 211, .11); --on-acc: #06262b;
    --ok: #4cc48d; --ok-soft: rgba(76, 196, 141, .13); --warn: #f2b04e; --warn-soft: rgba(242, 176, 78, .13); --err: #ff7b7b; --err-soft: rgba(255, 123, 123, .12);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 18px 44px -22px rgba(0, 0, 0, .85); --shadow-lg: 0 40px 90px -30px rgba(0, 0, 0, .95);
    --neural: 94, 196, 211;
    --font-d: 'Inter Tight', 'Inter', system-ui, sans-serif; --font: 'Inter', system-ui, sans-serif;
    --ease: cubic-bezier(.2, .8, .2, 1); --ease-io: cubic-bezier(.65, 0, .35, 1); --spring: cubic-bezier(.34, 1.56, .64, 1);
    --r: 14px; --r-sm: 10px; --side-w: 264px;
}
:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f5f6f8; --bg-2: #eef1f4; --surface: #ffffff; --surface-2: #f8f9fb; --surface-3: #eef1f5;
    --ink: #0b1220; --text-2: #3f4a5a; --muted: #667080; --line: #e4e7ec; --line-2: #d0d5dd;
    --acc: #0a6c7d; --acc-2: #12a3b8; --acc-soft: rgba(10, 108, 125, .09); --on-acc: #ffffff;
    --ok: #1e8a55; --ok-soft: rgba(30, 138, 85, .1); --warn: #a8640a; --warn-soft: rgba(232, 155, 45, .14); --err: #c83737; --err-soft: rgba(200, 55, 55, .09);
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 16px 40px -20px rgba(16, 24, 40, .22); --shadow-lg: 0 40px 80px -30px rgba(16, 24, 40, .35);
    --neural: 10, 108, 125;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font: 400 14.5px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; font-family: var(--font-d); font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.i { width: 18px; height: 18px; flex-shrink: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -80px; z-index: 300; padding: 10px 14px; border-radius: 10px; background: var(--ink); color: var(--bg); font-weight: 600; text-decoration: none; }
.skip:focus { top: 12px; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
kbd { padding: 1px 6px; border: 1px solid currentColor; border-radius: 5px; font: 600 10px var(--font); opacity: .55; }
#neural { position: fixed; inset: 0; z-index: -1; width: 100%; height: 100%; pointer-events: none; }
body::before { content: ''; position: fixed; inset: 0; z-index: -2; pointer-events: none; background: radial-gradient(60% 50% at 85% -10%, var(--acc-soft), transparent 70%), radial-gradient(40% 40% at 0% 100%, var(--acc-soft), transparent 70%); }

/* ---------------------------------------------------------------- estructura */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; display: flex; flex-direction: column; gap: 18px; height: 100vh; padding: 20px 14px 16px; border-right: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px); view-transition-name: side; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 6px; text-decoration: none; }
.brand img { filter: drop-shadow(0 6px 14px rgba(10, 108, 125, .45)); }
.brand b { display: block; font-family: var(--font-d); font-size: 1rem; line-height: 1.2; }
.brand small { display: block; color: var(--muted); font-size: .76rem; }
.quick { display: grid; gap: 8px; }
.side nav { display: grid; gap: 2px; }
.side nav a { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px; color: var(--text-2); font-weight: 500; text-decoration: none; transition: background-color .2s, color .2s; }
.side nav a:hover { background: var(--surface-2); color: var(--ink); }
.side nav a[aria-current="page"] { background: var(--acc-soft); color: var(--ink); font-weight: 600; }
.side nav a[aria-current="page"] .i { color: var(--acc); }
.side nav a[aria-current="page"]::before { content: ''; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--acc); }
.side-foot { display: grid; gap: 10px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.theme { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; width: max-content; }
.theme button { display: grid; place-items: center; width: 34px; height: 30px; border: 0; border-radius: 999px; background: none; color: var(--muted); }
.theme button[aria-pressed="true"] { background: var(--surface-3); color: var(--ink); }
.theme .i { width: 15px; height: 15px; }
.me { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 11px; text-decoration: none; }
.me:hover { background: var(--surface-2); }
.me b { display: block; font-size: .9rem; }
.me small { display: block; color: var(--muted); font-size: .76rem; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--acc), var(--acc-2)); color: var(--on-acc); font-family: var(--font-d); font-weight: 700; }
.side-scrim { display: none; }

.main { min-width: 0; padding: 26px clamp(16px, 3vw, 40px) 64px; view-transition-name: main; }
.topbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 20px; margin-bottom: 22px; }
.page-title { flex: 1; min-width: 0; }
.page-title h1 { font-size: clamp(1.5rem, 2.4vw, 2rem); }
.page-title p { margin-top: 4px; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.topbar .menu-btn { display: none; }
.content { display: grid; gap: 18px; }

/* ---------------------------------------------------------------- piezas */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 16px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font-size: .92rem; font-weight: 600; text-decoration: none; white-space: nowrap; overflow: hidden; transition: transform .15s var(--ease), border-color .2s, background-color .2s, box-shadow .25s; }
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.97); }
.btn-primary { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.btn-primary:hover { border-color: var(--ink); box-shadow: 0 10px 26px -12px var(--acc); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-danger { color: var(--err); }
.btn-danger:hover { border-color: var(--err); background: var(--err-soft); }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: .84rem; border-radius: 9px; }
.btn-lg { min-height: 50px; font-size: 1rem; }
.btn-icon { width: 40px; padding: 0; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn .ripple { position: absolute; border-radius: 50%; background: currentColor; opacity: .25; transform: scale(0); animation: ripple .6s var(--ease) forwards; pointer-events: none; }
@keyframes ripple { to { transform: scale(4); opacity: 0; } }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.panel { border: 1px solid var(--line); border-radius: var(--r); background: color-mix(in srgb, var(--surface) 94%, transparent); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 1.02rem; }
.panel-head p { color: var(--muted); font-size: .84rem; }
.panel-body { padding: 16px 18px; }
.panel.narrow { max-width: 640px; padding: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.stack { display: grid; gap: 18px; align-content: start; }

.form { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.span-2 { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; min-width: 0; color: var(--text-2); font-size: .84rem; font-weight: 600; }
.field small { color: var(--muted); font-weight: 400; }
.field input, .field select, .field textarea, .input, .repeat-row input, .tpl-name input, .act-form select, td select {
    width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink); font-size: .93rem; font-weight: 400; transition: border-color .2s, box-shadow .2s, background-color .2s;
}
.field textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus, .repeat-row input:focus, .tpl-name input:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 4px var(--acc-soft); background: var(--surface); }
.field input[disabled] { opacity: .6; }
.field-msg { min-height: 1em; font-weight: 500; }
.field-msg.ok { color: var(--ok); } .field-msg.err { color: var(--err); }
.hint { color: var(--muted); font-size: .84rem; }
.hint .i { display: inline; width: 14px; height: 14px; vertical-align: -2px; }
.warn-text { color: var(--warn); }
.group { display: grid; gap: 10px; margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-sm); }
.group legend { padding: 0 6px; color: var(--ink); font-weight: 600; font-size: .9rem; }
.repeat { display: grid; gap: 8px; }
.repeat-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr auto; gap: 8px; animation: row-in .35s var(--ease); }
@keyframes row-in { from { opacity: 0; transform: translateY(-6px); } }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-size: .76rem; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); } .badge.err { background: var(--err-soft); color: var(--err); } .badge.info { background: var(--acc-soft); color: var(--acc); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.kpi { position: relative; display: grid; gap: 4px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--r); background: color-mix(in srgb, var(--surface) 94%, transparent); box-shadow: var(--shadow); overflow: hidden; }
.kpi-l { color: var(--muted); font-size: .84rem; }
.kpi-v { font-family: var(--font-d); font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-h { color: var(--muted); font-size: .8rem; }
.kpi.hero { border-color: transparent; background: linear-gradient(135deg, var(--acc), var(--acc-2)); color: var(--on-acc); }
.kpi.hero .kpi-l, .kpi.hero .kpi-h { color: inherit; opacity: .8; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.search { position: relative; flex: 1 1 260px; max-width: 420px; }
.search .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .input { padding-left: 38px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 6px 12px; border: 1px solid var(--line-2); border-radius: 999px; color: var(--text-2); font-size: .85rem; font-weight: 500; text-decoration: none; transition: all .2s var(--ease); }
.chip small { padding: 0 6px; border-radius: 99px; background: var(--surface-3); font-size: .72rem; }
.chip.on { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.chip.on small { background: rgba(127, 127, 127, .25); }
.tabs { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 12px; }
.tabs a { padding: 6px 12px; border-radius: 9px; color: var(--muted); font-size: .85rem; font-weight: 600; text-decoration: none; }
.tabs a[aria-current="page"] { background: var(--surface-3); color: var(--ink); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { padding: 10px 16px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .78rem; font-weight: 600; text-align: left; white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color .15s; }
.table tbody tr[data-href] { cursor: pointer; }
.table tbody tr:hover { background: var(--surface-2); }
.table .n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .t-main a { text-decoration: none; }
.table .t-main b { font-weight: 600; }
.table .t-main small { display: block; color: var(--muted); }
.table td.actions { text-align: right; white-space: nowrap; }
.table td.actions > * { display: inline-flex; vertical-align: middle; margin-left: 6px; }
.doc-type { display: inline-block; margin-right: 8px; padding: 1px 7px; border-radius: 6px; background: var(--acc-soft); color: var(--acc); font-size: .7rem; font-weight: 700; vertical-align: 1px; }
.doc-type.boleta { background: var(--warn-soft); color: var(--warn); }

.empty { display: grid; justify-items: center; gap: 8px; padding: 42px 20px; text-align: center; color: var(--muted); }
.empty .i { width: 34px; height: 34px; color: var(--acc); }
.empty b { color: var(--ink); font-family: var(--font-d); font-size: 1.1rem; }
.empty p { max-width: 40ch; }

.toast { position: fixed; z-index: 250; left: 50%; bottom: 26px; display: flex; align-items: center; gap: 10px; max-width: min(560px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 14px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow-lg); font-weight: 500; transform: translateX(-50%); animation: toast-in .55s var(--spring) both, toast-out .4s var(--ease) 5s forwards; }
.toast.ok .i { color: var(--ok); } .toast.warn { background: var(--warn); color: #1d1300; } .toast.err { background: var(--err); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 24px) scale(.94); } }
@keyframes toast-out { to { opacity: 0; transform: translate(-50%, 12px); visibility: hidden; } }

dialog.modal { width: min(500px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); }
dialog.modal::backdrop { background: rgba(5, 8, 12, .6); backdrop-filter: blur(4px); }
dialog.modal[open] { animation: modal-in .4s var(--spring); }
@keyframes modal-in { from { opacity: 0; transform: translateY(18px) scale(.95); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head h2 { font-size: 1.2rem; }
.modal-body { padding: 20px; }

/* ---------------------------------------------------------------- inicio */
.hero-actions { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 14px; }
.qa { display: flex; align-items: center; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: var(--r); background: color-mix(in srgb, var(--surface) 94%, transparent); box-shadow: var(--shadow); text-decoration: none; transition: transform .35s var(--ease), border-color .25s, box-shadow .35s; }
.qa:hover { transform: translateY(-3px); border-color: var(--acc); box-shadow: var(--shadow-lg); }
.qa > span:nth-child(2) { flex: 1; }
.qa b { display: block; font-family: var(--font-d); font-size: 1.06rem; }
.qa small { display: block; color: var(--muted); font-size: .84rem; }
.qa > .i { color: var(--muted); transition: transform .3s var(--ease), color .2s; }
.qa:hover > .i { color: var(--acc); transform: translateX(4px); }
.qa-ic { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; background: var(--acc-soft); color: var(--acc); }
.qa-main { border-color: transparent; background: linear-gradient(135deg, var(--acc), var(--acc-2)); color: var(--on-acc); }
.qa-main small, .qa-main > .i { color: inherit; opacity: .85; }
.qa-main .qa-ic { background: rgba(255, 255, 255, .2); color: inherit; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 210px; padding: 18px 18px 12px; }
.bar-col { flex: 1; display: grid; grid-template-rows: 1fr auto; gap: 8px; height: 100%; }
.bar-pair { display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.bar { width: min(18px, 40%); height: var(--h, 0%); min-height: 2px; border-radius: 6px 6px 2px 2px; transition: height 1.1s var(--ease); }
.bar-p { background: var(--acc); } .bar-b { background: var(--warn); }
.bar-l { color: var(--muted); font-size: .78rem; text-align: center; }
.dot { display: inline-block; width: 9px; height: 9px; margin: 0 5px 0 10px; border-radius: 3px; }
.dot-p { background: var(--acc); } .dot-b { background: var(--warn); }
.todo { display: grid; margin: 0; padding: 6px; list-style: none; }
.todo li { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 10px; }
.todo li:hover { background: var(--surface-2); }
.todo a { flex: 1; text-decoration: none; }
.todo b { display: block; font-size: .92rem; }
.todo small { color: var(--muted); }
.todo-ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--acc-soft); color: var(--acc); }
.todo-ic.warn { background: var(--warn-soft); color: var(--warn); }
.todo-empty { color: var(--ok); }

/* ---------------------------------------------------------------- documento */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.doc-stage { min-width: 0; padding: 26px; border: 1px solid var(--line); border-radius: var(--r); background: repeating-linear-gradient(45deg, transparent 0 10px, rgba(127, 127, 127, .03) 10px 20px), var(--bg-2); overflow: hidden; }
.doc-side { display: grid; gap: 14px; position: sticky; top: 20px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-opt input { position: absolute; opacity: 0; }
.seg-opt span { display: inline-block; padding: 6px 12px; border: 1px solid var(--line-2); border-radius: 999px; color: var(--text-2); font-size: .84rem; font-weight: 600; cursor: pointer; transition: all .25s var(--ease); }
.seg-opt input:checked + span { border-color: var(--acc); background: var(--acc); color: var(--on-acc); }
.seg-opt.tone-ok input:checked + span { border-color: var(--ok); background: var(--ok); color: #fff; }
.seg-opt.tone-err input:checked + span { border-color: var(--err); background: var(--err); color: #fff; }
.seg-opt.tone-warn input:checked + span { border-color: var(--warn); background: var(--warn); color: #1d1300; }
.seg-opt input:focus-visible + span { outline: 2px solid var(--acc); outline-offset: 2px; }
.reason { display: none; } .reason.show { display: grid; animation: row-in .3s var(--ease); }
.act-list { display: grid; gap: 4px; padding: 8px; }
.act-list form { margin: 0; }
.act { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px; border: 0; border-radius: 10px; background: none; text-align: left; text-decoration: none; transition: background-color .2s; }
.act:hover { background: var(--surface-2); }
.act .i { color: var(--acc); }
.act b { display: block; font-size: .92rem; }
.act small { display: block; color: var(--muted); font-size: .8rem; }
.act-danger .i, .act-danger b { color: var(--err); }
.act-form { display: grid; gap: 8px; padding: 10px; border: 1px dashed var(--line-2); border-radius: 10px; margin: 4px 0; }
.act-title { display: flex; align-items: center; gap: 10px; }
.act-title .i { color: var(--acc); }
.timeline { display: grid; gap: 0; margin: 0; padding: 12px 18px 16px 34px; list-style: none; }
.timeline li { position: relative; display: grid; padding: 0 0 14px; }
.timeline li::before { content: ''; position: absolute; left: -17px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--acc); box-shadow: 0 0 0 4px var(--acc-soft); }
.timeline li::after { content: ''; position: absolute; left: -13px; top: 18px; bottom: 0; width: 1px; background: var(--line-2); }
.timeline li:last-child::after { display: none; }
.timeline b { font-size: .9rem; }
.timeline span { color: var(--text-2); font-size: .86rem; }
.timeline small { color: var(--muted); font-size: .78rem; }
.sheet-wrap { position: relative; }
.mini-list { display: grid; margin: 0; padding: 6px; list-style: none; }
.mini-list a { display: grid; grid-template-columns: auto 1fr auto auto; grid-template-areas: 't c a b' 't d a b'; align-items: center; gap: 0 10px; padding: 10px; border-radius: 10px; text-decoration: none; }
.mini-list a:hover { background: var(--surface-2); }
.mini-list .doc-type { grid-area: t; } .mini-list b { grid-area: c; } .mini-list small { grid-area: d; color: var(--muted); } .mini-amt { grid-area: a; font-weight: 600; font-variant-numeric: tabular-nums; } .mini-list .badge { grid-area: b; }
.danger-zone .btn-danger { border-color: var(--err-soft); }
.tip b { font-family: var(--font-d); }
.tip p { margin-top: 6px; color: var(--muted); font-size: .88rem; }

/* ---------------------------------------------------------------- plantillas y ajustes */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin: 0; padding: 16px 18px; list-style: none; }
.tpl { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: 'i n a' 'i s a'; align-items: center; gap: 2px 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.tpl-ic { grid-area: i; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--acc-soft); color: var(--acc); }
.tpl-name { grid-area: n; margin: 0; }
.tpl-name input { min-height: 34px; padding: 4px 8px; border-color: transparent; background: transparent; font-weight: 600; }
.tpl small { grid-area: s; padding-left: 8px; color: var(--muted); font-size: .8rem; }
.tpl-acts { grid-area: a; display: flex; gap: 4px; }
.tpl-acts form { margin: 0; }
.settings { display: grid; gap: 18px; }
.sticky-save { position: sticky; bottom: 16px; display: flex; justify-content: flex-end; }
.sticky-save .btn { box-shadow: var(--shadow-lg); }
code { padding: 1px 6px; border-radius: 6px; background: var(--surface-3); font-size: .86em; }

/* ---------------------------------------------------------------- editor */
.editor-page { overflow: hidden; }
.editor { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100vh; }
.ed-bar { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(14px); view-transition-name: side; }
.ed-title { flex: 1; min-width: 0; }
.ed-title h1 { font-size: 1.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-title p { color: var(--muted); font-size: .82rem; }
.ed-title p.dirty { color: var(--warn); }
.ed-title p.saved { color: var(--ok); }
.ed-total { display: grid; justify-items: end; line-height: 1.15; padding-right: 6px; }
.ed-total small { color: var(--muted); font-size: .74rem; }
.ed-total b { font-family: var(--font-d); font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.ed-total b.tick { animation: tick .5s var(--spring); }
@keyframes tick { 40% { transform: translateY(-3px) scale(1.06); color: var(--acc); } }
.ed-toggle { display: none; }
.ed-body { display: grid; grid-template-columns: minmax(380px, 470px) minmax(0, 1fr); min-height: 0; }
.ed-panel { min-height: 0; padding: 18px; border-right: 1px solid var(--line); overflow-y: auto; scrollbar-gutter: stable; }
.ed-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.ed-fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.ed-fields > *, .ed-group-body > *, .ed-item-body > *, .ed-list > *, .ed-cols > * { min-width: 0; }
.ed-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.ed-group { border: 1px solid var(--line); border-radius: var(--r); background: color-mix(in srgb, var(--surface) 94%, transparent); }
.ed-group > summary { display: flex; align-items: center; gap: 10px; padding: 13px 15px; list-style: none; cursor: pointer; font-family: var(--font-d); font-weight: 600; }
.ed-group > summary::-webkit-details-marker { display: none; }
.ed-group > summary .i { color: var(--acc); }
.ed-group > summary .chev { margin-left: auto; color: var(--muted); transition: transform .3s var(--ease); }
.ed-group[open] > summary .chev { transform: rotate(180deg); }
.ed-group > summary small { color: var(--muted); font: 500 .8rem var(--font); }
.ed-group-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 4px 15px 15px; animation: grp-in .35s var(--ease); }
@keyframes grp-in { from { opacity: 0; transform: translateY(-6px); } }
.ed-item { border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface-2); }
.ed-item-head { display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 12px; border-bottom: 1px solid var(--line); }
.ed-item-head b { flex: 1; min-width: 0; overflow: hidden; font-size: .88rem; text-overflow: ellipsis; white-space: nowrap; }
.ed-item-head .num { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--acc-soft); color: var(--acc); font-size: .74rem; font-weight: 700; }
.ed-item-head .btn { min-height: 30px; width: 30px; border-radius: 8px; }
.ed-item-head .btn .i { width: 15px; height: 15px; }
.ed-item-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 12px; }
.ed-item.enter { animation: item-in .45s var(--spring); }
.ed-item.leave { animation: item-out .3s var(--ease) forwards; }
@keyframes item-in { from { opacity: 0; transform: translateY(-10px) scale(.97); } }
@keyframes item-out { to { opacity: 0; transform: translateX(30px); height: 0; margin: 0; } }
.ed-item.moved { animation: moved .45s var(--spring); }
@keyframes moved { 40% { transform: scale(1.02); box-shadow: 0 0 0 3px var(--acc-soft); } }
.ed-add { display: flex; flex-wrap: wrap; gap: 6px; }
.ed-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.ed-help { color: var(--muted); font-size: .78rem; font-weight: 400; }
.picker { position: relative; }
.picker-list { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); display: grid; max-height: 280px; margin: 0; padding: 6px; list-style: none; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-lg); overflow-y: auto; animation: modal-in .25s var(--ease); }
.picker-list[hidden] { display: none; }
.picker-list button { display: grid; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; text-align: left; }
.picker-list button:hover, .picker-list button:focus { background: var(--surface-2); outline: none; }
.picker-list small { color: var(--muted); }
.ed-preview { position: relative; min-height: 0; background: repeating-linear-gradient(45deg, transparent 0 10px, rgba(127, 127, 127, .03) 10px 20px), var(--bg-2); }
.ed-preview-scroll { height: 100%; padding: 28px; overflow: auto; }
.ed-preview .sheet-wrap { transition: opacity .25s; }
.ed-preview .sheet-wrap.loading { opacity: .65; }
.ed-warnings { position: absolute; left: 20px; right: 20px; bottom: 16px; display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; pointer-events: none; }
.ed-warnings li { justify-self: start; display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-radius: 10px; background: var(--warn); color: #1d1300; font-size: .84rem; font-weight: 600; box-shadow: var(--shadow); animation: toast-in .4s var(--spring) both; pointer-events: auto; }

/* ---------------------------------------------------------------- acceso */
.auth { overflow-x: hidden; }
.auth-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); min-height: 100vh; }
.auth-card { display: grid; align-content: center; gap: 14px; width: min(430px, 100%); margin: 0 auto; padding: 40px 24px; }
.auth-logo { filter: drop-shadow(0 14px 26px rgba(10, 108, 125, .5)); animation: logo-in .9s var(--spring) both; }
@keyframes logo-in { from { opacity: 0; transform: translateY(16px) rotate(-8deg) scale(.8); } }
.auth-card h1 { font-size: 2.2rem; }
.auth-intro { color: var(--text-2); margin-bottom: 6px; }
.auth .toast { position: static; transform: none; animation: none; max-width: none; }
.auth-note { display: flex; gap: 8px; align-items: center; }
.auth-art { position: relative; display: grid; align-items: end; padding: 48px; overflow: hidden; border-left: 1px solid var(--line); background: radial-gradient(70% 60% at 70% 30%, rgba(94, 196, 211, .2), transparent 70%), #07161a; }
.auth-art p { position: relative; z-index: 2; color: #e8f6f8; font-family: var(--font-d); font-size: clamp(1.6rem, 2.8vw, 2.4rem); font-weight: 700; line-height: 1.1; }
.auth-art p span { display: block; max-width: 24ch; margin-top: 10px; color: #a9cfd4; font: 500 1rem/1.5 var(--font); }
.paper { position: absolute; display: grid; gap: 10px; align-content: start; width: 220px; height: 290px; padding: 26px 22px; border-radius: 6px; background: #fff; box-shadow: 0 40px 70px -30px rgba(0, 0, 0, .8); animation: float 9s ease-in-out infinite; }
.paper i { display: block; height: 8px; border-radius: 4px; background: #dfe6ea; }
.paper i:first-child { width: 60%; height: 14px; background: #0a6c7d; }
.paper i:nth-child(3) { width: 80%; }
.paper b { position: absolute; left: 22px; right: 22px; bottom: 26px; height: 26px; border-radius: 5px; background: #0b1220; }
.paper.p1 { left: 14%; top: 10%; transform: rotate(-8deg); }
.paper.p2 { left: 46%; top: 6%; transform: rotate(6deg); animation-delay: -3s; z-index: 1; }
.paper.p3 { left: 30%; top: 30%; transform: rotate(-2deg); animation-delay: -6s; }
@keyframes float { 50% { translate: 0 -16px; } }

/* ---------------------------------------------------------------- movimiento */
@view-transition { navigation: auto; }
::view-transition-old(main) { animation: vt-out .28s var(--ease-io) both; }
::view-transition-new(main) { animation: vt-in .45s var(--ease) both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-10px); filter: blur(6px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(16px); filter: blur(8px); } }
.js .reveal { opacity: 0; transform: translateY(18px); }
.js .reveal.in { opacity: 1; transform: none; transition: opacity .7s var(--ease), transform .8s var(--ease); }
.js .kpi { animation: kpi-in .8s var(--ease) backwards; }
.js .kpis .kpi:nth-child(2) { animation-delay: .07s; } .js .kpis .kpi:nth-child(3) { animation-delay: .14s; } .js .kpis .kpi:nth-child(4) { animation-delay: .21s; }
@keyframes kpi-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1180px) {
    .doc-layout { grid-template-columns: minmax(0, 1fr); }
    .doc-side { position: static; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
    .ed-body { grid-template-columns: minmax(0, 1fr); }
    .ed-preview { display: none; }
    .ed-toggle { display: inline-flex; }
    .editor.show-preview .ed-preview { display: block; position: fixed; inset: 64px 0 0; z-index: 30; }
}
@media (max-width: 1000px) { .hero-actions, .grid-2, .grid-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .side { position: fixed; inset: 0 auto 0 0; z-index: 90; width: min(300px, 86vw); transform: translateX(-104%); transition: transform .45s var(--ease); box-shadow: var(--shadow-lg); background: var(--surface); }
    .side.open { transform: none; }
    .side-scrim { position: fixed; inset: 0; z-index: 80; display: block; background: rgba(5, 8, 12, .55); opacity: 0; pointer-events: none; transition: opacity .3s; }
    .side.open + .side-scrim { opacity: 1; pointer-events: auto; }
    .topbar .menu-btn { display: inline-flex; }
    .main { padding: 16px 14px 90px; }
    .topbar { align-items: center; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1; }
    .doc-stage { padding: 10px; }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .repeat-row { grid-template-columns: 1fr 1fr auto; }
    .repeat-row input:nth-child(3) { grid-column: 1 / 3; }
    .table.stackable thead { display: none; }
    .table.stackable, .table.stackable tbody, .table.stackable tr, .table.stackable td { display: block; width: 100%; }
    .table.stackable tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
    .table.stackable td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0; text-align: right; }
    .table.stackable td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; }
    .table.stackable td.t-main { display: block; text-align: left; padding-bottom: 6px; }
    .table.stackable td.t-main::before, .table.stackable td.actions::before { display: none; }
    .table.stackable td.actions { justify-content: flex-end; padding-top: 8px; }
    .ed-bar { flex-wrap: wrap; padding: 10px 12px; }
    .ed-bar kbd, .ed-toggle span { display: none; }
    .ed-title h1 { font-size: .98rem; }
    .ed-total b { font-size: 1.05rem; }
    .ed-bar .btn-primary span { display: none; }
    .ed-bar .btn-primary { width: 44px; padding: 0; }
    .ed-panel { padding: 12px; }
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-art { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
    @view-transition { navigation: none; }
}
@media print {
    #neural, .side, .side-scrim, .topbar, .doc-side, .toast, .ed-bar, .ed-panel, .ed-warnings, body::before, .skip { display: none !important; }
    .shell, .main, .content, .doc-layout, .doc-stage, .editor, .ed-body, .ed-preview, .ed-preview-scroll { display: block !important; height: auto !important; padding: 0 !important; margin: 0 !important; border: 0 !important; background: #fff !important; overflow: visible !important; box-shadow: none !important; }
    body { background: #fff !important; }
}
