:root {
  --bg: #061d27;
  --panel: #0b1728;
  --line: rgba(255, 202, 47, 0.24);
  --text: #f8fbff;
  --muted: #b7c7d2;
  --primary: #ffca2f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 80% 10%, rgba(29, 211, 189, 0.16), transparent 24rem),
    linear-gradient(145deg, #14251f, var(--bg) 42%, #071629);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

[hidden] {
  display: none !important;
}

.admin-shell,
.admin-login-shell {
  display: grid;
  gap: 18px;
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.admin-login-shell {
  place-items: center;
  min-height: 100vh;
  width: min(760px, calc(100% - 36px));
}

.admin-login-card {
  display: grid;
  gap: 16px;
  width: 100%;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 23, 40, 0.94);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
}

.admin-login-card > span {
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.admin-login-card p,
.admin-reset-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.admin-login-card h1 {
  font-size: clamp(40px, 8vw, 72px);
  line-height: 0.98;
}

.admin-reset-box {
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 202, 47, 0.16);
}

.admin-logout-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  width: min(760px, calc(100% - 36px));
  margin: 0 auto;
  padding: 28px 0;
}

.admin-logout-card {
  display: grid;
  gap: 14px;
  width: 100%;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 23, 40, 0.94);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
}

.admin-logout-card span {
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.admin-logout-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.admin-logout-card button {
  justify-self: start;
}

.admin-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.admin-header span {
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(34px, 6vw, 58px);
}

h2 {
  font-size: 18px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-top-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-weight: 900;
  text-decoration: none;
}

.admin-top-link:hover {
  background: var(--primary);
  color: #061421;
}

.admin-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(2, 8, 14, 0.58);
  backdrop-filter: blur(4px);
}

.admin-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 21;
  display: grid;
  align-content: start;
  gap: 14px;
  width: min(520px, 100vw);
  height: 100vh;
  padding: 22px;
  border-left: 1px solid rgba(255, 202, 47, 0.34);
  background: linear-gradient(180deg, rgba(8, 22, 36, 0.98), rgba(5, 16, 28, 0.98));
  box-shadow: -28px 0 70px rgba(0, 0, 0, 0.48);
  overflow-y: auto;
}

.admin-drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.admin-drawer-head h2 {
  margin-top: 4px;
  font-size: 24px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
}

.admin-drawer-section {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(255, 202, 47, 0.18);
  border-radius: 8px;
  background: rgba(6, 18, 30, 0.52);
}

.admin-drawer-section h3 {
  margin: 0;
  font-size: 15px;
}

.admin-drawer-section p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.admin-two-factor-box {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid rgba(29, 211, 189, 0.22);
  border-radius: 8px;
  background: rgba(29, 211, 189, 0.06);
}

.admin-two-factor-box strong {
  color: #eaf8f7;
}

.admin-two-factor-box code {
  display: block;
  padding: 10px;
  border: 1px solid rgba(255, 202, 47, 0.24);
  border-radius: 7px;
  background: rgba(6, 18, 30, 0.82);
  color: var(--primary);
  font-weight: 900;
  overflow-wrap: anywhere;
}

.admin-two-factor-qr {
  width: 154px;
  height: 154px;
  padding: 8px;
  border: 1px solid rgba(255, 202, 47, 0.28);
  border-radius: 8px;
  background: #fff;
}

.admin-two-factor-link {
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
}

.drawer-button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.danger-button {
  border-color: rgba(255, 103, 91, 0.34);
  color: #ffe1de;
}

button {
  min-height: 40px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 202, 47, 0.12);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 900;
}

button:hover {
  background: var(--primary);
  color: #061421;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 23, 40, 0.9);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.copy-grid,
.legal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.wide-field {
  grid-column: span 2;
}

.legal-editor {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 202, 47, 0.16);
  border-radius: 8px;
  background: rgba(6, 18, 30, 0.36);
}

.legal-editor h3 {
  margin: 0;
  font-size: 15px;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid rgba(183, 199, 210, 0.18);
  border-radius: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.check-line input {
  width: auto;
  min-height: auto;
  margin: 0;
}

.check-line.has-inline-save .field-save-button {
  margin-left: auto;
}

.panel.wide {
  grid-column: span 3;
}

.accounts-list {
  display: grid;
  gap: 10px;
}

.account-row {
  display: grid;
  grid-template-columns: minmax(190px, 1.4fr) repeat(4, minmax(130px, 1fr)) auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid rgba(255, 202, 47, 0.16);
  border-radius: 8px;
  background: rgba(6, 18, 30, 0.48);
}

.account-row label {
  gap: 4px;
}

.account-row .account-email {
  display: grid;
  gap: 4px;
  align-self: center;
}

.account-row .account-email strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-row small {
  color: var(--muted);
  font-size: 12px;
}

.account-row button {
  white-space: nowrap;
}

.account-search-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 12px;
  border: 1px solid rgba(29, 211, 189, 0.2);
  border-radius: 8px;
  background: rgba(29, 211, 189, 0.05);
}

.manual-account-editor {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid rgba(255, 202, 47, 0.22);
  border-radius: 8px;
  background: rgba(255, 202, 47, 0.06);
}

.manual-account-editor button {
  min-height: 42px;
  font-weight: 900;
}

.visitor-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
}

.visitor-summary div,
.visitor-row > div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid rgba(255, 202, 47, 0.14);
  border-radius: 8px;
  background: rgba(6, 18, 30, 0.44);
}

.visitor-summary span,
.visitor-row span {
  color: var(--muted);
  font-size: 12px;
}

.visitor-row {
  grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(130px, 0.35fr));
}

.wiki-editor-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.7fr);
  gap: 14px;
  align-items: start;
}

.wiki-article-browser,
.wiki-article-form {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.wiki-article-list {
  display: grid;
  gap: 8px;
  max-height: 620px;
  padding-right: 4px;
  overflow: auto;
}

.wiki-article-row {
  display: grid;
  gap: 5px;
  min-height: auto;
  padding: 10px;
  border-color: rgba(183, 199, 210, 0.2);
  background: rgba(6, 18, 30, 0.58);
  text-align: left;
}

.wiki-article-row:hover,
.wiki-article-row.active {
  border-color: rgba(29, 211, 189, 0.48);
  background: rgba(29, 211, 189, 0.1);
  color: var(--text);
}

.wiki-article-row strong {
  overflow-wrap: anywhere;
}

.wiki-article-row span,
.wiki-editor-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.wiki-editor-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(29, 211, 189, 0.2);
  border-radius: 8px;
  background: rgba(29, 211, 189, 0.06);
}

.wiki-editor-head h3 {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

.wiki-editor-actions {
  display: flex;
  justify-content: end;
}

.wiki-html-editor {
  min-height: 320px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
}

.small-link {
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

.blacklist-editor {
  grid-template-columns: minmax(220px, 0.8fr) minmax(260px, 1fr) auto;
}

.account-status-pill {
  width: fit-content;
  padding: 3px 7px;
  border: 1px solid rgba(255, 202, 47, 0.24);
  border-radius: 999px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
}

.account-status-pill.deleted {
  border-color: rgba(255, 103, 91, 0.36);
  color: #ffb4ad;
}

.overview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.account-search-row small {
  color: var(--muted);
  font-weight: 800;
}

.account-row {
  cursor: pointer;
}

.account-row:hover {
  border-color: rgba(29, 211, 189, 0.42);
}

.blacklist-row {
  grid-template-columns: minmax(240px, 1fr) minmax(260px, 1.4fr) auto;
}

.account-overview-drawer {
  width: min(640px, 100vw);
}

.account-overview-content {
  display: grid;
  gap: 14px;
}

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

.overview-item {
  display: grid;
  gap: 4px;
  padding: 11px;
  border: 1px solid rgba(255, 202, 47, 0.16);
  border-radius: 8px;
  background: rgba(6, 18, 30, 0.52);
}

.overview-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.overview-item strong {
  overflow-wrap: anywhere;
}

.overview-note {
  margin: 0;
  padding: 12px;
  border: 1px solid rgba(255, 202, 47, 0.18);
  border-radius: 8px;
  background: rgba(255, 202, 47, 0.06);
  color: var(--muted);
  line-height: 1.45;
}

.auth-panel {
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.8fr);
  align-items: end;
}

.admin-login-grid,
.two-factor-admin {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.admin-login-grid.single {
  grid-template-columns: 1fr;
}

.two-factor-admin {
  grid-column: span 2;
  grid-template-columns: minmax(220px, 0.9fr) minmax(160px, 1fr);
  padding: 10px;
  border: 1px solid rgba(255, 202, 47, 0.16);
  border-radius: 8px;
  background: rgba(6, 18, 30, 0.42);
}

.two-factor-admin select {
  min-width: 0;
  padding-right: 34px;
}

.two-factor-admin button {
  grid-column: 1 / -1;
}

.secondary {
  background: rgba(11, 23, 40, 0.78);
}

.auth-panel p,
.status {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid rgba(183, 199, 210, 0.26);
  border-radius: 7px;
  background: rgba(6, 18, 30, 0.78);
  color: var(--text);
  font: inherit;
}

.field-with-save {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.field-with-save.compact {
  gap: 6px;
}

.field-save-button {
  min-height: 40px;
  padding: 8px 10px;
  border-color: rgba(29, 211, 189, 0.28);
  background: rgba(29, 211, 189, 0.08);
  color: #dffbf7;
  font-size: 12px;
  white-space: nowrap;
}

.field-save-button:hover {
  background: #1dd3bd;
  color: #061421;
}

.field-save-button:disabled,
.field-save-button.saving {
  opacity: 0.74;
  cursor: wait;
}

.save-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  min-width: min(170px, 70vw);
  padding: 7px 10px;
  border: 1px solid rgba(54, 214, 122, 0.65);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(54, 214, 122, 0.98), rgba(24, 152, 82, 0.98));
  color: #042011;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  transform: translateY(24px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.save-toast.visible {
  transform: translateY(0);
  opacity: 1;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.tall-textarea {
  min-height: 190px;
}

.status {
  padding: 12px 14px;
  border: 1px solid rgba(29, 211, 189, 0.28);
  border-radius: 8px;
  background: rgba(29, 211, 189, 0.08);
}

@media (max-width: 860px) {
  .admin-header,
  .auth-panel,
  .admin-login-grid,
  .two-factor-admin {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .panel.wide {
    grid-column: auto;
  }

  .copy-grid,
  .legal-grid {
    grid-template-columns: 1fr;
  }

  .wide-field {
    grid-column: auto;
  }

  .account-row {
    grid-template-columns: 1fr;
  }

  .wiki-editor-layout {
    grid-template-columns: 1fr;
  }

  .wiki-article-list {
    max-height: 360px;
    padding-right: 0;
  }

  .wiki-editor-head,
  .wiki-editor-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .field-with-save {
    grid-template-columns: 1fr;
  }

  .check-line.has-inline-save {
    flex-wrap: wrap;
  }

  .check-line.has-inline-save .field-save-button {
    margin-left: 0;
  }
}
