:root {
  color-scheme: dark;
  --bg: #111113;
  --panel: #19191d;
  --card: #1d1d22;
  --input: #17171a;
  --line: #333238;
  --subtle-line: #2a292f;
  --text: #f4f2ee;
  --muted: #b1adb5;
  --faint: #96919c;
  --accent: #ff9467;
  --accent-strong: #ffae8d;
  --accent-wash: #35241f;
  --blue: #b2c5fb;
  --green: #b5d5ac;
  --radius-sm: .55rem;
  --radius: .9rem;
  --font: "Aptos", "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(ellipse 48rem 28rem at 95% 0, #26201f 0, transparent 95%),
    var(--bg);
  font: 1rem/1.5 var(--font);
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
a { color: var(--accent-strong); }
button:disabled { cursor: default; opacity: .45; }

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

h1, h2, h3, p, dl { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }

.shell {
  width: min(100% - 3.5rem, 80rem);
  margin-inline: auto;
}

.site-header {
  border-bottom: 1px solid var(--subtle-line);
  background: #161618;
}

.header-inner,
.header-actions,
.brand {
  display: flex;
  align-items: center;
}

.header-inner {
  justify-content: space-between;
  min-height: 4.5rem;
  gap: 1rem;
}

.header-actions { gap: .75rem; }

.brand {
  width: fit-content;
  gap: .7rem;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid #82503d;
  border-radius: .65rem;
  background: #3b2822;
  color: var(--accent-strong);
  font-size: .92rem;
  font-weight: 850;
  line-height: 1;
}

.brand-mark svg { width: 1.15rem; height: 1.15rem; }
.brand-copy { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: .12rem .42rem; }
.brand-name { font-size: .95rem; font-weight: 850; letter-spacing: .055em; }
.brand-product { color: var(--muted); font-size: .92rem; font-weight: 620; }
.main-content { padding-block: clamp(2rem, 5vw, 4.5rem) 3rem; }
.intro { margin-bottom: clamp(1.55rem, 3.4vw, 2.5rem); }

.intro h1,
.login-card h1 {
  font-size: clamp(2.2rem, 4.5vw, 3.65rem);
  font-weight: 790;
  letter-spacing: -.052em;
  line-height: 1.07;
}

.intro p,
.login-card > p {
  max-width: 57ch;
  margin-top: .75rem;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.12rem);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .85rem;
  margin-bottom: 1.6rem;
}

.stat-card {
  display: grid;
  align-content: start;
  gap: .26rem;
  padding: 1rem 1.2rem 1.08rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

.stat-card:first-child { border-color: #774936; background: linear-gradient(140deg, #35251f, #271f1e); }
.stat-label { color: var(--muted); font-size: .9rem; font-weight: 650; }
.stat-card:first-child .stat-label { color: #e2baab; }
.stat-card strong { font-size: clamp(1.7rem, 3vw, 2.35rem); font-weight: 760; letter-spacing: -.04em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-card:first-child strong { color: var(--accent-strong); }
.stat-caption { color: var(--muted); font-size: .82rem; }

.registry {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.registry-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: .4rem 1rem;
  padding: 1.2rem 1.25rem 0;
}

.registry-header h2,
.dialog-header h2 {
  font-size: clamp(1.3rem, 2vw, 1.63rem);
  font-weight: 750;
  letter-spacing: -.028em;
}

.registry-header p { color: var(--muted); font-size: .92rem; }

.filters {
  display: grid;
  grid-template-columns: minmax(12rem, 1.6fr) repeat(3, minmax(7.2rem, 1fr)) auto;
  align-items: end;
  gap: .68rem;
  padding: 1.05rem 1.25rem .85rem;
}

.filter-field {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: .38rem;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 620;
}

.filter-field input,
.filter-field select,
.filter-field textarea,
.login-form input,
.manual-form input,
.manual-form select,
.manual-form textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 2.68rem;
  padding: .55rem .72rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background-color: var(--input);
  color: var(--text);
  font-size: 1rem;
  font-weight: 490;
}

input::placeholder, textarea::placeholder { color: var(--faint); opacity: 1; }
textarea { resize: vertical; }

.filter-field select,
.manual-form select {
  appearance: none;
  padding-right: 1.65rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--faint) 50%), linear-gradient(135deg, var(--faint) 50%, transparent 50%);
  background-position: calc(100% - 13px) 50%, calc(100% - 8px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.button,
.header-actions button,
.header-actions a,
.secondary-button,
.detail-button,
#ban-reset,
#ban-prev,
#ban-next,
#ban-dialog-close,
.primary-button,
.manual-form button,
.login-form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.68rem;
  width: fit-content;
  padding: .54rem .75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: #24242a;
  font-size: .88rem;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

.button:hover,
.header-actions button:hover,
.header-actions a:hover,
.secondary-button:hover,
.detail-button:hover,
#ban-reset:hover,
#ban-prev:not(:disabled):hover,
#ban-next:not(:disabled):hover,
#ban-dialog-close:hover { background: #303037; border-color: #514e58; }

.primary-button,
.manual-form button,
.login-form button {
  border-color: var(--accent);
  background: var(--accent);
  color: #22140f;
  font-weight: 770;
}

.primary-button:hover,
.manual-form button:hover,
.login-form button:hover { border-color: var(--accent-strong); background: var(--accent-strong); }

#ban-status {
  min-height: 1.55rem;
  margin: 0 1.25rem .65rem;
  color: var(--muted);
  font-size: .89rem;
}

.table-wrap { width: 100%; }

.ban-table,
table:has(#ban-results) {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  text-align: left;
}

.ban-table th,
table:has(#ban-results) th {
  padding: .66rem .7rem;
  border-block: 1px solid var(--subtle-line);
  color: var(--muted);
  background: #202025;
  font-size: .875rem;
  font-weight: 700;
}

.ban-table th:nth-child(1) { width: 21%; }
.ban-table th:nth-child(3) { width: 16%; }
.ban-table th:nth-child(4) { width: 12%; }
.ban-table th:nth-child(5) { width: 13%; }
.ban-table th:nth-child(6) { width: 6.15rem; }

.ban-table th:first-child,
#ban-results td:first-child { padding-left: 1.25rem; }

.ban-table th:last-child,
#ban-results td:last-child { padding-right: 1.25rem; }

#ban-results td {
  min-width: 0;
  padding: .85rem .7rem;
  border-bottom: 1px solid var(--subtle-line);
  font-size: .91rem;
  overflow-wrap: anywhere;
  vertical-align: middle;
}

#ban-results tr:nth-child(even) { background: #1c1c21; }
#ban-results tr:hover { background: #212127; }
#ban-results[aria-busy="true"] { opacity: .53; }

.account-mark {
  display: inline-grid;
  place-items: center;
  width: 2.12rem;
  height: 2.12rem;
  margin-right: .52rem;
  border: 1px solid #524038;
  border-radius: .66rem;
  color: #efb7a0;
  background: #2d2424;
  font-size: .72rem;
  font-weight: 820;
  text-transform: uppercase;
  vertical-align: middle;
}

.account-name {
  display: inline-block;
  max-width: calc(100% - 2.7rem);
  vertical-align: middle;
}

.account-name strong { display: block; font-weight: 735; line-height: 1.25; }
.secondary-line { display: block; margin-top: .18rem; color: var(--muted); font-size: .8125rem; line-height: 1.3; }
.reason-text {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  white-space: pre-wrap;
}
.live-cell, .date-cell { color: var(--muted); }
.date-cell { font-variant-numeric: tabular-nums; }
.actions-cell { text-align: right; }

.source-pill {
  display: inline-block;
  max-width: 100%;
  padding: .22rem .48rem;
  border: 1px solid #50505a;
  border-radius: .42rem;
  background: #2a2a32;
  color: #d3cfd9;
  font-size: .79rem;
  font-weight: 710;
  line-height: 1.33;
}

.source-bot { border-color: #734b3a; color: #ffb392; background: var(--accent-wash); }
.source-human { border-color: #465476; color: var(--blue); background: #242a3b; }
.source-phnx { border-color: #465642; color: var(--green); background: #252e24; }
.detail-button { min-height: 2.44rem; padding: .42rem .56rem; }

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: .65rem;
  padding: .88rem 1.25rem;
  color: var(--muted);
}

.pagination-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }
#ban-page { min-height: 1.3rem; font-size: .9rem; font-variant-numeric: tabular-nums; }

.notice,
#ban-error,
#ban-empty {
  margin: 1rem 1.25rem;
  padding: .85rem .95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--card);
  font-size: 1rem;
  overflow-wrap: anywhere;
}

#ban-error, .notice-error { border-color: #93594e; background: #372525; color: #ffccbd; }
.notice-success { border-color: #465642; background: #252e24; color: #c8e9bc; }

#ban-dialog {
  width: min(100% - 1.5rem, 38rem);
  max-height: min(85vh, 52rem);
  max-height: min(85dvh, 52rem);
  overflow: auto;
  padding: 0;
  border: 1px solid #49454e;
  border-radius: 1rem;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 1.25rem 5rem #0009;
}

#ban-dialog::backdrop { background: #0b0a0cb8; }
.dialog-panel { padding: 1.2rem; }

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: .65rem;
  margin-bottom: .75rem;
}

.dialog-header h2 { min-width: 0; overflow-wrap: anywhere; }
#ban-dialog-close { flex: 0 0 auto; }
#ban-details > div {
  display: grid;
  grid-template-columns: minmax(8rem, .8fr) minmax(0, 1.2fr);
  gap: .36rem .8rem;
  padding-block: .69rem;
  border-top: 1px solid var(--subtle-line);
  font-size: .96rem;
}
#ban-details dt { color: var(--muted); }
#ban-details dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.login-page { display: grid; align-content: start; }
.login-shell { width: min(100% - 2rem, 29rem); margin-inline: auto; padding-block: clamp(2.2rem, 10vh, 6rem); }
.login-card {
  padding: clamp(1.15rem, 5vw, 2rem);
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel);
  box-shadow: 0 1rem 3rem #0003;
}
.login-card .brand { margin-bottom: 1.2rem; }
.login-card h1 { font-size: clamp(1.8rem, 6vw, 2.65rem); }
.login-card .notice { margin-inline: 0; }
.login-form { display: grid; gap: .85rem; margin-top: 1.25rem; }
.login-form button { width: 100%; }
.login-form label, .manual-form label { font-size: .9rem; color: var(--muted); }
.login-form :is(input, select, textarea), .manual-form :is(input, select, textarea) { margin-top: .32rem; }
.login-form .filter-field :is(input, select, textarea), .manual-form .filter-field :is(input, select, textarea) { margin-top: 0; }

.manual-details {
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.manual-details summary {
  padding: .85rem 1.25rem;
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 720;
}
.manual-details summary:hover { color: var(--text); }
.manual-details > p { padding-inline: 1.25rem; color: var(--muted); }
.manual-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  gap: .85rem;
  padding: .85rem 1.25rem 1.2rem;
}
.manual-form .wide, .manual-form .form-actions, .manual-form :has(> textarea), .manual-form > p, .manual-form > button { grid-column: 1 / -1; }

.sr-only,
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 65rem) {
  :is(.ban-table, #ban-results) .account-mark { display: none; }
  .account-name { max-width: 100%; }
}

@media (max-width: 56rem) {
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filters .filter-field:has(#ban-search) { grid-column: span 2; }
  .filters #ban-reset { justify-self: start; }
}

@media (max-width: 48rem) {
  .shell { width: min(100% - 2rem, 80rem); }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-wrap { padding-inline: 1rem; }

  .ban-table thead,
  table:has(#ban-results) thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .ban-table,
  table:has(#ban-results),
  #ban-results { display: block; }

  #ban-results tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    margin-bottom: .58rem;
    padding: .25rem .75rem .45rem;
    border: 1px solid var(--line);
    border-radius: .72rem;
    background: var(--card);
  }

  #ban-results td,
  #ban-results td:first-child,
  #ban-results td:last-child {
    display: block;
    padding: .46rem .15rem;
    border-bottom: 0;
  }

  #ban-results td[data-label]:not([data-label=""]):not(.account-cell)::before {
    content: attr(data-label);
    display: block;
    margin-bottom: .2rem;
    color: var(--faint);
    font-size: .8125rem;
    line-height: 1.2;
  }

  #ban-results .account-cell {
    grid-column: 1 / -1;
    margin-bottom: .18rem;
    padding-block: .52rem .65rem;
    border-bottom: 1px solid var(--line);
  }
  #ban-results .account-mark { display: inline-grid; }
  .account-name { max-width: calc(100% - 2.7rem); }
  #ban-results .reason-cell { grid-column: 1 / -1; }
  .actions-cell { align-self: end; }
}

@media (max-width: 32rem) {
  .shell { width: calc(100% - 1.25rem); }
  .header-inner { min-height: 4.12rem; }
  .header-actions { gap: .4rem; }
  .main-content { padding-top: 1.65rem; }
  .stats-grid { gap: .55rem; }
  .stat-card { padding: .75rem .78rem; }
  .registry-header { padding: 1rem .82rem 0; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .56rem; padding: .78rem .82rem .6rem; }
  .filters .filter-field:has(#ban-search) { grid-column: 1 / -1; }
  .table-wrap { padding-inline: .66rem; }
  #ban-status { margin-inline: .82rem; }
  .pagination { padding: .72rem .82rem; }
  .pagination-controls { gap: .35rem; }
  .notice, #ban-error, #ban-empty { margin-inline: .82rem; }
  #ban-details > div { grid-template-columns: minmax(0, 1fr); }
  .manual-form { grid-template-columns: minmax(0, 1fr); padding-inline: .82rem; }
  .manual-details summary, .manual-details > p { padding-inline: .82rem; }
}
