/* ============================================================
   Bataller Contenidos - Cloud
   Sistema de diseno unico oscuro/bordo. Ver cloud/DESIGN.md.
   ============================================================ */

/* 1. Tokens ---------------------------------------------------- */
:root {
    --bg:        #1a1a1a;
    --surface:   #242526;
    --border:    #383838;
    --row-hover: #2d2e2f;
    --primary:   #9d2050;
    --primary-h: #7a1840;
    --danger:    #e62a2a;
    --success:   #22c55e;
    --warn:      #f59e0b;
    --info:      #3b82f6;
    --purple:    #8b5cf6;
    --text:      #f0f0f0;
    --muted:     #9ca0a4;
    --radius:    10px;
    --shadow:    0 1px 4px rgba(0,0,0,.45);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.65);
}

/* Tema claro: solo sobreescribe la zona de contenido (cards/modales/tabla).
 * El chrome (sidebar + topbar) sigue en bordo institucional — es la marca. */
:root[data-theme="light"] {
    --bg:        #f4f5f7;
    --surface:   #ffffff;
    --border:    #e2e4e8;
    --row-hover: #f0f1f4;
    --text:      #1a1a1a;
    --muted:     #5b6470;
    --shadow:    0 1px 4px rgba(0,0,0,.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.16);
}

/* 2. Reset & base --------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* 3. Layout principal ---------------------------------------- */
.layout  { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--primary);
           border-right: 1px solid rgba(0,0,0,.25);
           display: flex; flex-direction: column; flex-shrink: 0; }
.main    { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar  { background: var(--primary);
           border-bottom: 1px solid rgba(0,0,0,.25);
           padding: 0 24px; height: 60px;
           display: flex; align-items: center; justify-content: space-between;
           box-shadow: var(--shadow); }
.content { flex: 1; padding: 24px; overflow-y: auto; }

/* 4. Sidebar -------------------------------------------------- */
.sidebar-logo       { height: 60px; padding: 0 20px;
                      border-bottom: 1px solid rgba(0,0,0,.2);
                      display: flex; align-items: center; justify-content: center;
                      flex-shrink: 0; }
.sidebar-logo-mark  { display: block; width: auto; height: 35px;
                      max-width: 100%; object-fit: contain; }
.sidebar-logo-text  { color: #fff; font-weight: 700; font-size: .95rem;
                      letter-spacing: .04em; text-transform: uppercase; }

.sidebar-nav        { padding: 8px 0 12px; flex: 1; overflow-y: auto; }
.sidebar-footer     { padding: 10px 20px; font-size: .72rem;
                      color: rgba(255,255,255,.7);
                      border-top: 1px solid rgba(0,0,0,.2);
                      text-align: center; letter-spacing: .03em;
                      font-family: monospace; }

.nav-item { display: flex; align-items: center; gap: 10px;
            padding: 10px 20px; font-size: .9rem;
            color: rgba(255,255,255,.85); cursor: pointer;
            border-left: 3px solid transparent;
            transition: background .15s, color .15s;
            text-decoration: none; width: 100%; background: none; border-top: none; border-right: none; border-bottom: none;
            text-align: left; font-family: inherit; }
.nav-item:hover  { background: rgba(0,0,0,.18); color: #fff; }
.nav-item.active { background: rgba(0,0,0,.28); color: #fff;
                   border-left-color: #fff; font-weight: 600; }
.nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }

/* Grupos colapsables del sidebar — ver DESIGN.md §4 */
.nav-group-wrap                       { display: block; }
.nav-group-toggle                     { width: 100%; background: none; border: none;
                                        text-align: left; cursor: pointer;
                                        font-family: inherit; color: rgba(255,255,255,.85); }
.nav-group-label                      { flex: 1; }
.nav-group-arrow                      { margin-left: auto; font-size: 1rem; font-weight: 700;
                                        line-height: 1; color: rgba(255,255,255,.7);
                                        transition: transform .2s; }
.nav-group-wrap.open .nav-group-arrow { transform: rotate(45deg); }
.nav-sub                              { display: none; background: rgba(0,0,0,.18);
                                        border-top: 1px solid rgba(0,0,0,.2);
                                        border-bottom: 1px solid rgba(0,0,0,.2); }
.nav-group-wrap.open .nav-sub         { display: block; }
.nav-sub-item                         { padding-left: 44px; font-size: .85rem; }
.nav-sub-item.active                  { background: rgba(0,0,0,.32); }

/* 5. Topbar --------------------------------------------------- */
.topbar-title    { font-size: 1rem; font-weight: 600; flex: 1; color: #fff; }

.topbar-user     { display: flex; align-items: center; gap: 10px;
                   flex-shrink: 0; position: relative; }
.topbar-username { background: none; border: none; cursor: pointer;
                   font-size: .85rem; color: rgba(255,255,255,.9);
                   display: flex; align-items: center; gap: 6px;
                   padding: 6px 10px; border-radius: 8px;
                   transition: background .15s, color .15s;
                   font-family: inherit; }
.topbar-username:hover { background: rgba(0,0,0,.18); color: #fff; }
.topbar .hamburger     { display: none; background: none; border: none;
                         cursor: pointer; font-size: 1.4rem; color: #fff;
                         padding: 4px 8px; margin-right: 8px; line-height: 1; }

.user-dropdown   { display: none; position: absolute; right: 0;
                   top: calc(100% + 6px); background: var(--surface);
                   border: 1px solid var(--border); border-radius: 10px;
                   box-shadow: var(--shadow-lg);
                   min-width: 180px; overflow: hidden; z-index: 200; }
.user-dropdown.open { display: block; }
.user-dropdown-item { display: flex; align-items: center; gap: 10px;
                      padding: 10px 14px; width: 100%; background: none;
                      border: none; cursor: pointer; color: var(--text);
                      font-size: .85rem; font-family: inherit; text-align: left;
                      transition: background .15s, color .15s; }
.user-dropdown-item:hover { background: var(--bg); color: var(--primary); }

/* 6. Botones -------------------------------------------------- */
.btn { padding: 8px 16px; border-radius: var(--radius); border: none;
       font-size: .88rem; font-weight: 600; cursor: pointer;
       display: inline-flex; align-items: center; justify-content: center;
       gap: 6px; transition: background .15s, transform .1s;
       font-family: inherit; }
.btn:active        { transform: scale(.97); }
.btn-primary       { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-danger        { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #c91515; }
.btn-secondary     { background: var(--surface); color: var(--text);
                     border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-ghost         { background: transparent; color: var(--muted);
                     border: 1px solid var(--border); }
.btn-ghost:hover   { background: var(--bg); color: var(--text); }
.btn-sm            { padding: 5px 12px; font-size: .8rem; }
.btn-icon-sm       { background: none; border: none; cursor: pointer;
                     padding: 4px 8px; border-radius: 6px; font-size: .85rem;
                     color: var(--muted); font-family: inherit; }
.btn-icon-sm:hover { background: var(--bg); color: var(--text); }
/* Boton solo-icono de la toolbar de un listado (Filtros, Refrescar — ver la
   skill abm_design): mismo alto que el resto de la toolbar, sin texto. */
.btn-icon          { position: relative; padding: 8px 11px; line-height: 1; }
.btn-icon.active   { border-color: var(--primary); color: var(--primary); }

/* 7. Inputs --------------------------------------------------- */
input[type=text], input[type=number], input[type=url], input[type=tel],
input[type=email], input[type=date], input[type=time], input[type=datetime-local],
input[type=password], input[type=search], select, textarea {
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 8px 12px; font-size: .88rem; background: var(--surface);
    color: var(--text); outline: none; transition: border .15s;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(157,32,80,.25);
}
input:disabled, select:disabled, textarea:disabled,
input[readonly], textarea[readonly] {
    color: var(--muted); background: var(--bg);
    cursor: not-allowed; opacity: .75;
}
textarea { resize: vertical; min-height: 60px; }

.field-error   { margin-top: 4px; font-size: .78rem; color: var(--danger); }
.input-invalid { border-color: var(--danger) !important;
                 box-shadow: 0 0 0 2px rgba(239,68,68,.18); }

/* 8. Formularios --------------------------------------------- */
.form-row    { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3  { grid-template-columns: repeat(3, 1fr); }
.form-row-4  { grid-template-columns: repeat(4, 1fr); }
.form-row-5  { grid-template-columns: repeat(5, 1fr); }
.form-group  { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: .8rem; font-weight: 600; color: var(--muted); }
.form-group input,
.form-group select,
.form-group textarea { width: 100%; }
.form-group--toggle { flex-direction: row; align-items: center; justify-content: space-between; }
.form-group--toggle label:first-child { margin: 0; }

/* Textarea monoespaciado para blobs crudos (JSON, SQL). Ver DESIGN.md §26.
   Hereda los tokens normales de textarea (§7): solo cambia tipografia, alto
   y white-space (sin word-wrap, con scroll horizontal). Va siempre dentro
   de un .modal-wide. */
.json-editor {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .82rem;
    line-height: 1.5;
    min-height: 360px;
    max-height: 60vh;
    white-space: pre;
    overflow: auto;
    tab-size: 2;
}

.form-row { display: flex; flex-wrap: wrap; gap: 12px; }
.form-col { flex: 1; min-width: 200px; }
/* El ancho declarado descuenta su parte del gap (12px repartido entre las dos
   columnas): con 0 0 75% + 0 0 25% la suma pasa el 100% de la fila y el
   flex-wrap manda la segunda columna abajo, apilando los campos. */
.form-col--75 { flex: 0 0 calc(75% - 6px); min-width: 0; }
.form-col--25 { flex: 0 0 calc(25% - 6px); min-width: 0; }
.form-col--50 { flex: 0 0 calc(50% - 6px); min-width: 0; }
.form-row--switches { margin-top: 10px; }

/* ---- Ayuda de un campo: question-circle con globito -------------------
   La UNICA forma de explicar un campo en todo el panel (skill abm_design):
   icono a la DERECHA del rotulo y el texto en un globito al pasar el mouse.
   Nunca una nota suelta debajo del control: los campos van de a dos por
   renglon y una nota de tres lineas desalinea su mitad de la fila.
   Se arma con ayudaDeCampo() en app.js; nadie escribe el <span> a mano. */
.field-help {
    /* El ancla del globito NO es el icono: es la COLUMNA (.form-group, abajo).
       Anclado al icono, el globito de la ultima columna —que se alinea a la
       derecha para no pasarse del modal— se sale por la IZQUIERDA, porque el
       icono esta pegado al rotulo y no al borde de su columna. Pasa de verdad:
       el campo "Hasta" en un modal de 520px. */
    display: inline-flex; align-items: center; vertical-align: middle;
    margin-left: 5px;
    color: var(--muted); cursor: help;
    transition: color .15s;
}
/* Solo las columnas que REALMENTE tienen ayuda: volver posicionado a todo
   .form-group lo convertiria en bloque contenedor de cualquier descendiente
   absoluto del panel. */
.form-group:has(.field-help) { position: relative; }
/* El :has() acota el display:flex a los labels que REALMENTE tienen ayuda:
   `.form-group label` tambien lo usan los toggles y los campos sin globito,
   y volverlos flex a todos cambia como se acomoda su contenido. El gap
   reemplaza al margin-left de arriba, que sumado daria 10px. */
.form-group label:has(.field-help) { display: flex; align-items: center; gap: 5px; }
.form-group label .field-help      { margin-left: 0; }
.field-help:hover, .field-help:focus-visible { color: var(--text); outline: none; }
.field-help i { font-size: .85rem; }

.field-help-tip {
    /* Abre HACIA ABAJO: el .modal-body scrollea y un globito que sube por
       encima del primer renglon queda recortado contra el borde del modal.
       El 100% es el alto de la COLUMNA, asi que cae debajo del campo entero
       y nunca tapa su propio control. */
    position: absolute; top: 100%; margin-top: 6px; left: 0; z-index: 20;
    width: max-content; max-width: 280px;
    padding: 9px 11px;
    background: var(--bg); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    /* Hereda del <label>, que va en 600 y en --muted: sin esto se lee como
       otro rotulo y no como una explicacion. */
    font-size: .78rem; font-weight: 400; line-height: 1.5;
    text-transform: none; letter-spacing: normal; white-space: normal;
    /* `display: none` y NO `visibility: hidden`. Un globito meramente
       invisible sigue contando para el area scrolleable del .modal-body, y
       el del ULTIMO campo le cuelga ~80px por abajo: el modal sale con barra
       de scroll y recortado aunque el formulario entre entero. Pasa de
       verdad — se vio en "Nuevo programa" de Streaming.
       El fade se conserva con allow-discrete + @starting-style; donde no
       esten soportados el globito aparece de golpe, que es una degradacion
       aceptable para una ayuda. */
    display: none;
    opacity: 0;
    transition: opacity .12s ease, display .12s allow-discrete;
    /* Sin esto, el globito que cae sobre el campo de abajo se come sus clicks. */
    pointer-events: none;
}
.field-help:hover .field-help-tip,
.field-help:focus-visible .field-help-tip { display: block; opacity: 1; }
@starting-style {
    .field-help:hover .field-help-tip,
    .field-help:focus-visible .field-help-tip { opacity: 0; }
}

/* En la ULTIMA COLUMNA se ancla al borde derecho DE LA COLUMNA: anclado a la
   izquierda mide hasta 280px, se sale del modal y le saca barra horizontal. */
.form-row > *:last-child .field-help-tip { left: auto; right: 0; }

/* 10. Tablas -------------------------------------------------- */
.table-card { background: var(--surface); border: 1px solid var(--border);
              border-radius: var(--radius); box-shadow: var(--shadow);
              overflow-x: auto; overflow-y: hidden; }

table       { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead tr    { background: var(--bg); }
th          { padding: 10px 14px; text-align: left;
              font-size: .75rem; text-transform: uppercase; letter-spacing: .05em;
              color: var(--muted); font-weight: 600;
              border-bottom: 1px solid var(--border); white-space: nowrap; }
td          { padding: 10px 14px; border-bottom: 1px solid var(--border);
              vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--row-hover); }

.td-id      { color: var(--muted); font-size: .8rem; }
.td-nombre  { font-weight: 600; }
.table-empty { text-align: center; padding: 48px 24px; color: var(--muted); }

.actions    { display: flex; gap: 4px; }
.action-ico { background: none; border: none; cursor: pointer;
              padding: 6px 8px; border-radius: 6px; font-size: .95rem;
              color: var(--muted); transition: background .15s, color .15s; }
.action-ico:hover         { background: var(--bg); color: var(--text); }
.action-ico.danger:hover  { color: var(--danger); }
.action-ico:disabled,
.action-ico[aria-disabled="true"] { opacity: .35; cursor: not-allowed; }

/* Columna de acciones (ABM): una columna por icono, angosta y centrada.
   Ver DESIGN.md §24. */
th.action-col, td.action-col { width: 1%; white-space: nowrap; text-align: center;
                               padding-left: 4px; padding-right: 4px; }

/* Filas clickeables del listado ABM: el click izquierdo abre Consultar. */
tbody tr.row-clickable { cursor: pointer; }

/* Menu contextual de fila / footer de modal Consultar (skill abm_design).
   Se posiciona via JS con position:fixed y se abre por:
   - click en el boton hamburguesa de la columna Acciones,
   - click derecho sobre la fila,
   - boton hamburguesa del footer del modal Consultar. */
.ctx-menu { position: fixed; z-index: 300;
            background: var(--surface); border: 1px solid var(--border);
            border-radius: 10px; box-shadow: var(--shadow-lg);
            padding: 6px; min-width: 180px;
            display: none; flex-direction: column; gap: 2px; }
.ctx-menu.open { display: flex; }
.ctx-menu button { background: none; border: none; cursor: pointer;
                   display: flex; align-items: center; gap: 10px;
                   padding: 8px 12px; border-radius: 6px;
                   color: var(--text); font-size: .85rem;
                   font-family: inherit; text-align: left;
                   transition: background .15s, color .15s; }
.ctx-menu button > i { width: 16px; text-align: center; color: var(--muted); }
.ctx-menu button:hover         { background: var(--bg); }
.ctx-menu button:hover > i     { color: var(--text); }
.ctx-menu .ctx-menu-sep        { height: 1px; background: var(--border);
                                 margin: 4px 2px; }
.ctx-menu .ctx-menu-danger        { color: var(--danger); }
.ctx-menu .ctx-menu-danger > i    { color: var(--danger); }
.ctx-menu .ctx-menu-danger:hover  { background: rgba(230,42,42,.12); }

/* 9. Toolbar (busqueda + acciones del listado) --------------- */
.toolbar       { display: flex; align-items: center; gap: 12px;
                 flex-wrap: wrap; margin-bottom: 20px; }
.toolbar-left  { display: flex; align-items: center; gap: 10px;
                 flex: 1; flex-wrap: wrap; }
.toolbar-right { display: flex; gap: 10px; }

.search-wrap        { position: relative; display: inline-flex; align-items: center; }
.search-wrap .search-input { width: 240px; padding-right: 28px; }
.search-clear       { position: absolute; right: 6px; background: none; border: none;
                      cursor: pointer; color: var(--muted); font-size: 1.1rem;
                      padding: 2px 4px; border-radius: 50%;
                      transition: color .15s; font-family: inherit; }
.search-clear:hover { color: var(--text); }

/* Chip de filtro (utilitario suelto, ver DESIGN.md §9). NO se usa en los
   listados ABM — ahi los filtros van en el modal de Filtros (§23-bis). Queda
   para las herramientas que filtran por categoria en la propia toolbar
   (Visor de sucesos). Seleccion exclusiva: un solo chip .active a la vez. */
.filter-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 12px; border-radius: 999px;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--muted); font-size: .8rem; font-weight: 600;
    cursor: pointer; font-family: inherit; white-space: nowrap;
    transition: background .15s, color .15s, border-color .15s;
}
.filter-chip:hover   { background: var(--bg); color: var(--text); }
.filter-chip.active  { background: var(--primary); border-color: var(--primary);
                       color: #fff; }

/* 14. Modales ------------------------------------------------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45);
                  display: flex; align-items: center; justify-content: center;
                  z-index: 100; opacity: 0; pointer-events: none;
                  transition: opacity .2s; }
.modal-backdrop.open { opacity: 1; pointer-events: all; }
.modal          { background: var(--surface); border-radius: 14px;
                  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
                  box-shadow: var(--shadow-lg);
                  transform: scale(.96) translateY(12px);
                  transition: transform .2s; margin: 16px; }
.modal-backdrop.open .modal { transform: scale(1) translateY(0); }
.modal-header   { padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
                  display: flex; align-items: center; justify-content: space-between; }
.modal-title    { font-size: 1rem; font-weight: 700;
                  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.modal-subtitle { font-size: .8rem; font-weight: 500; color: var(--muted); }
.modal-body     { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer   { padding: 16px 24px; border-top: 1px solid var(--border);
                  display: flex; gap: 10px; justify-content: flex-end; }
.modal.modal-wide { max-width: 760px; }
.modal.modal-imagen-marca { max-width: 820px; }
/* Variante extra ancha: 100% mas ancha que .modal-wide, capada al viewport
   para no desbordar en pantallas chicas. Pensada para el modal Consultar de
   ABM, donde las tarjetas read-only necesitan respirar a lo ancho. */
.modal.modal-xl   { max-width: min(1520px, 95vw); }

/* ---- Estandar de modales: titulo en primary + barra de acciones --------
   Barra de titulo pintada en --primary y mas baja, todos los botones en una
   barra propia debajo del titulo, y sin footer.

   .modal-std es el opt-in del scroll interno: el resto del panel todavia
   usa el modal viejo, que scrollea entero (.modal tiene max-height +
   overflow-y). Cambiar eso en .modal a secas relaya todos los modales que
   ya existen de una sola vez, que es un cambio mas grande que el que vino a
   hacer este modulo. Los modales que se vayan migrando suman la clase. */
.modal.modal-std      { overflow: hidden; display: flex; flex-direction: column; }
.modal-std .modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.modal-std .modal-header,
.modal-std .modal-menubar,
.modal-std .modal-footer { flex: 0 0 auto; }

/* Va JUNTO a .modal-header, no en su lugar. El radio superior tiene que
   coincidir con el de .modal (14px). */
.modal-header-primary {
    background: var(--primary);
    color: #fff;
    border-bottom: none;
    border-radius: 14px 14px 0 0;
    padding: 10px 24px;
}
.modal-header-primary .modal-title       { color: #fff; }
.modal-header-primary .modal-subtitle    { color: rgba(255,255,255,.75); }
.modal-header-primary .btn-icon-sm,
.modal-header-primary .btn-ghost         { color: #fff; }
.modal-header-primary .btn-icon-sm:hover { background: rgba(255,255,255,.18); color: #fff; }

/* Barra de acciones, pegada debajo del titulo. 14px y no los 10 del titulo:
   aca hay botones de ~30px y con 10 quedan tocando el primary de arriba y la
   divisoria de abajo. */
.modal-menubar {
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    /* Un escalon mas oscuro que el cuerpo: gris intermedio entre los dos
       tokens que ya conviven en el modal. La mezcla es ENTRE TOKENS, no
       contra #000, asi el tono sigue solo al tema. */
    background: color-mix(in srgb, var(--surface) 40%, var(--bg));
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
/* La barra normaliza el tamano sola: ningun call site se olvida el btn-sm. */
.modal-menubar .btn { white-space: nowrap; padding: 5px 12px; font-size: .8rem; }
/* La salida va RELLENA con el gris del cuerpo, no transparente: sobre la
   franja mas oscura un ghost sin fondo se lee como un hueco. */
.modal-menubar .btn-ghost       { background: var(--surface); color: var(--text); }
.modal-menubar .btn-ghost:hover { background: var(--row-hover); color: var(--text); }
.modal-menubar-end  { margin-left: auto; }
.menubar-caret      { font-size: .7em; opacity: .65; margin-left: 2px; }

/* ---- Transcripcion de una conversacion del asistente -------------------
   Reproduce la charla tal como la vio el visitante: su pregunta a la
   derecha, la respuesta del asistente a la izquierda. */
.conv-hilo {
    display: flex; flex-direction: column; gap: 14px;
    padding: 4px;
}
.conv-msg {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: .88rem; line-height: 1.55;
    overflow-wrap: anywhere;
}
.conv-msg p { margin: 0 0 .5em; }
.conv-msg p:last-child { margin-bottom: 0; }
.conv-msg.is-usuario {
    align-self: flex-end;
    background: var(--primary); color: #fff;
    border-bottom-right-radius: 4px;
}
.conv-msg.is-asistente {
    align-self: flex-start;
    background: color-mix(in srgb, var(--surface) 90%, #000);
    border-bottom-left-radius: 4px;
}
.conv-msg-meta {
    display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
    font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
    opacity: .7; margin-bottom: 6px;
}
.conv-msg.is-usuario .conv-msg-meta { color: rgba(255,255,255,.85); }
.conv-msg.is-asistente .conv-msg-meta { color: var(--muted); }
/* La pagina desde la que se pregunto es una URL, no un rotulo: el
   uppercase del meta la deformaria (/ARTICULO?ID=324886). */
.conv-msg-ctx {
    text-transform: none; letter-spacing: normal;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .95em;
}
.conv-fuentes {
    margin-top: 10px; padding-top: 8px;
    border-top: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 4px;
    font-size: .8rem;
}
.conv-fuentes a { color: var(--info); }
.conv-fuentes a:hover { text-decoration: underline; }
/* Que busco el asistente para responder. Es auditoria, no conversacion:
   va mas chico y apagado para que no compita con el texto. */
.conv-tools {
    margin-top: 8px;
    display: flex; flex-wrap: wrap; gap: 5px;
}
.conv-tool {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .68rem;
    padding: 2px 7px; border-radius: 999px;
    background: var(--bg); color: var(--muted);
    border: 1px solid var(--border);
}

/* Editor HTML minimo (WYSIWYG vanilla, sin frameworks).
   Toolbar + contenteditable + alternancia a vista source. */
.html-editor          { border: 1px solid var(--border); border-radius: var(--radius);
                        background: var(--surface); display: flex; flex-direction: column;
                        overflow: hidden; }
.html-editor-toolbar  { display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
                        padding: 6px 8px; background: var(--bg);
                        border-bottom: 1px solid var(--border); }
.html-editor-toolbar button { background: none; border: none; cursor: pointer;
                              padding: 6px 9px; min-width: 32px; border-radius: 6px;
                              color: var(--muted); font-size: .85rem;
                              font-family: inherit; line-height: 1;
                              transition: background .15s, color .15s; }
.html-editor-toolbar button b,
.html-editor-toolbar button i,
.html-editor-toolbar button u { font-style: normal; }
.html-editor-toolbar button:hover  { background: var(--surface); color: var(--text); }
.html-editor-toolbar button.active { background: var(--surface); color: var(--primary); }
.html-editor-toolbar .sep { width: 1px; height: 18px; background: var(--border);
                            margin: 0 4px; display: inline-block; }

.html-editor-view     { padding: 12px 14px; min-height: 260px; max-height: 55vh;
                        overflow-y: auto; background: #fff; color: #1a1a1a;
                        font-size: .95rem; line-height: 1.55; outline: none; }
.html-editor-view:focus { box-shadow: inset 0 0 0 2px rgba(157,32,80,.28); }
.html-editor-view blockquote { color: #555; }
.html-editor-view p           { margin: 0 0 .8em; }
.html-editor-view h2          { font-size: 1.15rem; margin: .6em 0 .4em; font-weight: 700; }
.html-editor-view h3          { font-size: 1.05rem; margin: .5em 0 .3em; font-weight: 700; }
.html-editor-view ul,
.html-editor-view ol          { padding-left: 1.4em; margin: 0 0 .8em; }
.html-editor-view blockquote  { margin: 0 0 .8em; padding: 6px 12px;
                                border-left: 3px solid var(--primary);
                                color: var(--muted); }
.html-editor-view a           { color: var(--primary); text-decoration: underline; }

.html-editor-source   { width: 100%; min-height: 260px; max-height: 55vh;
                        border: none; border-radius: 0; resize: vertical;
                        background: #fff; color: #1a1a1a;
                        font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
                        font-size: .82rem; line-height: 1.5; padding: 12px 14px; }
.html-editor-source:focus { box-shadow: inset 0 0 0 2px rgba(157,32,80,.28); }

/* Modo pantalla completa del editor HTML. El wrap se mueve a document.body
   al activarse (ver buildHtmlEditor) para escapar del transform del .modal. */
.html-editor.fullscreen {
    position: fixed; inset: 0; z-index: 250;
    border: none; border-radius: 0; margin: 0;
    background: var(--surface);
    display: flex; flex-direction: column;
}
.html-editor.fullscreen .html-editor-toolbar { flex: 0 0 auto; }
.html-editor.fullscreen .html-editor-view,
.html-editor.fullscreen .html-editor-source  { flex: 1 1 auto; max-height: none;
                                               min-height: 0; }
/* Mientras el editor esta en pantalla completa, bloqueamos el scroll del body
   para evitar el doble scroll (viewport + editor). */
body.html-editor-fs-lock { overflow: hidden; }

/* Render del cuerpo HTML dentro de las view-card (modal Consultar). */
.view-card-value .html-content { background: #fff; color: #1a1a1a;
                                 border-radius: var(--radius);
                                 padding: 12px 14px; }
.view-card-value .html-content p          { margin: 0 0 .7em; }
.view-card-value .html-content h2         { font-size: 1.1rem; margin: .5em 0 .3em;
                                            font-weight: 700; }
.view-card-value .html-content h3         { font-size: 1rem; margin: .4em 0 .3em;
                                            font-weight: 700; }
.view-card-value .html-content ul,
.view-card-value .html-content ol         { padding-left: 1.4em; margin: 0 0 .7em; }
.view-card-value .html-content blockquote { margin: 0 0 .7em; padding: 4px 10px;
                                            border-left: 3px solid var(--primary);
                                            color: #555; }
.view-card-value .html-content a          { color: var(--primary); text-decoration: underline; }

/* 25. Tarjetas read-only del modal Consultar (DESIGN.md §25).
   Fondo fijo 10% mas oscuro que --surface, sin bordes, esquinas redondeadas. */
.view-tabs        { display: flex; gap: 4px;
                    border-bottom: 1px solid var(--border);
                    margin: 0 -4px; padding: 0 4px; flex-shrink: 0; }
.view-tab         { background: none; border: none; cursor: pointer;
                    font-family: inherit; font-size: .85rem; font-weight: 600;
                    color: var(--muted); padding: 10px 14px;
                    border-bottom: 2px solid transparent; margin-bottom: -1px;
                    transition: color .15s, border-color .15s; }
.view-tab:hover   { color: var(--text); }
.view-tab.active  { color: var(--primary); border-bottom-color: var(--primary); }
.view-tabpanel    { display: flex; flex-direction: column; gap: 12px;
                    padding-top: 8px; }
.view-tabpanel[hidden] { display: none; }

.view-photos      { display: grid; gap: 12px;
                    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.view-photo       { background: color-mix(in srgb, var(--surface) 90%, #000);
                    border-radius: var(--radius); overflow: hidden;
                    display: flex; flex-direction: column; }
.view-photo img   { display: block; width: 100%; height: auto;
                    background: var(--bg); padding: 10px;
                    box-sizing: border-box;
                    border-radius: calc(var(--radius) + 10px); }
.view-photo-caption { font-size: .78rem; color: var(--muted);
                      padding: 6px 8px; word-break: break-word; }
.view-photos-empty  { font-size: .82rem; color: var(--muted);
                      padding: 24px 12px; text-align: center;
                      background: color-mix(in srgb, var(--surface) 90%, #000);
                      border-radius: var(--radius); }

/* Editor de relaciones (modal Editar -> pestañas Imagenes/Videos/Audios) */
.rel-editor       { display: flex; flex-direction: column; gap: 12px; }
.rel-toolbar      { display: flex; justify-content: flex-start; gap: 8px; }
.rel-card         { position: relative; }
.rel-remove       { position: absolute; top: 6px; right: 6px;
                    width: 26px; height: 26px; border-radius: 50%;
                    border: none; cursor: pointer;
                    background: rgba(0,0,0,.65); color: #fff;
                    font-size: 1.1rem; line-height: 1;
                    display: inline-flex; align-items: center; justify-content: center;
                    transition: background .15s; }
.rel-remove:hover { background: var(--danger, #c0392b); }
.rel-icon-card    { display: flex; flex-direction: column; align-items: center;
                    justify-content: center; gap: 8px;
                    background: var(--bg); padding: 32px 12px;
                    color: var(--muted); border-radius: var(--radius);
                    margin: 10px; box-sizing: border-box; }
.rel-icon-card i  { font-size: 2rem; }
.rel-icon-card span { font-size: .85rem; font-weight: 600; }

.rel-caption       { display: flex; align-items: center; gap: 8px;
                     padding: 6px 8px; min-height: 32px; }
.rel-caption-edit  { background: none; border: none; cursor: pointer;
                     color: var(--muted); padding: 4px; line-height: 1;
                     font-size: .85rem; border-radius: 4px;
                     transition: color .15s, background .15s; }
.rel-caption-edit:hover { color: var(--primary);
                          background: color-mix(in srgb, var(--surface) 80%, #000); }
.rel-caption-text  { flex: 1; font-size: .78rem; color: var(--muted);
                     word-break: break-word; cursor: text;
                     min-width: 0; }
.rel-caption-text.is-placeholder { font-style: italic; opacity: .7; }
.rel-caption-input { flex: 1; min-width: 0; font-size: .82rem;
                     padding: 4px 6px; }

/* Picker de medios (modal abierto desde el editor de relaciones) */
.media-picker-search { width: 100%; padding: 10px 12px;
                       font-size: .95rem; }
.media-picker-status { font-size: .8rem; color: var(--muted); }
.media-picker-grid   { max-height: 60vh; overflow-y: auto; padding: 2px; }
.media-picker-card   { transition: transform .15s, box-shadow .15s;
                       outline: none; }
.media-picker-card:hover,
.media-picker-card:focus { transform: translateY(-2px);
                           box-shadow: var(--shadow-lg, 0 6px 16px rgba(0,0,0,.18)); }
.view-grid       { display: flex; flex-wrap: wrap; gap: 12px; }
.view-card       { background: color-mix(in srgb, var(--surface) 90%, #000);
                   border: none; border-radius: var(--radius);
                   padding: 12px 14px;
                   display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.view-card-half  { flex: 1 1 calc(50% - 6px); }
.view-card-third { flex: 1 1 calc(33.333% - 8px); }
.view-card-fifth { flex: 1 1 calc(20% - 10px); }
.view-card-full  { flex: 1 1 100%; }
.view-card-label { font-size: .72rem; font-weight: 600;
                   text-transform: uppercase; letter-spacing: .04em;
                   color: var(--muted); }
.view-card-value { font-size: .9rem; color: var(--text);
                   word-break: break-word; white-space: pre-wrap; }
.view-card-value .muted { color: var(--muted); }
.view-card-value pre    { margin: 0; font-family: monospace; font-size: .82rem;
                          background: var(--bg); border: 1px solid var(--border);
                          border-radius: 6px; padding: 10px 12px;
                          overflow-x: auto; white-space: pre-wrap; }
.link-ubicacion         { color: var(--primary); text-decoration: underline;
                          word-break: break-all; }
.link-ubicacion:hover   { color: var(--primary-h); }
@media (max-width: 640px) {
    .view-card-half,
    .view-card-third,
    .view-card-fifth { flex: 1 1 100%; }
}

/* 15. Confirm dialog ----------------------------------------- */
.confirm-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5);
                    display: flex; align-items: center; justify-content: center;
                    z-index: 150; opacity: 0; pointer-events: none;
                    transition: opacity .15s; }
.confirm-backdrop.open { opacity: 1; pointer-events: all; }
.confirm-box     { background: var(--surface); border-radius: 14px;
                   padding: 28px 28px 20px; max-width: 380px;
                   width: calc(100% - 32px); box-shadow: var(--shadow-lg);
                   transform: scale(.95); transition: transform .15s; }
.confirm-backdrop.open .confirm-box { transform: scale(1); }
.confirm-title   { font-weight: 700; margin-bottom: 8px; }
.confirm-msg     { font-size: .88rem; color: var(--muted); margin-bottom: 20px;
                   line-height: 1.45; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* 27. Tile grid (menu de utilidades) ------------------------- */
.tile-grid  { display: grid;
              grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
              gap: 16px; }
.tile-card  { background: var(--surface); border: 1px solid var(--border);
              border-radius: var(--radius); padding: 20px;
              display: flex; flex-direction: column; gap: 6px;
              text-align: left; cursor: pointer; text-decoration: none;
              color: var(--text); font-family: inherit;
              transition: border-color .15s, background .15s, transform .1s; }
.tile-card:hover  { border-color: var(--primary); background: var(--row-hover); }
.tile-card:active { transform: scale(.98); }
.tile-icon  { font-size: 1.6rem; line-height: 1; margin-bottom: 4px; }
.tile-title { font-weight: 600; font-size: .95rem; color: var(--text); }
.tile-desc  { font-size: .8rem; color: var(--muted); }

/* 17. Toggle switch (DESIGN.md §17) -------------------------- */
.toggle-switch       { display: inline-flex; align-items: center; gap: 12px;
                       cursor: pointer; user-select: none; }
.toggle-switch input { display: none; }
.toggle-track        { width: 44px; height: 24px; border-radius: 12px;
                       background: var(--border); position: relative;
                       transition: background .2s; flex-shrink: 0; }
.toggle-switch input:checked + .toggle-track { background: var(--primary); }
.toggle-thumb        { position: absolute; top: 3px; left: 3px;
                       width: 18px; height: 18px; border-radius: 50%;
                       background: #fff; transition: transform .2s;
                       box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.toggle-switch input:checked + .toggle-track .toggle-thumb { transform: translateX(20px); }
.toggle-label        { font-size: .9rem; color: var(--text); }

/* Configuracion: tarjetas de ajuste con label + control alineado a la derecha */
.config-grid         { display: grid;
                       grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
                       gap: 16px; }
.config-card         { background: var(--surface); border: 1px solid var(--border);
                       border-radius: var(--radius); padding: 18px 20px;
                       display: flex; align-items: center; gap: 16px; }
.config-card-body    { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.config-card-title   { font-weight: 600; font-size: .95rem; color: var(--text); }
.config-card-desc    { font-size: .8rem; color: var(--muted); }

/* 11. Badges -------------------------------------------------- */
.badge         { display: inline-block; padding: 2px 10px;
                 border-radius: 99px; font-size: .75rem; font-weight: 600; }
.badge-info    { background: rgba(59,130,246,.18); color: #93c5fd; }
.badge-success { background: rgba(34,197,94,.18);  color: #86efac; }
.badge-danger  { background: rgba(230,42,42,.2);   color: #f5a8a8; }
.badge-warn    { background: rgba(245,158,11,.18); color: #fcd34d; }

.vis-icon           { font-size: .95rem; display: inline-block; }
.vis-icon.vis-open  { color: var(--success); }
.vis-icon.vis-closed { color: var(--muted); }

/* 12. Stat cards --------------------------------------------- */
.stats-bar  { display: flex; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.stat-card  { background: var(--surface); border: 1px solid var(--border);
              border-radius: var(--radius); padding: 14px 20px;
              display: flex; flex-direction: column; gap: 2px;
              flex: 1; min-width: 140px; }
.stat-label { font-size: .72rem; color: var(--muted);
              text-transform: uppercase; letter-spacing: .04em;
              font-weight: 600; }
.stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-value.green   { color: var(--success); }
.stat-value.primary { color: var(--primary); }
.stat-value.red     { color: var(--danger); }
.stat-value.muted   { color: var(--muted); font-size: 1.2rem; }
.stat-sub   { font-size: .72rem; color: var(--muted); margin-top: 2px; }

/* 13. Dashboard grid ----------------------------------------- */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr;
             gap: 20px; margin-top: 4px; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

.dash-table-header { padding: 14px 20px 10px;
                     font-weight: 600; font-size: .95rem;
                     border-bottom: 1px solid var(--border);
                     display: flex; align-items: center;
                     justify-content: space-between; }
.dash-ver-mas      { font-size: .78rem; font-weight: 500; color: var(--primary); }

/* 16. Toasts ------------------------------------------------- */
.toast { position: fixed; bottom: 24px; left: 50%;
         transform: translateX(-50%) translateY(16px);
         background: #0d0d0d; color: var(--text);
         border: 1px solid var(--border);
         padding: 10px 20px; border-radius: 99px;
         font-size: .88rem; opacity: 0; pointer-events: none;
         transition: opacity .2s, transform .2s;
         z-index: 200; white-space: nowrap;
         box-shadow: var(--shadow-lg); }
.toast.show  { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); border-color: var(--danger); color: #fff; }

/* 18. Spinner ------------------------------------------------ */
.spin { display: inline-block; width: 28px; height: 28px;
        border: 3px solid var(--border); border-top-color: var(--primary);
        border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 19. Responsive --------------------------------------------- */
.sidebar-overlay  { display: none; position: fixed; inset: 0;
                    background: rgba(0,0,0,.45); z-index: 199; }
.sidebar-overlay.active { display: block; }

@media (max-width: 768px) {
    .topbar .hamburger { display: inline-flex; align-items: center; }
    .sidebar   { position: fixed; top: 0; left: 0; height: 100vh;
                 z-index: 200; transform: translateX(-100%);
                 transition: transform .25s; }
    .sidebar.open { transform: translateX(0); }
    .form-row, .form-row-3, .form-row-4, .form-row-5 { grid-template-columns: 1fr; }
}

/* 23. Module header ----------------------------------------- */
.module-header   { margin-bottom: 18px; }
.module-title    { font-size: 1.35rem; font-weight: 700;
                   color: var(--text); margin: 0 0 4px; line-height: 1.2; }
.module-subtitle { font-size: .88rem; color: var(--muted);
                   margin: 0; line-height: 1.4; }

/* Sub-seccion dentro de una vista. Una pantalla que agrupa dos cosas —
   Streaming: los canales y su programacion — las separa con este encabezado,
   un escalon por debajo del .module-header de la vista. */
.module-section       { margin: 34px 0 18px; }
.module-section-title { font-size: 1.08rem; font-weight: 700;
                        color: var(--text); margin: 0 0 4px; line-height: 1.2; }

/* Banner de nueva version disponible -------------------------- */
.version-banner { display: none; position: fixed; bottom: 24px; right: 24px;
                  background: var(--surface); border: 1px solid var(--primary);
                  border-radius: var(--radius); padding: 12px 16px;
                  box-shadow: var(--shadow-lg); z-index: 150;
                  align-items: center; gap: 12px; font-size: .85rem;
                  max-width: 320px; }
.version-banner.show { display: flex; }
.version-banner-text { color: var(--text); flex: 1; }
.version-banner-btn  { padding: 4px 10px; font-size: .78rem; }

/* 27-bis. Login --------------------------------------------- */
body.login-page { background: var(--bg); min-height: 100vh; }

.login-shell    { min-height: 100vh; display: flex;
                  align-items: center; justify-content: center; padding: 24px; }
.login-card     { width: 100%; max-width: 360px;
                  background: var(--primary);
                  border: 1px solid rgba(0,0,0,.25);
                  border-radius: 14px; box-shadow: var(--shadow-lg);
                  padding: 28px 28px 24px;
                  display: flex; flex-direction: column; gap: 16px;
                  color: #fff; }
.login-brand    { display: flex; align-items: center; justify-content: center; padding: 4px 0 0; margin-bottom: 10px; }
.login-logo     { display: block; height: 44px; max-width: 80%; object-fit: contain; }
.login-title    { font-size: 1.2rem; font-weight: 700;
                  text-align: center; color: #fff; }
.login-subtitle { font-size: .85rem; color: rgba(255,255,255,.78);
                  text-align: center; margin-top: -8px; }

.login-form     { display: flex; flex-direction: column; gap: 12px; }
.login-form .form-group label { color: rgba(255,255,255,.88); }
.login-form input[type=text],
.login-form input[type=password] {
    background: rgba(0,0,0,.22);
    border: 1px solid rgba(0,0,0,.35);
    color: #fff;
}
.login-form input::placeholder { color: rgba(255,255,255,.55); }
.login-form input:focus {
    border-color: #fff;
    box-shadow: 0 0 0 3px rgba(255,255,255,.22);
}

.login-error {
    color: #fff;
    background: rgba(0,0,0,.28);
    border: 1px solid rgba(0,0,0,.35);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: .82rem;
}

.login-page .btn-primary       { background: #fff; color: var(--primary); }
.login-page .btn-primary:hover { background: rgba(255,255,255,.9); color: var(--primary-h); }

.login-submit { justify-content: center; padding: 10px 16px; margin-top: 4px; }

/* ===== Herramienta: Explorador S3 ===== */
.s3-exp-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; padding: 6px 0;
    font-size: .88rem; color: var(--muted);
}
.s3-exp-header strong { color: var(--text); font-weight: 600; }

.s3-exp-breadcrumbs {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
    padding: 8px 10px; margin-top: 8px;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .85rem;
}
.s3-exp-crumb {
    cursor: pointer; padding: 2px 6px; border-radius: 4px;
    color: var(--primary);
}
.s3-exp-crumb:hover { background: var(--border); }
.s3-exp-crumb-sep   { color: var(--muted); }

.s3-exp-listado {
    margin-top: 10px;
    border: 1px solid var(--border); border-radius: var(--radius);
    max-height: 55vh; overflow-y: auto;
    background: var(--surface);
}
.s3-exp-item {
    display: grid;
    grid-template-columns: 44px 1fr 110px 170px;
    align-items: center; gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-size: .88rem;
}
/* Variante con columna extra de Acciones (la usa el Explorador SSH; el S3
   no la incluye en sus items y mantiene su grilla original de 4 columnas). */
.s3-exp-item.s3-exp-item-acciones {
    grid-template-columns: 44px 1fr 110px 170px 90px;
}
.s3-exp-item:last-child { border-bottom: none; }
.s3-exp-folder          { cursor: pointer; }
.s3-exp-folder:hover    { background: var(--bg); }

.s3-exp-acciones {
    display: flex; align-items: center; justify-content: flex-end; gap: 6px;
}
.s3-exp-acciones .btn-icon-row {
    background: transparent; border: 1px solid transparent;
    width: 30px; height: 30px; line-height: 1;
    border-radius: 6px; cursor: pointer;
    font-size: .95rem; padding: 0;
    color: var(--text); text-decoration: none;
    display: inline-flex; align-items: center; justify-content: center;
}
.s3-exp-acciones .btn-icon-row:hover {
    background: var(--bg); border-color: var(--border);
}

.s3-exp-icon {
    font-size: 1.1rem; text-align: center;
    display: flex; align-items: center; justify-content: center;
}
.s3-exp-thumb {
    width: 40px; height: 40px; object-fit: cover;
    border-radius: 4px; border: 1px solid var(--border);
    background: var(--bg); display: block;
}
.s3-exp-nombre        { word-break: break-all; color: var(--text); }
.s3-exp-nombre a      { color: var(--primary); text-decoration: none; }
.s3-exp-nombre a:hover{ text-decoration: underline; }
.s3-exp-meta          { color: var(--muted); font-size: .8rem; text-align: right; }
.s3-exp-empty {
    padding: 30px; text-align: center; color: var(--muted);
}

.s3-exp-paginacion {
    display: flex; justify-content: center; margin-top: 10px;
}
.s3-exp-btn-mas { min-width: 140px; }

/* Banner al final del listado de los exploradores cuando hay mas resultados
   que el cap (100). */
.exp-truncated-hint {
    padding: 12px; text-align: center; font-size: .82rem;
    color: var(--text);
    background: rgba(255, 196, 0, .08);
    border-top: 1px dashed rgba(255, 196, 0, .35);
}

/* ===== Progress modal (consola tipo terminal) =====
   Patron descripto en DESIGN.md §29. Body full-bleed con fondo oscuro:
   arriba una toolbar (.prog-toolbar) con spinner + linea de estado (la
   tarea actual), abajo la consola (.prog-console) donde caen las lineas
   coloreadas por nivel. No hay barra de progreso; el "(i/n)" ya lo expone
   el caller via setStatus. */
.prog-modal              { max-width: 900px; }
.prog-console-body       { padding: 0; background: #0a0a0a; }
.prog-toolbar {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    background: #141414; border-bottom: 1px solid #1f1f1f;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .82rem;
}
.prog-toolbar-status         { color: #d4d4d4; flex: 1; min-width: 0;
                               overflow: hidden; text-overflow: ellipsis;
                               white-space: nowrap; }
.prog-toolbar-status-ok      { color: #34d399; }
.prog-toolbar-status-err     { color: #f87171; }
.prog-spin-sm {
    display: inline-block; width: 12px; height: 12px;
    border: 2px solid #1f1f1f; border-top-color: #d4d4d4;
    border-radius: 50%; animation: spin .7s linear infinite;
    flex: 0 0 auto;
}
.prog-spin-sm-done           { animation: none; visibility: hidden; }

.prog-console {
    height: 60vh; overflow: auto;
    background: #0a0a0a; padding: 10px 14px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .8rem; line-height: 1.55;
    color: #d4d4d4;
}
.prog-console::-webkit-scrollbar         { width: 10px; height: 10px; }
.prog-console::-webkit-scrollbar-track   { background: #0a0a0a; }
.prog-console::-webkit-scrollbar-thumb   { background: #2a2a2a;
                                            border-radius: 5px; }
.prog-console::-webkit-scrollbar-thumb:hover { background: #3a3a3a; }

.prog-log-line  { padding: 1px 0; white-space: pre-wrap;
                  word-break: break-word; }
.prog-log-info  { color: #d4d4d4; }
.prog-log-ok    { color: #34d399; }
.prog-log-err   { color: #f87171; }
.prog-log-warn  { color: #fbbf24; }
.prog-log-skip  { color: #60a5fa; }

@media (max-width: 640px) {
    .s3-exp-item                  { grid-template-columns: 40px 1fr 80px; }
    .s3-exp-item.s3-exp-item-acciones { grid-template-columns: 40px 1fr 80px 80px; }
    /* Oculta la columna de fecha en mobile (es la 4a y solo existe en SSH). */
    .s3-exp-item.s3-exp-item-acciones > .s3-exp-meta:nth-of-type(2) { display: none; }
    .s3-exp-item > .s3-exp-meta:last-child { display: none; }
    .s3-exp-thumb { width: 36px; height: 36px; }
}

/* ================================================================
 * Mosaico de medios (modulos Imagenes y Videos)
 * Reemplaza la tabla del listado por una grilla de miniaturas. Las
 * miniaturas las sirve api/imagen.php desde S3 con crop centrado +
 * cache en disco.
 *
 * Variantes:
 *   .media-mosaic--ratio-1x1   Imagenes (150x150 cuadradas)
 *   .media-mosaic--ratio-4x3   Videos   (200x150 anchas 4:3)
 *   .media-mosaic--ratio-2x3   Libros   (tapas verticales 2:3)
 * ================================================================ */
.media-mosaic {
    display: grid;
    gap: 14px;
    padding: 16px;
}
.media-mosaic--ratio-1x1 {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.media-mosaic--ratio-4x3 {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.media-mosaic--ratio-2x3 {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

.media-mosaic-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    transition: border-color .15s, transform .15s, box-shadow .15s;
}
.media-mosaic-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, .25);
}

.media-mosaic-thumb-wrap {
    position: relative;
    width: 100%;
    background: var(--bg);
    overflow: hidden;
}
.media-mosaic--ratio-1x1 .media-mosaic-thumb-wrap { aspect-ratio: 1 / 1; }
.media-mosaic--ratio-4x3 .media-mosaic-thumb-wrap { aspect-ratio: 4 / 3; }
.media-mosaic--ratio-2x3 .media-mosaic-thumb-wrap { aspect-ratio: 2 / 3; }

.media-mosaic-img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

/* Thumb placeholder para audios: mismo "espacio" 4:3 que un thumb de video
 * pero sin imagen — gradiente oscuro + icono de nota musical centrado,
 * espejando la estetica del .preview-frame--audio del modal Consultar. */
.media-mosaic-audio-thumb {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #0f0f1e 100%);
    color: #fff;
}
.media-mosaic-audio-thumb i {
    font-size: clamp(40px, 30%, 72px);
    opacity: .85;
}
.media-mosaic-card:hover .media-mosaic-audio-thumb i {
    color: var(--primary);
    opacity: 1;
}

.media-mosaic-id {
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(0, 0, 0, .65);
    color: #fff;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: .7rem;
    font-weight: 600;
    pointer-events: none;
}

.media-mosaic-actions {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity .15s;
}
.media-mosaic-card:hover .media-mosaic-actions { opacity: 1; }

.media-mosaic-act {
    background: rgba(0, 0, 0, .65);
    color: #fff;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: .8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.media-mosaic-act:hover         { background: rgba(0, 0, 0, .9); }
.media-mosaic-act.danger:hover  { background: var(--danger); }

.media-mosaic-caption {
    position: relative;
    padding: 6px 8px 8px;
    font-size: .6rem;
    line-height: 1.3;
    color: var(--text);
    overflow: hidden;
    max-height: calc(2.6em + 20px);
    min-height: calc(2.6em + 20px);
}
/* Fade-out de 10px al final del epigrafe: el texto se desvanece
   suavemente contra el fondo de la tarjeta (var(--surface)) en lugar
   de cortarse en seco. */
.media-mosaic-caption::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 10px;
    background: linear-gradient(to top, var(--surface) 0%, transparent 100%);
    pointer-events: none;
}

/* ================================================================
 * Preview de medios (modal Consultar de Imagenes / Videos)
 * Layout 2-columnas: preview a la izquierda (col fija ~360px), datos
 * a la derecha (col fluida). Frame con aspect ratio definido; el
 * contenido (img/video) se encaja con object-fit: contain para no
 * recortar — bandas negras a los costados si el ratio del original no
 * coincide con el del frame.
 *
 * En pantallas chicas (<= 700px) las columnas se apilan: preview
 * arriba, datos abajo.
 * ================================================================ */
.view-with-preview {
    display: flex;
    gap: 18px;
    align-items: flex-start;
}
.view-preview-col {
    flex: 0 0 360px;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: color-mix(in srgb, var(--surface) 90%, #000);
    padding: 12px;
    border-radius: var(--radius);
}
.view-data-col {
    flex: 1 1 auto;
    min-width: 0;
}
@media (max-width: 700px) {
    .view-with-preview { flex-direction: column; }
    .view-preview-col  { flex: 0 0 auto; max-width: 100%; width: 100%; }
}

.preview-frame {
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.preview-frame--4x3 { aspect-ratio: 4 / 3; }
.preview-frame--2x3 { aspect-ratio: 2 / 3; }
.preview-frame--2x1 { aspect-ratio: 2 / 1; }
.preview-frame--16x9 { aspect-ratio: 16 / 9; }

/* Imagen: respeta tamaño natural sin estirar; se centra. */
.preview-frame img.preview-media {
    max-width:  100%;
    max-height: 100%;
    width:  auto;
    height: auto;
    display: block;
}

/* Video: llena el frame y deja que el navegador haga letterbox. */
.preview-frame video.preview-media {
    width:  100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* Frame "vacio": placeholder textual cuando no hay archivo (ej. video
 * sin subir a S3). */
.preview-frame--empty {
    color: var(--muted);
    font-size: .9rem;
    font-style: italic;
    padding: 16px;
    text-align: center;
}

/* Frame circular para autores (con fondo oscuro para no-imagen). */
.preview-frame--circular {
    background: #444;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.preview-frame--circular.preview-frame--empty {
    background: #444;
    color: transparent;
    padding: 0;
}

/* Imagen circular: llena el espacio sin dejar vacíos */
.preview-frame--circular .preview-media {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: cover !important;
}

/* Frame clickeable: indica al usuario que se puede ampliar la imagen. */
.preview-frame--clickable { cursor: zoom-in; }

/* Frame de audio: mismo espacio que video (4:3) pero con reproductor custom
 * — boton play/pause grande al centro + barra de progreso debajo. Sin <video>
 * real, el <audio> queda oculto y solo dibujamos los controles. */
.preview-frame--audio {
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    padding: 20px 16px 14px;
    background: linear-gradient(135deg, #1a1a2e 0%, #0f0f1e 100%);
    gap: 14px;
}
.preview-frame--audio audio { display: none; }
.audio-preview-play {
    background: transparent;
    border: none;
    color: #fff;
    font-size: clamp(60px, 24%, 110px);
    line-height: 1;
    padding: 0;
    margin: 0 auto;
    cursor: pointer;
    transition: color .15s, transform .1s;
}
.audio-preview-play:hover  { color: var(--primary); }
.audio-preview-play:active { transform: scale(.95); }
.audio-preview-seekrow {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: .82rem;
    font-variant-numeric: tabular-nums;
}
.audio-preview-seek {
    flex: 1 1 auto;
    min-width: 0;
    accent-color: var(--primary);
    cursor: pointer;
    margin: 0;
}
.audio-preview-time {
    flex: 0 0 auto;
    min-width: 36px;
    text-align: center;
    opacity: .85;
}

/* Audios — uploader (botones de subir/quitar) en el modal Editar. */
.audio-upload-aside    { display: flex; flex-direction: column; gap: 10px; }
.audio-upload-buttons  { display: flex; flex-direction: column; gap: 6px; }
.audio-upload-file     { display: none; }
.audio-upload-status   { font-size: .8rem; text-align: center; min-height: 1.1em; }
.audio-upload-status.muted { color: var(--muted); }
.audio-upload-status.ok    { color: var(--success); }
.audio-upload-status.err   { color: var(--danger); }
.audio-upload-hint {
    font-size: .75rem; color: var(--muted); line-height: 1.4; word-break: break-all;
}

/* Boton "Ver a tamaño original" debajo del preview de video (y reutilizable
 * por otras entidades). Ocupa el ancho de la columna del preview. */
.preview-fullsize-btn {
    width: 100%;
}

/* Lightbox: overlay full-viewport. La imagen se muestra a su tamaño
 * natural pero limitada al viewport (max-width/max-height: 100%) para que
 * siempre entre completa sin scroll. El backdrop se centra con flex. */
.image-lightbox-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.88);
    z-index: 200;
    opacity: 0; pointer-events: none;
    transition: opacity .18s;
    cursor: zoom-out;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.image-lightbox-backdrop.open { opacity: 1; pointer-events: all; }
.image-lightbox-img {
    display: block;
    max-width:  100%;
    max-height: 100%;
    width:  auto;
    height: auto;
    object-fit: contain;
    cursor: default;
    box-shadow: var(--shadow-lg);
}
.image-lightbox-close {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,.6);
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, transform .1s;
    font-family: inherit;
    z-index: 201;
}
.image-lightbox-close:hover  { background: rgba(0,0,0,.85); }
.image-lightbox-close:active { transform: scale(.95); }

/* ============================================================
   Categorias — vista de arbol jerarquico
   ============================================================ */
.cat-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
}
.cat-toolbar-left  { flex: 1 1 320px; display: flex; gap: 8px; align-items: center; }
.cat-toolbar-right { display: flex; gap: 8px; align-items: center; }
.cat-search {
    width: 100%; max-width: 420px;
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 9px 14px; font-size: .9rem; background: var(--surface);
    color: var(--text); outline: none; transition: border .15s;
}
.cat-search:focus { border-color: var(--primary); }

.cat-toolbar-secondary {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 12px;
}
.cat-kpi-strip { display: flex; gap: 10px; flex-wrap: wrap; }
.cat-kpi {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 6px 14px;
    display: flex; align-items: center; gap: 8px;
}
.cat-kpi-label { font-size: .7rem; font-weight: 700; color: var(--muted); letter-spacing: .05em; }
.cat-kpi-value { font-size: 1rem; font-weight: 700; }
.cat-kpi-value.primary { color: var(--primary); }
.cat-kpi-value.muted   { color: var(--muted); }

.cat-toolbar-icons { display: flex; gap: 4px; }
.btn-icon-tool {
    width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); color: var(--muted);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 1rem; transition: background .15s, color .15s;
}
.btn-icon-tool:hover { background: var(--bg); color: var(--text); }

.cat-tree-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.cat-tree { display: flex; flex-direction: column; }
.cat-row {
    display: grid;
    grid-template-columns: 24px auto 1fr auto auto;
    align-items: center; gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    transition: background .12s;
    position: relative;
}
.cat-row:last-child { border-bottom: none; }
.cat-row:hover { background: var(--row-hover); }

.cat-arrow {
    width: 18px; height: 18px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--muted); cursor: pointer; user-select: none;
    border-radius: 4px; font-size: .7rem;
}
.cat-arrow:hover:not(.empty) { background: var(--bg); color: var(--text); }
.cat-arrow.empty { cursor: default; }

.cat-name-wrap { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.cat-name      { font-weight: 600; color: var(--text); }
.cat-id        { font-size: .78rem; color: var(--muted); }

.cat-badge {
    font-size: .65rem; font-weight: 700; letter-spacing: .05em;
    padding: 2px 8px; border-radius: 999px;
    display: inline-flex; align-items: center;
    border: 1px solid transparent;
}
.cat-badge-raiz   { background: rgba(157,32,80,.18);  color: var(--primary); border-color: rgba(157,32,80,.45); }
.cat-badge-sitio  { background: rgba(59,130,246,.15); color: var(--info);    border-color: rgba(59,130,246,.35); }
.cat-badge-cat3   { background: rgba(34,197,94,.15);  color: var(--success); border-color: rgba(34,197,94,.35); }
.cat-badge-cat4   { background: rgba(245,158,11,.15); color: var(--warn);    border-color: rgba(245,158,11,.35); }

.cat-stats { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.cat-stat-muted { font-size: .78rem; color: var(--muted); }
.cat-stat-count { font-size: .78rem; color: var(--text); }
.cat-stat-count strong { color: var(--primary); }

.cat-actions { display: flex; gap: 2px; }
.cat-actions .action-ico {
    width: 30px; height: 30px; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    border: none; background: transparent; color: var(--muted);
    cursor: pointer; font-size: .95rem;
}
.cat-actions .action-ico:hover { background: var(--bg); color: var(--primary); }
.cat-actions .action-ico.disabled {
    opacity: .35; cursor: not-allowed; pointer-events: none;
}

.cat-row-depth-2 { background: rgba(255,255,255,.015); }
.cat-row-depth-3 { background: rgba(255,255,255,.03); }

@media (max-width: 700px) {
    .cat-row { grid-template-columns: 22px auto 1fr auto; }
    .cat-stats { display: none; }
}

/* ============================================================
   Articulos — picker de categoria (campo del form + arbol en modal)
   ============================================================ */
.cat-picker-field {
    display: flex; align-items: center; gap: 8px;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface);
    padding: 4px 4px 4px 12px; min-height: 40px;
}
.cat-picker-label {
    flex: 1; min-width: 0;
    display: flex; align-items: baseline; gap: 8px;
    font-size: .88rem; color: var(--text);
    overflow: hidden;
}
.cat-picker-name {
    flex: 1; min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cat-picker-name.muted { color: var(--muted); font-style: italic; }
.cat-picker-id { color: var(--muted); font-size: .78rem; flex-shrink: 0; }
.cat-picker-clear {
    background: none; border: none; color: var(--muted); cursor: pointer;
    font-size: 1.1rem; line-height: 1; padding: 4px 8px; border-radius: 6px;
    transition: color .15s, background .15s;
}
.cat-picker-clear:hover { color: var(--danger); background: var(--bg); }
.cat-picker-open { white-space: nowrap; flex-shrink: 0; }

.cat-picker-search { width: 100%; }

.cat-picker-tree {
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 50vh; overflow-y: auto;
}
.cat-picker-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; border-bottom: 1px solid var(--border);
    cursor: pointer; user-select: none;
    transition: background .12s;
}
.cat-picker-row:last-child { border-bottom: none; }
.cat-picker-row:hover { background: var(--row-hover); }
.cat-picker-row.selected { background: rgba(157,32,80,.18); }
.cat-picker-row.selected .cat-picker-row-name { color: var(--primary); font-weight: 600; }
.cat-picker-arrow {
    width: 18px; height: 18px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--muted); cursor: pointer; user-select: none;
    border-radius: 4px; font-size: .7rem;
}
.cat-picker-arrow:hover:not(.empty) { background: var(--surface); color: var(--text); }
.cat-picker-arrow.empty { cursor: default; }
.cat-picker-row-name {
    flex: 1; min-width: 0; color: var(--text); font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cat-picker-row-id { color: var(--muted); font-size: .78rem; flex-shrink: 0; }

/* ============================================================
   Widget reutilizable: input de etiquetas (chips + autocomplete)
   Usado en forms de articulos, imagenes y videos.
   ============================================================ */
.tag-input { position: relative; }
.tag-input-field {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface);
    padding: 6px 8px; min-height: 40px;
    cursor: text;
}
.tag-input-field:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(157, 32, 80, 0.15);
}
.tag-input-chips {
    display: contents;
}
.tag-chip {
    display: inline-flex; align-items: center; gap: 4px;
    background: rgba(157, 32, 80, 0.18);
    color: var(--text);
    border-radius: 999px;
    padding: 3px 4px 3px 10px;
    font-size: .85rem;
    line-height: 1.2;
    max-width: 100%;
    word-break: break-word;
}
.tag-chip-x {
    background: none; border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 1rem; line-height: 1;
    padding: 0 6px;
    border-radius: 50%;
    transition: color .12s, background .12s;
}
.tag-chip-x:hover { color: #fff; background: var(--primary); }
.tag-input-edit {
    flex: 1 1 120px; min-width: 100px;
    background: transparent; border: none; outline: none;
    color: var(--text);
    font-size: .9rem; line-height: 1.4;
    padding: 4px 2px;
}
.tag-input-edit::placeholder { color: var(--muted); }
.tag-input-edit.input-invalid {
    background: rgba(220, 53, 69, 0.15);
    border-radius: 4px;
}
.tag-input-suggestions {
    position: absolute; left: 0; right: 0; top: calc(100% + 4px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 240px; overflow-y: auto;
    z-index: 30;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    display: flex; flex-direction: column;
}
.tag-input-suggestions[hidden] { display: none; }
.tag-input-suggestion {
    background: none; border: none;
    text-align: left;
    padding: 8px 12px;
    color: var(--text);
    font-size: .88rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}
.tag-input-suggestion:last-child { border-bottom: none; }
.tag-input-suggestion:hover,
.tag-input-suggestion.is-active {
    background: rgba(157, 32, 80, 0.20);
    color: #fff;
}

/* ============================================================
   Libros — preview + uploader de tapa (columna izquierda del modal)
   ============================================================ */
.libro-tapa-aside {
    display: flex; flex-direction: column; gap: 10px;
    align-items: stretch;
}
.libro-tapa-aside-label {
    font-size: .8rem; font-weight: 600; color: var(--muted);
    text-transform: uppercase; letter-spacing: .03em;
}
.libro-tapa-btn { align-self: stretch; }
.libro-tapa-buttons { display: flex; flex-direction: column; gap: 6px; }
.libro-tapa-file { display: none; }
.libro-tapa-status { font-size: .8rem; text-align: center; min-height: 1.1em; }
.libro-tapa-status.muted { color: var(--muted); }
.libro-tapa-status.ok    { color: var(--success); }
.libro-tapa-status.err   { color: var(--danger); }
.libro-tapa-hint {
    font-size: .75rem; color: var(--muted); line-height: 1.4; word-break: break-all;
}
.libro-tapa-empty {
    font-size: .85rem; color: var(--muted); padding: 16px;
    border: 1px dashed var(--border); border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 90%, #000);
    text-align: center;
}

/* ============================================================
   Herramienta — Comparar estructura BD dev/prod (db-cmp-*)
   Diff de dos schemas (dev vs prod). El verde = DEV, el rojo = PROD;
   los chips/columnas resaltan por lado y los campos modificados se
   pintan con --warn dentro del bloque de columna.
   ============================================================ */
.db-cmp                  { display: flex; flex-direction: column; gap: 16px; }
.db-cmp-loading,
.db-cmp-empty,
.db-cmp-error            { padding: 32px 16px; text-align: center;
                           color: var(--muted); }
.db-cmp-error            { color: var(--danger); }

.db-cmp-summary          { display: flex; align-items: center; gap: 14px;
                           padding: 12px 14px; background: var(--bg);
                           border: 1px solid var(--border); border-radius: var(--radius); }
.db-cmp-summary-side     { display: flex; align-items: center; gap: 8px;
                           flex: 1; min-width: 0; }
.db-cmp-summary-side code { font-size: .85rem; color: var(--text);
                            background: var(--surface); border: 1px solid var(--border);
                            border-radius: 6px; padding: 2px 8px;
                            white-space: nowrap; overflow: hidden;
                            text-overflow: ellipsis; }
.db-cmp-summary-host     { font-size: .75rem; color: var(--muted);
                           white-space: nowrap; overflow: hidden;
                           text-overflow: ellipsis; }
.db-cmp-summary-arrow    { font-size: 1.2rem; color: var(--muted); flex-shrink: 0; }
.db-cmp-side-label       { font-size: .7rem; font-weight: 700; letter-spacing: .05em;
                           padding: 2px 8px; border-radius: 99px;
                           text-transform: uppercase; flex-shrink: 0; }
.db-cmp-side-dev         { background: rgba(34,197,94,.18);  color: #86efac; }
.db-cmp-side-prod        { background: rgba(230,42,42,.2);   color: #f5a8a8; }

.db-cmp-stats            { display: grid;
                           grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
                           gap: 10px; }
.db-cmp-stat             { background: var(--surface); border: 1px solid var(--border);
                           border-radius: var(--radius); padding: 10px 14px;
                           display: flex; flex-direction: column; gap: 2px; }
.db-cmp-stat-label       { font-size: .7rem; color: var(--muted);
                           text-transform: uppercase; letter-spacing: .04em; }
.db-cmp-stat-value       { font-size: 1.2rem; font-weight: 700; color: var(--text); }

.db-cmp-section          { display: flex; flex-direction: column; gap: 8px; }
.db-cmp-section-title    { font-size: .9rem; font-weight: 700; color: var(--text);
                           display: flex; align-items: center; gap: 6px; }
.db-cmp-badge            { display: inline-block; padding: 2px 8px;
                           border-radius: 99px; font-size: .7rem;
                           background: var(--bg); color: var(--muted);
                           border: 1px solid var(--border); }

.db-cmp-chips            { display: flex; flex-wrap: wrap; gap: 6px; }
.db-cmp-chip             { font-family: monospace; font-size: .78rem;
                           padding: 3px 8px; border-radius: 6px;
                           border: 1px solid var(--border); }
.db-cmp-chip-dev         { background: rgba(34,197,94,.12);  color: #86efac;
                           border-color: rgba(34,197,94,.32); }
.db-cmp-chip-prod        { background: rgba(230,42,42,.12);  color: #f5a8a8;
                           border-color: rgba(230,42,42,.32); }

.db-cmp-tables           { display: flex; flex-direction: column; gap: 12px; }
.db-cmp-table            { background: var(--surface); border: 1px solid var(--border);
                           border-radius: var(--radius); overflow: hidden; }
.db-cmp-table-name       { padding: 10px 14px; background: var(--bg);
                           border-bottom: 1px solid var(--border); }
.db-cmp-table-name code  { font-size: .9rem; color: var(--text);
                           font-weight: 600; background: none; border: none; padding: 0; }
.db-cmp-table-body       { padding: 12px 14px; display: flex; flex-direction: column;
                           gap: 14px; }

.db-cmp-subsection       { display: flex; flex-direction: column; gap: 8px; }
.db-cmp-subsection-title { font-size: .78rem; font-weight: 600; color: var(--muted);
                           text-transform: uppercase; letter-spacing: .04em; }

.db-cmp-col-rows         { display: flex; flex-direction: column; gap: 10px; }
.db-cmp-col-row          { background: var(--bg); border: 1px solid var(--border);
                           border-radius: 8px; padding: 10px 12px;
                           display: flex; flex-direction: column; gap: 6px; }
.db-cmp-col-name         { display: flex; align-items: center; gap: 10px;
                           flex-wrap: wrap; }
.db-cmp-col-name code    { font-size: .85rem; color: var(--text); font-weight: 600;
                           background: var(--surface); border: 1px solid var(--border);
                           border-radius: 6px; padding: 2px 8px; }

/* Una fila compacta por propiedad cambiada: [key] DEV → PROD */
.db-cmp-diff-rows        { display: flex; flex-direction: column; gap: 4px; }
.db-cmp-diff-row         { display: grid;
                           grid-template-columns: auto 1fr auto 1fr;
                           column-gap: 10px; align-items: baseline; }
.db-cmp-diff-key         { font-size: .7rem; color: var(--muted);
                           text-transform: uppercase; letter-spacing: .03em;
                           min-width: 64px; }
.db-cmp-diff-val         { font-family: monospace; font-size: .8rem;
                           word-break: break-word; padding: 2px 6px;
                           border-radius: 4px; }
.db-cmp-diff-val.dev     { background: rgba(34,197,94,.12); color: #86efac; }
.db-cmp-diff-val.prod    { background: rgba(230,42,42,.12); color: #f5a8a8; }
.db-cmp-diff-arrow       { color: var(--muted); font-size: .85rem; }

@media (max-width: 640px) {
    .db-cmp-summary       { flex-direction: column; align-items: stretch; }
    .db-cmp-summary-arrow { display: none; }
    .db-cmp-diff-row      { grid-template-columns: auto 1fr;
                            row-gap: 2px; }
    .db-cmp-diff-arrow    { display: none; }
}

/* Bloque SQL corrector */
.db-cmp-sql-title        { justify-content: space-between; gap: 12px;
                           flex-wrap: wrap; }
.db-cmp-sql-actions      { display: flex; gap: 8px; flex-wrap: wrap; }
.db-cmp-sql-hint         { font-size: .78rem; color: var(--muted);
                           margin-bottom: 6px; }
.db-cmp-sql              { background: var(--bg); border: 1px solid var(--border);
                           border-radius: var(--radius); padding: 12px 14px;
                           font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
                           font-size: .78rem; line-height: 1.45; color: var(--text);
                           white-space: pre; overflow: auto;
                           max-height: 360px; margin: 0; }

/* Frame cuadrado (1:1) para imágenes de autores y otras entidades. */
.preview-frame--1x1 { aspect-ratio: 1 / 1; overflow: hidden; }

/* Publicidades — uploader (botones de subir/quitar) en el modal Editar. */
.publicidad-upload-aside    { display: flex; flex-direction: column; gap: 10px; }
.publicidad-upload-buttons  { display: flex; flex-direction: column; gap: 6px; }
.publicidad-upload-file     { display: none; }
.publicidad-upload-status   { font-size: .8rem; text-align: center; min-height: 1.1em; }
.publicidad-upload-status.muted { color: var(--muted); }
.publicidad-upload-status.ok    { color: var(--success); }
.publicidad-upload-status.err   { color: var(--danger); }

/* Autores — uploader (botones de subir/quitar) en el modal Editar. */
.autor-upload-aside    { display: flex; flex-direction: column; gap: 10px; }
.autor-upload-buttons  { display: flex; flex-direction: column; gap: 6px; }
.autor-upload-file     { display: none; }
.autor-upload-status   { font-size: .8rem; text-align: center; min-height: 1.1em; }
.autor-upload-status.muted { color: var(--muted); }
.autor-upload-status.ok    { color: var(--success); }
.autor-upload-status.err   { color: var(--danger); }

.anunciante-logo-file  { display: none; }
.anunciante-logo-status { font-size: .8rem; text-align: center; min-height: 1.1em; }
.anunciante-logo-status.muted { color: var(--muted); }
.anunciante-logo-status.ok    { color: var(--success); }
.anunciante-logo-status.err   { color: var(--danger); }

.anunciante-upload-aside   { display: flex; flex-direction: column; gap: 10px; }
.anunciante-upload-buttons { display: flex; flex-direction: column; gap: 6px; }

/* Logotipo e ilustracion se apilan en la columna de preview del modal, asi que
   cada recuadro lleva su rotulo arriba para distinguirlos. */
.anunciante-imagen-bloque + .anunciante-imagen-bloque { margin-top: 14px; }
.anunciante-imagen-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    text-align: center;
    margin-bottom: 6px;
}

/* Tablero de anunciantes — pantalla completa */
.tablero-fullscreen {
    position: fixed;
    inset: 0;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
    z-index: 99;
}

.tablero-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-auto-rows: 1fr;
    gap: 12px;
    width: 100%;
    height: 100%;
}

.tablero-card {
    background: #111;
    border: 1px solid #333;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    position: relative;
}

.tablero-card:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(0,0,0,0.8);
}

.tablero-card-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

/* Ya jugada: queda atenuada, pero se puede reabrir en modo consulta. */
.tablero-card--disabled {
    cursor: pointer;
}

.tablero-card--disabled::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 8px;
    pointer-events: none;
}

.tablero-card--disabled:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

@media (max-width: 1400px) {
    .tablero-fullscreen { padding: 20px; }
    .tablero-grid { grid-template-columns: repeat(5, 1fr); }
}

@media (max-width: 1024px) {
    .tablero-fullscreen { padding: 20px; }
    .tablero-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 768px) {
    .tablero-fullscreen { padding: 20px; }
    .tablero-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 640px) {
    .tablero-fullscreen { padding: 20px; }
    .tablero-grid { grid-template-columns: 1fr; }
}

/* Estilos para TV - textos grandes y legibles */
.tablero-modal-title {
    font-size: 3rem;
    font-weight: 700;
    margin: 20px 0;
    line-height: 1.2;
}

.tablero-modal-question {
    font-size: 1.6rem;
    font-weight: 600;
    margin: 20px 0;
    line-height: 1.3;
    color: var(--text);
}

.tablero-opciones {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-top: 40px;
}

.tablero-opcion {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 20px 30px;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.15s, transform 0.15s;
    background-color: rgba(157, 32, 80, 0.05);
    border: 3px solid transparent;
}

.tablero-opcion:hover {
    background-color: rgba(157, 32, 80, 0.15);
    transform: scale(1.02);
    border-color: rgba(157, 32, 80, 0.3);
}

.tablero-opcion input[type="radio"] {
    cursor: pointer;
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
}

.tablero-opcion label {
    font-size: 1.3rem;
    font-weight: 500;
    cursor: pointer;
    flex: 1;
}

/* Nuevo diseño del modal de preguntas */
.tablero-modal-consulta {
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted);
    font-size: 1.1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    margin: 0 -24px 14px -24px;
}

/* El tablero se lee en un televisor y a varios metros: la pregunta y las
   opciones comparten tamaño y peso para que nada quede en segundo plano. */
.tablero-modal-question--header {
    background: var(--info);
    color: white;
    font-size: 2.1rem;
    font-weight: 700;
    padding: 25px;
    text-align: center;
    border-radius: 12px;
    margin: 0 -24px 25px -24px;
    line-height: 1.3;
}

.tablero-opciones-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 30px 0;
}

.tablero-opcion-btn {
    padding: 18px 20px;
    background: #d0d0d0;
    color: #333;
    border: none;
    border-radius: 12px;
    font-size: 2.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s, transform 0.15s;
    text-align: center;
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.tablero-opcion-btn:hover {
    background: #b8b8b8;
    transform: scale(1.01);
}

.tablero-opcion-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.tablero-action-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 40px;
}

.tablero-action-btn {
    padding: 20px 16px;
    background: var(--info);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s, transform 0.15s;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    gap: 8px;
}

.tablero-action-btn:hover {
    background: #2563eb;
    transform: scale(1.02);
}

.tablero-action-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Un comodin ya usado no se ilumina al pasar por encima: se tiene que ver
   apagado, que es el unico aviso de que ya no esta disponible. */
.tablero-action-btn:disabled:hover {
    background: var(--info);
    transform: none;
}

.tablero-action-btn-icon {
    font-size: 2rem;
}

.tablero-message {
    font-size: 2.5rem;
    font-weight: 700;
    padding: 30px;
    text-align: center;
    border-radius: 12px;
    margin: 30px 0;
    display: none;
}

/* Sello sobre la tarjeta de un anunciante ya jugado. */
.tablero-card-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #4CAF50;
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 700;
    font-size: .9rem;
}

/* Cierre de la jugada: aparece medio segundo después de contestar, por encima
   del modal de la pregunta (que está en z-index 250). */
.tablero-ilustracion {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4vh;
    background: rgba(0, 0, 0, .85);
    cursor: zoom-out;
}

/* Panel blanco: ilustración a la izquierda, pregunta a la derecha y la
   respuesta correcta debajo de la pregunta. */
.tablero-ilustracion-panel {
    display: flex;
    align-items: stretch;
    gap: 32px;
    max-width: 92vw;
    max-height: 92vh;
    padding: 32px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
    overflow: hidden;
}

.tablero-ilustracion-img {
    max-width: 45vw;
    max-height: calc(92vh - 64px);
    width: auto;
    height: auto;
    display: block;
    border-radius: 12px;
    object-fit: contain;
    flex: 0 0 auto;
}

/* Columna derecha: la pregunta arriba y la respuesta correcta al pie. */
.tablero-ilustracion-info {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 28px;
    min-width: 320px;
    max-width: 40vw;
    overflow-y: auto;
}

/* Sin ilustración cargada el panel es solo texto: se le da el ancho que
   dejaba libre la imagen en lugar de quedar como una columna angosta. */
.tablero-ilustracion-panel--sin-imagen .tablero-ilustracion-info {
    min-width: min(640px, 80vw);
    max-width: 80vw;
}

.tablero-ilustracion-pregunta {
    color: #1a1a1a;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.3;
}

/* Las tarjetas de respuesta van juntas al pie de la columna: la correcta
   siempre, y debajo la que erró cuando la hubo. */
.tablero-ilustracion-respuestas {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tablero-ilustracion-respuesta {
    color: #fff;
    padding: 20px 24px;
    border-radius: 12px;
}

/* Los mismos verde y rojo con los que se marcan los botones de las opciones
   al contestar, para que el panel de cierre no estrene colores. */
.tablero-ilustracion-respuesta--correcta   { background: #27ae60; }
.tablero-ilustracion-respuesta--incorrecta { background: #e74c3c; }

.tablero-ilustracion-respuesta-label {
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    opacity: .85;
    margin-bottom: 8px;
}

.tablero-ilustracion-respuesta-texto {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.3;
}

/* En pantallas angostas el panel se apila: imagen arriba, texto abajo. */
@media (max-width: 900px) {
    .tablero-ilustracion-panel {
        flex-direction: column;
        gap: 20px;
        padding: 20px;
    }

    .tablero-ilustracion-img  { max-width: 100%; max-height: 45vh; }
    .tablero-ilustracion-info { max-width: 100%; min-width: 0; }
}

/* ============================================================
   Explorador DB (Herramientas > Explorador DB)
   ============================================================ */
.modal.db-exp-modal     { max-width: 1080px; width: calc(100% - 32px);
                          height: calc(100vh - 64px); max-height: calc(100vh - 64px);
                          display: flex; flex-direction: column; overflow: hidden; }
.db-exp-modal .modal-body { gap: 12px; flex: 1; min-height: 0;
                            display: flex; flex-direction: column; overflow: hidden; }

.db-exp-toolbar       { display: flex; align-items: center; justify-content: space-between;
                        gap: 12px; flex-wrap: wrap; }
.db-exp-toolbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.db-exp-toolbar-right .search-wrap .search-input { width: 220px; }

.db-exp-breadcrumbs   { display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
                        font-size: .88rem; color: var(--muted); min-height: 28px; }
.db-exp-crumb         { background: none; border: none; cursor: pointer;
                        color: var(--primary); font-size: .88rem; font-weight: 600;
                        padding: 2px 6px; border-radius: 6px; font-family: inherit;
                        display: inline-flex; align-items: center; gap: 6px; }
.db-exp-crumb:hover   { background: var(--bg); }
.db-exp-crumb.current { color: var(--text); cursor: default; }
.db-exp-crumb.current:hover { background: none; }
.db-exp-crumb-sep     { color: var(--muted); opacity: .6; }

.db-exp-view          { display: flex; flex-direction: column; gap: 8px;
                        flex: 1; min-height: 0; }

.db-exp-tabs          { display: flex; gap: 4px; border-bottom: 1px solid var(--border);
                        margin: 0 -4px; padding: 0 4px; flex-shrink: 0; }
.db-exp-tab           { background: none; border: none; cursor: pointer;
                        font-family: inherit; font-size: .85rem; font-weight: 600;
                        color: var(--muted); padding: 10px 14px;
                        border-bottom: 2px solid transparent; margin-bottom: -1px;
                        display: inline-flex; align-items: center; gap: 8px;
                        transition: color .15s, border-color .15s; }
.db-exp-tab:hover     { color: var(--text); }
.db-exp-tab.active    { color: var(--primary); border-bottom-color: var(--primary); }
.db-exp-tab i         { font-size: .9rem; }
.db-exp-tab-count     { display: inline-flex; align-items: center; justify-content: center;
                        min-width: 18px; height: 18px; padding: 0 6px; border-radius: 99px;
                        background: var(--bg); border: 1px solid var(--border);
                        color: var(--muted); font-size: .7rem; font-weight: 700; }
.db-exp-tab.active .db-exp-tab-count {
                        background: rgba(157,32,80,.18); color: var(--primary);
                        border-color: rgba(157,32,80,.4); }

.db-exp-tabpanel      { flex: 1; min-height: 0; display: flex; flex-direction: column;
                        padding-top: 8px; gap: 8px; }
.db-exp-tabpanel[hidden] { display: none; }

.db-exp-recs-toolbar       { display: flex; align-items: center; justify-content: space-between;
                             gap: 12px; flex-wrap: wrap; flex-shrink: 0; }
.db-exp-recs-toolbar-left  { display: flex; align-items: center; gap: 10px; }
.db-exp-recs-toolbar-right { display: flex; align-items: center; gap: 8px; }
.db-exp-recs-toolbar-right .search-wrap .search-input { width: 240px; }
.db-exp-limite-label       { display: inline-flex; align-items: center; gap: 8px;
                             font-size: .8rem; font-weight: 600; color: var(--muted); }
.db-exp-limite-label select{ padding: 6px 10px; font-size: .85rem; }

#dbExpViewTables .db-exp-table-card { flex: 1; min-height: 0; }
.db-exp-table-card           { overflow: auto; }
.db-exp-fill                 { flex: 1; min-height: 0; max-height: none; }
.db-exp-table-card thead tr  { background: var(--bg); position: sticky; top: 0; z-index: 1; }
.db-exp-table-card tbody tr.row-clickable       { cursor: pointer; }
.db-exp-table-card tbody tr.row-clickable:hover { background: var(--row-hover); }
.db-exp-table-card td        { vertical-align: top; }

.db-exp-nombre     { font-weight: 600; word-break: break-all; }
.db-exp-col-nombre { font-weight: 600; color: var(--text); word-break: break-all; }
.db-exp-coment     { font-size: .75rem; color: var(--muted); margin-top: 2px;
                     font-style: italic; }
.db-exp-num        { color: var(--muted); font-size: .82rem; font-family: monospace;
                     white-space: nowrap; text-align: right; }
.db-exp-mono       { font-family: monospace; font-size: .82rem; color: var(--text);
                     white-space: nowrap; }
.db-exp-recs-card td { font-family: monospace; font-size: .8rem;
                       max-width: 280px; overflow: hidden; text-overflow: ellipsis;
                       white-space: nowrap; }
.db-exp-recs-card td:hover { white-space: normal; word-break: break-all; }
.db-exp-null       { color: var(--muted); font-style: italic; font-family: monospace;
                     font-size: .78rem; }
.db-exp-pk-ico     { color: var(--warn); font-size: .8rem; margin-left: 4px; }

.db-exp-footer-info { font-size: .78rem; color: var(--muted);
                      display: flex; justify-content: space-between;
                      gap: 8px; flex-wrap: wrap; }
.db-exp-empty       { padding: 30px; text-align: center; color: var(--muted); }

.db-exp-cell-edit                 { cursor: text; }
.db-exp-cell-edit:hover           { outline: 1px solid var(--border); outline-offset: -1px;
                                    background: rgba(255,255,255,.03); }
.db-exp-cell-lock                 { cursor: not-allowed; color: var(--muted); }
.db-exp-cell-lock:hover           { background: transparent; }
.db-exp-cell-editing              { padding: 4px 6px !important; background: var(--bg);
                                    outline: 2px solid var(--primary); outline-offset: -2px;
                                    white-space: normal !important; max-width: none !important;
                                    overflow: visible !important; }
.db-exp-cell-saving               { opacity: .6; pointer-events: none; }
.db-exp-cell-ok                   { animation: dbExpCellOk .8s ease-out; }
@keyframes dbExpCellOk {
  0%   { background: rgba(34,197,94,.35); }
  100% { background: transparent; }
}
.db-exp-edit-wrap                 { display: flex; align-items: center; gap: 4px; }
.db-exp-edit-input                { flex: 1; min-width: 80px; padding: 4px 6px !important;
                                    font-family: monospace; font-size: .82rem !important;
                                    border-radius: 6px !important; }
.db-exp-edit-actions              { display: inline-flex; gap: 2px; flex-shrink: 0; }
.db-exp-edit-actions .btn-icon-sm { padding: 2px 6px; font-size: .8rem; }

.db-exp-badge-purple { background: rgba(139,92,246,.18); color: #c4b5fd; }

@media (max-width: 640px) {
    .db-exp-table-card th:nth-child(4),
    .db-exp-table-card td:nth-child(4),
    .db-exp-table-card th:nth-child(7),
    .db-exp-table-card td:nth-child(7) { display: none; }
}

/* ============================================================
   Portada SJM (San Juan al mundo)
   Editor de las bandas y fichas de la home de sanjuanalmundo.com.
   ============================================================ */
.psjm-hint { font-size: .82rem; color: var(--muted); }

.psjm-list { display: flex; flex-direction: column; gap: 16px; }

.psjm-seccion {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.psjm-seccion.psjm-oculta { opacity: .55; }

.psjm-seccion-head {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.psjm-seccion-info    { flex: 1; min-width: 0; }
.psjm-seccion-titulo  { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.psjm-seccion-nombre  { display: inline-flex; align-items: center; gap: 8px;
                        font-weight: 600; font-size: 1rem; color: var(--text); }
.psjm-seccion-nombre.psjm-sin-titulo { color: var(--muted); font-style: italic; font-weight: 500; }
.psjm-plus            { display: inline-flex; align-items: center; justify-content: center;
                        width: 18px; height: 18px; border: 1px solid var(--border);
                        border-radius: 4px; font-size: .8rem; color: var(--muted);
                        line-height: 1; }
.psjm-seccion-meta    { font-size: .78rem; color: var(--muted); margin-top: 3px;
                        overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.psjm-badges          { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.psjm-seccion-acciones { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.psjm-moves { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.psjm-move {
    width: 24px; height: 20px; border-radius: 5px; border: 1px solid var(--border);
    background: var(--bg); color: var(--muted); cursor: pointer;
    font-size: .62rem; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background .15s, color .15s;
}
.psjm-move:hover:not(:disabled) { background: var(--row-hover); color: var(--text); }
.psjm-move:disabled             { opacity: .3; cursor: not-allowed; }

/* Una banda puede tener varias filas encadenadas (secciones con
   `continuacion`): se muestran juntas dentro de la misma tarjeta. */
.psjm-filas { display: flex; flex-direction: column; gap: 14px; padding: 14px 16px; }
.psjm-fila  { display: flex; flex-direction: column; gap: 8px; }
.psjm-fila-head {
    display: flex; align-items: center; justify-content: space-between;
    border-top: 1px dashed var(--border); padding-top: 8px;
}
.psjm-fila:first-child .psjm-fila-head { border-top: none; padding-top: 0; }
.psjm-fila-label {
    font-size: .72rem; font-weight: 600; color: var(--muted);
    text-transform: uppercase; letter-spacing: .04em;
}

.psjm-boxes { display: grid; gap: 12px; }

.psjm-box {
    background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
    overflow: hidden; display: flex; flex-direction: column; min-width: 0;
}
.psjm-box.psjm-oculta { opacity: .5; }
.psjm-box-barra {
    background: var(--info); color: #fff; padding: 5px 10px;
    font-size: .78rem; font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.psjm-box-figura {
    height: 96px; background: #000; display: flex;
    align-items: center; justify-content: center; overflow: hidden;
    position: relative;
}
.psjm-box-figura img { width: 100%; height: 100%; object-fit: cover; display: block; }
.psjm-box-sinimagen  { font-size: .72rem; color: var(--muted); }
/* Rótulo del tipo sobre la miniatura: solo para foto y video, porque el box
   de artículo es el caso normal y no necesita distinguirse. */
.psjm-box-tipo {
    position: absolute; top: 5px; left: 5px;
    background: rgba(0,0,0,.7); color: #fff;
    font-size: .64rem; font-weight: 700; letter-spacing: .04em;
    text-transform: uppercase; padding: 2px 7px; border-radius: 99px;
}

.psjm-box-cuerpo { padding: 8px 10px 6px; flex: 1; min-width: 0; }
.psjm-box-titulo {
    font-size: .84rem; font-weight: 600; color: var(--text); line-height: 1.3;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}
.psjm-box-copete {
    font-size: .74rem; color: var(--muted); line-height: 1.35; margin-top: 4px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}
.psjm-box-avisos { display: flex; gap: 4px; flex-wrap: wrap; padding: 0 10px 6px; }
.psjm-box-avisos .badge { font-size: .66rem; padding: 1px 7px; }

.psjm-box-foot {
    display: flex; align-items: center; justify-content: space-between;
    padding: 4px 6px 4px 10px; border-top: 1px solid var(--border);
}
.psjm-box-id       { font-size: .72rem; color: var(--muted); font-family: monospace; }
.psjm-box-acciones { display: inline-flex; align-items: center; gap: 2px; }

.psjm-box-add {
    border: 1px dashed var(--border); border-radius: 8px; background: transparent;
    color: var(--muted); cursor: pointer; min-height: 120px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; font-size: .8rem; transition: border-color .15s, color .15s, background .15s;
}
.psjm-box-add:hover      { border-color: var(--primary); color: var(--text);
                           background: var(--row-hover); }
.psjm-box-add-icon       { font-size: 1.4rem; line-height: 1; }

/* Selector de artículo + preview del box.
   .modal-body ya separa sus hijos con gap:16px; el margen negativo pega la
   ayuda al campo que explica en vez de dejarla flotando entre los dos. */
.form-hint { font-size: .76rem; color: var(--muted); margin-top: -11px; }

/* Switch "buscar en toda la base" de la toolbar del selector de artículo. */
.psjm-switch-row   { display: flex; align-items: center; gap: 10px; }
.psjm-switch-label { font-size: .82rem; color: var(--muted); font-weight: 600; }

.psjm-pick-preview  { margin-bottom: 8px; }
.psjm-pick-vacio    { font-size: .82rem; color: var(--muted); font-style: italic; }
.psjm-pick-acciones { display: flex; gap: 8px; }

.psjm-pick-card {
    display: flex; gap: 12px; align-items: flex-start;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 8px; padding: 10px;
}
.psjm-pick-thumb {
    width: 96px; height: 72px; flex-shrink: 0; border-radius: 6px; overflow: hidden;
    background: #000; display: flex; align-items: center; justify-content: center;
}
.psjm-pick-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.psjm-pick-datos     { flex: 1; min-width: 0; }
.psjm-pick-titulo    { font-size: .88rem; font-weight: 600; color: var(--text); line-height: 1.3; }
.psjm-pick-meta      { font-size: .74rem; color: var(--muted); margin-top: 2px; }
.psjm-pick-copete    { font-size: .76rem; color: var(--muted); margin-top: 4px; line-height: 1.35;
                       display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
                       overflow: hidden; }
.psjm-pick-datos .psjm-box-avisos { padding: 6px 0 0; }

.psjm-pick-lista { display: flex; flex-direction: column; gap: 8px;
                   max-height: 52vh; overflow-y: auto; }
.psjm-pick-fila {
    display: flex; gap: 12px; align-items: flex-start; text-align: left;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 8px; padding: 10px; cursor: pointer; width: 100%;
    color: var(--text); transition: border-color .15s, background .15s;
}
.psjm-pick-fila:hover     { border-color: var(--primary); background: var(--row-hover); }
.psjm-pick-fila.is-actual { border-color: var(--primary); }

@media (max-width: 900px) {
    .psjm-boxes { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}
@media (max-width: 560px) {
    .psjm-boxes { grid-template-columns: 1fr !important; }
    .psjm-seccion-head { flex-wrap: wrap; }
}
