/* Inter, self-hosted (rsms/inter v4.1) — no Google Fonts.
   font-display:optional + <link rel=preload> in the layout: with the font cached,
   Inter renders from first paint on every navigation with no fallback->Inter swap. */
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: optional;
  src: url('/assets/fonts/inter/InterVariable.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter'; font-style: italic; font-weight: 100 900; font-display: optional;
  src: url('/assets/fonts/inter/InterVariable-Italic.woff2') format('woff2');
}

:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --card: #ffffff;
  --panel: #fbfbfd;
  --surface-2: #fafbfc;
  --hover: #eef0f4;
  --ink: #1b1e24;
  --muted: #6b7280;
  --faint: #9aa1ac;
  --nav-ink: #3d434e;
  --line: #e6e8ec;
  --line-strong: #c9cdd6;
  --accent: #4c6ef5;
  --accent-soft: #eef1fe;
  --accent-line: #cfd8f5;
  --danger: #c0392b;
  --danger-bg: #fdece9;
  --danger-soft: #fdf2f0;
  --danger-border: #f0c8c3;
  --warn: #f0a020;
  --ok: #2f9e44;
  --ok-soft: #e7f5ec;
  --avatar-bg: #dfe3ee;
  --avatar-ink: #3a4256;
  --flash-info-ink: #26408b;
  --flash-ok-ink: #216e39;
  --flash-err-ink: #a02214;
  --radius: 10px;
  --side-w: 244px;
  --top-h: 56px;
  --emu-h: 0px;
  --shadow: 0 6px 24px rgba(20, 24, 40, .10), 0 1px 2px rgba(20, 24, 40, .06);
  /* density scale (overridden by data-density) */
  --d-row: 10px;     /* table cell vertical padding */
  --d-card: 20px;    /* card / tile padding */
  --d-item: 9px;     /* nav & menu item vertical padding */
  --d-field: 14px;   /* form label spacing */
  --d-list: 5px;     /* list item vertical padding */
  --d-content: 28px; /* main content padding */
}
:root[data-density="compact"] {
  --d-row: 6px; --d-card: 14px; --d-item: 6px; --d-field: 9px; --d-list: 3px; --d-content: 20px;
}
:root[data-density="spaced"] {
  --d-row: 15px; --d-card: 28px; --d-item: 12px; --d-field: 20px; --d-list: 9px; --d-content: 40px;
}

/* Dark palette. Kept in two places (explicit + auto-follows-system); keep in sync. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1013;
  --card: #181b21;
  --panel: #14171c;
  --surface-2: #1e222a;
  --hover: #232833;
  --ink: #e6e9ef;
  --muted: #99a1ad;
  --faint: #6c7481;
  --nav-ink: #bcc3ce;
  --line: #2a303a;
  --line-strong: #3a414d;
  --accent: #6b8afd;
  --accent-soft: #1f2842;
  --accent-line: #35406a;
  --danger: #f0796c;
  --danger-bg: #2a1613;
  --danger-soft: #2a1613;
  --danger-border: #5a2b26;
  --ok: #4cc571;
  --ok-soft: #14301e;
  --avatar-bg: #2b313d;
  --avatar-ink: #cfd5e0;
  --flash-info-ink: #b9c6f5;
  --flash-ok-ink: #8fe0a5;
  --flash-err-ink: #f2b1a8;
  --shadow: 0 10px 30px rgba(0,0,0,.55), 0 1px 2px rgba(0,0,0,.5);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;
    --bg: #0e1013;
    --card: #181b21;
    --panel: #14171c;
    --surface-2: #1e222a;
    --hover: #232833;
    --ink: #e6e9ef;
    --muted: #99a1ad;
    --faint: #6c7481;
    --nav-ink: #bcc3ce;
    --line: #2a303a;
    --line-strong: #3a414d;
    --accent: #6b8afd;
    --accent-soft: #1f2842;
    --accent-line: #35406a;
    --danger: #f0796c;
    --danger-bg: #2a1613;
    --danger-soft: #2a1613;
    --danger-border: #5a2b26;
    --ok: #4cc571;
    --ok-soft: #14301e;
    --avatar-bg: #2b313d;
    --avatar-ink: #cfd5e0;
    --flash-info-ink: #b9c6f5;
    --flash-ok-ink: #8fe0a5;
    --flash-err-ink: #f2b1a8;
    --shadow: 0 10px 30px rgba(0,0,0,.55), 0 1px 2px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* the attribute must win over component display rules */

body {
  margin: 0; color: var(--ink); background: var(--bg);
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-feature-settings: 'cv05', 'ss01'; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.ic { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.ic-lg { width: 22px; height: 22px; }

body.is-emulating { --emu-h: 36px; }

/* ---- emulation banner (top-most fixed strip) ---- */
.emu-banner {
  position: fixed; inset: 0 0 auto 0; height: var(--emu-h); z-index: 60;
  display: flex; align-items: center; justify-content: center; gap: 16px;
  background: #2b2f3a; color: #fdf0d5; font-size: 13px; font-weight: 500;
}
.emu-banner .ic { width: 15px; height: 15px; }
.emu-stop {
  border: 1px solid rgba(255,255,255,.25); background: transparent; color: #fff;
  padding: 3px 10px; border-radius: 6px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
}
.emu-stop:hover { background: rgba(255,255,255,.12); }

/* ---- top bar (fixed) ---- */
.topbar {
  position: fixed; top: var(--emu-h); left: 0; right: 0; height: var(--top-h); z-index: 50;
  display: flex; align-items: stretch; background: var(--card); border-bottom: 1px solid var(--line);
}
.top-spacer { flex: 1; }

/* corner = intersection of the two bars, holds the current brand */
.corner {
  width: var(--side-w); flex: none; display: flex; align-items: center; padding: 0 12px;
  border-right: 1px solid var(--line);
  transition: width .22s ease;
}
.brand-switch { position: relative; width: 100%; }
.brand-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: 0; background: transparent; cursor: pointer; padding: 7px 8px; border-radius: 8px; font: inherit; color: var(--ink);
}
.brand-btn:hover { background: var(--panel); }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 13px;
  display: grid; place-items: center;
}
.brand-name {
  font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 150px; opacity: 1; transition: max-width .22s ease, opacity .16s ease;
}
.chev { color: var(--faint); display: inline-flex; align-items: center; transition: transform .22s ease, color .22s ease; }
.chev .ic { width: 14px; height: 14px; }
.brand-btn .chev { margin-left: auto; }
.user-menu:hover .user-btn .chev, .user-menu:focus-within .user-btn .chev,
.brand-switch:hover .brand-btn .chev, .brand-switch:focus-within .brand-btn .chev { transform: rotate(180deg); color: var(--ink); }

/* super-admin badge */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; letter-spacing: .02em; vertical-align: middle; }
.badge .ic { width: 12px; height: 12px; }
.badge-super { background: var(--accent-soft); color: var(--accent); }
.badge-current { background: var(--ok-soft); color: var(--ok); }
.badge-passkey { background: var(--ok-soft); color: var(--ok); }
.badge-password { background: var(--accent-soft); color: var(--accent); }
.count-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--hover); color: var(--muted); font-size: 12px; font-weight: 600; vertical-align: middle; margin-left: 4px; }

/* sessions table */
.table-scroll { overflow-x: auto; }
.sessions td { vertical-align: middle; white-space: nowrap; }
.device-cell { display: inline-flex; align-items: center; gap: 8px; }
.device-cell .ic { color: var(--muted); }
.loc { display: flex; align-items: center; gap: 7px; }
.loc-ip { font-size: 12px; margin-top: 2px; }
.flag { width: 20px; height: 15px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.10); flex: none; object-fit: cover; }
.is-current-row td { background: rgba(76,197,113,.08); }

/* ---- user menu (top-right, hover) ---- */
.user-menu { position: relative; display: flex; align-items: center; padding: 0 14px; outline: none; }
.user-btn {
  display: flex; align-items: center; gap: 9px; border: 0; background: transparent; cursor: pointer;
  font: inherit; padding: 6px 8px; border-radius: 8px; color: var(--ink);
}
.user-btn:hover { background: var(--panel); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none; background: var(--avatar-bg); color: var(--avatar-ink);
  font-weight: 700; font-size: 14px; display: grid; place-items: center; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-sm { width: 26px; height: 26px; font-size: 12px; }
.avatar-md { width: 44px; height: 44px; font-size: 17px; }
.avatar-lg { width: 88px; height: 88px; font-size: 32px; }
.user-name { font-size: 14px; font-weight: 500; }

/* ---- topbar left: collapse toggle + section search ---- */
.topbar-left { display: flex; align-items: center; gap: 10px; padding-left: 10px; }
.icon-btn { display: flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 8px; border-radius: 8px; }
.icon-btn:hover { background: var(--panel); color: var(--ink); }

.search-box { position: relative; width: 260px; max-width: 40vw; transition: width .2s ease; }
.search-box:focus-within { width: 440px; }
.search-box .search-input {
  display: block; width: 100%; height: 38px; margin: 0;
  padding: 0 62px 0 38px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); font: inherit; font-size: 13px; color: var(--ink);
}
.search-box .search-input::placeholder { color: var(--faint); }
.search-box .search-input:focus { outline: none; border-color: var(--accent); background: var(--card); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-glass, .search-spinner { position: absolute; left: 13px; top: 50%; width: 16px; height: 16px; pointer-events: none; }
.search-glass { transform: translateY(-50%); color: var(--faint); display: flex; }
.search-glass .ic { width: 16px; height: 16px; }
.search-spinner { display: none; margin-top: -8px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: bk-spin .6s linear infinite; }
.search-box.searching .search-glass { display: none; }
.search-box.searching .search-spinner { display: block; }
@keyframes bk-spin { to { transform: rotate(360deg); } }
.search-kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-family: inherit; font-size: 11px; line-height: 1.5; color: var(--faint); background: var(--card); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; pointer-events: none; }
.search-box:focus-within .search-kbd { display: none; }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--card); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow); padding: 6px; display: none; max-height: 360px; overflow-y: auto; z-index: 80; }
.search-box.open .search-results { display: block; }
.search-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink); font-size: 14px; }
.search-item:hover { background: var(--panel); text-decoration: none; }
.search-ic { color: var(--faint); display: flex; }
.search-ic .ic { width: 16px; height: 16px; }
.search-empty { padding: 10px; color: var(--muted); font-size: 13px; }

/* ---- dropdown menus ---- */
.menu {
  position: absolute; z-index: 70; min-width: 220px; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 6px;
  opacity: 0; visibility: hidden; transform: translateY(-6px); pointer-events: none;
  transition: opacity .16s ease, transform .16s ease, visibility .16s ease;
}
.user-menu .user-dropdown { right: 12px; top: calc(100% - 6px); }
.brand-switch .brand-menu { left: 0; top: calc(100% + 2px); }
.user-menu:hover .user-dropdown, .user-menu:focus-within .user-dropdown,
.brand-switch:hover .brand-menu, .brand-switch:focus-within .brand-menu {
  opacity: 1; visibility: visible; transform: translateY(0); pointer-events: auto;
}

.menu form { margin: 0; }
.menu-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-head-name { font-weight: 600; }
.menu-head-sub { font-size: 12px; color: var(--muted); }
.menu-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 6px 10px 4px; }
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: var(--d-item) 10px; border: 0; background: transparent; border-radius: 8px;
  font: inherit; font-size: 14px; color: var(--ink); cursor: pointer;
}
.menu-item:hover { background: var(--panel); text-decoration: none; }
.menu-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.menu-item-strong { color: var(--danger); }
.menu-item .ic { color: var(--faint); }

/* theme toggle icon swap */
#theme-toggle .theme-ic { display: none; align-items: center; }
#theme-toggle .theme-ic-moon { display: inline-flex; }
#theme-toggle[data-eff="dark"] .theme-ic-moon { display: none; }
#theme-toggle[data-eff="dark"] .theme-ic-sun { display: inline-flex; }

/* ---- sidebar (fixed, lateral) ---- */
.sidebar {
  position: fixed; top: calc(var(--emu-h) + var(--top-h)); left: 0; bottom: 0; width: var(--side-w); z-index: 40;
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 14px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px;
  transition: width .22s ease;
}
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-manage { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.side-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 2px 10px 6px; }
.side-item {
  position: relative;
  display: flex; align-items: center; gap: 11px; padding: var(--d-item) 10px; border-radius: 8px;
  color: var(--nav-ink); font-weight: 500; font-size: 14px;
}
.side-item span {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 180px; opacity: 1;
  transition: max-width .22s ease, opacity .16s ease;
}
.side-item .ic { color: var(--faint); }
.side-item:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.side-item.is-active { background: var(--accent-soft); color: var(--accent); }
.side-item.is-active .ic { color: var(--accent); }

/* ---- menu icon hover: bigger + darker + a bespoke SVG-part animation ---- */
.side-item .ic, .menu-item .ic, .brand-btn .ic { transition: transform .18s ease, color .18s ease; }
.side-item:hover .ic, .menu-item:hover .ic { transform: scale(1.16); color: var(--ink); }
.side-item.is-active:hover .ic { color: var(--accent); }
.ic .a { transform-box: fill-box; transform-origin: center; }
.ic-chart .a { transform-origin: 50% 100%; }

.side-item:hover .ic-logout .a,    .menu-item:hover .ic-logout .a    { animation: bk-a-slidex .7s ease-in-out infinite; }
.side-item:hover .ic-receipt .a,   .menu-item:hover .ic-receipt .a   { animation: bk-a-slidex .9s ease-in-out infinite; }
.side-item:hover .ic-cog .a,       .menu-item:hover .ic-cog .a       { animation: bk-a-spin 1.6s linear infinite; }
.side-item:hover .ic-sun .a,       .menu-item:hover .ic-sun .a       { animation: bk-a-spin 6s linear infinite; }
.side-item:hover .ic-moon .a,      .menu-item:hover .ic-moon .a      { animation: bk-a-tilt 1.1s ease-in-out infinite; }
.side-item:hover .ic-bell .a,      .menu-item:hover .ic-bell .a      { animation: bk-a-tilt .5s ease-in-out infinite; }
.side-item:hover .ic-user .a,      .menu-item:hover .ic-user .a      { animation: bk-a-bob .8s ease-in-out infinite; }
.side-item:hover .ic-calendar .a,  .menu-item:hover .ic-calendar .a  { animation: bk-a-bob .8s ease-in-out infinite; }
.side-item:hover .ic-users .a,     .menu-item:hover .ic-users .a     { animation: bk-a-fade 1s ease-in-out infinite; }
.side-item:hover .ic-tag .a,       .menu-item:hover .ic-tag .a       { animation: bk-a-pulse .8s ease-in-out infinite; }
.side-item:hover .ic-grid .a,      .menu-item:hover .ic-grid .a      { animation: bk-a-pulse .9s ease-in-out infinite; }
.side-item:hover .ic-folder .a,    .menu-item:hover .ic-folder .a    { animation: bk-a-pulse 1s ease-in-out infinite; }
.side-item:hover .ic-layers .a,    .menu-item:hover .ic-layers .a    { animation: bk-a-lift .9s ease-in-out infinite; }
.side-item:hover .ic-home .a,      .menu-item:hover .ic-home .a      { animation: bk-a-lift .9s ease-in-out infinite; }
.side-item:hover .ic-mail .a,      .menu-item:hover .ic-mail .a      { animation: bk-a-lift .9s ease-in-out infinite; }
.side-item:hover .ic-briefcase .a, .menu-item:hover .ic-briefcase .a { animation: bk-a-lid 1s ease-in-out infinite; }
.side-item:hover .ic-box .a,       .menu-item:hover .ic-box .a       { animation: bk-a-lid 1s ease-in-out infinite; }
.side-item:hover .ic-chart .a,     .menu-item:hover .ic-chart .a     { animation: bk-a-grow 1s ease-in-out infinite; }
.side-item:hover .ic-panel-left .a,.menu-item:hover .ic-panel-left .a{ animation: bk-a-slidex .8s ease-in-out infinite; }
.side-item:hover .ic-search .a,    .menu-item:hover .ic-search .a    { animation: bk-a-pulse .8s ease-in-out infinite; }
/* sliders: each knob adjusts on its own — different direction and speed */
.side-item:hover .ic-sliders .a1,  .menu-item:hover .ic-sliders .a1  { animation: bk-a-slidex 1.1s ease-in-out infinite; }
.side-item:hover .ic-sliders .a2,  .menu-item:hover .ic-sliders .a2  { animation: bk-a-slidex-l .7s ease-in-out infinite; }
.side-item:hover .ic-sliders .a3,  .menu-item:hover .ic-sliders .a3  { animation: bk-a-slidex 1.5s ease-in-out infinite; }

@keyframes bk-a-slidex   { 0%,100% { transform: translateX(0); } 50% { transform: translateX(2.5px); } }
@keyframes bk-a-slidex-l { 0%,100% { transform: translateX(0); } 50% { transform: translateX(-2.5px); } }
@keyframes bk-a-spin   { to { transform: rotate(360deg); } }
@keyframes bk-a-tilt   { 0%,100% { transform: rotate(0); } 50% { transform: rotate(-16deg); } }
@keyframes bk-a-bob    { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-1.6px); } }
@keyframes bk-a-fade   { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
@keyframes bk-a-pulse  { 0%,100% { transform: scale(1); } 50% { transform: scale(1.32); } }
@keyframes bk-a-lift   { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-1.8px); } }
@keyframes bk-a-lid    { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-1.4px); } }
@keyframes bk-a-grow   { 0%,100% { transform: scaleY(1); } 50% { transform: scaleY(1.18); } }

/* ---- collapsed sidebar: icons only, labels become hover tooltips ---- */
body.sidebar-collapsed { --side-w: 66px; }
body.sidebar-collapsed .brand-name,
body.sidebar-collapsed .side-item span { max-width: 0; opacity: 0; }
body.sidebar-collapsed .corner .chev,
body.sidebar-collapsed .side-label { display: none; }
body.sidebar-collapsed .sidebar { overflow: visible; }
body.sidebar-collapsed .side-item[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  background: #2b2f3a; color: #fff; padding: 5px 9px; border-radius: 6px;
  font-size: 12px; font-weight: 500; white-space: nowrap; box-shadow: var(--shadow); z-index: 90;
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .corner, .content, .search-box, .side-item .ic, .menu-item .ic, .menu, .chev { transition: none; }
  .ic .a { animation: none !important; }
  .modal { animation: none; }
}

/* ---- content ---- */
.content {
  margin-left: var(--side-w); padding: var(--d-content) 32px;
  padding-top: calc(var(--emu-h) + var(--top-h) + var(--d-content)); max-width: 1400px;
  transition: margin-left .22s ease;
}
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
h1 { font-size: 22px; letter-spacing: -.02em; margin: 0; display: flex; align-items: center; gap: 8px; }
h2 { font-size: 17px; letter-spacing: -.01em; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 0 0 8px; }
h3.svc { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 6px; }
.muted { color: var(--muted); }

/* ---- dashboard tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.tile {
  display: flex; flex-direction: column; gap: 14px; padding: var(--d-card); background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); min-height: 96px;
}
.tile:hover { border-color: var(--accent-line); box-shadow: var(--shadow); text-decoration: none; }
.tile-ic { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.tile-ic .ic { width: 22px; height: 22px; }
.tile-name { font-weight: 600; }

/* ---- cards / forms / buttons / tables ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--d-card); margin-bottom: 18px; }
.card-narrow { max-width: 480px; }
.card-actions { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; }

label { display: block; margin-bottom: var(--d-field); font-size: 14px; font-weight: 500; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], select {
  display: block; width: 100%; margin-top: 6px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 8px; font: inherit; background: var(--card); color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label.check input { width: auto; margin: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.num { width: 80px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; margin: 0;
  padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; font-weight: 500; font-size: 14px;
  line-height: 1.4;
}
.btn:hover { border-color: var(--line-strong); text-decoration: none; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-danger { background: var(--card); border-color: var(--danger-border); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
form { margin: 0 0 8px; }

.grid { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.grid th, .grid td { text-align: left; padding: var(--d-row) 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.grid th { background: var(--surface-2); font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.grid tr:last-child td { border-bottom: none; }
.row-actions { display: flex; gap: 12px; }
.perm-grid th:not(:first-child), .perm-grid td:not(:first-child) { text-align: center; width: 64px; }

ul.subs, ul.plain { list-style: none; padding: 0; margin: 0; }
ul.subs li { display: flex; align-items: center; gap: 8px; padding: var(--d-list) 0; }
ul.plain li { padding: 4px 0; }
.pill { font-size: 11px; padding: 1px 7px; border-radius: 999px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.pill-view { background: var(--accent-soft); color: var(--accent); }
.pill-edit { background: var(--ok-soft); color: var(--ok); }
.svc-ic { color: var(--muted); }

.inline-form { display: inline-flex; align-items: center; gap: 8px; margin-right: 8px; flex-wrap: wrap; }
.inline-form input[type=text], .inline-form input[type=number], .inline-form select { width: auto; margin: 0; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.flash-info { background: var(--accent-soft); color: var(--flash-info-ink); }
.flash-success { background: var(--ok-soft); color: var(--flash-ok-ink); }
.flash-error { background: var(--danger-bg); color: var(--flash-err-ink); }

/* ---- confirm modal ---- */
body.modal-open { overflow: hidden; }
.modal-overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(8,10,15,.55); }
.modal-overlay[hidden] { display: none; }
.modal { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; animation: bk-modal-in .16s ease; }
@keyframes bk-modal-in { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-bar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600; }
.modal-x { border: 0; background: transparent; font-size: 22px; line-height: 1; color: var(--faint); cursor: pointer; padding: 0 4px; }
.modal-x:hover { color: var(--ink); }
.modal-body { padding: 18px 16px; color: var(--muted); font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 0 16px 16px; }

/* ---- avatar upload + editor ---- */
.user-cell { display: flex; align-items: center; gap: 10px; }
.avatar-row { display: flex; align-items: center; gap: 16px; }
.avatar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dropzone {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  margin: 0; min-width: 210px; padding: 9px 16px;
  border: 1px dashed var(--line-strong); border-radius: 8px;
  background: var(--panel); color: var(--muted); font: inherit; font-size: 14px; font-weight: 500; line-height: 1.4;
  cursor: pointer; transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.dropzone:hover { border-color: var(--accent); color: var(--ink); }
.dropzone.dragging { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone .ic { width: 18px; height: 18px; }
.avatar-err { color: var(--danger); font-size: 13px; flex-basis: 100%; }
.modal-avatar { max-width: 340px; }
.avatar-editor { position: relative; width: 280px; max-width: 100%; margin: 0 auto 16px; overflow: hidden; border-radius: 8px; }
#avatar-canvas { display: block; width: 280px; height: 280px; background: var(--panel); cursor: grab; touch-action: none; }
#avatar-canvas:active { cursor: grabbing; }
.avatar-ring {
  position: absolute; top: 50%; left: 50%; width: 236px; height: 236px; transform: translate(-50%, -50%);
  border-radius: 50%; box-shadow: 0 0 0 9999px rgba(0,0,0,.42); border: 2px solid rgba(255,255,255,.85); pointer-events: none;
}
.range-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; font-size: 13px; font-weight: 500; }
.range-row span { width: 60px; color: var(--muted); }
.range-row input[type=range] { flex: 1; width: auto; margin: 0; padding: 0; accent-color: var(--accent); background: transparent; border: 0; }
.range-row input[type=range]:focus { outline: none; }

/* ---- security page ---- */
.sec-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.sec-head h2 { margin-bottom: 2px; }
.sec-head p { margin: 0; }

/* ---- auth (login) ---- */
body.auth { display: grid; place-items: center; min-height: 100vh; background: var(--bg); }
.auth-wrap { width: 100%; max-width: 380px; padding: 24px; }
.auth-wrap h1 { margin-bottom: 16px; }
.remember-check { margin: -2px 0 16px; }
.passkey-btn { width: 100%; justify-content: center; margin-top: 10px; }

/* toggle switch (styled checkbox) */
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; font-weight: 500; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track { position: relative; flex: none; width: 38px; height: 22px; border-radius: 999px; background: var(--line-strong); transition: background .18s ease; }
.toggle-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .18s ease; }
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--accent-soft); outline-offset: 2px; }

/* ---- responsive ---- */
@media (max-width: 720px) {
  :root { --side-w: 0px; }
  .sidebar { display: none; }
  .corner { width: auto; border-right: 0; }
  .content { margin-left: 0; padding: 20px 16px; padding-top: calc(var(--emu-h) + var(--top-h) + 20px); }
  .user-name { display: none; }
  .search-box { width: 180px; }
  .search-box:focus-within { width: 220px; }
}
