:root {
  color-scheme: dark;
  --bg: #090d13;
  --panel: #121923;
  --panel-raised: #17202c;
  --field: #0b1119;
  --line: #2a3647;
  --line-soft: #202a38;
  --text: #f2f5f9;
  --muted: #9aa8ba;
  --accent: #f2b544;
  --accent-hover: #ffc95e;
  --success: #7dd9aa;
  --danger: #ff9292;
  font-family:
    Inter, "Microsoft YaHei UI", "PingFang SC", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 16% 0%, rgba(242, 181, 68, 0.09), transparent 30rem),
    linear-gradient(145deg, #080b10 0%, #0c121a 58%, #090d13 100%);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a,
a:visited {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

button,
input {
  font: inherit;
}

button {
  min-height: 46px;
  padding: 0 20px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  box-shadow: 0 8px 22px rgba(242, 181, 68, 0.12);
  color: #171006;
  cursor: pointer;
  font-weight: 800;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    opacity 140ms ease,
    transform 120ms ease;
}

button:hover {
  background: var(--accent-hover);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(242, 181, 68, 0.45);
  outline-offset: 3px;
}

.shell {
  width: min(720px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(34px, 7vh, 72px) 0 56px;
}

.shell-admin {
  width: min(1080px, calc(100% - 32px));
}

.shell-auth {
  position: relative;
  width: min(480px, calc(100% - 32px));
  margin: clamp(28px, 8vh, 82px) auto 40px;
  padding: 34px 38px 38px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(155deg, rgba(23, 32, 44, 0.98), rgba(15, 21, 30, 0.98));
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.42);
}

.shell-auth::before {
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), transparent 72%);
  content: "";
}

.card {
  position: relative;
  overflow: hidden;
  padding: clamp(30px, 5vw, 42px);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(155deg, rgba(23, 32, 44, 0.98), rgba(15, 21, 30, 0.98));
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.4);
}

.card::before {
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), transparent 72%);
  content: "";
}

.eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 9px 0 8px;
  font-size: clamp(34px, 6vw, 46px);
  line-height: 1.12;
  letter-spacing: -0.035em;
}

.welcome {
  margin: 0 0 26px;
}

.welcome h1 {
  margin-bottom: 8px;
}

.intro,
.hint,
.privacy,
.section-copy,
.field-hint {
  color: var(--muted);
}

.intro {
  margin: 0 0 30px;
  font-size: 15px;
}

.welcome .intro {
  margin-bottom: 0;
}

label {
  display: block;
  margin-bottom: 8px;
  color: #d9e0e9;
  font-size: 13px;
  font-weight: 700;
}

input {
  width: 100%;
  min-width: 0;
  height: 50px;
  padding: 0 15px;
  border: 1px solid #354359;
  border-radius: 10px;
  outline: none;
  background: var(--field);
  color: var(--text);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

input:hover {
  border-color: #45556d;
}

input:focus {
  border-color: var(--accent);
  background: #0d141e;
  box-shadow: 0 0 0 3px rgba(242, 181, 68, 0.12);
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.auth-card {
  padding: 26px 0 0;
  overflow: visible;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.auth-card::before {
  display: none;
}

.auth-card h2,
.admin-section h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.3;
}

.section-copy {
  margin: 7px 0 20px;
  font-size: 14px;
  line-height: 1.65;
}

.stack-form {
  display: grid;
  gap: 8px;
}

.stack-form label:not(:first-of-type) {
  margin-top: 7px;
}

.stack-form input {
  height: 48px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.stack-form button {
  width: 100%;
  margin-top: 12px;
}

.auth-switch {
  margin: 20px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.auth-switch a {
  margin-left: 5px;
  color: var(--accent);
  font-weight: 750;
}

.auth-switch a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.field-hint {
  margin: -2px 0 1px;
  font-size: 12px;
  line-height: 1.5;
}

.flash {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid #435169;
  border-radius: 10px;
  background: rgba(20, 28, 39, 0.96);
  color: var(--text);
  font-size: 13px;
}

.flash[data-type="success"] {
  border-color: rgba(125, 217, 170, 0.46);
  color: var(--success);
}

.flash[data-type="error"] {
  border-color: rgba(255, 146, 146, 0.46);
  color: var(--danger);
}

.account-bar,
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.account-bar {
  margin: 0 0 28px;
  padding: 0 0 17px;
  border-bottom: 1px solid var(--line-soft);
}

.account-bar > div {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 8px;
}

.account-bar strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-label {
  flex: none;
  color: var(--muted);
  font-size: 12px;
}

.account-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 7px;
}

.account-actions form {
  margin: 0;
}

.text-link,
.link-button,
.link-button:visited {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 11px;
  border: 1px solid #37455a;
  border-radius: 9px;
  background: transparent;
  box-shadow: none;
  color: #d8e0eb;
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.text-link:hover,
button.link-button:hover {
  border-color: #53647c;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  text-decoration: none;
}

button.link-button {
  height: 34px;
  min-height: 34px;
  appearance: none;
}

.quota-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 22px;
  padding: 12px 15px;
  border: 1px solid #314055;
  border-radius: 11px;
  background: rgba(9, 14, 21, 0.55);
  color: var(--muted);
  font-size: 13px;
}

.quota-panel strong {
  color: var(--accent);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 20px;
}

.hint {
  margin: 8px 0 0;
  font-size: 12px;
}

.status {
  min-height: 22px;
  margin-top: 18px;
  font-size: 13px;
}

.status[data-type="working"] {
  color: var(--accent);
}

.status[data-type="success"] {
  color: var(--success);
}

.status[data-type="error"] {
  color: var(--danger);
}

.result {
  margin-top: 20px;
  padding: 20px;
  border: 1px solid #334157;
  border-radius: 14px;
  background: var(--panel-raised);
}

.result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.result-label {
  color: var(--muted);
  font-size: 11px;
}

.result h2 {
  margin: 3px 0 0;
  font-size: 17px;
}

.secondary {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #46556c;
  background: transparent;
  box-shadow: none;
  color: #dce3ed;
  font-size: 12px;
}

.secondary:hover {
  background: #202a39;
}

.code {
  display: block;
  margin: 20px 0;
  color: var(--accent-hover);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: clamp(20px, 5vw, 28px);
  font-weight: 800;
  letter-spacing: 0.055em;
  overflow-wrap: anywhere;
}

.download {
  width: 100%;
}

.install-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.install-note code {
  color: #dfe6ef;
  font-family: Consolas, "SFMono-Regular", monospace;
  overflow-wrap: anywhere;
}

.privacy {
  margin: 16px 0 0;
  text-align: center;
  font-size: 11px;
}

.admin-header {
  margin-bottom: 18px;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(18, 25, 35, 0.88);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.22);
}

.admin-header h1 {
  margin: 3px 0 2px;
  font-size: 28px;
  letter-spacing: -0.025em;
}

.admin-header .intro {
  margin: 0;
  font-size: 13px;
}

.admin-section {
  padding: 27px 30px 30px;
}

.admin-section + .admin-section {
  margin-top: 18px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.section-heading .section-copy {
  max-width: 680px;
  margin-bottom: 0;
}

.count-badge {
  flex: none;
  padding: 5px 9px;
  border: 1px solid #3a475b;
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(8, 13, 20, 0.32);
  scrollbar-color: #46546a transparent;
}

table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 15px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

thead th {
  background: rgba(9, 14, 21, 0.5);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

thead th:nth-child(1) {
  width: 26%;
}

thead th:nth-child(2) {
  width: 15%;
}

thead th:nth-child(3) {
  width: 39%;
}

thead th:nth-child(4) {
  width: 20%;
}

.log-table thead th:nth-child(1) {
  width: 30%;
}

.log-table thead th:nth-child(2) {
  width: 30%;
}

.log-table thead th:nth-child(3) {
  width: 40%;
}

.serial-cell {
  color: var(--accent-hover);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
  letter-spacing: 0.05em;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.page-link,
.page-link:visited {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid #37455a;
  border-radius: 8px;
  color: #d8e0eb;
  font-size: 12px;
  font-weight: 750;
}

.page-link:hover {
  border-color: #53647c;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
}

.page-link.is-disabled {
  cursor: default;
  opacity: 0.4;
}

.page-status {
  color: var(--muted);
  font-size: 12px;
}

tbody th {
  color: var(--text);
  font-size: 14px;
}

tbody tr:last-child > * {
  border-bottom: 0;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

.quota-form {
  display: grid;
  grid-template-columns: 112px auto;
  align-items: center;
  justify-content: start;
  gap: 8px;
}

.quota-input {
  width: 112px;
  height: 36px;
  padding: 0 10px;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 14px;
  letter-spacing: 0;
  text-transform: none;
}

.compact-button,
.danger-button {
  min-height: 36px;
  padding: 0 13px;
  border-radius: 8px;
  box-shadow: none;
  font-size: 12px;
}

.muted-cell {
  color: var(--muted);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
}

.whitelist-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.whitelist-add input {
  width: 100%;
}

#whitelist-serial {
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 16px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.empty-state {
  margin: 18px 0 0;
  padding: 16px;
  border: 1px dashed #3a475b;
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.whitelist-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 9px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.whitelist-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px 9px 13px;
  border: 1px solid #314055;
  border-radius: 10px;
  background: var(--field);
}

.whitelist-list code {
  color: var(--accent-hover);
  font-size: 13px;
  letter-spacing: 0.05em;
}

.danger-button {
  border: 1px solid rgba(255, 146, 146, 0.46);
  background: transparent;
  color: var(--danger);
}

.danger-button:hover {
  background: rgba(255, 146, 146, 0.1);
}

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

[hidden] {
  display: none !important;
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 24px, 720px);
    padding: 24px 0 40px;
  }

  .shell-auth {
    width: min(100% - 24px, 480px);
    margin: 20px auto 32px;
    padding: 28px 26px 30px;
  }

  .admin-header {
    align-items: stretch;
    flex-direction: column;
    gap: 13px;
  }

  .admin-header .account-actions {
    padding-top: 12px;
    border-top: 1px solid var(--line-soft);
  }

  .admin-section {
    padding: 24px 22px 26px;
  }
}

@media (max-width: 560px) {
  .card {
    padding: 24px 20px;
    border-radius: 16px;
  }

  .shell-auth {
    padding: 25px 20px 27px;
    border-radius: 16px;
  }

  .shell-auth .auth-card {
    padding: 23px 0 0;
  }

  h1 {
    font-size: 32px;
  }

  .input-row,
  .whitelist-add {
    grid-template-columns: 1fr;
  }

  .input-row button,
  .whitelist-add button {
    width: 100%;
  }

  .account-bar {
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
  }

  .account-bar > div {
    flex: 1 1 180px;
  }

  .account-actions {
    gap: 6px;
  }

  .text-link,
  .link-button,
  button.link-button {
    min-height: 32px;
    height: 32px;
    padding: 0 9px;
  }

  .result-head {
    align-items: stretch;
    flex-direction: column;
  }

  .result-head .secondary {
    align-self: flex-start;
  }

  .section-heading {
    gap: 10px;
  }

  .section-heading h2 {
    font-size: 20px;
  }

  table {
    min-width: 640px;
  }
}
