:root {
    color-scheme: dark;
    --bg: #0b0b0c;
    --surface: #131315;
    --surface-2: #1a1a1d;
    --surface-3: #222226;
    --text: #f6f6f4;
    --muted: #98989f;
    --soft: #c8c8cc;
    --line: #2a2a2f;
    --line-strong: #3b3b42;
    --inverse: #0b0b0c;
    --inverse-text: #fff;
    --accent: #fff;
    --success: #75d79a;
    --success-bg: #102719;
    --warning: #e5bd61;
    --warning-bg: #29200f;
    --danger: #ef8888;
    --danger-bg: #2b1416;
    --info: #9eb7ed;
    --info-bg: #141c2c;
    --mark-bg: #fff;
    --mark-text: #0b0b0c;
    --mark-border: #fff;
    --role-admin: #8dccff;
    --role-admin-bg: #132635;
    --role-moderator: #ff9d9d;
    --role-moderator-bg: #32191b;
    --role-team: #8cdda9;
    --role-team-bg: #13291c;
    --shadow: 0 18px 50px rgba(0, 0, 0, .28);
    --sidebar: 264px;
    --radius: 16px;
    --radius-sm: 10px;
    --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f4f4f2;
    --surface: #fff;
    --surface-2: #f7f7f5;
    --surface-3: #ececea;
    --text: #101012;
    --muted: #6d6d72;
    --soft: #3f3f43;
    --line: #dededb;
    --line-strong: #c8c8c4;
    --inverse: #101012;
    --inverse-text: #fff;
    --accent: #101012;
    --success: #267a46;
    --success-bg: #e8f7ed;
    --warning: #85620f;
    --warning-bg: #fff5d8;
    --danger: #aa333a;
    --danger-bg: #fcebec;
    --info: #375d9e;
    --info-bg: #ebf1fc;
    --mark-bg: #111114;
    --mark-text: #fff;
    --mark-border: #111114;
    --role-admin: #247ab3;
    --role-admin-bg: #e2f3ff;
    --role-moderator: #ad353b;
    --role-moderator-bg: #ffe6e7;
    --role-team: #287a48;
    --role-team-bg: #e3f7ea;
    --shadow: 0 18px 50px rgba(18, 18, 20, .1);
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }
svg { display: block; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    display: flex;
    width: var(--sidebar);
    flex-direction: column;
    border-right: 1px solid var(--line);
    background: var(--surface);
}
.brand {
    display: flex;
    align-items: center;
    min-height: 90px;
    gap: 13px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--line);
}
.brand-mark {
    display: grid;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    place-items: center;
    border-radius: 12px;
    border: 1px solid var(--mark-border);
    background: var(--mark-bg);
    color: var(--mark-text);
    font-weight: 900;
    letter-spacing: -.08em;
}
.brand-logo { width: 27px; height: 27px; }
.brand-copy { min-width: 0; }
.brand-copy strong { display: block; font-size: 19px; letter-spacing: .08em; line-height: 1.1; }
.brand-copy small {
    display: block;
    overflow: hidden;
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.main-nav { display: flex; flex: 1; flex-direction: column; gap: 5px; padding: 24px 14px; }
.nav-label { padding: 0 12px 8px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 13px;
    min-height: 46px;
    padding: 0 13px;
    border: 1px solid transparent;
    border-radius: 11px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 650;
    transition: background .18s ease, color .18s ease, border-color .18s ease;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { border-color: var(--line); background: var(--surface-3); color: var(--text); }
.nav-item.active::before {
    position: absolute;
    left: -15px;
    width: 3px;
    height: 24px;
    border-radius: 0 4px 4px 0;
    background: var(--accent);
    content: "";
}
.nav-item .icon { flex: 0 0 auto; }
.sidebar-bottom { padding: 14px; border-top: 1px solid var(--line); }
.privacy-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 11px 14px;
    color: var(--muted);
    font-size: 12px;
}
.privacy-link span { flex: 1; }
.privacy-link:hover { color: var(--text); }
.sidebar-profile { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 13px; background: var(--surface-2); }
.profile-copy { min-width: 0; flex: 1; }
.profile-copy strong, .profile-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-copy strong { font-size: 12px; }
.profile-copy span { margin-top: 1px; color: var(--muted); font-size: 10px; }
.logout-form { display: inline-flex; margin: 0; }

.main-content { display: flex; min-height: 100vh; margin-left: var(--sidebar); flex-direction: column; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    min-height: 90px;
    align-items: center;
    justify-content: space-between;
    padding: 0 38px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
}
.topbar-title span, .topbar-title strong { display: block; }
.topbar-title span { color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
.topbar-title strong { margin-top: 3px; font-size: 15px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-user { display: flex; align-items: center; gap: 11px; padding-left: 10px; }
.topbar-user-copy { text-align: right; }
.topbar-user-copy strong, .topbar-user-copy small { display: block; }
.topbar-user-copy strong { font-size: 12px; }
.topbar-user-copy small { color: var(--muted); font-size: 10px; }
.mobile-menu { display: none !important; }
.theme-light-icon { display: none; }
:root[data-theme="light"] .theme-light-icon { display: block; }
:root[data-theme="light"] .theme-dark-icon { display: none; }

.page-wrap { width: 100%; max-width: 1500px; margin: 0 auto; padding: 38px; flex: 1; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.page-heading h1 { margin: 3px 0 0; font-size: clamp(27px, 3vw, 38px); line-height: 1.15; letter-spacing: -.04em; }
.page-heading p:not(.eyebrow) { max-width: 680px; margin: 9px 0 0; color: var(--muted); }
.eyebrow { margin: 0; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.page-actions { display: flex; align-items: center; gap: 10px; }
.app-footer { display: flex; justify-content: space-between; padding: 18px 38px 28px; color: var(--muted); font-size: 11px; }
.app-footer a:hover { color: var(--text); }

.icon-button {
    display: inline-grid;
    width: 40px;
    height: 40px;
    padding: 0;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--surface);
    cursor: pointer;
    transition: border-color .18s, background .18s, transform .18s;
}
.icon-button:hover { border-color: var(--line-strong); background: var(--surface-2); }
.icon-button:active { transform: scale(.96); }
.icon-button.small { width: 32px; height: 32px; border: 0; background: transparent; color: var(--muted); }
.icon-button.small:hover { background: var(--surface-3); color: var(--text); }

.button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
    transition: background .18s, border-color .18s, transform .18s;
}
.button:hover { border-color: var(--line-strong); background: var(--surface-2); }
.button:active { transform: translateY(1px); }
.button.primary { border-color: var(--accent); background: var(--accent); color: var(--inverse); }
:root[data-theme="light"] .button.primary { color: var(--inverse-text); }
.button.primary:hover { opacity: .88; }
.button.danger { border-color: var(--danger); color: var(--danger); }
.button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.button.small { min-height: 34px; padding: 0 11px; border-radius: 9px; font-size: 12px; }
.button .icon { flex: 0 0 auto; }

.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    margin: -12px 0 24px;
    padding: 10px 12px 10px 15px;
    border: 1px solid var(--line);
    border-radius: 12px;
    transition: opacity .5s;
}
.alert span { flex: 1; }
.alert-success { border-color: color-mix(in srgb, var(--success) 35%, var(--line)); background: var(--success-bg); color: var(--success); }
.alert-error { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); background: var(--danger-bg); color: var(--danger); }
.alert-info { background: var(--info-bg); color: var(--info); }
.alert-close { display: grid; padding: 7px; place-items: center; border: 0; background: transparent; color: currentColor; cursor: pointer; }
.alert.fade { opacity: .65; }

.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 66px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-header h2, .card-header h3 { margin: 0; font-size: 15px; }
.card-header p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.card-body { padding: 20px; }
.card-empty { display: grid; min-height: 220px; padding: 30px; place-items: center; text-align: center; }
.empty-icon { display: grid; width: 52px; height: 52px; margin: 0 auto 14px; place-items: center; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-2); color: var(--muted); }
.card-empty h3 { margin: 0; font-size: 16px; }
.card-empty p { max-width: 390px; margin: 6px auto 17px; color: var(--muted); font-size: 13px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 24px; }
.stat-card { position: relative; overflow: hidden; min-height: 150px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.stat-card > .stat-icon { display: grid; width: 38px; height: 38px; margin-top: 0; place-items: center; border-radius: 11px; background: var(--surface-3); color: var(--soft); }
.stat-card > .stat-icon .icon, .empty-icon .icon, .icon-button .icon { margin: auto; }
.stat-card strong { display: block; margin-top: 18px; font-size: 31px; line-height: 1; letter-spacing: -.05em; }
.stat-card > span:not(.stat-icon) { display: block; margin-top: 7px; color: var(--muted); font-size: 12px; }
.stat-card::after { position: absolute; right: -20px; bottom: -35px; width: 90px; height: 90px; border: 16px solid var(--surface-2); border-radius: 50%; content: ""; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .8fr); gap: 20px; }
.dashboard-stack { display: grid; gap: 20px; }
.activity-list, .compact-list { display: grid; }
.activity-item, .compact-item { display: flex; align-items: center; gap: 13px; min-height: 65px; padding: 10px 20px; border-bottom: 1px solid var(--line); }
.activity-item:last-child, .compact-item:last-child { border-bottom: 0; }
.activity-dot { width: 8px; height: 8px; flex: 0 0 8px; border: 2px solid var(--accent); border-radius: 50%; }
.activity-copy, .compact-copy { min-width: 0; flex: 1; }
.activity-copy strong, .compact-copy strong { display: block; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.activity-copy span, .compact-copy span { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.activity-time { color: var(--muted); font-size: 10px; white-space: nowrap; }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 20px; }
.quick-action { display: flex; min-height: 86px; flex-direction: column; justify-content: space-between; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); font-size: 11px; font-weight: 700; }
.quick-action .icon { color: var(--muted); }
.quick-action:hover { border-color: var(--line-strong); background: var(--surface-3); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.search-box { position: relative; width: min(100%, 360px); }
.search-box .icon { position: absolute; top: 50%; left: 13px; color: var(--muted); transform: translateY(-50%); pointer-events: none; }
.search-box input { width: 100%; height: 42px; padding: 0 14px 0 41px; border: 1px solid var(--line); border-radius: 11px; outline: none; background: var(--surface); color: var(--text); }
.search-box input:focus { border-color: var(--line-strong); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 9%, transparent); }
.toolbar-right { display: flex; align-items: center; gap: 10px; }
.result-count { color: var(--muted); font-size: 12px; }
.view-switch { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.view-switch button { display: grid; width: 34px; height: 32px; padding: 0; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.view-switch button.active { background: var(--surface-3); color: var(--text); }
[data-view-scope][data-view="table"] .view-grid { display: none; }
[data-view-scope][data-view="grid"] .view-table { display: none; }

.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { height: 48px; padding: 0 18px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.sort-button { display: inline-flex; align-items: center; gap: 6px; padding: 8px 0; border: 0; background: transparent; color: inherit; font: inherit; font-weight: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
.sort-button:hover, .sort-button[data-sort-direction] { color: var(--text); }
.sort-direction { display: inline-grid; width: 15px; height: 15px; place-items: center; color: var(--muted); font-size: 12px; letter-spacing: 0; }
.sort-button[data-sort-direction] .sort-direction { color: currentColor; }
.data-table td { height: 70px; padding: 10px 18px; border-bottom: 1px solid var(--line); color: var(--soft); font-size: 12px; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--surface-2); }
.entity-cell { display: flex; min-width: 160px; align-items: center; gap: 12px; }
.entity-cell strong, .entity-cell span { display: block; }
.entity-cell strong { color: var(--text); font-size: 13px; }
.entity-cell span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.actions-cell { text-align: right !important; white-space: nowrap; }
.row-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: 5px; }
.row-actions form { display: inline-flex; }
.badge { display: inline-flex; min-height: 25px; align-items: center; gap: 6px; padding: 0 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--soft); font-size: 10px; font-weight: 750; white-space: nowrap; }
.badge::before { width: 5px; height: 5px; border-radius: 50%; background: currentColor; content: ""; }
.badge.success { border-color: color-mix(in srgb, var(--success) 30%, var(--line)); color: var(--success); }
.badge.warning { border-color: color-mix(in srgb, var(--warning) 30%, var(--line)); color: var(--warning); }
.badge.danger { border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); color: var(--danger); }
.badge.role-admin { border-color: color-mix(in srgb, var(--role-admin) 42%, var(--line)); background: var(--role-admin-bg); color: var(--role-admin); }
.badge.role-moderator { border-color: color-mix(in srgb, var(--role-moderator) 42%, var(--line)); background: var(--role-moderator-bg); color: var(--role-moderator); }
.badge.role-team { border-color: color-mix(in srgb, var(--role-team) 42%, var(--line)); background: var(--role-team-bg); color: var(--role-team); }
.badge.neutral::before { display: none; }
.note-truncate { display: block; overflow: hidden; max-width: 260px; text-overflow: ellipsis; white-space: nowrap; }

.entity-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.entity-card { position: relative; min-width: 0; padding: 19px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.entity-card-top { display: flex; align-items: flex-start; gap: 13px; }
.entity-card-title { min-width: 0; flex: 1; }
.entity-card-title strong { display: block; overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.entity-card-title span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.entity-card .badge { margin-top: 13px; }
.entity-card .entity-meta .badge { margin-top: 0; }
.entity-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 17px 0; padding: 15px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.entity-meta div { min-width: 0; }
.entity-meta span, .entity-meta strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entity-meta span { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.entity-meta strong { margin-top: 4px; font-size: 11px; }
.entity-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.entity-card-note { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

.mc-avatar { position: relative; display: inline-grid; overflow: hidden; place-items: center; border: 1px solid var(--line); background: var(--surface-3); color: var(--soft); font-weight: 900; image-rendering: pixelated; }
.avatar-34 { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 8px; font-size: 12px; }
.avatar-36 { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 9px; font-size: 13px; }
.avatar-38 { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 9px; font-size: 14px; }
.avatar-40 { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 10px; font-size: 14px; }
.avatar-42 { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 10px; font-size: 15px; }
.avatar-48 { width: 48px; height: 48px; flex: 0 0 48px; border-radius: 11px; font-size: 17px; }
.mc-fallback { position: relative; z-index: 0; }
.mc-face, .mc-hat { position: absolute; z-index: 1; width: 800%; max-width: none; height: auto; image-rendering: pixelated; }
.mc-face { top: -100%; left: -100%; }
.mc-hat { top: -100%; left: -500%; z-index: 2; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.form-group { min-width: 0; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; color: var(--soft); font-size: 11px; font-weight: 750; }
.form-group label small { color: var(--muted); font-size: 9px; font-weight: 500; }
.field, .form-group input, .form-group select, .form-group textarea {
    width: 100%;
    min-height: 43px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    outline: none;
    background: var(--surface-2);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.form-group textarea { min-height: 104px; resize: vertical; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--line-strong); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 8%, transparent); }
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--muted); opacity: .7; }
.form-hint { margin: 6px 0 0; color: var(--muted); font-size: 10px; }
.checkbox { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }
.checkbox input { width: 17px; height: 17px; accent-color: var(--accent); }
.checkbox span { color: var(--soft); font-size: 12px; }
.password-field { position: relative; }
.password-field input { padding-right: 82px; }
.password-field button { position: absolute; top: 50%; right: 8px; padding: 5px; border: 0; background: transparent; color: var(--muted); font-size: 10px; cursor: pointer; transform: translateY(-50%); }
.form-section + .form-section { margin-top: 27px; padding-top: 23px; border-top: 1px solid var(--line); }
.form-section-heading { margin-bottom: 17px; }
.form-section-heading h3 { margin: 0; font-size: 14px; }
.form-section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }

dialog { width: min(92vw, 620px); max-height: 90vh; padding: 0; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 18px; outline: none; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, .68); }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 21px 22px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-size: 18px; letter-spacing: -.02em; }
.dialog-header p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.dialog-body { max-height: calc(90vh - 150px); padding: 22px; overflow-y: auto; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 9px; padding: 15px 22px; border-top: 1px solid var(--line); background: var(--surface-2); }

.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; }
.settings-nav { align-self: start; padding: 8px; position: sticky; top: 110px; }
.settings-nav a { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 11px; border-radius: 9px; color: var(--muted); font-size: 12px; font-weight: 700; }
.settings-nav a:hover { background: var(--surface-2); color: var(--text); }
.settings-nav a.active { background: var(--surface-3); color: var(--text); }
.settings-nav a.active .icon { color: var(--text); }
.settings-content { display: grid; gap: 20px; }
.settings-card .card-body { max-width: 780px; }
.settings-submit { display: flex; justify-content: flex-end; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.privacy-textarea { min-height: 320px !important; }
.login-background-preview { overflow: hidden; width: 100%; aspect-ratio: 16 / 6; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 12px; background: #0b0b0c; }
.login-background-preview img { display: block; width: 100%; height: 100%; object-fit: cover; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }

.login-page { display: grid; min-height: 100vh; grid-template-columns: minmax(360px, 520px) 1fr; background: var(--bg); }
.login-panel { display: flex; min-height: 100vh; flex-direction: column; padding: 34px clamp(28px, 5vw, 68px); border-right: 1px solid var(--line); background: var(--surface); }
.login-brand { display: flex; align-items: center; gap: 12px; align-self: flex-start; }
.login-brand strong, .login-brand span { display: block; }
.login-brand strong { font-size: 15px; }
.login-brand span { color: var(--muted); font-size: 10px; }
.login-content { width: 100%; max-width: 390px; margin: auto; padding: 60px 0; }
.login-content .eyebrow { margin-bottom: 9px; }
.login-content h1 { margin: 0; font-size: clamp(31px, 4vw, 44px); letter-spacing: -.05em; line-height: 1.05; }
.login-intro { margin: 12px 0 30px; color: var(--muted); }
.login-form { display: grid; gap: 17px; }
.login-form .button { width: 100%; margin-top: 5px; }
.login-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 2px; }
.login-meta a { color: var(--muted); font-size: 11px; }
.login-meta a:hover { color: var(--text); }
.login-footer { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; }
.login-page-centered { position: relative; isolation: isolate; grid-template-columns: 1fr; place-items: center; overflow: hidden; padding: 24px; background: #0b0b0c; }
.login-background-image { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; }
.login-page-centered.has-login-background::before { position: absolute; inset: 0; z-index: -1; background: rgba(0, 0, 0, .58); content: ""; }
.login-panel-centered { position: relative; z-index: 1; width: min(100%, 520px); min-height: 0; padding: 38px 42px 28px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.login-panel-centered .login-content { max-width: 390px; margin: 0 auto; padding: 8px 0 34px; }
.login-heading { margin-bottom: 29px; text-align: center; }
.login-heading .eyebrow { margin-bottom: 10px; }
.login-panel-centered .login-content h1 { font-size: clamp(30px, 5vw, 40px); }
.login-panel-centered .login-intro { margin-bottom: 0; }
.login-panel-centered .login-footer { padding-top: 19px; border-top: 1px solid var(--line); }
.login-visual { position: relative; display: grid; min-height: 100vh; overflow: hidden; place-items: center; padding: 60px; }
.visual-grid { position: absolute; inset: 0; opacity: .4; background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 48px 48px; }
.visual-mark { position: relative; z-index: 1; display: grid; width: min(27vw, 330px); aspect-ratio: 1; place-items: center; border: 1px solid var(--line-strong); background: var(--surface); box-shadow: 24px 24px 0 var(--surface-2); }
.visual-mark span { font-size: clamp(80px, 12vw, 160px); font-weight: 950; letter-spacing: -.1em; }
.visual-caption { position: absolute; right: 50px; bottom: 40px; z-index: 2; max-width: 300px; text-align: right; }
.visual-caption strong { display: block; font-size: 13px; }
.visual-caption span { color: var(--muted); font-size: 10px; }

.public-page { min-height: 100vh; background: var(--bg); }
.public-header { display: flex; min-height: 82px; align-items: center; justify-content: space-between; padding: 0 max(24px, calc((100vw - 980px) / 2)); border-bottom: 1px solid var(--line); background: var(--surface); }
.public-brand { display: inline-flex; min-width: 0; align-items: center; gap: 12px; }
.public-brand-logo { display: block; width: 40px; height: 40px; flex: 0 0 40px; border-radius: 11px; }
.public-brand-copy { display: block; min-width: 0; line-height: 1.2; }
.public-brand-copy strong, .public-brand-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.public-brand-copy strong { max-width: 330px; font-size: 14px; }
.public-brand-copy small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.public-header-actions { display: flex; align-items: center; gap: 9px; }
.public-content { width: min(calc(100% - 40px), 800px); margin: 0 auto; padding: 70px 0 100px; }
.public-content h1 { margin: 6px 0 12px; font-size: clamp(34px, 6vw, 58px); letter-spacing: -.055em; }
.public-lead { margin: 0 0 38px; color: var(--muted); }
.privacy-document { padding: clamp(22px, 5vw, 48px); border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.privacy-html { color: var(--soft); line-height: 1.75; overflow-wrap: anywhere; }
.privacy-html > :first-child { margin-top: 0; }
.privacy-html > :last-child { margin-bottom: 0; }
.privacy-html p, .privacy-html ul, .privacy-html ol, .privacy-html blockquote, .privacy-html pre { margin: 0 0 1.15em; }
.privacy-html h2, .privacy-html h3, .privacy-html h4 { margin: 1.6em 0 .55em; color: var(--text); line-height: 1.25; letter-spacing: -.025em; }
.privacy-html h2 { font-size: 24px; }
.privacy-html h3 { font-size: 19px; }
.privacy-html h4 { font-size: 15px; }
.privacy-html ul, .privacy-html ol { padding-left: 1.5em; }
.privacy-html li + li { margin-top: .35em; }
.privacy-html a { color: var(--text); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.privacy-html blockquote { padding: 3px 0 3px 18px; border-left: 3px solid var(--line-strong); color: var(--muted); }
.privacy-html code { padding: 2px 5px; border-radius: 5px; background: var(--surface-2); color: var(--text); font-size: .92em; }
.privacy-html pre { overflow-x: auto; padding: 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }
.privacy-html pre code { padding: 0; background: transparent; }
.privacy-html hr { margin: 1.7em 0; border: 0; border-top: 1px solid var(--line); }

.centered-page { display: grid; place-items: center; padding: 20px; }
.error-card { width: min(100%, 480px); padding: 42px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); text-align: center; }
.error-code { color: var(--muted); font-size: 12px; font-weight: 900; letter-spacing: .18em; }
.error-card h1 { margin: 10px 0 6px; font-size: 31px; }
.error-card p { margin: 0 0 24px; color: var(--muted); }
.setup-note { margin-bottom: 20px; padding: 12px 14px; border: 1px solid var(--warning); border-radius: 10px; background: var(--warning-bg); color: var(--warning); font-size: 11px; }

@media (max-width: 1180px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .entity-grid { grid-template-columns: 1fr 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
    :root { --sidebar: 280px; }
    .sidebar { transform: translateX(-100%); transition: transform .23s ease; box-shadow: var(--shadow); }
    .nav-backdrop { position: fixed; inset: 0; z-index: 25; display: none; background: rgba(0, 0, 0, .62); }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open .nav-backdrop { display: block; }
    .main-content { margin-left: 0; }
    .topbar { min-height: 72px; padding: 0 20px; }
    .mobile-menu { display: inline-grid !important; }
    .topbar-title { flex: 1; margin-left: 13px; }
    .topbar-title span { display: none; }
    .page-wrap { padding: 26px 20px; }
    .app-footer { padding: 18px 20px 26px; }
    .settings-layout { grid-template-columns: 1fr; }
    .settings-nav { position: static; display: flex; overflow-x: auto; }
    .settings-nav a { flex: 0 0 auto; }
    .login-page { grid-template-columns: 1fr; }
    .login-panel { border-right: 0; }
    .login-panel-centered { border: 1px solid var(--line); }
    .login-visual { display: none; }
}

@media (max-width: 640px) {
    .topbar-user-copy { display: none; }
    .topbar-actions { gap: 7px; }
    .page-heading { align-items: stretch; flex-direction: column; margin-bottom: 23px; }
    .page-actions { width: 100%; }
    .page-actions .button { width: 100%; }
    .page-heading h1 { font-size: 29px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { min-height: 135px; padding: 15px; }
    .stat-card strong { font-size: 26px; }
    .toolbar { align-items: stretch; flex-direction: column; }
    .search-box { width: 100%; }
    .toolbar-right { justify-content: space-between; }
    .entity-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .form-group.full { grid-column: auto; }
    .card-header { align-items: flex-start; flex-direction: column; }
    .dialog-footer { flex-direction: column-reverse; }
    .dialog-footer .button { width: 100%; }
    .quick-actions { grid-template-columns: 1fr 1fr; }
    .public-header { padding: 0 20px; }
    .public-brand-logo { width: 36px; height: 36px; flex-basis: 36px; }
    .public-brand-copy strong { max-width: 170px; }
    .public-content { padding-top: 45px; }
}

@media (max-width: 400px) {
    .topbar-title strong { font-size: 13px; }
    .stats-grid { grid-template-columns: 1fr; }
    .stat-card { min-height: 120px; }
    .stat-card strong { margin-top: 12px; }
    .quick-actions { grid-template-columns: 1fr; }
    .login-page-centered { padding: 12px; }
    .login-panel-centered { padding: 30px 22px 22px; }
    .public-brand-copy small { display: none; }
    .public-header-actions .button { padding: 0 11px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
