:root {
  --bg: #e6e8ef;
  --card: #fafbfd;
  --ink: #1b2030;
  --muted: #6b7488;
  --faint: #9aa3b5;
  --line: #e4e7ee;
  --line-strong: #d6dae4;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-hover: #4f46e5;
  --accent-soft: #eef0fe;
  --accent-soft-2: #e0e3fd;
  --ok: #16915a;
  --ok-soft: #e6f6ee;
  --ok-line: #c2e7d3;
  --warn: #b3700a;
  --warn-soft: #fdf2e1;
  --err: #d23a2e;
  --err-soft: #fde7e4;
  --code-bg: #eef0f6;
  --code-ink: #3b4252;
  --grad: linear-gradient(120deg, #6366f1 0%, #7c83fd 48%, #8b5cf6 100%);
  --side-bg: #171a2b;
  --side-bg-2: #1d2138;
  --side-ink: #e9ebf6;
  --side-muted: #8b90ad;
  --side-line: rgba(255,255,255,.07);
  --shadow-sm: 0 1px 2px rgba(20,28,48,.06);
  --shadow: 0 1px 2px rgba(20,28,48,.04), 0 8px 24px -8px rgba(40,46,88,.12);
  --shadow-lg: 0 24px 60px -18px rgba(40,46,88,.30);
  --radius: 14px;
  --side-w: 244px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1018;
    --card: #181b26;
    --ink: #e9ecf5;
    --muted: #9aa1b5;
    --faint: #6c7388;
    --line: #262a38;
    --line-strong: #353a4c;
    --accent: #818cf8;
    --accent-2: #a78bfa;
    --accent-hover: #939dff;
    --accent-soft: #20243a;
    --accent-soft-2: #2a2f4d;
    --ok: #34d17f;
    --ok-soft: #15281f;
    --ok-line: #20492f;
    --warn: #e0a23c;
    --warn-soft: #2e2410;
    --err: #f3766b;
    --err-soft: #2e1714;
    --code-bg: #11141d;
    --code-ink: #c4cad9;
    --side-bg: #12141f;
    --side-bg-2: #171a28;
    --side-ink: #e9ebf6;
    --side-muted: #7e849c;
    --side-line: rgba(255,255,255,.06);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 34px -10px rgba(0,0,0,.55);
    --shadow-lg: 0 24px 60px -18px rgba(0,0,0,.7);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 680; letter-spacing: .2px; }

/* ════════ layout ════════ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--side-w); flex-shrink: 0;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 40;
  background: linear-gradient(180deg, var(--side-bg) 0%, var(--side-bg-2) 100%);
  color: var(--side-ink);
  display: flex; flex-direction: column;
  border-right: 1px solid var(--side-line);
}
.side-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 20px 22px; font-size: 16px; font-weight: 700;
  border-bottom: 1px solid var(--side-line);
}
.side-logo {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  background: var(--grad); display: flex; align-items: center; justify-content: center;
  font-size: 17px; box-shadow: 0 6px 16px -4px rgba(99,102,241,.7);
}
.side-nav { flex: 1; padding: 14px 12px; display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px; cursor: pointer;
  color: var(--side-muted); font-size: 14px; font-weight: 550;
  text-decoration: none; transition: background .15s, color .15s; position: relative;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.05); color: var(--side-ink); }
.nav-item.is-active { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.is-active::before {
  content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px;
  background: var(--grad); border-radius: 0 3px 3px 0;
}
.nav-badge {
  margin-left: auto; background: var(--err); color: #fff;
  font-size: 11px; font-weight: 700; min-width: 18px; height: 18px;
  border-radius: 9px; padding: 0 5px; display: flex; align-items: center; justify-content: center;
}
.side-foot { padding: 16px 22px; border-top: 1px solid var(--side-line); }
.side-user { font-size: 12.5px; color: var(--side-ink); font-weight: 600; word-break: break-all; }
.side-ver { font-size: 11px; color: var(--side-muted); margin-top: 3px; }

.main { flex: 1; margin-left: var(--side-w); min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  height: 62px; padding: 0 28px;
  background: color-mix(in srgb, var(--card) 85%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 18px; }
.top-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.menu-btn { display: none; background: none; border: none; font-size: 22px; color: var(--ink); cursor: pointer; padding: 4px; }

.content { padding: 24px 30px 48px; width: 100%; }
.page { animation: fadeUp .35s cubic-bezier(.2,.7,.3,1) both; }
.hidden { display: none !important; }

@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-btn { display: block; }
  .content { padding: 18px 16px 40px; }
  .topbar { padding: 0 16px; }
}

/* ════════ panels ════════ */
.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px;
  overflow: hidden;
}
.panel.pad { padding: 26px; }
.panel-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: baseline; gap: 12px; }
.panel-head h3 { font-size: 15px; }
.panel-sub { font-size: 12.5px; color: var(--muted); }

/* ════════ stat cards ════════ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat-card .stat-label { font-size: 13px; color: var(--muted); font-weight: 550; }
.stat-card .stat-num { font-size: 32px; font-weight: 760; margin-top: 8px; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-card .stat-ico {
  position: absolute; top: 18px; right: 18px; width: 40px; height: 40px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
  background: var(--accent-soft); color: var(--accent);
}
.stat-card.danger .stat-num { color: var(--err); }
.stat-card.danger .stat-ico { background: var(--err-soft); color: var(--err); }
.stat-card.warn .stat-num { color: var(--warn); }
.stat-card.warn .stat-ico { background: var(--warn-soft); color: var(--warn); }
.stat-card.ok .stat-num { color: var(--ok); }
.stat-card.ok .stat-ico { background: var(--ok-soft); color: var(--ok); }

/* ════════ toolbar ════════ */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.tool-search { flex: 1 1 220px; margin: 0; }
.tool-select { flex: 0 0 auto; width: auto; margin: 0; }
.tool-spacer { flex: 1; }

/* ════════ data table ════════ */
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table thead th {
  text-align: left; font-size: 11.5px; font-weight: 700; color: var(--muted);
  letter-spacing: .04em; text-transform: none;
  padding: 13px 18px; border-bottom: 1px solid var(--line-strong);
  background: var(--code-bg); white-space: nowrap;
}
.data-table thead th:first-child { padding-left: 22px; }
.data-table thead th:last-child { padding-right: 22px; }
.data-table tbody td { padding: 14px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody td:first-child { padding-left: 22px; }
.data-table tbody td:last-child { padding-right: 22px; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
.ta-c { text-align: center; } .ta-r { text-align: right; }
.td-domain { font-weight: 620; word-break: break-all; }
.td-domain .port { color: var(--faint); font-weight: 500; }
.td-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.td-issuer { color: var(--muted); font-size: 12.5px; }
.td-exp { font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { text-align: center; color: var(--faint); padding: 40px 0; font-size: 13.5px; }

/* group tag */
.tag {
  display: inline-block; font-size: 11.5px; font-weight: 600; white-space: nowrap;
  color: var(--accent); background: var(--accent-soft); padding: 3px 10px; border-radius: 999px;
}
.tag.empty-tag { color: var(--faint); background: var(--code-bg); }

/* status / days pill */
.pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700;
  padding: 4px 11px; border-radius: 999px; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.pill.is-ok { background: var(--ok-soft); color: var(--ok); }
.pill.is-warn { background: var(--warn-soft); color: var(--warn); }
.pill.is-danger { background: var(--err-soft); color: var(--err); }
.pill .dot2 { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* row action icon buttons */
.row-ops { display: inline-flex; gap: 5px; justify-content: flex-end; }
.iconbtn {
  width: 30px; height: 30px; padding: 0; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--card); color: var(--muted); font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: all .12s;
}
.iconbtn:hover { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.iconbtn.danger:hover { background: var(--err-soft); color: var(--err); }

/* ════════ buttons ════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; border: none; border-radius: 10px; padding: 10px 18px;
  font-size: 13.5px; font-weight: 650; font-family: inherit; text-decoration: none;
  transition: transform .12s, box-shadow .2s, background .2s, color .2s, opacity .2s;
  white-space: nowrap;
}
.btn.primary { background: var(--grad); color: #fff; background-size: 140% 140%; box-shadow: 0 8px 18px -7px rgba(99,102,241,.6); }
.btn.primary:hover { background-position: 100% 50%; transform: translateY(-1px); }
.btn.primary:active { transform: translateY(1px); }
.btn.ghost { background: var(--card); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn.ghost:hover { color: var(--ink); box-shadow: inset 0 0 0 1px var(--faint); }
.btn.copy { background: var(--accent-soft); color: var(--accent); padding: 7px 14px; font-size: 12.5px; }
.btn.copy:hover { background: var(--accent-soft-2); }
.btn.sm { padding: 8px 13px; font-size: 12.5px; }
.btn:disabled { opacity: .6; cursor: progress; transform: none; box-shadow: none; }

/* ════════ forms ════════ */
.field { display: block; font-size: 13px; font-weight: 620; color: var(--ink); margin-bottom: 16px; }
.sublabel { display: block; font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 3px; }
input, select, textarea {
  width: 100%; margin-top: 8px; padding: 11px 13px;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 10px;
  color: var(--ink); font-size: 14px; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.tool-search, .tool-select, .toolbar input, .toolbar select { margin-top: 0; }
input::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
select { cursor: pointer; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 130px; }
.actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 12.5px; margin: 16px 0 0; padding: 11px 14px; background: var(--accent-soft); border-radius: 10px; }
.lead { color: var(--muted); margin: 0 0 18px; }
code { background: var(--code-bg); padding: 2px 6px; border-radius: 5px; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; color: var(--code-ink); }

/* provider auto-detect hint */
.provider-hint { margin: -6px 0 16px; padding: 9px 13px; border-radius: 10px; font-size: 12.5px; animation: fadeUp .25s ease both; }
.provider-hint.ok { background: var(--ok-soft); border: 1px solid var(--ok-line); color: var(--ok); }
.provider-hint.info { background: var(--accent-soft); color: var(--muted); }

/* ════════ issue wizard ════════ */
.steps { list-style: none; display: flex; margin: 0 0 22px; padding: 0; max-width: 560px; }
.step { flex: 1 1 0; position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; color: var(--faint); font-weight: 500; text-align: center; }
.step::before { content: ""; position: absolute; top: 15px; height: 2px; left: -50%; right: 50%; margin: 0 16px; background: var(--line-strong); border-radius: 2px; transition: background .3s; }
.step:first-child::before { display: none; }
.step .dot { position: relative; z-index: 1; width: 32px; height: 32px; border-radius: 50%; background: var(--card); color: var(--muted); box-shadow: inset 0 0 0 2px var(--line-strong); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 680; transition: all .25s; }
.step.is-active { color: var(--accent); }
.step.is-active .dot { background: var(--grad); color: #fff; box-shadow: 0 6px 16px -4px rgba(99,102,241,.6), 0 0 0 5px var(--accent-soft); }
.step.is-done { color: var(--ok); }
.step.is-done .dot { background: var(--ok); color: #fff; box-shadow: none; }
.step.is-done::before, .step.is-active::before { background: var(--ok); }
@media (max-width: 560px) { .step .label { display: none; } }

.txt-rec { border: 1px solid var(--line); border-radius: 11px; overflow: hidden; margin-bottom: 12px; box-shadow: var(--shadow-sm); }
.txt-rec .kv { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.txt-rec .kv:last-child { border-bottom: none; }
.txt-rec .kv:nth-child(odd) { background: var(--code-bg); }
.kv .k { color: var(--muted); width: 72px; flex-shrink: 0; font-size: 12.5px; font-weight: 650; }
.kv .v { word-break: break-all; flex: 1; min-width: 0; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
.copy.mini { padding: 5px 11px; font-size: 11.5px; }

.dns-status { margin: 14px 0 4px; padding: 14px 16px; border-radius: 12px; font-size: 13px; border: 1px solid var(--line); background: var(--code-bg); animation: fadeUp .3s ease both; }
.dns-status.ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); font-weight: 650; }
.dns-status.warn { background: var(--warn-soft); border-color: transparent; color: var(--ink); }
.dns-status-title { font-weight: 650; margin-bottom: 10px; }
.dns-rec { margin: 10px 0; } .dns-rec:last-child { margin-bottom: 0; }
.dns-rec-head { font-size: 12.5px; margin-bottom: 7px; word-break: break-all; }
.ns-list { display: flex; flex-wrap: wrap; gap: 7px; }
.ns-pill { font-size: 11.5px; padding: 4px 10px; border-radius: 999px; font-family: ui-monospace, Menlo, monospace; }
.ns-pill.ok { background: var(--ok-soft); color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok-line); }
.ns-pill.no { background: var(--err-soft); color: var(--err); }
.err-box { margin-top: 14px; padding: 13px 15px; border-radius: 11px; background: var(--err-soft); color: var(--err); font-size: 12px; font-family: ui-monospace, Menlo, monospace; white-space: pre-wrap; word-break: break-all; max-height: 240px; overflow: auto; animation: fadeUp .3s ease both; }

.success-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.success-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--ok); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 800; box-shadow: 0 6px 16px -4px rgba(21,130,75,.6), 0 0 0 5px var(--ok-soft); animation: popIn .45s cubic-bezier(.2,1.3,.4,1) both; }
.meta { background: var(--ok-soft); border: 1px solid var(--ok-line); border-radius: 11px; padding: 15px 17px; margin-bottom: 20px; font-size: 13px; }
.meta div { margin: 4px 0; } .meta .k { color: var(--muted); display: inline-block; width: 84px; font-weight: 650; }
.cert-block { margin-bottom: 15px; }
.cert-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px; font-weight: 650; }
textarea { height: 116px; resize: vertical; font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; background: var(--code-bg); color: var(--code-ink); line-height: 1.5; }

/* ════════ modal ════════ */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(18,22,38,.5); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 20px; animation: fadeUp .2s ease both; }
.modal-box { background: var(--card); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 440px; box-shadow: var(--shadow-lg); max-height: 90vh; overflow: auto; }
.modal-box h3 { margin: 0 0 18px; font-size: 16px; }

/* ════════ toast ════════ */
.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: var(--ink); color: var(--card); padding: 12px 22px; border-radius: 11px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); z-index: 80; animation: toastIn .28s cubic-bezier(.2,.9,.3,1) both; }
.toast.error { background: var(--err); color: #fff; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes popIn { 0% { opacity: 0; transform: scale(.4); } 60% { opacity: 1; transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(12px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ════════ 登录页 ════════ */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: var(--bg);
  background-image: radial-gradient(50rem 50rem at 80% -10%, rgba(99,102,241,.16), transparent 60%),
    radial-gradient(40rem 40rem at -5% 100%, rgba(139,92,246,.14), transparent 55%);
}
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 38px 34px; width: 100%; max-width: 388px; box-shadow: var(--shadow-lg); text-align: center; }
.login-logo { width: 58px; height: 58px; border-radius: 16px; background: var(--grad); display: flex; align-items: center; justify-content: center; font-size: 28px; margin: 0 auto 16px; box-shadow: 0 12px 26px -8px rgba(99,102,241,.7); }
.login-card h1 { font-size: 21px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 6px 0 24px; }
.login-card .field { text-align: left; }
.login-err { margin-top: 14px; color: var(--err); font-size: 13px; background: var(--err-soft); padding: 10px 13px; border-radius: 10px; }

/* ════════ 筛选 chip ════════ */
.filter-row { display: flex; align-items: center; gap: 12px; margin-bottom: 11px; flex-wrap: wrap; }
.filter-label { font-size: 12.5px; color: var(--muted); font-weight: 650; flex: 0 0 56px; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.fchip { font-size: 12.5px; color: var(--muted); padding: 5px 13px; border-radius: 8px; cursor: pointer; background: transparent; border: 1px solid transparent; transition: all .12s; user-select: none; }
.fchip:hover { background: var(--code-bg); color: var(--ink); }
.fchip.active { background: var(--accent); color: #fff; font-weight: 600; box-shadow: 0 4px 12px -4px rgba(99,102,241,.6); }

/* 侧栏退出 */
.side-logout { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; font-size: 12px; color: var(--side-muted); text-decoration: none; cursor: pointer; transition: color .15s; }
.side-logout:hover { color: #fff; }

/* 更新时间列 */
.td-upd { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ════════ 第二轮：续费按钮 / 停用 / 备注列 / 宽弹窗 ════════ */
.renewbtn {
  border: none; cursor: pointer; font-family: inherit;
  font-size: 12px; font-weight: 650; padding: 6px 12px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent); transition: all .12s; white-space: nowrap;
}
.renewbtn:hover { background: var(--accent); color: #fff; transform: translateY(-1px); }
.row-ops { gap: 6px; align-items: center; }

.pill.is-off { background: var(--code-bg); color: var(--faint); }
.row-dim td { opacity: .55; }
.row-dim:hover td { opacity: .8; }
.td-remark { color: var(--ink); font-size: 12.5px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.faint { color: var(--faint); }

.modal-box.wide { max-width: 540px; }
.modal-box .row > .field { margin-bottom: 0; }
.modal-box .row { margin-bottom: 16px; }
.modal-box textarea { height: auto; min-height: 56px; font-family: inherit; font-size: 14px; background: var(--card); color: var(--ink); }
