/* ============ 基础与主题变量 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f0f3f8;
  --card: #ffffff;
  --card-glass: rgba(255, 255, 255, 0.82);
  --text: #1e293b;
  --text2: #64748b;
  --muted: #94a3b8;
  --line: #e2e8f0;
  --brand: #3b82f6;
  --brand-soft: rgba(59, 130, 246, 0.12);
  --ok: #22c55e;
  --bad: #ef4444;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-hover: 0 10px 24px rgba(15, 23, 42, 0.13);
}

html[data-theme="dark"] {
  --bg: #0b1220;
  --card: #141d31;
  --card-glass: rgba(20, 29, 49, 0.85);
  --text: #e2e8f0;
  --text2: #8ea0bd;
  --muted: #5b6b88;
  --line: #22304d;
  --brand: #60a5fa;
  --brand-soft: rgba(96, 165, 250, 0.16);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 10px 24px rgba(0, 0, 0, 0.5);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }

/* ============ 顶栏 ============ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: 13px 28px;
  background: var(--card-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand .logo { font-size: 26px; line-height: 1; }
.brand h1 { font-size: 19px; font-weight: 700; white-space: nowrap; }

.search-box { flex: 1; max-width: 480px; margin: 0 auto; position: relative; }
.search-box::before {
  content: '🔍'; position: absolute; left: 13px; top: 50%;
  transform: translateY(-50%); font-size: 13px; opacity: 0.6; pointer-events: none;
}
.search-box input {
  width: 100%; padding: 9px 16px 9px 36px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg); outline: none; transition: 0.2s;
}
.search-box input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.top-actions { display: flex; gap: 8px; align-items: center; flex: none; margin-left: auto; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card);
  cursor: pointer; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: 0.15s; text-align: center; line-height: 1;
}
.icon-btn:hover { border-color: var(--brand); }

/* ============ 首页主体 ============ */
.main { max-width: 1200px; width: 100%; margin: 0 auto; padding: 30px 28px 40px; flex: 1; }
.group { margin-bottom: 34px; }
.group-title {
  font-size: 16px; font-weight: 700; margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.group-title::before {
  content: ''; width: 4px; height: 16px; border-radius: 2px;
  background: var(--brand); display: inline-block;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}
.card {
  display: flex; gap: 12px; align-items: center;
  padding: 16px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow); transition: 0.18s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: var(--brand); }
.card-icon {
  width: 46px; height: 46px; flex: none; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; overflow: hidden;
}
.card-body { min-width: 0; }
.card-name { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 15px; }
.card-name .name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-desc {
  font-size: 12.5px; color: var(--text2); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-url {
  font-size: 11.5px; color: var(--muted); margin-top: 5px;
  font-family: ui-monospace, Consolas, monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 在线状态圆点 */
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.unknown { background: var(--muted); }
.dot.online { background: var(--ok); box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18); }
.dot.offline { background: var(--bad); box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15); }

.empty { text-align: center; padding: 80px 20px; color: var(--text2); }
.empty .big { font-size: 18px; margin-bottom: 10px; }
.empty a { color: var(--brand); }
.load-error { text-align: center; padding: 80px 20px; color: var(--bad); }

.footer {
  text-align: center; padding: 18px; color: var(--muted);
  font-size: 12.5px; border-top: 1px solid var(--line);
}

/* ============ 管理页通用 ============ */
.back { color: var(--text2); font-size: 14px; white-space: nowrap; }
.back:hover { color: var(--brand); }
.admin-wrap { max-width: 1100px; width: 100%; margin: 0 auto; padding: 24px 20px 60px; flex: 1; }

.toolbar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }

.btn {
  padding: 9px 18px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card);
  cursor: pointer; transition: 0.15s;
}
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }

.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 20px 22px;
  margin-bottom: 20px; box-shadow: var(--shadow);
}
.panel h2 { font-size: 16px; margin-bottom: 14px; }

.row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; flex-wrap: wrap; }
.row input, .row select {
  padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 9px; background: var(--bg); outline: none; min-width: 0;
}
.row input:focus, .row select:focus { border-color: var(--brand); }
.row .lbl { flex: none; width: 52px; color: var(--text2); font-size: 14px; }
.row input.w-icon { width: 64px; text-align: center; }

.row-ops { display: flex; gap: 4px; flex: none; margin-left: auto; }
.row-ops .icon-btn { width: 30px; height: 30px; font-size: 13px; border-radius: 8px; }

.group-row input { flex: 1; }

.service-row {
  display: grid;
  grid-template-columns: 64px 1.1fr 1.6fr 1.2fr 110px auto;
  gap: 8px; align-items: center;
}
.service-row .row-ops { margin-left: 0; }
.row.head { color: var(--text2); font-size: 12.5px; margin-bottom: 10px; }
.row.head span { flex: none; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0; }
.panel .btn { margin-top: 6px; }

@media (max-width: 900px) {
  .service-row { grid-template-columns: 56px 1fr auto; }
  .service-row .f-url, .service-row .f-desc, .service-row select { grid-column: 1 / -1; }
  .row.head { display: none; }
  .brand h1 { display: none; }
  .topbar { padding: 12px 14px; gap: 10px; }
  .main { padding: 20px 14px 40px; }
}

/* ============ 登录卡片 ============ */
.auth-wrap { display: flex; justify-content: center; padding-top: 12vh; }
.auth-card {
  width: 340px; background: var(--card);
  border: 1px solid var(--line); border-radius: 16px;
  padding: 34px 30px; box-shadow: var(--shadow); text-align: center;
}
.auth-card .logo { font-size: 44px; }
.auth-card h2 { margin: 10px 0 22px; font-size: 18px; }
.auth-card input {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); margin-bottom: 12px; outline: none;
}
.auth-card input:focus { border-color: var(--brand); }
.auth-card .tip { margin-top: 14px; font-size: 12px; color: var(--muted); }

/* ============ 弹窗与提示 ============ */
dialog {
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--card); color: var(--text);
  padding: 24px; width: 320px;
  box-shadow: var(--shadow-hover);
}
dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
dialog h3 { font-size: 16px; margin-bottom: 16px; }
dialog input {
  width: 100%; padding: 9px 12px; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); outline: none;
}
dialog input:focus { border-color: var(--brand); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.toast {
  position: fixed; top: 18px; left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: #1e293b; color: #fff;
  padding: 10px 22px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: 0.25s;
  z-index: 99; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--bad); }
