:root {
    --bg: #f6f7fb;
    --panel: #ffffff;
    --text: #18202f;
    --muted: #5e6a7d;
    --border: #d9deea;
    --primary: #ff9011;
    --primary-contrast: #191919;
    --success: #166534;
    --warning: #92400e;
    --danger: #991b1b;
    --shadow: 0 12px 30px rgba(17, 24, 39, .08);
}

html[data-theme="dark"] {
    --bg: #0f172a;
    --panel: #172033;
    --text: #f8fafc;
    --muted: #cbd5e1;
    --border: #334155;
    --primary: #ff9f2f;
    --primary-contrast: #111827;
    --success: #86efac;
    --warning: #fbbf24;
    --danger: #fca5a5;
    --shadow: 0 16px 40px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: inherit; }

.app-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--panel);
    border-right: 1px solid var(--border);
    padding: 24px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 22px;
    margin-bottom: 28px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: var(--primary);
    color: var(--primary-contrast);
}

.nav { display: grid; gap: 8px; }
.nav-link {
    display: block;
    padding: 12px 14px;
    text-decoration: none;
    color: var(--muted);
    border-radius: 12px;
    font-weight: 650;
}
.nav-link:hover, .nav-link.active {
    background: rgba(255, 144, 17, .16);
    color: var(--text);
}

.main { min-width: 0; }
.topbar {
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
}
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.content { padding: 28px; }

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.auth-card {
    width: min(460px, 100%);
    background: var(--panel);
    padding: 32px;
    border-radius: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.auth-card h1 { margin: 0 0 8px; }
.auth-card p { color: var(--muted); }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.card h2, .card h3 { margin-top: 0; }
.metric { font-size: 34px; font-weight: 850; }
.muted { color: var(--muted); }

.form-grid { display: grid; gap: 14px; }
.form-row { display: grid; gap: 7px; }
label { font-weight: 700; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    padding: 11px 12px;
    border-radius: 12px;
    font: inherit;
}
textarea { min-height: 120px; resize: vertical; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    text-decoration: none;
    font-weight: 750;
    cursor: pointer;
}
.btn-primary {
    background: var(--primary);
    color: var(--primary-contrast);
    border-color: var(--primary);
}
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 800;
    border: 1px solid var(--border);
}
.badge-success { color: var(--success); background: rgba(22, 101, 52, .12); }
.badge-warning { color: var(--warning); background: rgba(251, 191, 36, .14); }
.badge-danger { color: var(--danger); background: rgba(153, 27, 27, .12); }
.badge-muted { color: var(--muted); }

.alert {
    padding: 12px 14px;
    border-radius: 14px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    background: var(--panel);
}
.alert-success { border-color: rgba(22, 101, 52, .4); color: var(--success); }
.alert-error { border-color: rgba(153, 27, 27, .4); color: var(--danger); }
.alert-info { color: var(--muted); }

.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hidden { display: none !important; }

@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .grid-2, .grid-4 { grid-template-columns: 1fr; }
    .topbar { align-items: flex-start; flex-direction: column; gap: 12px; }
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}
.card-header h2,
.card-header h3 {
    margin: 0;
}
.collapse-toggle {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 8px 12px;
}
.collapsible-content.is-collapsed {
    display: none;
}
.row-message {
    margin-top: 10px;
    max-width: 520px;
}
.row-message .alert {
    margin-bottom: 0;
    padding: 10px 12px;
}
