:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #f0f2f5;
  --ink: #16181d;
  --muted: #6e737d;
  --line: #e3e5e9;
  --line-strong: #d2d5da;
  --accent: #6757e8;
  --accent-soft: #eeecff;
  --danger: #b93b43;
  --sidebar: #111318;
  --sidebar-muted: #8f949e;
  --overlay-bg: rgba(246, 247, 249, .92);
  --mobile-menu-bg: #ffffff;
  --mobile-menu-ink: #16181d;
  --mobile-menu-muted: #6e737d;
  --mobile-menu-border: #e3e5e9;
  --mobile-menu-control: #f0f2f5;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1014;
  --panel: #17191f;
  --panel-soft: #20232a;
  --ink: #f2f3f5;
  --muted: #969ba5;
  --line: #2a2d34;
  --line-strong: #3a3e47;
  --accent: #8b7cf5;
  --accent-soft: #292544;
  --danger: #ff8e94;
  --sidebar: #0a0c0f;
  --sidebar-muted: #8f949e;
  --overlay-bg: rgba(14, 16, 20, .92);
  --mobile-menu-bg: #111318;
  --mobile-menu-ink: #ffffff;
  --mobile-menu-muted: #8f949e;
  --mobile-menu-border: #2c2f36;
  --mobile-menu-control: #1c1f24;
}

:root[data-theme="light"] { color-scheme: light; }

@font-face {
  font-family: "Material Symbols Rounded";
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url("/assets/material-symbols-lock-reset.ttf") format("truetype");
}

* { box-sizing: border-box; }
html { min-width: 320px; background: #000; }
body { margin: 0; min-height: 100vh; color: var(--ink); background-color: #000; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

body,
.login-shell,
.content-shell,
.site-card,
.table-card,
.search-box,
.user-dialog,
.login-form input,
.form-grid input,
.form-grid select {
  transition: color .25s ease, background-color .25s ease, border-color .25s ease;
}

.brand { display: inline-flex; align-items: center; gap: 10px; width: fit-content; color: inherit; text-decoration: none; font-size: 16px; font-weight: 750; letter-spacing: -.02em; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; background: var(--accent); font-size: 14px; font-weight: 800; box-shadow: 0 5px 18px rgba(103,87,232,.25); }

/* Logowanie */
.login-shell {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 20%, rgba(103,87,232,.07), transparent 32%),
    var(--bg);
}

.login-theme-toggle {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: var(--panel);
  cursor: pointer;
  font-size: 17px;
}
.login-theme-toggle:hover { border-color: var(--line-strong); background: var(--panel-soft); }

.login-card { width: min(100%, 390px); }
.login-brand { margin-bottom: clamp(36px, 7vh, 66px); }
.login-heading h1 { margin: 0; font-size: clamp(31px, 6vw, 40px); line-height: 1.08; letter-spacing: -.045em; }
.login-heading p { margin: 10px 0 28px; color: var(--muted); font-size: 14px; }
.login-form { display: grid; gap: 9px; }
.login-form label { margin-top: 7px; color: var(--ink); font-size: 12px; font-weight: 650; }
.login-form input, .form-grid input, .form-grid select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  outline: none;
  color: var(--ink);
  background: var(--panel);
  transition: border-color .16s, box-shadow .16s;
}
.login-form input { height: 48px; padding: 0 14px; }
.login-form input:focus, .form-grid input:focus, .form-grid select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(103,87,232,.11); }
.login-form button {
  height: 48px;
  margin-top: 14px;
  border: 0;
  border-radius: 11px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  background: var(--ink);
  cursor: pointer;
  font-weight: 700;
}
.login-form button:hover { background: #292c32; }
.login-form button:disabled { opacity: .6; cursor: wait; }
.form-error { margin: 0 0 16px; border: 1px solid #efc8ca; border-radius: 10px; padding: 10px 12px; color: var(--danger); background: #fff4f4; font-size: 12px; line-height: 1.45; }

:root[data-theme="dark"] .login-form button,
:root[data-theme="dark"] .primary-button { border-color: #f2f3f5; color: #15171b; background: #f2f3f5; }
:root[data-theme="dark"] .login-form button:hover,
:root[data-theme="dark"] .primary-button:hover { background: #dfe1e5; }
:root[data-theme="dark"] .form-error { border-color: #62373b; background: #2b1b1e; }

/* Układ aplikacji */
.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 250px;
  padding: 25px 17px 18px;
  display: flex;
  flex-direction: column;
  color: #f6f7f9;
  background: var(--sidebar);
}
.brand-app { margin: 0 10px; }
.side-nav { min-height: 0; margin-top: 39px; display: flex; flex: 1; flex-direction: column; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #2e3138 transparent; }
.nav-section + .nav-section { margin-top: 32px; }
.account-section { margin-top: auto !important; padding-top: 30px; }
.nav-label { margin: 0 10px 9px; color: #666b75; font-size: 10px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.nav-item {
  width: 100%;
  min-height: 41px;
  border: 0;
  border-radius: 9px;
  padding: 0 11px;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  color: var(--sidebar-muted);
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  font-weight: 590;
}
.nav-item:hover { color: #fff; background: #1d2026; }
.nav-item.active { color: #fff; background: #24272e; }
.nav-symbol { width: 16px; flex: 0 0 auto; color: #777d87; text-align: center; font-size: 15px; }
.icon-sites { height: 16px; color: currentColor; background:
  linear-gradient(currentColor 0 0) 1px 1px / 5px 5px no-repeat,
  linear-gradient(currentColor 0 0) 10px 1px / 5px 5px no-repeat,
  linear-gradient(currentColor 0 0) 1px 10px / 5px 5px no-repeat,
  linear-gradient(currentColor 0 0) 10px 10px / 5px 5px no-repeat; }
.material-symbols-rounded { font-family: "Material Symbols Rounded"; font-weight: normal; font-style: normal; font-size: 18px; line-height: 1; letter-spacing: normal; text-transform: none; white-space: nowrap; word-wrap: normal; direction: ltr; }
.icon-users { position: relative; height: 16px; color: currentColor; }
.icon-users { background:
  radial-gradient(circle at 5px 4px, currentColor 0 2px, transparent 2.2px),
  radial-gradient(circle at 12px 5px, currentColor 0 2px, transparent 2.2px),
  radial-gradient(ellipse at 5px 13px, currentColor 0 4px, transparent 4.2px),
  radial-gradient(ellipse at 12px 13px, currentColor 0 4px, transparent 4.2px); }
.sidebar-sites { display: grid; gap: 1px; }
.sidebar-site-link { text-decoration: none; }
.sidebar-site-link span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-empty { color: #5f646e; cursor: default; }
.sidebar-empty:hover { color: #5f646e; background: transparent; }
.site-mini-mark { width: 18px; height: 18px; flex: 0 0 auto; border-radius: 5px; display: grid; place-items: center; color: #b7b1ff; background: #29263b; font-size: 8px; font-weight: 800; }

.profile-block { margin-top: 16px; border-top: 1px solid #292c32; padding: 16px 9px 0; display: grid; grid-template-columns: 33px minmax(0,1fr); gap: 10px; align-items: center; }
.avatar, .user-avatar { display: grid; place-items: center; color: #3d348e; background: #ddd9ff; font-size: 11px; font-weight: 800; }
.avatar { width: 33px; height: 33px; border-radius: 9px; }
.profile-copy { min-width: 0; display: grid; gap: 2px; }
.profile-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.profile-copy span { color: #727782; font-size: 10px; }

.content-shell { min-height: 100vh; margin-left: 250px; background: var(--bg); }
.sidebar, .content-shell { transition: width .25s ease, margin-left .25s ease, padding .25s ease; }
.view-section { max-width: 1400px; margin: 0 auto; padding: 57px clamp(32px, 5vw, 72px) 72px; }
.site-view { height: 100vh; height: 100svh; overflow: hidden; background: #000; }
.site-frame { width: 100%; height: 100%; border: 0; display: block; background: #000; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 28px; }
.page-heading h2 { margin: 0; font-size: clamp(31px, 4vw, 44px); line-height: 1; letter-spacing: -.045em; }
.page-heading > div > p { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.site-controls { width: min(100%, 500px); display: grid; grid-template-columns: minmax(180px, 1fr) 190px; gap: 10px; }
.search-box { width: min(100%, 270px); height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; display: flex; align-items: center; gap: 8px; color: #9297a0; background: var(--panel); }
.site-controls .search-box { width: 100%; }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 13px; }
.sort-box { height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px 0 12px; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px; color: var(--muted); background: var(--panel); font-size: 10px; font-weight: 700; }
.sort-box select { min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; cursor: pointer; font-size: 11px; font-weight: 650; }
.sort-box select option { color: #16181d; background-color: #fff; }
:root[data-theme="light"] .sort-box select { color-scheme: light; }
:root[data-theme="dark"] .sort-box select { color-scheme: dark; color: #f2f3f5; background-color: #17191f; }
:root[data-theme="dark"] .sort-box select option { color: #f2f3f5; background-color: #17191f; }
.sort-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(103,87,232,.11); }
.collection-bar { margin-top: 38px; border-bottom: 1px solid var(--line); padding-bottom: 13px; display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.collection-bar strong { color: var(--ink); }
.local-preview-note i { display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: #58a878; }

/* Karty z lokalnym podglądem */
.sites-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 20px; margin-top: 22px; }
.site-card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--ink); background: var(--panel); box-shadow: 0 4px 18px rgba(22,24,29,.035); transition: border-color .18s, transform .18s, box-shadow .18s; }
.site-card:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: 0 12px 30px rgba(22,24,29,.075); }
.site-preview-wrap { position: relative; height: 190px; overflow: hidden; border-bottom: 1px solid var(--line); background: #e9ebef; }
.site-preview { position: absolute; inset: 0; width: 400%; height: 400%; border: 0; transform: scale(.25); transform-origin: top left; pointer-events: none; background: #fff; }
.preview-shade { position: absolute; inset: 0; background: linear-gradient(transparent 72%, rgba(15,17,21,.08)); pointer-events: none; }
.preview-hit { position: absolute; inset: 0; z-index: 2; }
.preview-open { position: absolute; right: 12px; bottom: 12px; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: rgba(17,19,24,.9); box-shadow: 0 5px 16px rgba(0,0,0,.16); font-size: 16px; }
.site-card-body { padding: 16px 17px 17px; }
.site-title-row { display: grid; grid-template-columns: 32px minmax(0,1fr); gap: 10px; align-items: center; }
.site-icon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: #4337a1; background: var(--accent-soft); font-size: 10px; font-weight: 800; }
.site-card h3 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; line-height: 1.25; }
.site-card h3 a { color: inherit; text-decoration: none; }
.site-card h3 a:hover { color: var(--accent); }
.site-card p { margin: 10px 0 0; min-height: 34px; color: var(--muted); display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: 11px; line-height: 1.55; }
.site-card-foot { margin-top: 13px; color: #9a9ea6; font-size: 10px; }
.empty-state { margin-top: 22px; border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 55px 24px; text-align: center; background: rgba(255,255,255,.45); }
.empty-mark { color: var(--accent); font-size: 32px; }
.empty-state h3 { margin: 10px 0 7px; font-size: 17px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 12px; }

/* Użytkownicy */
.primary-button, .secondary-button { min-height: 42px; border-radius: 10px; padding: 0 15px; cursor: pointer; font-size: 12px; font-weight: 700; }
.primary-button { border: 1px solid var(--ink); color: #fff; background: var(--ink); }
.primary-button:hover { background: #2b2e34; }
.primary-button:disabled { opacity: .55; cursor: wait; }
.secondary-button { border: 1px solid var(--line-strong); color: var(--ink); background: var(--panel); }
.secondary-button:hover { background: var(--panel-soft); }
.table-card { margin-top: 38px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.table-summary { border-bottom: 1px solid var(--line); padding: 15px 19px; color: var(--muted); font-size: 11px; }
.table-summary strong { color: var(--ink); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { color: #878c95; background: #fafafa; font-size: 9px; letter-spacing: .1em; text-align: left; text-transform: uppercase; }
th, td { border-bottom: 1px solid var(--line); padding: 14px 18px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.user-cell { min-width: 205px; display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 34px; height: 34px; flex: 0 0 auto; border-radius: 9px; }
.user-copy { display: grid; gap: 3px; }
.user-copy strong { font-size: 12px; }
.user-copy span { color: var(--muted); font-size: 10px; }
.role-pill, .status-pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 8px; font-size: 9px; font-weight: 750; }
.role-pill.admin { color: #4437a2; background: var(--accent-soft); }
.role-pill.user { color: #454a52; background: #eff0f2; }
.status-pill { gap: 5px; color: #2d7749; background: #eaf5ee; }
.status-pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: #4ba66d; }
.status-pill.off { color: #777b83; background: #f0f1f2; }
.status-pill.off::before { background: #9b9fa6; }
.access-cell { min-width: 160px; color: var(--muted); font-size: 11px; }
.edit-user { border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; color: var(--ink); background: var(--panel); cursor: pointer; font-size: 10px; font-weight: 700; }
.edit-user:hover { border-color: var(--line-strong); background: var(--panel-soft); }

/* Okno użytkownika */
.user-dialog { width: min(680px, calc(100% - 28px)); max-height: calc(100vh - 30px); border: 0; border-radius: 16px; padding: 0; color: var(--ink); background: var(--panel); box-shadow: 0 30px 90px rgba(10,12,16,.28); }
.user-dialog::backdrop { background: rgba(12,14,18,.65); backdrop-filter: blur(3px); }
.user-dialog form { padding: 27px; }
.dialog-head { display: flex; justify-content: space-between; gap: 20px; }
.dialog-kicker { margin: 0 0 7px; color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.dialog-head h2 { margin: 0; font-size: 27px; letter-spacing: -.035em; }
.close-button { border: 0; color: var(--muted); background: transparent; cursor: pointer; font-size: 28px; line-height: 1; }
.user-dialog .form-error { margin-top: 18px; }
.form-grid { margin-top: 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid label, fieldset legend { display: grid; gap: 7px; color: #42464e; font-size: 11px; font-weight: 700; }
.form-grid input, .form-grid select { height: 42px; padding: 0 12px; }
.form-grid small, fieldset > p { color: var(--muted); font-size: 10px; font-weight: 400; }
.full-field { grid-column: 1 / -1; }
.switch-field { align-content: end; grid-template-columns: 17px 1fr; }
.switch-field input { width: 17px; height: 17px; accent-color: var(--accent); }
.switch-field span { display: grid; gap: 2px; }
.switch-field strong { font-size: 11px; }
.user-dialog fieldset { margin: 23px 0 0; border: 1px solid var(--line); border-radius: 11px; padding: 16px; }
.user-dialog fieldset legend { padding: 0 5px; }
.user-dialog fieldset > p { margin: 0 0 11px; }
.permissions-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-height: 170px; overflow-y: auto; }
.permission-option { border: 1px solid var(--line); border-radius: 9px; padding: 9px; display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 11px; }
.permission-option:hover { background: var(--panel-soft); }
.permission-option input { accent-color: var(--accent); }
.admin-access-note { margin-top: 23px; border-radius: 10px; padding: 12px; color: #4437a2; background: var(--accent-soft); font-size: 11px; }
.dialog-actions { margin-top: 25px; border-top: 1px solid var(--line); padding-top: 18px; display: flex; justify-content: flex-end; gap: 9px; }
.password-dialog { width: min(470px, calc(100% - 28px)); }
.password-form-grid { grid-template-columns: 1fr; }
.password-requirements-wrap { border: 1px solid var(--line); border-radius: 11px; padding: 13px; background: var(--panel-soft); }
.admin-password-requirements { grid-column: 1 / -1; }
.password-requirements-wrap > p { margin: 0 0 10px; color: var(--ink); font-size: 10px; font-weight: 750; }
.password-requirements { margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; list-style: none; }
.password-requirements li { min-width: 0; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; transition: color .16s; }
.password-requirements li:last-child { grid-column: 1 / -1; }
.admin-password-requirements .password-requirements li:last-child { grid-column: auto; }
.password-requirements i { width: 16px; height: 16px; flex: 0 0 auto; border: 1px solid var(--line-strong); border-radius: 50%; display: grid; place-items: center; color: #fff; background: transparent; font-style: normal; transition: border-color .16s, background-color .16s, transform .16s; }
.password-requirements li.met { color: var(--ink); }
.password-requirements li.met i { border-color: #3c9a62; background: #3c9a62; transform: scale(1.04); }
.password-requirements li.met i::after { content: "✓"; font-size: 10px; font-weight: 800; }
.password-session-note { margin: 18px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }

.toast { position: fixed; right: 20px; bottom: 20px; z-index: 100; max-width: min(400px, calc(100vw - 40px)); border-radius: 10px; padding: 12px 14px; color: #fff; background: var(--ink); box-shadow: 0 12px 35px rgba(10,12,16,.2); opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .18s, transform .18s; font-size: 12px; }
.toast.show { opacity: 1; transform: translateY(0); }
.loading-screen { position: fixed; inset: 0; z-index: 200; display: grid; place-content: center; justify-items: center; gap: 17px; background: var(--bg); transition: opacity .2s; }
.loading-screen.ready { opacity: 0; pointer-events: none; }
.loading-screen .brand-mark { animation: pulse .8s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(.92); opacity: .7; } }

.transition-screen {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 13px;
  visibility: hidden;
  opacity: 0;
  color: var(--ink);
  background: var(--overlay-bg);
  backdrop-filter: blur(10px);
  pointer-events: none;
  transition: opacity .18s ease, visibility 0s linear .18s;
}
.transition-screen.active { visibility: visible; opacity: 1; pointer-events: auto; transition-delay: 0s; }
.transition-screen.leaving { opacity: 0; }
.transition-screen .brand-mark { width: 42px; height: 42px; border-radius: 12px; font-size: 17px; animation: transition-mark .85s cubic-bezier(.2,.8,.2,1) infinite alternate; }
.transition-screen strong { margin-top: 4px; font-size: 12px; font-weight: 650; letter-spacing: -.01em; }
.loading-dots { height: 8px; display: flex; align-items: center; gap: 4px; }
.loading-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: loading-dot .8s ease-in-out infinite alternate; }
.loading-dots i:nth-child(2) { animation-delay: .14s; }
.loading-dots i:nth-child(3) { animation-delay: .28s; }
.app-shell.entering .view-section,
.login-shell.entering .login-card { animation: view-enter .46s cubic-bezier(.2,.75,.2,1) both; }
@keyframes transition-mark { to { transform: translateY(-5px) rotate(-3deg); box-shadow: 0 10px 26px rgba(103,87,232,.34); } }
@keyframes loading-dot { from { transform: translateY(2px); opacity: .35; } to { transform: translateY(-2px); opacity: 1; } }
@keyframes view-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.mobile-header, .mobile-nav, .mobile-menu-backdrop { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

:root[data-theme="dark"] .site-preview-wrap { background: #111318; }
:root[data-theme="dark"] .empty-state { background: rgba(255,255,255,.015); }
:root[data-theme="dark"] th { background: #13151a; }
:root[data-theme="dark"] .role-pill.user { color: #c7cad0; background: #272a31; }
:root[data-theme="dark"] .role-pill.admin { color: #c9c3ff; }
:root[data-theme="dark"] .status-pill { color: #88d7a6; background: #1d3025; }
:root[data-theme="dark"] .status-pill.off { color: #a3a7af; background: #26282e; }
:root[data-theme="dark"] .user-avatar { color: #c9c3ff; background: #302b50; }
:root[data-theme="dark"] .site-icon { color: #c9c3ff; }
:root[data-theme="dark"] .admin-access-note { color: #c9c3ff; }
:root[data-theme="dark"] .toast { color: #15171b; background: #f2f3f5; }
:root[data-theme="dark"] .secondary-button { color: var(--ink); background: var(--panel); }
:root[data-theme="dark"] .form-grid label,
:root[data-theme="dark"] fieldset legend { color: var(--ink); }

@media (min-width: 761px) {
  .app-shell.site-open { height: 100vh; height: 100svh; overflow: hidden; }
  .app-shell.site-open .sidebar { width: 72px; padding-inline: 12px; }
  .app-shell.site-open .content-shell { margin-left: 72px; background: #000; }
  .app-shell.site-open .brand-app { margin-inline: auto; }
  .app-shell.site-open .brand-app > span:last-child,
  .app-shell.site-open .nav-label,
  .app-shell.site-open .nav-item > span:last-child,
  .app-shell.site-open .profile-copy { display: none; }
  .app-shell.site-open .side-nav { margin-top: 39px; overflow-x: hidden; }
  .app-shell.site-open .nav-item { padding-inline: 0; justify-content: center; gap: 0; }
  .app-shell.site-open .profile-block { grid-template-columns: 1fr; padding-inline: 0; justify-items: center; }
}

@media (max-width: 1100px) {
  .sites-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 760px) {
  .sidebar { display: none; }
  .content-shell { margin-left: 0; }
  .mobile-header { position: sticky; top: 0; z-index: 15; height: 64px; padding: 0 17px; display: flex; align-items: center; justify-content: space-between; color: #fff; background: var(--sidebar); }
  .app-shell.site-open { height: 100svh; overflow: hidden; }
  .app-shell.site-open .content-shell { height: 100svh; overflow: hidden; background: #000; }
  .app-shell.site-open .mobile-header { position: absolute; inset: 0 0 auto; transition: transform .24s ease; }
  .app-shell.site-open .site-view { height: 100svh; padding-top: 64px; transition: padding-top .24s ease; }
  .app-shell.site-open.mobile-site-header-hidden .mobile-header { transform: translateY(-100%); }
  .app-shell.site-open.mobile-site-header-hidden .site-view { padding-top: 0; }
  .brand-mobile { font-size: 14px; }
  .brand-mobile .brand-mark { width: 28px; height: 28px; }
  .menu-button { border: 1px solid #35383f; border-radius: 8px; padding: 7px 10px; color: #fff; background: transparent; font-size: 11px; }
  .menu-button:hover { background: #202329; }
  .mobile-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: block;
    visibility: hidden;
    opacity: 0;
    background: rgba(5, 6, 8, .36);
    backdrop-filter: blur(0);
    pointer-events: none;
    transition: opacity .24s ease, backdrop-filter .24s ease, visibility 0s linear .24s;
  }
  .mobile-menu-backdrop.active {
    visibility: visible;
    opacity: 1;
    backdrop-filter: blur(4px);
    pointer-events: auto;
    transition-delay: 0s;
  }
  .mobile-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 50;
    width: 100%;
    height: auto;
    max-height: calc(100svh - 18px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 14px 13px max(18px, env(safe-area-inset-bottom));
    display: grid;
    gap: 1px;
    visibility: hidden;
    opacity: .7;
    color: var(--mobile-menu-ink);
    background: var(--mobile-menu-bg);
    border: 1px solid var(--mobile-menu-border);
    border-bottom: 0;
    border-radius: 21px 21px 0 0;
    box-shadow: 0 -22px 60px rgba(0,0,0,.34);
    transform: translateY(calc(100% + 20px));
    transition: transform .32s cubic-bezier(.2,.8,.2,1), opacity .24s ease, visibility 0s linear .32s;
  }
  .mobile-nav.open { visibility: visible; opacity: 1; transform: translateY(0); transition-delay: 0s; }
  .mobile-sheet-head { min-height: 43px; margin-bottom: 8px; padding: 0 5px 8px 10px; border-bottom: 1px solid var(--mobile-menu-border); display: flex; align-items: center; justify-content: space-between; }
  .mobile-sheet-head strong { font-size: 14px; }
  .mobile-menu-close { width: 35px; height: 35px; border: 1px solid var(--mobile-menu-border); border-radius: 10px; display: grid; place-items: center; color: var(--mobile-menu-ink); background: var(--mobile-menu-control); cursor: pointer; font-size: 23px; line-height: 1; }
  .mobile-menu-close:hover { filter: brightness(.96); }
  .mobile-nav .nav-label { margin-top: 9px; color: var(--mobile-menu-muted); }
  .mobile-nav .nav-item { color: var(--mobile-menu-muted); }
  .mobile-nav .nav-item:hover,
  .mobile-nav .nav-item.active { color: var(--mobile-menu-ink); background: var(--mobile-menu-control); }
  .mobile-nav .site-mini-mark { color: var(--accent); background: var(--accent-soft); }
  .mobile-account-label { margin-top: 22px !important; }
  body.mobile-menu-open { overflow: hidden; }
  .view-section { padding: 39px 18px 60px; }
  .page-heading { align-items: stretch; flex-direction: column; gap: 22px; }
  .site-controls { width: 100%; grid-template-columns: minmax(0, 1fr) 170px; }
  .search-box { width: 100%; }
  .admin-heading .primary-button { width: 100%; }
  .collection-bar { margin-top: 29px; }
  #usersView .table-card { overflow: visible; border: 0; background: transparent; }
  #usersView .table-summary { margin-bottom: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); }
  #usersView .table-scroll { overflow: visible; }
  #usersView table, #usersView tbody { width: 100%; display: block; }
  #usersView thead { display: none; }
  #usersView tbody { display: grid; gap: 12px; }
  #usersView tr { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 13px; padding: 15px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 15px 12px; background: var(--panel); }
  #usersView td { min-width: 0; border: 0; padding: 0; display: grid; align-content: start; gap: 7px; }
  #usersView td::before { content: attr(data-label); color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
  #usersView .user-main-cell, #usersView .access-cell, #usersView .user-actions-cell { grid-column: 1 / -1; }
  #usersView .user-main-cell { border-bottom: 1px solid var(--line); padding-bottom: 13px; }
  #usersView .user-main-cell::before, #usersView .user-actions-cell::before { display: none; }
  #usersView .user-cell { min-width: 0; }
  #usersView .user-copy { min-width: 0; }
  #usersView .user-copy strong, #usersView .user-copy span, #usersView .access-cell { overflow-wrap: anywhere; }
  #usersView .edit-user { width: 100%; min-height: 40px; }
}

@media (max-width: 520px) {
  .login-shell { padding-inline: 22px; }
  .login-brand { margin-bottom: clamp(28px, 6vh, 48px); }
  .login-heading p { margin-bottom: 22px; }
  .login-form input, .login-form button { height: 46px; }
  .site-controls { grid-template-columns: 1fr; }
  .sites-grid { grid-template-columns: 1fr; }
  .site-preview-wrap { height: 180px; }
  .local-preview-note { display: none; }
  .user-dialog form { padding: 22px 18px; }
  .form-grid, .permissions-list { grid-template-columns: 1fr; }
  .switch-field { grid-template-columns: 17px 1fr; }
  .dialog-actions { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (max-width: 390px) {
  .password-requirements { grid-template-columns: 1fr; }
  .password-requirements li:last-child { grid-column: auto; }
}

@media (max-height: 610px) {
  .login-brand { margin-bottom: 24px; }
  .login-heading p { margin-bottom: 17px; }
  .login-form { gap: 6px; }
  .login-form input, .login-form button { height: 42px; }
  .login-form button { margin-top: 8px; }
}

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