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

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --border: #2a2d3a;
    --accent: #6c63ff;
    --text: #e2e8f0;
    --text-muted: #718096;
    --danger: #e53e3e;
    --success: #38a169;
    --sidebar-w: 220px;
}

body {
    font-family: 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── Login ── */
.login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
}
.login-card h1 { font-size: 1.5rem; margin-bottom: 1.5rem; text-align: center; }

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
}
.sidebar .logo {
    font-size: 1.2rem;
    font-weight: 700;
    padding: 0 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}
.sidebar nav a {
    display: block;
    padding: 0.65rem 1.25rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.15s, background 0.15s;
}
.sidebar nav a:hover,
.sidebar nav a.active {
    color: var(--text);
    background: rgba(108,99,255,0.12);
    border-right: 3px solid var(--accent);
}
.sidebar .logout {
    margin-top: auto;
    padding: 0 1.25rem;
}
.sidebar .logout a {
    color: var(--danger);
    text-decoration: none;
    font-size: 0.9rem;
}

.main {
    margin-left: var(--sidebar-w);
    padding: 2rem;
    flex: 1;
}

h2 { font-size: 1.4rem; margin-bottom: 1.5rem; }

/* ── Stat Cards ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem;
    text-align: center;
}
.stat-card .num {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--accent);
}
.stat-card .label {
    margin-top: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ── Category Cards ── */
.cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.25rem;
}
.cat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    font-size: 1.3rem;
    font-weight: 600;
    transition: border-color 0.2s, transform 0.15s;
}
.cat-card:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
}

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: 10px;
    overflow: hidden;
}
th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* ── Forms ── */
.form-row { display: flex; gap: 0.75rem; margin-bottom: 1.25rem; }
input[type=text], input[type=password], textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 0.6rem 0.9rem;
    font-size: 0.9rem;
    outline: none;
}
input[type=text]:focus, input[type=password]:focus, textarea:focus {
    border-color: var(--accent);
}
.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #5a52d5; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-danger:hover  { background: #c53030; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

.alert { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert-error   { background: rgba(229,62,62,0.15);  border: 1px solid var(--danger);  color: #fc8181; }
.alert-success { background: rgba(56,161,105,0.15); border: 1px solid var(--success); color: #68d391; }

.page-top { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.page-top a { color: var(--text-muted); text-decoration: none; font-size: 0.85rem; }
.page-top a:hover { color: var(--text); }
