/* Centinela: base visual del panel de webhook.omniprit.com, sin fuentes externas
   (la CSP no deja cargar nada de fuera) y con modo oscuro. */
:root {
    --primary: #0047FF;
    --primary-dark: #0033CC;
    --primary-light: #3B82F6;
    --sidebar-bg: #07102B;
    --sidebar-hover: #0D1F4A;
    --sidebar-active: #0047FF;
    --surface: #FFFFFF;
    --surface-2: #F5F7FF;
    --surface-3: #EEF2FF;
    --surface-head: #F8FAFC;
    --border: #E2E8F0;
    --text: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    /* Niveles: fondo / texto */
    --ok-bg: #ECFDF5;       --ok-fg: #047857;
    --info-bg: #F1F5F9;     --info-fg: #475569;
    --medio-bg: #FFFBEB;    --medio-fg: #B45309;
    --alto-bg: #FFF1E6;     --alto-fg: #C2410C;
    --critico-bg: #FEF2F2;  --critico-fg: #B91C1C;
    --azul-bg: #EEF2FF;     --azul-fg: #0047FF;
    --radius: 4px;
    --radius-sm: 2px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 10px 40px rgba(0,0,0,.1);
    --transition: .2s cubic-bezier(.4,0,.2,1);
    --mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary: #4D7CFF;
        --primary-dark: #3B6BFF;
        --primary-light: #7FA2FF;
        --sidebar-bg: #050B1E;
        --surface: #111827;
        --surface-2: #0B1120;
        --surface-3: #1A2540;
        --surface-head: #162033;
        --border: #263247;
        --text: #E5E9F2;
        --text-secondary: #A9B4C7;
        --text-muted: #6B7A93;
        --ok-bg: #0B2B22;       --ok-fg: #5EE0B0;
        --info-bg: #1C2536;     --info-fg: #A9B4C7;
        --medio-bg: #2E2410;    --medio-fg: #F6C35B;
        --alto-bg: #33200F;     --alto-fg: #FF9B5C;
        --critico-bg: #361318;  --critico-fg: #FF8A8A;
        --azul-bg: #16234A;     --azul-fg: #8FB0FF;
        --shadow: 0 1px 3px rgba(0,0,0,.4);
        --shadow-md: 0 10px 40px rgba(0,0,0,.5);
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--surface-2);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
code, .mono { font-family: var(--mono); font-size: .8rem; }

.icon { width: 16px; height: 16px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Toasts */
.toast-wrap { position: fixed; top: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 9999; pointer-events: none; }
.toast {
    background: var(--surface); color: var(--text); border-radius: var(--radius); border: 1px solid var(--border);
    border-left: 4px solid var(--primary); padding: 14px 20px; box-shadow: var(--shadow-md); font-size: .85rem; font-weight: 600;
    min-width: 280px; max-width: 460px; pointer-events: auto; transform: translateY(-20px); opacity: 0;
    animation: slideIn var(--transition) forwards; transition: opacity var(--transition);
}
.toast-success { border-left-color: var(--success); }
.toast-danger { border-left-color: var(--danger); }
@keyframes slideIn { to { transform: translateY(0); opacity: 1; } }

/* Botones */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; border-radius: var(--radius);
    font-size: .875rem; font-weight: 600; cursor: pointer; font-family: inherit; border: none; transition: var(--transition);
    text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--surface-3); color: var(--primary); }
.btn-secondary:hover:not(:disabled) { filter: brightness(.96); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(.9); }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-block { width: 100%; padding: 13px; font-size: .95rem; margin-top: 8px; }

/* Tarjetas */
.card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); padding: 22px 24px; box-shadow: var(--shadow); margin-bottom: 20px; min-width: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-title { font-size: 1.02rem; font-weight: 700; color: var(--text); }
.card-sub { font-size: .8rem; color: var(--text-muted); }

/* Login */
.login-screen { min-height: 100vh; display: flex; align-items: stretch; background: var(--surface); }
.login-left {
    flex: 1; background: var(--sidebar-bg); display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 60px; position: relative; overflow: hidden;
}
.login-left::before {
    content: ''; position: absolute; width: 600px; height: 600px; background: radial-gradient(circle, rgba(0,71,255,.25) 0%, transparent 70%);
    top: 50%; left: 50%; transform: translate(-50%, -50%); pointer-events: none;
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; position: relative; z-index: 1; }
.login-brand h1 { color: #fff; font-size: 2.2rem; font-weight: 800; letter-spacing: -0.5px; }
.login-brand h1 span { color: #7FA2FF; }
.login-tagline { color: rgba(255,255,255,.6); font-size: .95rem; max-width: 420px; line-height: 1.6; }
.login-server { color: rgba(255,255,255,.85); font-family: var(--mono); font-size: .85rem; padding: 6px 14px; border: 1px solid rgba(255,255,255,.15); border-radius: 99px; }
.login-right { width: 480px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 56px; background: var(--surface); }
.login-form-wrap { width: 100%; }
.login-form-wrap h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 6px; }
.login-form-wrap p { color: var(--text-muted); font-size: .875rem; margin-bottom: 24px; }
.login-qr { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 18px; }
.login-qr img { width: 200px; height: 200px; background: #fff; padding: 8px; border-radius: var(--radius); border: 1px solid var(--border); }
.login-secret-ayuda { font-size: .8rem; text-align: center; color: var(--text-muted); }
.login-secret { font-family: var(--mono); font-size: .85rem; word-break: break-all; text-align: center; color: var(--text); }
.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; font-family: inherit; font-size: .85rem; margin-top: 14px; }
.input.codigo { font-family: var(--mono); font-size: 1.4rem; letter-spacing: .4em; text-align: center; }

/* Formularios */
.input-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.input-group label { font-size: .72rem; font-weight: 700; color: var(--text-secondary); letter-spacing: .5px; text-transform: uppercase; }
.input-group .help { font-size: .75rem; color: var(--text-muted); }
.input, select.input {
    padding: 10px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: .9rem; color: var(--text);
    font-family: inherit; background: var(--surface); transition: var(--transition); outline: none; width: 100%;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,71,255,.15); }
.form-error { background: var(--critico-bg); color: var(--critico-fg); border-radius: var(--radius); padding: 10px 12px; font-size: .82rem; margin-bottom: 14px; }
.password-wrap { position: relative; width: 100%; }
.password-wrap .input { padding-right: 44px; }
.password-toggle {
    position: absolute; top: 50%; right: 6px; transform: translateY(-50%); width: 32px; height: 32px; display: flex; align-items: center;
    justify-content: center; background: none; border: none; border-radius: var(--radius-sm); cursor: pointer; color: var(--text-muted);
}
.password-toggle:hover { color: var(--primary); background: var(--surface-3); }

/* Layout */
.app-shell { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 236px; flex-shrink: 0; background: var(--sidebar-bg); display: flex; flex-direction: column; overflow-y: auto; }
.sidebar-logo { padding: 20px 24px; border-bottom: 1px solid rgba(255,255,255,.07); flex-shrink: 0; font-size: 1.15rem; font-weight: 800; color: #fff; }
.sidebar-logo small { display: block; font-size: .7rem; font-weight: 500; color: rgba(255,255,255,.5); letter-spacing: .3px; font-family: var(--mono); margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 14px 12px; display: flex; flex-direction: column; gap: 3px; }
.nav-label { font-size: .65rem; font-weight: 700; color: rgba(255,255,255,.35); text-transform: uppercase; letter-spacing: 1px; padding: 14px 14px 6px; }
.nav-item {
    display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-radius: var(--radius-sm); color: rgba(255,255,255,.72);
    text-decoration: none; background: none; border: none; font-family: inherit; text-align: left; font-size: .85rem; font-weight: 500;
    cursor: pointer; transition: var(--transition);
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-item .count { margin-left: auto; background: var(--danger); color: #fff; font-size: .68rem; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.nav-item-logout { margin-top: auto; color: #ff8a8a; }
.nav-item-logout:hover { background: rgba(255,80,80,.15); color: #ff8a8a; }

.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--surface-2); min-width: 0; }
.header { height: 62px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 32px; flex-shrink: 0; gap: 12px; }
.header-title { font-size: 1.15rem; font-weight: 700; }
.header-right { display: flex; align-items: center; gap: 12px; font-size: .82rem; color: var(--text-secondary); flex-wrap: wrap; justify-content: flex-end; }
.content-area { flex: 1; overflow-y: auto; padding: 26px 32px; }
.aviso { background: var(--medio-bg); color: var(--medio-fg); padding: 10px 14px; border-radius: var(--radius); font-size: .84rem; margin-bottom: 18px; }
.aviso.critico { background: var(--critico-bg); color: var(--critico-fg); }
.aviso a { color: inherit; font-weight: 700; text-decoration: underline; }
.lista-ayuda { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 10px; font-size: .86rem; line-height: 1.55; }
.lista-ayuda code { overflow-wrap: anywhere; }

/* Encabezados y barras */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { font-size: 1.3rem; font-weight: 800; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-muted); font-size: .85rem; margin-top: 2px; max-width: 760px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 600; margin-bottom: 10px; color: var(--text-secondary); cursor: pointer; background: none; border: none; font-family: inherit; }
.back-link:hover { color: var(--primary); }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.toolbar .input { width: auto; min-width: 180px; padding: 8px 12px; font-size: .85rem; }
.toolbar .search { flex: 1; min-width: 200px; }
.toolbar label.chk { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--text-secondary); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px; font-size: .74rem; font-weight: 600; white-space: nowrap; }
.badge-ok, .badge-green { background: var(--ok-bg); color: var(--ok-fg); }
.badge-info, .badge-gray, .badge-desconocido { background: var(--info-bg); color: var(--info-fg); }
.badge-medio, .badge-yellow { background: var(--medio-bg); color: var(--medio-fg); }
.badge-alto { background: var(--alto-bg); color: var(--alto-fg); }
.badge-critico, .badge-red { background: var(--critico-bg); color: var(--critico-fg); }
.badge-blue { background: var(--azul-bg); color: var(--azul-fg); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* Tablas */
.table-container { border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; background: var(--surface); }
.table { width: 100%; border-collapse: collapse; text-align: left; }
.table th { background: var(--surface-head); padding: 11px 14px; font-size: .72rem; font-weight: 700; color: var(--text-secondary); border-bottom: 1px solid var(--border); text-transform: uppercase; letter-spacing: .3px; white-space: nowrap; }
.table td { padding: 11px 14px; font-size: .85rem; color: var(--text); border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-3); }
.table .empty { text-align: center; color: var(--text-muted); padding: 28px; }
.cell-title { font-weight: 600; }
.cell-sub { font-size: .75rem; color: var(--text-muted); }
.muted { color: var(--text-muted); }
.nowrap { white-space: nowrap; }
.wrap-anywhere { overflow-wrap: anywhere; }

/* Resumen */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
    cursor: pointer; transition: var(--transition); text-align: left; font-family: inherit; color: var(--text); border-top: 3px solid var(--border);
}
.stat:hover { border-color: var(--primary-light); }
.stat .label { font-size: .72rem; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .4px; }
.stat .value { font-size: 1.8rem; font-weight: 800; margin-top: 2px; }
.stat.critico { border-top-color: var(--critico-fg); } .stat.critico .value { color: var(--critico-fg); }
.stat.alto { border-top-color: var(--alto-fg); } .stat.alto .value { color: var(--alto-fg); }
.stat.medio { border-top-color: var(--medio-fg); } .stat.medio .value { color: var(--medio-fg); }
.stat.ok { border-top-color: var(--ok-fg); } .stat.ok .value { color: var(--ok-fg); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 0 20px; }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: .85rem; color: var(--text); }
.list-item:last-child { border-bottom: none; }
a.list-item:hover { text-decoration: none; color: var(--primary); }
.list-empty { color: var(--text-muted); font-size: .85rem; padding: 6px 0; }

/* Fichas */
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px 24px; }
.kv-grid dt { font-size: .7rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.kv-grid dd { font-size: .88rem; margin-top: 2px; overflow-wrap: anywhere; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-family: var(--mono); font-size: .74rem; padding: 2px 8px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--text-secondary); }
.chip.oculto { opacity: .75; }
.chip-x { margin-left: 6px; padding: 0 2px; border: 0; background: none; color: var(--text-secondary); cursor: pointer; font-size: .9rem; line-height: 1; }
.chip-x:hover { color: var(--danger, #c0392b); }

/* Aplicaciones */
.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 16px; margin-bottom: 22px; }
.app-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); cursor: pointer; text-align: left; font-family: inherit; color: var(--text); display: flex; flex-direction: column; gap: 10px; transition: var(--transition); }
.app-card:hover { border-color: var(--primary-light); }
.app-card h3 { font-size: .98rem; font-weight: 700; overflow-wrap: anywhere; }
.app-card .fila { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: .8rem; color: var(--text-secondary); }

/* Revisión */
.check { border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 12px; background: var(--surface); }
.check.critico { border-left-color: var(--critico-fg); }
.check.alto { border-left-color: var(--alto-fg); }
.check.medio { border-left-color: var(--medio-fg); }
.check.ok { border-left-color: var(--ok-fg); }
.check-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.check-title { font-weight: 700; font-size: .92rem; }
.check-cat { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.check p { font-size: .85rem; color: var(--text-secondary); margin-top: 6px; }
.check .que-hacer { color: var(--text); }
.check ul { margin: 8px 0 0 18px; font-size: .8rem; color: var(--text-secondary); }
.check li { margin-bottom: 2px; overflow-wrap: anywhere; }
.comando { display: flex; align-items: center; gap: 8px; margin-top: 10px; background: var(--surface-head); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; }
.comando code { flex: 1; overflow-wrap: anywhere; color: var(--text); }
.comando button { flex-shrink: 0; }

/* Modales */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 20px; z-index: 100; overflow-y: auto; }
.modal { background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 520px; box-shadow: var(--shadow-md); border: 1px solid var(--border); }
.modal-header { padding: 16px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 1.02rem; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 1.4rem; line-height: 1; color: var(--text-muted); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface-head); display: flex; justify-content: flex-end; gap: 10px; }

.loading { color: var(--text-muted); padding: 40px; text-align: center; font-size: .9rem; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tab { background: none; border: none; border-bottom: 2px solid transparent; padding: 9px 14px; font-family: inherit; font-size: .86rem; font-weight: 600; color: var(--text-secondary); cursor: pointer; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

@media (max-width: 900px) {
    .login-left { display: none; }
    .login-right { width: 100%; padding: 40px 20px; }
    .app-shell { flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }
    .sidebar { width: 100%; }
    .sidebar-nav { flex-direction: row; overflow-x: auto; padding: 8px; }
    .nav-label { display: none; }
    .nav-item { white-space: nowrap; }
    .nav-item-logout { margin-top: 0; }
    .main-content { overflow: visible; }
    .content-area { padding: 18px 16px; overflow: visible; }
    .header { padding: 0 16px; height: auto; min-height: 56px; flex-wrap: wrap; }
    .toast-wrap { left: 16px; right: 16px; }
    .toast { min-width: 0; }
}
