:root {
  --bg: #0b0f14;
  --bg-soft: #111720;
  --panel: #141c26;
  --panel-2: #18222e;
  --line: #223041;
  --text: #e8eef6;
  --muted: #8496a9;
  --accent: #35d0a5;
  --accent-2: #2ab5c9;
  --danger: #ef5b6b;
  --warn: #f2b544;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(900px 500px at 12% -10%, rgba(53, 208, 165, 0.12), transparent 60%),
    radial-gradient(700px 400px at 95% 0%, rgba(42, 181, 201, 0.10), transparent 55%);
  background-repeat: no-repeat;
}

button, input, select, textarea { font: inherit; color: inherit; }

button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 8px 12px;
  transition: border-color .15s, background .15s, color .15s, transform .1s;
}
button:hover { border-color: #35495f; background: #1d2937; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; transform: none; }

input, select, textarea {
  width: 100%;
  background: #0e151d;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(53, 208, 165, .12);
}
textarea { resize: vertical; font-family: var(--mono); font-size: 12px; line-height: 1.6; }

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; letter-spacing: .02em; }

.btn-primary {
  background: linear-gradient(180deg, #3ad9ad, #22b98f);
  border-color: transparent;
  color: #04211a;
  font-weight: 600;
}
.btn-primary:hover { background: linear-gradient(180deg, #46e5b9, #27c79a); border-color: transparent; }
.btn-danger { color: #ffd7dc; border-color: rgba(239, 91, 107, .35); background: rgba(239, 91, 107, .12); }
.btn-danger:hover { background: rgba(239, 91, 107, .2); border-color: rgba(239, 91, 107, .5); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 9px; font-size: 12px; border-radius: 6px; white-space: nowrap; }

/* ---------------- 登录页 ---------------- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, rgba(24, 34, 46, .95), rgba(17, 23, 32, .95));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 28px 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-brand .logo-mark, .logo-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(145deg, rgba(53, 208, 165, .22), rgba(42, 181, 201, .18));
  border: 1px solid rgba(53, 208, 165, .35);
  color: var(--accent);
  font-size: 16px;
}
.auth-brand h1 { font-size: 16px; margin: 0; letter-spacing: .04em; }
.auth-brand p { margin: 2px 0 0; font-size: 11px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .btn-primary { width: 100%; padding: 10px; margin-top: 6px; }
.auth-hint { margin: 16px 0 0; font-size: 12px; color: var(--muted); line-height: 1.6; }
.form-error {
  min-height: 18px;
  font-size: 12px;
  color: var(--danger);
  margin: 8px 0 0;
}

/* ---------------- 主界面 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 15, 20, .72);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: .02em; }
.topbar .sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.topbar .spacer { flex: 1; }
.ca-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  background: rgba(20, 28, 38, .8);
  border-radius: 999px;
  padding: 5px 12px 5px 8px;
}
.ca-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px rgba(53, 208, 165, .8); }
.user-menu { display: flex; gap: 8px; align-items: center; }

.layout {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 18px;
  padding: 18px 22px 26px;
  align-items: start;
  max-width: 1500px;
  margin: 0 auto;
}

.card {
  background: linear-gradient(180deg, rgba(24, 34, 46, .82), rgba(17, 23, 32, .82));
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.card-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-head h2 { font-size: 13px; margin: 0; font-weight: 600; letter-spacing: .02em; }
.card-head .count { font-size: 11px; color: var(--muted); margin-left: auto; }
.card-body { padding: 16px; }

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

.segmented { display: flex; background: #0e151d; border: 1px solid var(--line); border-radius: 8px; padding: 3px; gap: 3px; }
.segmented button {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
}
.segmented button.active { background: rgba(53, 208, 165, .14); color: var(--accent); }
.segmented button:hover { background: rgba(53, 208, 165, .08); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}
.chip.active { border-color: rgba(53, 208, 165, .5); color: var(--accent); background: rgba(53, 208, 165, .1); }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.form-note { font-size: 11px; color: var(--muted); margin-top: 8px; line-height: 1.6; }
.renew-banner {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 12px;
  color: var(--accent);
  background: rgba(53, 208, 165, .08);
  border-bottom: 1px solid rgba(53, 208, 165, .2);
}
.renew-banner.show { display: flex; }
.renew-banner b { font-family: var(--mono); }
.form-status { font-size: 12px; margin-top: 10px; min-height: 17px; color: var(--muted); line-height: 1.5; }
.form-status.error { color: var(--danger); }
.form-status.ok { color: var(--accent); }

/* 证书列表 */
.cert-list { display: flex; flex-direction: column; }
.cert-item {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(34, 48, 65, .65);
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}
.cert-item:last-child { border-bottom: none; }
.cert-item:hover { background: rgba(53, 208, 165, .03); }
.cert-domain { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cert-domain strong { font-size: 14px; font-weight: 600; font-family: var(--mono); letter-spacing: -.01em; }
.badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  letter-spacing: .04em;
}
.badge.wildcard { color: #7fd0ff; border-color: rgba(127, 208, 255, .4); background: rgba(127, 208, 255, .1); }
.badge.valid { color: var(--accent); border-color: rgba(53, 208, 165, .35); background: rgba(53, 208, 165, .1); }
.badge.expiring { color: var(--warn); border-color: rgba(242, 181, 68, .35); background: rgba(242, 181, 68, .1); }
.badge.expired { color: var(--danger); border-color: rgba(239, 91, 107, .35); background: rgba(239, 91, 107, .1); }
.cert-meta { font-size: 11px; color: var(--muted); margin-top: 5px; font-family: var(--mono); }
.cert-time { font-size: 12px; color: var(--muted); }
.cert-time b { color: var(--text); font-weight: 500; font-family: var(--mono); font-size: 12px; }
.cert-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.9;
}
.empty .big { font-size: 26px; display: block; margin-bottom: 6px; opacity: .5; }

/* 弹层 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 12, .72);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}
.modal-mask.show { display: flex; }
.modal {
  width: min(860px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 40px 90px rgba(0, 0, 0, .6);
  overflow: hidden;
}
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal-head h3 { margin: 0; font-size: 14px; font-family: var(--mono); }
.modal-head .spacer { flex: 1; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.modal-foot .spacer { flex: 1; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button.active { border-color: rgba(53, 208, 165, .45); color: var(--accent); background: rgba(53, 208, 165, .1); }
.pem-box { height: 340px; }
.pem-warn { font-size: 11px; color: var(--warn); margin-top: 8px; }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; margin-bottom: 14px; }
.info-grid div { font-size: 12px; color: var(--muted); }
.info-grid div b { display: block; color: var(--text); font-weight: 500; font-family: var(--mono); font-size: 11px; margin-top: 3px; word-break: break-all; }

.format-group { display: flex; gap: 6px; flex-wrap: wrap; }
.format-group button { min-width: 88px; text-align: center; }

@media (max-width: 980px) {
  .topbar { padding: 10px 14px; gap: 10px; }
  .topbar h1 { font-size: 14px; }
  .topbar .sub { display: none; }
  .layout { grid-template-columns: 1fr; padding: 14px; }
  .cert-item { grid-template-columns: 1fr; }
  .cert-actions { justify-content: flex-start; }
  .topbar .ca-chip { display: none; }
}
