/* ───────────────────────── Tokens ───────────────────────── */
:root {
    --bg: #f6f5f1;
    --surface: #ffffff;
    --surface-2: #f1efe9;
    --surface-3: #e9e6dd;
    --border: #e2ded4;
    --border-strong: #cfcabd;
    --text: #1d2230;
    --muted: #5f6573;
    --faint: #8b909c;
    --primary: #2d3f8f;
    --primary-hover: #223172;
    --primary-soft: #e9ecf8;
    --primary-text: #ffffff;
    --accent: #b7791f;
    --accent-soft: #fbf1dc;
    --ok: #1f7a4d;
    --ok-soft: #e2f3e9;
    --warn: #8f5f00;
    --warn-soft: #fcf0d3;
    --err: #b42318;
    --err-soft: #fce8e6;
    --info: #2d3f8f;
    --info-soft: #e9ecf8;
    --console: #151823;
    --console-text: #d7dbe6;
    --shadow: 0 1px 2px rgba(29, 34, 48, .05), 0 1px 3px rgba(29, 34, 48, .04);
    --shadow-lg: 0 10px 30px rgba(29, 34, 48, .12);
    --radius: 10px;
    --radius-sm: 6px;
    --font: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-title: "Fraunces", Georgia, "Times New Roman", serif;
    --font-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #12141a;
        --surface: #1a1d25;
        --surface-2: #222632;
        --surface-3: #2a2f3d;
        --border: #2e3340;
        --border-strong: #3d4353;
        --text: #e7e9ee;
        --muted: #a0a6b3;
        --faint: #767c89;
        --primary: #8ea2f0;
        --primary-hover: #a6b6f4;
        --primary-soft: #232a45;
        --primary-text: #0f1320;
        --accent: #e0a64a;
        --accent-soft: #3a2c14;
        --ok: #5cc98b;
        --ok-soft: #173325;
        --warn: #e5b454;
        --warn-soft: #352a12;
        --err: #f08a82;
        --err-soft: #3a1c1a;
        --info: #8ea2f0;
        --info-soft: #232a45;
        --console: #0c0e14;
        --shadow: none;
        --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
        color-scheme: dark;
    }
}

/* ───────────────────────── Base ───────────────────────── */
* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 var(--font);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font: 600 1.75rem/1.2 var(--font-title); letter-spacing: -.01em; }
h2 { font: 600 1.25rem/1.3 var(--font-title); }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--primary); }
code, .mono { font-family: var(--font-mono); font-size: .88em; }
code { background: var(--surface-2); padding: .05em .35em; border-radius: 4px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
/* Los títulos reciben el foco al cambiar de página (lectores de pantalla), sin recuadro visible */
[tabindex="-1"]:focus { outline: none; }

/* ───────────────────────── Header ───────────────────────── */
.app-header {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 1.25rem;
    height: 60px; padding: 0 1.5rem;
    background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand {
    display: flex; align-items: center; gap: .55rem;
    font: 600 1.15rem var(--font-title); color: var(--text); text-decoration: none; white-space: nowrap;
}
.brand-mark {
    display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
    background: var(--primary); color: var(--primary-text); font: 700 .95rem var(--font);
}
.main-nav { display: flex; gap: .15rem; }
.main-nav a {
    padding: .45rem .75rem; border-radius: var(--radius-sm);
    color: var(--muted); text-decoration: none; font-weight: 550; white-space: nowrap;
}
.main-nav a:hover { color: var(--text); background: var(--surface-2); }
.main-nav a.active { color: var(--primary); background: var(--primary-soft); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: .6rem; }

.project-switch {
    display: flex; align-items: center; gap: .4rem;
    padding: .3rem .4rem .3rem .7rem; border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface-2); font-size: .85rem;
}
.project-switch label { color: var(--muted); }
.project-switch select {
    border: 0; background: transparent; color: var(--text); font: 600 .85rem var(--font);
    max-width: 180px; cursor: pointer; padding: .1rem .2rem;
}
.activity-pill {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .3rem .7rem; border-radius: 999px; font-size: .82rem; font-weight: 600;
    background: var(--info-soft); color: var(--info); text-decoration: none;
}
.activity-pill .spinner { width: 12px; height: 12px; border-width: 2px; }

.menu { position: relative; }
.menu-btn {
    display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent); border: 0; cursor: pointer;
    font: 700 .9rem var(--font); text-transform: uppercase;
}
.menu-list {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; z-index: 30;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); padding: .35rem; list-style: none; margin: 0;
}
.menu-list li > * {
    display: block; width: 100%; text-align: left; padding: .5rem .7rem; border-radius: var(--radius-sm);
    color: var(--text); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer;
}
.menu-list li > *:hover { background: var(--surface-2); }
.menu-list .menu-head { padding: .45rem .7rem .55rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; }
.menu-list .menu-head strong { display: block; }

/* ───────────────────────── Layout ───────────────────────── */
main { max-width: 1120px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head p { margin-top: .35rem; }
.back-link { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); text-decoration: none; font-size: .9rem; margin-bottom: .6rem; }
.back-link:hover { color: var(--text); }

.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1.25rem 1.4rem;
}
.card + .card { margin-top: 1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.section-title { font: 650 .78rem var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 2rem 0 .75rem; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: .6rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.stack > * + * { margin-top: .75rem; }

/* ───────────────────────── Botones ───────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    padding: .55rem 1rem; border-radius: var(--radius-sm); border: 1px solid transparent;
    font: 600 .9rem var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-outline:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--surface); color: var(--err); border-color: var(--border-strong); }
.btn-danger:hover:not(:disabled) { background: var(--err-soft); border-color: var(--err); }
.btn-sm { padding: .32rem .65rem; font-size: .82rem; }
.btn-lg { padding: .75rem 1.4rem; font-size: 1rem; }
.btn-icon { padding: .35rem; width: 32px; height: 32px; }

/* ───────────────────────── Formularios ───────────────────────── */
.field { display: block; margin-bottom: 1rem; }
.field > span { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .35rem; }
.field small { display: block; color: var(--muted); font-size: .8rem; margin-top: .3rem; }
.input, select.input, textarea.input {
    display: block; width: 100%; padding: .6rem .75rem;
    font: 400 .95rem var(--font); color: var(--text); background: var(--surface);
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
textarea.input { resize: vertical; min-height: 120px; font-family: var(--font-mono); font-size: .88rem; }
.input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.input.invalid { border-color: var(--err); }

.switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; font-weight: 500; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
    position: relative; width: 38px; height: 22px; border-radius: 999px; background: var(--surface-3);
    border: 1px solid var(--border-strong); transition: background .15s; flex: none;
}
.switch .track::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
    background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s;
}
.switch input:checked + .track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Tarjetas seleccionables (radio/checkbox) */
.choice-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.choice {
    position: relative; display: flex; gap: .75rem; align-items: flex-start;
    padding: .9rem 1rem; border: 1.5px solid var(--border); border-radius: var(--radius);
    background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s;
}
.choice:hover { border-color: var(--border-strong); }
.choice input { margin-top: .2rem; accent-color: var(--primary); width: 16px; height: 16px; flex: none; }
.choice strong { display: block; font-size: .95rem; }
.choice span.desc { display: block; color: var(--muted); font-size: .84rem; margin-top: .15rem; }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.choice:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.choice-icon {
    display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; flex: none;
    background: var(--surface-2); color: var(--primary); font-size: 1.1rem;
}

/* ───────────────────────── Estados ───────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .12rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 650; white-space: nowrap;
    background: var(--surface-2); color: var(--muted);
}
.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(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); font-size: .9rem; display: flex; gap: .6rem; align-items: flex-start; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.err { background: var(--err-soft); color: var(--err); }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert .btn { margin-left: auto; }

.spinner {
    display: inline-block; width: 16px; height: 16px; border-radius: 50%;
    border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; display: flex; }
.progress > span { display: block; height: 100%; transition: width .3s; }
.progress .ok { background: var(--ok); }
.progress .err { background: var(--err); }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty-state h3 { color: var(--text); margin-bottom: .35rem; }
.empty-state .btn { margin-top: 1rem; }

/* ───────────────────────── Inicio ───────────────────────── */
.hero { margin-bottom: 1.75rem; }
.hero p { color: var(--muted); margin-top: .35rem; font-size: 1.02rem; }
.task-grid { display: grid; gap: 1rem; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.task {
    display: flex; flex-direction: column; gap: .5rem;
    padding: 1.4rem; border-radius: 14px; text-decoration: none; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
    transition: transform .15s, box-shadow .15s, border-color .15s;
}
.task:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.task-icon {
    display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; margin-bottom: .4rem;
    font-size: 1.35rem; background: var(--primary-soft); color: var(--primary);
}
.task:nth-child(2) .task-icon { background: var(--accent-soft); color: var(--accent); }
.task:nth-child(3) .task-icon { background: var(--ok-soft); color: var(--ok); }
.task h2 { font-size: 1.15rem; }
.task p { color: var(--muted); font-size: .9rem; }
.task .go { margin-top: auto; padding-top: .6rem; font-weight: 650; color: var(--primary); font-size: .9rem; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.stat { padding: 1rem 1.2rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.stat b { display: block; font: 600 1.6rem var(--font-title); font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .85rem; }

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; align-items: center; gap: .75rem; padding: .7rem 0; border-top: 1px solid var(--border); }
.checklist li:first-child { border-top: 0; }
.checklist .num {
    display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; flex: none;
    border: 1.5px solid var(--border-strong); font-size: .8rem; font-weight: 700; color: var(--muted);
}
.checklist li.done .num { background: var(--ok); border-color: var(--ok); color: #fff; }
.checklist li.done .txt { color: var(--muted); text-decoration: line-through; }
.checklist .btn { margin-left: auto; }

/* ───────────────────────── Listas de trabajos ───────────────────────── */
.job-list { list-style: none; margin: 0; padding: 0; }
.job {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .9rem; align-items: center;
    padding: .9rem 1rem; border-top: 1px solid var(--border); text-decoration: none; color: inherit;
}
.job-list > li:first-child .job { border-top: 0; }
.job:hover { background: var(--surface-2); }
.job-type {
    display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; font-size: 1rem;
    background: var(--primary-soft); color: var(--primary);
}
.job-type.escritos { background: var(--accent-soft); color: var(--accent); }
.job-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-meta { color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-side { display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; min-width: 120px; }
.job-side .progress { width: 120px; }

.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip {
    padding: .35rem .8rem; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
    color: var(--muted); font: 600 .82rem var(--font); cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--text); border-color: var(--text); color: var(--surface); }

.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .input { width: auto; min-width: 220px; flex: 1; max-width: 360px; }
.toolbar select.input { flex: none; min-width: 0; }

/* ───────────────────────── Asistente ───────────────────────── */
.wizard { max-width: 820px; margin: 0 auto; }
.wizard-head { margin-bottom: 1.25rem; }
.stepper { display: flex; list-style: none; margin: 0 0 1.5rem; padding: 0; counter-reset: paso; }
.stepper li {
    flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: .35rem;
    font-size: .8rem; color: var(--faint); text-align: center; counter-increment: paso;
}
.stepper li::before {
    content: counter(paso); display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
    border: 2px solid var(--border-strong); background: var(--surface); color: var(--muted);
    font-weight: 700; font-size: .85rem; position: relative; z-index: 1;
}
.stepper li::after {
    content: ""; position: absolute; top: 15px; left: calc(50% + 18px); right: calc(-50% + 18px);
    height: 2px; background: var(--border);
}
.stepper li:last-child::after { display: none; }
.stepper li.current { color: var(--text); font-weight: 650; }
.stepper li.current::before { border-color: var(--primary); color: var(--primary); }
.stepper li.done { color: var(--muted); }
.stepper li.done::before { content: "✓"; background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.stepper li.done::after { background: var(--primary); }

.wizard-body { min-height: 260px; }
.wizard-body > h2 { margin-bottom: .3rem; }
.wizard-body > p.lead { color: var(--muted); margin-bottom: 1.25rem; }
.wizard-foot {
    display: flex; justify-content: space-between; gap: .75rem; align-items: center;
    margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border);
}

.summary { display: grid; grid-template-columns: minmax(140px, max-content) 1fr; gap: .55rem 1.25rem; margin: 0; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }

/* Lista de expedientes ingresados */
.exp-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .75rem; }
.exp-chip {
    display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .3rem .2rem .6rem;
    border-radius: 6px; background: var(--surface-2); font: .82rem var(--font-mono);
}
.exp-chip.invalid { background: var(--err-soft); color: var(--err); }
.exp-chip button { border: 0; background: none; color: inherit; cursor: pointer; opacity: .6; font-size: 1rem; line-height: 1; padding: 0 .2rem; }
.exp-chip button:hover { opacity: 1; }

/* Zona de archivos */
.dropzone {
    display: flex; flex-direction: column; align-items: center; gap: .3rem; text-align: center;
    padding: 1.75rem 1rem; border: 2px dashed var(--border-strong); border-radius: var(--radius);
    background: var(--surface-2); color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone strong { color: var(--text); }
.dropzone .dz-icon { font-size: 1.6rem; color: var(--primary); }

/* Selector con búsqueda */
.combo { position: relative; }
/* position: fixed para que no la recorten las tablas con scroll; la posición se calcula en JS */
.combo-list {
    position: fixed; z-index: 60; max-height: 260px; overflow-y: auto;
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg); list-style: none; margin: 0; padding: .25rem;
}
.combo-list li { padding: .45rem .6rem; border-radius: 4px; cursor: pointer; font-size: .9rem; }
.combo-list li:hover, .combo-list li.active { background: var(--primary-soft); }
.combo-list li .cod { color: var(--faint); font-family: var(--font-mono); font-size: .78rem; margin-left: .4rem; }
.combo-list li.none { color: var(--muted); cursor: default; }

/* ───────────────────────── Tablas ───────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--surface-2); font-weight: 650; font-size: .8rem; color: var(--muted); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .input { padding: .35rem .5rem; font-size: .85rem; }
td.check, th.check { width: 36px; }
td.check input, th.check input { width: 16px; height: 16px; accent-color: var(--primary); }

.kv { display: grid; grid-template-columns: minmax(150px, max-content) 1fr; gap: .45rem 1.25rem; margin: 0; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* Pestañas de la ficha */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tab {
    padding: .6rem .9rem; border: 0; background: none; color: var(--muted); cursor: pointer; white-space: nowrap;
    font: 600 .9rem var(--font); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab .count { font-weight: 500; color: var(--faint); margin-left: .25rem; }

/* Barra de selección múltiple */
.selection-bar {
    position: sticky; bottom: 1rem; z-index: 10; margin-top: 1rem;
    display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
    padding: .7rem 1rem; border-radius: var(--radius); background: var(--text); color: var(--surface); box-shadow: var(--shadow-lg);
}
.selection-bar .btn-outline { background: transparent; color: var(--surface); border-color: rgba(255,255,255,.35); }
.selection-bar .btn-outline:hover { background: rgba(255,255,255,.1); }

/* Consola de log */
.console {
    margin: 0; padding: .9rem 1rem; max-height: 360px; overflow: auto; border-radius: var(--radius-sm);
    background: var(--console); color: var(--console-text);
    font: 12.5px/1.6 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere;
}
details.log > summary { cursor: pointer; font-weight: 600; padding: .25rem 0; list-style: none; display: flex; align-items: center; gap: .4rem; }
details.log > summary::-webkit-details-marker { display: none; }
details.log > summary::before { content: "▸"; color: var(--muted); }
details.log[open] > summary::before { content: "▾"; }
details.log[open] > summary { margin-bottom: .6rem; }

/* Tarjetas de cuentas/proyectos */
.item-list { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.item-card { display: flex; flex-direction: column; gap: .5rem; }
.item-card .actions { display: flex; gap: .4rem; margin-top: auto; padding-top: .5rem; flex-wrap: wrap; }

/* ───────────────────────── Diálogos y avisos ───────────────────────── */
dialog {
    border: 1px solid var(--border); border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px));
    background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(15, 18, 28, .5); }
.dialog-body { padding: 1.4rem 1.5rem 1rem; }
.dialog-body h2 { margin-bottom: .5rem; }
.dialog-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: 1rem 1.5rem 1.25rem; }

/* Arriba a la derecha, bajo el encabezado: abajo tapaban los botones de los asistentes */
.toasts { position: fixed; right: 1.25rem; top: 72px; z-index: 100; display: flex; flex-direction: column; gap: .5rem; max-width: min(380px, calc(100vw - 32px)); }
.toast {
    padding: .7rem 1rem; border-radius: var(--radius-sm); background: var(--text); color: var(--surface);
    box-shadow: var(--shadow-lg); font-size: .9rem; animation: toast-in .2s ease-out;
}
.toast.err { background: var(--err); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* ───────────────────────── Ingreso ───────────────────────── */
.auth {
    min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
}
.auth-side {
    display: flex; flex-direction: column; justify-content: space-between; padding: 3rem;
    background: var(--primary); color: var(--primary-text);
}
.auth-side .brand { color: var(--primary-text); }
.auth-side .brand-mark { background: var(--primary-text); color: var(--primary); }
.auth-side h1 { font-size: 2.3rem; max-width: 460px; }
.auth-side ul { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .7rem; max-width: 440px; opacity: .92; }
.auth-side li { display: flex; gap: .6rem; }
.auth-side li::before { content: "—"; opacity: .6; }
.auth-main { display: grid; place-items: center; padding: 2rem 1.5rem; }
.auth-form { width: 100%; max-width: 380px; }
.auth-form h2 { font-size: 1.6rem; margin-bottom: .35rem; }
.auth-form > p { color: var(--muted); margin-bottom: 1.5rem; }
.auth-form .btn-primary { width: 100%; margin-top: .5rem; }

.loading-screen { min-height: 60vh; display: grid; place-items: center; color: var(--muted); }

/* ───────────────────────── Responsive ───────────────────────── */
@media (max-width: 900px) {
    .task-grid, .grid-3 { grid-template-columns: 1fr; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .auth { grid-template-columns: 1fr; }
    .auth-side { padding: 2rem 1.5rem; }
    .auth-side h1 { font-size: 1.7rem; }
    .auth-side ul { display: none; }
}
@media (max-width: 760px) {
    .app-header { flex-wrap: wrap; height: auto; padding: .6rem 1rem; gap: .6rem; }
    .main-nav { order: 3; width: 100%; overflow-x: auto; }
    .project-switch label { display: none; }
    .project-switch select { max-width: 120px; }
    main { padding: 1.25rem 1rem 3rem; }
    .grid-2 { grid-template-columns: 1fr; }
    .card { padding: 1rem; }
    .stepper li span { display: none; }
    .job { grid-template-columns: auto minmax(0, 1fr); }
    .job-side { grid-column: 2; align-items: flex-start; }
    .summary, .kv { grid-template-columns: 1fr; gap: .15rem; }
    .summary dd, .kv dd { margin-bottom: .5rem; }
    h1 { font-size: 1.45rem; }
}
