:root {
  --bg: #eef2f6;
  --panel: #ffffff;
  --ink: #1c2a3a;
  --muted: #5d6d7e;
  --line: #d7e0ea;
  --brand: #1a6f8a;
  --brand-dark: #14586c;
  --danger: #b42318;
  --ok: #157a4b;
  --shadow: 0 12px 40px rgba(28, 42, 58, 0.08);
  --radius: 14px;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 10% 10%, #d7ebf3 0, transparent 42%),
    radial-gradient(circle at 90% 90%, #dfe7f2 0, transparent 40%),
    var(--bg);
}

.auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
}

.eyebrow {
  color: var(--brand);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 0 8px;
}

h1, h2 { margin: 0 0 8px; }
.lead { color: var(--muted); margin: 0 0 24px; line-height: 1.5; }
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.field { margin-bottom: 14px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fbfcfe;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid #b7d7e3;
  border-color: var(--brand);
}
.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--brand);
  color: white;
  font-weight: 600;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.secondary { background: #e8eef3; color: var(--ink); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #8f1d16; }
.btn.ghost { background: transparent; color: var(--brand); padding-inline: 8px; }
.full { width: 100%; }
.alert {
  background: #fdecec;
  color: var(--danger);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  display: none;
}
.alert.show { display: block; }
.alert.ok {
  background: #e7f6ee;
  color: var(--ok);
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.side {
  background: #123040;
  color: #e8f2f6;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand { font-weight: 700; font-size: 18px; }
.brand small { display: block; font-weight: 400; color: #9db8c4; margin-top: 4px; }
.nav button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #d5e6ed;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
}
.nav button.active, .nav button:hover { background: rgba(255,255,255,0.08); }
.who { margin-top: auto; font-size: 13px; color: #b7cdd6; }
.who strong { color: white; }

.main { padding: 28px; }
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 16px 0 18px;
  flex-wrap: wrap;
}
.toolbar input { max-width: 320px; background: white; }
.toolbar #hosts-total { margin-left: auto; font-weight: 600; color: var(--ink); }
.pager {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
  flex-wrap: wrap;
}
.page-size-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.page-size-wrap select {
  width: auto;
  min-width: 72px;
  padding: 8px 10px;
  background: white;
}
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-weight: 600; background: #f7fafc; }
tr:last-child td { border-bottom: 0; }
.empty { padding: 36px; color: var(--muted); text-align: center; }
.badge {
  display: inline-block;
  background: #e7f3f7;
  color: var(--brand-dark);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
}
.badge.warn { background: #fdecec; color: var(--danger); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 32, 44, 0.45);
  display: none;
  place-items: center;
  padding: 20px;
}
.modal-backdrop.show { display: grid; }
.modal {
  width: min(560px, 100%);
  background: white;
  border-radius: 16px;
  padding: 22px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-span { grid-column: 1 / -1; }
.check-list {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  padding: 8px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.check-list input[type="search"] {
  margin-bottom: 8px;
  flex-shrink: 0;
}
.check-items {
  height: 128px;
  overflow-y: auto;
  flex: none;
}
.check-list label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 6px 4px;
  color: var(--ink);
  font-size: 14px;
}
.check-list input { width: auto; margin-top: 3px; }
.check-list .muted { color: var(--muted); font-size: 12px; }
td .muted { color: var(--muted); font-size: 12px; }
th.check, td.check { width: 36px; padding-right: 0; }
td.check input, th.check input { width: auto; }
.toggle-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 8px;
  font-weight: 600;
}
.toggle-field input { width: auto; }
.field-disabled { opacity: 0.45; pointer-events: none; }
input.occupant {
  width: 5.8em;
  min-width: 5.8em;
  padding: 6px 8px;
  letter-spacing: 0.04em;
}
input.remark {
  width: 12em;
  min-width: 8em;
  max-width: 100%;
  padding: 6px 8px;
}
.hint.warn { color: var(--danger); }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.hidden { display: none !important; }
.mono { font-family: Consolas, "Courier New", monospace; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.token-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 8px 0 12px;
}
.token-row input { flex: 1; }
.ext-link {
  color: var(--brand);
  text-decoration: none;
  word-break: break-all;
}
.ext-link:hover { text-decoration: underline; }
td .btn.ghost { white-space: nowrap; }
.code {
  background: #123040;
  color: #e8f2f6;
  border-radius: 10px;
  padding: 14px;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 13px;
}
tr.expired td { color: var(--danger); }
#toggle-auth { margin-top: 12px; }

@media (max-width: 840px) {
  .app { grid-template-columns: 1fr; }
  .side { flex-direction: row; align-items: center; gap: 12px; }
  .nav { display: flex; gap: 4px; }
  .who { margin-top: 0; margin-left: auto; }
  .grid2 { grid-template-columns: 1fr; }
}
