:root {
  --bg: #0f1419;
  --panel: #161d24;
  --panel-2: #1d252e;
  --border: #28323d;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #2fc4a5;
  --accent-dim: rgba(47, 196, 165, .14);
  --blue: #3d9ef5;
  --danger: #f2685f;
  --warn: #e8b339;
  --radius: 14px;
  --shadow: 0 12px 32px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  -webkit-text-size-adjust: 100%;   /* 关掉 iOS Safari 的字体自动放大，避免标签大小乱跳 */
  text-size-adjust: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: .2px; }
h1 { font-size: 21px; }
h2 { font-size: 16px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }

/* ---------------- 登录页 ---------------- */
/* 用多层 radial-gradient 做背景光晕，不用 blur() 滤镜：
   某些 WebView 渲染大范围模糊时会卡住，登录页会变成一片黑 */
.login-wrap {
  position: fixed; inset: 0; display: grid; place-items: center;
  padding: 24px; overflow: hidden;
  background:
    radial-gradient(620px 620px at 12% 6%, rgba(18, 86, 76, .55), transparent 70%),
    radial-gradient(560px 560px at 92% 96%, rgba(23, 54, 79, .55), transparent 70%),
    radial-gradient(circle at 50% 0%, #16222b 0%, #0d1216 62%);
}
.blob { display: none; }
.login-card {
  position: relative; width: 100%; max-width: 380px; padding: 32px 28px 24px;
  background: rgba(22, 29, 36, .92); border: 1px solid var(--border);
  border-radius: 20px; box-shadow: var(--shadow);
}
.logo {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, #2fc4a5, #1c8f7c); color: #06231d;
  font-size: 24px; font-weight: 800; margin-bottom: 16px;
}
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 22px; }
.login-err { color: var(--danger); font-size: 13px; min-height: 20px; margin-top: 10px; }
.login-foot { color: #5f6b78; font-size: 12px; text-align: center; margin-top: 14px; }

/* ---------------- 表单基础 ---------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.field em { font-size: 11.5px; color: #5f6b78; font-style: normal; }
input, textarea, select {
  width: 100%; padding: 10px 12px; color: var(--text);
  background: #11171d; border: 1px solid var(--border); border-radius: 10px;
  font: inherit; outline: none;
}
textarea { resize: vertical; min-height: 42px; }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim);
}
input::placeholder, textarea::placeholder { color: #4d5964; }

.btn {
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  padding: 9px 16px; border-radius: 10px; font-size: 14px; font-weight: 500;
}
.btn:hover { background: #232c36; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #05231d; font-weight: 600; }
.btn.primary:hover { background: #3ad4b3; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.block { width: 100%; padding: 11px; }
.btn.danger { color: var(--danger); border-color: rgba(242, 104, 95, .35); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link-btn {
  background: none; border: 0; color: var(--accent); padding: 0; font-size: 13px;
}
.link-btn:hover { text-decoration: underline; }
.icon-btn {
  background: none; border: 0; color: var(--muted); font-size: 18px; line-height: 1;
  padding: 6px; border-radius: 8px;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

/* ---------------- 布局 ---------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 212px; padding: 22px 16px;
  display: flex; flex-direction: column; gap: 22px;
  background: #121820; border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; padding: 0 8px; }
.brand-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-dim);
}
nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 12px; border: 0; border-radius: 10px; background: none;
  color: var(--muted); font-size: 14.5px;
}
.nav-item:hover { background: #1a222b; color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.nav-item .ico { font-size: 14px; width: 16px; text-align: center; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 8px; }
.tg-pill {
  display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted);
  padding: 7px 10px; border-radius: 9px; background: #10161c; border: 1px solid var(--border);
}
.tg-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: #5f6b78; flex: none; }
.tg-pill.online .dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.tg-pill.error .dot { background: var(--danger); }

.main { flex: 1; margin-left: 212px; padding: 26px 30px 60px; width: 100%; max-width: 1180px; }
.content-narrow { max-width: 1180px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; gap: 16px; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.view { }

/* ---------------- 概览 ---------------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 26px; }
.stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 4px;
}
.stat-label { font-size: 12px; color: var(--muted); }
.stat strong { font-size: 24px; font-weight: 650; letter-spacing: -.4px; }
.stat strong.sm { font-size: 16px; font-weight: 600; }
.section-head {
  display: flex; justify-content: space-between; align-items: center;
  margin: 22px 0 12px;
}
.hint { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

.card-list { display: flex; flex-direction: column; gap: 10px; }
.target-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 17px; display: flex; align-items: center; gap: 16px;
}
.target-card:hover { border-color: #35424f; }
.target-card.disabled { opacity: .55; }
.tc-main { flex: 1; min-width: 0; }
.tc-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tc-title strong { font-size: 15px; }
.tc-peer {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  color: var(--muted); background: #10161c; padding: 1px 7px; border-radius: 6px;
}
.tc-meta { color: var(--muted); font-size: 12.5px; margin-top: 5px; display: flex; gap: 12px; flex-wrap: wrap; }
.tc-next { text-align: right; min-width: 108px; }
.tc-next .lbl { font-size: 11.5px; color: var(--muted); }
.tc-next .val { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tc-next .val.soon { color: var(--accent); }
.tc-actions { display: flex; gap: 6px; align-items: center; }
.badge {
  font-size: 11.5px; padding: 2px 8px; border-radius: 999px; font-weight: 500;
  border: 1px solid transparent; white-space: nowrap;
}
.badge.ok { color: var(--accent); background: var(--accent-dim); border-color: rgba(47,196,165,.3); }
.badge.fail { color: var(--danger); background: rgba(242,104,95,.12); border-color: rgba(242,104,95,.3); }
.badge.unknown { color: var(--warn); background: rgba(232,179,57,.12); border-color: rgba(232,179,57,.3); }
.badge.idle { color: var(--muted); background: #10161c; border-color: var(--border); }
.badge.off { color: var(--muted); background: #10161c; border-color: var(--border); }

.runs { display: flex; flex-direction: column; gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.run-row { display: flex; gap: 12px; padding: 10px 14px; background: var(--panel); font-size: 13px; align-items: baseline; }
.run-row .t { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; font-size: 12px; }
.run-row .n { font-weight: 550; flex: none; min-width: 96px; }
.run-row .d { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty {
  border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 34px; text-align: center; color: var(--muted); font-size: 14px;
}
.empty p { margin-bottom: 12px; }

/* ---------------- 表格 ---------------- */
.target-table { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tr {
  display: grid; grid-template-columns: 1.4fr 1.2fr 1.1fr 1fr auto;
  gap: 12px; padding: 12px 16px; align-items: center;
  border-top: 1px solid var(--border); font-size: 13.5px;
}
.tr:first-child { border-top: 0; }
.tr.head { background: #131a21; color: var(--muted); font-size: 12px; padding: 9px 16px; }
.tr .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; color: var(--muted); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------------- 面板 / 设置 ---------------- */
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 18px;
}
.panel-head { margin-bottom: 16px; }
.panel-head p { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; }
.span2 { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; align-items: center; }
.spacer { flex: 1; }
.pad-top { padding-top: 14px; }
.range-row { display: flex; align-items: center; gap: 8px; }
.range-row span { color: var(--muted); }
.row-gap { display: flex; gap: 10px; align-items: center; }
.switch-inline { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.switch-inline input { width: 16px; height: 16px; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin: 8px 0; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.account-box {
  border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
  background: #11171d; margin-bottom: 18px; font-size: 13.5px;
}
.account-box .who { display: flex; align-items: center; gap: 10px; font-weight: 600; margin-bottom: 4px; }
.account-box .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, #2fc4a5, #1c8f7c);
  display: grid; place-items: center; color: #05231d; font-weight: 700;
}
.account-box .sub { color: var(--muted); font-size: 12.5px; }

/* ---------------- 弹窗 ---------------- */
.modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(5, 8, 11, .78); padding: 18px;
  overflow-y: auto;
}
.modal-card {
  width: 100%; max-width: 620px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow); margin: auto;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-body { padding: 18px 20px 24px; max-height: 78vh; overflow-y: auto; }
.modal-foot {
  display: flex; gap: 10px; align-items: center; padding: 14px 0 16px;
  position: sticky; bottom: 0; background: var(--panel); border-top: 1px solid var(--border);
  margin-top: 8px;
}
.windows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.window-row { display: flex; align-items: center; gap: 8px; }
.window-row input { width: 140px; }
.window-row .del { color: var(--muted); background: none; border: 0; font-size: 16px; padding: 4px 6px; }
.window-row .del:hover { color: var(--danger); }
.days { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.day-chip {
  width: 42px; padding: 7px 0; text-align: center; border-radius: 9px;
  border: 1px solid var(--border); background: #11171d; color: var(--muted); font-size: 13px;
}
.day-chip.on { background: var(--accent-dim); border-color: rgba(47,196,165,.4); color: var(--accent); font-weight: 600; }
.day-presets { display: flex; gap: 8px; }
.day-presets button {
  border: 1px solid var(--border); background: none; color: var(--muted);
  font-size: 12px; padding: 4px 10px; border-radius: 8px;
}
.day-presets button:hover { color: var(--text); border-color: #3a4653; }
.adv summary {
  cursor: pointer; color: var(--muted); font-size: 13.5px; padding: 12px 0 0;
  border-top: 1px solid var(--border); margin-top: 6px; list-style: none;
}
.adv summary::-webkit-details-marker { display: none; }
.adv summary::before { content: "▸ "; }
.adv[open] summary::before { content: "▾ "; }

/* ---------------- 日志 / toast ---------------- */
.logbox {
  background: #0c1116; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; line-height: 1.7; color: #b9c6d3; height: 62vh; overflow: auto;
  white-space: pre-wrap; word-break: break-all; margin: 0;
}
.logbox .lv-WARNING { color: var(--warn); }
.logbox .lv-ERROR { color: var(--danger); }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  background: #1e2731; border: 1px solid var(--border); border-left: 3px solid var(--accent);
  padding: 11px 15px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow);
  max-width: 340px;
}
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 820px) {
  .sidebar {
    position: fixed; inset: auto 0 0 0; width: 100%; height: 60px; padding: 0 8px;
    flex-direction: row; align-items: center; border-right: 0; border-top: 1px solid var(--border);
    background: #10161c; z-index: 30; gap: 0;
  }
  .brand, .side-foot { display: none; }
  nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav-item { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 0; align-items: center; }
  .main { margin-left: 0; padding: 18px 16px 84px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .grid-form { grid-template-columns: 1fr; }
  .tr { grid-template-columns: 1fr auto; gap: 6px 10px; }
  .tr.head { display: none; }
  .tr .mono, .tr .when { grid-column: 1 / -1; }
  .target-card { flex-direction: column; align-items: stretch; gap: 12px; padding: 14px; }
  .tc-main { width: 100%; }
  .tc-title strong { font-size: 16px; }
  .tc-meta { gap: 8px 14px; }
  .tc-next { text-align: left; min-width: 0; display: flex; align-items: baseline; gap: 8px; }
  .tc-next .lbl { font-size: 12px; }
  .tc-actions { justify-content: flex-end; border-top: 1px solid var(--border); padding-top: 10px; }
  .tc-actions .btn { flex: 1; text-align: center; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-card { border-radius: 18px 18px 0 0; max-width: 100%; }
  .toasts { left: 16px; right: 16px; bottom: 76px; }
  .toast { max-width: none; }
}

/* ---------------- 风控自检 ---------------- */
.risk-box { display: flex; flex-direction: column; gap: 2px; background: #11171d;
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.risk-row { display: flex; gap: 11px; padding: 11px 14px; align-items: flex-start;
  border-top: 1px solid var(--border); }
.risk-row:first-child { border-top: 0; }
.risk-ico { width: 19px; height: 19px; border-radius: 50%; flex: none; display: grid;
  place-items: center; font-size: 11px; font-weight: 700; margin-top: 1px; }
.risk-row.lv-ok .risk-ico { background: var(--accent-dim); color: var(--accent); }
.risk-row.lv-warn .risk-ico { background: rgba(232, 179, 57, .16); color: var(--warn); }
.risk-row.lv-info .risk-ico { background: #1b232c; color: var(--muted); }
.risk-title { font-size: 13.5px; font-weight: 550; }
.risk-detail { font-size: 12.5px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
