:root,
html[data-theme="dark"] {
    --bg: #121417;
    --panel: #1a1d22;
    --panel2: #22262d;
    --panel3: #2a2f38;
    --text: #edf0f5;
    --muted: #a5adbb;
    --muted2: #7d8796;
    --border: #343a45;
    --input: #111317;
    --accent: #2f81f7;
    --accent-hover: #1f6feb;
    --danger: #ff6b6b;
    --danger-bg: #3a1f24;
    --success-bg: #17351f;
    --success-text: #9be9a8;
    --error-bg: #3a1f24;
    --error-text: #ffb4b4;
    --shadow: 0 10px 30px rgba(0,0,0,.35);
}
html[data-theme="light"] {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --panel2: #f8fafc;
    --panel3: #eef2f7;
    --text: #18202b;
    --muted: #566273;
    --muted2: #7b8794;
    --border: #d9e0ea;
    --input: #ffffff;
    --accent: #1565c0;
    --accent-hover: #0d47a1;
    --danger: #c62828;
    --danger-bg: #ffebee;
    --success-bg: #e7f6ea;
    --success-text: #1b5e20;
    --error-bg: #ffebee;
    --error-text: #b71c1c;
    --shadow: 0 10px 30px rgba(15,23,42,.12);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.app-shell { display: flex; height: 100vh; min-width: 0; }
.sidebar {
    width: 260px;
    flex: 0 0 260px;
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 18px 18px; border-bottom: 1px solid var(--border); }
.brand-icon { width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; background: var(--panel3); border-radius: 12px; font-size: 22px; }
.brand-title { font-weight: 700; font-size: 17px; }
.brand-subtitle { color: var(--muted2); font-size: 12px; margin-top: 2px; }
.menu { padding: 10px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.menu-item {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; border-radius: 10px;
    color: var(--muted); font-size: 14px; border: 1px solid transparent;
}
.menu-item:hover { background: var(--panel2); color: var(--text); text-decoration: none; }
.menu-item.active { background: var(--panel3); color: var(--text); border-color: var(--border); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-bg); color: var(--danger); }
.sidebar-bottom { margin-top: auto; padding: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.user-card { color: var(--muted); font-size: 13px; padding: 8px 4px; word-break: break-word; }
.theme-toggle, .btn, button, input, textarea, select { font-family: inherit; }
.theme-toggle {
    border: 1px solid var(--border); background: var(--panel2); color: var(--text);
    padding: 9px 12px; border-radius: 10px; cursor: pointer; font-size: 14px;
}
.theme-toggle:hover { background: var(--panel3); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.topbar {
    min-height: 62px; padding: 12px 22px; background: var(--panel); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-shrink: 0;
}
.topbar-title { font-weight: 650; color: var(--text); }
.mobile-theme { display: none; }
.content { flex: 1; min-width: 0; overflow: auto; padding: 22px; }
.content::-webkit-scrollbar, .table-wrap::-webkit-scrollbar, .menu::-webkit-scrollbar { width: 10px; height: 10px; }
.content::-webkit-scrollbar-thumb, .table-wrap::-webkit-scrollbar-thumb, .menu::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.search-box { display: flex; align-items: center; gap: 6px; max-width: 480px; width: min(480px, 100%); }
.search-box input { flex: 1; }
.count-badge { color: var(--muted); font-size: 13px; background: var(--panel); border: 1px solid var(--border); padding: 8px 12px; border-radius: 999px; }
.panel, .card, .form-card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }
.form-card { max-width: 680px; padding: 22px; }
.form-grid { display: grid; gap: 14px; }
label { display: block; color: var(--muted); font-size: 13px; font-weight: 600; margin-bottom: 6px; }
input[type="text"], input[type="email"], input[type="password"], input[type="file"], textarea, select {
    width: 100%; border: 1px solid var(--border); background: var(--input); color: var(--text);
    padding: 11px 12px; border-radius: 10px; outline: none; font-size: 14px;
}
textarea { resize: vertical; min-height: 100px; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,129,247,.18); }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    border: 1px solid var(--border); background: var(--panel2); color: var(--text);
    padding: 10px 14px; border-radius: 10px; cursor: pointer; font-size: 14px; line-height: 1; min-height: 40px;
}
.btn:hover { background: var(--panel3); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-bg); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.table-wrap { width: 100%; overflow: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }
table { width: 100%; min-width: 760px; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; font-size: 14px; }
th { position: sticky; top: 0; background: var(--panel2); color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: .04em; z-index: 2; }
tr:hover td { background: var(--panel2); }
tr:last-child td { border-bottom: 0; }
.chk { width: 42px; text-align: center; }
.cell-muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.action-links { display: flex; gap: 8px; justify-content: flex-end; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 9px; background: var(--panel2); border: 1px solid var(--border); }
.icon-btn:hover { background: var(--panel3); text-decoration: none; }
.avatar-mini { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); background: var(--panel3); }
.avatar-placeholder { width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: #fff; font-weight: 700; }
.avatar-preview, .avatar-full { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.avatar-preview img { width: 86px; height: 86px; object-fit: cover; border-radius: 50%; border: 1px solid var(--border); }
.avatar-full img { width: 140px; height: 140px; object-fit: cover; border-radius: 50%; border: 1px solid var(--border); }
.bulk-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.checkbox-label { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); margin: 0; }
.empty-state { display: grid; place-items: center; min-height: 55vh; text-align: center; color: var(--muted); }
.empty-box { max-width: 420px; }
.empty-icon { font-size: 62px; opacity: .55; margin-bottom: 8px; }
.message, .toast { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-size: 14px; }
.success { background: var(--success-bg); color: var(--success-text); border: 1px solid rgba(80,180,100,.25); }
.error { background: var(--error-bg); color: var(--error-text); border: 1px solid rgba(220,60,60,.25); }
.toast { position: fixed; right: 18px; top: 18px; z-index: 99; box-shadow: var(--shadow); transition: opacity .35s ease; }
.toast.hide { opacity: 0; pointer-events: none; }
.card { max-width: 760px; padding: 24px; }
.detail-list { display: grid; gap: 12px; margin-top: 14px; }
.detail-row { padding: 12px; background: var(--panel2); border-radius: 12px; border: 1px solid var(--border); }
.detail-label { color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; overflow: auto; }
.auth-box { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 30px; }
.auth-title { text-align: center; font-size: 30px; font-weight: 750; margin-bottom: 6px; }
.auth-subtitle { text-align: center; color: var(--muted); margin-bottom: 20px; }
.auth-theme { position: fixed; top: 16px; right: 16px; }
.hint { color: var(--muted2); font-size: 13px; margin: 8px 0 0; }
@media (max-width: 820px) {
    body { overflow: auto; }
    .app-shell { display: block; height: auto; min-height: 100vh; }
    .sidebar { width: 100%; min-height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
    .brand { padding: 12px 14px; }
    .menu { flex-direction: row; overflow-x: auto; padding: 8px; }
    .menu-item { white-space: nowrap; }
    .sidebar-bottom { flex-direction: row; align-items: center; overflow-x: auto; }
    .sidebar-bottom .theme-toggle { display: none; }
    .main { height: auto; min-height: calc(100vh - 150px); overflow: visible; }
    .topbar { position: sticky; top: 0; z-index: 20; padding: 10px 14px; }
    .mobile-theme { display: inline-flex; }
    .content { overflow: visible; padding: 14px; }
    .toolbar { align-items: stretch; }
    .search-box { width: 100%; max-width: none; }
    table { min-width: 680px; }
    .form-card, .card { max-width: none; padding: 16px; }
}
.hint {
    text-align: center;
}