/* ==========================================================================
   Equipar Print — sistema de diseño
   ========================================================================== */

:root {
    color-scheme: light dark;

    --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Cantarell, Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, monospace;

    --hue: 252;
    --accent: hsl(var(--hue) 92% 64%);
    --accent-2: hsl(192 86% 50%);
    --accent-soft: hsl(var(--hue) 92% 64% / .14);
    --grad: linear-gradient(135deg, hsl(var(--hue) 92% 64%), hsl(220 90% 60%) 55%, hsl(192 86% 50%));

    --bg: hsl(232 30% 97%);
    --bg-2: hsl(232 30% 93%);
    --surface: hsl(0 0% 100% / .72);
    --surface-solid: #fff;
    --surface-2: hsl(232 30% 96% / .9);
    --border: hsl(232 30% 20% / .09);
    --border-strong: hsl(232 30% 20% / .16);
    --text: hsl(235 30% 12%);
    --text-2: hsl(234 14% 38%);
    --muted: hsl(234 12% 52%);

    --ok: hsl(156 64% 38%);
    --ok-soft: hsl(156 64% 38% / .13);
    --warn: hsl(36 96% 46%);
    --warn-soft: hsl(36 96% 46% / .15);
    --bad: hsl(352 78% 54%);
    --bad-soft: hsl(352 78% 54% / .12);
    --info: hsl(212 90% 54%);
    --info-soft: hsl(212 90% 54% / .13);

    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 24px;
    --shadow-sm: 0 1px 2px hsl(232 40% 20% / .06), 0 1px 1px hsl(232 40% 20% / .04);
    --shadow: 0 10px 30px -12px hsl(232 50% 25% / .22), 0 2px 6px hsl(232 40% 20% / .05);
    --shadow-lg: 0 30px 80px -20px hsl(240 60% 20% / .35);
    --ring: 0 0 0 4px hsl(var(--hue) 92% 64% / .28);

    --ease: cubic-bezier(.2, .8, .2, 1);
    --spring: cubic-bezier(.34, 1.56, .64, 1);

    --topbar-h: 64px;
    --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: hsl(234 32% 6%);
        --bg-2: hsl(234 28% 10%);
        --surface: hsl(234 26% 13% / .66);
        --surface-solid: hsl(234 26% 12%);
        --surface-2: hsl(234 24% 17% / .8);
        --border: hsl(230 40% 90% / .08);
        --border-strong: hsl(230 40% 90% / .15);
        --text: hsl(232 40% 96%);
        --text-2: hsl(232 18% 76%);
        --muted: hsl(232 12% 60%);
        --accent-soft: hsl(var(--hue) 92% 68% / .18);
        --shadow: 0 16px 40px -16px hsl(0 0% 0% / .6), 0 2px 6px hsl(0 0% 0% / .25);
        --shadow-lg: 0 30px 80px -20px hsl(0 0% 0% / .7);
    }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100dvh;
    font-family: var(--font);
    font-size: 15.5px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}
h1, h2, p { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 1.25em; height: 1.25em; flex: none; }
code { font-family: var(--mono); font-size: .9em; padding: .1em .4em; border-radius: 6px; background: var(--accent-soft); }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.eyebrow { font-size: .72rem; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }

/* ---------- Fondo aurora ---------- */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aurora span {
    position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%;
    filter: blur(90px); opacity: .55; will-change: transform;
    animation: float 26s var(--ease) infinite alternate;
}
.aurora span:nth-child(1) { background: hsl(var(--hue) 90% 70% / .55); top: -30vmax; left: -15vmax; }
.aurora span:nth-child(2) { background: hsl(192 90% 60% / .40); top: -20vmax; right: -25vmax; animation-delay: -8s; animation-duration: 32s; }
.aurora span:nth-child(3) { background: hsl(320 80% 70% / .22); bottom: -40vmax; left: 20vmax; animation-delay: -16s; animation-duration: 38s; }
@media (prefers-color-scheme: dark) { .aurora span { opacity: .38; } }
@keyframes float {
    0% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(6vmax, 4vmax, 0) scale(1.08); }
    100% { transform: translate3d(-4vmax, 6vmax, 0) scale(.95); }
}

.glass {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    -webkit-backdrop-filter: blur(22px) saturate(1.6);
    backdrop-filter: blur(22px) saturate(1.6);
}

.grad-text {
    background: var(--grad);
    -webkit-background-clip: text; background-clip: text;
    color: transparent;
}

/* ---------- Barra superior ---------- */
.topbar {
    position: sticky; top: 0; z-index: 30;
    height: var(--topbar-h);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 0 max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-right));
    background: color-mix(in srgb, var(--bg) 70%, transparent);
    -webkit-backdrop-filter: blur(18px) saturate(1.5);
    backdrop-filter: blur(18px) saturate(1.5);
    border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-mark {
    display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px;
    background: var(--grad); color: #fff;
    box-shadow: 0 6px 18px -6px hsl(var(--hue) 90% 55% / .7), inset 0 1px 0 hsl(0 0% 100% / .35);
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-name { font-size: 1.06rem; letter-spacing: -.01em; font-weight: 500; }
.brand-name strong { font-weight: 750; }

.topbar-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 38px;
    padding: 0 12px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    font-size: .84rem;
    font-weight: 600;
    color: var(--text-2);
}
.user-pill svg {
    width: 16px;
    height: 16px;
    color: var(--accent);
}
.logout-form {
    display: inline-flex;
    margin: 0;
}
.logout-btn {
    gap: 6px;
    height: 38px;
    color: var(--text-2);
}
.logout-btn:hover {
    color: var(--bad);
    background: var(--bad-soft);
    border-color: transparent;
}
.logout-btn svg {
    width: 16px;
    height: 16px;
}
@media (max-width: 580px) {
    .user-pill .user-name { display: none; }
    .logout-btn span { display: none; }
    .logout-btn { padding: 0 10px; }
}

.printer-pill {
    display: inline-flex; align-items: center; gap: 9px;
    height: 38px; padding: 0 14px 0 12px; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    font-size: .86rem; font-weight: 600;
    transition: transform .2s var(--ease), border-color .2s, background .2s;
}
.printer-pill:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.pill-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); position: relative; }
.pill-dot::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; background: inherit; opacity: .35; animation: pulse 2s ease-out infinite; }
.printer-pill[data-state="idle"] .pill-dot { background: var(--ok); }
.printer-pill[data-state="processing"] .pill-dot { background: var(--info); }
.printer-pill[data-state="stopped"] .pill-dot,
.printer-pill[data-state="unknown"] .pill-dot { background: var(--bad); }
.printer-pill[data-state="warning"] .pill-dot { background: var(--warn); }
.printer-pill[data-state="loading"] .pill-dot::after { animation-duration: 1s; }
@keyframes pulse { 0% { transform: scale(.6); opacity: .55; } 100% { transform: scale(1.9); opacity: 0; } }

.ink-mini { display: inline-flex; align-items: flex-end; gap: 2px; height: 16px; }
.ink-mini i { display: block; width: 4px; border-radius: 2px; background: var(--c); min-height: 2px; box-shadow: inset 0 0 0 1px hsl(0 0% 0% / .08); }
@media (max-width: 380px) { .ink-mini { display: none; } }

.printer-panel {
    position: fixed; z-index: 40;
    top: calc(var(--topbar-h) + 8px); right: max(12px, env(safe-area-inset-right));
    width: min(360px, calc(100vw - 24px));
    padding: 18px; display: grid; gap: 14px;
    background: var(--surface-solid);
    box-shadow: var(--shadow-lg);
    transform-origin: top right;
    animation: pop .25s var(--spring);
}
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(-6px); } }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.panel-title { font-weight: 700; font-size: 1.05rem; }
.panel-sub { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.reason-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.reason-list li { font-size: .85rem; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--info-soft); }
.reason-list li[data-sev="warning"] { background: var(--warn-soft); }
.reason-list li[data-sev="error"] { background: var(--bad-soft); }
.ink-levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.ink { display: grid; justify-items: center; gap: 6px; font-size: .74rem; color: var(--text-2); }
.ink-tube { position: relative; width: 26px; height: 78px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.ink-fill { position: absolute; left: 0; right: 0; bottom: 0; background: var(--c); transition: height .8s var(--ease); }
.ink-fill::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, hsl(0 0% 100% / .35), transparent 45%); }
.ink b { font-size: .8rem; color: var(--text); }
.ink.low b { color: var(--bad); }

/* ---------- Layout ---------- */
.shell {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 28px max(16px, env(safe-area-inset-left)) 48px max(16px, env(safe-area-inset-right));
    display: grid; gap: 22px;
}
.hero { text-align: center; padding: 26px 8px 6px; animation: rise .6s var(--ease) both; }
.hero h1 { font-size: clamp(1.75rem, 5.2vw, 3rem); line-height: 1.08; letter-spacing: -.035em; font-weight: 800; }
.hero h1 .grad-text { display: inline-block; }
.lead { max-width: 620px; margin: 14px auto 0; color: var(--text-2); font-size: clamp(.98rem, 2.4vw, 1.08rem); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* ---------- Zona de carga ---------- */
.dropzone { padding: 14px; animation: rise .6s .08s var(--ease) both; }
.drop-label {
    position: relative;
    display: grid; justify-items: center; gap: 8px;
    padding: clamp(38px, 8vw, 64px) 20px;
    border-radius: calc(var(--radius-lg) - 8px);
    border: 2px dashed var(--border-strong);
    cursor: pointer; text-align: center;
    transition: border-color .25s, background .25s, transform .25s var(--ease);
}
.drop-label:hover, .dropzone.is-over .drop-label { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.is-over .drop-label { transform: scale(.99); }
#file-input:focus-visible + .drop-label { box-shadow: var(--ring); }
.drop-icon {
    display: grid; place-items: center; width: 68px; height: 68px; border-radius: 22px; margin-bottom: 6px;
    background: var(--grad); color: #fff;
    box-shadow: 0 16px 34px -12px hsl(var(--hue) 90% 55% / .75), inset 0 1px 0 hsl(0 0% 100% / .35);
    transition: transform .35s var(--spring);
}
.drop-icon svg { width: 30px; height: 30px; }
.drop-label:hover .drop-icon { transform: translateY(-4px) rotate(-4deg); }
.drop-title { font-size: 1.2rem; font-weight: 700; letter-spacing: -.01em; }
.drop-sub { color: var(--muted); font-size: .92rem; }
.drop-sub u { color: var(--accent); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.feature-row { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; margin: 14px 0 4px; padding: 0; font-size: .82rem; color: var(--muted); }
.feature-row li { display: inline-flex; align-items: center; gap: 6px; }
.feature-row svg { width: 16px; height: 16px; color: var(--accent); }

/* ---------- Espacio de trabajo ---------- */
.workspace { display: grid; gap: 22px; align-items: start; animation: rise .45s var(--ease) both; }
@media (min-width: 960px) {
    .workspace { grid-template-columns: minmax(0, 1fr) 360px; }
    .col-side { position: sticky; top: calc(var(--topbar-h) + 18px); }
}
.col-main { display: grid; gap: 18px; min-width: 0; }

.file-card { display: flex; align-items: center; gap: 14px; padding: 14px 14px 14px 16px; }
.file-icon {
    position: relative; display: grid; place-items: center; width: 48px; height: 56px; flex: none;
    border-radius: 12px; background: var(--bad-soft); color: var(--bad);
}
.file-icon svg { width: 30px; height: 30px; }
.file-icon b { position: absolute; bottom: 7px; font-size: .56rem; letter-spacing: .06em; }
.file-info { flex: 1; min-width: 0; display: grid; gap: 3px; }
.file-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: .83rem; color: var(--muted); }
.progress { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.progress span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--grad); transition: width .3s var(--ease); }
.progress.is-done { opacity: 0; height: 0; margin: 0; transition: opacity .4s .4s, height .3s .8s, margin .3s .8s; }
.progress.is-error span { background: var(--bad); }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head h2, .options-card h2 { font-size: 1.06rem; font-weight: 700; letter-spacing: -.01em; }
.head-actions { display: flex; gap: 6px; }

.preview-card { padding: 18px; display: grid; gap: 16px; min-width: 0; }
.thumb-grid {
    display: grid; gap: 14px;
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    max-height: min(68vh, 780px); overflow-y: auto; overscroll-behavior: contain;
    padding: 4px; margin: -4px;
    scrollbar-width: thin;
}
@media (max-width: 480px) { .thumb-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; max-height: none; } }
@media (max-width: 340px) { .thumb-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.thumb { position: relative; display: grid; gap: 6px; animation: rise .35s var(--ease) both; animation-delay: calc(var(--i, 0) * 18ms); }
.thumb-view {
    position: relative; display: block; width: 100%; padding: 0;
    aspect-ratio: var(--ar, 0.7727);
    border-radius: 10px; overflow: hidden;
    background: #fff; border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: transform .25s var(--ease), box-shadow .25s, outline-color .2s, opacity .25s;
    outline: 2.5px solid transparent; outline-offset: 2px;
}
.thumb-view:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.thumb-view canvas { display: block; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity .35s, filter .4s; }
.thumb-view canvas.is-ready { opacity: 1; }
.thumb-view .skeleton {
    position: absolute; inset: 0;
    background: linear-gradient(100deg, hsl(232 20% 94%) 30%, hsl(232 20% 98%) 50%, hsl(232 20% 94%) 70%);
    background-size: 300% 100%; animation: shimmer 1.4s linear infinite;
}
.thumb-view .page-glyph { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.6rem; font-weight: 800; color: hsl(232 20% 80%); }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }
.thumb-view .zoom {
    position: absolute; right: 6px; bottom: 6px; display: grid; place-items: center;
    width: 26px; height: 26px; border-radius: 8px; background: hsl(235 30% 12% / .62); color: #fff;
    opacity: 0; transform: scale(.85); transition: opacity .2s, transform .2s var(--ease);
}
.thumb-view .zoom svg { width: 14px; height: 14px; }
.thumb-view:hover .zoom, .thumb-view:focus-visible .zoom { opacity: 1; transform: none; }
@media (hover: none) { .thumb-view .zoom { opacity: .9; transform: none; } }

.thumb-check {
    position: absolute; top: 7px; left: 7px; z-index: 2;
    display: grid; place-items: center; width: 26px; height: 26px; padding: 0;
    border-radius: 8px; border: 2px solid hsl(0 0% 100% / .95);
    background: hsl(235 30% 12% / .28); color: #fff;
    box-shadow: 0 2px 8px hsl(0 0% 0% / .2);
    transition: background .2s, transform .25s var(--spring), border-color .2s;
}
.thumb-check svg { width: 15px; height: 15px; opacity: 0; transform: scale(.4); transition: opacity .15s, transform .25s var(--spring); }
.thumb-check:active { transform: scale(.88); }
.thumb.is-selected .thumb-check { background: var(--accent); border-color: var(--accent); }
.thumb.is-selected .thumb-check svg { opacity: 1; transform: none; }
.thumb.is-selected .thumb-view { outline-color: var(--accent); }
.thumb:not(.is-selected) .thumb-view { opacity: .45; }
.thumb:not(.is-selected) .thumb-view canvas { filter: grayscale(.6); }
.thumb-num { text-align: center; font-size: .78rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.thumb.is-selected .thumb-num { color: var(--text); }
.thumb-grid.is-gray .thumb-view canvas { filter: grayscale(1) contrast(1.05); }

.preview-fallback { display: grid; gap: 10px; }
.preview-fallback iframe { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }

/* ---------- Opciones ---------- */
.options-card { padding: 20px; display: grid; gap: 20px; }
.field { border: 0; margin: 0; padding: 0; display: grid; gap: 10px; min-width: 0; }
.field legend { padding: 0; margin-bottom: 10px; font-size: .78rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }

.segmented {
    position: relative; display: grid; grid-template-columns: 1fr 1fr;
    padding: 4px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--border);
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
    position: relative; z-index: 1; text-align: center; padding: 9px 10px;
    font-weight: 600; font-size: .9rem; color: var(--text-2); cursor: pointer; border-radius: 10px;
    transition: color .2s;
}
.segmented input:checked + label { color: var(--text); }
.segmented input:focus-visible + label { box-shadow: var(--ring); }
.seg-glider {
    position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px);
    border-radius: 10px; background: var(--surface-solid); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
    transition: transform .35s var(--spring);
}
#mode-custom:checked ~ .seg-glider { transform: translateX(100%); }

.range-wrap { display: grid; gap: 6px; animation: rise .3s var(--ease) both; }
.input {
    width: 100%; height: 46px; padding: 0 14px; border-radius: 12px;
    border: 1px solid var(--border-strong); background: var(--surface-solid);
    font-family: var(--mono); font-size: .98rem; letter-spacing: .02em;
    transition: border-color .2s, box-shadow .2s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input.is-invalid { border-color: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }
.hint { font-size: .8rem; color: var(--muted); }
.hint.is-error { color: var(--bad); font-weight: 600; }

.stepper { display: grid; grid-template-columns: 50px 1fr 50px; align-items: center; height: 50px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); padding: 4px; }
.step-btn { display: grid; place-items: center; height: 100%; border: 0; border-radius: 10px; background: var(--surface-solid); box-shadow: var(--shadow-sm); transition: transform .15s var(--ease), background .2s; }
.step-btn:hover { background: var(--accent-soft); color: var(--accent); }
.step-btn:active { transform: scale(.9); }
.step-btn:disabled { opacity: .4; pointer-events: none; }
.step-input {
    width: 100%; height: 100%; border: 0; background: transparent; text-align: center;
    font-size: 1.25rem; font-weight: 750; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield;
}
.step-input:focus { outline: none; }
.step-input::-webkit-outer-spin-button, .step-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.step-input.bump { animation: bump .3s var(--spring); }
@keyframes bump { 50% { transform: scale(1.2); } }

.color-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.color-options input { position: absolute; opacity: 0; pointer-events: none; }
.color-option {
    display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 14px; cursor: pointer;
    border: 1.5px solid var(--border); background: var(--surface-2);
    transition: border-color .2s, background .2s, transform .2s var(--ease);
}
.color-option:hover { transform: translateY(-1px); border-color: var(--border-strong); }
.color-option b { display: block; font-size: .9rem; line-height: 1.2; }
.color-option small { display: block; font-size: .74rem; color: var(--muted); }
.color-options input:checked + .color-option { border-color: var(--accent); background: var(--accent-soft); }
.color-options input:focus-visible + .color-option { box-shadow: var(--ring); }
.swatch { width: 30px; height: 30px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 2px hsl(0 0% 100% / .5), 0 3px 8px hsl(0 0% 0% / .15); }
.swatch-color { background: conic-gradient(#00b4d8, #ff2d95, #ffd60a, #00b4d8); }
.swatch-gray { background: linear-gradient(135deg, #f2f2f2, #1a1a1a); }

.summary {
    display: flex; align-items: center; justify-content: space-between; gap: 6px;
    padding: 14px 16px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border);
}
.summary > div { display: grid; justify-items: center; }
.summary-num { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.summary-num.accent { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.summary-lbl { font-size: .72rem; color: var(--muted); }
.summary-op { color: var(--muted); font-weight: 600; }
.target { text-align: center; margin-top: -8px; }

/* ---------- Botones ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 44px; padding: 0 18px; border-radius: 13px; border: 1px solid transparent;
    font-weight: 650; font-size: .95rem; white-space: nowrap;
    transition: transform .2s var(--ease), box-shadow .2s, background .2s, opacity .2s, border-color .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-sm { height: 34px; padding: 0 12px; font-size: .84rem; border-radius: 10px; }
.btn-sm svg { width: 16px; height: 16px; }
.btn-block { width: 100%; }
.btn-ghost { background: var(--surface-2); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-solid); }
.btn-danger { background: var(--bad-soft); color: var(--bad); }
.btn-danger:hover:not(:disabled) { background: var(--bad); color: #fff; }
.btn-primary {
    position: relative; overflow: hidden; isolation: isolate;
    height: 54px; border-radius: 16px; font-size: 1.02rem; color: #fff;
    background: var(--grad);
    box-shadow: 0 14px 30px -12px hsl(var(--hue) 90% 55% / .8), inset 0 1px 0 hsl(0 0% 100% / .3);
}
.btn-primary::before {
    content: ""; position: absolute; inset: 0; z-index: -1;
    background: linear-gradient(110deg, transparent 30%, hsl(0 0% 100% / .35) 50%, transparent 70%);
    transform: translateX(-120%); transition: transform .8s var(--ease);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 18px 38px -12px hsl(var(--hue) 90% 55% / .9), inset 0 1px 0 hsl(0 0% 100% / .3); transform: translateY(-1px); }
.btn-primary:hover:not(:disabled)::before { transform: translateX(120%); }
.btn-primary:disabled { filter: saturate(.4); }
.btn.is-loading .btn-label::before {
    content: ""; display: inline-block; width: 15px; height: 15px; margin-right: 8px; vertical-align: -2px;
    border: 2.2px solid hsl(0 0% 100% / .4); border-top-color: #fff; border-radius: 50%;
    animation: spin .7s linear infinite;
}
.btn.is-loading > svg { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); transition: background .2s, transform .2s var(--ease); }
.icon-btn:hover { background: var(--surface-solid); }
.icon-btn:active { transform: scale(.92); }

.badge {
    display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 99px;
    font-size: .76rem; font-weight: 700; white-space: nowrap;
    background: var(--surface-2); color: var(--text-2);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge[data-tone="ok"] { background: var(--ok-soft); color: var(--ok); }
.badge[data-tone="info"] { background: var(--info-soft); color: var(--info); }
.badge[data-tone="warn"] { background: var(--warn-soft); color: var(--warn); }
.badge[data-tone="bad"] { background: var(--bad-soft); color: var(--bad); }
.badge[data-tone="info"]::before { animation: blink 1.1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* ---------- Trabajos ---------- */
.jobs-card { padding: 18px; display: grid; gap: 14px; animation: rise .45s var(--ease) both; }
.job-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.job {
    display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px;
    padding: 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border);
    animation: rise .4s var(--ease) both;
}
.job-icon { position: relative; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; background: var(--accent-soft); color: var(--accent); }
.job[data-tone="ok"] .job-icon { background: var(--ok-soft); color: var(--ok); }
.job[data-tone="bad"] .job-icon { background: var(--bad-soft); color: var(--bad); }
.job[data-tone="warn"] .job-icon { background: var(--warn-soft); color: var(--warn); }
.job[data-tone="info"] .job-icon::after {
    content: ""; position: absolute; inset: -3px; border-radius: 15px;
    border: 2px solid transparent; border-top-color: var(--info); border-right-color: var(--info);
    animation: spin 1s linear infinite;
}
.job-body { min-width: 0; display: grid; gap: 3px; }
.job-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.job-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-id { font-family: var(--mono); font-size: .74rem; color: var(--muted); flex: none; }
.job-meta { font-size: .8rem; color: var(--muted); }
.job-msg { font-size: .8rem; color: var(--warn); font-weight: 600; }
.job-side { display: grid; justify-items: end; gap: 8px; }
.job-bar { grid-column: 1 / -1; height: 4px; border-radius: 99px; overflow: hidden; background: var(--surface-solid); }
.job-bar span { display: block; height: 100%; width: 40%; border-radius: inherit; background: var(--grad); animation: indet 1.4s var(--ease) infinite; }
@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
@media (max-width: 520px) {
    .job { grid-template-columns: auto 1fr; }
    .job-side { grid-column: 1 / -1; grid-template-columns: 1fr auto; align-items: center; justify-items: start; }
}

/* ---------- Barra móvil ---------- */
.mobile-bar {
    position: fixed; z-index: 25; left: 10px; right: 10px; bottom: calc(10px + var(--safe-b));
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 10px 10px 18px; border-radius: 20px;
    background: color-mix(in srgb, var(--surface-solid) 82%, transparent);
    box-shadow: var(--shadow-lg);
    animation: slideup .4s var(--spring) both;
}
.mobile-bar .btn-primary { height: 48px; padding: 0 22px; }
.mobile-sum { display: grid; line-height: 1.15; }
.mobile-sum b { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.mobile-sum span { font-size: .76rem; color: var(--muted); }
@keyframes slideup { from { transform: translateY(120%); } }
@media (min-width: 960px) { .mobile-bar { display: none !important; } }
@media (max-width: 959px) {
    body.has-doc .shell { padding-bottom: calc(110px + var(--safe-b)); }
    body.has-doc .options-card .btn-primary, body.has-doc .options-card .target { display: none; }
}

/* ---------- Visor ---------- */
.viewer {
    width: min(980px, 100vw); height: min(100dvh, 1100px); max-width: 100vw; max-height: 100dvh;
    margin: auto; padding: 0; border: 0; border-radius: var(--radius-lg);
    background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.viewer[open] { display: grid; grid-template-rows: auto 1fr; animation: pop .28s var(--spring); }
.viewer::backdrop { background: hsl(235 40% 6% / .66); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
@media (max-width: 700px) { .viewer { width: 100vw; height: 100dvh; border-radius: 0; } }
.viewer-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--border); }
.viewer-actions { display: flex; align-items: center; gap: 8px; }
.viewer-toggle[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.viewer-toggle[aria-pressed="false"] svg { opacity: .25; }
.viewer-stage { position: relative; display: grid; place-items: center; padding: 16px 64px; overflow: auto; background: var(--bg-2); min-height: 0; touch-action: pan-y pinch-zoom; }
.viewer-stage canvas { max-width: 100%; max-height: 100%; height: auto; background: #fff; border-radius: 6px; box-shadow: var(--shadow); transition: opacity .2s, filter .3s; }
.viewer-stage.is-loading canvas { opacity: .4; }
.viewer-stage.is-gray canvas { filter: grayscale(1); }
.viewer .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; background: var(--surface-solid); box-shadow: var(--shadow); }
.viewer .nav.prev { left: 12px; }
.viewer .nav.next { right: 12px; }
.viewer .nav:disabled { opacity: .3; }
@media (max-width: 700px) { .viewer-stage { padding: 12px; } .viewer .nav { top: auto; bottom: 16px; transform: none; } }

/* ---------- Arrastrar / toasts ---------- */
.drag-overlay {
    position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
    background: hsl(var(--hue) 70% 30% / .35); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    animation: fade .2s both; pointer-events: none;
}
.drag-overlay > div { display: grid; justify-items: center; gap: 10px; padding: 34px 44px; border-radius: var(--radius-lg); background: var(--surface-solid); box-shadow: var(--shadow-lg); border: 2px dashed var(--accent); font-weight: 700; }
.drag-overlay svg { width: 40px; height: 40px; color: var(--accent); }
@keyframes fade { from { opacity: 0; } }

.toasts {
    position: fixed; z-index: 70; left: 50%; transform: translateX(-50%);
    top: calc(var(--topbar-h) + 10px);
    width: min(440px, calc(100vw - 24px)); display: grid; gap: 8px; pointer-events: none;
}
.toast {
    display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 14px;
    background: var(--surface-solid); box-shadow: var(--shadow-lg); border: 1px solid var(--border);
    font-size: .9rem; pointer-events: auto;
    animation: toastin .35s var(--spring) both;
}
.toast.is-leaving { animation: toastout .25s var(--ease) forwards; }
.toast::before { content: ""; width: 8px; height: 8px; margin-top: 7px; border-radius: 50%; flex: none; background: var(--info); }
.toast[data-type="success"]::before { background: var(--ok); }
.toast[data-type="error"]::before { background: var(--bad); }
.toast[data-type="warn"]::before { background: var(--warn); }
.toast p { flex: 1; }
.toast button { border: 0; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .8rem; padding: 4px 10px; border-radius: 8px; }
@keyframes toastin { from { opacity: 0; transform: translateY(-12px) scale(.96); } }
@keyframes toastout { to { opacity: 0; transform: translateY(-8px) scale(.97); } }

/* ---------- Pantalla de Inicio de Sesión ---------- */
.login-shell {
    min-height: calc(100dvh - var(--topbar-h) - 60px);
    display: grid;
    place-items: center;
    padding: 24px 16px;
}
.login-card {
    width: min(440px, 100%);
    padding: clamp(24px, 5vw, 36px);
    display: grid;
    gap: 20px;
    animation: pop .35s var(--spring);
}
.login-header {
    text-align: center;
    display: grid;
    gap: 8px;
    justify-items: center;
}
.login-header .brand-mark {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    margin-bottom: 4px;
}
.login-header .brand-mark svg {
    width: 28px;
    height: 28px;
}
.login-header h1 {
    font-size: 1.45rem;
    font-weight: 750;
    letter-spacing: -.02em;
}
.login-header p {
    font-size: .9rem;
    color: var(--text-2);
}
.login-form {
    display: grid;
    gap: 16px;
}
.login-group {
    display: grid;
    gap: 6px;
}
.login-group label {
    font-size: .82rem;
    font-weight: 650;
    color: var(--text-2);
}
.login-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.login-input-wrap .field-icon {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    color: var(--muted);
    pointer-events: none;
    transition: color .2s;
}
.login-input {
    width: 100%;
    height: 48px;
    padding: 0 44px 0 42px;
    border-radius: 13px;
    border: 1px solid var(--border-strong);
    background: var(--surface-solid);
    font-size: .96rem;
    transition: border-color .2s, box-shadow .2s;
}
.login-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring);
}
.login-input-wrap:focus-within .field-icon {
    color: var(--accent);
}
.toggle-pass-btn {
    position: absolute;
    right: 8px;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    transition: color .2s, background .2s;
}
.toggle-pass-btn:hover {
    color: var(--text);
    background: var(--surface-2);
}
.remember-row {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    font-size: .88rem;
    color: var(--text-2);
}
.remember-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
    border-radius: 5px;
}
.login-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: .88rem;
    line-height: 1.4;
    animation: rise .3s var(--ease);
}
.login-alert.is-error {
    background: var(--bad-soft);
    color: var(--bad);
    border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent);
}
.login-alert svg {
    width: 18px;
    height: 18px;
    flex: none;
    margin-top: 2px;
}
.login-note {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: .82rem;
    color: var(--muted);
    line-height: 1.45;
}
.login-note strong {
    color: var(--text);
}
.login-note code {
    font-size: .85em;
    user-select: all;
}

.footer { text-align: center; padding: 0 16px calc(28px + var(--safe-b)); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
