/* hkchart — shadcn/ui 风格设计系统 */
:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --accent: 240 4.8% 95.9%;
  --destructive: 0 84.2% 60.2%;
  --success: 142 71% 45%;
  --warning: 38 92% 50%;
  --info: 217 91% 60%;
  --radius: 0.5rem;
}
:root[data-theme="dark"] {
  --background: 240 10% 3.9%;
  --foreground: 0 0% 98%;
  --card: 240 10% 5.9%;
  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;
  --border: 240 3.7% 15.9%;
  --input: 240 3.7% 15.9%;
  --primary: 0 0% 98%;
  --primary-foreground: 240 5.9% 10%;
  --accent: 240 3.7% 15.9%;
  --success: 142 71% 45%;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: Inter, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: hsl(var(--background)); color: hsl(var(--foreground));
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }

/* ---------- 登录 ---------- */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.login-card { width: 100%; max-width: 380px; border: 1px solid hsl(var(--border)); border-radius: var(--radius); background: hsl(var(--card)); padding: 32px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.login-card h1 { font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.login-card .sub { color: hsl(var(--muted-foreground)); font-size: 13px; margin: 6px 0 24px; }
.login-card label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.login-card .field { margin-bottom: 16px; }

/* ---------- 基础控件 ---------- */
.input, input[type=text], input[type=password], input[type=date], input[type=search], select {
  height: 36px; width: 100%; padding: 0 12px; font-size: 13px; font-family: inherit;
  color: hsl(var(--foreground)); background: hsl(var(--background));
  border: 1px solid hsl(var(--input)); border-radius: calc(var(--radius) - 2px); outline: none;
}
.input:focus, input:focus, select:focus { border-color: hsl(var(--foreground) / .4); box-shadow: 0 0 0 3px hsl(var(--foreground) / .06); }
select { cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; font-size: 13px; font-weight: 500; font-family: inherit;
  border-radius: calc(var(--radius) - 2px); border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
}
.btn:hover { opacity: .9; }
.btn.outline { background: transparent; border-color: hsl(var(--border)); color: hsl(var(--foreground)); }
.btn.outline:hover { background: hsl(var(--accent)); opacity: 1; }
.btn.ghost { background: transparent; color: hsl(var(--muted-foreground)); }
.btn.ghost:hover { background: hsl(var(--accent)); color: hsl(var(--foreground)); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn.danger { background: transparent; border-color: hsl(var(--border)); color: hsl(var(--destructive)); }
.btn.danger:hover { background: hsl(var(--destructive) / .08); opacity: 1; }
.btn.block { width: 100%; }
.err { color: hsl(var(--destructive)); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.side {
  width: 240px; flex-shrink: 0; border-right: 1px solid hsl(var(--border));
  background: hsl(var(--card)); position: fixed; top: 0; bottom: 0; display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px; border-bottom: 1px solid hsl(var(--border)); }
.brand .logo { width: 30px; height: 30px; border-radius: 7px; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.brand .txt b { display: block; font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.brand .txt span { font-size: 11px; color: hsl(var(--muted-foreground)); }
.app-switch { padding: 12px 12px 4px; }
.app-switch select { width: 100%; height: 34px; font-weight: 500; }
.side nav { padding: 8px 10px 12px; flex: 1; }
.side .nav-label { font-size: 11px; font-weight: 500; color: hsl(var(--muted-foreground)); padding: 8px 10px 4px; text-transform: uppercase; letter-spacing: .04em; }
.side nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin-bottom: 2px;
  border-radius: calc(var(--radius) - 2px); font-size: 13.5px; font-weight: 500; color: hsl(var(--muted-foreground));
}
.side nav a:hover { background: hsl(var(--accent)); color: hsl(var(--foreground)); }
.side nav a.active { background: hsl(var(--accent)); color: hsl(var(--foreground)); }
.side nav a svg { width: 16px; height: 16px; flex-shrink: 0; }
.side-foot { padding: 12px; border-top: 1px solid hsl(var(--border)); display: flex; gap: 8px; }

.main { flex: 1; margin-left: 240px; min-width: 0; }
.topbar {
  height: 56px; border-bottom: 1px solid hsl(var(--border)); display: flex; align-items: center;
  justify-content: space-between; padding: 0 24px; position: sticky; top: 0; background: hsl(var(--background) / .85);
  backdrop-filter: blur(8px); z-index: 10;
}
.topbar h1 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.content { padding: 24px; }
.page-head { margin-bottom: 20px; }
.page-head h2 { font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.page-head p { color: hsl(var(--muted-foreground)); font-size: 13px; margin-top: 3px; }

/* ---------- 卡片 ---------- */
.card { border: 1px solid hsl(var(--border)); border-radius: var(--radius); background: hsl(var(--card)); }
.card-head { padding: 16px 20px 0; }
.card-head .t { font-size: 13px; font-weight: 500; color: hsl(var(--muted-foreground)); display: flex; justify-content: space-between; align-items: center; }
.card-body { padding: 8px 20px 18px; }
.card-body .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.card-body .d { font-size: 12px; color: hsl(var(--muted-foreground)); margin-top: 3px; }
.delta { font-weight: 600; margin-left: 2px; }
.delta.up { color: hsl(var(--success)); }
.delta.down { color: hsl(var(--destructive)); }
.delta.flat { color: hsl(var(--muted-foreground)); }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.panel { border: 1px solid hsl(var(--border)); border-radius: var(--radius); background: hsl(var(--card)); padding: 20px; margin-bottom: 20px; }
.panel > h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.panel > .desc { font-size: 12.5px; color: hsl(var(--muted-foreground)); margin-bottom: 14px; }
#trend-chart, #active-chart { width: 100%; height: 300px; }

/* ---------- 状态灯 ---------- */
.lights { display: flex; gap: 10px; flex-wrap: wrap; }
.lights + .lights { margin-top: 10px; }
.svc-row .light { flex: 1 1 100%; }
.svc-row .meta { text-align: right; word-break: break-all; }
.light { display: flex; align-items: center; gap: 8px; border: 1px solid hsl(var(--border)); border-radius: calc(var(--radius) - 2px); padding: 8px 12px; flex: 1; min-width: 180px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot.ok { background: hsl(var(--success)); box-shadow: 0 0 0 3px hsl(var(--success) / .15); }
.dot.bad { background: hsl(var(--destructive)); box-shadow: 0 0 0 3px hsl(var(--destructive) / .15); }
.light .lt { font-size: 13px; font-weight: 500; }
.light .meta { font-size: 11.5px; color: hsl(var(--muted-foreground)); margin-left: auto; }

/* ---------- 筛选栏 ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .input, .toolbar select { width: auto; min-width: 120px; }
.toolbar .grow { flex: 1; }

/* ---------- 表格 ---------- */
.table-wrap { border: 1px solid hsl(var(--border)); border-radius: var(--radius); overflow: hidden; background: hsl(var(--card)); }
.table-scroll { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; padding: 10px 14px; font-weight: 500; color: hsl(var(--muted-foreground)); font-size: 12px; border-bottom: 1px solid hsl(var(--border)); white-space: nowrap; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid hsl(var(--border)); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: hsl(var(--muted) / .5); }
.tbl .link { color: hsl(var(--foreground)); font-weight: 500; cursor: pointer; }
.tbl .link:hover { text-decoration: underline; }
.muted { color: hsl(var(--muted-foreground)); font-size: 12px; }
.nowrap { white-space: nowrap; }
.empty { padding: 40px; text-align: center; color: hsl(var(--muted-foreground)); }

/* ---------- Badge ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 9999px; font-size: 11.5px; font-weight: 500; border: 1px solid transparent; white-space: nowrap; }
.badge.outline { border-color: hsl(var(--border)); color: hsl(var(--muted-foreground)); }
.badge.live { background: hsl(var(--info) / .12); color: hsl(var(--info)); border-color: hsl(var(--info) / .25); }
.badge.file { background: hsl(280 65% 60% / .12); color: hsl(280 65% 55%); border-color: hsl(280 65% 60% / .25); }
.badge.rec { background: hsl(var(--warning) / .12); color: hsl(38 92% 42%); border-color: hsl(var(--warning) / .25); }
.badge.paid { background: hsl(var(--warning) / .12); color: hsl(38 92% 42%); border-color: hsl(var(--warning) / .25); }
.badge.free { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.badge.banned { background: hsl(var(--destructive) / .12); color: hsl(var(--destructive)); border-color: hsl(var(--destructive) / .25); }
.badge.ghost { background: hsl(var(--destructive) / .12); color: hsl(var(--destructive)); border-color: hsl(var(--destructive) / .25); }

/* ---------- 状态链 ---------- */
.chain { display: inline-flex; align-items: center; white-space: nowrap; }
.chain .step { display: inline-flex; align-items: center; gap: 2px; padding: 2px 7px; white-space: nowrap; border-radius: 9999px; font-size: 11px; font-weight: 500; }
.chain .step.ok { background: hsl(var(--success) / .12); color: hsl(142 71% 35%); }
.chain .step.fail { background: hsl(var(--destructive) / .12); color: hsl(var(--destructive)); }
.chain .step.pending { background: hsl(var(--warning) / .14); color: hsl(38 92% 40%); }
.chain .step.none { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.chain .sep { width: 8px; height: 1px; background: hsl(var(--border)); }

/* ---------- 弹窗 ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 100; }
.modal { background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius); width: 100%; max-width: 760px; max-height: 86vh; display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-head { padding: 20px 24px; border-bottom: 1px solid hsl(var(--border)); display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.modal-head h3 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.modal-head .sub { font-size: 12.5px; color: hsl(var(--muted-foreground)); margin-top: 5px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.modal-body { padding: 20px 24px; overflow-y: auto; }
.modal-body h4 { font-size: 13px; font-weight: 600; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.modal-body section { margin-bottom: 22px; }
.modal-body section:last-child { margin-bottom: 0; }
.prose { font-size: 13.5px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; color: hsl(var(--foreground)); background: hsl(var(--muted) / .5); border-radius: calc(var(--radius) - 2px); padding: 14px 16px; }
.transcript { max-height: 320px; overflow-y: auto; border: 1px solid hsl(var(--border)); border-radius: calc(var(--radius) - 2px); }
.utt { display: flex; gap: 12px; padding: 9px 14px; border-bottom: 1px solid hsl(var(--border)); font-size: 13px; }
.utt:last-child { border-bottom: 0; }
.utt .ts { color: hsl(var(--muted-foreground)); font-size: 11.5px; font-variant-numeric: tabular-nums; flex-shrink: 0; padding-top: 2px; }

/* ---------- 用户详情 ---------- */
.profile { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; border: 1px solid hsl(var(--border)); border-radius: var(--radius); background: hsl(var(--card)); padding: 20px; margin-bottom: 20px; }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: hsl(var(--muted)); display: grid; place-items: center; font-weight: 600; font-size: 16px; color: hsl(var(--muted-foreground)); }
.profile .who b { font-size: 16px; font-weight: 600; }
.profile .who div { font-size: 12px; color: hsl(var(--muted-foreground)); margin-top: 2px; }
.profile .stats { display: flex; gap: 26px; margin-left: auto; flex-wrap: wrap; }
.profile .stats .s .k { font-size: 11.5px; color: hsl(var(--muted-foreground)); }
.profile .stats .s .v { font-size: 15px; font-weight: 600; margin-top: 2px; }
.ops { display: flex; gap: 6px; flex-wrap: wrap; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 14px; border-top: 1px solid hsl(var(--border)); }
.pager .info { margin-right: auto; font-size: 12.5px; color: hsl(var(--muted-foreground)); }

@media (max-width: 900px) {
  .side { transform: translateX(-100%); }
  .main { margin-left: 0; }
}
