:root {
    --bg: #06070d;
    --bg-2: #0b0e1a;
    --panel: rgba(20, 24, 41, 0.65);
    --border: rgba(120, 150, 255, 0.16);
    --text: #e7eaf6;
    --muted: #8a90ab;
    --cyan: #4ff0ff;
    --violet: #9b6bff;
    --pink: #ff5fb2;
    --green: #34e2a3;
    --red: #ff5f6d;
    --radius: 14px;
    font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.bg-grid {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image:
        linear-gradient(rgba(120, 150, 255, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(120, 150, 255, 0.06) 1px, transparent 1px),
        radial-gradient(circle at 15% 10%, rgba(79, 240, 255, 0.07), transparent 35%),
        radial-gradient(circle at 85% 15%, rgba(155, 107, 255, 0.09), transparent 35%),
        linear-gradient(var(--bg-2), var(--bg));
    background-size: 42px 42px, 42px 42px, auto, auto, auto;
    background-color: var(--bg);
}

.container { max-width: 1080px; margin: 0 auto; padding: 24px 18px 32px; }

/* Navbar */
.navbar {
    display: flex; align-items: center; gap: 16px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(8, 10, 20, 0.7);
    backdrop-filter: blur(10px);
    position: sticky; top: 0; z-index: 10;
    flex-wrap: wrap;
}
.brand, .brand-lg {
    font-weight: 700; letter-spacing: 0.5px; text-decoration: none; color: var(--text);
    display: flex; align-items: center; gap: 8px; font-size: 1.1rem;
}
.brand-lg { font-size: 1.6rem; justify-content: center; }
.accent { color: var(--cyan); text-shadow: 0 0 18px rgba(79, 240, 255, 0.5); }
.brand-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--cyan); box-shadow: 0 0 12px 3px var(--cyan);
    display: inline-block;
}
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-links a {
    color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 8px; font-size: 0.92rem;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); background: rgba(255,255,255,0.05); }
.nav-user { display: flex; align-items: center; gap: 10px; }
.user-pill {
    font-size: 0.82rem; color: var(--muted);
    background: rgba(255,255,255,0.05); border: 1px solid var(--border);
    padding: 5px 10px; border-radius: 999px;
}

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 1px solid var(--border); border-radius: 10px;
    padding: 10px 16px; font-size: 0.92rem; font-weight: 600;
    cursor: pointer; text-decoration: none; color: var(--text);
    background: rgba(255,255,255,0.03);
    transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease;
}
.btn:hover { border-color: rgba(120,150,255,0.4); background: rgba(255,255,255,0.06); }
.btn:active { transform: scale(0.98); }
.btn-primary {
    background: linear-gradient(135deg, var(--cyan), var(--violet));
    color: #05060c; border: none; box-shadow: 0 4px 20px rgba(79, 240, 255, 0.25);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-outline { border-color: var(--cyan); color: var(--cyan); background: transparent; }
.btn-ghost { background: transparent; border-color: transparent; padding: 6px 10px; }
.btn-ghost:hover { background: rgba(255,255,255,0.06); }
.btn-sm { padding: 6px 10px; font-size: 0.82rem; }
.btn-danger { color: var(--red); }
.btn-block { width: 100%; }
.inline { display: inline; }

/* Cards */
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    backdrop-filter: blur(8px);
}
.card h2 { margin: 0 0 14px; font-size: 1.05rem; }

.page-head { margin: 8px 0 22px; }
.page-head h1 { margin: 4px 0 4px; font-size: 1.6rem; }
.back-link { color: var(--muted); text-decoration: none; font-size: 0.85rem; }

/* Auth */
.auth-wrap { display: flex; justify-content: center; padding-top: 6vh; }
.auth-card { width: 100%; max-width: 380px; }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-tight { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); margin-bottom: 10px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--muted); }
input[type=text], input[type=password], input[type=url], select {
    background: rgba(0,0,0,0.35); border: 1px solid var(--border); border-radius: 9px;
    padding: 11px 12px; color: var(--text); font-size: 0.95rem; outline: none;
    transition: border-color 0.15s ease;
}
input:focus, select:focus { border-color: var(--cyan); }
.divider { display: flex; align-items: center; gap: 10px; margin: 18px 0; color: var(--muted); font-size: 0.8rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card {
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; display: flex; flex-direction: column; gap: 6px;
}
.accent-card { border-color: rgba(79,240,255,0.4); box-shadow: 0 0 24px rgba(79,240,255,0.08) inset; }
.stat-label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 1.7rem; font-weight: 700; }
.small-value { font-size: 1rem; font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* Forms inline */
.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row .grow { flex: 1 1 260px; }
.w-160 { width: 160px; flex: 0 0 auto; }

/* Table */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 14px; border-bottom: 1px solid var(--border); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.4px; }
.table td { padding: 10px 14px; vertical-align: middle; }
.table tbody tr { border-bottom: 1px solid rgba(255,255,255,0.07); }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; }
.nowrap { white-space: nowrap; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; padding-left: 18px !important; }
.link-code { color: var(--cyan); text-decoration: none; font-weight: 600; }
.badge {
    background: rgba(79,240,255,0.12); color: var(--cyan); padding: 2px 9px;
    border-radius: 999px; font-size: 0.8rem; font-weight: 600;
}
.tag { padding: 2px 9px; border-radius: 999px; font-size: 0.75rem; background: rgba(255,255,255,0.06); color: var(--muted); }
.tag-on { background: rgba(52,226,163,0.14); color: var(--green); }
.tag-off { background: rgba(255,95,109,0.12); color: var(--red); }

.empty-hint { color: var(--muted); font-size: 0.9rem; padding: 12px 0; }

/* Bar chart */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 140px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar { width: 70%; min-width: 6px; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, var(--cyan), var(--violet)); box-shadow: 0 0 10px rgba(79,240,255,0.35); }
.bar-label { font-size: 0.62rem; color: var(--muted); margin-top: 6px; }

/* Distribution rows */
.dist-row { display: grid; grid-template-columns: 90px 1fr 34px; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 0.85rem; }
.dist-bar { height: 8px; background: rgba(255,255,255,0.05); border-radius: 999px; overflow: hidden; }
.dist-bar div { height: 100%; background: linear-gradient(90deg, var(--cyan), var(--violet)); }

/* QR */
.qr-card { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 32px; }
.qr-box { background: #fff; padding: 16px; border-radius: 12px; }
.qr-box svg { display: block; }
.qr-actions { display: flex; gap: 10px; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 0.88rem; border: 1px solid var(--border); }
.alert-success { background: rgba(52,226,163,0.1); border-color: rgba(52,226,163,0.35); color: var(--green); }
.alert-error { background: rgba(255,95,109,0.1); border-color: rgba(255,95,109,0.35); color: var(--red); }

.muted { color: var(--muted); }
.small { font-size: 0.8rem; }

@media (max-width: 720px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
    .form-row .w-160 { width: 100%; }
    .nav-links { order: 3; width: 100%; justify-content: space-around; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 8px; }
    .navbar { flex-wrap: wrap; }
    .truncate { max-width: 140px; }
    .dist-row { grid-template-columns: 70px 1fr 28px; font-size: 0.78rem; }
}
