/* ExploraHost · Panel AntiDDoS — estilos comunes del panel y del login */

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

:root {
    --bg: #f4f6f9;
    --sidebar-bg: #0b0e14;
    --sidebar-border: #151a24;
    --sidebar-text: #8a99ad;
    --sidebar-text-active: #ffffff;
    --sidebar-active-bg: #1c2333;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --border-strong: #cbd5e0;
    --border-focus: #3182ce;
    --text: #2d3748;
    --text-muted: #718096;
    --text-dark: #1a202c;
    --accent: #2b6cb0;
    --accent-hover: #245a94;
    --accent-bright: #3182ce;
    --accent-light: rgba(43, 108, 176, 0.08);
    --green: #2f855a;
    --green-bright: #38a169;
    --green-light: rgba(56, 161, 105, 0.1);
    --danger: #e53e3e;
    --danger-hover: #c53030;
    --danger-light: rgba(229, 62, 62, 0.08);
    --warn: #c05621;
    --warn-light: rgba(221, 107, 32, 0.1);
    --purple: #6b46c1;
    --purple-light: rgba(107, 70, 193, 0.1);
    --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
    --sans: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --radius: 10px;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 14px;
    min-height: 100vh;
    display: flex;
}

a { color: var(--accent); }
code { font-family: var(--mono); font-size: 0.92em; }

/* ── Iconos (sprite SVG) ── */
.icon {
    width: 1.15em;
    height: 1.15em;
    flex-shrink: 0;
    vertical-align: -0.2em;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.icon-sm { width: 0.95em; height: 0.95em; }
.icon-lg { width: 1.5em; height: 1.5em; }
.icon-xl { width: 26px; height: 26px; }
.icon-spin { animation: rot 0.9s linear infinite; }
@keyframes rot { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ── Banderas ── */
.fi { border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08); margin-right: 6px; vertical-align: -1px; }

/* ── Utilidades ── */
[hidden] { display: none !important; }
.mono { font-family: var(--mono); }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-danger { color: var(--danger); }
.text-warn { color: var(--warn); }
.text-green { color: var(--green); }
.strong { font-weight: 600; color: var(--text-dark); }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: 6px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px; }

/* ── Sidebar ── */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 36px; height: 36px; flex-shrink: 0; }
.brand-name { color: #fff; font-weight: 800; font-size: 18px; letter-spacing: -0.4px; line-height: 1.1; }
.brand-name span { color: #4299e1; }
.brand-name .brand-sub { display: block; font-size: 10px; font-weight: 600; letter-spacing: 1.6px; text-transform: uppercase; color: var(--sidebar-text); margin-top: 3px; }
.sidebar-logo { padding: 22px 24px; border-bottom: 1px solid var(--sidebar-border); }
.sidebar-menu { flex: 1; padding: 24px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.menu-section { font-size: 10px; font-weight: 700; letter-spacing: 1.5px; color: #4a5568; margin: 18px 8px 8px; text-transform: uppercase; }
.menu-section:first-child { margin-top: 0; }
.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--radius);
    font-weight: 500;
    transition: background-color 0.15s, color 0.15s;
    position: relative;
}
.menu-item .icon { width: 18px; height: 18px; }
.menu-item:hover { color: var(--sidebar-text-active); background-color: rgba(255, 255, 255, 0.03); }
.menu-item.active { color: var(--sidebar-text-active); background-color: var(--sidebar-active-bg); }
.menu-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 25%;
    height: 50%;
    width: 3px;
    background-color: var(--accent-bright);
    border-radius: 0 4px 4px 0;
}
.menu-item-support { color: #68d391; }
.menu-item-support:hover { color: #9ae6b4; }
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background-color: rgba(0, 0, 0, 0.12);
}
.client-pill { display: flex; align-items: center; gap: 10px; min-width: 0; }
.client-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #4299e1, #2b6cb0);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.client-info { display: flex; flex-direction: column; min-width: 0; }
.client-name { font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-role { font-size: 10px; color: var(--sidebar-text); }
.btn-logout {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #1c2333;
    color: #fc8181;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    flex-shrink: 0;
    transition: background-color 0.15s;
}
.btn-logout:hover { background-color: rgba(229, 62, 62, 0.12); }

/* ── Contenido ── */
.main-content {
    margin-left: 260px;
    flex: 1;
    min-width: 0; /* sin esto una tabla ancha estira la página en vez de hacer scroll en su .table-responsive */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.topbar {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 99;
    min-height: 70px;
}
.breadcrumbs { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; display: block; margin-bottom: 2px; }
.topbar-title h2 { font-size: 18px; font-weight: 700; color: var(--text-dark); }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.header-ip-badge {
    background-color: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}
.ip-label { color: var(--text-muted); font-weight: 500; }
.ip-value { font-family: var(--mono); font-weight: 700; color: var(--text-dark); }
.ip-status-dot { width: 8px; height: 8px; border-radius: 50%; background-color: var(--text-muted); display: inline-block; }
.ip-status-dot.checking { background-color: var(--border-focus); box-shadow: 0 0 8px var(--border-focus); animation: pulse-dot 1.2s infinite; }
.ip-status-dot.blocked { background-color: var(--danger); box-shadow: 0 0 8px var(--danger); }
.ip-status-dot.clean { background-color: var(--green-bright); box-shadow: 0 0 8px var(--green-bright); }
@keyframes pulse-dot { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
.pulse { animation: pulse-dot 1s infinite; }

.content-wrapper {
    padding: 32px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 1240px;
    width: 100%;
    margin: 0 auto;
}
.page-head h1 { font-size: 22px; font-weight: 800; color: var(--text-dark); display: flex; align-items: center; gap: 10px; }
.page-head h1 .icon { color: var(--accent-bright); }
.page-head p { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

/* ── Tarjetas ── */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 14px;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--text-dark); display: flex; align-items: center; gap: 8px; }
.card-title .icon { color: var(--accent-bright); }
.card-desc { font-size: 13px; color: var(--text-muted); margin-top: 4px; line-height: 1.5; }
.card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-foot { font-size: 11px; color: var(--text-muted); margin-top: 12px; }
.card-flex { display: flex; flex-direction: column; justify-content: space-between; }
.card-debug { border: 1px dashed var(--warn); }
.card-debug .card-title .icon { color: var(--warn); }

/* ── Avisos ── */
.alert {
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
    border: 1px solid transparent;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.alert .icon { margin-top: 1px; }
.alert-danger { background: var(--danger-light); border-color: rgba(229, 62, 62, 0.22); color: #9b2c2c; }
.alert-success { background: var(--green-light); border-color: rgba(56, 161, 105, 0.25); color: #276749; }
.alert-warning { background: var(--warn-light); border-color: rgba(221, 107, 32, 0.25); color: #9c4221; }
.alert-info { background: var(--accent-light); border-color: rgba(43, 108, 176, 0.2); color: #2c5282; }
.alert-title { font-weight: 700; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ── Formularios ── */
.form-group { margin-bottom: 16px; }
.form-group label, .form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-control {
    width: 100%;
    background-color: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text-dark);
    font-family: var(--sans);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.15); }
.form-control-sm { padding: 6px 10px; font-size: 12px; width: auto; }
select.form-control { cursor: pointer; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 5px; }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.input-icon .form-control { padding-left: 32px; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent-bright); cursor: pointer; vertical-align: middle; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); cursor: pointer; user-select: none; }

/* ── Botones ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background-color: var(--accent-hover); }
.btn-danger { background-color: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background-color: var(--danger-hover); }
.btn-success { background-color: #25a55f; color: #fff; }
.btn-success:hover:not(:disabled) { background-color: #1e8a4f; }
.btn-support { background-color: #1faa55; color: #fff; }
.btn-support:hover:not(:disabled) { background-color: #178a44; }
.support-only { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 600; text-decoration: none; }
.support-only:hover { text-decoration: underline; }
.btn-outline { background-color: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover:not(:disabled) { background-color: var(--bg); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--text-muted); padding: 6px 8px; }
.btn-ghost:hover:not(:disabled) { color: var(--text-dark); background: var(--bg); }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 5px; gap: 5px; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 5px 0 0 5px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 5px 5px 0; }
.btn-group .btn.active { background-color: var(--accent); border-color: var(--accent); color: #fff; position: relative; z-index: 1; }

/* ── Tablas ── */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
    background-color: var(--bg);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 11px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text-dark); font-size: 13px; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background-color: #fafbfc; }
.table tr.selected td { background-color: var(--accent-light); }
.table .col-check { width: 36px; padding-right: 0; }
.table td.empty { text-align: center; color: var(--text-muted); padding: 28px 16px; }
.th-sort { cursor: pointer; user-select: none; }
.th-sort:hover { color: var(--text-dark); }
.th-sort .icon { opacity: 0.35; margin-left: 2px; }
.th-sort.sorted { color: var(--text-dark); }
.th-sort.sorted .icon { opacity: 1; color: var(--accent-bright); }
.cell-sub { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.ip-cell { font-family: var(--mono); font-weight: 600; white-space: nowrap; }
.link-ip { font-family: var(--mono); font-weight: 600; color: var(--accent); cursor: pointer; text-decoration: underline dotted var(--border-strong); background: none; border: none; font-size: 13px; }
.link-plain { background: none; border: none; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.link-plain:hover { color: var(--accent); }
.search-row { gap: 10px; flex-wrap: nowrap; }
.search-row .input-icon { max-width: 420px; }

/* ── Barra de selección múltiple y paginación ── */
.bulk-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    background: #eef3f9; /* opaco: la tabla pasa por debajo al hacer scroll */
    border: 1px solid rgba(43, 108, 176, 0.2);
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 12px;
    font-size: 13px;
    color: #2c5282;
    position: sticky; /* sigue a la vista bajo la barra superior mientras se recorre la tabla */
    top: 72px;
    z-index: 5;
    box-shadow: 0 4px 12px rgba(26, 32, 44, 0.06);
}
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; font-size: 12px; color: var(--text-muted); }
.pager-pages { display: flex; gap: 4px; flex-wrap: wrap; }
.pager-pages .btn { min-width: 32px; padding: 5px 9px; }
.pager-pages .btn.active { background-color: var(--accent); border-color: var(--accent); color: #fff; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .form-control { width: auto; }

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    background-color: var(--bg);
    color: var(--text-muted);
}
.badge .icon { width: 12px; height: 12px; }
.badge-success { background-color: var(--green-light); color: var(--green); }
.badge-danger { background-color: var(--danger-light); color: var(--danger); }
.badge-warning { background-color: var(--warn-light); color: var(--warn); }
.badge-info { background-color: var(--accent-light); color: var(--accent); }
.badge-purple { background-color: var(--purple-light); color: var(--purple); }
.badge-outline { background: #fff; border: 1px solid var(--border); color: var(--text-muted); }
.badge-lg { font-size: 14px; padding: 8px 16px; border-radius: 20px; }
.badge-lg .icon { width: 16px; height: 16px; }
.badge-click { cursor: pointer; }
.badge-click:hover { filter: brightness(0.95); text-decoration: underline dotted; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }

/* ── Cargando ── */
.card-loading-wrapper { position: relative; }
.card-loader {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(3px);
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    z-index: 50;
}
.card-loading-wrapper.loading .card-loader { display: flex; }
.card-loader-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(49, 130, 206, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: rot 0.8s linear infinite;
}

/* ── Escaneo de la IP del cliente ── */
.ip-scan-visual { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 22px 0 16px; }
.ip-scan-radar { position: relative; width: 78px; height: 78px; display: flex; align-items: center; justify-content: center; }
.radar-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--border-focus); opacity: 0; }
.ip-scan-radar.checking .radar-ring { animation: radar-pulse 1.8s ease-out infinite; }
.ip-scan-radar.checking .radar-ring:nth-child(2) { animation-delay: 0.5s; }
.ip-scan-radar.checking .radar-ring:nth-child(3) { animation-delay: 1s; }
@keyframes radar-pulse {
    0% { transform: scale(0.55); opacity: 0.7; border-color: var(--border-focus); }
    100% { transform: scale(1.7); opacity: 0; }
}
.ip-scan-core {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--bg);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-bright);
    transition: background 0.25s, border-color 0.25s, color 0.25s;
    z-index: 1;
}
.ip-scan-radar.clean .ip-scan-core { border-color: var(--green-bright); background: var(--green-light); color: var(--green); animation: scan-pop 0.4s; }
.ip-scan-radar.blocked .ip-scan-core { border-color: var(--danger); background: var(--danger-light); color: var(--danger); animation: scan-shake 0.5s; }
.ip-scan-radar.unknown .ip-scan-core { border-color: var(--warn); background: var(--warn-light); color: var(--warn); }
@keyframes scan-pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes scan-shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.ip-scan-value { font-family: var(--mono); font-size: 16px; font-weight: 700; color: var(--text-dark); }
.ip-scan-steps { display: flex; flex-direction: column; gap: 7px; margin-top: 6px; min-height: 20px; }
.ip-scan-step { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); opacity: 0; transform: translateY(4px); animation: step-in 0.3s forwards; }
@keyframes step-in { to { opacity: 1; transform: translateY(0); } }
.ip-scan-step.ok .icon { color: var(--green-bright); }
.ip-scan-step.bad { color: var(--text-dark); font-weight: 600; }
.ip-scan-step.bad .icon { color: var(--danger); }
.ip-scan-step.unknown .icon { color: var(--warn); }
.ip-scan-summary { border-radius: 8px; padding: 10px 14px; font-size: 12px; font-weight: 600; margin-top: 10px; display: flex; align-items: center; gap: 8px; opacity: 0; animation: step-in 0.35s forwards; }
.ip-scan-summary.clean { background: var(--green-light); color: var(--green); border: 1px solid rgba(56, 161, 105, 0.2); }
.ip-scan-summary.blocked { background: var(--danger-light); color: var(--danger); border: 1px solid rgba(229, 62, 62, 0.2); }
.ip-scan-summary.unknown { background: var(--warn-light); color: var(--warn); border: 1px solid rgba(221, 107, 32, 0.2); }

/* ── Resultado de búsqueda ── */
/* ── Consulta de varias IPs ── */
.multi-results { list-style: none; border: 1px solid var(--border); border-radius: 8px; max-height: 480px; overflow-y: auto; }
.multi-row + .multi-row { border-top: 1px solid var(--border); }
.multi-row.blocked { background: var(--danger-light); }
.multi-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 13px; }
.multi-ip { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.multi-ip .cell-sub { margin-top: 1px; }
summary.multi-head { cursor: pointer; list-style: none; }
summary.multi-head::-webkit-details-marker { display: none; }
.multi-caret { color: var(--text-muted); transition: transform 0.15s; }
details[open] > summary .multi-caret { transform: rotate(90deg); }
.multi-row .result-list { padding: 0 12px 10px 34px; }
.multi-row .result-list li:first-child { margin-top: 0; }

.result-box { border-radius: 8px; padding: 12px 16px; border: 1px solid; }
.result-box.clean { background: var(--green-light); border-color: rgba(56, 161, 105, 0.22); }
.result-box.blocked { background: var(--danger-light); border-color: rgba(229, 62, 62, 0.22); }
.result-list { list-style: none; font-size: 12px; color: var(--text); }
.result-list li { margin-top: 7px; display: flex; gap: 7px; align-items: flex-start; line-height: 1.45; }
.result-list li .icon { margin-top: 1px; color: var(--text-muted); }

/* ── Estadísticas ── */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; text-align: center; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text-dark); min-height: 20px; }
.stat-value.sm { font-size: 14px; font-weight: 700; }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

/* ── Explicaciones ── */
.explain { font-size: 13px; color: var(--text-muted); line-height: 1.6; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; }
.explain h4 { color: var(--text-dark); margin-bottom: 6px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.explain h4 .icon { color: var(--accent-bright); }
.glossary { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px; }
.glossary summary { cursor: pointer; font-weight: 600; color: var(--text-dark); font-size: 13px; }
.glossary dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin-top: 12px; font-size: 13px; }
.glossary dt { font-weight: 600; }
.glossary dd { color: var(--text-muted); }

/* ── Modales (SweetAlert2) ── */
.swal2-popup { font-family: var(--sans) !important; }
.swal-form { text-align: left; font-size: 13px; }
.swal-form .form-group { margin-bottom: 12px; }
.swal-form .form-control { font-size: 14px; }
.swal-lines { text-align: left; font-size: 13px; line-height: 1.8; margin-top: 12px; }

/* ── Login ── */
body.login-body { display: block; background: var(--bg); }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 440px) 1fr; }
.login-brand {
    background: var(--sidebar-bg);
    background-image: radial-gradient(ellipse 80% 60% at 0% 0%, rgba(66, 153, 225, 0.16) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 100% 100%, rgba(43, 108, 176, 0.14) 0%, transparent 60%);
    color: #cbd5e0;
    padding: 48px 44px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 32px;
}
.login-brand .brand-logo { width: 44px; height: 44px; }
.login-brand .brand-name { font-size: 22px; }
.login-brand h1 { color: #fff; font-size: 26px; font-weight: 800; line-height: 1.25; margin-bottom: 10px; }
.login-brand p { color: var(--sidebar-text); font-size: 14px; line-height: 1.6; }
.login-features { list-style: none; display: flex; flex-direction: column; gap: 14px; margin-top: 28px; }
.login-features li { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: #cbd5e0; line-height: 1.45; }
.login-features .icon { color: #63b3ed; width: 20px; height: 20px; margin-top: 1px; }
.login-copy { font-size: 11px; color: #4a5568; }
.login-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.login-card { width: 100%; max-width: 400px; }
.login-card h2 { font-size: 24px; font-weight: 800; color: var(--text-dark); }
.login-card .card { padding: 28px; margin-top: 22px; }
.login-card .btn { padding: 12px 18px; font-size: 14px; }
.login-note { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 18px; }
.captcha { margin: 4px 0 16px; min-height: 65px; }

/* ── Adaptación a pantallas pequeñas ── */
@media (max-width: 991px) {
    .sidebar { width: 70px; }
    .brand-name, .brand-sub, .client-info, .menu-item span, .menu-section { display: none; }
    .sidebar-logo { display: flex; justify-content: center; padding: 18px 0; }
    .sidebar-menu { padding: 16px 8px; }
    .menu-item { justify-content: center; padding: 12px; }
    .main-content { margin-left: 70px; }
    .sidebar-footer { flex-direction: column; justify-content: center; padding: 12px 0; }
}
@media (max-width: 860px) {
    .login-shell { grid-template-columns: 1fr; }
    .login-brand { padding: 28px 24px; }
    .login-features, .login-copy { display: none; }
}
@media (max-width: 768px) {
    .topbar { padding: 12px 16px; }
    .content-wrapper { padding: 16px; }
    .header-ip-badge { padding: 4px 10px; font-size: 11px; }
}

/* ── Móvil (hasta 640 px) ──
   Todo va dentro de la media query: en pantallas más grandes no cambia nada. Lo único de fuera es
   ocultar el botón de salir de la barra superior, que solo existe para el móvil. */
.topbar-logout { display: none; }

@media (max-width: 640px) {
    /* Menú: barra fija abajo con icono y nombre corto; con muchas secciones se desliza de lado */
    .sidebar { top: auto; bottom: 0; width: 100%; height: auto; flex-direction: row; border-right: none; border-top: 1px solid var(--sidebar-border); padding-bottom: env(safe-area-inset-bottom); }
    .sidebar-logo, .sidebar-footer, .menu-section { display: none; }
    .sidebar-menu { flex-direction: row; padding: 0 4px; gap: 0; overflow-x: auto; scrollbar-width: none; }
    .sidebar-menu::-webkit-scrollbar { display: none; }
    .menu-item { flex: 1 0 68px; flex-direction: column; justify-content: center; gap: 3px; padding: 9px 4px 8px; border-radius: 0; }
    .menu-item::after { content: attr(data-short); font-size: 10px; font-weight: 600; white-space: nowrap; }
    .menu-item.active::before { left: 22%; top: 0; width: 56%; height: 3px; border-radius: 0 0 3px 3px; }
    .main-content { margin-left: 0; }
    .content-wrapper { padding: 12px 12px calc(80px + env(safe-area-inset-bottom)); gap: 12px; }

    /* Barra superior compacta, con el botón de salir que en escritorio está al pie del menú */
    .topbar { padding: 8px 12px; min-height: 56px; gap: 8px; }
    .breadcrumbs { display: none; }
    .topbar-title h2 { font-size: 16px; }
    .topbar-actions { flex-wrap: nowrap; gap: 6px; }
    .topbar-actions .badge { padding: 4px 8px !important; font-size: 10px; }
    .header-ip-badge .ip-label { display: none; }
    .topbar-logout { display: inline-flex; color: var(--text-muted); }

    /* Cabeceras y tarjetas */
    .page-head h1 { font-size: 19px; }
    .page-head p { font-size: 12px; }
    .card { padding: 14px; }
    .card-header { margin-bottom: 12px; padding-bottom: 10px; }
    .card-actions { width: 100%; }
    .card-actions > .btn { flex: 1 1 auto; }
    .grid-cards { grid-template-columns: 1fr; gap: 12px; }
    .explain { grid-template-columns: 1fr; gap: 14px; }
    .glossary dl { grid-template-columns: 1fr; gap: 2px; }
    .glossary dd { margin-bottom: 8px; }

    /* Filtros: uno por línea, a todo el ancho */
    .toolbar { gap: 6px; }
    .toolbar > .form-control, .toolbar > .input-icon, .toolbar > select,
    .toolbar .input-icon .form-control { flex: 1 1 100%; width: 100% !important; max-width: none !important; }
    .toolbar > input[type="date"] { flex: 1 1 35%; }
    .toolbar > .grow { display: none; }
    .search-row { flex-wrap: wrap; }
    .search-row .input-icon { max-width: none; flex: 1 1 100%; }
    .search-row .btn { width: 100%; }
    .bulk-bar { top: 57px; }

    /* Tablas: cada fila pasa a ser una tarjeta, con el nombre de cada dato a la izquierda */
    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody, .table-cards tr { display: block; width: 100%; }
    .table-cards tr { position: relative; border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; background: var(--card-bg); }
    .table-cards tbody tr:hover td, .table-cards tr.selected td { background: none; }
    .table-cards tr.selected { border-color: var(--accent-bright); background: var(--accent-light); }
    .table-cards td { display: block; position: relative; border: none; padding: 5px 0 5px 104px; min-height: 26px; text-align: left; }
    .table-cards td::before { content: attr(data-label); position: absolute; left: 0; top: 8px; width: 96px; font-family: var(--sans); font-size: 10px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; color: var(--text-muted); }
    .table-cards td:not([data-label]), .table-cards td[data-label=""] { padding-left: 0; }
    .table-cards td:not([data-label])::before, .table-cards td[data-label=""]::before { display: none; }
    .table-cards td.text-center, .table-cards td.text-right { text-align: left; }
    .table-cards td.text-right .btn { width: 100%; margin-top: 4px; }
    .table-cards td.empty { padding: 20px 8px; text-align: center; }
    .table-cards td.col-check { position: absolute; top: 10px; right: 12px; width: auto; min-height: 0; padding: 0; }
    .table-cards .nowrap { white-space: normal; }

    /* Gráficas más bajas y modales a casi todo el ancho */
    .chart-box { height: 230px !important; }
    .swal2-popup { width: calc(100vw - 20px) !important; padding: 16px 12px !important; }

    /* Login */
    .login-shell { grid-template-rows: auto 1fr; }
    .login-brand { padding: 20px 16px; gap: 0; }
    .login-brand .brand-name { display: block; }
    .login-brand > div > div[style] { margin-top: 18px !important; }
    .login-brand h1 { font-size: 20px; }
    .login-main { padding: 24px 12px 32px; align-items: flex-start; }
    .login-card .card { padding: 18px; }
}
