/* 共享工具组网页端样式。
   颜色、字号、字重、圆角、阴影一律引用灵栈 token（lingzhan-tokens.css），这里不写色值与字号数值；
   由 scripts/check_ui.py 检查。 */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
  background: var(--canvas);
}
h1, h2, h3, p { margin: 0; }

/* ── 布局 ── */
.shell { display: flex; height: 100%; }
.sidebar {
  width: 208px; flex: none; display: flex; flex-direction: column; gap: 16px;
  padding: 20px 12px; background: var(--surface); border-right: 1px solid var(--border-default);
}
.brand { padding: 0 8px; font-size: var(--fs-title-sm); font-weight: var(--fw-emphasis); }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-group { padding: 12px 8px 4px; font-size: var(--fs-caption); color: var(--text-muted); }
.nav-link {
  display: block; padding: 8px 10px; border-radius: var(--radius-md);
  color: var(--text-secondary); text-decoration: none;
}
.nav-link:hover { background: var(--surface-hover); }
.nav-link.active { background: var(--brand-light); color: var(--brand); font-weight: var(--fw-semibold); }
.sidebar-foot { display: flex; flex-direction: column; gap: 6px; }
.who { padding: 0 8px; font-size: var(--fs-body-sm); color: var(--text-muted); overflow-wrap: anywhere; }
.main { flex: 1; min-width: 0; overflow-y: auto; padding: 24px 28px 40px; }

/* ── 通用 ── */
.page-title { font-size: var(--fs-title); font-weight: var(--fw-semibold); }
.page-sub { margin-top: 4px; color: var(--text-muted); font-size: var(--fs-body-sm); }
.hint { color: var(--text-muted); font-size: var(--fs-body-sm); line-height: 1.6; }
.error-text { color: var(--red-text); font-size: var(--fs-body-sm); }
.card {
  background: var(--surface); border: 1px solid var(--border-default);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
}
.section { margin-top: 20px; }
.section-title { margin-bottom: 10px; font-size: var(--fs-title-sm); font-weight: var(--fw-semibold); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border: 1px solid transparent; border-radius: var(--radius-md);
  font: inherit; cursor: pointer; background: transparent; color: var(--text-secondary);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--text-inverse); }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn-ghost { border-color: var(--border-default); background: var(--surface); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); }

.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: var(--fs-body-sm); color: var(--text-muted); }
.input, .select {
  height: 34px; padding: 0 10px; border: 1px solid var(--border-default); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text-primary); font: inherit; min-width: 0;
}
.input:focus, .select:focus { outline: 2px solid var(--brand-light); border-color: var(--brand); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius-sm);
  font-size: var(--fs-caption); white-space: nowrap; background: var(--pending-bg); color: var(--pending-text);
}
.badge-ok { background: var(--green-bg); color: var(--green-text); }
.badge-warn { background: var(--amber-bg); color: var(--amber-text); }
.badge-bad { background: var(--red-bg); color: var(--red-text); }
.badge-info { background: var(--blue-bg); color: var(--blue-text); }

/* ── 登录 ── */
.login { height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.login-title { font-size: var(--fs-heading); font-weight: var(--fw-emphasis); }

/* ── 筛选条 ── */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-top: 16px; padding: 14px 16px; }
.toolbar .grow { flex: 1; min-width: 160px; }

/* ── 表格 ── */
.table-wrap { margin-top: 16px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border-default); vertical-align: top; }
th {
  font-size: var(--fs-body-sm); font-weight: var(--fw-medium); color: var(--text-muted);
  background: var(--surface-muted); white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-hover); }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sub { color: var(--text-muted); font-size: var(--fs-body-sm); }
.title-cell { min-width: 260px; line-height: 1.5; }
.nowrap { white-space: nowrap; }
.empty { padding: 36px 16px; text-align: center; color: var(--text-muted); }
.more { display: flex; justify-content: center; padding: 14px; }

/* ── 指标块 ── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 16px; }
.tile { padding: 14px 16px; }
.tile-label { font-size: var(--fs-body-sm); color: var(--text-muted); }
.tile-value { margin-top: 6px; font-size: var(--fs-heading); font-weight: var(--fw-emphasis); font-variant-numeric: tabular-nums; }
.tile-note { margin-top: 4px; font-size: var(--fs-body-sm); color: var(--text-muted); }

/* ── 详情抽屉 ── */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border-default); box-shadow: var(--shadow-elevated); z-index: 20;
}
.drawer-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border-default); }
.drawer-title { font-size: var(--fs-title-sm); font-weight: var(--fw-semibold); line-height: 1.5; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px 28px; }
.kv { display: grid; grid-template-columns: 88px 1fr; gap: 8px 12px; }
.kv dt { color: var(--text-muted); font-size: var(--fs-body-sm); }
.kv dd { margin: 0; }
.spark { width: 100%; height: 120px; margin-top: 8px; }
.spark path { fill: none; stroke: var(--brand); stroke-width: 2; }
.spark circle { fill: var(--brand); }

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 10px 12px; border-right: none; border-bottom: 1px solid var(--border-default); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-group, .who { display: none; }
  .sidebar-foot { flex-direction: row; }
  .main { padding: 16px; }
}
