:root {
    --bg: #0c1018;
    --surface: #131a27;
    --surface-alt: #1a2334;
    --border: #253048;
    --text: #e7ecf7;
    --text-muted: #8b96ac;
    --text-faint: #5c6780;
    --accent: #4f8cff;
    --accent-dim: #2a4a86;
    --accent-2: #7c5cff;
    --success: #34d399;
    --success-bg: rgba(52, 211, 153, 0.12);
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.12);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.12);
    --radius: 10px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', Inter, -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------- Auth (login/register) pages --------------------------- */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 20% 20%, #16203a 0%, var(--bg) 55%);
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 36px 32px;
}

.auth-card h1 {
    margin: 0 0 4px;
    font-size: 22px;
    letter-spacing: -0.02em;
}

.auth-card p.sub {
    margin: 0 0 24px;
    color: var(--text-muted);
    font-size: 13px;
}

/* --------------------------------------- Layout -------------------------------------- */

.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 236px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 22px;
}

.brand .dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 0 12px var(--accent);
}

.brand span {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.01em;
}

.nav-section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
    padding: 16px 12px 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 500;
}

.nav-link:hover {
    background: var(--surface-alt);
    color: var(--text);
    text-decoration: none;
}

.nav-link.active {
    background: var(--accent-dim);
    color: #cfe0ff;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

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

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    border-bottom: 1px solid var(--border);
    background: rgba(19, 26, 39, 0.6);
    backdrop-filter: blur(6px);
    position: sticky;
    top: 0;
    z-index: 5;
}

.topbar h1 {
    font-size: 18px;
    margin: 0;
    letter-spacing: -0.01em;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-muted);
}

.content {
    padding: 24px 28px 60px;
    max-width: 1200px;
    width: 100%;
}

/* ---------------------------------------- Cards --------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    margin-bottom: 20px;
}

.card h2 {
    margin: 0 0 4px;
    font-size: 15px;
}

.card .card-sub {
    color: var(--text-muted);
    font-size: 12.5px;
    margin: 0 0 16px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.stat-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
}

.stat-tile .label {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.stat-tile .value {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* --------------------------------------- Tables ---------------------------------------- */

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:hover { background: var(--surface-alt); }
tbody tr:last-child td { border-bottom: none; }

.table-empty {
    padding: 32px;
    text-align: center;
    color: var(--text-muted);
}

/* --------------------------------------- Badges ---------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-neutral { background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); }
.badge-accent { background: var(--accent-dim); color: #cfe0ff; }

/* --------------------------------------- Forms ---------------------------------------- */

label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

input[type=text], input[type=password], input[type=search], input[type=number], select, textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13.5px;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.15);
}

.field { margin-bottom: 16px; }
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }

.help-text { font-size: 12px; color: var(--text-faint); margin-top: 5px; }

/* --------------------------------------- Buttons ---------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover { text-decoration: none; filter: brightness(1.08); }

.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.btn-danger { background: var(--danger); color: #201010; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-faint); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 11px; font-size: 12px; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* --------------------------------------- Misc ---------------------------------------- */

.flash {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 13px;
    border: 1px solid transparent;
}

.flash-success { background: var(--success-bg); color: var(--success); border-color: rgba(52, 211, 153, 0.3); }
.flash-error { background: var(--danger-bg); color: var(--danger); border-color: rgba(248, 113, 113, 0.3); }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono { font-family: 'Cascadia Code', 'Consolas', monospace; }

.pill-tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.pill-tab {
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 600;
}
.pill-tab.active { background: var(--accent-dim); color: #cfe0ff; border-color: transparent; }
.pill-tab:hover { text-decoration: none; color: var(--text); }

.search-row { display: flex; gap: 10px; margin-bottom: 18px; }
.search-row input { flex: 1; }

.profile-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.profile-header h1 { margin: 0; font-size: 22px; }

.divider { height: 1px; background: var(--border); margin: 18px 0; border: none; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state .big { font-size: 32px; margin-bottom: 8px; }

code.k { background: var(--surface-alt); padding: 2px 6px; border-radius: 5px; font-size: 12px; }

@media (max-width: 860px) {
    .sidebar { display: none; }
    .content { padding: 18px; }
}
