/* CertHub 证枢 — 控制台样式
   设计目标：高密度管理台，14px 基准，信息优先；深浅色跟随系统。 */

:root {
  --bg: #f1f3f6;
  --surface: #ffffff;
  --surface-2: #fbfcfd;
  --surface-3: #f1f3f5;
  --border: #e3e6ea;
  --border-strong: #d3d8de;
  --text: #16191d;
  --text-2: #4a5158;
  --muted: #7c848c;
  --primary: #0d7a6f;
  --primary-hover: #0a655c;
  --primary-soft: #e6f4f1;
  --primary-ink: #ffffff;
  --ok: #0f7b4f;
  --ok-soft: #e7f6ee;
  --warn: #a15c00;
  --warn-soft: #fdf3e3;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --info: #1f5ea8;
  --info-soft: #eaf1fa;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14), 0 2px 8px rgba(16, 24, 40, .08);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101316;
    --surface: #171b1f;
    --surface-2: #1b2025;
    --surface-3: #21272d;
    --border: #272e35;
    --border-strong: #333c45;
    --text: #e6e9ec;
    --text-2: #b6bec6;
    --muted: #8b949d;
    --primary: #2fb8a6;
    --primary-hover: #4ccdb9;
    --primary-soft: #14302d;
    --primary-ink: #06201d;
    --ok: #46c98c;
    --ok-soft: #13291f;
    --warn: #e2a54a;
    --warn-soft: #2a2318;
    --danger: #f0776c;
    --danger-soft: #2e1a18;
    --info: #6aa9ea;
    --info-soft: #16232f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
#root { min-height: 100vh; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
::selection { background: var(--primary-soft); color: var(--text); }

/* ---------------- 登录页 ---------------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background:
    radial-gradient(900px 420px at 15% -10%, var(--primary-soft), transparent 70%),
    radial-gradient(700px 380px at 110% 110%, var(--info-soft), transparent 65%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 404px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 30px 28px 24px;
}
.brand-row { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.brand-mark {
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: 9px;
  background: linear-gradient(145deg, var(--primary), #0a5f57);
  display: grid; place-items: center;
  color: #fff;
}
.brand-name { font-weight: 650; letter-spacing: .2px; font-size: 15px; }
.brand-sub { color: var(--muted); font-size: 12px; }
.login-card h1 { font-size: 19px; margin: 0 0 6px; font-weight: 650; }
.login-card p.lead { color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.login-foot { margin-top: 18px; color: var(--muted); font-size: 12px; text-align: center; }

/* ---------------- 布局 ---------------- */
.app { display: flex; min-height: 100%; }
.sidebar {
  width: 228px; flex: 0 0 228px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand-row { padding: 18px 16px 14px; margin: 0; }
.nav { padding: 6px 10px; overflow-y: auto; flex: 1; }
.nav-label {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); padding: 14px 8px 6px;
}
.nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 9px; margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 13.5px; text-decoration: none;
}
.nav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav a svg { flex: 0 0 16px; opacity: .85; }
.nav a .count {
  margin-left: auto; font-size: 11px; color: var(--muted);
  background: var(--surface-3); border-radius: 20px; padding: 0 7px; min-width: 20px; text-align: center;
}
.sidebar-foot { border-top: 1px solid var(--border); padding: 10px; }
.userchip {
  display: flex; align-items: center; gap: 9px; padding: 7px 8px;
  border-radius: var(--radius-sm); cursor: pointer;
}
.userchip:hover { background: var(--surface-3); }
.avatar {
  width: 27px; height: 27px; border-radius: 50%; flex: 0 0 27px;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.userchip .u-name { font-size: 12.5px; font-weight: 600; line-height: 1.2; }
.userchip .u-mail { font-size: 11px; color: var(--muted); line-height: 1.3;
  max-width: 128px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  padding: 22px 28px 0;
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 650; letter-spacing: -.2px; }
.topbar .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.topbar .actions { display: flex; gap: 8px; align-items: center; }
.content { padding: 18px 28px 40px; }

/* ---------------- 组件 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font-size: 13px; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: var(--primary); border-color: var(--primary); color: var(--primary-ink);
  font-weight: 600;
}
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: var(--border-strong); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 27px; padding: 0 9px; font-size: 12px; }
.btn.block { width: 100%; }
.btn.loading { position: relative; color: transparent; }
.btn.loading::after {
  content: ""; position: absolute; width: 13px; height: 13px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  color: var(--primary-ink); animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card-head h3 { margin: 0; font-size: 13.5px; font-weight: 650; }
.card-head .hint { font-size: 12px; color: var(--muted); }
.card-body { padding: 14px 16px; }

.grid { display: grid; gap: 14px; }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1080px) {
  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.c3, .grid.c2 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .sidebar { display: none; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
}

.stat { padding: 14px 16px; }
.stat .k { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 25px; font-weight: 650; letter-spacing: -.5px; margin-top: 4px; }
.stat .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat .v small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }

.table-wrap { overflow-x: auto; }
table.tb { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tb th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px;
  letter-spacing: .03em; text-transform: none;
  padding: 9px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap;
}
table.tb td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tb tr:last-child td { border-bottom: none; }
table.tb tbody tr.clickable { cursor: pointer; }
table.tb tbody tr.clickable:hover { background: var(--surface-2); }
.domain { font-family: var(--mono); font-size: 12.5px; font-weight: 600; }
.subdomains { color: var(--muted); font-size: 11.5px; margin-top: 2px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 21px; padding: 0 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  line-height: 1; vertical-align: middle;
}
.badge.tiny { height: 17px; padding: 0 6px; font-size: 10px; margin-left: 6px; letter-spacing: 0; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.muted { background: var(--surface-3); color: var(--muted); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }
.dot.pulse { box-shadow: 0 0 0 0 currentColor; animation: pulse 2.4s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(15, 123, 79, .35); }
  70% { box-shadow: 0 0 0 6px rgba(15, 123, 79, 0); }
  100% { box-shadow: 0 0 0 0 rgba(15, 123, 79, 0); }
}

.progress { height: 5px; border-radius: 4px; background: var(--surface-3); overflow: hidden; width: 100%; }
.progress > i { display: block; height: 100%; background: var(--ok); border-radius: 4px; }
.progress.warn > i { background: var(--warn); }
.progress.err > i { background: var(--danger); }

.field { margin-bottom: 13px; }
.field > label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; }
.field .hint { color: var(--muted); font-size: 11.5px; margin-top: 4px; line-height: 1.5; }
.field .err { color: var(--danger); font-size: 11.5px; margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=email], select, textarea {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 13px; font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { resize: vertical; min-height: 68px; font-family: var(--mono); font-size: 12px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--primary); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.inline { display: inline-flex; align-items: center; gap: 6px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt8 { margin-top: 8px; } .mt14 { margin-top: 14px; } .mt20 { margin-top: 20px; }
.mb0 { margin-bottom: 0; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

.empty { padding: 42px 20px; text-align: center; color: var(--muted); }
.empty .ico { opacity: .45; margin-bottom: 10px; }
.empty h4 { margin: 0 0 4px; color: var(--text); font-size: 14px; font-weight: 600; }
.empty p { margin: 0 0 14px; font-size: 12.5px; }

.kv { display: grid; grid-template-columns: 118px 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--muted); font-size: 12px; }
.kv dd { margin: 0; word-break: break-all; }

.logs {
  font-family: var(--mono); font-size: 12px; line-height: 1.7;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  max-height: 340px; overflow: auto; padding: 10px 12px;
}
.logs .l { display: flex; gap: 8px; }
.logs .t { color: var(--muted); flex: 0 0 auto; }
.logs .m { white-space: pre-wrap; word-break: break-word; }
.logs .lv-warn .m { color: var(--warn); }
.logs .lv-error .m { color: var(--danger); }

pre.code {
  font-family: var(--mono); font-size: 12px; line-height: 1.6;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
  overflow: auto; margin: 0; white-space: pre-wrap; word-break: break-all;
}

/* ---------------- 弹窗 / 提示 ---------------- */
.overlay {
  position: fixed; inset: 0; background: rgba(12, 16, 20, .5);
  display: grid; place-items: center; padding: 20px; z-index: 50;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 13px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column;
}
.modal.wide { max-width: 760px; }
.modal-head {
  padding: 16px 18px 12px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.modal-head h3 { margin: 0; font-size: 15.5px; font-weight: 650; }
.modal-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.modal-body { padding: 0 18px 4px; overflow: auto; }
.modal-foot {
  padding: 14px 18px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}
.iconbtn {
  border: none; background: transparent; color: var(--muted);
  width: 28px; height: 28px; border-radius: 6px; cursor: pointer; display: grid; place-items: center;
}
.iconbtn:hover { background: var(--surface-3); color: var(--text); }

#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 8px; box-shadow: var(--shadow-lg);
  padding: 10px 14px; font-size: 13px; min-width: 240px; max-width: 400px;
  animation: slidein .18s ease-out;
}
.toast.err { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
@keyframes slidein { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button {
  border: none; background: transparent; padding: 9px 12px; font-size: 13px;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.skel { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: 6px; height: 12px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
