:root {
    --bg: #0b1020;
    --panel: rgba(255, 255, 255, 0.075);
    --panel-strong: rgba(255, 255, 255, 0.12);
    --border: rgba(255, 255, 255, 0.12);
    --text: #f7f8ff;
    --muted: #aeb6d5;
    --primary: #7c5cff;
    --primary-2: #00d4ff;
    --success: #2ee59d;
    --danger: #ff5c7a;
    --warning: #ffce5c;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
    --radius: 24px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(124, 92, 255, 0.26), transparent 34rem),
        radial-gradient(circle at top right, rgba(0, 212, 255, 0.18), transparent 32rem),
        var(--bg);
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 280px;
    padding: 26px;
    border-right: 1px solid var(--border);
    background: rgba(5, 9, 22, 0.76);
    backdrop-filter: blur(24px);
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 28px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-icon, .login-logo {
    width: 52px; height: 52px; border-radius: 18px;
    display: grid; place-items: center;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 18px 50px rgba(124, 92, 255, 0.35);
}
.brand span { display: block; color: var(--muted); font-size: 0.86rem; margin-top: 3px; }
.nav { display: grid; gap: 8px; }
.nav a, .logout {
    padding: 13px 15px;
    border-radius: 16px;
    color: var(--muted);
    transition: 0.18s ease;
}
.nav a:hover, .nav a.active, .logout:hover {
    color: var(--text);
    background: var(--panel-strong);
}
.logout { margin-top: auto; }
.main-content { width: 100%; padding: 34px; overflow: hidden; }
.mobile-menu { display: none; }

.page-header, .hero-panel {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 22px;
    margin-bottom: 28px;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
}
.hero-panel { align-items: center; min-height: 260px; }
h1 { margin: 6px 0 8px; font-size: clamp(2rem, 5vw, 4.2rem); letter-spacing: -0.06em; line-height: 0.95; }
h2, h3, p { margin-top: 0; }
p { color: var(--muted); line-height: 1.65; }
.eyebrow { color: var(--primary-2); text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.78rem; font-weight: 800; }
.header-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.stat-card, .panel, .event-card, .empty-state, .login-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
}
.stat-card { padding: 22px; }
.stat-card span, .stat-card small { color: var(--muted); }
.stat-card strong { display: block; margin: 12px 0 6px; font-size: 2rem; letter-spacing: -0.04em; }
.grid-two { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; margin-bottom: 18px; }
.align-start { align-items: start; }
.panel { padding: 22px; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.panel-header h2 { margin: 0; }
.panel-header a { color: var(--primary-2); }

.btn, .range-tabs button {
    border: 0;
    border-radius: 14px;
    padding: 11px 15px;
    cursor: pointer;
    color: var(--text);
    background: var(--panel-strong);
    transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn:hover, .range-tabs button:hover { transform: translateY(-1px); }
.btn.primary, .range-tabs .active { background: linear-gradient(135deg, var(--primary), #5d9cff); }
.btn.ghost { background: rgba(255,255,255,0.08); }
.btn.danger { background: rgba(255, 92, 122, 0.16); color: #ffb5c2; }

.site-filter, .range-tabs { display: flex; gap: 9px; align-items: center; }
.site-filter label { color: var(--muted); font-size: 0.9rem; }
select, input {
    width: 100%;
    color: var(--text);
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    outline: none;
}
select { min-width: 190px; }
.form-stack { display: grid; gap: 16px; }
.form-stack label { display: grid; gap: 8px; color: var(--muted); }
.form-stack button { width: fit-content; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 700; font-size: 0.86rem; }
.truncate { max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chart { height: 280px; display: flex; align-items: end; gap: 10px; padding-top: 18px; }
.chart-bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: end; gap: 8px; align-items: center; color: var(--muted); font-size: 0.75rem; }
.chart-bar span { width: 100%; min-height: 8px; border-radius: 12px 12px 4px 4px; background: linear-gradient(180deg, var(--primary-2), var(--primary)); }
.list-bars { display: grid; gap: 14px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 50px; gap: 12px; align-items: center; }
.bar-row span { color: var(--muted); }
.bar-row div { height: 10px; background: rgba(255,255,255,0.08); border-radius: 999px; overflow: hidden; }
.bar-row i { display: block; height: 100%; border-radius: inherit; background: var(--primary-2); }

.site-list { display: grid; gap: 14px; }
.site-item { display: flex; justify-content: space-between; gap: 16px; padding: 16px; border: 1px solid var(--border); border-radius: 18px; background: rgba(255,255,255,0.05); }
.site-item span, .site-item code { display: block; color: var(--muted); margin-top: 4px; word-break: break-all; }
.site-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: end; }
.code-block { padding: 18px; border-radius: 18px; background: rgba(0,0,0,0.32); color: #dbe8ff; overflow-x: auto; border: 1px solid var(--border); }
.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 18px; }
.info-grid div { padding: 16px; border-radius: 18px; background: rgba(255,255,255,0.06); }
.info-grid strong, .info-grid span { display: block; }
.info-grid span { color: var(--muted); margin-top: 6px; word-break: break-all; }

.events-list { display: grid; gap: 14px; }
.event-card { padding: 20px; }
.event-card.error { border-color: rgba(255, 92, 122, 0.32); }
.event-top { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.86rem; margin-bottom: 12px; }
.event-top span { color: var(--danger); text-transform: uppercase; letter-spacing: 0.12em; font-weight: 800; }
.event-card pre { max-height: 260px; overflow: auto; padding: 14px; border-radius: 14px; background: rgba(0,0,0,0.35); color: #ffd7df; white-space: pre-wrap; }
.empty-state { padding: 30px; color: var(--muted); text-align: center; }
.empty-state.small { box-shadow: none; border: 0; background: transparent; }
.alert { padding: 14px 16px; border-radius: 16px; margin-bottom: 18px; border: 1px solid var(--border); }
.alert.success { color: #b8ffe1; background: rgba(46, 229, 157, 0.1); }
.alert.error { color: #ffc6d0; background: rgba(255, 92, 122, 0.1); }

.login-body { display: grid; place-items: center; padding: 24px; }
.login-card { width: min(460px, 100%); padding: 32px; }
.login-logo { margin-bottom: 18px; }
.login-card h1 { font-size: 2.4rem; }

@media (max-width: 1050px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-two { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
    .sidebar { position: fixed; z-index: 20; transform: translateX(-105%); transition: 0.2s ease; }
    .sidebar.open { transform: translateX(0); }
    .main-content { padding: 20px; }
    .mobile-menu { display: inline-flex; margin-bottom: 16px; background: var(--panel-strong); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 10px 14px; }
    .page-header, .hero-panel { flex-direction: column; padding: 22px; }
    .stats-grid { grid-template-columns: 1fr; }
    .site-item { flex-direction: column; }
    .site-actions { justify-content: start; }
    .header-actions { width: 100%; }
    .site-filter, .range-tabs { width: 100%; flex-wrap: wrap; }
}

/* Better styled dropdowns */
select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    padding-right: 44px;
    background-color: rgba(255,255,255,0.08);
    background-image:
        linear-gradient(45deg, transparent 50%, var(--text) 50%),
        linear-gradient(135deg, var(--text) 50%, transparent 50%);
    background-position:
        calc(100% - 22px) 50%,
        calc(100% - 16px) 50%;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

select:hover {
    border-color: rgba(255,255,255,0.28);
    background-color: rgba(255,255,255,0.11);
}

select:focus {
    border-color: rgba(124, 92, 255, 0.75);
    box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.18);
}

select option {
    background: #11182e;
    color: #f7f8ff;
}

select option:checked {
    background: #7c5cff;
    color: #ffffff;
}

select option:hover {
    background: #263253;
    color: #ffffff;
}
