:root {
  --bg0: #0b1218;
  --bg1: #121c26;
  --bg2: #182430;
  --line: rgba(140, 170, 190, 0.18);
  --text: #edf3f7;
  --muted: #8ea3b5;
  --accent: #2fd6a1;
  --accent-2: #3ec4e8;
  --accent-dim: #1fa879;
  --danger: #ff7b7b;
  --ok-bg: rgba(47, 214, 161, 0.12);
  --err-bg: rgba(255, 123, 123, 0.12);
  --radius: 18px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-body: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Consolas", "Courier New", monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html, body {
  margin: 0;
  padding: 0;
}
body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg0);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
body.page-home {
  background:
    radial-gradient(900px 520px at 50% -12%, rgba(47, 214, 161, 0.16), transparent 60%),
    radial-gradient(700px 420px at 100% 8%, rgba(62, 196, 232, 0.12), transparent 55%),
    radial-gradient(600px 400px at 0% 40%, rgba(30, 80, 120, 0.18), transparent 50%),
    var(--bg0);
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  inset: auto -20% -10% -20%;
  height: 40vh;
  background: radial-gradient(ellipse at center, rgba(47, 214, 161, 0.08), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* —— 通用布局（后台 / 安装） —— */
.wrap {
  width: min(640px, calc(100% - 2rem));
  margin: 0 auto;
  padding: calc(1.5rem + var(--safe-top)) 0 calc(2.5rem + var(--safe-bottom));
  position: relative;
  z-index: 1;
}
.wrap.wide { width: min(1100px, calc(100% - 1.25rem)); }
.wrap.narrow { width: min(420px, calc(100% - 2rem)); }

.hero h1 {
  margin: 0.25rem 0 0.5rem;
  font-family: var(--font);
  font-size: clamp(1.55rem, 5vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.25;
}
.hero .lead { margin: 0; color: var(--muted); }
.eyebrow {
  margin: 0;
  color: var(--accent);
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.hero.row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
}
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.panel {
  margin-top: 1.15rem;
  padding: 1.2rem 1.25rem;
  background: rgba(18, 28, 38, 0.86);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.panel h2 {
  margin: 0 0 0.75rem;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
}

.ip {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(1.45rem, 7vw, 2rem);
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.03em;
  word-break: break-all;
  line-height: 1.3;
}
.ip-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  margin: 0.7rem 0 0;
  color: #c5d5e2;
  font-size: 0.95rem;
  line-height: 1.4;
}
.ip-meta.muted {
  color: var(--muted);
  font-size: 0.84rem;
}
.carrier-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(47, 214, 161, 0.14);
  border: 1px solid rgba(47, 214, 161, 0.35);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.hint { margin: 0.55rem 0 0; color: var(--muted); font-size: 0.88rem; }
.tips li { color: var(--muted); font-size: 0.92rem; }

label {
  display: block;
  margin: 0;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
}
.req { color: var(--danger); }
.opt {
  margin-left: 0.35rem;
  font-size: 0.75rem;
  color: #6e8496;
  font-weight: 400;
}

.field { margin-top: 1rem; }
.field label { margin-bottom: 0.4rem; }

input[type="text"],
input[type="password"],
input[type="search"],
textarea {
  width: 100%;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg2);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* 避免 iOS 聚焦放大 */
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus {
  outline: none;
  border-color: rgba(47, 214, 161, 0.55);
  box-shadow: 0 0 0 3px rgba(47, 214, 161, 0.18);
}
textarea {
  resize: vertical;
  min-height: 6rem;
  line-height: 1.5;
}

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1rem;
  min-height: 48px;
  padding: 0.8rem 1.15rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent) 0%, #28c4b8 100%);
  color: #062218;
  font-family: var(--font);
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, filter 0.12s ease, opacity 0.12s ease;
}
button:hover, .btn:hover { filter: brightness(1.06); }
button:active, .btn:active { transform: scale(0.98); }
button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.ghost {
  margin-top: 0;
  min-height: 42px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 600;
  box-shadow: none;
}
.btn.ghost:hover {
  filter: none;
  border-color: rgba(47, 214, 161, 0.55);
  color: var(--accent);
}

.btn-primary {
  width: 100%;
  margin-top: 1.25rem;
  min-height: 52px;
  letter-spacing: 0.02em;
}

.msg {
  margin-top: 1rem;
  padding: 0.85rem 0.95rem;
  border-radius: 12px;
  background: var(--ok-bg);
  border: 1px solid rgba(47, 214, 161, 0.35);
  font-size: 0.92rem;
}
.msg.error {
  background: var(--err-bg);
  border-color: rgba(255, 123, 123, 0.4);
  color: #ffc9c9;
}

.tips { margin-top: 1.5rem; }
.tips h2 { font-size: 1rem; margin: 0 0 0.5rem; font-family: var(--font); }
.tips ul { margin: 0; padding-left: 1.2rem; }

.search-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.search-row input { flex: 1; min-width: 160px; }
.search-row button { margin-top: 0; }

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  background: var(--bg2);
}
.mono { font-family: var(--mono); }
.ua { color: var(--muted); max-width: 220px; }
.empty { text-align: center; color: var(--muted); padding: 2rem; }
td a { color: var(--accent); text-decoration: none; }
td a:hover { text-decoration: underline; }

.pager {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  margin-top: 1.25rem;
  color: var(--muted);
  flex-wrap: wrap;
}
.pager a { color: var(--accent); }

/* —— 首页 —— */
.home {
  position: relative;
  z-index: 1;
  width: min(480px, 100%);
  margin: 0 auto;
  padding:
    calc(1.35rem + var(--safe-top))
    max(1rem, var(--safe-right))
    calc(1.75rem + var(--safe-bottom))
    max(1rem, var(--safe-left));
}

.home-hero {
  text-align: center;
  padding: 0.5rem 0.25rem 1.1rem;
}
.brand-name {
  margin: 0 0 0.35rem;
  font-family: var(--font);
  font-size: clamp(1.35rem, 5vw, 1.7rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  background: linear-gradient(120deg, #7ff0c8 0%, #5ad0ef 55%, #edf3f7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  position: relative;
  display: grid;
  place-items: center;
}
.brand-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(47, 214, 161, 0.35);
  box-shadow: 0 0 0 8px rgba(47, 214, 161, 0.06);
  animation: spin-slow 12s linear infinite;
}
.brand-ring::after {
  content: "";
  position: absolute;
  top: -3px;
  left: 50%;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 12px var(--accent-2);
}
.brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 20px rgba(47, 214, 161, 0.55);
}
.home-hero h1 {
  margin: 0.45rem 0 0.65rem;
  font-family: var(--font);
  font-size: clamp(1.65rem, 6.5vw, 2.15rem);
  font-weight: 700;
  line-height: 1.28;
  letter-spacing: -0.01em;
}
.home-hero .lead {
  margin: 0 auto;
  max-width: 34em;
  color: var(--muted);
  font-size: 0.95rem;
}

.ip-card,
.form-card,
.tips-card,
.notice-card {
  margin-top: 0.9rem;
  padding: 1.15rem 1.15rem 1.2rem;
  background: rgba(18, 28, 38, 0.88);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.notice-card {
  padding: 0.95rem 1.05rem;
  background: rgba(62, 196, 232, 0.08);
  border-color: rgba(62, 196, 232, 0.28);
  box-shadow: none;
}
.notice-card p {
  margin: 0;
  color: #b7c9d6;
  font-size: 0.86rem;
  line-height: 1.6;
}
.notice-card strong {
  color: var(--accent-2);
  font-weight: 600;
}

.already-card {
  margin-top: 0.9rem;
  padding: 1.1rem 1.15rem;
  background: rgba(47, 214, 161, 0.1);
  border: 1px solid rgba(47, 214, 161, 0.35);
  border-radius: calc(var(--radius) + 2px);
}
.already-title {
  margin: 0 0 0.4rem;
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
}
.already-card > p {
  margin: 0;
  color: #c5d5e2;
  font-size: 0.9rem;
  line-height: 1.55;
}
.already-wait {
  margin-top: 0.65rem !important;
  color: var(--accent) !important;
  font-weight: 600;
}

form.is-disabled fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
  opacity: 0.72;
}

.ip-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}
.ip-card h2,
.form-card h2,
.tips-card h2 {
  margin: 0;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
}
.section-desc {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  background: rgba(47, 214, 161, 0.1);
  border: 1px solid rgba(47, 214, 161, 0.28);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(47, 214, 161, 0.55);
  animation: pulse 1.8s ease-out infinite;
}

.tip-list {
  list-style: none;
  margin: 0.95rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.85rem;
}
.tip-list li {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 0.75rem;
  align-items: start;
}
.tip-num {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(62, 196, 232, 0.12);
  border: 1px solid rgba(62, 196, 232, 0.28);
  color: var(--accent-2);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 700;
}
.tip-list strong {
  display: block;
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}
.tip-list p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.home-foot {
  margin-top: 1.35rem;
  text-align: center;
  color: #6d8294;
  font-size: 0.8rem;
}
.home-foot p { margin: 0; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(47, 214, 161, 0.5); }
  70% { box-shadow: 0 0 0 10px rgba(47, 214, 161, 0); }
  100% { box-shadow: 0 0 0 0 rgba(47, 214, 161, 0); }
}
@keyframes spin-slow {
  to { transform: rotate(360deg); }
}

@media (min-width: 640px) {
  .home {
    width: min(520px, 100%);
    padding-top: calc(2.25rem + var(--safe-top));
  }
  .ip-card,
  .form-card,
  .tips-card {
    padding: 1.35rem 1.4rem 1.4rem;
  }
  .notice-card {
    padding: 1.05rem 1.2rem;
  }
}

@media (max-width: 640px) {
  th:nth-child(9), td:nth-child(9) { display: none; }
  .wrap.wide { width: calc(100% - 0.75rem); }
  .actions { width: 100%; }
  .actions .btn { flex: 1; min-width: calc(50% - 0.25rem); }
  .hero.row { gap: 0.75rem; }
  table { font-size: 0.82rem; }
  th, td { padding: 0.65rem 0.6rem; }
  .ops-cell { min-width: 7rem; }
}

/* 后台状态 */
.status-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}
.status-tab {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}
.status-tab.active,
.status-tab:hover {
  color: var(--accent);
  border-color: rgba(47, 214, 161, 0.45);
  background: rgba(47, 214, 161, 0.08);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.status-pending {
  color: #f0c674;
  background: rgba(240, 198, 116, 0.12);
  border: 1px solid rgba(240, 198, 116, 0.35);
}
.status-handled {
  color: var(--accent-2);
  background: rgba(62, 196, 232, 0.12);
  border: 1px solid rgba(62, 196, 232, 0.35);
}
.status-done {
  color: var(--accent);
  background: rgba(47, 214, 161, 0.12);
  border: 1px solid rgba(47, 214, 161, 0.35);
}

.row-status-handled { background: rgba(62, 196, 232, 0.04); }
.row-status-done { background: rgba(47, 214, 161, 0.06); }

.ops-cell {
  white-space: nowrap;
}
.check-op {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  margin: 0.15rem 0.45rem 0.15rem 0;
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
  user-select: none;
}
.check-op input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.btn-delete {
  display: inline-flex;
  align-items: center;
  margin: 0.25rem 0 0;
  min-height: 30px;
  padding: 0.25rem 0.55rem;
  border: 1px solid rgba(255, 123, 123, 0.45);
  border-radius: 8px;
  background: rgba(255, 123, 123, 0.1);
  color: #ffb4b4;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-delete:hover {
  background: rgba(255, 123, 123, 0.2);
  filter: none;
}
.btn-delete:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.admin-note-cell { min-width: 140px; }
.admin-note-input {
  width: 100%;
  min-width: 120px;
  margin: 0;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg2);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
}
.admin-note-input:focus {
  outline: none;
  border-color: rgba(47, 214, 161, 0.55);
}
.admin-note-input.saved {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(47, 214, 161, 0.2);
}

.backend-table th:first-child,
.backend-table td:first-child {
  position: sticky;
  left: 0;
  background: var(--bg1);
  z-index: 1;
}

@media (max-width: 380px) {
  .home-hero h1 { font-size: 1.5rem; }
  .ip { font-size: 1.3rem; }
  .tip-list li { grid-template-columns: 32px 1fr; gap: 0.6rem; }
  .tip-num { width: 32px; height: 32px; border-radius: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .brand-ring, .pulse { animation: none; }
  button, .btn { transition: none; }
}

@supports not (height: 100dvh) {
  body { min-height: 100vh; }
}
