/* ============================================================================
   keyyzd 设计系统
   ----------------------------------------------------------------------------
   一个文件搞定：设计令牌 → 基础元素 → 组件 → 布局 → 响应式。
   不引任何外部字体/图标/框架，CSP 只放行 'self'，离线也能跑。
   ========================================================================== */

:root {
  /* 底色由深到浅，卡片永远比背景亮一档，层次才立得住 */
  --bg: #0b0d11;
  --surface: #11141a;
  --card: #161a21;
  --card-2: #1b2029;
  --card-3: #212734;

  --line: rgba(255, 255, 255, .075);
  --line-2: rgba(255, 255, 255, .14);

  --ink: #eef1f7;
  --ink-2: #c6cdd9;
  --muted: #8b95a7;
  --faint: #626c7d;

  --accent: #3871e0;
  --accent-2: #5b8cf5;
  --accent-soft: rgba(56, 113, 224, .16);

  --good: #31c07a;
  --good-soft: rgba(49, 192, 122, .14);
  --warn: #e8a33d;
  --warn-soft: rgba(232, 163, 61, .14);
  --bad: #ef5f6b;
  --bad-soft: rgba(239, 95, 107, .14);

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --r-xl: 24px;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-2: 0 10px 30px rgba(0, 0, 0, .34);
  --shadow-3: 0 24px 70px rgba(0, 0, 0, .5);

  --ease: cubic-bezier(.2, .7, .3, 1);
  --side-w: 244px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

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

/* 顶部两团极淡的光，避免整屏死黑 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(58% 38% at 12% -4%, rgba(56, 113, 224, .17), transparent 62%),
    radial-gradient(46% 34% at 96% 4%, rgba(91, 140, 245, .09), transparent 66%);
  z-index: 0;
}

::selection { background: rgba(56, 113, 224, .35); }

h1, h2, h3, h4, p { margin: 0; }

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, .mono {
  font-family: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", monospace;
  font-variant-ligatures: none;
}

/* --------------------------------------------------------------- 滚动条 */
* { scrollbar-width: thin; scrollbar-color: #2a3140 transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: #2a3140; border-radius: 99px; border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: #3a4355; background-clip: content-box; }

/* --------------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px;
  border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--card-2); color: var(--ink);
  font: inherit; font-size: 13.5px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background .16s var(--ease), border-color .16s var(--ease),
              transform .12s var(--ease), box-shadow .16s var(--ease);
}
.btn:hover { background: var(--card-3); border-color: rgba(255, 255, 255, .22); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.btn.primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-color: transparent; color: #fff;
  box-shadow: 0 6px 18px rgba(56, 113, 224, .3), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.btn.primary:hover { filter: brightness(1.07); box-shadow: 0 8px 24px rgba(56, 113, 224, .4); }

.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn.ghost:hover { background: rgba(255, 255, 255, .05); color: var(--ink); }

.btn.danger { color: var(--bad); border-color: rgba(239, 95, 107, .32); background: var(--bad-soft); }
.btn.danger:hover { background: rgba(239, 95, 107, .22); }

.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn .ico { font-size: 15px; line-height: 1; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card-2); color: var(--ink-2);
  font-size: 16px; cursor: pointer;
  transition: background .16s, color .16s;
}
.icon-btn:hover { background: var(--card-3); color: var(--ink); }

/* --------------------------------------------------------------- 表单 */
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > label {
  font-size: 12.5px; color: var(--muted); font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}
.field .hint { font-size: 12px; color: var(--faint); line-height: 1.45; }

.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 13.5px;
  transition: border-color .16s, box-shadow .16s, background .16s;
}
.textarea { height: auto; min-height: 92px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--card);
}
.select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.select option { background: var(--card); color: var(--ink); }

.input.mono { letter-spacing: .06em; }

/* 开关 */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 40px; height: 22px; border-radius: 99px;
  background: #2a3140; border: 1px solid var(--line-2);
  position: relative; transition: background .18s var(--ease), border-color .18s;
  flex: 0 0 auto;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #8e98aa; transition: transform .18s var(--ease), background .18s;
}
.switch input:checked + .track { background: var(--accent); border-color: transparent; }
.switch input:checked + .track::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .track { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.switch .label { font-size: 13px; color: var(--ink-2); }

/* --------------------------------------------------------------- 徽标 */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px; border-radius: 99px;
  font-size: 12px; font-weight: 500; line-height: 1;
  border: 1px solid transparent; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.active   { color: var(--good); background: var(--good-soft); border-color: rgba(49, 192, 122, .3); }
.badge.disabled { color: var(--warn); background: var(--warn-soft); border-color: rgba(232, 163, 61, .3); }
.badge.expired  { color: var(--muted); background: rgba(139, 149, 167, .12); border-color: rgba(139, 149, 167, .28); }
.badge.revoked  { color: var(--bad); background: var(--bad-soft); border-color: rgba(239, 95, 107, .32); }
.badge.info     { color: var(--accent-2); background: var(--accent-soft); border-color: rgba(91, 140, 245, .3); }
.badge.plain    { color: var(--muted); background: rgba(255, 255, 255, .05); border-color: var(--line); }
.badge.no-dot::before { display: none; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  background: rgba(255, 255, 255, .05); border: 1px solid var(--line);
  font-size: 11.5px; color: var(--ink-2);
}

/* --------------------------------------------------------------- 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  position: relative;
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.card-head h2, .card-head h3 { font-size: 14.5px; font-weight: 600; letter-spacing: .01em; }
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 20px; }
.card-body.tight { padding: 12px; }

.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; }

/* --------------------------------------------------------------- 统计卡 */
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.stat {
  padding: 15px 16px 14px;
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--line); border-radius: var(--r);
  position: relative; overflow: hidden;
  transition: border-color .18s, transform .18s var(--ease);
}
.stat:hover { border-color: var(--line-2); transform: translateY(-1px); }
.stat .k { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .d { font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.stat .v.good { color: var(--good); }
.stat .v.warn { color: var(--warn); }
.stat .v.bad { color: var(--bad); }

/* --------------------------------------------------------------- 柱状图 */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 168px; padding-top: 8px; }
.bar-day { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 6px; min-width: 0; }
.bar-pair { display: flex; align-items: flex-end; justify-content: center; gap: 3px; flex: 1; min-height: 2px; }
.bar-pair i {
  display: block; width: 46%; max-width: 12px; min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, var(--accent-2), rgba(56, 113, 224, .5));
  transition: height .3s var(--ease), filter .16s;
}
.bar-pair i.a { background: linear-gradient(180deg, #46d08c, rgba(49, 192, 122, .45)); }
.bar-pair i:hover { filter: brightness(1.25); }
.bar-day .x { font-size: 10px; color: var(--faint); text-align: center; white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend .l1 i { background: var(--accent-2); }
.legend .l2 i { background: #46d08c; }

/* --------------------------------------------------------------- 表格 */
.table-wrap { overflow-x: auto; border-radius: var(--r); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data th {
  font-weight: 500; color: var(--muted); font-size: 12px; white-space: nowrap;
  background: rgba(255, 255, 255, .02);
  position: sticky; top: 0; z-index: 1;
}
table.data tbody tr { transition: background .13s; }
table.data tbody tr:hover { background: rgba(255, 255, 255, .028); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.num { font-variant-numeric: tabular-nums; color: var(--ink-2); }
table.data td .actions { display: flex; gap: 6px; flex-wrap: wrap; }
table.data tr.clickable { cursor: pointer; }
/* 勾选列 */
table.data th.sel, table.data td.sel { width: 34px; padding-right: 0; text-align: center; }
table.data td.sel input[type="checkbox"], table.data th.sel input[type="checkbox"] {
  accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; margin: 0;
}
/* 批量操作条 */
.batchbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 12px; margin: 0 0 4px;
  background: var(--accent-soft);
  border: 1px solid rgba(91, 140, 245, .28);
  border-radius: 12px;
}
.batchbar[hidden] { display: none; }
.batchbar .info { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.batchbar .info b { color: var(--accent-2); font-variant-numeric: tabular-nums; }
.batchbar .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.mono-cell { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; letter-spacing: .04em; }
/* 卡密完整显示：等宽 + 可点复制 */
.keycell { color: var(--text); letter-spacing: .06em; word-break: break-all; }
.keycell.clickable { cursor: pointer; border-bottom: 1px dashed var(--line); }
.keycell.clickable:hover { color: var(--accent); border-bottom-color: var(--accent); }
.dim { color: var(--muted); }
.tiny { font-size: 11.5px; }
.nowrap { white-space: nowrap; }

/* 设备用量条 */
.usage { display: inline-flex; align-items: center; gap: 8px; }
.usage .track { width: 46px; height: 5px; border-radius: 99px; background: #262c39; overflow: hidden; }
.usage .track i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.usage .track i.full { background: var(--warn); }
.usage span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- 工具条 */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.toolbar .search { position: relative; flex: 1 1 240px; min-width: 160px; max-width: 360px; }
.toolbar .search .input { padding-left: 34px; height: 36px; }
.toolbar .search::before {
  content: "⌕"; position: absolute; left: 12px; top: 50%; transform: translateY(-52%);
  color: var(--faint); font-size: 16px; pointer-events: none;
}
.toolbar .spacer { flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  height: 32px; padding: 0 12px; border-radius: 99px;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font: inherit; font-size: 12.5px; cursor: pointer;
  transition: all .15s var(--ease);
}
.chip:hover { color: var(--ink); border-color: var(--line-2); }
.chip.on { background: var(--accent-soft); border-color: rgba(91, 140, 245, .45); color: var(--accent-2); }

/* --------------------------------------------------------------- 分页 */
.pager { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pager .info { color: var(--muted); font-size: 12.5px; margin-right: auto; }
.pager .pages { display: flex; gap: 4px; }
.pager button {
  min-width: 30px; height: 30px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 8px;
  background: transparent; color: var(--ink-2); font: inherit; font-size: 12.5px; cursor: pointer;
}
.pager button:hover:not(:disabled) { background: var(--card-3); }
.pager button:disabled { opacity: .35; cursor: default; }
.pager button.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* --------------------------------------------------------------- 结构 */
.shell { display: flex; min-height: 100vh; position: relative; z-index: 1; }

.sidebar {
  width: var(--side-w); flex: 0 0 var(--side-w);
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px 14px;
  background: rgba(17, 20, 26, .82);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
  position: sticky; top: 0; height: 100vh;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent-2), #2a56b8);
  box-shadow: 0 6px 16px rgba(56, 113, 224, .34);
  font-weight: 700; font-size: 15px; color: #fff; letter-spacing: -.02em;
}
.brand .txt b { display: block; font-size: 14.5px; letter-spacing: .01em; }
.brand .txt span { display: block; font-size: 11.5px; color: var(--faint); }

.nav-group { font-size: 11px; color: var(--faint); letter-spacing: .08em; padding: 12px 10px 6px; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 38px; padding: 0 11px; border-radius: 9px;
  color: var(--ink-2); font-size: 13.5px;
  border: 1px solid transparent; cursor: pointer;
  background: transparent; width: 100%; text-align: left; font-family: inherit;
  transition: background .15s, color .15s, border-color .15s;
}
.nav-item .ico { width: 18px; text-align: center; font-size: 15px; opacity: .85; }
.nav-item:hover { background: rgba(255, 255, 255, .05); color: var(--ink); text-decoration: none; }
.nav-item.on {
  background: linear-gradient(90deg, rgba(56, 113, 224, .22), rgba(56, 113, 224, .06));
  color: #fff; border-color: rgba(91, 140, 245, .28);
}
.nav-item.on .ico { opacity: 1; color: var(--accent-2); }
.nav-item .pill { margin-left: auto; font-size: 11px; color: var(--muted); }
.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.side-foot .who { display: flex; align-items: center; gap: 9px; padding: 6px 8px 10px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
  background: var(--card-3); color: var(--ink-2); border: 1px solid var(--line-2);
}
.side-foot .who b { display: block; font-size: 12.5px; }
.side-foot .who span { display: block; font-size: 11px; color: var(--faint); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 28px; border-bottom: 1px solid var(--line);
  background: rgba(11, 13, 17, .72); backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 30;
}
.topbar .titles { min-width: 0; }
.topbar h1 { font-size: 20px; font-weight: 620; letter-spacing: -.01em; }
.topbar p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.topbar .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.view { padding: 22px 28px 56px; max-width: 1440px; width: 100%; margin: 0 auto; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.right { margin-left: auto; }
.only-mobile { display: none !important; }

/* --------------------------------------------------------------- 抽屉 */
.scrim {
  position: fixed; inset: 0; background: rgba(4, 6, 10, .62);
  backdrop-filter: blur(2px); opacity: 0; pointer-events: none;
  transition: opacity .2s var(--ease); z-index: 50;
}
.scrim.show { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw);
  background: var(--surface); border-left: 1px solid var(--line-2);
  box-shadow: var(--shadow-3);
  transform: translateX(102%); transition: transform .26s var(--ease);
  z-index: 60; display: flex; flex-direction: column;
}
.drawer.show { transform: none; }
.drawer-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 18px 20px; border-bottom: 1px solid var(--line);
}
.drawer-head h2 { font-size: 16px; font-weight: 600; }
.drawer-head p { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.drawer-head .icon-btn { margin-left: auto; flex: 0 0 auto; }
.drawer-body { padding: 18px 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 18px; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; }

/* 键值列表 */
.kv { display: flex; flex-direction: column; gap: 0; }
.kv .item {
  display: flex; align-items: baseline; gap: 12px;
  padding: 9px 0; border-bottom: 1px dashed rgba(255, 255, 255, .06);
  font-size: 13px;
}
.kv .item:last-child { border-bottom: none; }
.kv .k { color: var(--muted); flex: 0 0 88px; font-size: 12.5px; }
.kv .v { color: var(--ink); min-width: 0; word-break: break-all; }

.section-title { font-size: 12px; color: var(--faint); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 8px; }

/* 设备行 */
.dev {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); margin-bottom: 8px;
}
.dev .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: 0 0 auto; }
.dev .dot.on { background: var(--good); box-shadow: 0 0 0 4px var(--good-soft); }
.dev .m { min-width: 0; flex: 1; }
.dev .m b { display: block; font-size: 12.5px; font-family: ui-monospace, Consolas, monospace; }
.dev .m span { display: block; font-size: 11.5px; color: var(--faint); margin-top: 2px; }

/* 时间线 */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tl-item:last-child { border-bottom: none; }
.tl-item .dot {
  width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: 0 0 auto;
  background: var(--accent-2); box-shadow: 0 0 0 4px rgba(56, 113, 224, .12);
}
.tl-item .body { min-width: 0; flex: 1; }
.tl-item .body b { font-size: 12.5px; font-weight: 550; }
.tl-item .body p { font-size: 11.5px; color: var(--muted); margin-top: 2px; word-break: break-all; }
.tl-item time { font-size: 11px; color: var(--faint); white-space: nowrap; }

/* --------------------------------------------------------------- 空态/骨架/提示 */
.empty { padding: 46px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 28px; opacity: .5; margin-bottom: 8px; }
.empty p { font-size: 13px; }
.empty .btn { margin-top: 14px; }

.skeleton {
  border-radius: 8px; height: 14px;
  background: linear-gradient(90deg, #1b2029 25%, #232a36 37%, #1b2029 63%);
  background-size: 400% 100%; animation: shimmer 1.3s infinite linear;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.notice {
  display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px;
  border: 1px solid rgba(91, 140, 245, .26); background: var(--accent-soft);
  font-size: 12.5px; color: var(--ink-2); line-height: 1.6;
}
.notice.warn { border-color: rgba(232, 163, 61, .3); background: var(--warn-soft); }
.notice.bad { border-color: rgba(239, 95, 107, .32); background: var(--bad-soft); }
.notice .i { flex: 0 0 auto; }
.notice b { color: var(--ink); }

/* --------------------------------------------------------------- 弹窗 */
.modal {
  position: fixed; inset: 0; z-index: 70;
  display: none; align-items: center; justify-content: center; padding: 18px;
  background: rgba(4, 6, 10, .68); backdrop-filter: blur(3px);
}
.modal.show { display: flex; animation: fadein .16s var(--ease); }
.modal .box {
  width: min(440px, 100%);
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--r-lg); box-shadow: var(--shadow-3);
  padding: 22px; animation: pop .2s var(--ease);
}
.modal h3 { font-size: 16px; font-weight: 600; }
.modal p { font-size: 13px; color: var(--muted); margin-top: 8px; line-height: 1.6; }
.modal .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
@keyframes fadein { from { opacity: 0; } }

/* --------------------------------------------------------------- Toast */
.toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 90;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 11px 15px; border-radius: 11px;
  background: var(--card-2); border: 1px solid var(--line-2);
  border-left: 3px solid var(--accent);
  box-shadow: var(--shadow-2); font-size: 13px;
  animation: toastin .22s var(--ease);
}
.toast.ok { border-left-color: var(--good); }
.toast.err { border-left-color: var(--bad); }
.toast.out { animation: toastout .2s var(--ease) forwards; }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }
@keyframes toastout { to { opacity: 0; transform: translateY(6px); } }

/* --------------------------------------------------------------- 登录 */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  position: relative; z-index: 1;
}
.login-card {
  width: min(392px, 100%);
  background: linear-gradient(180deg, rgba(27, 32, 41, .92), rgba(17, 20, 26, .96));
  border: 1px solid var(--line-2); border-radius: var(--r-xl);
  padding: 30px; box-shadow: var(--shadow-3);
}
.login-card .brand { padding: 0 0 22px; }
.login-card h1 { font-size: 19px; font-weight: 600; }
.login-card .lead { color: var(--muted); font-size: 13px; margin: 6px 0 22px; }
.login-card .field + .field { margin-top: 14px; }
.login-card .btn { margin-top: 20px; height: 42px; }
.login-card .foot { margin-top: 18px; font-size: 11.5px; color: var(--faint); text-align: center; line-height: 1.7; }

/* --------------------------------------------------------------- 代码块 */
pre.code {
  margin: 0; padding: 14px 16px; border-radius: var(--r);
  background: #0c0f14; border: 1px solid var(--line);
  color: #b8c6dd; font-size: 12.5px; line-height: 1.65;
  overflow: auto; max-height: 420px; white-space: pre;
}
pre.code .k { color: #7fb0ff; }
pre.code .s { color: #8fd6a8; }
pre.code .n { color: #e8b877; }

/* --------------------------------------------------------------- 响应式 */
@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid.side { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 960px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; height: 100vh;
    transform: translateX(-104%); transition: transform .24s var(--ease);
    box-shadow: var(--shadow-3);
    z-index: 55;              /* 必须高于遮罩(50)，否则抽屉展开后被压暗且点不到 */
  }
  .sidebar.open { transform: none; }
  .only-mobile { display: inline-grid !important; }
  .topbar { padding: 14px 16px; }
  .topbar h1 { font-size: 17px; }
  .topbar p { display: none; }
  .view { padding: 16px 16px 48px; }
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat .v { font-size: 22px; }
  .card-head { padding: 14px 16px; }
  .card-body { padding: 16px; }
  .toolbar { padding: 12px; }
  .toolbar .search { max-width: none; flex-basis: 100%; }
  .drawer { width: 100%; border-left: none; }
}

@media (max-width: 620px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { gap: 8px; }
  .chips { width: 100%; overflow-x: auto; padding-bottom: 2px; flex-wrap: nowrap; }
  .chips::-webkit-scrollbar { height: 0; }
  .chip { flex: 0 0 auto; }
  .bar-day .x { font-size: 9px; }
  .bars { gap: 3px; }

  /* 表格转卡片 */
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr {
    border: 1px solid var(--line); border-radius: 12px;
    margin: 0 0 10px; padding: 8px 12px; background: var(--card-2);
  }
  table.responsive tbody tr:hover { background: var(--card-2); }
  table.responsive td {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 6px 0; border-bottom: 1px dashed rgba(255, 255, 255, .055);
    text-align: right;
  }
  table.responsive td:last-child { border-bottom: none; }
  table.responsive td::before {
    content: attr(data-label);
    color: var(--muted); font-size: 12px; text-align: left; flex: 0 0 auto;
  }
  table.responsive td.act { justify-content: flex-start; flex-wrap: wrap; padding-top: 10px; }
  table.responsive td.act::before { display: none; }
  table.responsive td.sel { justify-content: flex-start; padding: 6px 0 0; }
  table.responsive td.sel::before { display: none; }
  table.responsive td.full { display: block; text-align: left; }
  table.responsive td.full::before { display: block; margin-bottom: 4px; }
  .pager .info { flex-basis: 100%; }
  .pager { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
