@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --rojo:         #C0392B;
    --rojo-hover:   #A93226;
    --rojo-light:   #FDF3F2;
    --rojo-border:  rgba(192,57,43,0.18);
    --rojo-glow:    rgba(192,57,43,0.10);
    --navy:         #1B2B3A;
    --navy-mid:     #243547;
    --navy-light:   #2D4259;
    --bg:           #F2F5F9;
    --bg-card:      #FFFFFF;
    --bg-hover:     #EDF1F7;
    --border:       #DDE3EC;
    --border-md:    #C8D0DC;
    --text-1:       #0D1B2A;
    --text-2:       #2C3E50;
    --text-3:       #5D7285;
    --text-4:       #96A8B8;
    --font:         'Inter', system-ui, sans-serif;
    --r-sm:         6px;
    --r-md:         10px;
    --r-lg:         14px;
    --shadow-xs:    0 1px 2px rgba(0,0,0,0.05);
    --shadow-sm:    0 2px 8px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:    0 4px 16px rgba(0,0,0,0.09), 0 1px 4px rgba(0,0,0,0.05);
    --shadow-lg:    0 12px 40px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-2);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.oculto { display: none !important; }

/* ─── SCROLLBAR ─────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-md); border-radius: 3px; }

/* ─── LOGIN ─────────────────────────────────── */
.pagina-login {
    display: flex;
    min-height: 100vh;
    background: var(--bg);
}

.login-marca {
    width: 420px;
    background: linear-gradient(160deg, var(--navy) 0%, var(--navy-mid) 50%, var(--navy-light) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
    position: relative;
    overflow: hidden;
}

.login-marca::before {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(192,57,43,0.2) 0%, transparent 70%);
    top: -100px; right: -100px;
}

.login-marca::after {
    content: '';
    position: absolute;
    width: 300px; height: 300px;
    background: radial-gradient(circle, rgba(192,57,43,0.12) 0%, transparent 70%);
    bottom: -80px; left: -80px;
}

.login-marca-logo {
    position: relative; z-index: 1;
    background: white;
    border-radius: var(--r-lg);
    padding: 20px 28px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 28px;
}

.login-marca-logo img { height: 56px; width: auto; display: block; }

.login-marca-text {
    position: relative; z-index: 1;
    text-align: center;
    color: rgba(255,255,255,0.85);
    font-size: 0.875rem;
    line-height: 1.7;
}

.login-marca-text strong {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: white;
    margin-bottom: 6px;
}

.login-form-side {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

.login-contenedor { width: 100%; max-width: 380px; }

.login-logo { display: none; }

.login-caja {
    background: var(--bg-card);
    border-radius: var(--r-lg);
    padding: 36px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-caja-titulo {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-1);
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.login-caja-sub {
    font-size: 0.825rem;
    color: var(--text-3);
    margin-top: -8px;
    margin-bottom: 4px;
}

.campo { display: flex; flex-direction: column; gap: 5px; }

.campo label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-3);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.campo input {
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    font-size: 0.9rem;
    font-family: var(--font);
    color: var(--text-1);
    background: var(--bg);
    outline: none;
    transition: all 0.15s;
}

.campo input:focus {
    border-color: var(--rojo);
    background: white;
    box-shadow: 0 0 0 3px var(--rojo-glow);
}

.texto-info { font-size: 0.85rem; color: var(--text-3); line-height: 1.6; }

/* ─── BOTONES ────────────────────────────────── */
.btn-primary {
    background: var(--rojo);
    color: white;
    border: none;
    padding: 11px;
    border-radius: var(--r-sm);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 2px 8px rgba(192,57,43,0.3);
    letter-spacing: 0.01em;
}
.btn-primary:hover { background: var(--rojo-hover); box-shadow: 0 4px 14px rgba(192,57,43,0.4); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { background: var(--text-4); box-shadow: none; cursor: not-allowed; transform: none; }

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-2);
    border: 1.5px solid var(--border-md);
    padding: 6px 12px;
    border-radius: var(--r-sm);
    font-size: 0.775rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { border-color: var(--rojo-border); color: var(--rojo); background: var(--rojo-light); }

.btn-logout {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
    border: 1px solid rgba(255,255,255,0.18);
    padding: 6px 14px;
    border-radius: var(--r-sm);
    font-size: 0.775rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s;
    font-family: var(--font);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-logout:hover { background: rgba(255,255,255,0.18); color: white; border-color: rgba(255,255,255,0.35); }

.btn-volver { color: var(--rojo); text-decoration: none; font-weight: 600; font-size: 0.875rem; }
.btn-volver:hover { text-decoration: underline; }

.btn-ver {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 11px;
    background: var(--bg-card);
    border: 1.5px solid var(--border-md);
    border-radius: var(--r-sm);
    font-size: 0.72rem; font-weight: 500;
    font-family: var(--font);
    color: var(--text-2);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    box-shadow: var(--shadow-xs);
}
.btn-ver:hover { border-color: var(--rojo-border); color: var(--rojo); background: var(--rojo-light); }

.btn-descargar {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 11px;
    background: var(--rojo);
    border: 1.5px solid var(--rojo);
    border-radius: var(--r-sm);
    font-size: 0.72rem; font-weight: 600;
    font-family: var(--font);
    color: white;
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(192,57,43,0.25);
}
.btn-descargar:hover { background: var(--rojo-hover); border-color: var(--rojo-hover); box-shadow: 0 2px 8px rgba(192,57,43,0.35); }

.enlace-recuperar { text-align: center; color: var(--rojo); font-size: 0.825rem; text-decoration: none; }
.enlace-recuperar:hover { text-decoration: underline; }

/* ─── MENSAJES ───────────────────────────────── */
.mensaje-error {
    background: #FEF2F2; color: #991B1B;
    padding: 10px 14px; border-radius: var(--r-md);
    font-size: 0.825rem; border-left: 3px solid #EF4444;
}
.mensaje-ok {
    background: #F0FDF4; color: #14532D;
    padding: 10px 14px; border-radius: var(--r-md);
    font-size: 0.825rem; border-left: 3px solid #22C55E;
}

/* ─── CABECERA ───────────────────────────────── */
.cabecera {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
    color: white;
    padding: 0 24px;
    position: sticky;
    top: 0; z-index: 100;
    box-shadow: 0 2px 16px rgba(0,0,0,0.2), 0 1px 0 rgba(255,255,255,0.04) inset;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.cabecera-contenido {
    display: flex;
    align-items: center;
    height: 58px;
    gap: 16px;
}

.cabecera h1 {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.cabecera-derecha {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

/* ─── LAYOUT ─────────────────────────────────── */
.layout {
    display: flex;
    height: calc(100vh - 58px);
    overflow: hidden;
}

/* ─── PANEL LATERAL ──────────────────────────── */
.panel-lateral {
    width: 240px;
    min-width: 240px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    box-shadow: 2px 0 12px rgba(0,0,0,0.04);
}

.lateral-busqueda { position: relative; }

.lateral-busqueda input {
    width: 100%;
    padding: 7px 10px 7px 32px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    font-size: 0.8rem;
    font-family: var(--font);
    color: var(--text-1);
    background: var(--bg);
    outline: none;
    transition: all 0.15s;
}
.lateral-busqueda input:focus { border-color: var(--rojo); background: white; box-shadow: 0 0 0 3px var(--rojo-glow); }

.lateral-busqueda::before {
    content: '';
    position: absolute;
    left: 10px; top: 50%;
    transform: translateY(-50%);
    width: 14px; height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2396A8B8' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    pointer-events: none;
}

.lateral-ordenar label, .lateral-filtros label {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-4);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: block;
    margin-bottom: 4px;
}

.lateral-ordenar select {
    width: 100%;
    padding: 6px 8px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    font-size: 0.78rem;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-2);
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s;
}
.lateral-ordenar select:focus { border-color: var(--rojo); }

.filtro-check {
    display: flex !important;
    align-items: center;
    gap: 7px;
    font-size: 0.775rem !important;
    color: var(--text-3) !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    font-weight: 400 !important;
    cursor: pointer;
}
.filtro-check input[type="checkbox"] { width: 13px; height: 13px; accent-color: var(--rojo); cursor: pointer; }

/* ─── ÁRBOL TIPOS ────────────────────────────── */
.arbol-tipos {
    display: flex; flex-direction: column; gap: 1px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
}

.arbol-item {
    padding: 6px 8px;
    border-radius: var(--r-sm);
    font-size: 0.775rem;
    color: var(--text-3);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.12s;
}
.arbol-item:hover { background: var(--bg-hover); color: var(--text-1); }
.arbol-item.activo { background: var(--rojo-light); color: var(--rojo); font-weight: 600; }

.arbol-count {
    background: var(--border);
    color: var(--text-4);
    font-size: 0.62rem;
    padding: 1px 7px;
    border-radius: 20px;
    font-weight: 700;
}
.arbol-item.activo .arbol-count { background: rgba(192,57,43,0.12); color: var(--rojo); }

/* ─── LISTA EQUIPOS ──────────────────────────── */
.lista-lateral {
    display: flex; flex-direction: column; gap: 1px;
    overflow-y: auto; flex: 1;
}

.equipo-lateral {
    padding: 8px 8px;
    border-radius: var(--r-sm);
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    gap: 9px;
    transition: all 0.12s;
    border: 1.5px solid transparent;
}
.equipo-lateral:hover { background: var(--bg-hover); }
.equipo-lateral.equipo-seleccionado {
    background: var(--rojo-light);
    border-color: var(--rojo-border);
    box-shadow: 0 1px 4px rgba(192,57,43,0.08);
}

.equipo-lateral-icono { font-size: 0.85rem; flex-shrink: 0; margin-top: 1px; opacity: 0.4; }
.equipo-lateral.equipo-seleccionado .equipo-lateral-icono { opacity: 1; }

.equipo-lateral-info { flex: 1; min-width: 0; }

.equipo-lateral-titulo {
    font-size: 0.775rem; font-weight: 600;
    color: var(--text-1); line-height: 1.3;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.equipo-lateral.equipo-seleccionado .equipo-lateral-titulo { color: var(--rojo); }

.equipo-lateral-detalle, .equipo-lateral-serie {
    font-size: 0.67rem; color: var(--text-4);
    margin-top: 1px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-family: 'SF Mono', 'Consolas', monospace;
}

.equipo-baja .equipo-lateral-titulo { color: var(--text-4); text-decoration: line-through; }

/* ─── PESTAÑAS LATERAL ───────────────────────── */
.pestanas {
    display: flex; gap: 2px;
    background: var(--bg);
    border-radius: var(--r-sm);
    padding: 2px;
    border: 1px solid var(--border);
}

.pestana {
    flex: 1; padding: 5px;
    border: none; border-radius: 4px;
    background: transparent;
    font-size: 0.72rem; font-weight: 600;
    font-family: var(--font);
    color: var(--text-4);
    cursor: pointer; transition: all 0.15s;
}
.pestana.activa { background: var(--bg-card); color: var(--text-1); box-shadow: var(--shadow-xs); }
.pestana:hover:not(.activa) { color: var(--text-2); }

.tab-contenido { display: flex; flex-direction: column; gap: 8px; }

/* ─── CONTENIDO PRINCIPAL ────────────────────── */
.contenido { flex: 1; padding: 22px 26px; overflow-y: auto; background: var(--bg); }

/* ─── BIENVENIDA ─────────────────────────────── */
.panel-bienvenida {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    height: 100%; text-align: center; gap: 10px;
}
.bienvenida-icono { font-size: 2rem; opacity: 0.15; }
.panel-bienvenida h2 { font-size: 1rem; color: var(--text-4); font-weight: 500; }
.panel-bienvenida p { font-size: 0.8rem; color: var(--text-4); max-width: 240px; line-height: 1.6; }

/* ─── CERT CABECERA ──────────────────────────── */
.cert-cabecera { margin-bottom: 14px; }

.cert-equipo-info h2 {
    font-size: 1.05rem; font-weight: 800;
    color: var(--text-1); letter-spacing: -0.02em;
}
.cert-subtitulo { font-size: 0.75rem; color: var(--text-3); margin-top: 3px; font-family: monospace; }

.cert-filtros {
    display: flex; flex-wrap: wrap; gap: 6px;
    align-items: center; margin-bottom: 12px;
}
.cert-filtros input {
    padding: 6px 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    font-size: 0.8rem; font-family: var(--font);
    color: var(--text-1); background: var(--bg-card);
    outline: none; transition: all 0.15s;
    box-shadow: var(--shadow-xs);
}
.cert-filtros input:focus { border-color: var(--rojo); box-shadow: 0 0 0 3px var(--rojo-glow); }
.cert-filtros input[type="text"] { width: 200px; }

/* ─── PESTAÑAS DOCUMENTOS ────────────────────── */
.doc-tabs {
    display: flex; gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 16px;
}

.doc-tab {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 9px 18px;
    border: none; background: transparent;
    font-size: 0.785rem; font-weight: 500;
    font-family: var(--font);
    color: var(--text-3);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
}
.doc-tab svg { width: 13px; height: 13px; }
.doc-tab.activa { color: var(--rojo); border-bottom-color: var(--rojo); font-weight: 600; }
.doc-tab:hover:not(.activa) { color: var(--text-1); }

/* ─── TABLA ──────────────────────────────────── */
.tabla-contenedor {
    background: var(--bg-card);
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.tabla-certificados { width: 100%; border-collapse: collapse; font-size: 0.8rem; }

.tabla-certificados thead {
    background: linear-gradient(180deg, #F5F7FA 0%, #EFF2F7 100%);
    border-bottom: 1px solid var(--border);
}

.tabla-certificados th {
    padding: 10px 14px; text-align: left;
    font-size: 0.68rem; font-weight: 700;
    color: var(--text-4);
    text-transform: uppercase; letter-spacing: 0.07em;
    white-space: nowrap;
}

.col-ordenable { cursor: pointer !important; user-select: none; }
.col-ordenable:hover { color: var(--text-2) !important; background: transparent !important; }

.tabla-certificados td {
    padding: 10px 14px;
    color: var(--text-2);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.tabla-certificados tbody tr { transition: background 0.1s; }
.tabla-certificados tbody tr:hover { background: #F8F0EF; }
.tabla-certificados tbody tr:last-child td { border-bottom: none; }

/* NÚMERO CERTIFICADO */
.cert-numero {
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 0.8rem; font-weight: 700;
    color: var(--text-1);
    background: #F0F3F8;
    padding: 3px 9px;
    border-radius: 5px;
    border: 1px solid var(--border);
    display: inline-block;
    letter-spacing: 0.02em;
}

/* ─── ACCIONES ───────────────────────────────── */
.acciones { display: flex; gap: 5px; align-items: center; }

/* ─── BADGES ─────────────────────────────────── */
.badge-ok {
    display: inline-flex; align-items: center; gap: 3px;
    background: #F0FDF4; color: #166534;
    border: 1px solid #BBF7D0;
    padding: 2px 8px; border-radius: 20px;
    font-size: 0.68rem; font-weight: 700;
}
.badge-ko {
    background: #FEF2F2; color: #991B1B;
    border: 1px solid #FECACA;
    padding: 2px 8px; border-radius: 20px;
    font-size: 0.68rem; font-weight: 700;
}
.sin-pdf { color: var(--text-4); font-size: 0.75rem; }
.badge-baja {
    background: #FEF2F2; color: #991B1B;
    font-size: 0.6rem; padding: 1px 5px;
    border-radius: 4px; font-weight: 700;
    margin-left: 4px; vertical-align: middle;
    border: 1px solid #FECACA;
}

/* ─── ESTADOS ────────────────────────────────── */
.cargando { text-align: center; padding: 40px; color: var(--text-4); font-size: 0.825rem; }
.sin-resultados {
    text-align: center; padding: 40px;
    color: var(--text-3); font-size: 0.825rem;
    background: var(--bg-card);
    border-radius: var(--r-md);
    border: 1px solid var(--border);
}

/* ─── MODAL PDF ──────────────────────────────── */
.modal-pdf {
    position: fixed; inset: 0;
    background: rgba(13,27,42,0.55);
    z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}
.modal-pdf.oculto { display: none !important; }

.modal-pdf-contenido {
    background: var(--bg-card);
    border-radius: var(--r-lg);
    width: 100%; max-width: 940px;
    height: 87vh;
    display: flex; flex-direction: column;
    overflow: hidden;
    box-shadow: 0 40px 100px rgba(0,0,0,0.25), 0 0 0 1px var(--border);
}

.modal-pdf-cabecera {
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #F5F7FA 0%, #EFF2F7 100%);
}

#modal-pdf-titulo { font-size: 0.8rem; font-weight: 600; color: var(--text-2); font-family: monospace; }

.modal-cerrar {
    background: var(--bg-card);
    border: 1.5px solid var(--border-md);
    color: var(--text-3);
    width: 28px; height: 28px;
    border-radius: var(--r-sm);
    cursor: pointer; font-size: 0.85rem;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s; box-shadow: var(--shadow-xs);
}
.modal-cerrar:hover { background: var(--rojo-light); border-color: var(--rojo-border); color: var(--rojo); }

.modal-pdf-contenido iframe { flex: 1; width: 100%; border: none; }

/* ─── RESPONSIVE ─────────────────────────────── */
@media (max-width: 768px) {
    .layout { flex-direction: column; height: auto; }
    .panel-lateral { width: 100%; min-width: 0; border-right: none; border-bottom: 1px solid var(--border); }
    .contenido { padding: 14px; }
    .cert-filtros input[type="text"] { width: 100%; }
    .tabla-certificados th:nth-child(4), .tabla-certificados td:nth-child(4) { display: none; }
    .login-marca { display: none; }
}
