:root {
  --bg: #070b16;
  --panel: #0d1324;
  --panel2: #111a30;
  --line: #202b46;
  --text: #f4f7ff;
  --muted: #8f9ab5;
  --blue: #4f7cff;
  --violet: #845cff;
  --cyan: #31d4c3;
  --green: #36d399;
  --amber: #f8b84e;
  --red: #ff6376;
  --shadow: 0 18px 50px rgba(0,0,0,.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; 
  min-height: 100%;
  background: radial-gradient(circle at 80% 0, #111a3b 0, transparent 34%), var(--bg);
  color: var(--text); 
  font-family: Inter, system-ui, sans-serif;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }


/* ========================================================
   1. PÁGINA DE LOGIN Y AUTENTICACIÓN
======================================================== */
.login-body, .install-body { 
  min-height: 100vh; 
  display: grid; 
  place-items: center; 
  padding: 30px; 
}

.login-shell { 
  width: min(980px, 100%); 
  display: grid; 
  grid-template-columns: 1.15fr 0.85fr; 
  border: 1px solid #253150; 
  border-radius: 26px; 
  overflow: hidden; 
  background: #0a1020; 
  box-shadow: 0 40px 100px rgba(0,0,0,0.45); 
}

.login-brand { 
  padding: 58px; 
  background: radial-gradient(circle at 20% 10%, rgba(79,124,255,0.22), transparent 36%), linear-gradient(145deg, #0e1730, #17143a); 
  display: flex; 
  align-items: center; 
  gap: 22px; 
}

.login-brand h1, .install-logo h1 { font-size: 42px; margin: 6px 0; }
.login-brand p { color: #a1acc8; line-height: 1.6; max-width: 420px; }

.login-card { 
  padding: 50px 44px; 
  background: #0a1020;
}

.login-card h2 { font-size: 28px; margin: 30px 0 5px; color: #fff; }

.login-card form { 
  display: flex; 
  flex-direction: column; 
  gap: 10px; 
  margin-top: 24px; 
}

.login-card label { 
  font-size: 11px; 
  color: #a4aec7; 
  font-weight: 700; 
  margin-top: 5px; 
}

.login-card input { 
  background: #080e1c; 
  border: 1px solid #263151; 
  color: #fff; 
  border-radius: 11px; 
  padding: 13px; 
  width: 100%;
  outline: none;
}

.login-card input:focus {
  border-color: var(--blue);
}

.login-foot { text-align: center; color: #58647f; font-size: 10px; margin-top: 20px; }
.mobile-brand { display: none; }


/* ========================================================
   2. LAYOUT PRINCIPAL DEL PANEL
======================================================== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px; 
  background: rgba(9,14,28,.96); 
  border-right: 1px solid var(--line);
  padding: 18px 14px; 
  position: fixed; 
  inset: 0 auto 0 0; 
  display: flex; 
  flex-direction: column; 
  z-index: 20; 
  overflow-y: auto;
}

.logo { display: flex; align-items: center; gap: 11px; font-weight: 800; font-size: 18px; padding: 4px 8px 16px; }
.logo b, .login-brand h1 span, .install-logo h1 span { color: #8f74ff; }

.brand-mark {
  display: grid; place-items: center; width: 58px; height: 58px; border-radius: 18px;
  background: linear-gradient(135deg, var(--blue), var(--violet)); box-shadow: 0 12px 30px rgba(95,79,255,.35);
  font-weight: 800; font-size: 28px; color: #fff;
}
.brand-mark.small { width: 36px; height: 36px; border-radius: 12px; font-size: 16px; }

.sidebar nav { display: grid; gap: 4px; flex-shrink: 0; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: #9da8c3; font-weight: 600; font-size: 13px; }
.nav-item:hover { background: #111b31; color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(79,124,255,.2), rgba(132,92,255,.12)); color: #fff; border: 1px solid rgba(110,111,255,.28); }
.nav-icon { width: 22px; text-align: center; font-size: 16px; }

.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 6px 4px; flex-shrink: 0; }
.mini-user { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.mini-user div:last-child { min-width: 0; }
.mini-user strong, .mini-user small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-user small { color: var(--muted); font-size: 11px; margin-top: 2px; }

.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: #1d2946; color: #cbd7ff; font-weight: 800; }
.avatar.big { width: 42px; height: 42px; border: 1px solid #2a395e; }

.link-btn { background: none; border: 0; color: #ff8c9a; padding: 5px 0; font-weight: 700; font-size: 12px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

.main { margin-left: 260px; min-width: 0; flex: 1; }

.topbar { 
  height: 88px; display: flex; align-items: center; justify-content: space-between; 
  padding: 0 34px; border-bottom: 1px solid rgba(32,43,70,.7); background: rgba(7,11,22,.65); 
  backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 10; 
}

.topbar > div:first-of-type { flex: 1; }
.topbar h1 { margin: 2px 0 0; font-size: 22px; }
.eyebrow { font-size: 10px; letter-spacing: .18em; font-weight: 800; color: #7180a4; }

.top-actions { display: flex; align-items: center; gap: 12px; }
.credit-chip { display: flex; gap: 12px; align-items: center; background: #10182a; border: 1px solid var(--line); border-radius: 12px; padding: 9px 13px; }
.credit-chip span { font-size: 11px; color: var(--muted); }
.credit-chip strong { font-size: 14px; color: #fff; }
.menu-btn { display: none; background: #111b31; border: 1px solid var(--line); color: #fff; border-radius: 10px; width: 40px; height: 40px; }


/* ========================================================
   3. CONTENEDOR CENTRAL
======================================================== */
.content { padding: 28px 34px 60px; width: 100%; max-width: 1200px; margin-left: auto; margin-right: auto; }
.footer { padding: 0 34px 24px; color: #5f6b89; font-size: 12px; width: 100%; max-width: 1200px; margin-left: auto; margin-right: auto; }


/* ========================================================
   4. COMPONENTES Y ELEMENTOS
======================================================== */
.hero { display: flex; justify-content: space-between; align-items: center; padding: 26px 28px; border: 1px solid #283254; border-radius: 22px; background: linear-gradient(120deg, rgba(79,124,255,.13), rgba(132,92,255,.12) 45%, rgba(13,19,36,.8)); box-shadow: var(--shadow); margin-bottom: 22px; }
.hero h2 { font-size: 28px; margin: 5px 0 6px; }
.hero p { margin: 0; color: var(--muted); }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card { display: flex; align-items: center; gap: 15px; background: var(--panel); border: 1px solid var(--line); border-radius: 17px; padding: 19px; }
.stat-card small, .stat-card strong { display: block; }
.stat-card small { color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.stat-card strong { font-size: 24px; }
.stat-icon { display: grid; place-items: center; width: 43px; height: 43px; border-radius: 13px; background: rgba(132,92,255,.15); color: #a992ff; font-size: 20px; }
.stat-icon.amber { background: rgba(248,184,78,.13); color: var(--amber); }
.stat-icon.blue { background: rgba(79,124,255,.14); color: #7ea0ff; }
.stat-icon.green { background: rgba(54,211,153,.13); color: var(--green); }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
.card { background: linear-gradient(180deg, rgba(14,21,39,.96), rgba(11,17,32,.96)); border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: 0 10px 35px rgba(0,0,0,.16); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; margin-bottom: 18px; }
.card-head.wrap { flex-wrap: wrap; }
.card h3, .card-head h3 { margin: 0 0 5px; font-size: 17px; }
.card p, .card-head p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.text-link { font-size: 12px; color: #97adff; font-weight: 700; }

.table-wrap { overflow: auto; margin: 0 -8px; }
.table-wrap table { width: 100%; border-collapse: collapse; min-width: 640px; }
.table-wrap th { text-align: left; color: #6f7b98; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table-wrap td { padding: 13px 12px; border-bottom: 1px solid rgba(32,43,70,.7); font-size: 12px; vertical-align: middle; }
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap td strong, .table-wrap td small { display: block; }
.table-wrap td small { font-size: 10px; color: var(--muted); margin-top: 3px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .03em; }

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 6px 9px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.badge.success { background: rgba(54,211,153,.12); color: #66e4b4; }
.badge.warning { background: rgba(248,184,78,.13); color: #ffc966; }
.badge.info { background: rgba(79,124,255,.14); color: #8aa8ff; }
.badge.danger { background: rgba(255,99,118,.14); color: #ff8c9a; }
.badge.muted { background: #182033; color: #8c97b1; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 11px; padding: 11px 16px; font-weight: 700; font-size: 13px; color: #fff; }
.btn.primary { background: linear-gradient(135deg, var(--blue), var(--violet)); box-shadow: 0 9px 24px rgba(82,86,255,.24); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.large { padding: 14px 18px; font-size: 14px; }
.btn.full { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.tiny-btn { background: #15203a; border: 1px solid #2a385d; color: #aebadd; border-radius: 8px; padding: 5px 8px; font-size: 9px; }
.tiny-btn.danger { color: #ff9aa5; border-color: #60313b; background: #24141c; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.field { display: grid; gap: 7px; }
.span-2 { grid-column: span 2; }
.field label { font-size: 11px; font-weight: 700; color: #a5afc8; }
.field small { color: #65718e; font-size: 10px; }
.field input, .field select, .field textarea { width: 100%; background: #090f1f; border: 1px solid #263150; color: #f6f8ff; border-radius: 11px; padding: 12px 13px; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #5d7dff; box-shadow: 0 0 0 3px rgba(79,124,255,.10); }
.field textarea { resize: vertical; }
.mac-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 18px !important; letter-spacing: .08em; }

.cost-box { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; background: #0a1121; border: 1px solid var(--line); border-radius: 13px; padding: 14px; }
.cost-box div { display: flex; justify-content: space-between; gap: 10px; }
.cost-box span { font-size: 11px; color: var(--muted); }
.cost-box strong { font-size: 12px; }

.alert { border-radius: 11px; padding: 11px 13px; margin-bottom: 14px; font-size: 12px; }
.alert.success { background: rgba(54,211,153,.1); border: 1px solid rgba(54,211,153,.24); color: #80e7bd; }
.alert.error { background: rgba(255,99,118,.1); border: 1px solid rgba(255,99,118,.24); color: #ff98a4; }
.alert.info { background: rgba(79,124,255,.1); border: 1px solid rgba(79,124,255,.22); color: #a4b8ff; }
.empty { text-align: center !important; color: #65708c !important; padding: 30px !important; }
.subtle { color: var(--muted) !important; }
.error-text { color: #ff8d9a !important; }

.queue-table td[data-label="Estado"]{min-width:132px}
.job-actions{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin-top:7px}
.job-actions .inline-form{margin:0}
.job-actions .tiny-btn{min-height:28px;padding:6px 10px;font-size:10px;font-weight:800}
.job-actions .tiny-btn.danger{background:rgba(255,99,118,.09);border-color:rgba(255,99,118,.34);color:#ff9aa5}

/* ========================================================
   5. RESPONSIVO Y ZOOM PARA PC / LAPTOPS
======================================================== */
@media (min-width: 1101px) {
  body { zoom: 0.85; }
}

@media(max-width:1100px){
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media(max-width:760px){
  .sidebar { transform: translateX(-100%); transition: .22s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-btn { display: block; }
  .topbar { height: 76px; padding: 0 16px; gap: 12px; }
  .topbar .eyebrow { display: none; }
  .topbar h1 { font-size: 18px; }
  .credit-chip span { display: none; }
  
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-card { padding: 32px 24px; }
  .mobile-brand { display: flex; align-items: center; gap: 10px; }
  
  .hero { padding: 20px; align-items: flex-start; gap: 18px; flex-direction: column; }
  .hero h2 { font-size: 22px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
}

@media(max-width:430px){
  .stats-grid { grid-template-columns: 1fr; }
  .top-actions .avatar { display: none; }
}

/* ========================================================
   6. VERSIÓN MÓVIL DEFINITIVA: TEMA "CELESTE & AMARILLO NEÓN"
   CERO DESBORDES, TEXTOS ENCAPSULADOS, LOGIN EXCLUSIVO
======================================================== */
@media (max-width: 1024px) {

    /* --- Animaciones --- */
    @keyframes bgGreyFlow {
        0% { background-position: 0% 50%; }
        50% { background-position: 100% 50%; }
        100% { background-position: 0% 50%; }
    }

    @keyframes neonLavaPulse {
        0%   { box-shadow: 0 0 6px #ffff00, inset 0 0 3px #ffff00; border-color: #ffff00; } /* Amarillo */
        50%  { box-shadow: 0 0 10px #00d2ff, inset 0 0 5px #00d2ff; border-color: #00d2ff; } /* Celeste */
        100% { box-shadow: 0 0 6px #ffff00, inset 0 0 3px #ffff00; border-color: #ffff00; } /* Amarillo */
    }

    /* --- Animación Exclusiva Login Móvil (Agua, Celeste, Rojo, Naranja) --- */
    @keyframes loginNeonLava {
        0%   { box-shadow: 0 0 8px #31d4c3, inset 0 0 4px #31d4c3; border-color: #31d4c3; } 
        33%  { box-shadow: 0 0 12px #00d2ff, inset 0 0 6px #00d2ff; border-color: #00d2ff; } 
        66%  { box-shadow: 0 0 8px #ff0000, inset 0 0 4px #ff0000; border-color: #ff0000; } 
        100% { box-shadow: 0 0 12px #ff7300, inset 0 0 6px #ff7300; border-color: #ff7300; } 
    }

    /* --- 1. BLOQUEO DE DESBORDE SEGURO --- */
    html, body, .app-shell, .main {
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important; 
    }

    .mono { 
        word-break: break-all !important; 
    }

    /* --- 2. TEMA GRIS OSCURO Y CELESTE (Páginas internas) --- */
    html, body {
        font-size: 16px !important; 
        background: linear-gradient(315deg, #121212, #242424, #1a1a1a, #2c2c2c) !important;
        background-size: 200% 200% !important;
        animation: bgGreyFlow 15s ease infinite !important;
        color: #ffffff !important; 
    }

    /* --- 3. FONDO EXCLUSIVO DE LOGIN EN MÓVILES --- */
    body.login-body {
        background: url('https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRXtR58YJLRDFwj9GtLuAMRUx2DFeAZSNWSCWPqB96FBFU0zls7CP0PEJ8&s=10') no-repeat center center fixed !important;
        background-size: cover !important;
        animation: none !important; /* Desactiva el fondo gris interno aquí */
    }

    /* Estilos Exclusivos para la Tarjeta de Login (Transparencia y Neón 4 colores) */
    .login-shell {
        border: 2px solid #31d4c3 !important;
        animation: loginNeonLava 8s infinite alternate !important;
        background: rgba(10, 16, 32, 0.75) !important; /* Cristal oscuro */
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
    }
    
    .login-card {
        background: transparent !important; /* Deja ver el efecto cristal */
    }

    .content { 
        padding: 15px 12px 90px !important; 
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* --- 4. MENÚ LATERAL Y TOPBAR --- */
    .topbar {
        padding: 0 15px !important;
        width: 100% !important;
    }

    .topbar .menu-btn {
        display: grid !important;
        place-items: center !important;
        width: 45px !important;
        height: 45px !important;
        flex: 0 0 45px !important; 
        min-width: 45px !important;
        background: #2a2a2a !important;
        border: 1px solid #00d2ff !important;
        color: #00d2ff !important;
        border-radius: 8px !important;
        padding: 0 !important;
        margin-right: auto !important;
    }

    .sidebar { background: #1a1a1a !important; border-right: 1px solid #333 !important; }
    .sidebar nav .nav-item { font-size: 16px !important; padding: 14px 18px !important; color: #e0e0e0 !important; }
    .sidebar nav .nav-item.active { background: rgba(0, 210, 255, 0.1) !important; border-left: 3px solid #00d2ff !important; color: #fff !important;}
    .sidebar nav .nav-item .nav-icon { color: #00d2ff !important; text-shadow: 0 0 10px #00d2ff !important; }

    /* --- 5. CONVERSIÓN DE CUADRÍCULAS --- */
    .grid-2, .hero-grid, .form-grid, .stats-grid {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        gap: 15px !important;
    }

    /* --- 6. TARJETAS INTERNAS Y CONTENEDORES (GRIS CON NEÓN AMARILLO/CELESTE) --- */
    .card, .welcome-card, .clock-card, .stat-card, .cost-box {
        background: #1f1f1f !important;
        border: 1px solid #333 !important;
        border-radius: 16px !important;
        width: 100% !important;
        padding: 20px 15px !important;
        margin-bottom: 0 !important; 
        animation: neonLavaPulse 6s infinite alternate !important; 
        box-sizing: border-box !important;
    }

    h1, h2, h3, h4 { color: #ffffff !important; }
    p, label, span, div, small { color: #e0e0e0 !important; }
    .text-link, .eyebrow { color: #00d2ff !important; }

    .badge, .badge.info, .badge.primary, .badge.success, .badge.warning {
        background: rgba(0, 210, 255, 0.15) !important;
        color: #00d2ff !important;
        border: 1px solid #00d2ff !important;
        display: inline-block !important; 
        width: fit-content !important;
    }

    input, select, textarea {
        font-size: 16px !important;
        padding: 14px 15px !important;
        background: #2a2a2a !important;
        color: #ffffff !important;
        border: 1px solid #555 !important;
        border-radius: 10px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    input:focus, select:focus {
        border-color: #00d2ff !important;
        box-shadow: 0 0 8px rgba(0, 210, 255, 0.4) !important;
    }

    button, .btn {
        border-radius: 10px !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        font-weight: 800 !important;
        width: 100% !important; 
        padding: 14px !important;
        box-sizing: border-box !important;
    }
    .btn.primary {
        background: #00d2ff !important; 
        color: #000000 !important;
        border: none !important;
        box-shadow: 0 4px 15px rgba(0, 210, 255, 0.3) !important;
    }

    /* --- 7. TABLAS DE TODOS LOS MÓDULOS (AUDITORÍA INCLUIDA) --- */
    .table-wrap {
        width: 100% !important;
        overflow-x: hidden !important; 
        max-height: 480px !important; 
        overflow-y: auto !important;  
        -webkit-overflow-scrolling: touch;
        margin: 0 !important;
        background: transparent !important;
        padding-right: 5px !important; 
        box-sizing: border-box !important;
    }
    
    .table-wrap::-webkit-scrollbar { width: 4px !important; }
    .table-wrap::-webkit-scrollbar-track { background: rgba(255,255,255,0.05) !important; }
    .table-wrap::-webkit-scrollbar-thumb { background: #00d2ff !important; border-radius: 10px; }

    .table-wrap th { display: none !important; }
    
    .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td, 
    .card table, .card tbody, .card tr, .card td {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .table-wrap tr, .card table tr {
        background: #232323 !important; 
        border-radius: 14px !important;
        margin-bottom: 15px !important;
        padding: 15px !important;
        animation: neonLavaPulse 6s infinite alternate !important; 
        border: 1px solid #333 !important;
        border-left: 4px solid #00d2ff !important; 
    }

    .table-wrap td, .card table td {
        padding: 5px 0 !important;
        border-bottom: none !important;
        display: flex !important;
        flex-direction: column !important; 
        align-items: flex-start !important;
        text-align: left !important;
        font-size: 14px !important;
        background: transparent !important; 
    }

    .table-wrap td strong, .card table td strong { color: #ffffff !important; font-size: 15px !important; } 
    .table-wrap td small, .card table td small { color: #cccccc !important; font-size: 13px !important;}   

    .table-wrap td:last-child, .card table td:last-child {
        margin-top: 10px !important;
        padding-top: 12px !important;
        border-top: 1px solid #333 !important; 
        flex-direction: row !important;
        flex-wrap: wrap !important;
        width: 100% !important;
    }

    .table-wrap td .inline-form {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
        width: 100% !important;
        justify-content: space-between !important;
    }
    
    .table-wrap td .inline-form input[type="password"] {
        flex: 0 1 80px !important; 
        min-width: 60px !important;
        padding: 10px 5px !important;
        text-align: center !important;
        height: auto !important; 
    }
    
    .table-wrap td .btnEdit, 
    .table-wrap td .danger,
    .tiny-btn {
        flex: 1 1 auto !important; 
        padding: 10px !important;
        font-size: 13px !important;
        border-radius: 8px !important;
        width: auto !important;
    }
    
    .tiny-btn {
        background: #2a2a2a !important;
        border: 1px solid #00d2ff !important;
        color: #00d2ff !important;
    }
    .tiny-btn.danger {
        background: #3a1515 !important;
        color: #ff4d4d !important;
        border: 1px solid #ff4d4d !important;
    }
}