/* ATLAS panel — design system
   ------------------------------------------------------------------------------------------
   Layers: tokens → base → layout → components → page modules → responsive.
   One accent (the same blue as the Discord bot's emojis); green / amber / red only for state.
   Depth comes from surfaces and 1px borders; shadows only on things that float (menus,
   dialogs, toasts). Icons are inline SVG from Iconify (Tabler), drawn with currentColor. */

/* Tokens ----------------------------------------------------------------------------------- */

:root {
  --bg: #0a0c10;
  --bg-2: #0d1015;          /* sidebar, inputs */
  --surface: #11141a;       /* cards */
  --surface-2: #161a21;     /* hover, nested surfaces */
  --raised: #1c212a;        /* active states */
  --line: #212630;
  --line-soft: #191d25;
  --line-strong: #2c3340;

  --text: #e8ebf1;
  --text-2: #a7afbd;
  --muted: #6f7888;

  --accent: #5b8cff;
  --accent-hover: #7099ff;
  --accent-press: #4a79ea;
  --accent-soft: rgba(91, 140, 255, 0.12);
  --accent-line: rgba(91, 140, 255, 0.35);
  --on-accent: #ffffff;

  --green: #3ecf8e;
  --green-soft: rgba(62, 207, 142, 0.12);
  --amber: #f2b544;
  --amber-soft: rgba(242, 181, 68, 0.12);
  --red: #f2616a;
  --red-soft: rgba(242, 97, 106, 0.12);
  --violet: #a78bfa;
  --violet-soft: rgba(167, 139, 250, 0.12);
  --sky: #7ea8ff;

  --radius-lg: 12px;   /* cards, dialogs */
  --radius: 8px;       /* controls */
  --radius-sm: 6px;    /* badges, small chips */

  --shadow-float: 0 12px 32px -8px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--line);
  --focus: 0 0 0 3px rgba(91, 140, 255, 0.28);

  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "Cascadia Mono", monospace;

  --sidebar-w: 248px;
  --topbar-h: 56px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  color-scheme: dark;
}

/* Base -------------------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
code, kbd, .mono { font-family: var(--mono); font-size: 0.9em; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
.sr { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { flex-shrink: 0; display: inline-block; vertical-align: middle; }
.muted { color: var(--muted); }
.muted-2 { color: var(--text-2); }
.right { margin-left: auto; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.inline-ic { display: inline-flex; align-items: center; gap: 6px; }
.inline-ic .ic { color: var(--muted); }
.narrow { max-width: 600px; }
.mt-16 { margin-top: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
::selection { background: rgba(91, 140, 255, 0.3); }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

/* Layout ------------------------------------------------------------------------------------ */

.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; z-index: 30;
  display: flex; flex-direction: column;
  background: var(--bg-2); border-right: 1px solid var(--line-soft);
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; height: var(--topbar-h); padding: 0 12px 0 16px; border-bottom: 1px solid var(--line-soft); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-text strong { font-size: 14px; font-weight: 700; letter-spacing: 0.08em; }
.brand-text small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-close { display: none !important; }

.nav { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 18px; }
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-label { padding: 0 10px 6px; color: var(--muted); font-size: 11.5px; font-weight: 500; }
.nav-link {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px;
  border-radius: var(--radius); color: var(--text-2); font-weight: 500;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.nav-link .ic { color: var(--muted); transition: color 0.12s var(--ease); }
.nav-link span:not(.nav-count) { flex: 1; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link:hover .ic { color: var(--text-2); }
.nav-link.is-active { background: var(--raised); color: var(--text); }
.nav-link.is-active .ic { color: var(--accent); }
.nav-count { min-width: 22px; padding: 0 6px; height: 20px; line-height: 20px; border-radius: 10px; background: var(--surface-2); color: var(--text-2); font-size: 11.5px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.nav-link.is-active .nav-count { background: var(--accent-soft); color: var(--accent-hover); }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--line-soft); }
.bot-status { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); }
.bot-status-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.bot-status-text strong { font-size: 13px; font-weight: 600; }
.bot-status-text small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); flex-shrink: 0; box-shadow: 0 0 0 3px var(--red-soft); }
.bot-status.is-online .status-dot { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.scrim { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; overflow-x: clip; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; height: var(--topbar-h); padding: 0 24px;
  background: rgba(10, 12, 16, 0.94); border-bottom: 1px solid var(--line-soft);
}
.nav-toggle { display: none !important; }
.quick-search {
  display: flex; align-items: center; gap: 8px; width: min(420px, 100%); height: 36px; padding: 0 6px 0 12px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-2); color: var(--muted);
  transition: border-color 0.12s var(--ease), box-shadow 0.12s var(--ease);
}
.quick-search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; color: var(--text); }
.quick-search input::placeholder { color: var(--muted); }
.quick-search:focus-within { border-color: var(--accent-line); box-shadow: var(--focus); }
kbd { padding: 2px 6px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-size: 11px; white-space: nowrap; }
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.server-chip { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px 0 6px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line-soft); color: var(--text-2); font-size: 13px; max-width: 220px; }
.server-chip img { border-radius: 6px; }
.server-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px 0 4px; border-radius: var(--radius); cursor: pointer; color: var(--text-2); list-style: none; }
.user-chip::-webkit-details-marker { display: none; }
.user-chip:hover, .user-menu[open] .user-chip { background: var(--surface-2); color: var(--text); }
.user-name { font-weight: 500; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { width: 100%; max-width: 1400px; margin: 0 auto; padding: 28px 32px 64px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.page-title h1 { font-size: 24px; font-weight: 600; line-height: 1.2; }
.page-title p { margin-top: 4px; color: var(--muted); }
.page-title p:empty { display: none; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-actions:empty { display: none; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 20px; align-items: start; }

/* Buttons ------------------------------------------------------------------------------------ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
  font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background 0.12s var(--ease), border-color 0.12s var(--ease), color 0.12s var(--ease);
}
.btn .ic { color: var(--text-2); }
.btn:hover { background: var(--raised); border-color: #353d4b; }
.btn:active { background: var(--surface); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary .ic { color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:active { background: var(--accent-press); border-color: var(--accent-press); }
.btn-soft { background: var(--accent-soft); border-color: transparent; color: #c6d6ff; }
.btn-soft .ic { color: var(--accent-hover); }
.btn-soft:hover { background: rgba(91, 140, 255, 0.2); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn-danger { background: var(--red-soft); border-color: rgba(242, 97, 106, 0.3); color: #ffb3b8; }
.btn-danger .ic { color: var(--red); }
.btn-danger:hover { background: rgba(242, 97, 106, 0.2); border-color: rgba(242, 97, 106, 0.5); }
.btn-danger-ghost:hover { color: #ffb3b8; border-color: rgba(242, 97, 106, 0.45); background: var(--red-soft); }
.btn-danger-ghost:hover .ic { color: var(--red); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 6px; }
.btn-lg { height: 42px; padding: 0 18px; font-size: 15px; }
.btn-block { width: 100%; }
.btn:disabled, .btn.is-disabled { opacity: 0.45; pointer-events: none; }
.btn[aria-busy="true"] { opacity: 0.7; pointer-events: none; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: var(--radius); background: transparent; color: var(--text-2); cursor: pointer; list-style: none;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.icon-btn::-webkit-details-marker { display: none; }
.icon-btn:hover, .menu[open] > .icon-btn { background: var(--surface-2); color: var(--text); }
.link { color: var(--accent-hover); font-weight: 500; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.btn-count { min-width: 18px; padding: 0 5px; height: 18px; line-height: 18px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; text-align: center; }
.copied { color: var(--green) !important; }

/* Cards ------------------------------------------------------------------------------------- */

.card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); padding: 20px; min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.card-title h2 { font-size: 15px; font-weight: 600; }
.card-title p { margin-top: 2px; color: var(--muted); font-size: 13px; }
.card-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tile {
  --t: var(--accent); --tb: var(--accent-soft);
  display: inline-grid; place-items: center; flex-shrink: 0; width: 34px; height: 34px; border-radius: var(--radius);
  color: var(--t); background: var(--tb);
}
.tile-sm { width: 28px; height: 28px; }
.tile-blue { --t: var(--accent); --tb: var(--accent-soft); }
.tile-sky { --t: var(--sky); --tb: rgba(126, 168, 255, 0.1); }
.tile-green { --t: var(--green); --tb: var(--green-soft); }
.tile-amber { --t: var(--amber); --tb: var(--amber-soft); }
.tile-red { --t: var(--red); --tb: var(--red-soft); }
.tile-violet { --t: var(--violet); --tb: var(--violet-soft); }
.tile-muted { --t: var(--muted); --tb: var(--surface-2); }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat {
  --t: var(--accent); --tb: var(--accent-soft);
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto auto; column-gap: 12px;
  padding: 18px 20px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line-soft);
}
.stat-blue { --t: var(--accent); --tb: var(--accent-soft); }
.stat-amber { --t: var(--amber); --tb: var(--amber-soft); }
.stat-green { --t: var(--green); --tb: var(--green-soft); }
.stat-violet { --t: var(--violet); --tb: var(--violet-soft); }
.stat > div { grid-column: 1; grid-row: 1 / span 2; display: flex; flex-direction: column-reverse; gap: 6px; }
.stat strong { font-size: 28px; font-weight: 600; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat div span { color: var(--text-2); font-size: 13px; font-weight: 500; }
.stat-ic { grid-column: 2; grid-row: 1; display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius); background: var(--tb); color: var(--t); }
.stat-ic .ic { width: 18px; height: 18px; }
.stat small { grid-column: 1 / span 2; grid-row: 3; margin-top: 12px; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.stat small .ic { width: 14px; height: 14px; }

.mini-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.mini-strip.mini-strip-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mini-strip > div {
  --t: var(--accent); --tb: var(--accent-soft);
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; min-width: 0;
  border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line-soft);
}
.mini-strip > div:nth-child(2) { --t: var(--green); --tb: var(--green-soft); }
.mini-strip > div:nth-child(3) { --t: var(--violet); --tb: var(--violet-soft); }
.mini-strip > div:nth-child(4) { --t: var(--amber); --tb: var(--amber-soft); }
.mini-strip > div.strip-active { --t: var(--green); --tb: var(--green-soft); }
.mini-strip > div.strip-expired { --t: var(--amber); --tb: var(--amber-soft); }
.mini-strip > div.strip-unused { --t: var(--accent); --tb: var(--accent-soft); }
.mini-strip > div.strip-revoked { --t: var(--red); --tb: var(--red-soft); }
.mini-strip > div > .ic:first-child { box-sizing: content-box; width: 16px; height: 16px; padding: 7px; border-radius: var(--radius); color: var(--t); background: var(--tb); }
.mini-strip strong { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mini-strip span:last-child { color: var(--muted); font-size: 13px; }

/* Badges ------------------------------------------------------------------------------------ */

.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px 0 6px; border-radius: 11px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--surface-2); color: var(--text-2); }
.pill .ic { width: 13px; height: 13px; }
.pill-active, .pill-up { color: var(--green); background: var(--green-soft); }
.pill-unused { color: var(--accent-hover); background: var(--accent-soft); }
.pill-expired, .pill-updating { color: var(--amber); background: var(--amber-soft); }
.pill-revoked, .pill-down { color: var(--red); background: var(--red-soft); }
.pill-muted { color: var(--muted); background: var(--surface-2); }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: var(--radius-sm); font-size: 11.5px; font-weight: 500; white-space: nowrap; border: 1px solid var(--line); color: var(--text-2); }
.tag .ic { width: 12px; height: 12px; }
.tag-paid { color: var(--amber); border-color: rgba(242, 181, 68, 0.3); background: var(--amber-soft); }
.tag-free { color: var(--green); border-color: rgba(62, 207, 142, 0.28); background: var(--green-soft); }
.glass { background: rgba(10, 12, 16, 0.82) !important; color: #fff !important; }
.glass-tag { background: rgba(30, 22, 6, 0.88); }
.count-chip { display: inline-block; min-width: 26px; padding: 1px 7px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted); text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.count-chip.is-on { background: var(--green-soft); color: var(--green); }
.count-chip.is-paid { background: var(--amber-soft); color: var(--amber); }
.chip-ok, .chip-warn { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px; border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.chip-ok { color: var(--green); background: var(--green-soft); }
.chip-warn { color: var(--amber); background: var(--amber-soft); }

/* Forms ------------------------------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field > span, .field legend, .field-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text); padding: 0; }
.field > span .ic, .field legend .ic { color: var(--muted); width: 15px; height: 15px; }
.field em { font-style: normal; font-weight: 400; color: var(--muted); }
.field-split em { margin-left: auto; font-family: var(--mono); font-size: 12px; }
.field-help { color: var(--muted); font-size: 12.5px; margin-top: -2px; }
.field input, .field select, .field textarea, .search, .select-wrap, .custom-duration input, .control {
  height: 38px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-2); color: var(--text);
  transition: border-color 0.12s var(--ease), box-shadow 0.12s var(--ease), background 0.12s var(--ease);
}
.field input, .field textarea, .control { width: 100%; padding: 0 12px; }
.field textarea, textarea.control { height: auto; min-height: 92px; padding: 10px 12px; line-height: 1.55; resize: vertical; }
.field input::placeholder, .field textarea::placeholder, .search input::placeholder, .control::placeholder { color: #545c6b; }
.field input:hover, .field textarea:hover, .select-wrap:hover, .search:hover, .control:hover { border-color: var(--line-strong); }
.field input:focus, .field textarea:focus, .select-wrap:focus-within, .search:focus-within, .control:focus { outline: none; border-color: var(--accent-line); box-shadow: var(--focus); }
.field input:disabled, .control:disabled { opacity: 0.55; }
.control[aria-invalid="true"] { border-color: rgba(242, 97, 106, 0.6); }
.field-row { display: flex; gap: 14px; }
.field-row .field:not(.grow) { width: 160px; flex-shrink: 0; }
.grow { flex: 1; }
.help { display: flex; align-items: flex-start; gap: 8px; color: var(--muted); font-size: 13px; line-height: 1.55; margin-top: 12px; }
.help > .ic { margin-top: 2px; color: var(--muted); width: 15px; height: 15px; }
.help code, .empty code { background: var(--surface-2); border: 1px solid var(--line-soft); padding: 1px 5px; border-radius: 5px; color: var(--text-2); }
.suffix { position: relative; display: flex; align-items: center; }
.suffix input { padding-right: 56px !important; }
.suffix em { position: absolute; right: 12px; color: var(--muted); pointer-events: none; font-style: normal; }
.input-ic { position: relative; display: flex; align-items: center; }
.input-ic > .ic { position: absolute; left: 12px; color: var(--muted); pointer-events: none; width: 16px; height: 16px; }
.field .input-ic input, .input-ic .control { padding-left: 38px; }
.input-ic:focus-within > .ic { color: var(--text-2); }
.input-btn { position: absolute; right: 4px; display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); cursor: pointer; }
.input-btn:hover { background: var(--surface-2); color: var(--text); }
.input-ic:has(.input-btn) input { padding-right: 40px; }
.select-wrap { position: relative; display: flex; align-items: center; gap: 8px; padding-left: 12px; color: var(--muted); }
.select-wrap select {
  flex: 1; height: 100%; min-width: 0; padding: 0 34px 0 0; border: 0; background: transparent; outline: none; appearance: none; cursor: pointer; color: var(--text);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%236f7888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='m8 9 4-4 4 4M16 15l-4 4-4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.select-wrap select option, .select-wrap select optgroup { background: var(--surface-2); color: var(--text); }
.select-bare { padding-left: 12px; }
.copy-field { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 4px 4px 4px 12px; border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--line); }
.copy-field > .ic { color: var(--muted); width: 16px; height: 16px; }
.copy-field code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.copy-field.secret:not(.revealed) code { filter: blur(5px); user-select: none; }
.code-area { width: 100%; min-height: 160px; padding: 12px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; border-radius: var(--radius); border: 1px solid var(--line); background: #08090d !important; color: #cbd3e1; resize: vertical; tab-size: 2; }
.code-area-sm { min-height: 72px; }
.code-area:focus { outline: none; border-color: var(--accent-line); box-shadow: var(--focus); }

/* Native checkbox → custom */
input[type="checkbox"]:not(.switch) {
  appearance: none; width: 16px; height: 16px; margin: 0; border-radius: 4px; cursor: pointer; vertical-align: middle;
  border: 1.5px solid var(--line-strong); background: var(--bg-2); display: inline-grid; place-items: center;
  transition: background 0.12s var(--ease), border-color 0.12s var(--ease);
}
input[type="checkbox"]:not(.switch):hover { border-color: var(--text-2); }
input[type="checkbox"]:not(.switch):checked, input[type="checkbox"]:not(.switch):indeterminate { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"]:not(.switch):checked::after { content: ""; width: 8px; height: 4.5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
input[type="checkbox"]:not(.switch):indeterminate::after { content: ""; width: 8px; height: 2px; border-radius: 2px; background: #fff; }

/* Switch */
input.switch { appearance: none; width: 38px; height: 22px; margin: 0; border-radius: 11px; background: var(--raised); border: 1px solid var(--line-strong); position: relative; cursor: pointer; transition: background 0.15s var(--ease), border-color 0.15s var(--ease); flex-shrink: 0; }
input.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #8f98a8; transition: transform 0.15s var(--ease), background 0.15s var(--ease); }
input.switch:checked { background: var(--accent); border-color: var(--accent); }
input.switch:checked::after { transform: translateX(16px); background: #fff; }
input.switch:disabled { cursor: default; opacity: 0.5; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line-soft); cursor: pointer; }
.card-head + .switch-row { border-top: 0; padding-top: 0; }
.switch-label { display: flex; align-items: center; gap: 12px; min-width: 0; }
.switch-label > .ic:first-child { box-sizing: content-box; width: 16px; height: 16px; padding: 8px; border-radius: var(--radius); background: var(--surface-2); color: var(--text-2); }
.switch-label > span:last-child, .switch-row > span:not(.switch-label) { display: flex; flex-direction: column; }
.switch-row strong { font-weight: 500; }
.switch-row small { color: var(--muted); font-size: 12.5px; }
.switch-row + .field-row { padding-top: 14px; border-top: 1px solid var(--line-soft); }
.switch-row-tight { padding: 12px 14px; border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--bg-2); }
.switch-row-tight.disabled { opacity: 0.55; cursor: default; }
.switch-inline { display: inline-flex; cursor: pointer; }

/* Option chips (radio groups) */
.chips, .opt-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chips input, .opt input { position: absolute; opacity: 0; pointer-events: none; }
.chips span, .opt span {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-2); color: var(--text-2);
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: border-color 0.12s var(--ease), background 0.12s var(--ease), color 0.12s var(--ease);
}
.chips span .ic, .opt span .ic { color: var(--muted); width: 15px; height: 15px; }
.chips span:hover, .opt span:hover { border-color: var(--line-strong); color: var(--text); }
.chips input:checked + span, .opt input:checked + span { border-color: var(--accent-line); background: var(--accent-soft); color: var(--text); }
.chips input:checked + span .ic, .opt input:checked + span .ic { color: var(--accent-hover); }
.chips input:focus-visible + span, .opt input:focus-visible + span { box-shadow: var(--focus); }
.opt { position: relative; }
.opt b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.opt em { font-style: normal; min-width: 20px; padding: 0 5px; border-radius: 5px; background: var(--surface-2); color: var(--muted); font-size: 11px; font-weight: 600; text-align: center; }
.opt input:checked + span em { background: rgba(91, 140, 255, 0.22); color: #d6e2ff; }
.custom-duration { display: flex; gap: 8px; margin-top: 10px; }
.custom-duration input { width: 110px; padding: 0 12px; }

/* Tabs */
.tabs, .range-tabs, .settings-tabs {
  display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--line-soft);
  overflow-x: auto; scrollbar-width: none; max-width: 100%;
}
.tabs::-webkit-scrollbar, .settings-tabs::-webkit-scrollbar { display: none; }
.tabs a, .range-tabs a, .settings-tabs a {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px; border-radius: 6px;
  color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap; transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.tabs a .ic, .range-tabs a .ic, .settings-tabs a .ic { width: 15px; height: 15px; }
.tabs a:hover, .range-tabs a:hover, .settings-tabs a:hover { color: var(--text); }
.tabs a.on, .range-tabs a.on, .settings-tabs a.on { background: var(--raised); color: var(--text); }
.tabs a.on .ic, .settings-tabs a.on .ic { color: var(--accent); }
.tab-count { font-style: normal; min-width: 20px; padding: 0 5px; border-radius: 5px; background: var(--surface-2); color: var(--muted); font-size: 11px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.tabs a.on .tab-count { background: var(--accent-soft); color: var(--accent-hover); }
.settings-tabs { position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 10; align-self: flex-start; }
.js-tabs .tab-panel:not(.on) { display: none !important; }
.settings { display: flex; flex-direction: column; gap: 20px; }
.settings-save { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 12px 12px 18px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line-soft); }
.settings-save span { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }

/* Tables ------------------------------------------------------------------------------------ */

.table-card { padding: 0; overflow: hidden; }
.toolbar, .filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); min-height: 58px; }
.filters { justify-content: space-between; }
.filters-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text-2); }
.filters-title .ic { color: var(--muted); }
.filter-right { display: flex; gap: 10px; flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 8px; padding: 0 8px 0 12px; color: var(--muted); width: 280px; }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: none; color: var(--text); }
.search-clear { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; color: var(--muted); }
.search-clear:hover { background: var(--surface-2); color: var(--text); }
.toolbar .btn.is-on { border-color: var(--accent-line); background: var(--accent-soft); }
.toolbar .btn.is-on .ic { color: var(--accent-hover); }
.toolbar-hint { color: var(--muted); font-size: 13px; }
.toolbar-clear { color: var(--muted); font-size: 13px; font-weight: 500; }
.toolbar-clear:hover { color: var(--red); }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 6px 0 9px; border-radius: var(--radius-sm); background: var(--accent-soft); border: 1px solid transparent; color: #d1ddff; font-size: 12.5px; font-weight: 500; }
.filter-chip > .ic:first-child { color: var(--accent-hover); width: 14px; height: 14px; }
.filter-chip .chip-x { color: var(--muted); }
.filter-chip:hover { border-color: rgba(242, 97, 106, 0.35); }
.filter-chip:hover .chip-x { color: var(--red); }
.bulkbar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--accent-soft); border-bottom: 1px solid var(--accent-line); flex-wrap: wrap; }
.bulk-count { display: inline-flex; align-items: center; gap: 8px; margin-right: auto; color: var(--text-2); }
.bulk-count .ic { color: var(--accent-hover); }

.table-wrap { position: relative; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 10px 14px; background: var(--bg-2); white-space: nowrap; border-bottom: 1px solid var(--line-soft); }
.table td { padding: 11px 14px; border-top: 1px solid var(--line-soft); vertical-align: middle; white-space: nowrap; }
.table tbody tr:first-child td { border-top: 0; }
.table tbody tr { transition: background 0.1s var(--ease); }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.015); }
.table tbody tr:has(input[data-check]:checked) { background: var(--accent-soft); }
.table .num { text-align: right; }
.row-dim td { opacity: 0.5; }
.row-dim td.col-menu, .row-dim td.col-check, .row-dim td.col-actions { opacity: 1; }
.col-check { width: 44px; padding-left: 18px !important; }
.col-menu { width: 60px; text-align: right; }
.col-actions { text-align: right; width: 1%; white-space: nowrap; }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; }

.key-cell { display: flex; align-items: center; gap: 10px; }
.row-ic { display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-sm); flex-shrink: 0; }
.row-ic .ic { width: 15px; height: 15px; }
.row-ic-paid { background: var(--amber-soft); color: var(--amber); }
.row-ic-free { background: var(--green-soft); color: var(--green); }
.key-copy { display: inline-flex; align-items: center; gap: 8px; padding: 3px 7px; margin-left: -7px; border: 0; border-radius: var(--radius-sm); background: transparent; cursor: pointer; color: var(--text); }
.key-copy code { font-weight: 500; font-size: 13px; letter-spacing: 0.02em; }
.key-copy .ic { color: var(--muted); opacity: 0; transition: opacity 0.12s var(--ease); width: 14px; height: 14px; }
.key-copy:hover { background: var(--surface-2); }
.key-copy:hover .ic, .key-copy:focus-visible .ic { opacity: 1; }
.key-copy.copied .ic { color: var(--green); opacity: 1; }
.note { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.owner { display: inline-flex; align-items: center; gap: 9px; }
.owner-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.owner-stack { display: flex; flex-direction: column; line-height: 1.3; }
.owner-stack small { color: var(--muted); font-size: 12px; }
.owner-stack .buyer { display: inline-flex; align-items: center; gap: 3px; color: var(--amber); }
.avatar { border-radius: 50%; object-fit: cover; background: var(--raised); flex-shrink: 0; }
.avatar-empty { display: inline-grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--raised); }
.lifetime, .device { display: inline-flex; align-items: center; gap: 6px; }
.lifetime { color: var(--amber); font-weight: 500; }
.device { color: var(--text-2); }
.device .ic { color: var(--amber); }
.uses { display: inline-block; min-width: 26px; padding: 1px 7px; border-radius: var(--radius-sm); background: var(--surface-2); text-align: center; font-weight: 500; font-variant-numeric: tabular-nums; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 16px; border-top: 1px solid var(--line-soft); color: var(--muted); flex-wrap: wrap; }
.pager strong { color: var(--text); }

/* Menus ------------------------------------------------------------------------------------- */

.menu { position: relative; display: inline-block; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 220px; text-align: left;
  display: flex; flex-direction: column; padding: 6px; gap: 1px;
  background: var(--surface-2); border-radius: var(--radius-lg); box-shadow: var(--shadow-float);
  animation: pop 0.12s var(--ease);
}
.menu-pop.is-fixed { position: fixed; right: auto; bottom: auto; z-index: 90; max-height: calc(100vh - 16px); overflow-y: auto; }
.menu-pop > button, .menu-pop > a, .menu-pop form > button, .menu-row button {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px; border: 0; border-radius: var(--radius-sm);
  background: transparent; cursor: pointer; text-align: left; color: var(--text-2); font-size: 13px; font-weight: 500;
}
.menu-pop > button .ic, .menu-pop > a .ic, .menu-pop form > button .ic { color: var(--muted); width: 16px; height: 16px; }
.menu-pop > button:hover, .menu-pop > a:hover, .menu-pop form > button:hover, .menu-row button:hover { background: var(--raised); color: var(--text); }
.menu-pop .danger, .menu-pop .danger .ic { color: #ff9aa1; }
.menu-pop .danger:hover { background: var(--red-soft); }
.menu-title, .menu-label { display: flex; align-items: center; gap: 6px; padding: 8px 10px 6px; font-size: 12px; font-weight: 500; color: var(--muted); }
.menu-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 0 2px 6px; }
.menu-row button { justify-content: center; height: 30px; padding: 0; background: var(--bg-2); border: 1px solid var(--line); font-weight: 600; }
.menu-sep { height: 1px; margin: 4px 6px; background: var(--line); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }

/* Lists ------------------------------------------------------------------------------------- */

.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rows li { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-top: 1px solid var(--line-soft); }
.rows li:first-child { border-top: 0; padding-top: 0; }
.rows .muted { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.checks li { --t: var(--green); display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.checks li:first-child { border-top: 0; padding-top: 0; }
.checks li.warn { --t: var(--amber); }
.checks li.bad { --t: var(--red); }
.check-ic { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius); background: var(--surface-2); color: var(--text-2); flex-shrink: 0; }
.checks li > span:nth-child(2) { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.checks strong { font-size: 13.5px; font-weight: 500; }
.checks small { color: var(--muted); font-size: 12.5px; }
.check-state { margin-left: auto; color: var(--t); display: grid; place-items: center; }
.rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rank li { display: flex; align-items: center; gap: 14px; padding: 11px 0; border-top: 1px solid var(--line-soft); }
.rank li:first-child { border-top: 0; padding-top: 0; }
.rank-no { display: grid; place-items: center; width: 26px; height: 26px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-2); font-weight: 600; font-size: 12.5px; flex-shrink: 0; }
.rank li:first-child .rank-no { background: var(--amber-soft); color: var(--amber); }
.rank-body { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rank-body strong { display: flex; align-items: center; gap: 6px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-body > span { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; }
.rank-bar { display: block; height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.rank-bar b { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.rank-count { font-size: 18px; font-weight: 600; display: flex; flex-direction: column; align-items: flex-end; line-height: 1; font-variant-numeric: tabular-nums; }
.rank-count small { color: var(--muted); font-size: 11px; font-weight: 400; margin-top: 4px; }

/* Empty / notice states */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 48px 24px; color: var(--muted); }
.empty-ic { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 8px; border-radius: var(--radius-lg); color: var(--text-2); background: var(--surface-2); border: 1px solid var(--line); }
.empty h3 { color: var(--text); font-size: 15px; font-weight: 600; }
.empty p { max-width: 400px; font-size: 13.5px; }
.empty-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; justify-content: center; }
.empty.small { padding: 24px 12px; }
.empty.small .empty-ic { width: 40px; height: 40px; }
.notice-bar { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-lg); border: 1px solid var(--line-soft); background: var(--surface); color: var(--text-2); font-size: 13.5px; }
.notice-bar > .ic { margin-top: 1px; flex-shrink: 0; color: var(--accent); }
.notice-bar > div { flex: 1; min-width: 0; }
.notice-bar strong { color: var(--text); font-weight: 600; }
.notice-bar.is-warn { border-color: rgba(242, 181, 68, 0.28); background: rgba(242, 181, 68, 0.05); }
.notice-bar.is-warn > .ic { color: var(--amber); }
.notice-bar.is-error { border-color: rgba(242, 97, 106, 0.3); background: rgba(242, 97, 106, 0.05); }
.notice-bar.is-error > .ic { color: var(--red); }
.notice-bar.is-ok > .ic { color: var(--green); }
.notice-bar a:not(.btn) { color: var(--accent-hover); font-weight: 500; }
.notice-bar a:not(.btn):hover { text-decoration: underline; }
.notice-bar .btn { margin-left: auto; align-self: center; }

/* Charts ------------------------------------------------------------------------------------ */

.legend { display: flex; gap: 14px; color: var(--muted); font-size: 12.5px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.dot-runs { background: var(--accent); }
.dot-users { background: var(--sky); }
.dot-free { background: var(--green); }
.grid-main > .card:has(> .bar-chart) { align-self: stretch; display: flex; flex-direction: column; }
.bar-chart { display: flex; align-items: stretch; gap: 6px; min-height: 220px; flex: 1; }
.bar-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.bar-stack { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; padding: 0 14%; border-radius: var(--radius-sm); }
.bar-col:hover .bar-stack { background: rgba(255, 255, 255, 0.025); }
.bar-stack span { display: block; width: 100%; border-radius: 3px; }
.bar-paid { background: var(--accent); }
.bar-free { background: var(--green); }
.bar-col small { text-align: center; color: var(--muted); font-size: 10.5px; white-space: nowrap; overflow: hidden; font-variant-numeric: tabular-nums; }
.area-chart { display: flex; flex-direction: column; gap: 8px; }
.area-chart svg { width: 100%; height: 220px; overflow: visible; }
.area-chart .grid { stroke: var(--line-soft); stroke-width: 1; vector-effect: non-scaling-stroke; }
.area-chart .line-runs { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.area-chart .line-users { fill: none; stroke: var(--sky); stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-dasharray: 4 4; opacity: 0.9; }
.area-chart .area { opacity: 0.5; }
.area-chart .pt { fill: var(--accent); stroke: var(--surface); stroke-width: 2; opacity: 0; transition: opacity 0.12s; cursor: pointer; }
.area-chart .pt:hover { opacity: 1; }
.area-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 10.5px; }
.area-labels small { flex: 1; text-align: center; }
.area-labels small:first-child { text-align: left; }
.area-labels small:last-child { text-align: right; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 140px; border-bottom: 1px solid var(--line-soft); }
.spark-bar { flex: 1; border-radius: 3px 3px 0 0; background: var(--accent); min-height: 2px; opacity: 0.7; transition: opacity 0.12s; }
.spark-bar:hover, .spark-bar.is-peak { opacity: 1; }
.spark-axis { display: flex; justify-content: space-between; margin-top: 8px; color: var(--muted); font-size: 11px; }

/* Modals & toasts -------------------------------------------------------------------------- */

.modal { width: min(640px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-float); overflow-x: hidden; }
.modal::backdrop { background: rgba(4, 6, 10, 0.7); }
.modal[open] { animation: modal-in 0.16s var(--ease); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.985); } }
.modal-sm { width: min(420px, calc(100vw - 32px)); }
.modal-body { display: flex; flex-direction: column; gap: 18px; padding: 22px; max-height: 88vh; overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.modal-head h2 { font-size: 17px; font-weight: 600; }
.modal-head p { margin-top: 2px; color: var(--muted); font-size: 13px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.modal-foot-split { justify-content: space-between; align-items: center; }
.modal-foot-split > div { display: flex; gap: 8px; }
.confirm-body { align-items: center; text-align: center; gap: 8px; padding-top: 26px; }
.confirm-body h2 { margin-top: 4px; font-size: 17px; font-weight: 600; }
.confirm-body p { color: var(--muted); }
.confirm-body .modal-foot { width: 100%; margin-top: 10px; }
.confirm-body .modal-foot .btn { flex: 1; }
.confirm-ic { display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--radius); color: var(--red); background: var(--red-soft); }

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { position: relative; overflow: hidden; display: flex; align-items: center; gap: 10px; min-width: 280px; max-width: 420px; padding: 10px 8px 10px 12px; border-radius: var(--radius-lg); background: var(--surface-2); box-shadow: var(--shadow-float); animation: toast-in 0.2s var(--ease); transition: opacity 0.25s, transform 0.25s; }
.toast-ic { display: grid; place-items: center; color: var(--green); flex-shrink: 0; }
.toast-error .toast-ic { color: var(--red); }
.toast-text { flex: 1; font-size: 13.5px; }
.toast-x { display: grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); cursor: pointer; }
.toast-x:hover { background: var(--raised); color: var(--text); }
.toast-bar { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: var(--green); transform-origin: left; animation: toast-timer 3.6s linear forwards; opacity: 0.6; }
.toast-error .toast-bar { background: var(--red); }
.toast:hover .toast-bar { animation-play-state: paused; }
.toast.hide { opacity: 0; transform: translateY(6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-timer { to { transform: scaleX(0); } }

/* Auth & error ---------------------------------------------------------------------------- */

.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.auth-range { display: none; }
.auth-card { width: min(400px, 100%); padding: 32px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line-soft); }
.auth-brand { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 24px; }
.auth-mark { display: grid; place-items: center; width: 52px; height: 52px; border-radius: var(--radius-lg); background: var(--surface-2); border: 1px solid var(--line); }
.auth-mark svg { width: 30px; height: 30px; }
.auth-brand h1 { margin-top: 14px; font-size: 20px; font-weight: 700; letter-spacing: 0.12em; }
.auth-brand p { margin-top: 4px; color: var(--muted); }
.auth-foot { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 18px; color: var(--muted); font-size: 12.5px; }
.notice { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }
.notice-error { background: var(--red-soft); color: #ffc2c6; }
.notice-success { background: var(--green-soft); color: #b9f0d6; }
.error-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.error-ic { display: grid; place-items: center; width: 48px; height: 48px; border-radius: var(--radius-lg); color: var(--text-2); background: var(--surface-2); border: 1px solid var(--line); }
.error-card h1 { margin-top: 8px; font-size: 40px; font-weight: 600; font-variant-numeric: tabular-nums; }
.error-card p { margin-bottom: 12px; color: var(--muted); }

/* Page modules ------------------------------------------------------------------------------ */

/* Dashboard */
.created { border-color: rgba(62, 207, 142, 0.3); }
.created-list { display: flex; flex-wrap: wrap; gap: 8px; }
.key-chip { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border-radius: var(--radius); cursor: pointer; font-family: var(--mono); font-size: 13px; background: var(--bg-2); border: 1px solid var(--line); color: var(--text); }
.key-chip .ic { width: 15px; height: 15px; }
.key-chip .ic:first-child { color: var(--green); }
.key-chip .ic:last-child { color: var(--muted); }
.key-chip:hover { border-color: var(--line-strong); }
.key-chip.copied { border-color: rgba(62, 207, 142, 0.5); }
/* Scripts */
.script-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.script-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); transition: border-color 0.12s var(--ease); }
.script-card:hover { border-color: var(--line-strong); }
.script-card.off { opacity: 0.6; }
.script-cover { position: relative; height: 148px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; background: var(--surface-2); overflow: clip; }
.script-cover:has(.menu[open]) { overflow: visible; }
.script-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.script-card.off .script-art { filter: grayscale(0.8) brightness(0.7); }
.script-placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: var(--line-strong); }
.script-cover-grad { position: absolute; inset: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; background: linear-gradient(180deg, rgba(10, 12, 16, 0) 30%, rgba(10, 12, 16, 0.92) 100%); pointer-events: none; }
.script-cover-tags { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.script-menu { position: absolute; top: 8px; right: 8px; z-index: 3; }
.script-cover-title { position: absolute; left: 14px; right: 14px; bottom: 12px; display: flex; flex-direction: column; gap: 2px; }
.script-cover-title strong { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.script-cover-title span { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-2); font-family: var(--mono); }
.script-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.script-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.script-stats div { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px; border-radius: var(--radius); background: var(--bg-2); text-align: center; }
.script-stats .ic { color: var(--muted); width: 15px; height: 15px; margin-bottom: 2px; }
.script-stats strong { font-size: 17px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.script-stats span { color: var(--muted); font-size: 11.5px; }
.script-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.script-add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 280px; border-radius: var(--radius-lg); border: 1px dashed var(--line-strong); background: transparent; color: var(--text); cursor: pointer; transition: border-color 0.12s var(--ease), background 0.12s var(--ease); }
.script-add small { color: var(--muted); }
.script-add > .ic { box-sizing: content-box; padding: 12px; border-radius: var(--radius-lg); color: var(--text-2); background: var(--surface-2); margin-bottom: 4px; }
.script-add:hover { border-color: var(--accent-line); background: var(--surface); }

/* New-key panel & filter modal */
.modal-wide { width: min(940px, calc(100vw - 32px)); }
.modal-filter { width: min(720px, calc(100vw - 32px)); }
.nk { display: grid; grid-template-columns: minmax(0, 1fr) 300px; max-height: 90vh; }
.nk-main { display: flex; flex-direction: column; gap: 20px; padding: 24px; overflow-y: auto; }
.nk-close-sm { display: none !important; }
.type-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.type-card input { position: absolute; opacity: 0; pointer-events: none; }
.type-card-body { position: relative; display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: center; padding: 14px; border-radius: var(--radius-lg); cursor: pointer; background: var(--bg-2); border: 1px solid var(--line); transition: border-color 0.12s var(--ease), background 0.12s var(--ease); }
.type-card-body:hover { border-color: var(--line-strong); }
.type-card-ic { grid-row: span 2; display: grid; place-items: center; width: 38px; height: 38px; border-radius: var(--radius); }
.type-card-ic-paid { background: var(--amber-soft); color: var(--amber); }
.type-card-ic-free { background: var(--green-soft); color: var(--green); }
.type-card strong { font-size: 14px; font-weight: 600; }
.type-card small { color: var(--muted); font-size: 12px; line-height: 1.4; padding-right: 18px; }
.type-card-check { position: absolute; top: 10px; right: 10px; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: #fff; background: var(--accent); opacity: 0; transition: opacity 0.12s; }
.type-card input:checked + .type-card-body { border-color: var(--accent-line); background: var(--accent-soft); }
.type-card input:checked + .type-card-body .type-card-check { opacity: 1; }
.type-card input:focus-visible + .type-card-body { box-shadow: var(--focus); }
.stepper { display: flex; align-items: center; height: 38px; width: 160px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-2); overflow: hidden; }
.stepper button { display: grid; place-items: center; width: 38px; height: 100%; border: 0; background: transparent; color: var(--text-2); cursor: pointer; }
.stepper button:hover { background: var(--surface-2); color: var(--text); }
.field .stepper input { flex: 1; min-width: 0; height: 100%; border: 0; border-radius: 0; padding: 0; text-align: center; background: transparent; font-weight: 600; -moz-appearance: textfield; box-shadow: none; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper:focus-within { border-color: var(--accent-line); box-shadow: var(--focus); }
.nk-summary { display: flex; flex-direction: column; gap: 16px; padding: 22px; background: var(--bg-2); border-left: 1px solid var(--line-soft); }
.nk-summary-top { display: flex; align-items: center; justify-content: space-between; margin: -6px -8px -4px 0; }
.nk-summary-label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.nk-ticket { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line); }
.nk-ticket.free { border-color: rgba(62, 207, 142, 0.35); }
.nk-ticket .tag-paid .ic-gift, .nk-ticket .tag-free .ic-card { display: none; }
.nk-ticket-head { display: flex; align-items: center; justify-content: space-between; }
.nk-ticket-key { font-family: var(--mono); font-weight: 500; font-size: 13.5px; color: var(--text); padding: 10px 0; border-top: 1px dashed var(--line-strong); border-bottom: 1px dashed var(--line-strong); text-align: center; }
.nk-ticket-foot { display: flex; justify-content: space-between; font-weight: 600; }
.nk-facts { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.nk-facts div { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.nk-facts dt { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.nk-facts dd { margin: 0; text-align: right; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 170px; }
.nk-actions { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.filter-sec { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: var(--radius-lg); background: var(--bg-2); border: 1px solid var(--line-soft); }
.filter-sec h3 { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.filter-sec h3 .ic { color: var(--muted); width: 15px; height: 15px; }
.filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.filter-search input { height: 40px; width: 100%; padding: 0 14px 0 40px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-2); color: var(--text); outline: none; }
.filter-search input:focus { border-color: var(--accent-line); box-shadow: var(--focus); }
.opt-group.status-opts, .modal-filter .opt-group { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.modal-filter .opt span, .status-opts .opt span { width: 100%; padding: 0 8px; }
.opt-st-up span .ic, .opt-status .opt-active span .ic { color: var(--green); }
.opt-st-updating span .ic, .opt-status .opt-expired span .ic { color: var(--amber); }
.opt-st-down span .ic, .opt-status .opt-revoked span .ic { color: var(--red); }

/* Updates & status */
.channel-notes { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.channel-note { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border-radius: var(--radius); background: var(--amber-soft); color: #ffd98f; font-size: 13px; }
.channel-note .ic { color: var(--amber); width: 16px; height: 16px; }
.channel-note.is-set { background: var(--surface); border: 1px solid var(--line-soft); color: var(--text-2); }
.channel-note.is-set .ic { color: var(--muted); }
.channel-note strong { color: var(--text); font-weight: 500; }
.channel-hint { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.channel-hint a { color: var(--accent-hover); }
.status-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.status-row { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: var(--radius-lg); background: var(--bg-2); border: 1px solid var(--line-soft); }
.status-game { display: flex; align-items: center; gap: 12px; min-width: 0; }
.status-game img, .status-thumb { width: 38px; height: 38px; border-radius: var(--radius); object-fit: cover; flex-shrink: 0; }
.status-thumb { display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.status-game > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.status-game strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-game small { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.status-save { display: flex; gap: 8px; }
.status-save .input-ic { flex: 1; }
.status-save input { width: 100%; height: 32px; padding: 0 10px 0 34px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--text); outline: none; }
.status-save input:focus { border-color: var(--accent-line); box-shadow: var(--focus); }
.status-save .input-ic > .ic { left: 11px; width: 15px; height: 15px; }

/* Responsive ------------------------------------------------------------------------------ */

@media (max-width: 1280px) {
  .grid-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .mini-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); transform: translateX(-100%); visibility: hidden; transition: transform 0.2s var(--ease), visibility 0s linear 0.2s; }
  .app.nav-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-float); transition: transform 0.2s var(--ease); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(4, 6, 10, 0.6); opacity: 0; pointer-events: none; transition: opacity 0.2s var(--ease); }
  .app.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .sidebar-close, .nav-toggle { display: inline-grid !important; }
  .topbar { padding: 0 12px; gap: 8px; }
  .quick-search { flex: 1; width: auto; min-width: 0; }
  .quick-search kbd, .server-chip, .user-name, .user-chip > .ic { display: none; }
  .content { padding: 20px 16px 48px; }
  .field-row { flex-direction: column; }
  .field-row .field:not(.grow) { width: auto; }
  .search { width: 100%; }
  .filter-right { width: 100%; }
  .filter-right .search { flex: 1; }
  .nk { grid-template-columns: minmax(0, 1fr); overflow-y: auto; }
  .nk-main { overflow: visible; padding: 20px; }
  .nk-close-sm { display: inline-grid !important; }
  .nk-summary { border-left: 0; border-top: 1px solid var(--line-soft); }
  .nk-summary-top .icon-btn { display: none; }
  .type-cards { grid-template-columns: minmax(0, 1fr); }
  .stepper { width: 100%; }
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { min-width: 0; max-width: none; }
}
@media (max-width: 600px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
  .mini-strip, .mini-strip.mini-strip-3 { grid-template-columns: minmax(0, 1fr); }
  .page-title h1 { font-size: 21px; }
  .rows li { flex-wrap: wrap; row-gap: 6px; }
  .bar-col small { display: none; }
  .script-grid { grid-template-columns: minmax(0, 1fr); }
  .filter-grid { grid-template-columns: minmax(0, 1fr); }
  .opt-group.status-opts, .modal-filter .opt-group { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
