.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control-h-md);
  padding: 0 12px;
  border: 1px solid var(--accent-press);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--text-on-accent);
  font: 600 13px/1 var(--font-sans);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .14), 0 1px 1px rgba(20, 30, 50, .06);
}
.btn:hover { background: var(--accent-hover); color: var(--text-on-accent); text-decoration: none; }
.btn:active { background: var(--accent-press); }
.btn:focus-visible { outline: 0; box-shadow: var(--focus-ring); }
.btn .ic { width: 15px; height: 15px; }
.btn--secondary { background: var(--surface-1); color: var(--text-primary); border-color: var(--border-strong); box-shadow: 0 1px 1px rgba(20, 30, 50, .05); }
.btn--secondary:hover { background: var(--surface-hover); color: var(--text-primary); }
.btn--secondary:active { background: var(--surface-active); }
.btn--ghost { background: transparent; color: var(--text-gold); border-color: transparent; box-shadow: none; }
.btn--ghost:hover { background: var(--surface-hover); color: var(--text-gold); }
.btn--ghost:active { background: var(--surface-active); }
.btn--danger { background: var(--surface-1); color: var(--danger-fg); border-color: color-mix(in srgb, var(--danger) 55%, var(--border-default)); }
.btn--danger:hover { background: var(--danger); border-color: var(--danger); color: #FFFFFF; }
.btn--danger:active { background: var(--red-700); }
.btn--discord { background: var(--discord); border-color: var(--discord-hover); color: #FFFFFF; }
.btn--discord:hover { background: var(--discord-hover); color: #FFFFFF; }
.btn--discord:active { background: #3C45C9; }
.btn--sm { height: var(--control-h-sm); padding: 0 9px; font-size: 12px; }
.btn--sm .ic { width: 14px; height: 14px; }
.btn--lg { height: var(--control-h-lg); padding: 0 16px; font-size: 14px; }
.btn--lg .ic { width: 16px; height: 16px; }
.btn--block { width: 100%; }
.btn:disabled, .btn.is-disabled {
  background: var(--surface-3);
  color: var(--text-disabled);
  border-color: var(--border-default);
  cursor: not-allowed;
}

.icon-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text-primary); }
.icon-btn:focus-visible { outline: 0; box-shadow: var(--focus-ring); }
.icon-btn--sm { width: 26px; height: 26px; }
.icon-btn--sm .ic { width: 14px; height: 14px; }
.icon-btn--danger:hover { background: var(--danger-subtle); color: var(--danger-fg); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 6px;
  background: var(--surface-3);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xs);
  font: 600 12px/1 var(--font-sans);
  white-space: nowrap;
}
.badge .ic { width: 12px; height: 12px; }
.badge--dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 99px;
  background: currentColor;
}
.badge--gold { background: var(--accent-subtle); color: var(--text-gold); border-color: var(--border-gold); }
.badge--danger { background: var(--danger-subtle); color: var(--danger-fg); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.badge--warning { background: var(--warning-subtle); color: var(--warning-fg); border-color: color-mix(in srgb, var(--warning) 40%, transparent); }
.badge--success { background: var(--success-subtle); color: var(--success-fg); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.badge--info { background: var(--info-subtle); color: var(--info-fg); border-color: color-mix(in srgb, var(--info) 35%, transparent); }

.card {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.card--classified { border-top: 2px solid var(--accent); }
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 12px 18px;
  background: var(--surface-head);
  border-bottom: 1px solid var(--border-default);
}
.card__head--sm { padding: 10px 14px; }
.card__eyebrow {
  font: 400 13px/1.3 var(--font-sans);
  color: var(--text-muted);
  margin-bottom: 2px;
}
.card__title { font: 600 16px/1.3 var(--font-sans); color: var(--text-primary); }
.card__title a { color: inherit; }
.card__actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.card__body { padding: 18px; }
.card__body--sm { padding: 12px; }
.card__body--md { padding: 16px; }
.card__body--flush { padding: 0; }
.card__foot {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 10px 16px;
  background: var(--surface-head);
  border-top: 1px solid var(--border-subtle);
}

.avatar {
  --size: 32px;
  position: relative;
  display: inline-flex;
  flex: none;
  width: var(--size);
  height: var(--size);
}
.avatar--30 { --size: 30px; }
.avatar--32 { --size: 32px; }
.avatar--34 { --size: 34px; }
.avatar--38 { --size: 38px; }
.avatar--52 { --size: 52px; }
.avatar--96 { --size: 96px; }
.avatar--160 { --size: 160px; }
.avatar__img {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  overflow: hidden;
  background: var(--navy-700);
  border: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: calc(var(--size) * .38);
  line-height: 1;
}
.avatar__img img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 15%; }

.rank {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-xs);
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  font: 600 12px/1 var(--font-sans);
}
.rank--cmd { background: var(--rank-gold); color: var(--rank-gold-fg); border-color: var(--rank-gold-border); text-transform: uppercase; letter-spacing: .02em; }
.rank--admin {
  gap: 4px;
  background: var(--danger-subtle);
  color: var(--danger-fg);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  margin-left: 6px;
}
.me .rank--admin { margin-left: 0; }

.stat {
  padding: 16px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.stat__label { font: 400 14px/1.3 var(--font-sans); color: var(--text-secondary); }
.stat__icon { flex: none; display: inline-flex; color: var(--text-muted); }
.stat__icon .ic { width: 18px; height: 18px; }
.stat__value {
  font: 600 30px/1.1 var(--font-sans);
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.stat__meta { font: 400 12px/1 var(--font-sans); color: var(--text-muted); margin-left: 6px; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  box-shadow: var(--shadow-1);
}
.card .table-wrap { border: 0; border-radius: 0; box-shadow: none; }
.table { width: 100%; border-collapse: collapse; font: var(--text-small); }
.table th {
  text-align: left;
  padding: 9px 12px;
  background: var(--surface-head);
  border-bottom: 1px solid var(--border-default);
  font: 600 12px/1.3 var(--font-sans);
  color: var(--text-secondary);
  white-space: nowrap;
}
.table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}
.table tbody tr:nth-child(even) { background: var(--surface-zebra); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--accent-subtle); }
.table tr[data-href] { cursor: pointer; }
th.is-sortable { cursor: pointer; user-select: none; }
th.is-sortable:hover { color: var(--text-primary); text-decoration: underline; }
th.is-sortable:focus-visible { outline: 0; box-shadow: inset var(--focus-ring); }
th.is-sortable::after { content: "↕"; margin-left: 4px; font-size: 11px; opacity: .4; }
th.is-sortable[aria-sort="ascending"], th.is-sortable[aria-sort="descending"] { color: var(--text-primary); }
th.is-sortable[aria-sort="ascending"]::after { content: "▲"; font-size: 9px; opacity: .8; }
th.is-sortable[aria-sort="descending"]::after { content: "▼"; font-size: 9px; opacity: .8; }
.table td.mono { font: var(--text-data); white-space: nowrap; }
.table .right { text-align: right; }
.table--dense td { padding: 6px 12px; }
.table__title { font-weight: 600; }
.table__title a { color: var(--text-gold); }
.table__sub { color: var(--text-muted); font-size: 12px; }

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border-default);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  margin-bottom: -1px;
  padding: 0 12px;
  background: none;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  color: var(--text-gold);
  font: 400 13px/1 var(--font-sans);
  white-space: nowrap;
  text-decoration: none;
}
.tab:hover { background: var(--surface-hover); color: var(--text-gold); text-decoration: none; }
.tab.is-active {
  background: var(--surface-1);
  border-color: var(--border-default);
  color: var(--text-primary);
  font-weight: 600;
}
.tab.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: var(--surface-1);
}
.tab__count {
  font: 400 12px/1 var(--font-sans);
  padding: 2px 5px;
  border-radius: var(--radius-pill);
  background: var(--surface-active);
  color: var(--text-secondary);
}
.tab.is-active .tab__count { background: var(--surface-active); color: var(--text-primary); }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 36px;
  padding: 0 14px;
  color: var(--text-secondary);
  font: 400 14px/1 var(--font-sans);
  text-decoration: none;
}
.nav-item .ic { width: 18px; height: 18px; color: var(--text-muted); }
.nav-item:hover { background: var(--surface-hover); color: var(--text-primary); text-decoration: none; }
.nav-item.is-active { background: var(--surface-active); color: var(--text-primary); font-weight: 600; }
.nav-item.is-active .ic { color: var(--text-primary); }
.nav-item__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item__count { font: 400 12px/1 var(--font-sans); color: var(--text-muted); }
.nav-item__count--new {
  min-width: 18px;
  padding: 2px 5px;
  border-radius: var(--radius-pill);
  background: var(--danger);
  color: #FFFFFF;
  font-weight: 600;
  text-align: center;
}
.nav-item.is-active .nav-item__count { color: var(--text-secondary); }
.nav-item.is-active .nav-item__count--new { color: #FFFFFF; }
.nav-item__ext { color: var(--text-disabled); }

.field { display: block; min-width: 0; }
.field__label {
  display: block;
  font: 600 13px/1.3 var(--font-sans);
  color: var(--text-secondary);
  margin-bottom: 5px;
}
.field__hint { display: block; font: 400 12px/1.4 var(--font-sans); color: var(--text-muted); margin-top: 4px; }

.control {
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--control-h-md);
  padding: 0 9px;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
.control:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 20%, transparent); }
.control .ic { width: 15px; height: 15px; color: var(--text-muted); }
.control input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text-primary);
  font: var(--text-body);
}
.control--sm { height: var(--control-h-sm); }
.control--sm input { font-size: 13px; }

.input, .select, .textarea {
  width: 100%;
  background: var(--surface-1);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: var(--text-body);
  outline: 0;
}
.input, .select { height: var(--control-h-md); padding: 0 9px; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 20%, transparent); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-3); color: var(--text-muted); }
.input--mono { font: var(--text-data); }
.input--sm, .select--sm { height: var(--control-h-sm); font-size: 13px; }
.select {
  appearance: none;
  padding-right: 28px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23646D78' stroke-width='2.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: right 8px center;
  background-size: 14px;
}
.select option { background: var(--surface-1); color: var(--text-primary); }
.textarea { resize: vertical; padding: 7px 9px; min-height: 90px; }

.check {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font: var(--text-small);
  color: var(--text-primary);
}
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.check__box {
  width: 15px;
  height: 15px;
  flex: none;
  border-radius: var(--radius-xs);
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
}
.check input:checked + .check__box {
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FFFFFF' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 11px no-repeat;
  border-color: var(--accent);
}
.check input:focus-visible + .check__box { box-shadow: var(--focus-ring); }
.check input:disabled + .check__box { opacity: .5; }

.dialog {
  width: 560px;
  max-width: calc(100% - 32px);
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--border-strong);
  background: var(--surface-1);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-3);
}
.dialog::backdrop { background: var(--surface-overlay); }
.dialog__inner { position: relative; display: flex; flex-direction: column; max-height: calc(100vh - 48px); margin: 0; }
.dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface-head);
  border-bottom: 1px solid var(--border-default);
}
.dialog__eyebrow {
  font: 400 13px/1.3 var(--font-sans);
  color: var(--text-muted);
  margin-bottom: 2px;
}
.dialog__title { font: 600 16px/1.3 var(--font-sans); color: var(--text-primary); }
.dialog__body { padding: 14px 16px 16px; overflow-y: auto; }
.dialog__foot {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px;
  background: var(--surface-head);
  border-top: 1px solid var(--border-default);
}

.dialog--wide { width: 760px; }

.ctx {
  position: fixed;
  z-index: 400;
  min-width: 220px;
  max-width: min(300px, calc(100vw - 16px));
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  padding: 4px 0;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
  outline: 0;
}
.ctx__label {
  padding: 6px 12px 4px;
  font: 600 12px/1.3 var(--font-sans);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ctx__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 30px;
  padding: 0 12px;
  border: 0;
  background: none;
  color: var(--text-primary);
  font: 400 13px/1 var(--font-sans);
  text-align: left;
  cursor: pointer;
}
.ctx__item:hover, .ctx__item:focus-visible { background: var(--accent); color: var(--text-on-accent); outline: 0; }
.ctx__item .ic { width: 15px; height: 15px; }
.ctx__text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx__hint {
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  background: var(--surface-active);
  color: var(--text-secondary);
  font: 400 11px/1.3 var(--font-sans);
}
.ctx__sep { height: 1px; margin: 4px 0; background: var(--border-subtle); }
.ctx__foot { padding: 6px 12px 3px; margin-top: 4px; border-top: 1px solid var(--border-subtle); font: 400 11px/1.3 var(--font-sans); color: var(--text-disabled); }
@media (pointer: coarse) {
  .ctx__item { height: 40px; }
  .ctx__foot { display: none; }
}

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  --c: var(--info);
  position: relative;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  width: 360px;
  max-width: calc(100vw - 32px);
  padding: 10px 12px;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--c);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
  transition: opacity var(--dur-slow), transform var(--dur-slow);
}
.toast--success { --c: var(--success); }
.toast--danger { --c: var(--danger); }
.toast--warning { --c: var(--warning); }
.toast > .ic { width: 17px; height: 17px; color: var(--c); margin-top: 1px; }
.toast__title { font: 600 13px/1.3 var(--font-sans); color: var(--text-primary); }
.toast__msg { font: var(--text-small); color: var(--text-secondary); margin-top: 2px; }
.toast__close { background: none; border: 0; padding: 0; color: var(--text-muted); cursor: pointer; display: flex; }
.toast.is-hiding { opacity: 0; transform: translateY(6px); }

.alert {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  background: var(--danger-subtle);
  color: var(--danger-fg);
  font: var(--text-small);
  text-align: left;
}
.alert--info { border-color: color-mix(in srgb, var(--info) 35%, transparent); background: var(--info-subtle); color: var(--info-fg); }

.upload {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--text-muted);
  text-align: center;
  cursor: pointer;
  font: var(--text-small);
}
.upload:hover, .upload.is-drag { border-color: var(--accent); background: var(--accent-subtle); color: var(--text-primary); }
.upload input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload .ic { width: 18px; height: 18px; }
.upload__hint { font-size: 12px; color: var(--text-muted); }

.empty {
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  text-align: center;
  font-size: 13px;
}
.empty .ic { display: none; }
.empty__title { color: var(--text-secondary); font-weight: 600; font-size: 13px; }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.pager__info { font: 400 12px/1 var(--font-sans); color: var(--text-muted); }

.kv { margin: 0; }
.kv__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-top: 1px solid var(--border-subtle);
  font-size: 13px;
}
.kv__row dt { color: var(--text-muted); }
.kv__row dd { margin: 0; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.kv__row dd.mono { font: var(--text-data); }

.dialog--confirm { width: 440px; }
.confirm { display: flex; gap: 12px; align-items: flex-start; padding: 16px; }
.confirm__icon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--text-gold);
}
.confirm__icon .ic { width: 24px; height: 24px; }
.confirm__title { font: 600 15px/1.3 var(--font-sans); color: var(--text-primary); margin-bottom: 4px; }
.confirm__text { font: var(--text-body); color: var(--text-secondary); overflow-wrap: anywhere; }
.dialog--confirm.is-danger .confirm__icon { color: var(--danger-fg); }
.dialog--confirm .dialog__foot .btn { min-width: 90px; justify-content: center; }
@media (max-width: 640px) {
  .dialog--confirm { width: calc(100% - 32px); }
  .dialog--confirm .dialog__foot .btn { flex: 1; }
}

.avatar--zoom, [data-zoom] { cursor: zoom-in; }
.avatar--zoom:hover .avatar__img { box-shadow: 0 0 0 2px var(--border-gold); }
.lightbox {
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
}
.lightbox::backdrop { background: rgba(0, 0, 0, .82); }
.lightbox__figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: zoom-out; }
.lightbox__img {
  display: block;
  max-width: min(800px, calc(100vw - 32px));
  max-height: calc(100vh - 96px);
  width: auto;
  height: auto;
  border: 4px solid #FFFFFF;
  background: #FFFFFF;
}
.lightbox__caption { font: 600 14px/1.3 var(--font-sans); color: #F1F4F9; text-align: center; }
.lightbox__close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 30px;
  height: 30px;
  border-radius: 99px;
  border: 1px solid var(--border-strong);
  background: var(--surface-1);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-2);
}
