:root {
    --bg: #080a0f;
    --bg-elevated: #0f1219;
    --surface: #141824;
    --surface-2: #1a2030;
    --border: #252d3d;
    --text: #eef2ff;
    --muted: #8b96ab;
    --accent: #7c6cff;
    --accent-2: #4f8cff;
    --ok: #34d399;
    --bad: #f87171;
    --gold: #fbbf24;
    --radius: 14px;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    --scrollbar-track: #0f1219;
    --scrollbar-thumb: #2d3548;
    --scrollbar-thumb-hover: #3d4660;
    --scrollbar-thumb-active: #5c6cff;
}

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

/* Custom scrollbars */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #3a4258 0%, var(--scrollbar-thumb) 100%);
    border-radius: 999px;
    border: 2px solid var(--scrollbar-track);
    min-height: 40px;
}

*::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #4a5470 0%, var(--scrollbar-thumb-hover) 100%);
}

*::-webkit-scrollbar-thumb:active {
    background: var(--scrollbar-thumb-active);
}

*::-webkit-scrollbar-corner {
    background: var(--scrollbar-track);
}

.log-feed::-webkit-scrollbar-thumb,
.table-scroll::-webkit-scrollbar-thumb {
    border-color: var(--bg);
}

.log-feed,
.table-scroll {
    scrollbar-color: var(--scrollbar-thumb) var(--bg);
}

body {
    font-family: Inter, system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { color: #8eb6ff; }

/* ── App shell ── */
.shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem 1.5rem;
}

.sidebar-brand strong { display: block; font-size: 0.95rem; }
.sidebar-brand small { color: var(--muted); font-size: 0.75rem; }

.logo-img,
.sidebar-logo,
.login-logo {
    display: block;
    object-fit: cover;
    border-radius: 12px;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-logo {
    width: 88px;
    height: 88px;
    border-radius: 16px;
    margin-bottom: 1rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.login-brand h1 { font-size: 1.6rem; }
.login-sub { color: var(--muted); margin-top: 0.25rem; }

.login-card h1 { font-size: 1.6rem; }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.sidebar-nav a .ico { opacity: 0.7; font-size: 0.85rem; }

.sidebar-nav a:hover {
    background: var(--surface);
    color: var(--text);
}

.sidebar-nav a.active {
    background: linear-gradient(135deg, rgba(124, 108, 255, 0.2), rgba(79, 140, 255, 0.12));
    border: 1px solid rgba(124, 108, 255, 0.35);
    color: var(--text);
}

.sidebar-foot { padding: 0.5rem 0.75rem; }

.logout-btn {
    display: block;
    text-align: center;
    padding: 0.55rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.85rem;
}

.logout-btn:hover {
    border-color: var(--bad);
    color: var(--bad);
    background: rgba(248, 113, 113, 0.08);
}

.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.pagebar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1.5rem 2rem 1rem;
    border-bottom: 1px solid var(--border);
    background: rgba(15, 18, 25, 0.6);
}

.pagebar h1 { font-size: 1.5rem; font-weight: 700; }
.pagebar p { color: var(--muted); font-size: 0.9rem; margin-top: 0.15rem; }
.pagebar-meta { color: var(--muted); font-size: 0.8rem; padding-top: 0.35rem; }

.content {
    padding: 1.5rem 2rem 3rem;
}

/* ── Login ── */
body.login-page {
    background: radial-gradient(ellipse at 20% 0%, rgba(124, 108, 255, 0.18), transparent 50%),
                radial-gradient(ellipse at 80% 100%, rgba(79, 140, 255, 0.12), transparent 50%),
                var(--bg);
}

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
    position: relative;
}

.login-glow {
    position: absolute;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(124, 108, 255, 0.15), transparent 70%);
    pointer-events: none;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: rgba(20, 24, 36, 0.9);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2.25rem;
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
    position: relative;
    z-index: 1;
}

.login-form {
    display: grid;
    gap: 0.65rem;
}

.login-form label {
    font-size: 0.82rem;
    color: var(--muted);
    font-weight: 500;
}

.login-form input {
    padding: 0.8rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124, 108, 255, 0.2);
}

.login-form button {
    margin-top: 0.5rem;
    padding: 0.85rem;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
}

.login-form button:hover { filter: brightness(1.08); }

/* ── Alerts ── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-error {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.35);
    color: #fecaca;
}

.muted { color: var(--muted); }
.center { text-align: center; }

/* ── Dashboard ── */
.status-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 2rem;
    border: 1px solid var(--border);
    background: var(--surface);
}

.status-banner.online {
    border-color: rgba(52, 211, 153, 0.35);
    background: linear-gradient(90deg, rgba(52, 211, 153, 0.08), transparent);
}

.status-banner.offline {
    border-color: rgba(248, 113, 113, 0.35);
    background: linear-gradient(90deg, rgba(248, 113, 113, 0.08), transparent);
}

.status-banner strong { display: block; font-size: 1rem; }
.status-banner span { color: var(--muted); font-size: 0.85rem; }

.pulse {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5);
    animation: pulse 2s infinite;
}

.status-banner.offline .pulse {
    background: var(--bad);
    animation: none;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5); }
    70% { box-shadow: 0 0 0 10px rgba(52, 211, 153, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.section-title {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 0.85rem;
    margin-top: 0.5rem;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.stat-card.accent-blue { border-top: 3px solid var(--accent-2); }
.stat-card.accent-purple { border-top: 3px solid var(--accent); }
.stat-card.accent-gold { border-top: 3px solid var(--gold); }
.stat-card.accent-green { border-top: 3px solid var(--ok); }

.stat-label {
    font-size: 0.78rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
}

.stat-hint {
    font-size: 0.82rem;
    color: var(--muted);
}

/* ── Database ── */
.db-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    margin-bottom: 1rem;
}

.db-picker {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.db-picker label {
    font-size: 0.78rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.db-picker select {
    min-width: 240px;
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.95rem;
}

.db-meta {
    color: var(--muted);
    font-size: 0.9rem;
    padding-bottom: 0.5rem;
}

.db-note {
    color: var(--muted);
    font-size: 0.8rem;
    margin: -0.25rem 0 1rem;
}

.db-note code {
    font-size: 0.78rem;
    color: var(--text);
}

.table-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}

.table-scroll { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.data-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    background: var(--surface-2);
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid rgba(37, 45, 61, 0.6);
    vertical-align: top;
    max-width: 280px;
    word-break: break-word;
}

.data-table tbody tr:hover td {
    background: rgba(124, 108, 255, 0.04);
}

.data-table tbody tr:last-child td { border-bottom: none; }

.pager {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.25rem;
}

.pager-info { color: var(--muted); font-size: 0.9rem; }

.btn {
    display: inline-block;
    padding: 0.5rem 0.9rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
}

.btn-ghost {
    border: 1px solid var(--border);
    color: var(--text);
    background: var(--surface);
}

.btn-ghost:hover {
    border-color: var(--accent);
    background: rgba(124, 108, 255, 0.08);
}

@media (max-width: 800px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.5rem;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .sidebar-brand { padding-bottom: 0; }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar-foot { margin-left: auto; }
    .pagebar, .content { padding-left: 1rem; padding-right: 1rem; }
}

/* ── Premium ── */
.premium-layout {
    display: grid;
    gap: 1.25rem;
}

.panel-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
}

.panel-card h2 {
    font-size: 1.05rem;
    margin-bottom: 0.35rem;
}

.panel-head-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    background: rgba(124, 108, 255, 0.15);
    border: 1px solid rgba(124, 108, 255, 0.35);
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 600;
}

.premium-form {
    display: grid;
    gap: 0.5rem;
    max-width: 420px;
    margin-top: 1rem;
}

.premium-form label {
    font-size: 0.82rem;
    color: var(--muted);
    margin-top: 0.35rem;
}

.premium-form input {
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
}

.premium-form button { margin-top: 0.75rem; width: fit-content; }

.hidden { display: none !important; }

.btn {
    display: inline-block;
    padding: 0.55rem 0.95rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
}

.btn-danger {
    background: rgba(248, 113, 113, 0.15);
    border: 1px solid rgba(248, 113, 113, 0.4);
    color: #fecaca;
}

.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.78rem; }

.data-table .actions { white-space: nowrap; }

.data-table code {
    font-size: 0.78rem;
    color: #c4d0ff;
}

/* ── Logs ── */
.logs-layout {
    display: grid;
    gap: 1.25rem;
}

.logs-panel-scraper {
    border-color: rgba(251, 191, 36, 0.25);
    background: linear-gradient(180deg, rgba(251, 191, 36, 0.04) 0%, var(--surface) 120px);
}

.logs-panel-scraper .log-feed {
    max-height: 210px;
}

.badge-scraper {
    background: rgba(251, 191, 36, 0.12);
    border: 1px solid rgba(251, 191, 36, 0.35);
    color: #fde68a;
}

.log-line-simple {
    grid-template-columns: 10.5rem minmax(0, 1fr);
}

.log-line-simple .log-msg {
    padding-top: 0.1rem;
}

.logs-panel .logs-desc {
    font-size: 0.82rem;
    margin-bottom: 0.75rem;
}

.log-feed {
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    font-size: 0.8rem;
}

.log-empty {
    padding: 1.5rem;
}

.log-line {
    display: grid;
    grid-template-columns: 10.5rem minmax(0, 1fr);
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    border-bottom: 1px solid rgba(37, 45, 61, 0.55);
    align-items: start;
}

.log-line:last-child { border-bottom: none; }

.log-body {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.45rem 0.6rem;
    min-width: 0;
}

.log-time {
    color: var(--muted);
    font-size: 0.72rem;
    line-height: 1.45;
    white-space: nowrap;
    padding-top: 0.1rem;
}

.log-tag {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    background: rgba(124, 108, 255, 0.12);
    border: 1px solid rgba(124, 108, 255, 0.25);
    color: #c4b5fd;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
    flex-shrink: 0;
}

.log-tag-scraper {
    background: rgba(251, 191, 36, 0.1);
    border-color: rgba(251, 191, 36, 0.3);
    color: #fde68a;
}

.log-tag-public {
    background: rgba(79, 140, 255, 0.1);
    border-color: rgba(79, 140, 255, 0.3);
    color: #93c5fd;
}

.log-tag-hop {
    background: rgba(52, 211, 153, 0.1);
    border-color: rgba(52, 211, 153, 0.3);
    color: #6ee7b7;
}

.log-tag-analytics {
    background: rgba(124, 108, 255, 0.1);
    border-color: rgba(124, 108, 255, 0.28);
    color: #c4b5fd;
}

.log-tag-cash {
    background: rgba(52, 211, 153, 0.08);
    border-color: rgba(52, 211, 153, 0.25);
    color: #a7f3d0;
}

.log-msg {
    flex: 1 1 12rem;
    min-width: 0;
    word-break: break-word;
    color: var(--text);
    line-height: 1.45;
}

.log-line.log-warn {
    background: rgba(251, 191, 36, 0.06);
}

.log-line.log-warn .log-tag {
    background: rgba(251, 191, 36, 0.12);
    border-color: rgba(251, 191, 36, 0.35);
    color: #fcd34d;
}

.log-line.log-error {
    background: rgba(248, 113, 113, 0.08);
}

.log-line.log-error .log-tag {
    background: rgba(248, 113, 113, 0.12);
    border-color: rgba(248, 113, 113, 0.35);
    color: #fca5a5;
}

.badge-warn {
    background: rgba(251, 191, 36, 0.12);
    border-color: rgba(251, 191, 36, 0.35);
}

@media (max-width: 700px) {
    .log-line {
        grid-template-columns: 1fr;
        gap: 0.35rem;
    }
}
