/* ==========================================================================
   Daberna Admin — layout & components
   Everything here reads only the tokens from theme.css.
   RTL-first: the document dir is "rtl", and physical properties are used for
   the few things that must stay on a side (left/right) rather than start/end.
   ========================================================================== */

/* ---------------------------------------------------------------- reset -- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

/* A very low-contrast aurora so the dark shell is not a flat void. Fixed and
   behind everything, so it never scrolls or eats pointer events. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(760px 420px at 88% -8%, rgba(99, 102, 241, 0.16), transparent 62%),
    radial-gradient(620px 380px at 4% 4%, rgba(139, 92, 246, 0.1), transparent 60%);
}

html[data-theme="light"] body::before {
  background:
    radial-gradient(760px 420px at 88% -8%, rgba(79, 70, 229, 0.1), transparent 62%),
    radial-gradient(620px 380px at 4% 4%, rgba(124, 58, 237, 0.07), transparent 60%);
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
}

/* Android Chrome flashes a translucent box on every tap and waits out the
   double-tap heuristic on controls that are not links. */
button,
a,
label,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button,
a,
label {
  touch-action: manipulation;
}

a {
  color: var(--brand-text);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

ul,
ol {
  list-style: none;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* index.html asks for viewport-fit=cover, so on a notched phone the layout owns
   the whole screen and these are the insets it has to stay clear of. They are 0
   on a desktop browser, so every calc() built on them collapses back to the
   value it had before. */
:root {
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
}


::selection {
  background: var(--brand-soft);
  color: var(--text);
}

/* scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

*::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--r-full);
  border: 2px solid transparent;
  background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--text-3);
  background-clip: content-box;
}

.mono {
  font-family: var(--mono);
  font-size: 0.92em;
  letter-spacing: -0.2px;
  direction: ltr;
  unicode-bidi: embed;
  /* Error codes and API base URLs are unbreakable LTR runs. Without this they
     push the panel wider than a phone screen. */
  overflow-wrap: anywhere;
}

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

/* ------------------------------------------------------------- app grid -- */

#app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 100%;
  height: 100vh;
  height: 100dvh;
  transition: grid-template-columns var(--t) var(--ease);
}

#app.rail {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}

/* The signed-out screen and the two boot states are mounted straight into #app,
   which is still the shell grid (--sidebar-w | 1fr). As plain grid items they
   land in the first column and get squeezed to 264px on the inline-start side:
   invisible on a phone, where the grid is a single column, but visibly cramped
   and shoved to one side on a desktop. Span both tracks instead.
   Only top-level screens match; a nested .center-state lives in a block or flex
   container, where grid-column is inert. */
#app > .auth,
#app > .center-state {
  grid-column: 1 / -1;
}

/* ------------------------------------------------------------- sidebar -- */

.sidebar {
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-elev);
  border-inline-start: 0;
  border-inline-end: 1px solid var(--line);
  /* Keeps the profile card off the gesture bar and the rail off the notch. */
  padding-right: var(--sar);
  padding-left: var(--sal);
  padding-bottom: var(--sab);
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  height: calc(var(--topbar-h) + var(--sat));
  padding: var(--sat) 18px 0;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line-soft);
  overflow: hidden;
}

.brand__mark {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.brand__mark svg {
  width: 19px;
  height: 19px;
  color: #fff;
}

.brand__text {
  min-width: 0;
  transition: opacity var(--t) var(--ease);
}

.brand__title {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.brand__sub {
  font-size: 10.5px;
  color: var(--text-3);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  white-space: nowrap;
}

#app.rail .brand__text,
#app.rail .nav__label,
#app.rail .side-foot__meta {
  opacity: 0;
  pointer-events: none;
}

/* The group heading is a label, not an icon, so fading it would just leave an
   invisible ~30px band between the sections. Collapse it instead. */
#app.rail .nav__group {
  height: 0;
  margin: 0;
  padding-block: 0;
  overflow: hidden;
  opacity: 1;
}

.nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 14px 10px 8px;
}

.nav__group {
  padding: 16px 10px 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
  transition: opacity var(--t) var(--ease);
}

.nav__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  margin-bottom: 2px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.nav__item:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.nav__item.is-active {
  background: var(--brand-soft);
  color: var(--brand-text);
  font-weight: 600;
}

.nav__item.is-active::before {
  content: "";
  position: absolute;
  inset-inline-start: -10px;
  top: 50%;
  translate: 0 -50%;
  width: 3px;
  height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
}

html[dir="rtl"] .nav__item.is-active::before {
  border-radius: 3px 0 0 3px;
}

.nav__icon {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  color: currentColor;
}

.nav__icon svg {
  width: 18px;
  height: 18px;
}

.nav__label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity var(--t) var(--ease);
}

.nav__badge {
  flex: 0 0 auto;
  min-width: 20px;
  height: 19px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border-radius: var(--r-full);
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.nav__badge:empty,
.nav__badge[data-empty="1"] {
  display: none;
}

.side-foot {
  flex: 0 0 auto;
  padding: 10px;
  border-top: 1px solid var(--line-soft);
}

.side-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  overflow: hidden;
}

.avatar {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: var(--r-full);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  overflow: hidden;
  user-select: none;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar--sm {
  width: 27px;
  height: 27px;
  font-size: 11px;
}

.avatar--lg {
  width: 46px;
  height: 46px;
  font-size: 17px;
}

.side-foot__meta {
  min-width: 0;
  transition: opacity var(--t) var(--ease);
}

.side-foot__name {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-foot__role {
  font-size: 10.5px;
  color: var(--text-3);
  white-space: nowrap;
}

/* rail: centre the icon when the sidebar collapses */
#app.rail .nav__item,
#app.rail .brand {
  justify-content: center;
  padding-inline: 0;
}

#app.rail .side-card {
  justify-content: center;
  padding-inline: 0;
}

.rail-toggle {
  display: none;
}

/* -------------------------------------------------------------- topbar -- */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.topbar {
  --bar-pad: 20px;
  position: relative;
  flex: 0 0 auto;
  height: calc(var(--topbar-h) + var(--sat));
  display: flex;
  align-items: center;
  gap: 12px;
  /* Physical left/right, not padding-inline: env() reports physical insets, and
     the two only line up while dir is ltr. */
  padding: var(--sat) var(--bar-pad) 0;
  padding-right: max(var(--bar-pad), var(--sar));
  padding-left: max(var(--bar-pad), var(--sal));
  background: color-mix(in srgb, var(--bg-elev) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

.topbar__title {
  min-width: 0;
  flex: 1 1 auto;
}

.topbar__title h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-3);
}

.crumbs span[aria-current] {
  color: var(--text-2);
}

.topbar__tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-width: 0;
}

.online-label {
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}

.clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.3;
  padding-inline-end: 6px;
  border-inline-end: 1px solid var(--line);
  margin-inline-end: 4px;
}

.clock__time {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.clock__date {
  font-size: 10px;
  color: var(--text-3);
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  transition: all var(--t-fast) var(--ease);
}

.icon-btn:hover {
  color: var(--text);
  background: var(--surface-3);
  border-color: var(--line-strong);
}

.icon-btn:active {
  scale: 0.94;
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

.icon-btn.is-spinning svg {
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    rotate: 360deg;
  }
}

.pulse {
  position: relative;
}

.pulse::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  border: 1px solid currentColor;
  opacity: 0;
  animation: pulse 2.4s var(--ease) infinite;
}

.pulse[data-state="up"] {
  color: var(--ok);
}

.pulse[data-state="down"] {
  color: var(--danger);
}

.pulse[data-state="idle"] {
  color: var(--text-3);
}

.pulse[data-state="idle"]::after {
  display: none;
}

@keyframes pulse {
  0% {
    opacity: 0.7;
    scale: 1;
  }
  70%,
  100% {
    opacity: 0;
    scale: 1.5;
  }
}

/* -------------------------------------------------------------- content -- */

.content {
  --pad: 20px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--pad) var(--pad) calc(var(--pad) + var(--sab));
  scroll-behavior: smooth;
  overscroll-behavior-y: contain;
}

.page {
  max-width: 1500px;
  margin: 0 auto;
  animation: page-in var(--t-slow) var(--ease-out);
}

@keyframes page-in {
  from {
    opacity: 0;
    translate: 0 8px;
  }
}

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.page-head__text {
  flex: 1 1 260px;
  min-width: 0;
}

.page-head h2 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.page-head p {
  font-size: 12.5px;
  color: var(--text-3);
  margin-top: 2px;
}

.page-head__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ----------------------------------------------------------------- card -- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden;
}

.card__head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.card__head h3 {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card__head h3 svg {
  width: 16px;
  height: 16px;
  color: var(--text-3);
}

.card__head p {
  font-size: 11.5px;
  color: var(--text-3);
  width: 100%;
  margin-top: -4px;
}

.card__tools {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card__body {
  padding: 16px;
}

.card__body--flush {
  padding: 0;
}

.card__foot {
  padding: 12px 16px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text-3);
}

/* ------------------------------------------------------------- buttons -- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 15px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: all var(--t-fast) var(--ease);
  user-select: none;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.btn:disabled,
.btn[aria-busy="true"] {
  opacity: 0.55;
  pointer-events: none;
}

.btn--primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 3px 12px rgba(99, 102, 241, 0.32);
}

.btn--primary:hover {
  filter: brightness(1.09);
  box-shadow: 0 5px 18px rgba(99, 102, 241, 0.42);
}

.btn--ghost {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text-2);
}

.btn--ghost:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--line-strong);
}

.btn--soft {
  background: var(--brand-soft);
  color: var(--brand-text);
}

.btn--soft:hover {
  background: var(--brand-soft);
  filter: brightness(1.25);
}

.btn--ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.btn--ok:hover {
  filter: brightness(1.3);
}

.btn--warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.btn--warn:hover {
  filter: brightness(1.3);
}

.btn--danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn--danger:hover {
  filter: brightness(1.3);
}

.btn--sm {
  height: 31px;
  padding: 0 11px;
  font-size: 12px;
  border-radius: var(--r-xs);
  gap: 5px;
}

.btn--sm svg {
  width: 14px;
  height: 14px;
}

.btn--icon {
  width: 31px;
  padding: 0;
}

.btn--block {
  width: 100%;
}

.btn--lg {
  height: 46px;
  padding: 0 22px;
  font-size: 14.5px;
}

.btn-group {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Segmented control */
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}

.seg button {
  padding: 5px 12px;
  border-radius: var(--r-xs);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  transition: all var(--t-fast) var(--ease);
}

.seg button:hover {
  color: var(--text);
}

.seg button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--sh-1);
}

/* --------------------------------------------------------------- forms -- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 5px;
}

.field__req {
  color: var(--danger);
}

.field__hint {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.field__err {
  font-size: 11.5px;
  color: var(--danger);
  display: none;
}

.field.has-err .field__err {
  display: block;
}

.field.has-err .input,
.field.has-err .select,
.field.has-err .textarea {
  border-color: var(--danger);
}

.input,
.select,
.textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 13.5px;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease);
}

html[dir="rtl"] .input,
html[dir="rtl"] .select,
html[dir="rtl"] .textarea {
  text-align: right;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--line-strong);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.textarea {
  height: auto;
  min-height: 96px;
  padding: 10px 12px;
  line-height: 1.8;
  resize: vertical;
}

.select {
  appearance: none;
  padding-inline-end: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236f7b93' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 15px;
  background-position: left 12px center;
  cursor: pointer;
}

html[dir="rtl"] .select {
  background-position: left 12px center;
}

.input--num {
  font-variant-numeric: tabular-nums;
  direction: ltr;
  text-align: right;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.form-grid--2 {
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
}

.form-grid--3 {
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
}

/* switch */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch__track {
  position: relative;
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
  border-radius: var(--r-full);
  background: var(--surface-3);
  border: 1px solid var(--line);
  transition: all var(--t) var(--ease);
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-3);
  transition: all var(--t) var(--ease-out);
}

.switch input:checked + .switch__track {
  background: var(--brand);
  border-color: var(--brand);
}

.switch input:checked + .switch__track::after {
  inset-inline-start: 20px;
  background: #fff;
}

.switch input:focus-visible + .switch__track {
  box-shadow: var(--ring);
}

.switch__text {
  font-size: 13px;
  color: var(--text-2);
}

.switch input:disabled + .switch__track {
  opacity: 0.5;
  cursor: not-allowed;
}

/* A titled switch for a single boolean setting: the switch is the whole
   control, not one field inside a form, so it carries its own title and
   description instead of a <label> plus a hint. */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.toggle-row--warn {
  border-color: color-mix(in srgb, var(--warn) 42%, var(--line));
  background: color-mix(in srgb, var(--warn) 7%, var(--surface-2));
}

.toggle-row--danger {
  border-color: color-mix(in srgb, var(--danger) 42%, var(--line));
  background: color-mix(in srgb, var(--danger) 7%, var(--surface-2));
}

.toggle-row__text {
  min-width: 0;
}

.toggle-row__title {
  font-size: 13.5px;
  font-weight: 600;
}

.toggle-row__desc {
  margin-top: 3px;
  font-size: 11.5px;
  line-height: 1.75;
  color: var(--text-3);
}

@media (max-width: 520px) {
  .toggle-row {
    flex-direction: column;
    align-items: stretch;
  }

  .toggle-row .switch {
    align-self: flex-start;
  }
}

/* Resend-countdown line in the OTP step of the login screen. */
.cooldown-line {
  min-height: 18px;
  margin-top: 10px;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* checkbox row (used for the payment gateway option matrix) */
.check {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
}

.check input {
  appearance: none;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 1.5px solid var(--line-strong);
  border-radius: 5px;
  background: var(--bg-elev);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}

.check input:checked {
  background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center/13px no-repeat;
  border-color: var(--brand);
}

.check input:focus-visible {
  box-shadow: var(--ring);
}

.check__text {
  font-size: 13px;
  color: var(--text-2);
}

/* ------------------------------------------------------------- search -- */

.search {
  position: relative;
  flex: 1 1 220px;
  max-width: 380px;
  min-width: 0;
}

.search svg {
  position: absolute;
  top: 50%;
  inset-inline-start: 11px;
  translate: 0 -50%;
  width: 16px;
  height: 16px;
  color: var(--text-3);
  pointer-events: none;
}

.search .input {
  padding-inline-start: 35px;
}

.search__clear {
  position: absolute;
  top: 50%;
  inset-inline-end: 8px;
  translate: 0 -50%;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--text-3);
  background: var(--surface-3);
}

.search__clear:hover {
  color: var(--text);
}

.search__clear svg {
  position: static;
  translate: none;
  width: 12px;
  height: 12px;
}

/* --------------------------------------------------------------- table -- */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  white-space: nowrap;
}

.table th,
.table td {
  padding: 11px 14px;
  text-align: right;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  font-size: 11.5px;
  font-weight: 650;
  color: var(--text-3);
  letter-spacing: 0.2px;
  user-select: none;
  border-bottom: 1px solid var(--line);
}

.table thead th.is-sortable {
  cursor: pointer;
}

.table thead th.is-sortable:hover {
  color: var(--text);
}

.table thead th .sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.table thead th .sort svg {
  width: 12px;
  height: 12px;
  opacity: 0.35;
  transition: opacity var(--t-fast);
}

.table thead th.is-sorted .sort {
  color: var(--brand-text);
}

.table thead th.is-sorted .sort svg {
  opacity: 1;
}

.table tbody tr {
  transition: background var(--t-fast) var(--ease);
}

.table tbody tr:hover {
  background: var(--surface-2);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table td.wrap {
  white-space: normal;
  min-width: 200px;
  max-width: 420px;
}

.table .row-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  justify-content: flex-end;
}

.table__empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--text-3);
}

.table__empty svg {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  opacity: 0.3;
}

.table__empty h4 {
  font-size: 14px;
  color: var(--text-2);
  font-weight: 600;
  margin-bottom: 4px;
}

.table__empty p {
  font-size: 12px;
}

/* ------------------------------------------------------------- badges -- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--text-2);
  border: 1px solid transparent;
}

.badge svg {
  width: 12px;
  height: 12px;
}

.badge--ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge--warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge--danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge--info {
  background: var(--info-soft);
  color: var(--info);
}

.badge--brand {
  background: var(--brand-soft);
  color: var(--brand-text);
}

.badge--purple {
  background: var(--purple-soft);
  color: var(--purple);
}

.badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

/* tags for user flags */
.tags {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 19px;
  padding: 0 7px;
  border-radius: var(--r-xs);
  font-size: 10.5px;
  font-weight: 700;
  background: var(--surface-3);
  color: var(--text-3);
}

.tag--admin {
  background: var(--brand-soft);
  color: var(--brand-text);
}

.tag--vip {
  background: var(--purple-soft);
  color: var(--purple);
}

.tag--ban {
  background: var(--danger-soft);
  color: var(--danger);
}

.tag--tban {
  background: var(--warn-soft);
  color: var(--warn);
}

/* ------------------------------------------------------------- skeleton -- */

.sk {
  border-radius: var(--r-xs);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.sk-row {
  height: 13px;
  margin: 14px;
}

.sk-page {
  display: grid;
  gap: 16px;
}

/* ------------------------------------------------------------- spinner -- */

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: 0 0 auto;
}

.spinner--lg {
  width: 30px;
  height: 30px;
  border-width: 3px;
}

.center-state {
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 54px 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

/* place-items:center sizes grid items to fit-content, so an unbreakable string
   would size past the viewport instead of wrapping. */
.center-state > * {
  max-width: 100%;
}

/* ----------------------------------------------------------- stat grid -- */

.stats {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(min(215px, 100%), 1fr));
  margin-bottom: 18px;
}

.stat {
  position: relative;
  padding: 15px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden;
  transition: border-color var(--t) var(--ease), transform var(--t) var(--ease);
}

.stat:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.stat::after {
  content: "";
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  width: 3px;
  height: 100%;
  background: var(--accent, var(--brand));
  opacity: 0.85;
}

.stat__head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 9px;
}

.stat__icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: var(--accent-soft, var(--brand-soft));
  color: var(--accent, var(--brand));
  flex: 0 0 auto;
}

.stat__icon svg {
  width: 17px;
  height: 17px;
}

.stat__label {
  font-size: 11.5px;
  color: var(--text-3);
  font-weight: 600;
}

.stat__value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.6px;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

.stat__unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  margin-inline-start: 3px;
}

.stat__meta {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.stat--ok {
  --accent: var(--ok);
  --accent-soft: var(--ok-soft);
}

.stat--warn {
  --accent: var(--warn);
  --accent-soft: var(--warn-soft);
}

.stat--danger {
  --accent: var(--danger);
  --accent-soft: var(--danger-soft);
}

.stat--info {
  --accent: var(--info);
  --accent-soft: var(--info-soft);
}

.stat--purple {
  --accent: var(--purple);
  --accent-soft: var(--purple-soft);
}

/* ---------------------------------------------------------- two columns -- */

.split {
  display: grid;
  gap: 16px;
  grid-template-columns: 1.55fr 1fr;
  align-items: start;
}

.stack {
  display: grid;
  gap: 16px;
}

/* -------------------------------------------------------------- charts -- */

.chart {
  width: 100%;
  height: 190px;
  display: block;
  overflow: visible;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  font-size: 11.5px;
  color: var(--text-2);
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.chart-legend i {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: currentColor;
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.donut {
  width: 132px;
  height: 132px;
  flex: 0 0 auto;
}

.donut__center {
  font-size: 17px;
  font-weight: 700;
  fill: var(--text);
}

.donut__sub {
  font-size: 9px;
  fill: var(--text-3);
}

/* -------------------------------------------------------------- modal -- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: calc(18px + var(--sat)) calc(18px + var(--sar)) calc(18px + var(--sab))
    calc(18px + var(--sal));
  animation: fade var(--t) var(--ease);
  overflow-y: auto;
  overscroll-behavior: contain;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.modal {
  width: 100%;
  max-width: 520px;
  max-height: calc(100dvh - 36px - var(--sat) - var(--sab));
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  animation: pop var(--t-slow) var(--ease-out);
  overflow: hidden;
}

.modal--wide {
  max-width: 780px;
}

.modal--slim {
  max-width: 420px;
}

@keyframes pop {
  from {
    opacity: 0;
    scale: 0.96;
    translate: 0 10px;
  }
}

.modal__head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
  flex: 0 0 auto;
}

.modal__head h3 {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.modal__head p {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.modal__icon {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: var(--brand-soft);
  color: var(--brand-text);
}

.modal__icon svg {
  width: 19px;
  height: 19px;
}

.modal__icon--danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.modal__icon--warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.modal__icon--ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.modal__close {
  margin-inline-start: auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: var(--r-xs);
  color: var(--text-3);
  flex: 0 0 auto;
}

.modal__close:hover {
  background: var(--surface-2);
  color: var(--text);
}

.modal__body {
  padding: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1 1 auto;
}

.modal__foot {
  display: flex;
  align-items: center;
  gap: 9px;
  justify-content: flex-end;
  padding: 14px 18px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.modal__foot .spacer {
  margin-inline-end: auto;
}

/* -------------------------------------------------------------- drawer -- */

.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--overlay);
  backdrop-filter: blur(3px);
  animation: fade var(--t) var(--ease);
}

.drawer {
  position: fixed;
  top: 0;
  inset-inline-end: 0;
  z-index: 101;
  width: min(560px, 100%);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border-inline-start: 1px solid var(--line);
  box-shadow: var(--sh-3);
  animation: slide-in var(--t-slow) var(--ease-out);
}

@keyframes slide-in {
  from {
    translate: 100% 0;
  }
}

html[dir="rtl"] .drawer {
  animation-name: slide-in-rtl;
}

@keyframes slide-in-rtl {
  from {
    translate: -100% 0;
  }
}

.drawer__head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(15px + var(--sat)) calc(18px + var(--sar)) 15px calc(18px + var(--sal));
  border-bottom: 1px solid var(--line-soft);
}

.drawer__head h3 {
  font-size: 15px;
  font-weight: 700;
}

.drawer__head p {
  font-size: 11.5px;
  color: var(--text-3);
}

.drawer__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px;
}

.drawer__foot {
  flex: 0 0 auto;
  padding: 14px 18px calc(14px + var(--sab));
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
}

/* ------------------------------------------------------------- toasts -- */

.toasts {
  position: fixed;
  bottom: calc(18px + var(--sab));
  /* Physical right = the inline-start edge under dir=rtl, and env() is
     physical too, so this pair lines up in either direction. */
  right: calc(18px + var(--sar));
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
  max-width: min(400px, calc(100vw - 36px - var(--sal) - var(--sar)));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  box-shadow: var(--sh-3);
  pointer-events: auto;
  animation: toast-in var(--t-slow) var(--ease-out);
  border-inline-start: 3px solid var(--brand);
}

@keyframes toast-in {
  from {
    opacity: 0;
    translate: -14px 0;
  }
}

.toast.is-out {
  animation: toast-out var(--t) var(--ease) forwards;
}

@keyframes toast-out {
  to {
    opacity: 0;
    translate: -14px 0;
    scale: 0.97;
  }
}

.toast--ok {
  border-inline-start-color: var(--ok);
}

.toast--danger {
  border-inline-start-color: var(--danger);
}

.toast--warn {
  border-inline-start-color: var(--warn);
}

.toast__icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  color: var(--brand);
}

.toast--ok .toast__icon {
  color: var(--ok);
}

.toast--danger .toast__icon {
  color: var(--danger);
}

.toast--warn .toast__icon {
  color: var(--warn);
}

.toast__text {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12.5px;
  line-height: 1.65;
}

.toast__title {
  font-weight: 650;
  margin-bottom: 1px;
}

.toast__code {
  display: inline-block;
  max-width: 100%;
  margin-top: 4px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-3);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-3);
  direction: ltr;
  overflow-wrap: anywhere;
}

.toast__close {
  flex: 0 0 auto;
  color: var(--text-3);
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
}

.toast__close:hover {
  color: var(--text);
}

.toast__close svg {
  width: 13px;
  height: 13px;
}

/* ------------------------------------------------------------ details -- */

.dl {
  display: grid;
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  overflow: hidden;
}

.dl > div {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  background: var(--surface-2);
}

.dl dt {
  flex: 0 0 auto;
  min-width: 118px;
  font-size: 12px;
  color: var(--text-3);
}

.dl dd {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  text-align: left;
  word-break: break-word;
}

html[dir="rtl"] .dl dd {
  text-align: right;
}

/* ticket thread */
.thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
}

.msg--admin {
  align-self: flex-start;
  background: var(--brand-soft);
  border-color: var(--brand-line);
}

.msg--user {
  align-self: flex-end;
}

.msg__head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
  font-size: 11px;
  color: var(--text-3);
}

.msg__who {
  font-weight: 650;
  color: var(--text-2);
}

.msg__body {
  font-size: 13.5px;
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ------------------------------------------------------------- notices -- */

.note {
  display: flex;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--r-md);
  font-size: 12.5px;
  line-height: 1.75;
  background: var(--info-soft);
  color: var(--text-2);
  border: 1px solid transparent;
}

.note > div {
  min-width: 0;
  overflow-wrap: anywhere;
}

.note svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  color: var(--info);
  margin-top: 2px;
}

.note--warn {
  background: var(--warn-soft);
}

.note--warn svg {
  color: var(--warn);
}

.note--danger {
  background: var(--danger-soft);
}

.note--danger svg {
  color: var(--danger);
}

.note--ok {
  background: var(--ok-soft);
}

.note--ok svg {
  color: var(--ok);
}

.note b {
  color: var(--text);
}

/* --------------------------------------------------------- pagination -- */

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
}

.pager__info {
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.pager__pages {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-inline-start: auto;
}

.pager__btn {
  min-width: 31px;
  height: 31px;
  padding: 0 8px;
  display: grid;
  place-items: center;
  border-radius: var(--r-xs);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  transition: all var(--t-fast) var(--ease);
}

.pager__btn:hover:not(:disabled) {
  border-color: var(--brand-line);
  color: var(--text);
}

.pager__btn.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.pager__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pager__btn svg {
  width: 15px;
  height: 15px;
}

.pager__gap {
  color: var(--text-3);
  padding: 0 2px;
  font-size: 12px;
}

.pager__size {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
}

.pager__size .select {
  width: auto;
  height: 31px;
  padding-block: 0;
  font-size: 12px;
}

/* ------------------------------------------------------------- toolbar -- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
}

.toolbar__end {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.result-count {
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* --------------------------------------------------------------- login -- */

.auth {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  /* The real problem is the *row*, not the item: a lone auto row stretches to
     fill the container, and a centred item taller than the container then
     overflows equally top and bottom, so the top half scrolls out of reach.
     `safe` pins the overflow to the start edge; browsers without it keep the
     old centred behaviour, which is no worse. */
  align-content: safe center;
  padding: calc(22px + var(--sat)) calc(22px + var(--sar)) calc(22px + var(--sab))
    calc(22px + var(--sal));
  overflow-y: auto;
}

.auth__box {
  width: 100%;
  max-width: 412px;
}

.auth__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 13px;
  margin-bottom: 22px;
  text-align: center;
}

.auth__mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 10px 34px rgba(99, 102, 241, 0.42);
}

.auth__mark svg {
  width: 29px;
  height: 29px;
  color: #fff;
}

.auth__brand h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.7px;
}

.auth__brand p {
  font-size: 12.5px;
  color: var(--text-3);
}

.auth__card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  padding: 24px;
}

.auth__foot {
  text-align: center;
  margin-top: 18px;
  font-size: 11.5px;
  color: var(--text-3);
  line-height: 1.9;
}

/* OTP inputs */
.otp {
  display: flex;
  gap: 8px;
  direction: ltr;
  justify-content: center;
}

.otp__box {
  width: 100%;
  max-width: 52px;
  aspect-ratio: 3 / 4;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  font-family: var(--mono);
  padding: 0;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--text);
  transition: all var(--t-fast) var(--ease);
}

.otp__box:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
  scale: 1.05;
}

.otp__box:not(:placeholder-shown) {
  border-color: var(--brand-line);
  background: var(--brand-soft);
}

/* ------------------------------------------------------------ popover -- */

.popover {
  position: fixed;
  z-index: 150;
  width: min(310px, calc(100vw - 24px - var(--sal) - var(--sar)));
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--sh-3);
  overflow: hidden;
  animation: pop var(--t) var(--ease-out);
}

.popover__head {
  padding: 9px 13px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-soft);
}

.popover__body {
  padding: 5px;
}

.popover__item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 9px;
  border-radius: var(--r-xs);
  text-align: right;
  color: var(--text-2);
  font-size: 12.5px;
  transition: background var(--t-fast) var(--ease);
}

.popover__item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.popover__icon {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  color: var(--text-3);
}

.popover__icon svg {
  width: 15px;
  height: 15px;
}

.popover__label {
  flex: 1 1 auto;
  min-width: 0;
}

/* --------------------------------------------------------------- misc -- */

.meter {
  height: 6px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  overflow: hidden;
}

.meter__fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  transition: width var(--t-slow) var(--ease);
}

.kbd {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 5px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-2);
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--text-3);
  font-size: 11.5px;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--line);
}

/* min() keeps the track from outgrowing its container: on a 320px phone a plain
   280px min would force a column wider than the card, and .content clips
   overflow-x, so the surplus would be silently cut off. */
.grid-auto {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
}

.flex {
  display: flex;
  align-items: center;
  gap: 8px;
}

.flex-wrap {
  flex-wrap: wrap;
}

.gap-4 {
  gap: 4px;
}

.gap-12 {
  gap: 12px;
}

.mt-8 {
  margin-top: 8px;
}

.mt-12 {
  margin-top: 12px;
}

.mt-16 {
  margin-top: 16px;
}

.mb-12 {
  margin-bottom: 12px;
}

.mb-16 {
  margin-bottom: 16px;
}

.muted {
  color: var(--text-3);
}

.small {
  font-size: 12px;
}

.xsmall {
  font-size: 11px;
}

.strong {
  font-weight: 650;
}

.center {
  text-align: center;
}

.nowrap {
  white-space: nowrap;
}

.ok-text {
  color: var(--ok);
}

.danger-text {
  color: var(--danger);
}

.warn-text {
  color: var(--warn);
}

.brand-text {
  color: var(--brand-text);
}

.backdrop-toggle {
  display: none;
}

/* ---------------------------------------------------------- responsive -- */

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

@media (max-width: 980px) {
  .stats {
    grid-template-columns: repeat(auto-fit, minmax(min(168px, 100%), 1fr));
  }

  .stat__value {
    font-size: 19px;
  }
}

@media (max-width: 860px) {
  /* Sidebar becomes an overlay drawer driven by .nav-open on <body>. */
  #app,
  #app.rail {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-end: 0;
    z-index: 90;
    width: min(280px, 84vw);
    translate: 100% 0;
    transition: translate var(--t) var(--ease-out);
    box-shadow: var(--sh-3);
  }

  /* The inline-end edge is the *physical left* edge under dir=rtl, so the closed
     drawer has to be parked off-screen to the left. Translating it the other way
     parks it over the page, which leaves the sidebar permanently half-visible on
     every phone — and above the backdrop, so it also eats the taps. */
  html[dir="rtl"] .sidebar {
    translate: -100% 0;
  }

  body.nav-open .sidebar {
    translate: 0 0;
  }

  /* In the overlay the sidebar always shows labels, even if the desktop rail
     preference is collapsed. */
  #app.rail .brand__text,
  #app.rail .nav__label,
  #app.rail .side-foot__meta {
    opacity: 1;
    pointer-events: auto;
  }

  #app.rail .nav__group {
    height: auto;
    margin: 0;
    padding: 16px 10px 7px;
    overflow: visible;
  }

  #app.rail .nav__item,
  #app.rail .brand,
  #app.rail .side-card {
    justify-content: flex-start;
    padding-inline: 11px;
  }

  .backdrop-toggle {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 89;
    background: var(--overlay);
    backdrop-filter: blur(2px);
    animation: fade var(--t) var(--ease);
  }

  .content {
    --pad: 15px;
  }

  .topbar {
    --bar-pad: 13px;
    gap: 9px;
  }

  .clock {
    display: none;
  }

  .rail-toggle {
    display: grid;
  }

  /* The rail cannot be collapsed when it is an overlay drawer. */
  .side-foot__collapse {
    display: none;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 13.5px;
  }

  .content {
    --pad: 12px;
  }

  /* The status sentence is a full line wide on a phone ("سرور در دسترس نیست")
     and the tools row cannot shrink, so it would push the page title out of the
     bar. The dot keeps carrying the state, its title/aria-label has the text. */
  .online-label {
    display: none;
  }

  .topbar__tools {
    gap: 6px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stat {
    padding: 12px 13px;
  }

  .stat__value {
    font-size: 17px;
  }

  .stat__icon {
    width: 28px;
    height: 28px;
  }

  .stat__head {
    margin-bottom: 6px;
  }

  .page-head h2 {
    font-size: 17px;
  }

  .modal,
  .modal--wide {
    max-height: calc(100dvh - 24px - var(--sat) - var(--sab));
  }

  .scrim {
    padding: calc(12px + var(--sat)) calc(12px + var(--sar)) calc(12px + var(--sab))
      calc(12px + var(--sal));
  }

  .modal__body,
  .modal__head,
  .modal__foot {
    padding-inline: 15px;
  }

  .modal__foot .btn {
    flex: 1 1 auto;
  }

  .modal__foot .spacer {
    display: none;
  }

  .toasts {
    right: calc(12px + var(--sar));
    left: calc(12px + var(--sal));
    bottom: calc(12px + var(--sab));
    max-width: none;
  }

  .drawer {
    width: 100%;
  }

  .dl dt {
    min-width: 96px;
    font-size: 11.5px;
  }

  .pager {
    justify-content: center;
  }

  .pager__pages {
    margin-inline-start: 0;
    width: 100%;
    justify-content: center;
  }

  .search {
    max-width: none;
    flex-basis: 100%;
  }

  .auth__card {
    padding: 19px;
  }

  .otp__box {
    max-width: 44px;
    font-size: 19px;
  }
}

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

  /* A 118px label plus a 320px screen leaves the value almost nothing, and the
     value is the part worth reading. */
  .dl dt {
    min-width: 84px;
  }
}

/* ------------------------------------------------------------- motion -- */

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

@media print {
  .sidebar,
  .topbar,
  .toasts,
  .toolbar,
  .pager {
    display: none !important;
  }

  #app {
    grid-template-columns: 1fr;
  }

  body {
    overflow: visible;
  }
}
