/* ── Reset & variables ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:        #0f1117;
    --surface:   #1a1d27;
    --surface2:  #1f2235;
    --border:    #2a2d3e;
    --primary:   #6366f1;
    --primary-h: #4f52d6;
    --danger:    #ef4444;
    --success:   #22c55e;
    --warning:   #f59e0b;
    --text:      #e2e8f0;
    --muted:     #64748b;
    --sidebar-w: 220px;
    --radius:    8px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    min-height: 100vh;
}

code {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 12px;
    background: rgba(255,255,255,.06);
    padding: 1px 5px;
    border-radius: 3px;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 10;
}

.sidebar-logo {
    padding: 18px 16px;
    font-weight: 700;
    font-size: 15px;
    border-bottom: 1px solid var(--border);
    color: var(--primary);
    letter-spacing: .4px;
}

.sidebar nav { flex: 1; padding: 10px 0; }

.nav-link {
    display: block;
    padding: 10px 16px;
    color: var(--muted);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: color .15s, background .15s, border-color .15s;
    font-size: 13px;
}

.nav-link:hover,
.nav-link.active {
    color: var(--text);
    background: rgba(99,102,241,.1);
    border-left-color: var(--primary);
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--muted);
}

.sidebar-footer a { color: var(--danger); text-decoration: none; }

/* ── Main content ──────────────────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 28px 32px;
    max-width: 100%;
    overflow-x: auto;
}

.section       { display: none; }
.section.active { display: block; }

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-header h2 { font-size: 18px; font-weight: 600; }

/* ── Stats ─────────────────────────────────────────────────────────────────── */
.stats-row {
    display: flex;
    gap: 14px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 22px;
    min-width: 110px;
}

.stat-card .value { font-size: 26px; font-weight: 700; }
.stat-card .label { color: var(--muted); font-size: 11px; margin-top: 2px; text-transform: uppercase; letter-spacing: .4px; }

.stat-card.total .value  { color: var(--primary); }
.stat-card.online .value { color: var(--success); }
.stat-card.offline .value{ color: var(--danger); }

/* ── Tabla ─────────────────────────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.data-table th {
    text-align: left;
    padding: 11px 14px;
    background: var(--surface2);
    color: var(--muted);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(255,255,255,.02); }

.loading {
    color: var(--muted);
    text-align: center;
    padding: 28px !important;
    font-style: italic;
}

/* ── Dot de estado ─────────────────────────────────────────────────────────── */
.dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    flex-shrink: 0;
}
.dot.online  { background: var(--success); box-shadow: 0 0 5px var(--success); }
.dot.offline { background: var(--muted); }

/* ── Botones ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: background .15s, border-color .15s;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover         { background: rgba(255,255,255,.06); }
.btn-primary       { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); border-color: var(--primary-h); }
.btn-danger        { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover  { background: rgba(239,68,68,.1); }
.btn-sm            { padding: 4px 10px; font-size: 12px; }
.btn:disabled      { opacity: .45; cursor: not-allowed; }

/* ── Token ─────────────────────────────────────────────────────────────────── */
.token-mono {
    font-family: 'Consolas', monospace;
    font-size: 11px;
    background: var(--bg);
    padding: 3px 7px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--muted);
    max-width: 180px;
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
    transition: color .15s;
    border: 1px solid var(--border);
}
.token-mono:hover { color: var(--text); }

.token-display {
    background: rgba(34,197,94,.08);
    border: 1px solid var(--success);
    border-radius: var(--radius);
    padding: 14px;
    margin-top: 16px;
    font-family: monospace;
    font-size: 12px;
    word-break: break-all;
    color: var(--success);
    line-height: 1.7;
}

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal.hidden { display: none; }

.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
    width: 420px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-box.wide { width: 600px; }
.modal-box h3 { margin-bottom: 20px; font-size: 16px; }

.modal-box label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 14px;
}

.modal-box input[type=text],
.modal-box input[type=number],
.modal-box select,
.modal-box textarea {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    color: var(--text);
    font-size: 13px;
    outline: none;
    font-family: inherit;
    transition: border-color .15s;
    width: 100%;
}
.modal-box input:focus,
.modal-box select:focus,
.modal-box textarea:focus { border-color: var(--primary); }

.modal-box textarea { font-family: 'Consolas', monospace; resize: vertical; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
}
.span2 { grid-column: span 2; }

.checkbox-label {
    flex-direction: row !important;
    align-items: center;
    gap: 8px !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    font-size: 13px !important;
    color: var(--text) !important;
    cursor: pointer;
}
.checkbox-label input { width: auto; cursor: pointer; accent-color: var(--primary); }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.badge-inject   { background: rgba(99,102,241,.18); color: #818cf8; }
.badge-block    { background: rgba(239,68,68,.18);  color: #f87171; }
.badge-redirect { background: rgba(245,158,11,.18); color: #fbbf24; }
.badge-log      { background: rgba(100,116,139,.18);color: var(--muted); }
.badge-contains { background: rgba(34,197,94,.15);  color: #4ade80; }
.badge-regex    { background: rgba(245,158,11,.15); color: #fbbf24; }
.badge-exact    { background: rgba(99,102,241,.15); color: #818cf8; }

/* ── Toggle switch ─────────────────────────────────────────────────────────── */
.toggle {
    position: relative;
    width: 36px; height: 20px;
    display: inline-block;
    flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0;
    background: var(--border);
    border-radius: 20px;
    cursor: pointer;
    transition: background .2s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px; height: 14px;
    left: 3px; top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ── Login ─────────────────────────────────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    width: 360px;
    max-width: 95vw;
}

.login-box h1 {
    font-size: 20px;
    margin-bottom: 28px;
    color: var(--primary);
    font-weight: 700;
}

.login-box label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 16px;
}

.login-box input[type=text],
.login-box input[type=password] {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text);
    font-size: 14px;
    outline: none;
    font-family: inherit;
    transition: border-color .15s;
    width: 100%;
}
.login-box input:focus { border-color: var(--primary); }
.login-box .btn { width: 100%; justify-content: center; padding: 10px; font-size: 14px; }

.error {
    color: #f87171;
    background: rgba(239,68,68,.1);
    border: 1px solid rgba(239,68,68,.3);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* ── Tabla de acciones (botones inline) ───────────────────────────────────── */
.row-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}
