/* Gestor documental Inika — estilos del panel. Sin dependencias externas.
   Diseño: barra superior blanca con el logotipo, menú lateral azul con esquina redondeada, tarjetas suaves.
   Azul de la interfaz + naranja de la marca Inika (#F47921) como acento. */
:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --text: #1b2433;
  --muted: #64708a;
  --border: #e3e8f1;
  --primary: #1f5bd6;
  --primary-strong: #1747a8;
  --primary-soft: #e8effc;
  --accent: #f47921;
  --accent-soft: #fef0e5;
  --sidebar: #1f5bd6;
  --sidebar-text: #e9f0ff;
  --sidebar-muted: #b9cbf2;
  --ok: #2e7d4f;
  --ok-soft: #e5f4ea;
  --warn: #8a5a00;
  --warn-soft: #fff4dc;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --info: #1f5fa8;
  --info-soft: #e8f0fb;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(23, 42, 87, .05), 0 4px 16px rgba(23, 42, 87, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --topbar-h: 64px;
  --border-hover: #c9d4e8;
  --sidebar-active-bg: #fff;
  --sidebar-active-text: var(--primary-strong);
  --logo-bg: transparent;
  --logo-pad: 0;
  --hero-start: var(--primary);
  --hero-end: #2f74ee;
  color-scheme: light;
}

/* Temas: <html data-theme="auto|light|dark|blue|sepia|cream">. «auto» (y «light») usan la paleta anterior;
   «auto» cambia a la oscura si el sistema lo pide. Cada tema solo redefine las variables. */
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #12161d; --surface: #1b212b; --surface-2: #202836; --text: #e6e9ef; --muted: #9aa6ba; --border: #2c3443; --border-hover: #3d4759;
    --primary: #6f9bf5; --primary-strong: #a4c0fb; --primary-soft: #1d2b47;
    --accent: #ff9a4d; --accent-soft: #3a2616;
    --sidebar: #17305f; --sidebar-text: #e3ebfd; --sidebar-muted: #93a9d6; --sidebar-active-bg: var(--primary-soft); --sidebar-active-text: #fff;
    --ok: #6fcf97; --ok-soft: #1d3326; --warn: #f2c14e; --warn-soft: #3a2f13;
    --danger: #ff8a80; --danger-soft: #3d1f1d; --info: #8ab4f8; --info-soft: #1e2b3d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --logo-bg: #fff; --logo-pad: 2px 6px; --hero-start: #17305f; --hero-end: #1f4590;
    color-scheme: dark;
  }
}
/* Noche */
:root[data-theme="dark"] {
  --bg: #12161d; --surface: #1b212b; --surface-2: #202836; --text: #e6e9ef; --muted: #9aa6ba; --border: #2c3443; --border-hover: #3d4759;
  --primary: #6f9bf5; --primary-strong: #a4c0fb; --primary-soft: #1d2b47;
  --accent: #ff9a4d; --accent-soft: #3a2616;
  --sidebar: #17305f; --sidebar-text: #e3ebfd; --sidebar-muted: #93a9d6; --sidebar-active-bg: var(--primary-soft); --sidebar-active-text: #fff;
  --ok: #6fcf97; --ok-soft: #1d3326; --warn: #f2c14e; --warn-soft: #3a2f13;
  --danger: #ff8a80; --danger-soft: #3d1f1d; --info: #8ab4f8; --info-soft: #1e2b3d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --logo-bg: #fff; --logo-pad: 2px 6px; --hero-start: #17305f; --hero-end: #1f4590;
  color-scheme: dark;
}
/* Azul: fondos azul claro y menú azul marino */
:root[data-theme="blue"] {
  --bg: #e4edfb; --surface: #f6f9ff; --surface-2: #ecf2fd; --text: #10264d; --muted: #4c638c; --border: #c8d8f2; --border-hover: #a9c1e9;
  --primary: #1a56c8; --primary-strong: #123f96; --primary-soft: #d6e4fa;
  --sidebar: #12347a; --sidebar-text: #e2ebfc; --sidebar-muted: #9fb6e2;
  --info-soft: #dce8fb;
  --shadow: 0 1px 2px rgba(18, 52, 122, .07), 0 4px 16px rgba(18, 52, 122, .07);
  --hero-start: #12347a; --hero-end: #1a56c8;
}
/* Sepia: tonos de papel envejecido, cómodos para leer mucho rato */
:root[data-theme="sepia"] {
  --bg: #efe4cc; --surface: #f8f0dd; --surface-2: #f3e9d3; --text: #46382a; --muted: #7c6a54; --border: #e0cfac; --border-hover: #cdb68a;
  --primary: #8a5a2b; --primary-strong: #6b431c; --primary-soft: #ecdcbd;
  --accent: #c0602a; --accent-soft: #f3dcc6;
  --sidebar: #7a5230; --sidebar-text: #f7ecd9; --sidebar-muted: #dcc4a2;
  --info: #6b5a3a; --info-soft: #ece0c6; --warn-soft: #f3e2b8;
  --shadow: 0 1px 2px rgba(90, 60, 20, .07), 0 4px 16px rgba(90, 60, 20, .07);
  --hero-start: #7a5230; --hero-end: #a06c3c;
}
/* Crema: fondo cálido claro con el azul y el naranja de la marca */
:root[data-theme="cream"] {
  --bg: #f7f1e3; --surface: #fffcf5; --surface-2: #fbf6ea; --text: #2f2a22; --muted: #786f5f; --border: #eadfc8; --border-hover: #d9c9a8;
  --primary-soft: #e9eefa;
  --info-soft: #eef1f8;
  --shadow: 0 1px 2px rgba(80, 60, 20, .06), 0 4px 16px rgba(80, 60, 20, .06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .86em; background: var(--primary-soft); padding: .05em .35em; border-radius: 4px; }
h1 { font-size: 1.7rem; margin: 0 0 .3rem; line-height: 1.25; color: var(--primary-strong); font-weight: 700; }
h2 { font-size: 1.12rem; margin: 0 0 .8rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 .6rem; }
.sr-only { position: absolute; 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); }
.hint { color: var(--muted); font-size: .86rem; margin: .5rem 0; }
.icon { flex-shrink: 0; }

/* Barra superior */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; height: var(--topbar-h); padding: 0 1.5rem; background: var(--surface); }
.brand { display: flex; align-items: center; gap: .75rem; font-weight: 600; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo { display: block; height: 32px; width: auto; background: var(--logo-bg); padding: var(--logo-pad); border-radius: 8px; }
.brand-name { padding-left: .75rem; border-left: 1px solid var(--border); color: var(--muted); font-size: .95rem; }
.brand-mark { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 800; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .9rem; }
.ui-lang select { min-height: 34px; padding: .25rem 1.8rem .25rem .6rem; border-radius: 999px; background-color: var(--surface-2); font-size: .88rem; }
.user-chip { display: flex; align-items: center; gap: .65rem; color: var(--text); }
.user-chip:hover { text-decoration: none; }
.user-chip:hover .avatar { box-shadow: 0 0 0 3px var(--primary-soft); }
.user-name { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; font-weight: 500; font-size: .92rem; }
.user-name small { color: var(--muted); font-weight: 400; font-size: .76rem; }
.avatar { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; transition: box-shadow .15s; }
.nav-toggle { display: none; }

/* Estructura: menú lateral azul con la esquina superior derecha redondeada */
.shell { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidebar { position: sticky; top: var(--topbar-h); align-self: flex-start; width: 248px; height: calc(100vh - var(--topbar-h)); flex-shrink: 0; overflow-y: auto; padding: 1.6rem 1rem 1.2rem; background: var(--sidebar); display: flex; flex-direction: column; gap: 2px; scrollbar-width: none; }
.sidebar::-webkit-scrollbar { display: none; }
.sidebar a { display: flex; align-items: center; gap: .75rem; padding: .55rem .85rem; border-radius: 999px; color: var(--sidebar-text); font-weight: 500; }
.sidebar a .icon { opacity: .85; }
.sidebar a:hover { background: rgba(255, 255, 255, .12); text-decoration: none; }
.sidebar a[aria-current="page"] { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); font-weight: 600; }
.sidebar a[aria-current="page"] .icon { opacity: 1; color: var(--primary); }
.sidebar .sidebar-action { justify-content: center; margin: 0 .2rem 1.1rem; padding: .7rem 1rem; background: var(--sidebar-active-bg); color: var(--sidebar-active-text); font-weight: 600; box-shadow: 0 4px 14px rgba(9, 30, 80, .18); }
.sidebar .sidebar-action:hover { background: var(--sidebar-active-bg); transform: translateY(-1px); }
.sidebar .sidebar-foot { margin-top: auto; padding-top: .9rem; border-radius: 0; border-top: 1px solid rgba(255, 255, 255, .18); color: var(--sidebar-muted); font-size: .9rem; }
.sidebar .sidebar-foot:hover { background: transparent; color: #fff; }
.nav-group { display: flex; align-items: center; gap: .6rem; margin: 1.3rem .85rem .45rem; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--sidebar-muted); }
.nav-group::after { content: ""; flex: 1; height: 1px; background: rgba(255, 255, 255, .22); }
.main { flex: 1; min-width: 0; padding: 2rem 2.2rem 3rem; max-width: 100%; }
body.bare .main { margin: 0 auto; }

/* Tarjetas */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem 1.4rem; margin-bottom: 1.2rem; box-shadow: var(--shadow); }
.panel > h2:first-child { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 1rem; }
.panel.narrow { max-width: 440px; margin: 3rem auto; }
/* Guía del gestor */
.guide { max-width: 900px; }
.guide-toc { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: 1.2rem; }
.guide-toc a { padding: .3rem .8rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: .88rem; font-weight: 600; }
.guide-toc a:hover { border-color: var(--primary); text-decoration: none; }
.guide .panel { scroll-margin-top: calc(var(--topbar-h) + 1rem); }
.guide .panel > h2:first-child { font-size: 1.1rem; text-transform: none; letter-spacing: 0; color: var(--primary-strong); margin-bottom: .7rem; }
.guide p, .guide ul { max-width: 72ch; line-height: 1.6; }
.guide ul { padding-left: 1.2rem; margin: 0 0 .8rem; }
.guide li + li, .guide li > ul { margin-top: .3rem; }
.guide .table th[scope="row"] { font-size: inherit; text-transform: none; letter-spacing: 0; color: var(--text); padding-top: .8rem; white-space: nowrap; }
.panel-warn { border-color: var(--warn); }
.panel-danger { border-color: var(--danger); }
.panel-danger .btn .icon { width: 16px; height: 16px; }
.muted-panel { background: transparent; box-shadow: none; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem; padding-bottom: 1.1rem; border-bottom: 1px solid var(--border); }
.page-head p { margin: .2rem 0 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.2rem; }
.grid-2 > .panel, .grid-3 > .panel { margin-bottom: 0; }
.grid-2, .grid-3 { margin-bottom: 1.2rem; }
.breadcrumbs { font-size: .86rem; color: var(--muted); margin-bottom: .7rem; }

/* Estadísticas (accesos rápidos) */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: .9rem; margin-bottom: 1.4rem; }
.stat { position: relative; display: flex; flex-direction: column; gap: .15rem; padding: 1.1rem 1.15rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); box-shadow: var(--shadow); transition: background .15s, color .15s, transform .15s; }
.stat:hover { text-decoration: none; background: var(--primary); border-color: var(--primary); color: #fff; transform: translateY(-2px); }
.stat:hover span { color: rgba(255, 255, 255, .85); }
.stat strong { font-size: 1.7rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.stat-warn { border-color: var(--accent); background: var(--accent-soft); }
.stat-warn strong { color: var(--accent); }

/* Formularios */
.form { display: flex; flex-direction: column; gap: .8rem; }
.form + .form { margin-top: .8rem; }
.form-row { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; flex-direction: row; }
.form-row .grow { flex: 1 1 240px; }
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; font-size: .88rem; }
label.check { flex-direction: row; align-items: center; gap: .45rem; font-weight: 400; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .5rem .75rem; min-height: 40px; transition: border-color .15s, box-shadow .15s, background .15s; }
input:hover, select:hover, textarea:hover { border-color: var(--border-hover); }
input[type="checkbox"], input[type="radio"] { min-height: auto; width: 1.05rem; height: 1.05rem; accent-color: var(--primary); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px var(--primary-soft); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.input-num { width: 90px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .7rem .9rem .9rem; margin: 0; }
legend { font-weight: 600; font-size: .88rem; padding: 0 .3rem; }
.lang-fields { display: flex; flex-direction: column; gap: .45rem; }
.lang-field { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; }
.lang-field { flex-wrap: wrap; }
.lang-field input, .lang-field textarea { flex: 1 1 140px; min-width: 0; }
.lang-field.is-inactive { opacity: .6; }
.lang-code { display: inline-block; min-width: 2.6rem; text-align: center; font-family: var(--mono); font-size: .8rem; padding: .15rem .35rem; border-radius: 6px; background: var(--primary-soft); color: var(--primary-strong); }
.checks { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }
.inline-form { display: inline; margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; margin-bottom: 1.2rem; padding: 1rem 1.1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.filters .filter-actions { display: flex; gap: .5rem; align-items: center; }
.filters > label { min-width: 0; max-width: 100%; }
.filters select { max-width: 100%; text-overflow: ellipsis; }
.page-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.form-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.result-count { margin: 0 0 .7rem; font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.nowrap { white-space: nowrap; }
.placement + .placement { margin-top: .2rem; }
.content-lang label { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600; font-size: .92rem; padding: .5rem 1.1rem; min-height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; align-self: flex-start; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { border-color: var(--primary); color: var(--primary-strong); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(31, 91, 214, .22); }
.btn-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); color: #fff; }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-small { padding: .25rem .7rem; min-height: 32px; font-size: .84rem; }
.btn-block { width: 100%; align-self: stretch; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: .95rem; }
.icon-btn:hover { border-color: var(--border); color: var(--primary); background: var(--surface-2); text-decoration: none; }
.icon-btn-lg { width: 38px; height: 38px; border-radius: 50%; }

/* Avisos y etiquetas */
.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid transparent; }
.alert-success { background: var(--ok-soft); border-color: var(--ok); }
.alert-error { background: var(--danger-soft); border-color: var(--danger); }
.alert-info { background: var(--info-soft); border-color: var(--info); }
.badge { display: inline-block; font-size: .72rem; font-weight: 600; line-height: 1.4; padding: .1rem .55rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); background: var(--surface-2); white-space: nowrap; vertical-align: middle; }
.badge-ok, .status-published { border-color: transparent; color: var(--ok); background: var(--ok-soft); }
.badge-warn, .status-pending_translation { border-color: transparent; color: var(--warn); background: var(--warn-soft); }
.badge-info, .status-in_review { border-color: transparent; color: var(--info); background: var(--info-soft); }
.status-draft { border-color: var(--border); }

/* Tablas y listas */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .8rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { padding-top: .2rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--primary-soft); }
.table tbody tr:last-child td { border-bottom: 0; }
.table-compact td { font-size: .86rem; padding: .45rem .55rem; }
.table td.details { max-width: 380px; word-break: break-word; font-family: var(--mono); font-size: .78rem; color: var(--muted); }
tr.is-archived td, .is-archived > .tree-row { opacity: .6; }
.card-list { list-style: none; margin: 0; padding: 0; }
.card-list li { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .7rem .5rem; border-bottom: 1px solid var(--border); border-radius: 8px; }
.card-list li:hover { background: var(--primary-soft); }
.card-list li:last-child { border-bottom: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0 0 1rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* Árbol del manual */
.tree { list-style: none; margin: 0; padding: 0; }
.tree .tree { padding-left: 1.6rem; border-left: 1px dashed var(--border); margin-left: .9rem; }
.tree-row { display: flex; align-items: center; gap: .45rem; padding: .4rem .5rem; border-radius: 8px; flex-wrap: wrap; }
.tree-row:hover { background: var(--primary-soft); }
.tree-num { min-width: 2.6rem; font-family: var(--mono); font-size: .82rem; color: var(--muted); }
.tree-title { flex: 0 1 auto; }
.tree-badges { display: inline-flex; gap: .3rem; flex-wrap: wrap; }
.tree-actions { margin-left: auto; display: inline-flex; gap: 2px; }
:target > .tree-row { background: var(--warn-soft); }
/* Botones «+ Sección» / «+ Documento» del árbol: siempre visibles en las secciones; en los documentos, al pasar por la fila */
.tree-actions { align-items: center; }
.tree-add > summary.btn { min-height: 28px; padding: .15rem .6rem .15rem .45rem; gap: .25rem; border-radius: 999px; font-size: .8rem; font-weight: 600; color: var(--primary-strong); background: var(--surface); border: 1px solid var(--border); }
.tree-add > summary.btn .icon { width: 15px; height: 15px; color: var(--primary); }
.tree-add > summary.btn::after { display: none; }
.tree-add > summary.btn:hover, .tree-add[open] > summary.btn { border-color: var(--primary); background: var(--primary-soft); }
.tree-add-form { min-width: 340px; gap: .6rem; padding: .4rem .8rem .9rem; cursor: auto; }
.tree-add-form .menu-group { padding-left: 0; }
.tree-node.is-doc > .tree-row .tree-add { visibility: hidden; }
.tree-node.is-doc > .tree-row:hover .tree-add, .tree-node.is-doc > .tree-row:focus-within .tree-add, .tree-node.is-doc > .tree-row .tree-add[open] { visibility: visible; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1rem; margin-bottom: 1rem; }
.panel-head > h2 { margin: 0; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.tree-root-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-size: .86rem; }
@media (hover: none) { .tree-node.is-doc > .tree-row .tree-add { visibility: visible; } }

/* Menú «⋯» del índice: desvincular, eliminar */
.tree-more > summary.icon-btn { list-style: none; justify-content: center; padding: 0; min-height: 0; border-radius: 8px; }
.tree-more > summary.icon-btn::after { display: none; }
.tree-more .menu-panel { min-width: 270px; }
.tree-more form { margin: 0; }
.menu-action { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .5rem .75rem; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.menu-action .icon { width: 18px; height: 18px; color: var(--muted); }
.menu-action:hover:not([disabled]) { background: var(--primary-soft); }
.menu-action.is-danger { color: var(--danger); }
.menu-action.is-danger .icon { color: var(--danger); }
.menu-action.is-danger:hover:not([disabled]) { background: var(--danger-soft); }
.menu-action[disabled] { opacity: .45; cursor: not-allowed; }
.badge-error { border-color: transparent; color: var(--danger); background: var(--danger-soft); }
a.badge-error { text-decoration: none; }
.badge .icon { width: 12px; height: 12px; vertical-align: -1px; }

/* Fallos reportados en documentos (D-59) */
.issue-list { list-style: none; margin: 0 0 .8rem; padding: 0; display: grid; gap: .6rem; }
.issue { padding: .6rem .8rem; border: 1px solid var(--border); border-left: 3px solid var(--danger); border-radius: var(--radius-sm); background: var(--surface); }
.issue.is-resolved { border-left-color: var(--ok); opacity: .85; }
.issue-note { margin: 0; white-space: normal; }
.issue-meta { margin: .25rem 0 0; font-size: .82rem; }
.issue-resolve { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.issue-resolve input { flex: 1 1 14rem; min-width: 0; }
.issue-report, .issue-history { margin-top: .6rem; }
.issue-report > summary, .issue-history > summary { cursor: pointer; font-weight: 600; }
.issues-alert .issue-list { margin: .6rem 0 0; }
.issue-docs { margin: .4rem 0 0; padding-left: 1.2rem; }
.issue-quick { display: grid; gap: .4rem; padding: .5rem .75rem .6rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem !important; }
.issue-quick .menu-label { display: grid; gap: .3rem; font-weight: 600; }
.issue-quick-t { display: flex; align-items: center; gap: .45rem; }
.issue-quick .menu-label .icon { width: 16px; height: 16px; color: var(--danger); }
.issue-quick textarea { width: 100%; font: inherit; }
.issue-quick .btn { justify-self: start; }
.menu-hint { margin: .3rem .75rem .2rem; font-size: .8rem; color: var(--muted); white-space: normal; }

/* Contenido de un documento desplegado en el índice del manual */
.tree-expand { width: 26px; height: 26px; flex-shrink: 0; }
.tree-expand .icon { width: 16px; height: 16px; transition: transform .15s; }
.tree-expand[aria-expanded="true"] { color: var(--primary); background: var(--primary-soft); }
.tree-expand[aria-expanded="true"] .icon { transform: rotate(90deg); }
.tree-expand-spacer { display: none; width: 26px; flex-shrink: 0; }
.has-js .tree-expand-spacer { display: inline-block; }
.tree-preview { margin: .3rem .5rem .8rem 2.4rem; padding: 1rem 1.3rem 1.2rem; max-height: 70vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: var(--radius-sm); box-shadow: var(--shadow); color: var(--muted); }
.tree-preview .doc-content { color: var(--text); max-width: 860px; }
.tree-preview-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .9rem; padding-bottom: .7rem; border-bottom: 1px solid var(--border); font-size: .86rem; }
.tree-preview-links { margin-left: auto; display: inline-flex; gap: .4rem; }
@media (max-width: 760px) { .tree-preview { margin-left: 0; margin-right: 0; padding: .8rem; } }

/* Vista del contenido en la ficha del documento */
.preview-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.lang-pills { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); }
.lang-pills a { padding: .15rem .6rem; border-radius: 999px; font-family: var(--mono); font-size: .78rem; text-transform: uppercase; color: var(--muted); }
.lang-pills a:hover { color: var(--primary); text-decoration: none; }
.lang-pills a[aria-current] { background: var(--primary); color: #fff; }
.preview-body { max-width: 860px; padding-top: .4rem; }
/* «Mostrar todo el contenido» en el panel */
.admin-all { max-width: 980px; padding: 1.4rem 2.2rem 2.4rem; }
.admin-all > .all-node:first-child > .all-title { margin-top: .4rem; padding-top: 0; border-top: 0; }
.admin-all .all-open { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
@media (max-width: 760px) { .admin-all { padding: 1rem 1.1rem 1.6rem; } }
.preview-title { font-size: 1.7rem; margin: 0 0 1.2rem; padding-bottom: .9rem; border-bottom: 1px solid var(--border); }

/* Versiones lingüísticas */
.version-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .9rem 1rem; margin-bottom: .8rem; background: var(--surface-2); }
.version-card header { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.version-card header .muted { margin-left: auto; font-size: .82rem; }

pre.debug { white-space: pre-wrap; font-size: .75rem; background: var(--bg); padding: 1rem; overflow: auto; }

/* ----- Pantallas de acceso (login y recuperación) ----- */
.auth-body { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 2rem 1rem; background: radial-gradient(circle at 15% 10%, #f47921 0, transparent 45%), var(--bg); }
.auth-wrap { width: 100%; max-width: 1040px; }
.auth-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 600px; background: var(--surface); border-radius: 22px; overflow: hidden; box-shadow: 0 24px 60px rgba(23, 42, 87, .14); }
.auth-form { display: flex; flex-direction: column; justify-content: center; padding: 3rem clamp(1.5rem, 6vw, 4.5rem); }
.auth-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 2.4rem; }
.auth-logo img { display: block; height: 47px; width: auto; background: var(--logo-bg); padding: var(--logo-pad); border-radius: 8px; }
.auth-title { font-size: 1.85rem; color: var(--text); margin-bottom: .35rem; }
.auth-subtitle { color: var(--muted); margin: 0 0 1.8rem; }
.auth-fields { gap: 1rem; }
.field-icon { position: relative; display: block; }
.field-icon > .icon { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.field-icon input { width: 100%; min-height: 48px; padding-left: 2.8rem; }
.field-icon .reveal { position: absolute; right: .45rem; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.field-icon .reveal:hover, .field-icon .reveal[aria-pressed="true"] { color: var(--primary); background: var(--primary-soft); }
.field-icon:has(.reveal) input { padding-right: 3rem; }
.auth-row { display: flex; justify-content: flex-end; margin: -.2rem 0 .4rem; font-size: .88rem; font-weight: 500; }
.auth-fields .btn-block { min-height: 48px; font-size: 1rem; }
.auth-foot { margin: 1.6rem 0 0; text-align: center; font-size: .9rem; }
.auth-aside { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; padding: 3rem 2.5rem; text-align: center; color: #fff; background: linear-gradient(160deg, var(--hero-end) 0%, var(--hero-start) 55%, var(--sidebar) 100%); }
.auth-illustration { width: min(100%, 360px); height: auto; margin-bottom: 1.6rem; }
.auth-claim { margin: 0; max-width: 24ch; font-size: 1.3rem; font-weight: 700; text-wrap: balance; }
.auth-claim-text { margin: 0; max-width: 32ch; color: rgba(255, 255, 255, .82); }

/* Móvil */
@media (max-width: 900px) {
  .grid-3 { grid-template-columns: 1fr; }
  .auth-card { grid-template-columns: 1fr; min-height: 0; }
  .auth-aside { display: none; }
}
@media (max-width: 760px) {
  :root { --topbar-h: 56px; }
  .nav-toggle { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer; }
  .sidebar { display: none; position: fixed; top: var(--topbar-h); left: 0; bottom: 0; height: auto; z-index: 15; box-shadow: 4px 0 20px rgba(0, 0, 0, .2); }
  .sidebar.is-open { display: flex; }
  .main { padding: 1.1rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .user-name, .brand-name { display: none; }
  .topbar { gap: .5rem; padding: 0 .75rem; }
  .brand-logo { height: 26px; }
  .topbar-right { gap: .4rem; }
  .tree .tree { padding-left: .8rem; margin-left: .4rem; }
  .tree-actions { margin-left: 0; }
  .auth-form { padding: 2rem 1.4rem; }
  .auth-top { margin-bottom: 1.6rem; }
}

/* ----- Editor visual (fase 3) ----- */
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.1rem; }
.editor-layout.with-source { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.editor-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
.input-title { font-size: 1.15rem; font-weight: 600; }
.editor { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.editor:focus-within { border-color: var(--primary); }
.editor-toolbar { position: sticky; top: var(--topbar-h); z-index: 5; display: flex; flex-wrap: wrap; gap: 2px; align-items: center; padding: .35rem; border-bottom: 1px solid var(--border); background: var(--bg); border-radius: 8px 8px 0 0; }
.tb-btn { min-width: 32px; height: 32px; padding: 0 .4rem; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--text); font: inherit; font-size: .88rem; cursor: pointer; }
.tb-btn:hover { border-color: var(--border); background: var(--surface); }
.tb-btn[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary-strong); border-color: var(--primary); }
.tb-btn:disabled { opacity: .35; cursor: default; }
.tb-bold { font-weight: 800; }
.tb-italic { font-style: italic; font-family: Georgia, serif; }
.tb-text { padding: 0 .7rem; font-weight: 600; }
.tb-select { min-height: 32px; padding: .15rem .4rem; font-size: .86rem; }
.tb-sep { width: 1px; height: 22px; background: var(--border); margin: 0 .25rem; }
.editor-surface, .editor-preview { padding: 1rem 1.2rem; min-height: 420px; }
.editor-surface .ProseMirror { outline: none; min-height: 400px; }
.editor-surface .ProseMirror p.is-editor-empty:first-child::before { content: attr(data-placeholder); color: var(--muted); float: left; height: 0; pointer-events: none; }
.editor-surface .ProseMirror .selectedCell { background: var(--primary-soft); }
.editor-surface .ProseMirror-gapcursor { display: none; pointer-events: none; position: absolute; }
.editor-surface .ProseMirror-gapcursor:after { content: ""; display: block; position: absolute; top: -2px; width: 20px; border-top: 1px solid var(--text); }
.editor-surface .ProseMirror-focused .ProseMirror-gapcursor { display: block; }
.editor-surface .ProseMirror table { table-layout: fixed; }
.editor-preview { background: var(--bg); }
.editor-status { padding: .35rem .8rem; font-size: .84rem; color: var(--muted); border-top: 1px solid var(--border); min-height: 1.9rem; }
.editor-fallback { width: 100%; font-family: var(--mono); font-size: .86rem; }
/* Editor compacto (resumen de un vídeo): sin encabezados, imágenes, adjuntos, vídeos ni vista previa. */
.field { display: flex; flex-direction: column; gap: .3rem; }
.field > .hint { margin: 0; }
.editor[data-compact] .tb-block, .editor[data-compact] .tb-upload, .editor[data-compact] .tb-media, .editor[data-compact] .tb-text { display: none; }
.editor[data-compact] .editor-toolbar { position: static; }
.editor[data-compact] .editor-surface { min-height: 150px; }
.editor[data-compact] .editor-surface .ProseMirror { min-height: 130px; }
.editor[data-compact] .editor-status { display: none; }
.editor-tall .editor-surface { min-height: 260px; }
.editor-tall .editor-surface .ProseMirror { min-height: 240px; }
.media-summary-view { font-size: .95rem; }
/* Iconos de vídeo y resumen en el índice del manual */
.tree-media { display: inline-flex; align-items: center; gap: .1rem; }
.tree-media .icon { width: 17px; height: 17px; }
.tree-media .media-has { color: var(--primary); width: 26px; height: 26px; }
.tree-media .summary-ok { color: var(--ok); }
.tree-media .summary-missing { color: var(--warn); }
.source-panel { position: sticky; top: calc(var(--topbar-h) + 10px); align-self: start; max-height: calc(100vh - var(--topbar-h) - 30px); overflow-y: auto; margin: 0; }
.version-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: .7rem; }
.inline-check { display: inline-flex; font-size: .8rem; margin-right: .3rem; }
@media (max-width: 900px) { .editor-layout.with-source { grid-template-columns: 1fr; } .source-panel { position: static; max-height: none; } }

/* ----- Vídeos y enlaces (fase 5) ----- */
.copy-row { display: flex; gap: .5rem; align-items: center; margin-bottom: .6rem; }
.copy-input { flex: 1; min-width: 0; font-family: var(--mono); font-size: .92rem; }
.break { word-break: break-all; }
.card-list.compact li { padding: .3rem 0; font-size: .88rem; }
.policy-choice label.check { align-items: flex-start; }
.policy-choice label.check input { margin-top: .25rem; }
.transcript-text { line-height: 1.7; max-height: 70vh; overflow-y: auto; }
.transcript-raw { white-space: pre-wrap; word-break: break-word; font-size: .82rem; max-height: 70vh; overflow-y: auto; background: var(--bg); padding: .8rem; border-radius: 6px; }
.links-table .url-cell { max-width: 260px; }
.actions-cell { white-space: nowrap; }
.link-status { text-align: center; }
.status-danger { border-color: var(--danger) !important; color: var(--danger) !important; background: var(--danger-soft) !important; }
