/* ============================== 基础 ============================== */
:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #16202e;
  --ink-2: #4a5768;
  --ink-3: #8794a6;
  --line: #e3e8ef;
  --line-2: #eef1f6;
  --brand: #2f6bff;
  --brand-ink: #1d4ed8;
  --brand-soft: #eaf0ff;
  --ok: #0f9d58;
  --ok-soft: #e6f6ed;
  --warn: #b26a00;
  --warn-soft: #fff3e0;
  --danger: #d93025;
  --danger-soft: #fdecea;
  --side: #101a2b;
  --side-2: #18243a;
  --side-ink: #aab6c8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px -12px rgba(16, 24, 40, .18);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

/* 关键：作者样式里的 display 会盖掉浏览器对 [hidden] 的默认隐藏 */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
button { font: inherit; }

/* ============================== 登录 ============================== */
.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 600px at 12% -10%, #dbe6ff 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 110%, #e4f6ef 0%, transparent 50%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.login-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 26px; }
.login-brand h1 { font-size: 19px; letter-spacing: -.2px; }
.login-brand p { color: var(--ink-3); font-size: 13px; margin-top: 2px; }

.brand-mark {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(140deg, #3b7bff, #2050e0);
  color: #fff; font-size: 16px;
  box-shadow: 0 6px 14px -6px rgba(47, 107, 255, .8);
}

.login-form { display: grid; gap: 16px; }
.login-foot { margin-top: 22px; color: var(--ink-3); font-size: 12px; text-align: center; }

/* ============================== 布局 ============================== */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100%; }

.sidebar {
  background: var(--side);
  color: var(--side-ink);
  display: flex; flex-direction: column;
  padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; }
.brand-text { color: #fff; font-weight: 600; letter-spacing: .2px; }

.nav { display: grid; gap: 3px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px;
  border-radius: 9px;
  color: var(--side-ink);
  font-size: 13.5px;
  transition: background .15s, color .15s;
}
.nav a svg {
  width: 17px; height: 17px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.nav a:hover { background: var(--side-2); color: #e8edf5; }
.nav a.active { background: #22304a; color: #fff; }
.nav a.active svg { stroke: #7aa2ff; }

.sidebar-foot {
  margin-top: auto;
  padding: 14px 10px 2px;
  border-top: 1px solid #1d2b42;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.who { font-size: 12.5px; color: #8fa0b8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { min-width: 0; padding: 28px 34px 60px; }
.view { max-width: 1180px; margin: 0 auto; }

/* ============================== 通用组件 ============================== */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-head h1 { font-size: 22px; letter-spacing: -.4px; }
.page-head p { color: var(--ink-3); font-size: 13px; margin-top: 5px; }
.head-actions { display: flex; gap: 10px; align-items: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff; color: var(--ink-2);
  cursor: pointer; font-size: 13.5px; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { background: #f8fafc; border-color: #d5dce6; color: var(--ink); }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 6px 14px -8px rgba(47, 107, 255, .9);
}
.btn.primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn.danger { color: var(--danger); border-color: #f2c9c4; background: #fff; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--side-ink); }
.btn.ghost:hover { background: var(--side-2); color: #fff; }
.btn.small { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.link {
  height: auto; padding: 0; border: 0; background: none; color: var(--brand);
  font-size: 13px;
}
.btn.link:hover { text-decoration: underline; background: none; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.field .hint { font-size: 12px; color: var(--ink-3); }

input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="search"], select, textarea {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 76px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #9db9ff;
  box-shadow: 0 0 0 3px rgba(47, 107, 255, .13);
}
input::placeholder, textarea::placeholder { color: #aab4c3; }

.check { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--ink-2); }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }

/* 卡片 */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 1px rgba(16, 24, 40, .03);
}
.card > h2 {
  font-size: 14px; font-weight: 600; letter-spacing: -.1px;
  margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card > h2 .muted { font-weight: 400; font-size: 12.5px; color: var(--ink-3); }

/* 统计卡 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat .label { color: var(--ink-3); font-size: 12.5px; }
.stat .value { font-size: 26px; font-weight: 650; letter-spacing: -.8px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--ink-3); font-size: 12px; margin-top: 4px; }
.stat .value.warn { color: var(--warn); }
.stat .value.ok { color: var(--ok); }
.stat .value.danger { color: var(--danger); }

.panel-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 14px; margin-bottom: 20px; }
@media (max-width: 980px) { .panel-grid { grid-template-columns: 1fr; } }

/* 柱状图 */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.chart .bar-wrap { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 7px; height: 100%; }
.chart .bar {
  width: 100%; max-width: 28px; min-height: 3px;
  border-radius: 5px 5px 3px 3px;
  background: linear-gradient(180deg, #6d97ff, #2f6bff);
  transition: filter .15s;
}
.chart .bar.zero { background: #e6ecf5; }
.chart .bar:hover { filter: brightness(1.08); }
.chart .x { font-size: 10.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* 状态分布 */
.bars { display: grid; gap: 13px; }
.bar-row .top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.bar-row .top .num { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.track { height: 7px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.track > i { display: block; height: 100%; border-radius: 99px; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font-weight: 500; color: var(--ink-3); font-size: 12px;
  text-transform: none; letter-spacing: .2px;
  padding: 0 12px 10px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfd; }
td .sub { color: var(--ink-3); font-size: 12px; margin-top: 2px; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn + .btn { margin-left: 4px; }

.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: -.1px; }
.key-cell { display: flex; align-items: center; gap: 8px; }
.key-cell .mono { color: var(--ink-2); }
.copy-mini {
  border: 0; background: none; padding: 2px; border-radius: 5px;
  color: var(--ink-3); cursor: pointer; line-height: 0;
}
.copy-mini:hover { background: var(--line-2); color: var(--brand); }
.copy-mini svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.empty { padding: 44px 16px; text-align: center; color: var(--ink-3); }
.empty strong { display: block; color: var(--ink-2); font-size: 14px; margin-bottom: 6px; }

/* 徽标 */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 23px; padding: 0 9px;
  border-radius: 99px; font-size: 12px; font-weight: 500;
  background: var(--line-2); color: var(--ink-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: currentColor; opacity: .75; }
.badge.active { background: var(--ok-soft); color: #0b7a45; }
.badge.expired { background: var(--warn-soft); color: var(--warn); }
.badge.revoked { background: var(--danger-soft); color: var(--danger); }
.badge.neutral { background: var(--line-2); color: var(--ink-2); }

/* 工具条 */
.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar .grow { flex: 1; min-width: 160px; }
.toolbar input[type="search"], .toolbar select { height: 34px; font-size: 13px; }
.toolbar .spacer { flex: 1; }

/* 列表 / 时间线 */
.feed { display: grid; gap: 2px; }
.feed-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--line-2);
  font-size: 13px;
}
.feed-row:last-child { border-bottom: 0; }
.feed-row .dot {
  width: 7px; height: 7px; border-radius: 99px; flex: none; background: #c9d3e0;
}
.feed-row .dot.ok { background: var(--ok); }
.feed-row .dot.warn { background: var(--warn); }
.feed-row .dot.bad { background: var(--danger); }
.feed-row .grow { flex: 1; min-width: 0; }
.feed-row .grow span { color: var(--ink-3); }
.feed-row time { color: var(--ink-3); font-size: 12px; white-space: nowrap; }

/* 表单 */
.form { display: grid; gap: 15px; }
.form .row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { color: var(--danger); font-size: 12.5px; background: var(--danger-soft); padding: 8px 11px; border-radius: 8px; }
.form-note { color: var(--ink-3); font-size: 12px; }

/* ============================== 弹窗 ============================== */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(15, 23, 42, .42);
  backdrop-filter: blur(2px);
  display: grid; place-items: center;
  padding: 20px;
  animation: fade .12s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.modal {
  width: 100%; max-width: 520px;
  max-height: calc(100vh - 40px);
  background: var(--panel);
  border-radius: 16px;
  box-shadow: 0 24px 60px -18px rgba(15, 23, 42, .5);
  display: flex; flex-direction: column;
  animation: pop .14s ease;
}
@keyframes pop { from { transform: translateY(6px) scale(.99); opacity: 0 } to { transform: none; opacity: 1 } }
.modal.wide { max-width: 720px; }
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 20px 22px 0;
}
.modal-head h3 { font-size: 16px; letter-spacing: -.2px; }
.modal-head p { color: var(--ink-3); font-size: 12.5px; margin-top: 3px; }
.modal-close {
  border: 0; background: none; color: var(--ink-3); cursor: pointer;
  font-size: 20px; line-height: 1; padding: 2px 4px; border-radius: 6px;
}
.modal-close:hover { background: var(--line-2); color: var(--ink); }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px 20px; border-top: 1px solid var(--line-2);
}

/* 提示 */
.toasts { position: fixed; z-index: 80; right: 20px; bottom: 20px; display: grid; gap: 8px; }
.toast {
  min-width: 220px; max-width: 380px;
  background: #16202e; color: #fff;
  padding: 11px 14px; border-radius: 10px;
  font-size: 13px; box-shadow: 0 12px 30px -10px rgba(15, 23, 42, .6);
  display: flex; gap: 9px; align-items: flex-start;
  animation: rise .18s ease;
}
.toast::before { content: ""; width: 7px; height: 7px; border-radius: 99px; margin-top: 6px; flex: none; background: #5bd08a; }
.toast.error::before { background: #ff6b61; }
@keyframes rise { from { transform: translateY(8px); opacity: 0 } to { transform: none; opacity: 1 } }

/* 代码块 */
.code {
  position: relative;
  background: #0e1726; color: #d7e1f0;
  border-radius: 10px; padding: 14px 15px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
  overflow-x: auto; white-space: pre;
}
.code .copy-code {
  position: absolute; top: 8px; right: 8px;
  background: #22304a; color: #cbd7e8; border: 0;
  border-radius: 7px; padding: 5px 9px; font-size: 11.5px; cursor: pointer;
}
.code .copy-code:hover { background: #2d3f60; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button {
  border: 0; background: none; padding: 8px 13px; cursor: pointer;
  color: var(--ink-3); font-size: 13px; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 500; }

/* 详情键值 */
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 10px 14px; font-size: 13.5px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.section-title { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 20px 0 10px; }

.divider { height: 1px; background: var(--line-2); margin: 18px 0; }

.muted { color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.tag-list { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: 12px; padding: 2px 8px; border-radius: 6px;
  background: var(--brand-soft); color: var(--brand-ink);
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; align-items: center;
    padding: 12px 14px; gap: 14px; overflow-x: auto;
  }
  .brand { padding: 0; }
  .brand-text { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav a span { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .who { display: none; }
  .main { padding: 20px 16px 50px; }
  .form .row-2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 3px 0; }
  .kv dd { margin-bottom: 10px; }
}
