/* =====================================================================================================
 *  WAEVO DASHBOARD — Estilo blanco y negro, serio, estricto
 * ===================================================================================================== */

:root {
    --bg: #0a0a0a;
    --bg-elev: #111111;
    --bg-elev-2: #0e0e0e;
    --border: #1e1e1e;
    --border-2: #2a2a2a;
    --text: #f5f5f5;
    --text-muted: #8a8a8a;
    --text-dim: #5a5a5a;
    --ok: #22c55e;
    --bad: #ef4444;
    --warn: #eab308;
    --sidebar-w: 240px;
}

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

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body {
    display: flex;
    min-height: 100vh;
}

.mono {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}

/* =====================================================================================================
 *  SIDEBAR
 * ===================================================================================================== */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    position: sticky;
    top: 0;
    background: var(--bg-elev);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 6px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.brand-mark {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-2);
    border-radius: 4px;
    color: var(--text);
    flex-shrink: 0;
}

.brand-mark svg { width: 20px; height: 20px; }

.sb-title {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 3px;
    color: var(--text);
}

.sb-sub {
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-family: 'JetBrains Mono', monospace;
    margin-top: 1px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s ease;
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.nav-item:hover {
    color: var(--text);
    background: rgba(255,255,255,0.03);
}

.nav-item.active {
    color: var(--text);
    background: rgba(255,255,255,0.06);
    border-color: var(--border-2);
}

.nav-item.hidden { display: none; }

.sidebar-footer {
    padding-top: 14px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-chip {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    background: var(--text);
    color: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 12px;
    flex-shrink: 0;
}

.user-info { min-width: 0; flex: 1; }

.user-email {
    font-size: 11px;
    color: var(--text);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 9.5px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: 'JetBrains Mono', monospace;
    margin-top: 2px;
}

.btn-logout {
    background: transparent;
    border: 1px solid var(--border-2);
    color: var(--text-muted);
    width: 34px;
    height: 34px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-logout svg { width: 15px; height: 15px; }

.btn-logout:hover {
    color: var(--bad);
    border-color: var(--bad);
}

/* =====================================================================================================
 *  MAIN
 * ===================================================================================================== */
.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    padding: 18px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 5;
}

.topbar h1 {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.topbar p {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 2px;
}

.topbar-right { display: flex; align-items: center; gap: 10px; }

.live-badge {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    border: 1px solid var(--border-2);
    border-radius: 3px;
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 0.5px;
}

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ok);
    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-2);
    color: var(--text-muted);
    width: 34px;
    height: 34px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-icon svg { width: 15px; height: 15px; transition: transform 0.5s; }
.btn-icon:hover { color: var(--text); border-color: var(--border-2); background: rgba(255,255,255,0.03); }
.btn-icon.spinning svg { transform: rotate(360deg); }

/* =====================================================================================================
 *  VISTAS
 * ===================================================================================================== */
.view-container { padding: 24px 28px 60px; }

.view { display: none; }
.view.active { display: block; animation: fadeIn 0.25s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

/* =====================================================================================================
 *  STATS
 * ===================================================================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.stat-card {
    background: var(--bg-elev);
    padding: 20px;
    transition: background 0.15s ease;
}

.stat-card:hover { background: #141414; }

.stat-card.hidden { display: none; }

.stat-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.3px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.8px;
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.1;
}

.stat-foot {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 8px;
    font-family: 'JetBrains Mono', monospace;
}

.stat-foot .ok { color: var(--ok); }
.stat-foot .bad { color: var(--bad); }

/* =====================================================================================================
 *  PANEL
 * ===================================================================================================== */
.panel {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 20px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    gap: 12px;
    flex-wrap: wrap;
}

.panel-header h2 {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.panel-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.panel-tag {
    font-size: 10.5px;
    font-weight: 700;
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--border-2);
    color: var(--text-muted);
    border-radius: 3px;
    letter-spacing: 0.8px;
    font-family: 'JetBrains Mono', monospace;
}

.search-input {
    background: var(--bg-elev-2);
    border: 1px solid var(--border-2);
    padding: 8px 12px;
    border-radius: 3px;
    color: var(--text);
    font-family: inherit;
    font-size: 12.5px;
    outline: none;
    min-width: 220px;
    transition: border-color 0.15s ease;
}

.search-input:focus {
    border-color: #444;
}

/* =====================================================================================================
 *  TABLAS
 * ===================================================================================================== */
.table-wrap {
    overflow-x: auto;
    margin: 0 -20px -20px;
    padding: 0 20px 20px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.data-table thead th {
    text-align: left;
    padding: 10px 12px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    font-family: 'JetBrains Mono', monospace;
}

.data-table tbody td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text);
}

.data-table tbody tr:hover {
    background: rgba(255,255,255,0.015);
}

.empty-row {
    text-align: center;
    color: var(--text-dim);
    padding: 30px !important;
    font-style: italic;
    font-size: 12px;
}

/* =====================================================================================================
 *  PÍLDORAS DE ESTADO
 * ===================================================================================================== */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 3px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.5px;
    font-family: 'JetBrains Mono', monospace;
    text-transform: uppercase;
}

.pill-ok {
    background: rgba(34,197,94,0.08);
    color: var(--ok);
    border: 1px solid rgba(34,197,94,0.25);
}

.pill-bad {
    background: rgba(239,68,68,0.08);
    color: var(--bad);
    border: 1px solid rgba(239,68,68,0.25);
}

.pill-warn {
    background: rgba(234,179,8,0.08);
    color: var(--warn);
    border: 1px solid rgba(234,179,8,0.25);
}

.pill-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

/* =====================================================================================================
 *  BOTÓN VER
 * ===================================================================================================== */
.btn-view {
    background: transparent;
    border: 1px solid var(--border-2);
    color: var(--text-muted);
    padding: 5px 12px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: all 0.15s ease;
}

.btn-view:hover {
    color: var(--text);
    border-color: #444;
    background: rgba(255,255,255,0.03);
}

/* =====================================================================================================
 *  MODAL
 * ===================================================================================================== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal[hidden] { display: none; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.75);
}

.modal-card {
    position: relative;
    background: var(--bg-elev);
    border: 1px solid var(--border-2);
    border-radius: 6px;
    max-width: 720px;
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    padding: 32px;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: transparent;
    border: 1px solid var(--border-2);
    color: var(--text-muted);
    width: 30px;
    height: 30px;
    border-radius: 4px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s ease;
}

.modal-close:hover {
    color: var(--bad);
    border-color: var(--bad);
}

.modal-body h3 {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: -0.3px;
}

.modal-body .modal-sub {
    color: var(--text-dim);
    font-size: 11.5px;
    margin-bottom: 22px;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 0.5px;
}

.modal-section {
    margin-bottom: 20px;
}

.modal-section h4 {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.4px;
    margin-bottom: 12px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.info-item {
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 10px 12px;
}

.info-label {
    font-size: 9.5px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    margin-bottom: 5px;
    font-family: 'JetBrains Mono', monospace;
}

.info-value {
    font-size: 13px;
    font-weight: 600;
    word-break: break-word;
    color: var(--text);
}

/* =====================================================================================================
 *  RESPONSIVE
 * ===================================================================================================== */
@media (max-width: 768px) {
    :root { --sidebar-w: 60px; }
    .sb-title, .sb-sub, .nav-item span, .user-info { display: none; }
    .nav-item { justify-content: center; padding: 12px; }
    .sidebar-brand { justify-content: center; }
    .topbar { padding: 14px 18px; }
    .topbar h1 { font-size: 15px; }
    .view-container { padding: 18px 18px 40px; }
}
