/* =========================================================================
   INGENIA neurología — Hoja de estilos
   Paleta: documento "COLORES LOGOTIPO" (Pantone oficial + muestreo del logo)
   Tipografía: Barlow (familia tipo DIN), alojada en /assets/fonts — OFL 1.1
   ========================================================================= */

/* ---------- Tipografía local (sin peticiones a terceros) ---------- */
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 300; font-display: swap; src: url('../fonts/barlow-latin-300.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/barlow-latin-400.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/barlow-latin-500.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/barlow-latin-600.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/barlow-latin-700.woff2') format('woff2'); }

/* ---------- Tokens de marca ---------- */
:root {
    /* Principales
       Donde el Pantone oficial y el logotipo en pantalla no coinciden, se usa
       el valor muestreado del logo para que la interfaz case con él. */
    --ing-verde:          #6B8F9C;   /* Pantone 2178 C (logo: #6D96A0) */
    --ing-verde-600:      #4F7280;   /* botones y enlaces — contraste AA con blanco */
    --ing-verde-700:      #3F5D69;
    --ing-verde-50:       #EEF3F5;
    --ing-amarillo:       #E5CB83;   /* logo · Pantone 617 C oficial: #C0B561 */
    --ing-amarillo-50:    #FBF6E8;
    --ing-gris:           #9D9A9B;   /* logo · 60 % de Pantone 445 C */
    --ing-beis:           #D9CDBD;   /* logo · Pantone 454 C oficial: #CAC7A7 */
    --ing-beis-50:        #F7F4F0;
    --ing-texto:          #505759;   /* Pantone 445 C — letras */
    --ing-texto-900:      #3A3F41;

    /* Secundarios */
    --ing-ocre:           #B58150;   /* Pantone 729 C — marrón ocre */
    --ing-ocre-700:       #8A5E35;   /* variante legible para texto */
    --ing-ocre-50:        #F8F0E7;
    --ing-gris-claro:     #E5E1E6;   /* Pantone 663 C */
    --ing-gris-claro-50:  #F3F1F4;
    --ing-gris-oscuro:    #898D8D;   /* Pantone 423 C */

    /* Semánticos */
    --bg:              #F7F6F4;
    --surface:         #FFFFFF;
    --border:          var(--ing-gris-claro);
    --text:            var(--ing-texto);
    --text-muted:      #676767;
    --primary:         var(--ing-verde-600);
    --primary-hover:   var(--ing-verde-700);
    --success:         #4F8A6B;
    --success-bg:      #EAF3EE;
    --danger:          #B4544A;
    --danger-bg:       #F8EBE9;
    --warning-bg:      var(--ing-ocre-50);

    /* Forma */
    --radius-sm: 8px;
    --radius:    14px;
    --radius-lg: 22px;
    --shadow-sm: 0 1px 2px rgba(80, 87, 89, .06);
    --shadow:    0 1px 3px rgba(80, 87, 89, .05), 0 10px 30px -12px rgba(80, 87, 89, .18);
    --ring:      0 0 0 4px rgba(107, 143, 156, .25);

    --font: 'Barlow', 'DIN Next', 'DIN 2014', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
    color: var(--text);
    background:
        radial-gradient(1200px 600px at 110% -10%, rgba(217, 205, 189, .45), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(107, 143, 156, .12), transparent 60%),
        var(--bg);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    margin: 0 0 .5em;
    color: var(--ing-texto-900);
    line-height: 1.2;
}
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.25rem); font-weight: 300; letter-spacing: .01em; }
h2 { font-size: 1.25rem; font-weight: 600; }

p { margin: 0 0 1em; }

a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); }

code {
    font-size: .9em;
    padding: .1em .4em;
    border-radius: 6px;
    background: var(--ing-beis-50);
    border: 1px solid var(--border);
}

::selection { background: rgba(229, 203, 131, .55); }

/* ---------- Cabecera de marca ---------- */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem;
}
.site-header .brand img {
    display: block;
    height: 56px;
    width: auto;
}
.site-header .badge {
    font-size: .8rem;
    font-weight: 500;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: .35rem .8rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, .7);
    border: 1px solid var(--border);
}

/* Franja de colores corporativos bajo la cabecera */
.brand-stripe {
    height: 4px;
    background: linear-gradient(90deg,
        var(--ing-verde) 0 25%,
        var(--ing-gris) 25% 50%,
        var(--ing-amarillo) 50% 75%,
        var(--ing-beis) 75% 100%);
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1.25rem 4rem;
}
.container--narrow { max-width: 640px; }

.page-title { margin-bottom: 1.75rem; }
.page-title p { color: var(--text-muted); margin: 0; }

/* ---------- Tarjetas ---------- */
.card,
main > div:not([class]) {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: clamp(1.25rem, 1rem + 1.5vw, 2rem);
    margin-bottom: 1.5rem;
}
.card > h2:first-child {
    display: flex;
    align-items: center;
    gap: .6rem;
}
.card > h2:first-child::before {
    content: "";
    width: 10px; height: 10px;
    border-radius: 0 10px 0 0;
    background: var(--ing-amarillo);
    flex: none;
}

/* ---------- Formularios ---------- */
form > div + div,
form > div + button { margin-top: 1.1rem; }

label {
    display: inline-block;
    margin-bottom: .4rem;
    font-weight: 500;
    font-size: .95rem;
    color: var(--ing-texto-900);
}

input[type="text"],
input[type="password"],
input[type="search"],
textarea,
select {
    width: 100%;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .7rem .9rem;
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
textarea { resize: vertical; min-height: 96px; }
select {
    appearance: none;
    padding-right: 2.5rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%23505759' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .9rem center;
    cursor: pointer;
}
input::placeholder, textarea::placeholder { color: var(--ing-gris-oscuro); }

input[type="text"]:hover, input[type="password"]:hover, input[type="search"]:hover, textarea:hover, select:hover { border-color: var(--ing-beis); }
input[type="text"]:focus, input[type="password"]:focus, input[type="search"]:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--ing-verde);
    box-shadow: var(--ring);
}

/* Campo de código (portal público) */
input#code {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: .18em;
    text-transform: uppercase;
}

/* ---------- Botones ---------- */
button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    font: inherit;
    font-weight: 600;
    letter-spacing: .01em;
    color: #fff;
    background: var(--primary);
    border: 1.5px solid transparent;
    border-radius: 999px;
    padding: .7rem 1.4rem;
    cursor: pointer;
    text-decoration: none;
    transition: background-color .2s var(--ease), transform .15s var(--ease), box-shadow .2s var(--ease), color .2s, border-color .2s;
}
button:hover, .btn:hover { background: var(--primary-hover); color: #fff; }
button:active { transform: translateY(1px); }
button:focus-visible, .btn:focus-visible { outline: none; box-shadow: var(--ring); }
button:disabled { opacity: .55; cursor: not-allowed; }

#btn-upload, form[action="download.php"] button { width: 100%; padding: .9rem 1.4rem; }

/* Fila "código + botón" en el portal */
.code-row { display: flex; gap: .6rem; }
.code-row input { flex: 1; }
.code-row button { flex: none; }

/* ---------- Avisos ---------- */
.alert {
    display: flex;
    gap: .75rem;
    align-items: flex-start;
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    border: 1px solid;
    margin-bottom: 1.5rem;
}
.alert p { margin: 0; }
.alert--error   { background: var(--danger-bg);  border-color: #EBCBC6; color: #7C352D; }
.alert--warning { background: var(--warning-bg); border-color: #EAD3BC; color: var(--ing-ocre-700); }
.alert::before {
    content: "!";
    flex: none;
    display: grid; place-items: center;
    width: 22px; height: 22px;
    border-radius: 50%;
    font-weight: 700; font-size: .8rem;
    color: #fff;
    background: currentColor;
}
.alert--error::before   { background: var(--danger); }
.alert--warning::before { background: var(--ing-ocre); }

/* Estado de subida (rellenado por JS) */
#upload-status:empty { display: none; }
#upload-status {
    margin: 1rem 0 0;
    padding: .8rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--ing-verde-50);
    color: var(--ing-verde-700);
    font-weight: 500;
}
#upload-status.is-success { background: var(--success-bg); color: #2F6248; }
#upload-status.is-error   { background: var(--danger-bg);  color: #7C352D; }
#upload-status.is-loading::before {
    content: "";
    display: inline-block;
    width: 14px; height: 14px;
    margin-right: .55rem;
    vertical-align: -2px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: ing-spin .8s linear infinite;
}

/* ---------- Ficha del documento (portal público) ---------- */
dl {
    display: grid;
    grid-template-columns: minmax(140px, max-content) 1fr;
    gap: .2rem 1.25rem;
    margin: 1rem 0 1.5rem;
}
dt {
    font-size: .85rem;
    font-weight: 500;
    color: var(--text-muted);
    padding: .65rem 0;
    border-top: 1px solid var(--border);
}
dd {
    margin: 0;
    padding: .65rem 0;
    border-top: 1px solid var(--border);
    font-weight: 500;
    word-break: break-word;
}
dd p { margin: 0; }
dt:first-of-type, dd:first-of-type { border-top: 0; }

/* ---------- Zona de arrastre (admin) ---------- */
#drop-zone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    min-height: 168px;
    padding: 1.75rem 1.25rem;
    text-align: center;
    border: 2px dashed var(--ing-beis);
    border-radius: var(--radius);
    background:
        linear-gradient(var(--ing-beis-50), var(--ing-beis-50)) padding-box;
    transition: border-color .2s var(--ease), background-color .2s var(--ease), transform .2s var(--ease);
    cursor: pointer;
}
#drop-zone:hover,
#drop-zone:focus-within {
    border-color: var(--ing-verde);
    background: var(--ing-verde-50);
}
#drop-zone p { margin: 0; color: var(--text-muted); font-size: .95rem; }
#drop-zone .dz-icon {
    width: 46px; height: 46px;
    margin-bottom: .35rem;
    border-radius: 50%;
    display: grid; place-items: center;
    background: #fff;
    border: 1px solid var(--border);
    color: var(--ing-verde);
    font-size: 1.6rem;
    font-weight: 300;
    line-height: 1;
}
#drop-zone .dz-file {
    margin-top: .5rem;
    padding: .35rem .8rem;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--border);
    font-weight: 600;
    font-size: .9rem;
    color: var(--ing-verde-700);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#drop-zone .dz-file:empty { display: none; }
#drop-zone.has-file { border-style: solid; border-color: var(--ing-verde); background: var(--ing-verde-50); }

/* El input real cubre toda la zona: clic en cualquier punto abre el selector */
#drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* ---------- Overlay de arrastre a pantalla completa ---------- */
.drop-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    background: rgba(63, 93, 105, .42);
    -webkit-backdrop-filter: blur(6px) saturate(120%);
    backdrop-filter: blur(6px) saturate(120%);
    opacity: 0;
    visibility: hidden;
    transition: opacity .22s var(--ease), visibility 0s linear .22s;
}
.drop-overlay.is-visible {
    opacity: 1;
    visibility: visible;
    transition: opacity .22s var(--ease), visibility 0s;
}
/* Solo el overlay recibe los eventos: evita parpadeos de dragleave */
.drop-overlay * { pointer-events: none; }

.drop-overlay__frame {
    position: absolute;
    inset: 18px;
    border: 3px dashed rgba(255, 255, 255, .65);
    border-radius: 28px;
}
.drop-overlay__content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    color: #fff;
    text-align: center;
    transform: scale(.92);
    transition: transform .3s var(--ease);
}
.drop-overlay.is-visible .drop-overlay__content { transform: scale(1); }

/* "+" translúcido: cada brazo con un color corporativo */
.drop-plus {
    position: relative;
    width: min(38vmin, 260px);
    aspect-ratio: 1;
    border-radius: 50%;
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .35);
    box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .35), inset 0 0 0 12px rgba(255, 255, 255, .06);
    animation: ing-pulse 1.8s var(--ease) infinite;
}
.drop-plus span {
    position: absolute;
    left: 50%; top: 50%;
    width: 13%;
    height: 30%;
    border-radius: 999px;
    opacity: .82;
    transform-origin: 50% 0;
}
.drop-plus span:nth-child(1) { background: var(--ing-verde);    transform: translateX(-50%) rotate(180deg); }
.drop-plus span:nth-child(2) { background: var(--ing-amarillo); transform: translateX(-50%) rotate(0deg); }
.drop-plus span:nth-child(3) { background: var(--ing-gris);   transform: translateX(-50%) rotate(90deg); }
.drop-plus span:nth-child(4) { background: var(--ing-beis);    transform: translateX(-50%) rotate(270deg); }
.drop-plus::after {          /* núcleo blanco que une los brazos */
    content: "";
    position: absolute;
    left: 50%; top: 50%;
    width: 13%; aspect-ratio: 1;
    border-radius: 50%;
    background: rgba(255, 255, 255, .9);
    transform: translate(-50%, -50%);
}

.drop-overlay__title { font-size: clamp(1.4rem, 1rem + 2vw, 2.2rem); font-weight: 300; margin: 0; color: #fff; }
.drop-overlay__hint  { margin: 0; opacity: .85; }

body.is-dragging { overflow: hidden; }

/* ---------- Tabla de documentos (admin) ---------- */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: .95rem;
}
thead th {
    position: sticky; top: 0;
    text-align: left;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--ing-beis-50);
    padding: .85rem .85rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody td {
    padding: .9rem .85rem;
    border-bottom: 1px solid var(--ing-gris-claro);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color .15s; }
tbody tr:hover { background: #FAF9FA; }

/* Código de descarga como "chip" */
tbody td:first-child strong {
    display: inline-block;
    font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
    font-weight: 600;
    font-size: .9rem;
    letter-spacing: .08em;
    padding: .25rem .55rem;
    border-radius: 6px;
    color: var(--ing-verde-700);
    background: var(--ing-verde-50);
    user-select: all;
}

#empty-row td {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

/* Cuenta regresiva */
.countdown {
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    white-space: nowrap;
}
.countdown.is-urgent  { color: var(--ing-ocre-700); }
.countdown.is-urgent::before {
    content: "";
    display: inline-block;
    width: 8px; height: 8px;
    margin-right: .45rem;
    border-radius: 50%;
    background: var(--ing-ocre);
    vertical-align: 1px;
}

/* Botón de estado (activo / inactivo) */
.btn-toggle {
    padding: .4rem .9rem;
    font-size: .85rem;
    font-weight: 600;
    white-space: nowrap;
}
.btn-toggle[data-active="1"] {
    color: #2F6248;
    background: var(--success-bg);
    border-color: #CFE3D7;
}
.btn-toggle[data-active="0"] {
    color: var(--text-muted);
    background: var(--ing-gris-claro-50);
    border-color: var(--border);
}
.btn-toggle::before {
    content: "";
    width: 8px; height: 8px;
    border-radius: 50%;
    background: currentColor;
}
.btn-toggle[data-active="1"]:hover { background: #DDEDE3; color: #2F6248; }
.btn-toggle[data-active="0"]:hover { background: var(--ing-gris-claro); color: var(--ing-texto-900); }

/* Botón eliminar */
.btn-delete {
    padding: .4rem .9rem;
    font-size: .85rem;
    color: var(--danger);
    background: transparent;
    border-color: #EBCBC6;
}
.btn-delete:hover { color: #fff; background: var(--danger); border-color: var(--danger); }

/* ---------- Layout del panel ---------- */
.admin-grid {
    display: grid;
    gap: 1.5rem;
}
.admin-grid > * { min-width: 0; }   /* permite que la tabla haga scroll dentro de su contenedor */
.section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}
.section-head h2 { margin: 0; }

/* Lista de instalación */
.log-list { list-style: none; margin: 0 0 1.5rem; padding: 0; }
.log-list li {
    padding: .7rem .9rem;
    border-left: 3px solid var(--ing-verde);
    background: var(--ing-beis-50);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: .5rem;
}

.site-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: .85rem;
    padding: 0 1.25rem 2rem;
}

/* ---------- Cabecera: acciones de sesión ---------- */
.header-actions { display: flex; align-items: center; gap: .75rem; }
.header-actions form { margin: 0; }
.btn-ghost {
    padding: .45rem 1rem;
    font-size: .9rem;
    color: var(--ing-texto);
    background: rgba(255, 255, 255, .7);
    border-color: var(--border);
}
.btn-ghost:hover { color: var(--ing-texto-900); background: #fff; border-color: var(--ing-gris-oscuro); }

/* ---------- Login ---------- */
.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
}
.login-card { width: 100%; max-width: 400px; text-align: center; }
.login-card form { text-align: left; }
.login-card h1 { font-size: 1.5rem; margin-bottom: .25rem; }
.login-logo { display: block; width: 150px; height: auto; margin: 0 auto 1rem; }
.login-sub { color: var(--text-muted); margin-bottom: 1.5rem; }
.login-card .alert { text-align: left; }
.btn-block { width: 100%; padding: .85rem 1.4rem; }
form > div + .btn-block { margin-top: 1.4rem; }

/* ---------- Zona de arrastre: ayuda de formatos ---------- */
#drop-zone .dz-hint {
    margin-top: .35rem;
    font-size: .8rem;
    color: var(--ing-gris-oscuro);
    letter-spacing: .02em;
}

/* ---------- Barra de progreso de subida ---------- */
.upload-progress {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-top: 1.1rem;
}
.upload-progress[hidden] { display: none; }
.upload-progress__track {
    flex: 1;
    height: 8px;
    border-radius: 999px;
    background: var(--ing-gris-claro);
    overflow: hidden;
}
.upload-progress__bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--ing-verde), var(--ing-amarillo));
    transition: width .2s linear;
}
.upload-progress__value {
    min-width: 3.2em;
    text-align: right;
    font-weight: 600;
    font-size: .9rem;
    font-variant-numeric: tabular-nums;
    color: var(--ing-verde-700);
}
form > .upload-progress + button { margin-top: 1.1rem; }

#upload-status { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
#upload-status .status-code {
    font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
    letter-spacing: .08em;
    padding: .1rem .5rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, .7);
}

/* ---------- Copiar código ---------- */
.code-cell { display: inline-flex; align-items: center; gap: .4rem; }
.btn-copy {
    padding: .25rem .65rem;
    font-size: .78rem;
    font-weight: 600;
    color: var(--ing-verde-700);
    background: transparent;
    border-color: var(--ing-gris-claro);
}
.btn-copy:hover { color: #fff; background: var(--ing-verde-600); border-color: var(--ing-verde-600); }
.btn-copy.is-copied,
.btn-copy.is-copied:hover { color: #2F6248; background: var(--success-bg); border-color: #CFE3D7; }

/* ---------- Tabla: detalles ---------- */
.section-count {
    white-space: nowrap;
    font-size: .85rem;
    font-weight: 500;
    color: var(--text-muted);
    padding: .25rem .75rem;
    border-radius: 999px;
    background: var(--ing-gris-claro-50);
    border: 1px solid var(--border);
}
.cell-description { min-width: 180px; max-width: 340px; overflow-wrap: anywhere; }
.cell-file { min-width: 160px; }
.cell-file__name { display: block; overflow-wrap: anywhere; }
.cell-file small {
    display: block;
    font-size: .78rem;
    color: var(--ing-gris-oscuro);
}

tbody tr.is-expired { background: var(--ing-gris-claro-50); }
tbody tr.is-expired td { color: var(--ing-gris-oscuro); }
tbody tr.is-expired .countdown { color: var(--danger); font-weight: 600; }

tbody tr.is-new { animation: ing-row-in 1.6s var(--ease); }
@keyframes ing-row-in {
    0%   { background: var(--ing-amarillo-50); }
    100% { background: transparent; }
}

/* ---------- Visor del log (modo debug) ---------- */
.btn-small { padding: .5rem 1rem; font-size: .88rem; }

.debug-badge {
    display: inline-block;
    margin-left: .4rem;
    padding: .1rem .5rem;
    border-radius: 6px;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .1em;
    vertical-align: middle;
    color: var(--ing-ocre-700);
    background: var(--ing-ocre-50);
    border: 1px solid #EAD3BC;
}
.log-intro { color: var(--text-muted); font-size: .9rem; margin: -.25rem 0 1rem; }

.log-levels { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.log-chip {
    padding: .3rem .8rem;
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .06em;
    color: var(--text-muted);
    background: #fff;
    border-color: var(--border);
}
.log-chip b {
    margin-left: .25rem;
    font-variant-numeric: tabular-nums;
}
.log-chip::before {
    content: "";
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--chip-color);
}
.log-chip--error   { --chip-color: var(--danger); }
.log-chip--warning { --chip-color: var(--ing-ocre); }
.log-chip--info    { --chip-color: var(--ing-verde); }
.log-chip--debug   { --chip-color: var(--ing-gris-oscuro); }
.log-chip:hover    { color: var(--ing-texto-900); background: var(--ing-gris-claro-50); }
.log-chip.is-active {
    color: var(--ing-texto-900);
    border-color: var(--chip-color);
    box-shadow: inset 0 0 0 1px var(--chip-color);
}

.log-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: .75rem 1rem;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius);
    background: var(--ing-gris-claro-50);
    border: 1px solid var(--border);
}
.log-toolbar > div + div { margin-top: 0; }
.log-field { display: flex; flex-direction: column; min-width: 140px; }
.log-field label { font-size: .8rem; margin-bottom: .3rem; color: var(--text-muted); }
.log-field select,
.log-field input { padding: .5rem .75rem; font-size: .9rem; }
.log-field select { padding-right: 2.2rem; }
.log-field--grow { flex: 1 1 220px; }
.log-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem; }
.log-auto {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin: 0;
    font-size: .88rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
}
.log-auto input { accent-color: var(--ing-verde-600); width: 16px; height: 16px; }

.log-feed {
    max-height: 560px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    transition: opacity .2s;
}
.log-panel.is-loading .log-feed { opacity: .6; }
.log-empty, .log-warning { margin: 0; padding: 1.5rem 1rem; text-align: center; color: var(--text-muted); }
.log-warning { color: #7C352D; background: var(--danger-bg); }

.log-entry { border-bottom: 1px solid var(--ing-gris-claro); border-left: 3px solid var(--entry-color, transparent); }
.log-entry:last-of-type { border-bottom: 0; }
.log-entry--error   { --entry-color: var(--danger);  background: #FDF7F6; }
.log-entry--warning { --entry-color: var(--ing-ocre); }
.log-entry--info    { --entry-color: var(--ing-verde); }
.log-entry--debug   { --entry-color: var(--ing-gris-claro); }

.log-entry__summary {
    display: grid;
    grid-template-columns: 70px 78px minmax(140px, 200px) 1fr auto;
    align-items: center;
    gap: .75rem;
    padding: .55rem .9rem;
    font-size: .88rem;
    cursor: pointer;
    list-style: none;
}
.log-entry__summary::-webkit-details-marker { display: none; }
.log-entry__summary:hover { background: var(--ing-gris-claro-50); }
.log-entry[open] > .log-entry__summary { background: var(--ing-verde-50); }
.log-entry__time { font-variant-numeric: tabular-nums; color: var(--text-muted); }
.log-entry__event {
    font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
    font-size: .8rem;
    color: var(--ing-verde-700);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.log-entry__msg { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-entry__ip  { font-size: .8rem; color: var(--ing-gris-oscuro); font-variant-numeric: tabular-nums; }
.log-entry--debug .log-entry__msg { color: var(--text-muted); }

.log-level {
    justify-self: start;
    padding: .1rem .45rem;
    border-radius: 5px;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .06em;
}
.log-level--error   { color: #fff; background: var(--danger); }
.log-level--warning { color: #fff; background: var(--ing-ocre-700); }
.log-level--info    { color: #fff; background: var(--ing-verde-600); }
.log-level--debug   { color: var(--ing-texto); background: var(--ing-gris-claro); }

.log-entry__body { padding: .5rem .9rem 1rem calc(.9rem + 70px + .75rem); }
.log-meta {
    grid-template-columns: max-content 1fr;
    gap: .15rem 1rem;
    margin: .25rem 0 .75rem;
    font-size: .85rem;
}
.log-meta dt, .log-meta dd { padding: .15rem 0; border: 0; }
.log-meta dt { font-size: .78rem; }
.log-meta dd { font-weight: 400; }
.log-link {
    padding: 0;
    font: inherit;
    font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
    font-size: .82rem;
    color: var(--ing-verde-600);
    background: none;
    border: 0;
    border-radius: 0;
    text-decoration: underline dotted;
    text-underline-offset: 3px;
}
.log-link:hover { color: var(--ing-verde-700); background: none; }
.log-context {
    margin: 0;
    padding: .8rem 1rem;
    max-height: 320px;
    overflow: auto;
    font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
    font-size: .8rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--ing-texto-900);
    background: var(--ing-beis-50);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

/* ---------- Animaciones ---------- */
@keyframes ing-spin  { to { transform: rotate(360deg); } }
@keyframes ing-pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.04); }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
    .site-header .brand img { height: 40px; }
    .site-header .badge { display: none; }

    .code-row { flex-direction: column; }

    dl { grid-template-columns: 1fr; gap: 0; }
    dd { border-top: 0; padding-top: 0; }

    /* La tabla se convierte en tarjetas */
    .table-wrap { border: 0; background: transparent; overflow: visible; }
    table, thead, tbody, tr, td { display: block; width: 100%; }
    thead { display: none; }
    tbody tr {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: .5rem 1rem;
        margin-bottom: .9rem;
        box-shadow: var(--shadow-sm);
    }
    tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
        padding: .55rem 0;
        border-bottom: 1px solid var(--ing-gris-claro);
        text-align: right;
        min-width: 0;
        overflow-wrap: anywhere;   /* nombres o descripciones largas sin espacios */
    }
    tbody td[data-label]::before {
        flex: none;
        content: attr(data-label);
        font-size: .75rem;
        font-weight: 600;
        letter-spacing: .06em;
        text-transform: uppercase;
        color: var(--text-muted);
        text-align: left;
    }

    /* En tarjetas, el ::before es la etiqueta: el aviso urgente se indica solo con el color */
    .countdown.is-urgent::before {
        content: attr(data-label);
        width: auto; height: auto;
        margin: 0;
        border-radius: 0;
        background: none;
        vertical-align: baseline;
    }
    .cell-description { min-width: 0; max-width: none; overflow-wrap: anywhere; }
    .cell-file { min-width: 0; }
    .cell-file__info { display: block; min-width: 0; text-align: right; }
    .cell-file small { margin-top: .1rem; }
    tbody tr.is-expired { background: var(--ing-gris-claro-50); }

    /* Visor de log */
    .log-panel .section-head h2 { flex: 1 1 100%; }
    .log-entry__summary > * { min-width: 0; }
    .log-meta dd { overflow-wrap: anywhere; }
    .log-toolbar { display: grid; grid-template-columns: 1fr 1fr; align-items: end; }
    .log-field { min-width: 0; }
    .log-field--grow,
    .log-actions { grid-column: 1 / -1; }
    .log-entry__summary { grid-template-columns: auto auto 1fr; gap: .35rem .6rem; }
    .log-entry__event { grid-column: 3; }
    .log-entry__msg { grid-column: 1 / -1; white-space: normal; }
    .log-entry__ip { display: none; }
    .log-entry__body { padding-left: .9rem; }
    .log-meta { grid-template-columns: 1fr; }
    .log-meta dd { padding-top: 0; }
}
