/* ===== Design tokens ===== */
:root {
    --color-primary: #5e1224;
    --color-primary-dark: #460d1b;
    --color-bg: #f6f2ef;
    --color-surface: #ffffff;
    --color-text: #2b2b2b;
    --color-muted: #7a7068;
    --color-border: #e3dcd5;
    --color-success-bg: #e6f4ea;
    --color-success-text: #1e6b3a;
    --color-error-bg: #fdecea;
    --color-error-text: #a3271c;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

a { color: var(--color-primary); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }

/* ===== Topbar ===== */
.topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--color-primary);
    color: #fff;
    padding: 0.6rem 1rem;
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
}

.topbar-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.3rem;
    cursor: pointer;
}

/* ===== Layout ===== */
.layout { display: flex; min-height: calc(100vh - 52px); }

.sidebar {
    width: 210px;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
}

.sidebar a {
    padding: 0.65rem 1.25rem;
    text-decoration: none;
    color: var(--color-text);
}

.sidebar a:hover { background: var(--color-bg); }

.nav-disabled { color: var(--color-muted) !important; cursor: not-allowed; }

.content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1100px;
}

/* ===== Cards & tables ===== */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.table-wrapper { padding: 0; overflow-x: auto; }

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

th, td {
    text-align: left;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

th { font-size: 0.8rem; text-transform: uppercase; color: var(--color-muted); }

.badge {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    font-size: 0.8rem;
}

/* ===== Stats ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.stat-card { text-align: center; margin: 0; }
.stat-value { display: block; font-size: 2rem; font-weight: 700; color: var(--color-primary); }
.stat-label { color: var(--color-muted); font-size: 0.85rem; }

/* ===== Forms ===== */
label { display: block; margin: 0.75rem 0 0.25rem; font-weight: 600; font-size: 0.9rem; }

input, select, textarea {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font: inherit;
    background: #fff;
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0 1.25rem;
}

.form-field-full { grid-column: 1 / -1; }
.form-card button[type="submit"] { margin-top: 1.25rem; }

.filters {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.filters input[type="search"] { flex: 1; min-width: 200px; width: auto; }
.filters select { width: auto; }

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

.btn-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.btn-primary:hover { background: var(--color-primary-dark); }
.btn-small { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
.btn-block { width: 100%; margin-top: 1.25rem; }

.btn-link {
    background: none;
    border: none;
    color: #fff;
    text-decoration: underline;
    cursor: pointer;
    font: inherit;
    padding: 0;
}

/* ===== Alerts ===== */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

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

/* ===== Misc ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

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

/* ===== Login ===== */
.guest {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.guest-container { width: 100%; max-width: 380px; padding: 1rem; }
.login-card { text-align: center; }
.login-card form { text-align: left; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .nav-toggle { display: block; }

    .sidebar {
        position: fixed;
        top: 52px;
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 15;
    }

    .sidebar.open { transform: translateX(0); }
    .content { padding: 1rem; }
}
