:root {
  --bg: #111318;
  --panel: #1b1f27;
  --panel-2: #232936;
  --line: #303848;
  --text: #f4f7fb;
  --muted: #9aa7b8;
  --blue: #168df2;
  --green: #54c88a;
  --red: #ff7373;
  --yellow: #ffd36a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  height: 38px;
  padding: 0 16px;
  font-weight: 700;
}

button.ghost {
  border: 1px solid var(--line);
  background: transparent;
}

button.small {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  background: #11151d;
  color: var(--text);
  padding: 0 10px;
}

select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  background: #11151d;
  color: var(--text);
  padding: 0 10px;
}

textarea {
  width: 100%;
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  background: #11151d;
  color: var(--text);
  padding: 10px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
}

label {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

label input {
  margin-top: 6px;
}

label input[type="checkbox"] {
  width: auto;
  height: auto;
  margin: 0;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px;
  border-bottom: 1px solid var(--line);
  background: #171b23;
}

.top h1 {
  margin: 0 0 6px;
  font-size: 22px;
}

.top p {
  margin: 0;
  color: var(--muted);
}

.page {
  max-width: 1360px;
  margin: 0 auto;
  padding: 24px;
}

.admin-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.admin-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 136px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
}

.admin-nav a:hover {
  border-color: var(--line);
  color: var(--text);
}

.admin-nav a.active {
  border-color: rgba(22, 141, 242, 0.55);
  background: rgba(22, 141, 242, 0.16);
  color: #fff;
}

.warning {
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 211, 106, 0.35);
  border-radius: 8px;
  background: rgba(255, 211, 106, 0.1);
  color: var(--yellow);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stats div,
.panel,
.login-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.stats div {
  padding: 18px;
}

.stats b {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.stats span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.panel {
  margin-bottom: 18px;
  padding: 18px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

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

.panel-title-row h2 {
  margin: 0;
}

.forms {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.forms form {
  display: grid;
  gap: 12px;
}

.settings-form {
  display: grid;
  gap: 12px;
}

.risk-form {
  gap: 16px;
}

.risk-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.setting-field {
  display: grid;
  gap: 8px;
  width: fit-content;
}

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

.setting-select {
  min-width: 180px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.muted {
  color: var(--muted);
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.hint-block span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.account-table {
  margin-top: 16px;
}

.error-cell {
  max-width: 260px;
  color: var(--muted);
  font-size: 12px;
  white-space: normal;
  word-break: break-word;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
}

.tag.active,
.tag.succeeded,
.tag.ok {
  background: rgba(84, 200, 138, 0.14);
  color: var(--green);
}

.tag.disabled,
.tag.failed {
  background: rgba(255, 115, 115, 0.14);
  color: var(--red);
}

.tag.unknown,
.tag.missing,
.tag.cookie_only,
.tag.refreshing {
  background: rgba(255, 211, 106, 0.12);
  color: var(--yellow);
}

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

.actions form {
  display: flex;
  gap: 6px;
}

.actions input {
  width: 70px;
  height: 30px;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-box {
  width: min(420px, calc(100vw - 32px));
  padding: 28px;
}

.login-box h1 {
  margin: 0 0 8px;
}

.login-box p {
  margin: 0 0 20px;
  color: var(--muted);
}

.login-box form {
  display: grid;
  gap: 12px;
}

.alert {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 6px;
  background: rgba(255, 115, 115, 0.14);
  color: var(--red);
}

@media (max-width: 900px) {
  .admin-nav {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-nav a {
    width: 100%;
  }

  .stats,
  .forms,
  .grid {
    grid-template-columns: 1fr;
  }
}
