@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg: #ffffff;
    --card: #ffffff;
    --text: #000000;
    --muted: #666666;
    --line: #e0e0e0;
    --accent: #000000;
    --accent-dark: #333333;
    --danger: #000000;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

img, video { max-width: 100%; height: auto; }

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    width: min(1200px, 92vw);
    margin: 0 auto;
}

/* ── Topbar ─────────────────────────────────────────────────────────────── */

.topbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--text);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 80px;
    gap: 1rem;
}

.brand {
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-size: 1.125rem;
    display: flex;
    flex-direction: column;
}

.brand-sub {
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-top: -2px;
}

.nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav a {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.nav a:hover { color: var(--muted); }

.user-role {
    border: 1px solid var(--text);
    padding: 0.3rem 0.8rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */

.page { padding: 3rem 0; }

.app-shell {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 3rem;
    align-items: start;
}

.sidebar {
    position: sticky;
    top: 110px;
    border-right: 1px solid var(--line);
    padding-right: 1.5rem;
}

.sidebar-label {
    margin: 0 0 1.5rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
}

.sidebar-nav { display: grid; gap: 0.5rem; }

.sidebar-link {
    text-decoration: none;
    color: var(--muted);
    padding: 0.5rem 0.75rem;
    font-weight: 500;
    font-size: 0.9rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.sidebar-link:hover {
    color: var(--text);
    background: #f5f5f5;
}

.sidebar-link.active {
    color: var(--bg);
    background: var(--text);
}

.content-area { min-width: 0; }

/* ── Cards ──────────────────────────────────────────────────────────────── */

.card {
    background: var(--card);
    border: 1px solid var(--line);
    padding: 2.5rem;
    margin-bottom: 2rem;
}

.card h1, .card h2, .card h3 {
    margin-top: 0;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.card h1 { font-size: 2rem; }
.card h2 { font-size: 1.5rem; border-bottom: 1px solid var(--line); padding-bottom: 1rem; margin-bottom: 1.5rem; }
.card h3 { font-size: 1.25rem; }

.form-card { max-width: 640px; }

.muted { color: var(--muted); }

/* ── Stats ──────────────────────────────────────────────────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat.card {
    padding: 2rem;
    margin: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border: 1px solid var(--text);
    box-shadow: 4px 4px 0px 0px var(--text);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat.card:hover {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px 0px var(--text);
}

.stat h3 {
    margin: 0 0 0.5rem 0;
    font-size: 3rem;
    font-weight: 400;
    color: var(--text);
}

.stat p { margin: 0; font-size: 0.875rem; color: var(--muted); font-weight: 500; }

/* ── Table ──────────────────────────────────────────────────────────────── */

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

.data-table { width: 100%; border-collapse: collapse; }

.data-table th,
.data-table td {
    text-align: left;
    padding: 0.9rem 0.5rem;
    border-bottom: 1px solid var(--line);
}

.data-table th {
    color: var(--muted);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 600;
}

.data-table .data-table th:first-child,
.data-table td:first-child {
    width: 60px;
    color: var(--muted);
}

.row-protected td { background: #fafafa; }

.audit-action {
    font-family: 'Courier New', monospace;
    font-size: 0.82rem;
    letter-spacing: 0.02em;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn, button, input, select, textarea {
    font: inherit;
    border-radius: 0;
}

.btn, button {
    border: 1px solid var(--text);
    background: var(--bg);
    color: var(--text);
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.btn:hover, button:hover { background: #f5f5f5; }

.btn-primary { background: var(--text); color: var(--bg); }
.btn-primary:hover { background: var(--bg); color: var(--text); }

.btn-sm {
    padding: 0.4rem 0.9rem;
    font-size: 0.82rem;
}

.btn-danger { border-color: var(--text); color: var(--text); }
.btn-danger:hover { background: var(--text); color: var(--bg); }

.inline-form { display: inline; }

/* ── Form ───────────────────────────────────────────────────────────────── */

.field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.field label, .field span { font-weight: 500; font-size: 0.9rem; }

.required { color: var(--text); font-weight: 700; }

.field input,
.field select,
.field textarea {
    border: 1px solid var(--line);
    padding: 0.75rem;
    background: var(--bg);
    transition: border-color 0.2s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--text);
}

.field-error {
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 500;
    border-left: 2px solid var(--text);
    padding-left: 0.5rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding-top: 1rem;
}

/* ── Action bar ─────────────────────────────────────────────────────────── */

.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--line);
}

/* ── Badges ─────────────────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    border: 1px solid var(--text);
    padding: 0.2rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-success { background: var(--text); color: var(--bg); }
.badge-muted   { background: var(--bg); color: var(--muted); border-color: var(--muted); }
.badge-pending { background: var(--bg); color: var(--text); border-style: dashed; }

/* ── Alerts ─────────────────────────────────────────────────────────────── */

.alert {
    padding: 1rem;
    margin-bottom: 2rem;
    border: 1px solid var(--text);
    font-weight: 500;
    font-size: 0.9rem;
}

.alert-success { background: var(--text); color: var(--bg); }
.alert-error   { background: var(--bg); color: var(--text); border-style: dashed; }

/* ── Auth card ──────────────────────────────────────────────────────────── */

.auth-card {
    max-width: 480px;
    margin: 4rem auto;
    border: 1px solid var(--text);
    box-shadow: 8px 8px 0px 0px var(--text);
    padding: 2.5rem;
}

.auth-card h1 {
    margin-top: 0;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 920px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--line);
        padding-right: 0;
        padding-bottom: 1.5rem;
    }
    .sidebar-nav {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
}

@media (max-width: 760px) {
    .topbar-inner {
        min-height: 64px;
        flex-direction: column;
        padding: 1rem 0;
        gap: 1rem;
    }
}
