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

:root {
    --bg:          #09090b;
    --surface:     #111115;
    --surface2:    #1c1c24;
    --surface3:    #27273a;
    --border:      #242430;
    --border2:     #36364a;

    --text:        #f1f1f5;
    --text-2:      #a0a0b8;
    --text-muted:  #68688a;
    --text-subtle: #48485e;

    --accent:        #6366f1;
    --accent-hover:  #818cf8;
    --accent-dim:    rgba(99,102,241,.13);
    --accent-border: rgba(99,102,241,.28);

    --green:         #34d399;   --green-dim:   rgba(52,211,153,.12);
    --yellow:        #fbbf24;   --yellow-dim:  rgba(251,191,36,.12);
    --red:           #f87171;   --red-dim:     rgba(248,113,113,.12);
    --blue:          #60a5fa;   --blue-dim:    rgba(96,165,250,.12);
    --purple:        #c084fc;   --purple-dim:  rgba(192,132,252,.12);
    --emerald:       #2dd4bf;   --emerald-dim: rgba(45,212,191,.12);
    --orange:        #fb923c;   --orange-dim:  rgba(251,146,60,.12);

    --sidebar-w: 268px;
    --topbar-h:  64px;
    --r:    8px;
    --r-lg: 12px;
}

html { font-size: 15px; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
    min-height: 100vh;
    display: flex;
    -webkit-font-smoothing: antialiased;
    line-height: 1.55;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ═══════════════════════════ SIDEBAR ═══════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 20px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}
.logo-mark {
    width: 36px; height: 36px;
    background: linear-gradient(140deg, #6366f1 0%, #a78bfa 100%);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(99,102,241,.35);
}
.logo-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.15;
}
.logo-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 1px;
}

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

.nav-section {
    font-size: 0.63rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-subtle);
    padding: 14px 10px 5px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    border-radius: var(--r);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 450;
    transition: background 0.12s, color 0.12s;
    margin-bottom: 2px;
    position: relative;
}
.nav-link:hover { background: var(--surface2); color: var(--text-2); }
.nav-link.active {
    background: var(--accent-dim);
    color: var(--accent-hover);
    font-weight: 600;
}
.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 22%; bottom: 22%;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}
.nav-link .icon { width: 18px; text-align: center; font-size: 13px; flex-shrink: 0; opacity: .65; }
.nav-link.active .icon { opacity: 1; }

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 11px;
}
.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--accent-dim);
    border: 1.5px solid var(--accent-border);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
    color: var(--accent-hover);
    flex-shrink: 0;
    text-transform: uppercase;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 0.83rem; font-weight: 500; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-btn {
    background: none; border: none; cursor: pointer;
    color: var(--text-subtle); font-size: 18px; padding: 4px 5px;
    border-radius: 6px; line-height: 1;
    transition: color 0.12s, background 0.12s;
    font-family: inherit; flex-shrink: 0;
}
.logout-btn:hover { color: var(--red); background: var(--red-dim); }

/* ═══════════════════════ MAIN LAYOUT ════════════════════════ */
.main { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    height: var(--topbar-h);
    padding: 0 28px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 10; gap: 16px;
}
.topbar-title { font-size: 1rem; font-weight: 650; color: var(--text); letter-spacing: -0.015em; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.content { padding: 28px 32px; flex: 1; max-width: 1600px; }

/* ═══════════════════════ BUTTONS ═════════════════════════ */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 18px;
    border-radius: var(--r);
    font-size: 0.875rem; font-weight: 500;
    cursor: pointer; border: 1px solid transparent;
    text-decoration: none; transition: all 0.12s;
    white-space: nowrap; font-family: inherit; line-height: 1.4;
}
.btn-primary  { background: var(--accent);   color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text-2); border-color: var(--border2); }
.btn-secondary:hover { background: var(--surface3); color: var(--text); }
.btn-danger  { background: var(--red-dim);   color: var(--red);   border-color: rgba(248,113,113,.22); }
.btn-danger:hover  { background: rgba(248,113,113,.2); }
.btn-success { background: var(--green-dim); color: var(--green); border-color: rgba(52,211,153,.22); }
.btn-success:hover { background: rgba(52,211,153,.2); }
.btn-ghost   { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--surface2); color: var(--text-2); }
.btn-sm { padding: 6px 13px; font-size: 0.8rem; }
.btn-xs { padding: 4px 9px;  font-size: 0.75rem; }

/* ═══════════════════════ CARDS ═══════════════════════════ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.card-header {
    padding: 16px 22px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    font-size: 0.9rem; font-weight: 600; color: var(--text); gap: 12px;
}
.card-body { padding: 22px; }

/* ═══════════════════════ STATS ═══════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px; margin-bottom: 28px;
}
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-lg); padding: 20px 22px;
    position: relative; overflow: hidden;
}
.stat-card::after {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--accent), transparent);
}
.stat-value { font-size: 2.2rem; font-weight: 750; color: var(--text); line-height: 1; letter-spacing: -0.04em; }
.stat-label { font-size: 0.73rem; color: var(--text-muted); margin-top: 8px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }

/* ═══════════════════════ GRIDS ═══════════════════════════ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }

/* ═══════════════════════ TABLE ═══════════════════════════ */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    padding: 10px 14px; text-align: left;
    color: var(--text-muted); border-bottom: 1px solid var(--border);
    font-weight: 600; font-size: 0.72rem; text-transform: uppercase;
    letter-spacing: 0.06em; white-space: nowrap;
}
tbody td {
    padding: 13px 14px; border-bottom: 1px solid var(--border);
    color: var(--text-2); vertical-align: middle; font-size: 0.875rem;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface2); }
td a { color: var(--text-2); text-decoration: none; }
td a:hover { color: var(--text); }

/* ═══════════════════════ BADGES ══════════════════════════ */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 10px; border-radius: 20px;
    font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap;
}
.badge-gray    { background: rgba(100,100,130,.15); color: var(--text-muted); }
.badge-blue    { background: var(--blue-dim);    color: var(--blue); }
.badge-yellow  { background: var(--yellow-dim);  color: var(--yellow); }
.badge-green   { background: var(--green-dim);   color: var(--green); }
.badge-purple  { background: var(--purple-dim);  color: var(--purple); }
.badge-emerald { background: var(--emerald-dim); color: var(--emerald); }
.badge-red     { background: var(--red-dim);     color: var(--red); }
.badge-orange  { background: var(--orange-dim);  color: var(--orange); }

/* ═══════════════════════ FORMS ═══════════════════════════ */
.form-group { margin-bottom: 20px; }
label { display: block; margin-bottom: 6px; font-size: 0.83rem; color: var(--text-2); font-weight: 500; }
input[type=text], input[type=email], input[type=url],
input[type=password], input[type=number], select, textarea {
    width: 100%; padding: 10px 13px;
    background: var(--surface2); border: 1px solid var(--border2);
    border-radius: var(--r); color: var(--text); font-size: 0.875rem;
    outline: none; transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
select option { background: var(--surface2); }
textarea { min-height: 130px; resize: vertical; font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace; }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
.form-row   { display: grid; grid-template-columns: 1fr 1fr;     gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-error { font-size: 0.75rem; color: var(--red);        margin-top: 5px; }
.form-hint  { font-size: 0.75rem; color: var(--text-muted); margin-top: 5px; }

/* ═══════════════════════ ALERTS ══════════════════════════ */
.alert { padding: 12px 16px; border-radius: var(--r); margin-bottom: 20px; font-size: 0.875rem; border: 1px solid transparent; }
.alert-success { background: var(--green-dim);  border-color: rgba(52,211,153,.22);  color: var(--green); }
.alert-error   { background: var(--red-dim);    border-color: rgba(248,113,113,.22); color: var(--red); }
.alert-warning { background: var(--yellow-dim); border-color: rgba(251,191,36,.22);  color: var(--yellow); }
.alert-info    { background: var(--blue-dim);   border-color: rgba(96,165,250,.22);  color: var(--blue); }

/* ═══════════════════════ EDITOR ══════════════════════════ */
.md-editor { font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace; font-size: 0.875rem; min-height: 420px; line-height: 1.65; }
.editor-toolbar {
    display: flex; gap: 2px; padding: 8px 10px; flex-wrap: wrap;
    background: var(--surface2); border: 1px solid var(--border2);
    border-bottom: none; border-radius: var(--r) var(--r) 0 0;
}
.editor-toolbar button {
    background: none; border: none; color: var(--text-muted);
    padding: 4px 9px; border-radius: 5px; cursor: pointer;
    font-size: 0.8rem; font-family: inherit; transition: background 0.1s, color 0.1s;
}
.editor-toolbar button:hover { background: var(--surface3); color: var(--text); }
.editor-body { border-radius: 0 0 var(--r) var(--r); }

/* ═══════════════════════ SCORES ══════════════════════════ */
.score-bar      { height: 5px; background: var(--surface3); border-radius: 3px; margin: 5px 0; overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 3px; transition: width 0.4s; }
.score-high { background: var(--green); }
.score-mid  { background: var(--yellow); }
.score-low  { background: var(--red); }

/* ═══════════════════════ PAGINATION ══════════════════════ */
.pagination { display: flex; gap: 5px; align-items: center; margin-top: 22px; }
.pagination a, .pagination span { padding: 7px 12px; border-radius: var(--r); font-size: 0.83rem; text-decoration: none; }
.pagination a { color: var(--text-muted); background: var(--surface2); border: 1px solid var(--border2); transition: all 0.1s; }
.pagination a:hover { color: var(--text); }
.pagination .active { background: var(--accent); color: #fff; border: 1px solid var(--accent); }

/* ═══════════════════════ CODE ════════════════════════════ */
code { background: var(--surface3); padding: 2px 6px; border-radius: 5px; font-size: 0.82rem; font-family: 'JetBrains Mono', ui-monospace, monospace; color: var(--accent-hover); }
pre  { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; overflow-x: auto; font-size: 0.83rem; color: var(--text-2); }

/* ═══════════════════════ UTILITIES ═══════════════════════ */
.text-muted  { color: var(--text-muted); }
.text-2      { color: var(--text-2); }
.text-sm     { font-size: 0.83rem; }
.text-xs     { font-size: 0.75rem; }
.mt-4        { margin-top: 16px; }
.mt-6        { margin-top: 24px; }
.mt-8        { margin-top: 32px; }
.mb-4        { margin-bottom: 16px; }
.mb-6        { margin-bottom: 24px; }
.flex        { display: flex; }
.flex-col    { display: flex; flex-direction: column; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center  { display: flex; align-items: center; }
.gap-1  { gap: 4px; } .gap-2 { gap: 10px; } .gap-3 { gap: 14px; } .gap-4 { gap: 18px; }
.w-full { width: 100%; }
.truncate    { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px; }
.inline-form { display: inline; }
hr.divider   { border: none; border-top: 1px solid var(--border); margin: 22px 0; }

/* ═══════════════════════ LOGIN ════════════════════════════ */
.login-wrap { min-height: 100vh; width: 100%; display: flex; align-items: center; justify-content: center; }
.login-card { width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 32px; }
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
