
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 40px;
  padding: 0 var(--s-4);
  border-radius: var(--r-md);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}
.btn svg {
  width: 17px;
  height: 17px;
  stroke-width: 2;
  flex-shrink: 0;
}
.btn:active:not(:disabled) {
  transform: scale(0.975);
}
.btn:disabled,
.btn.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn--primary {
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: 0 4px 14px var(--primary-ring);
}
.btn--primary:hover {
  background: var(--primary-hover);
}

.btn--ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-2);
}
.btn--ghost:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn--soft {
  background: var(--primary-soft);
  color: var(--primary);
}
.btn--soft:hover {
  background: color-mix(in srgb, var(--primary) 22%, transparent);
}

.btn--danger {
  background: var(--danger);
  color: #fff;
}
.btn--danger:hover {
  filter: brightness(1.08);
}

.btn--danger-soft {
  background: var(--danger-soft);
  color: var(--danger);
}
.btn--danger-soft:hover {
  background: color-mix(in srgb, var(--danger) 22%, transparent);
}

.btn--success {
  background: var(--success);
  color: #fff;
}
.btn--success:hover {
  filter: brightness(1.08);
}

.btn--plain {
  color: var(--text-2);
}
.btn--plain:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn--sm {
  min-height: 32px;
  padding: 0 var(--s-3);
  font-size: 12.5px;
  border-radius: var(--r-sm);
}
.btn--sm svg {
  width: 15px;
  height: 15px;
}

.btn--lg {
  min-height: 46px;
  padding: 0 var(--s-6);
  font-size: 14.5px;
}

.btn--icon {
  padding: 0;
  width: 40px;
}
.btn--icon.btn--sm {
  width: 32px;
}

.btn--block {
  width: 100%;
}

.btn.is-loading {
  color: transparent !important;
  position: relative;
  pointer-events: none;
}
.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 50%;
  border-inline-start-color: transparent;
  animation: spin 0.7s linear infinite;
  color: var(--on-primary);
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.btn-group {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.btn-group button {
  min-height: 32px;
  padding: 0 var(--s-3);
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-3);
  transition: all var(--dur-fast) var(--ease);
}
.btn-group button:hover {
  color: var(--text);
}
.btn-group button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--sh-1);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden;
}

/* Popovers (dropdowns, custom selects, date pickers) have to escape the card's
   overflow clip and paint above the cards that follow them — but still stay
   under the sticky topbar, whose own dropdowns must win. */
.card--pop {
  overflow: visible;
  position: relative;
  z-index: var(--z-pop);
}

.card:has(.dd.is-open),
.card:has(.xsel.is-open),
.card:has(.jdp.is-open),
.card:has(.mnav.is-open) {
  overflow: visible;
  position: relative;
  z-index: var(--z-pop);
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  flex-wrap: wrap;
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border-soft);
}
.card__head h3 {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: 15px;
}
.card__head h3 svg {
  width: 18px;
  height: 18px;
  color: var(--text-3);
}
.card__head p {
  font-size: 12.5px;
  color: var(--text-3);
  width: 100%;
  margin-top: -2px;
}
.card__head--split {
  flex-wrap: nowrap;
}
.card__head--split .card__titles {
  min-width: 0;
}
.card__head--split .card__titles p {
  width: auto;
}
.card__head--split > :last-child {
  flex-shrink: 0;
}
@media (max-width: 560px) {
  .card__head--split {
    flex-wrap: wrap;
  }
}
.card__body {
  padding: var(--s-4) var(--s-5);
}
.card__body--flush {
  padding: 0;
}
.card__foot {
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--border-soft);
  background: var(--surface-2);
}

.stat {
  position: relative;
  padding: var(--s-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--sh-1);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
.stat::before {
  content: '';
  position: absolute;
  inset-block-start: 0;
  inset-inline-end: 0;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  transform: translate(-38%, -52%);
  background: var(--accent-soft, var(--primary-soft));
  opacity: 0.55;
  pointer-events: none;
}
.stat:hover {
  border-color: var(--border-strong);
  box-shadow: var(--sh-2);
  transform: translateY(-2px);
}
.stat::after {
  content: '';
  position: absolute;
  inset-block-start: 0;
  inset-inline: 0;
  height: 3px;
  background: var(--accent, var(--primary));
}
.stat > * {
  position: relative;
}

.stat__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-2);
}
.stat__label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
}
.stat__icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  background: var(--accent-soft, var(--primary-soft));
  color: var(--accent, var(--primary));
  flex-shrink: 0;
}
.stat__icon svg {
  width: 19px;
  height: 19px;
  stroke-width: 1.9;
}
.stat__value {
  font-size: 25px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat__unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  margin-inline-start: 4px;
}
.stat__foot {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid var(--border-soft);
  font-size: 11.5px;
  color: var(--text-3);
}

.trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.trend svg {
  width: 13px;
  height: 13px;
  stroke-width: 2.4;
}
.trend--up {
  background: var(--success-soft);
  color: var(--success);
}
.trend--down {
  background: var(--danger-soft);
  color: var(--danger);
}
.trend--flat {
  background: var(--surface-3);
  color: var(--text-3);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.7;
}
.badge svg {
  width: 12px;
  height: 12px;
  stroke-width: 2.4;
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.badge--nodot::before {
  display: none;
}
.badge--success {
  background: var(--success-soft);
  color: var(--success);
}
.badge--danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.badge--warning {
  background: var(--warning-soft);
  color: var(--warning);
}
.badge--info {
  background: var(--info-soft);
  color: var(--info);
}
.badge--primary {
  background: var(--primary-soft);
  color: var(--primary);
}
.badge--violet {
  background: var(--violet-soft);
  color: var(--violet);
}
.badge--muted {
  background: var(--surface-3);
  color: var(--text-3);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 var(--s-3);
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.chip.is-active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}
.chip svg {
  width: 14px;
  height: 14px;
}
.chip__x {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface-3);
}
.chip__x:hover {
  background: var(--danger);
  color: #fff;
}

.avatar {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(140deg, var(--primary), var(--violet));
  user-select: none;
}
.avatar--sm {
  width: 30px;
  height: 30px;
  font-size: 11.5px;
}
.avatar--lg {
  width: 64px;
  height: 64px;
  font-size: 22px;
}
.avatar--xl {
  width: 84px;
  height: 84px;
  font-size: 28px;
}

.avatar-cell {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-width: 0;
}
.avatar-cell__meta {
  display: flex;
  flex-direction: column;
  line-height: 1.4;
  min-width: 0;
}
.avatar-cell__name {
  font-size: 13.5px;
  font-weight: 600;
}
.avatar-cell .avatar {
  background: var(--primary-soft);
  color: var(--primary-deep);
}
.avatar-cell .avatar svg {
  width: 15px;
  height: 15px;
}
.avatar-cell__sub {
  font-size: 11.5px;
  color: var(--text-3);
  direction: ltr;
  text-align: right;
}

/* Bare id inside a table cell: no leading decoration, so it starts exactly
   where its column header starts. */
.ident {
  font-size: 13.5px;
  font-weight: 600;
}
a.ident:hover {
  color: var(--primary-deep);
  text-decoration: underline;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  min-width: 720px;
  font-size: 13.5px;
}
.table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: var(--s-3) var(--s-4);
  text-align: start;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table thead th.is-sortable {
  cursor: pointer;
  user-select: none;
}
.table thead th.is-sortable:hover {
  color: var(--text);
}
.table thead th .th-in {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.table thead th svg {
  width: 13px;
  height: 13px;
  opacity: 0.4;
}
.table thead th[aria-sort] svg {
  opacity: 1;
  color: var(--primary);
}

.table tbody td {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.table tbody tr {
  transition: background var(--dur-fast) var(--ease);
}
.table tbody tr:hover {
  background: var(--surface-2);
}
.table tbody tr:last-child td {
  border-bottom: 0;
}
.table td.num,
.table th.num {
  font-variant-numeric: tabular-nums;
}

/* .mono forces direction: ltr so a latin id or a TRX code is not reordered by
   bidi. On a block box — a td, or a span that flex made into an item — that
   also flips `text-align: start` to the LEFT edge, so the value drifted to the
   far side of its own column while the header stayed right-aligned. Pin the
   text back to the column's start edge. Inline .mono is unaffected: text-align
   only applies to block containers. */
.table .mono,
.table .col > .mono {
  text-align: right;
}
.table .col-actions {
  width: 1%;
  white-space: nowrap;
}
.table--compact tbody td {
  padding: var(--s-2) var(--s-4);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* The dimming is scoped to table rows, where tr:hover brings it back. It used
   to apply everywhere, which broke the card list twice over: those actions sat
   permanently at 55% with no row to hover, and an opacity below 1 creates a
   stacking context — so the tooltip's z-index could not escape it, and the
   tooltip itself was painted at 55% with the card showing through. */
tr .row-actions {
  opacity: 0.55;
  transition: opacity var(--dur-fast) var(--ease);
}
tr:hover .row-actions,
tr:focus-within .row-actions {
  opacity: 1;
}
.row-actions button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--text-3);
  transition: all var(--dur-fast) var(--ease);
}
.row-actions button svg {
  width: 16px;
  height: 16px;
}
.row-actions button:hover {
  background: var(--surface-3);
  color: var(--text);
}
.row-actions button.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--border-soft);
}
.pagination__info {
  font-size: 12.5px;
  color: var(--text-3);
}
.pagination__pages {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pagination__pages button {
  min-width: 34px;
  height: 34px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  border: 1px solid transparent;
  font-variant-numeric: tabular-nums;
  transition: all var(--dur-fast) var(--ease);
}
.pagination__pages button:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}
.pagination__pages button.is-active {
  background: var(--primary);
  color: var(--on-primary);
}
.pagination__pages button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.pagination__pages svg {
  width: 16px;
  height: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.field__label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.field__label .req {
  color: var(--danger);
}
.field__hint {
  font-size: 11.5px;
  color: var(--text-3);
  line-height: 1.7;
}
.field__err {
  display: none;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--danger);
}
.field__err svg {
  width: 13px;
  height: 13px;
}
.field.has-error .field__err {
  display: flex;
}
.field.has-error .input,
.field.has-error .select {
  border-color: var(--danger);
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--s-4);
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13.5px;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease);
}
.textarea {
  padding: var(--s-3) var(--s-4);
  min-height: 104px;
  line-height: 1.85;
  resize: vertical;
}
.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
}
.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--border-strong);
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.input:disabled,
.select:disabled,
.textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.input[readonly] {
  background: var(--surface-3);
  color: var(--text-2);
  border-style: dashed;
}

.input[type='number'] {
  -moz-appearance: textfield;
  appearance: textfield;
  direction: ltr;
  text-align: right;
}
.input[type='number']::-webkit-outer-spin-button,
.input[type='number']::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

.select {
  appearance: none;
  cursor: pointer;
  padding-inline-end: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7896' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  background-size: 17px;
}

.xsel {
  position: relative;
  width: 100%;
}
.xsel > select {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}
.xsel.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}

.xsel__btn {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  width: 100%;
  min-height: 44px;
  padding: 0 var(--s-3) 0 var(--s-4);
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13.5px;
  text-align: start;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease);
}
.xsel__btn:hover {
  border-color: var(--border-strong);
}
.xsel.is-open .xsel__btn,
.xsel__btn:focus-visible {
  outline: none;
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.xsel__label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.xsel__chev {
  flex-shrink: 0;
  color: var(--text-3);
  transition: transform var(--dur-fast) var(--ease);
}
.xsel.is-open .xsel__chev {
  transform: rotate(180deg);
}

.xsel__panel {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline: 0;
  max-height: 264px;
  overflow-y: auto;
  padding: var(--s-2);
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--sh-pop);
  z-index: var(--z-modal);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: all var(--dur-fast) var(--ease);
}
.xsel.is-open .xsel__panel {
  opacity: 1;
  visibility: visible;
  transform: none;
}
.xsel--up .xsel__panel {
  top: auto;
  bottom: calc(100% + 6px);
  transform: translateY(6px);
}

.xsel__opt {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  width: 100%;
  min-height: 38px;
  padding: 0 var(--s-3);
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--text-2);
  text-align: start;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.xsel__opt span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.xsel__opt svg {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
}
.xsel__opt:hover {
  background: var(--surface-2);
  color: var(--text);
}
.xsel__opt.is-on {
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-weight: 600;
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}
.input-group__icon ~ .input {
  padding-inline-start: 40px;
}

/* Same direction mismatch as the trailing button: the icon is pinned with
   inset-inline-start against the RTL group (so it sits on the RIGHT), while an
   LTR field resolves its own inline-start to the LEFT. Without this the value
   gets padded away from the icon on one side and tucked under it on the other. */
.input-group__icon ~ .input.mono,
.input-group__icon ~ .input[dir='ltr'],
.input-group__icon ~ .input--ltr {
  padding-inline-start: var(--s-4);
  padding-right: 40px;
}
.input-group__icon {
  position: absolute;
  inset-inline-start: 13px;
  display: grid;
  place-items: center;
  color: var(--text-3);
  pointer-events: none;
}
.input-group__icon svg {
  width: 17px;
  height: 17px;
}
.input-group__suffix {
  position: absolute;
  inset-inline-end: 13px;
  font-size: 12px;
  color: var(--text-3);
  pointer-events: none;
}
.input-group .input.has-suffix {
  padding-inline-end: 56px;
}
.input-group__btn {
  position: absolute;
  inset-inline-end: 6px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--text-3);
}
.input-group__btn:hover {
  background: var(--surface-3);
  color: var(--text);
}
.input-group__btn svg {
  width: 16px;
  height: 16px;
}

/* The reveal / clear button floats over the field, so the value needs room to
   stop before it (bot token, panel access key, gateway secrets, passwords).

   The button resolves `inset-inline-end` against the RTL group, which puts it on
   the LEFT. A field that is itself LTR (.mono, or dir="ltr") resolves its own
   inline-end to the RIGHT — the opposite side — so logical padding would leave
   the value running straight under the button. Those fields get physical
   padding on the side the button actually occupies. */
.input-group:has(> .input-group__btn:not(.hidden)) > .input {
  padding-inline-end: 46px;
}

.input-group:has(> .input-group__btn:not(.hidden)) > .input.mono,
.input-group:has(> .input-group__btn:not(.hidden)) > .input[dir='ltr'],
.input-group:has(> .input-group__btn:not(.hidden)) > .input--ltr {
  padding-inline-end: var(--s-4);
  padding-left: 46px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-5);
}
.form-grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.form-grid .full {
  grid-column: 1 / -1;
}
@media (max-width: 820px) {
  .form-grid,
  .form-grid--3 {
    grid-template-columns: minmax(0, 1fr);
  }
}

.fieldset {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-5);
}
.fieldset legend {
  padding: 0 var(--s-2);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
}

.switch {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  cursor: pointer;
  user-select: none;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.switch__track {
  position: relative;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
  border-radius: var(--r-full);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.switch__track::after {
  content: '';
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-3);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.switch input:checked + .switch__track {
  background: var(--primary);
  border-color: var(--primary);
}
.switch input:checked + .switch__track::after {
  transform: translateX(-20px);
  background: #fff;
}
.btn__spin {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border: 2px solid currentColor;
  border-radius: 50%;
  border-inline-start-color: transparent;
  animation: spin 0.7s linear infinite;
}
.switch input:focus-visible + .switch__track {
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.switch input:disabled + .switch__track {
  opacity: 0.45;
  cursor: not-allowed;
}
.switch__text {
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}
.switch__title {
  font-size: 13.5px;
  font-weight: 600;
}
.switch__desc {
  font-size: 11.5px;
  color: var(--text-3);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  transition: border-color var(--dur-fast) var(--ease);
}
.toggle-row:hover {
  border-color: var(--border);
}
.toggle-row__info {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-width: 0;
}
.toggle-row__icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  color: var(--text-2);
}
.toggle-row__icon svg {
  width: 18px;
  height: 18px;
}
.toggle-row.is-on .toggle-row__icon {
  background: var(--success-soft);
  color: var(--success);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  cursor: pointer;
  user-select: none;
  font-size: 13.5px;
}
.check input {
  appearance: none;
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  border-radius: var(--r-xs);
  border: 1.5px solid var(--border-strong);
  background: var(--surface-2);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.check input[type='radio'] {
  border-radius: 50%;
}
.check input:checked {
  background: var(--primary);
  border-color: var(--primary);
  background-image: 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.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  background-size: 13px;
  background-position: center;
  background-repeat: no-repeat;
}
.check input[type='radio']:checked {
  background-image: none;
  box-shadow: inset 0 0 0 4px var(--surface);
}
.check input:focus-visible {
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.pick {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4);
  border-radius: var(--r-md);
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.pick:hover {
  border-color: var(--border-strong);
}
.pick input {
  position: absolute;
  opacity: 0;
}
.pick:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.pick__icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  color: var(--text-2);
  flex-shrink: 0;
}
.pick:has(input:checked) .pick__icon {
  background: var(--primary);
  color: #fff;
}
.pick__icon svg {
  width: 17px;
  height: 17px;
}

.tabs {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: 44px;
  padding: 0 var(--s-4);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-3);
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease);
}
.tab:hover {
  color: var(--text);
}
.tab svg {
  width: 16px;
  height: 16px;
}
.tab.is-active {
  color: var(--primary);
}
.tab.is-active::after {
  content: '';
  position: absolute;
  inset-inline: var(--s-2);
  bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--primary);
}
.tab__count {
  padding: 1px 6px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.tab.is-active .tab__count {
  background: var(--primary-soft);
  color: var(--primary);
}

.tabpanel {
  display: none;
  animation: fade-up var(--dur) var(--ease);
}
.tabpanel.is-active {
  display: block;
}
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.pillnav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.pillnav a {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 42px;
  padding: 0 var(--s-3);
  border-radius: var(--r-md);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
  transition: all var(--dur-fast) var(--ease);
}
.pillnav a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.pillnav a:hover {
  background: var(--surface-2);
  color: var(--text);
}
.pillnav a.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.dd {
  position: relative;
}
.dd__menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  min-width: 210px;
  padding: var(--s-2);
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--sh-pop);
  z-index: var(--z-modal);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top left;
  transition: all var(--dur-fast) var(--ease);
}
.dd.is-open .dd__menu {
  opacity: 1;
  visibility: visible;
  transform: none;
}
.dd__menu--start {
  inset-inline-end: auto;
  inset-inline-start: 0;
  transform-origin: top right;
}
.dd__item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  min-height: 38px;
  padding: 0 var(--s-3);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-align: start;
  transition: all var(--dur-fast) var(--ease);
}
.dd__item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.dd__item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.dd__item--danger {
  color: var(--danger);
}
.dd__item--danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}
.dd__sep {
  height: 1px;
  margin: var(--s-2) 0;
  background: var(--border-soft);
}
.dd__head {
  padding: var(--s-2) var(--s-3);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: var(--s-4);
  background: var(--overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur) var(--ease), visibility var(--dur) var(--ease);
}
.modal.is-open {
  opacity: 1;
  visibility: visible;
}
.modal__box {
  width: 100%;
  max-width: 520px;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-pop);
  transform: translateY(14px) scale(0.97);
  transition: transform var(--dur) var(--ease);
}
.modal.is-open .modal__box {
  transform: none;
}
.modal__box--lg {
  max-width: 760px;
}
.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-5);
  border-bottom: 1px solid var(--border-soft);
}
.modal__head h3 {
  font-size: 16px;
}
.modal__head p {
  font-size: 12.5px;
  color: var(--text-3);
  margin-top: 2px;
}
.modal__body {
  padding: var(--s-5);
  overflow-y: auto;
}
.modal__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-2);
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--border-soft);
  background: var(--surface-2);
}
.modal__x {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--text-3);
}
.modal__x:hover {
  background: var(--surface-3);
  color: var(--text);
}
.modal__x svg {
  width: 18px;
  height: 18px;
}
.modal__hero {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
}
.modal__hero svg {
  width: 22px;
  height: 22px;
}

.confirm {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.confirm__head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.confirm__head h3 {
  font-size: 16px;
  line-height: 1.5;
  min-width: 0;
}
.confirm__text {
  font-size: 13px;
  line-height: 1.95;
  color: var(--text-2);
}
.modal__hero--danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.modal__hero--warning {
  background: var(--warning-soft);
  color: var(--warning);
}
.modal__hero--primary {
  background: var(--primary-soft);
  color: var(--primary);
}

.toasts {
  position: fixed;
  inset-block-end: var(--s-5);
  inset-inline-start: var(--s-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  pointer-events: none;
}
@media (max-width: 1024px) {
  .toasts {
    inset-block-end: calc(var(--bottomnav-h) + var(--s-3) + env(safe-area-inset-bottom, 0px));
    inset-inline: var(--s-4);
  }
  .toast {
    min-width: 0;
    max-width: none;
  }
  .modal {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-width: 290px;
  max-width: 380px;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--sh-pop);
  font-size: 13.5px;
  pointer-events: auto;
  animation: toast-in var(--dur) var(--ease);
}
.toast.is-out {
  animation: toast-out var(--dur-fast) var(--ease) forwards;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-24px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(-24px);
  }
}
.toast__icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
}
.toast__icon svg {
  width: 17px;
  height: 17px;
  stroke-width: 2.2;
}
.toast--success .toast__icon {
  background: var(--success-soft);
  color: var(--success);
}
.toast--danger .toast__icon {
  background: var(--danger-soft);
  color: var(--danger);
}
.toast--warning .toast__icon {
  background: var(--warning-soft);
  color: var(--warning);
}
.toast--info .toast__icon {
  background: var(--info-soft);
  color: var(--info);
}
.toast__x {
  margin-inline-start: auto;
  color: var(--text-3);
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--r-xs);
}
.toast__x:hover {
  background: var(--surface-3);
  color: var(--text);
}
.toast__x svg {
  width: 15px;
  height: 15px;
}

.progress {
  height: 7px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--bar, var(--primary));
  transition: width 600ms var(--ease);
}
.progress--sm {
  height: 5px;
}

.meter {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.meter__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  font-size: 12.5px;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-12) var(--s-5);
  text-align: center;
}
.empty__icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  color: var(--text-3);
  border: 1px solid var(--border);
}
.empty__icon svg {
  width: 28px;
  height: 28px;
  stroke-width: 1.5;
}
.empty h4 {
  font-size: 15px;
}
.empty p {
  font-size: 13px;
  color: var(--text-3);
  max-width: 360px;
}

.skeleton {
  border-radius: var(--r-sm);
  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;
  }
}

tr.is-loading .skeleton {
  display: block;
  height: 13px;
  width: 100%;
}
tr.is-loading td {
  padding-block: var(--s-4);
}

.divider {
  height: 1px;
  background: var(--border-soft);
  margin: var(--s-5) 0;
}

.kv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) 0;
  border-bottom: 1px dashed var(--border-soft);
  font-size: 13.5px;
}
.kv:last-child {
  border-bottom: 0;
}
.kv__k {
  color: var(--text-3);
  font-size: 12.5px;
}
.kv__v {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.note {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-4);
  border-radius: var(--r-md);
  font-size: 12.5px;
  line-height: 1.85;
  border: 1px solid transparent;
}
.note svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 3px;
}
.note--info {
  background: var(--info-soft);
  color: var(--info);
  border-color: color-mix(in srgb, var(--info) 25%, transparent);
}
.note--warning {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: color-mix(in srgb, var(--warning) 25%, transparent);
}
.note--danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 25%, transparent);
}

.copybox {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  background: var(--surface-3);
  border: 1px solid var(--border);
  font-size: 12px;
  direction: ltr;
}
.copybox code {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
}
.copybox button {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: var(--r-xs);
  color: var(--text-3);
  flex-shrink: 0;
}
.copybox button:hover {
  background: var(--surface);
  color: var(--primary);
}
.copybox button svg {
  width: 14px;
  height: 14px;
}

.jdp {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-start: 0;
  width: 288px;
  padding: var(--s-3);
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--sh-pop);
  z-index: var(--z-modal);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top center;
  transition: all var(--dur-fast) var(--ease);
}
.jdp.is-open {
  opacity: 1;
  visibility: visible;
  transform: none;
}
.jdp--up {
  top: auto;
  bottom: calc(100% + 8px);
  transform-origin: bottom center;
}

.jdp__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}
.jdp__nav {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--text-2);
  transition: all var(--dur-fast) var(--ease);
}
.jdp__nav:hover:not(:disabled) {
  background: var(--primary-soft);
  color: var(--primary-deep);
}
.jdp__nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.jdp__title {
  display: flex;
  align-items: center;
  gap: var(--s-1);
}
.jdp__sel {
  appearance: none;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: all var(--dur-fast) var(--ease);
}
.jdp__sel:hover {
  border-color: var(--border-strong);
}
.jdp__sel:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.jdp__week,
.jdp__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.jdp__week {
  margin-bottom: var(--s-2);
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--border-soft);
}
.jdp__week span {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
}

.jdp__day {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  transition: all var(--dur-fast) var(--ease);
}
.jdp__day:hover:not(:disabled) {
  background: var(--primary-soft);
  color: var(--primary-deep);
}
.jdp__day:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}
.jdp__day.is-today {
  box-shadow: inset 0 0 0 1.5px var(--primary);
  color: var(--primary-deep);
  font-weight: 700;
}
.jdp__day.is-selected {
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 700;
  box-shadow: none;
}
.jdp__pad {
  aspect-ratio: 1;
}

.jdp__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid var(--border-soft);
}

@media (max-width: 520px) {
  .jdp {
    inset-inline: 0;
    width: auto;
  }
}

.tip {
  position: relative;
}
.tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 7px);
  inset-inline-start: 50%;
  transform: translateX(50%);
  padding: 4px 9px;
  border-radius: var(--r-xs);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease);
  z-index: var(--z-modal);
}
.tip:hover::after,
.tip:focus-visible::after {
  opacity: 1;
  visibility: visible;
}

.card__foot.end,
.card__foot.between {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.card__foot.end {
  justify-content: flex-end;
}
.card__foot.between {
  justify-content: space-between;
}

.input[type='number'] {
  appearance: textfield;
  -moz-appearance: textfield;
}
.input[type='number']::-webkit-outer-spin-button,
.input[type='number']::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.input-group .input.has-suffix {
  padding-inline-end: 46px;
}
.input-group__suffix {
  inset-inline-end: 12px;
}

.input[dir='ltr'],
.input--ltr {
  direction: ltr;
  text-align: left;
}

.skeleton {
  display: block;
  border-radius: var(--r-sm);
  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;
}
.skeleton--text {
  height: 12px;
  margin-block: 4px;
}
.skeleton--title {
  height: 18px;
  width: 45%;
}
.skeleton--pill {
  height: 22px;
  width: 72px;
  border-radius: 999px;
}
.skeleton--circle {
  border-radius: 50%;
  flex: none;
}
.skeleton--w40 {
  width: 40%;
}
.skeleton--w60 {
  width: 60%;
}
.skeleton--w80 {
  width: 80%;
}

.sk-card {
  padding: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.sk-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-5);
  border-bottom: 1px solid var(--border-soft);
}
.sk-row:last-child {
  border-bottom: 0;
}
.sk-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.sk-block {
  border-radius: var(--r-md);
}

@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
  }
}

/* The 16px-on-mobile rule that stops focus-zoom lives at the end of pages.css:
   pages.css is the last stylesheet every page loads, and several of the fields
   it needs to beat (.filterbar__search input) are declared there too. */
