/* ===================================================================
   卡密授权控制台 · 设计系统
   =================================================================== */
:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e6ebf2;
  --border-2: #d6dfea;
  --text: #0f172a;
  --text-2: #64748b;
  --text-3: #94a3b8;
  --accent: #00bfa5;
  --accent-2: #00a38c;
  --accent-soft: rgba(0, 191, 165, .12);
  --accent-ink: #04241f;
  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, .1);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, .12);
  --info: #2563eb;
  --info-soft: rgba(37, 99, 235, .1);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; }

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

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

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

.side {
  width: 232px;
  flex: 0 0 232px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.side-logo {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #2ee6c8);
  color: var(--accent-ink);
  display: grid; place-items: center;
  font-weight: 800; font-size: 14px;
}
.side-title { font-size: 14px; font-weight: 700; letter-spacing: .2px; }
.side-sub { font-size: 11px; color: var(--text-3); letter-spacing: 1px; }

.side-nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  cursor: pointer;
  transition: background .16s, color .16s;
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-2);
  border-color: rgba(0, 191, 165, .3);
  font-weight: 600;
}
.nav-item .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .5; }

.side-foot {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
  display: flex; justify-content: space-between; align-items: center;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 14px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 16px; font-weight: 600; margin: 0; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 12.5px; color: var(--text-2); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-2);
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}

.content { padding: 22px 24px 40px; }

/* ---------------- 通用 ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 14px; font-weight: 600; margin: 0; }
.card-head .sub { font-size: 12px; color: var(--text-3); }
.card-body { padding: 18px; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1180px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .grid-4, .grid-2 { grid-template-columns: 1fr; }
  .side { width: 68px; flex: 0 0 68px; }
  .side-title, .side-sub, .nav-item span.txt, .side-foot { display: none; }
  .nav-item { justify-content: center; }
}

/* 指标卡 */
.stat {
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent); opacity: .8;
}
.stat.k-blue::after { background: var(--info); }
.stat.k-amber::after { background: var(--warn); }
.stat.k-red::after { background: var(--danger); }
.stat .label { font-size: 12px; color: var(--text-2); letter-spacing: .3px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 8px; letter-spacing: -.5px; }
.stat .meta { font-size: 12px; color: var(--text-3); margin-top: 6px; }

/* 按钮 */
.btn {
  height: 34px; padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--text);
  font-size: 13px; cursor: pointer;
  transition: all .16s;
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent-2); background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  font-weight: 600;
}
.btn.primary:hover { background: #21d6ba; border-color: #21d6ba; color: var(--accent-ink); }
.btn.danger { color: var(--danger); border-color: rgba(229,72,77,.35); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn.ghost { border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }

/* 表单 */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--text-2); }
input[type=text], input[type=password], input[type=number], input[type=url], select, textarea {
  height: 36px; padding: 0 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text); font-size: 13.5px;
  outline: none; transition: border-color .16s, background .16s;
  font-family: inherit;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: #fff; }
input::placeholder { color: var(--text-3); }

/* 开关 */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track {
  width: 42px; height: 24px; border-radius: 12px;
  background: #dbe3ec; position: relative; transition: background .18s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(15,23,42,.25); transition: transform .18s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* 表格 */
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-3); font-weight: 600; font-size: 12px; background: var(--surface-2); position: sticky; top: 0; }
tbody tr:hover { background: #fbfdff; }
td.mono, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 600; border: 1px solid transparent;
}
.chip.ok { background: var(--accent-soft); color: var(--accent-2); border-color: rgba(0,191,165,.3); }
.chip.off { background: #eef2f7; color: var(--text-2); border-color: var(--border); }
.chip.red { background: var(--danger-soft); color: var(--danger); border-color: rgba(229,72,77,.3); }
.chip.blue { background: var(--info-soft); color: var(--info); border-color: rgba(37,99,235,.3); }
.chip.amber { background: var(--warn-soft); color: var(--warn); border-color: rgba(217,119,6,.3); }

/* 标签页 */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 18px; }
.tab {
  padding: 12px 14px; font-size: 13.5px; color: var(--text-2);
  border-bottom: 2px solid transparent; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-2); border-bottom-color: var(--accent); font-weight: 600; }

/* 分页 */
.pager { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); }
.pager .info { font-size: 12.5px; color: var(--text-3); margin-right: auto; }
.pager input { width: 58px; height: 30px; text-align: center; }

/* 提示 */
.toast-wrap { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast {
  min-width: 220px; padding: 12px 16px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(15,23,42,.12);
  font-size: 13px; display: flex; align-items: center; gap: 10px;
  animation: slideIn .2s ease;
}
.toast.ok { border-left: 3px solid var(--accent); }
.toast.err { border-left: 3px solid var(--danger); }
@keyframes slideIn { from { opacity: 0; transform: translateY(8px); } }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.35);
  display: none; align-items: center; justify-content: center; z-index: 90;
  backdrop-filter: blur(2px);
}
.modal-mask.show { display: flex; }
.modal {
  width: min(560px, 92vw); max-height: 84vh; overflow: auto;
  background: var(--surface); border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px rgba(15,23,42,.2);
}
.modal-head { display: flex; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-body { padding: 18px; }
.modal-close { margin-left: auto; border: none; background: transparent; font-size: 18px; color: var(--text-3); cursor: pointer; }
.modal-close:hover { color: var(--danger); }

/* 图表 */
.chart-box { padding: 8px 6px 0; }
.chart-legend { display: flex; gap: 16px; padding: 0 12px 12px; font-size: 12px; color: var(--text-2); }
.chart-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

/* 代码块 */
pre.code {
  margin: 0; padding: 14px; border-radius: 10px;
  background: #0f172a; color: #e2e8f0;
  font-family: ui-monospace, Consolas, monospace; font-size: 12.5px;
  max-height: 420px; overflow: auto;
}

/* 空状态 */
.empty { padding: 46px 0; text-align: center; color: var(--text-3); font-size: 13px; }

/* 登录页 */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(0,191,165,.14), transparent 60%),
    radial-gradient(900px 500px at 90% 110%, rgba(37,99,235,.10), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 380px; padding: 30px 28px 26px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 20px 60px rgba(15,23,42,.10);
}
.auth-logo {
  width: 44px; height: 44px; border-radius: 12px; margin-bottom: 16px;
  background: linear-gradient(135deg, var(--accent), #2ee6c8);
  color: var(--accent-ink); display: grid; place-items: center;
  font-weight: 800; font-size: 18px;
}
.auth-card h1 { font-size: 18px; margin: 0 0 6px; }
.auth-card p.sub { margin: 0 0 20px; font-size: 12.5px; color: var(--text-3); }
.auth-card .field { margin-bottom: 14px; }
.auth-card .btn { width: 100%; height: 40px; justify-content: center; margin-top: 6px; }
.auth-err { color: var(--danger); font-size: 12.5px; min-height: 18px; margin-top: 8px; }
.auth-foot { margin-top: 18px; font-size: 11.5px; color: var(--text-3); text-align: center; }

/* 小工具 */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.right { margin-left: auto; }
.muted { color: var(--text-3); }
.hidden { display: none !important; }
