/* Nyx admin panel — self-contained (no CDN; CSP: style-src 'self'), RTL, dark + light.
   Look: aurora background, glass surfaces, tactile 3D buttons, soft glow accents. */

@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn-wght.woff2") format("woff2-variations"),
       url("fonts/Vazirmatn-wght.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ------------------------------------------------------------------ tokens */
:root {
  --font: "Vazirmatn", Tahoma, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
  --radius: 16px; --radius-sm: 12px; --sidebar: 272px;
  --ease: cubic-bezier(.2, .8, .2, 1);

  /* dark (default) */
  --bg: #060913; --bg-2: #0b1022;
  --surface: rgba(19, 25, 48, .66); --surface-solid: #121831; --surface-2: rgba(255, 255, 255, .045);
  --surface-hover: rgba(255, 255, 255, .07); --field: rgba(4, 7, 18, .55);
  --border: rgba(148, 163, 255, .13); --border-strong: rgba(148, 163, 255, .26);
  --highlight: rgba(255, 255, 255, .07);
  --text: #e9ecff; --muted: #8f98bd; --faint: #5f6890;
  --primary: #7c6cff; --primary-2: #5b8cff; --primary-text: #fff; --ring: rgba(124, 108, 255, .38);
  --ok: #4ade9b; --ok-bg: rgba(34, 197, 120, .14);
  --off: #ff7a8a; --off-bg: rgba(255, 77, 103, .14); --danger: #ff5c72;
  --warn: #fbbf4b; --warn-bg: rgba(251, 176, 40, .14);
  --unknown-bg: rgba(148, 163, 255, .12);
  --shadow: 0 20px 50px -24px rgba(0, 0, 0, .8), 0 2px 6px -2px rgba(0, 0, 0, .45);
  --shadow-sm: 0 8px 22px -14px rgba(0, 0, 0, .9);
  --aurora-1: rgba(124, 92, 255, .38); --aurora-2: rgba(34, 211, 238, .22); --aurora-3: rgba(244, 114, 182, .2);
  --grid-line: rgba(148, 163, 255, .045);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef1fb; --bg-2: #e6eafa;
    --surface: rgba(255, 255, 255, .72); --surface-solid: #fff; --surface-2: rgba(40, 52, 120, .045);
    --surface-hover: rgba(40, 52, 120, .07); --field: rgba(255, 255, 255, .9);
    --border: rgba(52, 64, 140, .13); --border-strong: rgba(52, 64, 140, .24); --highlight: rgba(255, 255, 255, .9);
    --text: #141938; --muted: #5d668c; --faint: #8b93b5;
    --primary: #6a55f5; --primary-2: #3f7bff; --ring: rgba(106, 85, 245, .28);
    --ok: #0b8a52; --ok-bg: rgba(16, 185, 105, .13); --off: #d61f45; --off-bg: rgba(225, 29, 72, .1);
    --danger: #e11d48; --warn: #b45c06; --warn-bg: rgba(245, 158, 11, .16); --unknown-bg: rgba(52, 64, 140, .08);
    --shadow: 0 22px 48px -26px rgba(40, 48, 110, .38), 0 2px 6px -2px rgba(40, 48, 110, .12);
    --shadow-sm: 0 10px 24px -16px rgba(40, 48, 110, .5);
    --aurora-1: rgba(124, 92, 255, .26); --aurora-2: rgba(34, 211, 238, .2); --aurora-3: rgba(244, 114, 182, .16);
    --grid-line: rgba(52, 64, 140, .05);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #eef1fb; --bg-2: #e6eafa;
  --surface: rgba(255, 255, 255, .72); --surface-solid: #fff; --surface-2: rgba(40, 52, 120, .045);
  --surface-hover: rgba(40, 52, 120, .07); --field: rgba(255, 255, 255, .9);
  --border: rgba(52, 64, 140, .13); --border-strong: rgba(52, 64, 140, .24); --highlight: rgba(255, 255, 255, .9);
  --text: #141938; --muted: #5d668c; --faint: #8b93b5;
  --primary: #6a55f5; --primary-2: #3f7bff; --ring: rgba(106, 85, 245, .28);
  --ok: #0b8a52; --ok-bg: rgba(16, 185, 105, .13); --off: #d61f45; --off-bg: rgba(225, 29, 72, .1);
  --danger: #e11d48; --warn: #b45c06; --warn-bg: rgba(245, 158, 11, .16); --unknown-bg: rgba(52, 64, 140, .08);
  --shadow: 0 22px 48px -26px rgba(40, 48, 110, .38), 0 2px 6px -2px rgba(40, 48, 110, .12);
  --shadow-sm: 0 10px 24px -16px rgba(40, 48, 110, .5);
  --aurora-1: rgba(124, 92, 255, .26); --aurora-2: rgba(34, 211, 238, .2); --aurora-3: rgba(244, 114, 182, .16);
  --grid-line: rgba(52, 64, 140, .05);
  color-scheme: light;
}

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh; background: var(--bg); color: var(--text);
  font: 15px/1.75 var(--font); font-feature-settings: "ss01"; -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
::selection { background: var(--ring); }
a { color: var(--primary); text-decoration: none; transition: color .2s; }
a:hover { color: var(--primary-2); }
h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.01em; margin: .2rem 0 1.1rem; }
h2 { font-size: 1.08rem; font-weight: 700; margin: 0 0 .7rem; }
h3 { font-weight: 700; }
code, .mono { font-family: var(--mono); font-size: .86em; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: .05rem .35rem; }
small, .muted { color: var(--muted); }
hr { border: 0; height: 1px; background: linear-gradient(90deg, transparent, var(--border-strong), transparent); margin: 1.2rem 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: 6px; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------------ aurora background */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  background:
    linear-gradient(var(--grid-line) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px) 0 0 / 44px 44px,
    radial-gradient(120% 80% at 50% -10%, var(--bg-2), var(--bg) 60%); }
.aurora::after { content: ""; position: absolute; inset: 0;
  background: radial-gradient(70% 60% at 50% 40%, transparent, var(--bg) 92%); }
.aurora i { position: absolute; width: 46vmax; height: 46vmax; border-radius: 50%; filter: blur(70px);
  animation: drift 26s var(--ease) infinite alternate; opacity: .9; }
.aurora i:nth-child(1) { background: var(--aurora-1); top: -18vmax; right: -8vmax; }
.aurora i:nth-child(2) { background: var(--aurora-2); bottom: -22vmax; left: -10vmax; animation-duration: 32s; animation-delay: -8s; }
.aurora i:nth-child(3) { background: var(--aurora-3); top: 30%; left: 35%; width: 30vmax; height: 30vmax; animation-duration: 38s; animation-delay: -16s; }
@keyframes drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(-6vmax, 4vmax, 0) scale(1.12); }
  100% { transform: translate3d(5vmax, -3vmax, 0) scale(.94); }
}

/* ------------------------------------------------------------------ layout */
.container { max-width: 1240px; margin: 0 auto; padding: 1.4rem 28px 4rem; }
body.app .container { margin-inline-start: var(--sidebar); }
body.app .topbar { margin-inline-start: calc(var(--sidebar) + clamp(16px, 3vw, 40px)); }
body.app .container { max-width: none; padding-inline: clamp(16px, 3vw, 40px); }

.sidebar { position: fixed; inset-block: 12px; inset-inline-start: 12px; width: calc(var(--sidebar) - 24px); z-index: 30;
  display: flex; flex-direction: column; gap: .6rem; padding: 1rem .8rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px;
  backdrop-filter: blur(22px) saturate(140%); -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow: var(--shadow), inset 0 1px 0 var(--highlight); }
.brand { display: flex; align-items: center; gap: .75rem; padding: .3rem .5rem .8rem; color: var(--text);
  border-bottom: 1px solid var(--border); }
.brand:hover { color: var(--text); }
.logo { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  box-shadow: 0 8px 22px -6px rgba(124, 92, 255, .7), inset 0 0 0 1px rgba(255, 255, 255, .2);
  transition: transform .5s var(--ease); }
.logo svg { width: 42px; height: 42px; }
.brand:hover .logo { transform: rotate(-8deg) scale(1.06); }
.brand-text b { display: block; font-size: 1.25rem; font-weight: 900; letter-spacing: .02em; line-height: 1.2;
  background: linear-gradient(90deg, var(--text), var(--primary)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-text small { font-size: .74rem; }

.nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding: .2rem .1rem;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.nav-title { margin: .9rem .7rem .25rem; font-size: .7rem; font-weight: 700; color: var(--faint); letter-spacing: .04em; }
.nav-title:first-child { margin-top: .2rem; }
.nav a { position: relative; display: flex; align-items: center; gap: .75rem; padding: .55rem .8rem; border-radius: 12px;
  color: var(--muted); font-weight: 500; transition: background .25s, color .25s, transform .25s var(--ease); }
.nav a .ico { transition: transform .35s var(--ease), color .25s; }
.nav a:hover { background: var(--surface-hover); color: var(--text); }
.nav a:hover .ico { transform: translateX(-2px) scale(1.08); color: var(--primary); }
.nav a.active { color: #fff; font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 10px 24px -10px var(--primary), inset 0 1px 0 rgba(255, 255, 255, .25); }
.nav a.active .ico { color: #fff; }
.nav a.active::before { content: ""; position: absolute; inset-inline-start: -.8rem; top: 22%; bottom: 22%; width: 4px;
  border-radius: 4px; background: linear-gradient(var(--primary), var(--primary-2)); box-shadow: 0 0 14px var(--primary); }

.me { display: flex; align-items: center; gap: .65rem; padding: .55rem .6rem; border-radius: 14px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); transition: background .25s, border-color .25s; }
.me:hover, .me.active { background: var(--surface-hover); border-color: var(--border-strong); color: var(--text); }
.me-text { flex: 1; min-width: 0; line-height: 1.35; }
.me-text b { display: block; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; }
.me-text small { font-size: .74rem; }
.me .ico { width: 16px; color: var(--muted); }
.avatar { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #f472b6, #7c6cff); box-shadow: 0 6px 14px -6px #f472b6; }

.topbar { position: sticky; top: 12px; z-index: 20; display: flex; align-items: center; gap: .8rem;
  margin-top: 12px; margin-inline-end: clamp(16px, 3vw, 40px); padding: .5rem .6rem .5rem .9rem;
  border-radius: 18px; background: var(--surface); border: 1px solid var(--border);
  backdrop-filter: blur(22px) saturate(140%); -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--highlight); }
.topbar .icon-btn { width: 38px; height: 38px; }
.topbar-title { flex: 1; font-weight: 700; color: var(--muted); font-size: .92rem; }
.topbar-end { display: flex; gap: .5rem; align-items: center; }
.topbar-end form { margin: 0; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 12px; cursor: pointer;
  color: var(--text); background: var(--surface); border: 1px solid var(--border);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: inset 0 1px 0 var(--highlight), 0 3px 0 var(--border-strong), var(--shadow-sm);
  transition: transform .15s var(--ease), box-shadow .15s, color .2s; }
.icon-btn:hover { color: var(--primary); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(2px); box-shadow: inset 0 1px 0 var(--highlight), 0 1px 0 var(--border-strong); }
.menu-btn { display: none; }
[data-theme-toggle] .sun { display: none; }
:root[data-theme="light"] [data-theme-toggle] .sun { display: block; }
:root[data-theme="light"] [data-theme-toggle] .moon { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) [data-theme-toggle] .sun { display: block; }
  :root:not([data-theme="dark"]) [data-theme-toggle] .moon { display: none; }
}
.scrim { display: none; }

/* page entrance */
.container > * { animation: rise .55s var(--ease) both; }
.container > *:nth-child(2) { animation-delay: .05s; } .container > *:nth-child(3) { animation-delay: .1s; }
.container > *:nth-child(4) { animation-delay: .15s; } .container > *:nth-child(5) { animation-delay: .2s; }
.container > *:nth-child(n+6) { animation-delay: .25s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ surfaces */
.card, .table-wrap, .stat, .auth-card, .empty, .form fieldset {
  background: var(--surface); border: 1px solid var(--border);
  backdrop-filter: blur(18px) saturate(130%); -webkit-backdrop-filter: blur(18px) saturate(130%);
  box-shadow: var(--shadow), inset 0 1px 0 var(--highlight); }
.card { border-radius: var(--radius); padding: 1.2rem 1.35rem; margin: 1.1rem 0; position: relative; }
.card > h2:first-child, .card > h2:first-child + p { margin-top: 0; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .4rem; }
.page-head h1 { margin: .2rem 0 .8rem; }
.row { display: flex; gap: .65rem; align-items: center; flex-wrap: wrap; margin: .7rem 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 1.1rem; }
.empty { border-radius: var(--radius); border-style: dashed; border-color: var(--border-strong);
  padding: 2rem 1.4rem; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 1rem; } .empty p:last-child { margin-bottom: 0; }

/* ------------------------------------------------------------------ 3D buttons */
.btn {
  --b1: #8f7dff; --b2: #6250f0; --lip: #3d2fb3; --glow: rgba(110, 90, 255, .55); --fg: #fff;
  position: relative; isolation: isolate; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .56rem 1.15rem; border: 0; border-radius: 12px; cursor: pointer; text-decoration: none;
  font: inherit; font-weight: 700; color: var(--fg); white-space: nowrap; user-select: none;
  background: linear-gradient(180deg, var(--b1), var(--b2));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .38), inset 0 -2px 0 rgba(0, 0, 0, .14),
              0 4px 0 var(--lip), 0 12px 24px -8px var(--glow);
  transform: translateY(0);
  transition: transform .14s var(--ease), box-shadow .14s var(--ease), filter .2s;
}
.btn::after { /* moving shine */
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .35) 50%, transparent 65%);
  transform: translateX(120%); transition: transform .7s var(--ease); }
.btn:hover { color: var(--fg); filter: brightness(1.07) saturate(1.05); transform: translateY(-2px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), inset 0 -2px 0 rgba(0, 0, 0, .14),
              0 6px 0 var(--lip), 0 18px 30px -10px var(--glow); }
.btn:hover::after { transform: translateX(-120%); }
.btn:active { transform: translateY(3px); filter: brightness(.97);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .22), 0 1px 0 var(--lip), 0 4px 10px -6px var(--glow); }
.btn .ico { width: 18px; height: 18px; }
.btn.ghost { --fg: var(--text); --lip: var(--border-strong); --glow: transparent;
  background: var(--surface-2); border: 1px solid var(--border);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.btn.ghost { box-shadow: inset 0 1px 0 var(--highlight), 0 3px 0 var(--lip), var(--shadow-sm); }
.btn.ghost:hover { --fg: var(--primary); background: var(--surface-hover);
  box-shadow: inset 0 1px 0 var(--highlight), 0 5px 0 var(--lip), var(--shadow-sm); }
.btn.ghost:active { box-shadow: inset 0 2px 4px rgba(0, 0, 0, .18), 0 1px 0 var(--lip); }
.btn.ghost::after { background: linear-gradient(105deg, transparent 35%, var(--highlight) 50%, transparent 65%); }
.btn.danger { --b1: #ff7d8f; --b2: #e8344f; --lip: #9e1730; --glow: rgba(255, 60, 90, .5); }
.btn.success { --b1: #4ee3a2; --b2: #12b06c; --lip: #0a6f43; --glow: rgba(20, 200, 120, .45); }
.btn.small { padding: .3rem .78rem; font-size: .84rem; border-radius: 10px; }
.btn.small { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), inset 0 -2px 0 rgba(0, 0, 0, .12),
                         0 3px 0 var(--lip), 0 8px 16px -8px var(--glow); }
.btn.small.ghost { box-shadow: inset 0 1px 0 var(--highlight), 0 3px 0 var(--lip); }
.btn.small:active { box-shadow: inset 0 2px 3px rgba(0, 0, 0, .2), 0 1px 0 var(--lip); }
.btn.wide { width: 100%; margin-top: .6rem; padding-block: .72rem; font-size: 1rem; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .65; cursor: progress; transform: none; filter: saturate(.6); }
.ripple { position: absolute; z-index: -1; border-radius: 50%; pointer-events: none; transform: scale(0);
  background: rgba(255, 255, 255, .45); animation: ripple .65s var(--ease) forwards; }
.btn.ghost .ripple { background: var(--ring); }
@keyframes ripple { to { transform: scale(2.6); opacity: 0; } }
form.inline { display: inline; }

/* ------------------------------------------------------------------ forms */
.form fieldset { border-radius: var(--radius); padding: .9rem 1.2rem 1.2rem; margin: 0 0 1.2rem; }
.form legend { padding: .15rem .8rem; font-weight: 800; font-size: .92rem; border-radius: 999px; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); box-shadow: 0 6px 16px -8px var(--primary); }
.form.narrow { max-width: 460px; }
.field { display: block; margin: .7rem 0; }
.field > span, .label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.field small { display: block; margin-top: .25rem; font-size: .8rem; }
.req { color: var(--danger); }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--field);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .58rem .85rem;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, .16), 0 1px 0 var(--highlight);
  transition: border-color .2s, box-shadow .2s, background .2s; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, .12), 0 0 0 4px var(--ring), 0 0 24px -6px var(--primary); }
textarea { min-height: 110px; resize: vertical; line-height: 1.8; }
select { appearance: none; -webkit-appearance: none; padding-inline-end: 2.4rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238f98bd' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: 16px; background-position: left .85rem center; }
select option { background: var(--surface-solid); color: var(--text); }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; padding: 0; accent-color: var(--primary);
  box-shadow: none; cursor: pointer; flex: none; }
input[type="file"] { padding: .45rem; }
input[type="file"]::file-selector-button { font: inherit; font-weight: 600; margin-inline-end: .7rem; padding: .3rem .8rem;
  border: 0; border-radius: 8px; color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-2)); cursor: pointer; }
.row input, .row select { width: auto; flex: 1; min-width: 170px; }
.check { display: flex; gap: .6rem; align-items: flex-start; margin: .5rem 0; cursor: pointer; }
.check input { margin-top: .3rem; }
.radio-row { display: flex; gap: .7rem; flex-wrap: wrap; }
.radio-row label { display: inline-flex; align-items: center; gap: .5rem; padding: .45rem .9rem; border-radius: 12px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); transition: border-color .2s, background .2s, box-shadow .2s; }
.radio-row label:hover { border-color: var(--border-strong); }
.radio-row label:has(input:checked) { border-color: var(--primary); background: var(--surface-hover);
  box-shadow: 0 0 0 3px var(--ring); }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius); margin: .4rem 0 1rem; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { padding: .75rem .95rem; text-align: start; white-space: nowrap; border-bottom: 1px solid var(--border); }
th { position: sticky; top: 0; font-size: .78rem; font-weight: 700; color: var(--muted); letter-spacing: .02em;
  background: var(--surface-2); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
tbody tr { transition: background .2s; }
tbody tr:hover { background: linear-gradient(90deg, transparent, var(--surface-hover) 40%, var(--surface-hover)); }
tbody tr:hover td:first-child { box-shadow: inset -3px 0 0 var(--primary); }
tr:last-child td { border-bottom: 0; }
td { font-variant-numeric: tabular-nums; }
td.actions { display: flex; gap: .45rem; justify-content: flex-end; align-items: center; }

/* ------------------------------------------------------------------ badges / chips / flashes */
.badge { display: inline-flex; align-items: center; gap: .38rem; padding: .08rem .62rem .08rem .7rem; border-radius: 999px;
  font-size: .78rem; font-weight: 700; border: 1px solid transparent; line-height: 1.7; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.badge.ok::before { animation: blink 2.4s ease-in-out infinite; }
.badge.off { background: var(--off-bg); color: var(--off); border-color: color-mix(in srgb, var(--off) 25%, transparent); }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.badge.unknown { background: var(--unknown-bg); color: var(--muted); }
@keyframes blink { 50% { opacity: .35; box-shadow: none; } }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; list-style: none; padding: 0; margin: .5rem 0; }
.chips li, .chip { display: inline-flex; gap: .45rem; align-items: center; padding: .2rem .5rem .2rem .85rem; margin: .1rem;
  border-radius: 999px; font-size: .88rem; background: var(--surface-2); border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 var(--highlight); }
.chips .check { margin: 0; }

.flash { position: relative; display: flex; align-items: center; gap: .7rem; padding: .8rem 1.1rem .8rem 1rem; margin-bottom: 1.1rem;
  border-radius: var(--radius-sm); border: 1px solid; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-sm); font-weight: 500; overflow: hidden; }
.flash::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 4px; background: currentColor;
  box-shadow: 0 0 14px currentColor; }
.flash.ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.flash.err { background: var(--off-bg); color: var(--off); border-color: color-mix(in srgb, var(--off) 30%, transparent); }
.flash.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.flash.leaving { animation: fade-out .4s var(--ease) forwards; }
@keyframes fade-out { to { opacity: 0; transform: translateY(-8px); } }
.warn-note { display: flex; gap: .4rem; align-items: center; color: var(--warn); font-size: .84rem; margin-top: 1.1rem; }

/* ------------------------------------------------------------------ stats */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 1rem; margin-bottom: 1.3rem; }
.stat { --accent-1: #8f7dff; --accent-2: #5b8cff;
  position: relative; overflow: hidden; display: block; border-radius: var(--radius); padding: 1rem 1.15rem 1.05rem;
  color: inherit; transform-style: preserve-3d; will-change: transform;
  transition: transform .35s var(--ease), border-color .3s, box-shadow .3s; }
.stat::before { /* accent glow orb */
  content: ""; position: absolute; width: 140px; height: 140px; inset-inline-end: -46px; top: -56px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent-1), transparent 70%); opacity: .32; transition: opacity .35s, transform .6s var(--ease); }
.stat::after { /* top accent line */
  content: ""; position: absolute; inset-inline: 18px; top: 0; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-1), var(--accent-2), transparent); opacity: .8; }
.stat:hover { border-color: var(--border-strong); box-shadow: var(--shadow), 0 20px 40px -24px var(--accent-1), inset 0 1px 0 var(--highlight); }
.stat:hover::before { opacity: .55; transform: scale(1.2); }
.stat .stat-ico { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; margin-bottom: .7rem; color: #fff;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  box-shadow: 0 10px 20px -8px var(--accent-1), inset 0 1px 0 rgba(255, 255, 255, .35), inset 0 -2px 0 rgba(0, 0, 0, .15);
  transform: translateZ(30px); }
.stat .stat-ico .ico { width: 22px; height: 22px; }
.stat span { display: block; color: var(--muted); font-size: .84rem; font-weight: 500; }
.stat b { display: block; font-size: 1.65rem; font-weight: 800; line-height: 1.45; font-variant-numeric: tabular-nums;
  letter-spacing: -.01em; transform: translateZ(20px); }
.stat small { display: block; font-size: .8rem; }
a.stat:hover { color: inherit; }
a.stat::after { opacity: 1; }
.stat.attention { border-color: color-mix(in srgb, var(--warn) 55%, transparent); animation: attention 2.6s ease-in-out infinite; }
.stat.attention b { color: var(--warn); }
@keyframes attention { 50% { box-shadow: var(--shadow), 0 0 0 4px var(--warn-bg), 0 0 34px -8px var(--warn); } }
.stats > .stat:nth-child(6n+1) { --accent-1: #8f7dff; --accent-2: #5b8cff; }
.stats > .stat:nth-child(6n+2) { --accent-1: #22d3ee; --accent-2: #3b82f6; }
.stats > .stat:nth-child(6n+3) { --accent-1: #34d399; --accent-2: #10b981; }
.stats > .stat:nth-child(6n+4) { --accent-1: #fbbf24; --accent-2: #f97316; }
.stats > .stat:nth-child(6n+5) { --accent-1: #f472b6; --accent-2: #a855f7; }
.stats > .stat:nth-child(6n+6) { --accent-1: #60a5fa; --accent-2: #22d3ee; }

/* ------------------------------------------------------------------ auth */
body.guest .container { min-height: 100vh; display: grid; place-items: center; padding-block: 2rem; }
.auth-card { position: relative; width: min(420px, 100%); border-radius: 24px; padding: 2rem 1.8rem 1.6rem; }
.auth-card::before { /* animated gradient ring */
  content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; pointer-events: none;
  background: conic-gradient(from var(--angle, 0deg), transparent 0 60%, #a78bfa, #22d3ee, transparent 90%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  animation: spin 6s linear infinite; }
@property --angle { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
@keyframes spin { to { --angle: 360deg; } }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: .3rem; margin-bottom: 1.2rem; text-align: center; }
.auth-logo .logo { width: 64px; height: 64px; border-radius: 19px; animation: float 5s ease-in-out infinite; }
.auth-logo .logo svg { width: 64px; height: 64px; }
.auth-logo b { font-size: 1.5rem; font-weight: 900; margin-top: .4rem; }
.auth-card h1 { font-size: 1.05rem; font-weight: 600; color: var(--muted); margin: 0; }
@keyframes float { 50% { transform: translateY(-6px) rotate(-4deg); } }
.totp { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.totp img, .qr { background: #fff; padding: 8px; border-radius: 12px; box-shadow: var(--shadow-sm); }
.backends { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .2rem 1rem; }
.backends .check { padding: .5rem .7rem; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.backends .check small { display: block; }
.test-result { margin-top: .9rem; }

/* type-dependent fields (toggled by app.js via data-type on <body>) */
body[data-type="wg"] .xui-only, body[data-type="xui"] .wg-only { display: none; }

/* ------------------------------------------------------------------ misc (Phase 9) */
.small-note { font-size: .84rem; }
.filters { padding: .7rem .9rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.filters select, .filters input { width: auto; min-width: 150px; flex: 0 1 auto; }
.pager { display: flex; gap: .8rem; align-items: center; justify-content: center; margin: 1.2rem 0; }
.tabs { display: inline-flex; gap: .25rem; flex-wrap: wrap; margin-bottom: 1.1rem; padding: .3rem; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: inset 0 1px 0 var(--highlight); }
.tabs a { padding: .4rem 1rem; border-radius: 10px; color: var(--muted); font-weight: 600; transition: background .2s, color .2s; }
.tabs a:hover { color: var(--text); background: var(--surface-hover); }
.tabs a.active { color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 6px 16px -8px var(--primary), inset 0 1px 0 rgba(255, 255, 255, .25); }
.pos { color: var(--ok); font-weight: 600; font-variant-numeric: tabular-nums; }
.neg { color: var(--off); font-weight: 600; font-variant-numeric: tabular-nums; }
td.clip { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.break { word-break: break-all; white-space: normal; }

.receipts { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 1.1rem; }
.receipt { display: flex; flex-direction: column; gap: .55rem; margin: 0; transition: transform .35s var(--ease), border-color .3s; }
.receipt:hover { transform: translateY(-3px); border-color: var(--border-strong); }
.receipt h3 { margin: 0; font-size: 1rem; }
.receipt p { margin: .15rem 0; }
.receipt-img { width: 100%; max-height: 380px; object-fit: contain; background: var(--field); border-radius: 12px;
  border: 1px solid var(--border); cursor: zoom-in; transition: transform .35s var(--ease); }
.receipt-img:hover { transform: scale(1.015); }
details.reject summary { list-style: none; cursor: pointer; display: inline-flex; }
details.reject summary::-webkit-details-marker { display: none; }
details.reject[open] { flex-basis: 100%; }
details.reject form { margin-top: .7rem; }

/* ------------------------------------------------------------------ chart */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 220px; padding: .6rem .2rem 0; position: relative;
  border-bottom: 1px solid var(--border);
  background: repeating-linear-gradient(to top, transparent 0 calc(25% - 1px), var(--border) calc(25% - 1px) 25%); }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%;
  gap: 6px; min-width: 0; position: relative; }
.bar-col small { color: var(--muted); font-size: .7rem; }
.bar { width: 100%; max-width: 38px; border-radius: 9px 9px 3px 3px; position: relative; transform-origin: bottom;
  background: linear-gradient(180deg, #a78bfa, var(--primary) 45%, var(--primary-2));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .08) inset, 0 10px 24px -10px var(--primary);
  animation: grow .9s var(--ease) both; transition: filter .2s, transform .25s var(--ease); }
.bar::after { content: ""; position: absolute; inset: 0 0 auto; height: 40%; border-radius: inherit;
  background: linear-gradient(rgba(255, 255, 255, .35), transparent); }
.bar-col:hover .bar { filter: brightness(1.2) drop-shadow(0 0 10px var(--primary)); transform: scaleX(1.08); }
.bar-col:nth-child(2) .bar { animation-delay: .03s; } .bar-col:nth-child(3) .bar { animation-delay: .06s; }
.bar-col:nth-child(4) .bar { animation-delay: .09s; } .bar-col:nth-child(5) .bar { animation-delay: .12s; }
.bar-col:nth-child(6) .bar { animation-delay: .15s; } .bar-col:nth-child(7) .bar { animation-delay: .18s; }
.bar-col:nth-child(8) .bar { animation-delay: .21s; } .bar-col:nth-child(9) .bar { animation-delay: .24s; }
.bar-col:nth-child(10) .bar { animation-delay: .27s; } .bar-col:nth-child(11) .bar { animation-delay: .3s; }
.bar-col:nth-child(12) .bar { animation-delay: .33s; } .bar-col:nth-child(13) .bar { animation-delay: .36s; }
.bar-col:nth-child(14) .bar { animation-delay: .39s; }
@keyframes grow { from { transform: scaleY(0); opacity: 0; } }
.bar-h0 { height: 3px; opacity: .35; }
.bar-h5 { height: calc(.05 * (100% - 1.4rem)); } .bar-h10 { height: calc(.10 * (100% - 1.4rem)); }
.bar-h15 { height: calc(.15 * (100% - 1.4rem)); } .bar-h20 { height: calc(.20 * (100% - 1.4rem)); }
.bar-h25 { height: calc(.25 * (100% - 1.4rem)); } .bar-h30 { height: calc(.30 * (100% - 1.4rem)); }
.bar-h35 { height: calc(.35 * (100% - 1.4rem)); } .bar-h40 { height: calc(.40 * (100% - 1.4rem)); }
.bar-h45 { height: calc(.45 * (100% - 1.4rem)); } .bar-h50 { height: calc(.50 * (100% - 1.4rem)); }
.bar-h55 { height: calc(.55 * (100% - 1.4rem)); } .bar-h60 { height: calc(.60 * (100% - 1.4rem)); }
.bar-h65 { height: calc(.65 * (100% - 1.4rem)); } .bar-h70 { height: calc(.70 * (100% - 1.4rem)); }
.bar-h75 { height: calc(.75 * (100% - 1.4rem)); } .bar-h80 { height: calc(.80 * (100% - 1.4rem)); }
.bar-h85 { height: calc(.85 * (100% - 1.4rem)); } .bar-h90 { height: calc(.90 * (100% - 1.4rem)); }
.bar-h95 { height: calc(.95 * (100% - 1.4rem)); } .bar-h100 { height: calc(1 * (100% - 1.4rem)); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1024px) {
  body.app .container { margin-inline-start: 0; }
  body.app .topbar { margin-inline-start: clamp(12px, 3vw, 40px); }
  .menu-btn { display: inline-grid; }
  html.js .sidebar { inset-block: 0; inset-inline-start: 0; width: min(300px, 86vw); border-radius: 0 22px 22px 0;
    transform: translateX(105%); transition: transform .45s var(--ease); visibility: hidden; }
  html.js.nav-open .sidebar { transform: none; visibility: visible; }
  html.js .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(3, 5, 14, .55);
    backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity .35s; }
  html.js.nav-open .scrim { opacity: 1; pointer-events: auto; }
  html:not(.js) .sidebar { position: static; width: auto; margin: 12px; }
  html:not(.js) .menu-btn { display: none; }
}
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  h1 { font-size: 1.35rem; }
  .hide-sm { display: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
  .stat { padding: .85rem .9rem; } .stat b { font-size: 1.25rem; } .stat .stat-ico { width: 38px; height: 38px; }
  .card { padding: 1rem; }
  td.actions { flex-wrap: wrap; justify-content: flex-start; }
  .receipts { grid-template-columns: 1fr; }
  .chart { height: 170px; gap: 3px; } .bar-col small { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
