/* ==========================================================================
   GEO 工作台 · 组件层 (Components)
   --------------------------------------------------------------------------
   依赖 tokens.css。三端共用。
   设计立场：用 1px hairline 分区建立秩序，卡片只用于真正需要抬升的元素。
   ========================================================================== */

/* ---- 布局外壳 App Shell ------------------------------------------------- */
.shell {
  display: grid;
  grid-template-columns: var(--nav-w, 248px) minmax(0, 1fr);
  min-height: 100vh;
  container-type: inline-size;
  background: var(--bg-canvas);
}
.shell[data-nav="collapsed"] { --nav-w: 64px; }

/* 侧栏 —— 固定、独立滚动、底栏固定 */
.nav {
  display: flex; flex-direction: column;
  background: var(--bg-surface);
  border-right: var(--bw-hair) solid var(--border-subtle);
  position: sticky; top: 0; height: 100vh;
}
.nav__brand {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-4) var(--sp-5);
  border-bottom: var(--bw-hair) solid var(--border-subtle);
}
.nav__logo {
  width: 28px; height: 28px; flex: none; border-radius: var(--r-sm);
  background: var(--accent);
  display: grid; place-items: center;
  color: var(--neutral-0); font-size: var(--fs-xs); font-weight: var(--fw-bold);
  letter-spacing: -0.04em;
}
.nav__title { font-size: var(--fs-sm); font-weight: var(--fw-semi); line-height: 1.2; }
.nav__sub { font-size: var(--fs-2xs); color: var(--text-tertiary); }

.nav__scroll { flex: 1; overflow-y: auto; padding: var(--sp-4) var(--sp-3); }
.nav__group + .nav__group { margin-top: var(--sp-5); }
/* 管理员最常用的是切换客户，客户选择固定在导航上方。 */
#customerGroup { order: -1; margin: 0 0 var(--sp-5); padding-bottom: var(--sp-4); border-bottom: 1px solid var(--border-subtle); }
#customerGroup .nav__group-label { color: var(--accent-text); }
#customerGroup .search { margin-bottom: var(--sp-2) !important; }
#customerGroup .input { min-height: 32px; background: var(--bg-surface-2); }
.nav__group-label {
  padding: 0 var(--sp-2) var(--sp-2);
  font-size: var(--fs-2xs); font-weight: var(--fw-semi);
  letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-tertiary);
}
.nav__item {
  position: relative;
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; padding: 7px var(--sp-3);
  border-radius: var(--r-sm);
  font-size: var(--fs-base); color: var(--text-secondary);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.nav__item:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.nav__item[aria-current="page"] { background: var(--accent-subtle); color: var(--accent-text); font-weight: var(--fw-medium); }
/* 当前项：左侧 2px 指示条，比整块填充更克制 */
.nav__item[aria-current="page"]::before {
  content: ""; position: absolute; left: -12px; top: 50%; translate: 0 -50%;
  width: 3px; height: 18px; border-radius: 0 var(--r-full) var(--r-full) 0;
  background: var(--accent);
}
.nav__item:focus-visible,
.customer:focus-visible,
.guide-step:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nav__icon { width: 16px; height: 16px; flex: none; opacity: 0.85; }
.nav__count { margin-left: auto; font-size: var(--fs-2xs); color: var(--text-tertiary); }

.nav__foot {
  padding: var(--sp-3); border-top: var(--bw-hair) solid var(--border-subtle);
  display: grid; gap: var(--sp-2);
}

/* 主区 */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; gap: var(--sp-4);
  height: 56px; padding: 0 var(--sp-6);
  background: color-mix(in oklab, var(--bg-surface) 86%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: var(--bw-hair) solid var(--border-subtle);
}
.content { padding: var(--sp-8) clamp(20px, 3vw, 48px) var(--sp-10); max-width: 1520px; width: 100%; }
.content > .notice:empty { display: none; }
.content > #adminWorkspace, .content > #tenantWorkspace { min-width: 0; }
[data-pane] { min-width: 0; }
[data-pane]:not([data-pane="overview"]) > .panel:first-child { border-top: 2px solid var(--accent); }
[data-pane]:not([data-pane="overview"]) > .panel + .panel { margin-top: var(--sp-5); }
[data-pane] .section-head h2 { font-size: var(--fs-lg); }
[data-pane] .section-head .muted { max-width: 72ch; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav { position: fixed; inset: 0 auto 0 0; width: 248px; z-index: var(--z-drawer); translate: -100% 0; transition: translate var(--dur-base) var(--ease-out); }
  .nav[data-open="true"] { translate: 0 0; box-shadow: var(--shadow-xl); }
  .content { padding: var(--sp-4); }
}

/* ---- 工作台首页 --------------------------------------------------------- */
.workspace-hero {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-8);
  margin: 0 0 var(--sp-6); padding: var(--sp-8);
  border: 1px solid color-mix(in oklab, var(--accent) 20%, var(--border-subtle));
  border-radius: var(--r-lg);
  background: var(--bg-surface);
  box-shadow: inset 3px 0 0 var(--accent), var(--shadow-sm);
}
.workspace-hero__copy { max-width: 680px; }
.workspace-hero h2 { margin-top: var(--sp-2); font-size: clamp(1.45rem, 1.1rem + 1vw, 2rem); line-height: var(--lh-tight); letter-spacing: -0.02em; }
.workspace-hero p { margin-top: var(--sp-3); max-width: 60ch; color: var(--text-secondary); }
.workspace-hero__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.workspace-guide {
  grid-column: 1 / -1;
  margin: 0 0 var(--sp-6);
  padding: var(--sp-6);
  border-top: var(--bw-thick) solid var(--accent);
  border-bottom: var(--bw-hair) solid var(--border-subtle);
  background: var(--bg-surface-2);
}
.workspace-guide__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-5);
  margin-bottom: var(--sp-5);
}
.workspace-guide__head h2 { margin-top: var(--sp-2); font-size: var(--fs-xl); line-height: var(--lh-tight); }
.workspace-guide__head p { margin-top: var(--sp-2); }
.workspace-guide__steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  border: var(--bw-hair) solid var(--border-subtle);
  background: var(--border-subtle);
}
.guide-step {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  min-width: 0;
  min-height: 76px;
  padding: var(--sp-3);
  border: 0;
  background: var(--bg-surface);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.guide-step:hover { background: var(--accent-subtle); color: var(--accent-text); }
.guide-step__num {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: var(--r-full);
  background: var(--accent-subtle);
  color: var(--accent-text);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
}
.guide-step b { display: block; font-size: var(--fs-sm); font-weight: var(--fw-semi); }
.guide-step small { display: block; margin-top: var(--sp-1); color: var(--text-tertiary); font-size: var(--fs-xs); line-height: var(--lh-snug); }
.case-builder {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: var(--bw-hair) solid var(--border-subtle);
  background: var(--bg-surface-2);
}
.case-builder__head,
.case-row__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.case-builder__head { color: var(--text-primary); }
.case-builder__head > div { display: grid; gap: var(--sp-1); }
.case-builder__count { color: var(--accent-text); font-size: var(--fs-xs); font-weight: var(--fw-semi); white-space: nowrap; }
.case-builder__rows { display: grid; gap: var(--sp-3); }
.case-row {
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
  gap: var(--sp-3) var(--sp-4);
  padding: var(--sp-4);
  border: var(--bw-hair) solid var(--border-subtle);
  border-radius: var(--r-sm);
  background: var(--bg-surface);
}
.case-row__head { grid-column: 1 / -1; padding-bottom: var(--sp-2); border-bottom: var(--bw-hair) solid var(--border-subtle); }
.case-row label { min-width: 0; }
.field__label { color: var(--text-secondary); font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.advanced-settings {
  border-top: var(--bw-hair) solid var(--border-subtle);
  padding-top: var(--sp-3);
}
.advanced-settings summary { color: var(--text-tertiary); cursor: pointer; font-size: var(--fs-sm); }
.advanced-settings summary:hover { color: var(--text-primary); }
.advanced-settings textarea { margin-top: var(--sp-3); font-family: var(--font-mono); font-size: var(--fs-xs); }
.advanced-settings .actions { margin-top: var(--sp-2); }
.eyebrow { color: var(--accent-text); font-size: var(--fs-xs); font-weight: var(--fw-semi); letter-spacing: .08em; text-transform: uppercase; }
.overview__primary, .overview__grid { display: grid; gap: var(--sp-4); }
.overview__primary { grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr); }
.overview__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
[data-pane="overview"] { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
[data-pane="overview"] > .workspace-hero { grid-column: 1 / -1; }
[data-pane="overview"] > .panel:first-of-type { grid-column: 1 / -1; }
[data-pane="overview"] > .panel { min-width: 0; }
[data-pane="overview"] .section-head { align-items: flex-start; }
.topbar__context { display: flex; flex-direction: column; min-width: 150px; line-height: 1.15; }
.topbar__context-label { color: var(--text-tertiary); font-size: var(--fs-2xs); }
.topbar__context strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); font-weight: var(--fw-medium); }
@media (max-width: 860px) {
  .workspace-hero { align-items: flex-start; flex-direction: column; gap: var(--sp-5); padding: var(--sp-6); }
  .workspace-guide { padding: var(--sp-5); }
  .workspace-guide__head { flex-direction: column; }
  .workspace-guide__steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview__primary, .overview__grid, [data-pane="overview"] { grid-template-columns: minmax(0, 1fr); }
  [data-pane="overview"] > .panel:first-of-type { grid-column: auto; }
}
@media (max-width: 560px) {
  .workspace-guide { padding: var(--sp-4); }
  .workspace-guide__steps { grid-template-columns: minmax(0, 1fr); }
  .case-row { grid-template-columns: minmax(0, 1fr); }
  .case-row__head { grid-column: auto; }
}

/* ---- 页面头 Page Header ------------------------------------------------- */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-6); flex-wrap: wrap; padding-bottom: var(--sp-5); margin-bottom: var(--sp-5);
  border-bottom: var(--bw-hair) solid var(--border-subtle);
}
.page-head__title { font-size: var(--fs-2xl); letter-spacing: -0.02em; }
.page-head__desc { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--sp-2); margin-top: var(--sp-2); color: var(--text-secondary); font-size: var(--fs-base); max-width: 72ch; }
.page-head__sep { color: var(--text-disabled); }
.page-head__desc [data-field="pageDescription"] { color: var(--text-tertiary); }
.page-head__actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.breadcrumb { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-xs); color: var(--text-tertiary); margin-bottom: var(--sp-2); }
.breadcrumb a { color: var(--text-tertiary); }
.breadcrumb a:hover { color: var(--text-primary); }
.breadcrumb__sep { opacity: 0.5; }

/* ---- 按钮 Button -------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 34px; padding: 0 var(--sp-4);
  border: var(--bw-hair) solid transparent; border-radius: var(--r-sm);
  font-size: var(--fs-base); font-weight: var(--fw-medium); white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn--primary { background: var(--accent); color: var(--text-on-accent); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--primary:active { background: var(--accent-active); }
.btn--secondary { background: var(--bg-surface); color: var(--text-primary); border-color: var(--border-default); }
.btn--secondary:hover { background: var(--bg-surface-2); border-color: var(--border-strong); }
.btn--ghost { background: transparent; color: var(--text-secondary); }
.btn--ghost:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.btn--danger { background: var(--danger); color: var(--neutral-0); }
.btn--danger:hover { background: var(--rust-600); }
.btn--sm { min-height: 28px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn--lg { min-height: 42px; padding: 0 var(--sp-6); font-size: var(--fs-md); }
.btn--icon { width: 34px; min-height: 34px; padding: 0; }
.btn--icon.btn--sm { width: 28px; min-height: 28px; }
.btn__icon { width: 15px; height: 15px; }

/* 命令提示 ⌘K —— 键盘优先的细节 */
.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 4px;
  border: var(--bw-hair) solid var(--border-default); border-bottom-width: 2px;
  border-radius: var(--r-xs); background: var(--bg-surface-2);
  font-family: var(--font-mono); font-size: 10px; color: var(--text-tertiary);
}

/* ---- 表单 Form ---------------------------------------------------------- */
.field { display: grid; gap: var(--sp-2); }
.field__label { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-primary); }
.field__hint { font-size: var(--fs-xs); color: var(--text-tertiary); line-height: var(--lh-snug); }
.field__error { font-size: var(--fs-xs); color: var(--danger-text); display: flex; align-items: center; gap: var(--sp-1); }
.field--inline { display: flex; align-items: center; gap: var(--sp-3); }

.input, .select, .textarea {
  width: 100%; min-height: 34px; padding: 6px var(--sp-3);
  border: var(--bw-hair) solid var(--border-default); border-radius: var(--r-sm);
  background: var(--bg-surface); color: var(--text-primary);
  font-size: var(--fs-base);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.input::placeholder, .textarea::placeholder { color: var(--text-disabled); }  /* 占位符也守 4.5:1 */
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--border-focus); box-shadow: var(--focus-ring);
}
.input[aria-invalid="true"] { border-color: var(--danger); }
.textarea { min-height: 76px; resize: vertical; line-height: var(--lh-normal); }
.select {
  appearance: none; padding-right: var(--sp-8); cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237d8894' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.input[size="sm"] { min-height: 28px; font-size: var(--fs-sm); }

/* 搜索框 */
.search { position: relative; }
.search .input { padding-left: 32px; }
.search__icon { position: absolute; left: 10px; top: 50%; translate: 0 -50%; width: 14px; height: 14px; color: var(--text-tertiary); pointer-events: none; }

/* 复选框 / 开关 */
.check { display: flex; align-items: flex-start; gap: var(--sp-3); font-size: var(--fs-base); cursor: pointer; }
.check input { width: 15px; height: 15px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.switch { position: relative; width: 36px; height: 20px; flex: none; border-radius: var(--r-full); background: var(--border-default); transition: background var(--dur-fast) var(--ease-out); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: translate var(--dur-base) var(--ease-out); }
.check input:checked + .switch { background: var(--accent); }
.check input:checked + .switch::after { translate: 16px 0; }
.check input:focus-visible + .switch { box-shadow: var(--focus-ring); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4) var(--sp-5); }
.form-grid > .span-2 { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---- 面板 / 分区 Panel -------------------------------------------------- */
/* 立场：默认不用卡片边框 + 阴影，用 hairline 分组。需要抬升时才加 .card */
.section { padding: var(--sp-5) 0; border-top: var(--bw-hair) solid var(--border-subtle); }
.section:first-of-type { border-top: 0; padding-top: 0; }
.section__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.section__title { font-size: var(--fs-lg); }
.section__desc { font-size: var(--fs-sm); color: var(--text-secondary); margin-top: 2px; }

.card {
  background: var(--bg-surface); border: var(--bw-hair) solid var(--border-subtle);
  border-radius: var(--r-lg); box-shadow: var(--shadow-xs);
}
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: var(--bw-hair) solid var(--border-subtle); }
.card__body { padding: var(--sp-5); }
.card__foot { padding: var(--sp-3) var(--sp-5); border-top: var(--bw-hair) solid var(--border-subtle); background: var(--bg-surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* ---- 指标 Metric ------------------------------------------------------- */
/* 不走「大数字英雄卡」：数字居中+micro delta+极细 sparkline 组合 */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp-4); }
.metric {
  padding: var(--sp-4); border: var(--bw-hair) solid var(--border-subtle);
  border-radius: var(--r-md); background: var(--bg-surface);
  display: grid; gap: var(--sp-1);
  transition: border-color var(--dur-base) var(--ease-out);
}
.metric:hover { border-color: var(--border-strong); }
.metric__label { font-size: var(--fs-xs); color: var(--text-tertiary); letter-spacing: 0.02em; }
.metric__row { display: flex; align-items: baseline; gap: var(--sp-2); }
.metric__value { font-size: var(--fs-2xl); font-weight: var(--fw-semi); letter-spacing: -0.025em; line-height: 1.1; }
.metric__unit { font-size: var(--fs-xs); color: var(--text-tertiary); }
.metric__foot { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-xs); color: var(--text-tertiary); }
.metric__spark { width: 100%; height: 20px; margin-top: var(--sp-2); display: block; }

.delta { display: inline-flex; align-items: center; gap: 2px; font-size: var(--fs-xs); font-weight: var(--fw-medium); }
.delta--up { color: var(--success-text); }
.delta--down { color: var(--danger-text); }
.delta--flat { color: var(--text-tertiary); }

/* ---- Chip / Badge / Tag ------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  min-height: 22px; padding: 1px var(--sp-2);
  border: var(--bw-hair) solid var(--border-subtle); border-radius: var(--r-xs);
  background: var(--bg-surface-2); color: var(--text-secondary);
  font-size: var(--fs-xs); font-weight: var(--fw-medium); white-space: nowrap;
}
.chip--accent { background: var(--accent-subtle); border-color: color-mix(in oklab, var(--accent) 30%, transparent); color: var(--accent-text); }
.chip--success{ background: var(--success-bg); border-color: color-mix(in oklab, var(--success) 28%, transparent); color: var(--success-text); }
.chip--warning{ background: var(--warning-bg); border-color: color-mix(in oklab, var(--warning) 28%, transparent); color: var(--warning-text); }
.chip--danger { background: var(--danger-bg);  border-color: color-mix(in oklab, var(--danger) 28%, transparent);  color: var(--danger-text); }
.chip--info   { background: var(--info-bg);    border-color: color-mix(in oklab, var(--info) 28%, transparent);    color: var(--info-text); }
.chip--outline{ background: transparent; }
.chip--removable { padding-right: 3px; }

/* 状态点 —— 颜色之外还要有形状/文字，不靠颜色单独传达 */
.dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.dot--live { background: var(--success); box-shadow: 0 0 0 3px color-mix(in oklab, var(--success) 22%, transparent); animation: pulse 2.4s var(--ease-out) infinite; }
.dot--idle { background: var(--text-disabled); }
.dot--warn { background: var(--warning); }
.dot--bad  { background: var(--danger); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px color-mix(in oklab, var(--success) 22%, transparent); }
  50%      { box-shadow: 0 0 0 6px color-mix(in oklab, var(--success) 0%, transparent); }
}

/* ---- 表格 Table --------------------------------------------------------- */
/* 后台主力：粘性表头 + 行 hover + 行首状态色条 */
.table-wrap { border: var(--bw-hair) solid var(--border-subtle); border-radius: var(--r-lg); overflow: hidden; background: var(--bg-surface); }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-base); }
.table th {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg-surface-2); text-align: left; font-weight: var(--fw-medium);
  font-size: var(--fs-xs); color: var(--text-tertiary); letter-spacing: 0.03em;
  padding: var(--sp-3) var(--sp-4); white-space: nowrap;
  border-bottom: var(--bw-hair) solid var(--border-subtle);
}
.table td { padding: var(--sp-3) var(--sp-4); border-bottom: var(--bw-hair) solid var(--border-subtle); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--dur-fast) var(--ease-out); cursor: pointer; }
.table tbody tr:hover { background: var(--bg-surface-2); }
.table tbody tr[aria-selected="true"] { background: var(--accent-subtle); }
.table__num { text-align: right; font-variant-numeric: tabular-nums; }
.table__cell-main { font-weight: var(--fw-medium); color: var(--text-primary); }
.table__cell-sub { display: block; font-size: var(--fs-xs); color: var(--text-tertiary); margin-top: 1px; }
.table th[aria-sort] { cursor: pointer; user-select: none; }
.table th[aria-sort]:hover { color: var(--text-primary); }
.table th[aria-sort="descending"]::after,
.table th[aria-sort="ascending"]::after { content: " ↓"; font-size: 10px; color: var(--accent); }
.table th[aria-sort="ascending"]::after { content: " ↑"; }

/* 迷你条形量条 —— 表格内的微可视化 */
.bar { height: 4px; width: 72px; border-radius: var(--r-full); background: var(--bg-inset); overflow: hidden; }
.bar__fill { height: 100%; border-radius: var(--r-full); background: var(--accent); }

/* ---- 工具栏 Toolbar ----------------------------------------------------- */
.toolbar {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-surface-2);
  border: var(--bw-hair) solid var(--border-subtle); border-radius: var(--r-md);
  margin-bottom: var(--sp-4);
}
.toolbar__spacer { margin-left: auto; }
.toolbar .input, .toolbar .select { width: auto; min-width: 140px; }

/* 分段控制器 */
.segmented { display: inline-flex; padding: 2px; gap: 2px; background: var(--bg-inset); border-radius: var(--r-sm); }
.segmented button {
  min-height: 26px; padding: 0 var(--sp-3); border-radius: var(--r-xs);
  font-size: var(--fs-sm); color: var(--text-secondary); font-weight: var(--fw-medium);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.segmented button[aria-pressed="true"] { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-xs); }

/* ---- 抽屉 Drawer -------------------------------------------------------- */
/* 替代原来的「内联展开详情」—— 详情不抢走列表上下文 */
.scrim {
  position: fixed; inset: 0; z-index: var(--z-drawer); background: var(--bg-scrim);
  opacity: 0; pointer-events: none; transition: opacity var(--dur-base) var(--ease-out);
}
.scrim[data-open="true"] { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: calc(var(--z-drawer) + 1);
  width: min(520px, 100vw); display: flex; flex-direction: column;
  background: var(--bg-surface); border-left: var(--bw-hair) solid var(--border-subtle);
  translate: 100% 0; transition: translate var(--dur-slow) var(--ease-out);
  box-shadow: var(--shadow-xl);
}
.drawer[data-open="true"] { translate: 0 0; }
.drawer__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-5); border-bottom: var(--bw-hair) solid var(--border-subtle); }
.drawer__title { font-size: var(--fs-lg); }
.drawer__body { flex: 1; overflow-y: auto; padding: var(--sp-5); }
.drawer__foot { display: flex; gap: var(--sp-2); justify-content: flex-end; padding: var(--sp-4) var(--sp-5); border-top: var(--bw-hair) solid var(--border-subtle); background: var(--bg-surface-2); }
@media (max-width: 560px) {
  .drawer { top: auto; height: 88vh; width: 100vw; border-radius: var(--r-xl) var(--r-xl) 0 0; border-left: 0; }
}

/* 定义列表（详情面板的事实展示） */
.dl { display: grid; grid-template-columns: minmax(0, 34%) minmax(0, 1fr); gap: var(--sp-3) var(--sp-4); }
.dl dt { font-size: var(--fs-sm); color: var(--text-tertiary); }
.dl dd { font-size: var(--fs-base); margin: 0; }
@media (max-width: 520px) { .dl { grid-template-columns: minmax(0, 1fr); gap: 2px var(--sp-4); } .dl dd { margin-bottom: var(--sp-3); } }

/* 时间线 —— 审计/版本历史 */
.timeline { display: grid; gap: var(--sp-4); position: relative; padding-left: var(--sp-5); }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 1px; background: var(--border-subtle); }
.timeline__item { position: relative; }
.timeline__item::before { content: ""; position: absolute; left: calc(var(--sp-5) * -1); top: 6px; width: 11px; height: 11px; border-radius: 50%; background: var(--bg-surface); border: 2px solid var(--border-default); }
.timeline__item--now::before { border-color: var(--accent); background: var(--accent); }
.timeline__title { font-size: var(--fs-base); font-weight: var(--fw-medium); }
.timeline__meta { font-size: var(--fs-xs); color: var(--text-tertiary); }

/* ---- 空状态 Empty ------------------------------------------------------- */
.empty { padding: var(--sp-12) var(--sp-6); text-align: center; border: 1px dashed var(--border-default); border-radius: var(--r-lg); background: var(--bg-surface); }
.empty__art { margin: 0 auto var(--sp-4); color: var(--text-disabled); }
.empty__title { font-size: var(--fs-md); font-weight: var(--fw-semi); }
.empty__desc { margin: var(--sp-2) auto var(--sp-4); max-width: 46ch; font-size: var(--fs-sm); color: var(--text-secondary); }

/* ---- 骨架屏 Skeleton ---------------------------------------------------- */
.skeleton { background: linear-gradient(90deg, var(--bg-inset) 25%, var(--bg-surface-2) 50%, var(--bg-inset) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; border-radius: var(--r-sm); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---- 提示 Note / Alert -------------------------------------------------- */
.note { display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-sm); border: var(--bw-hair) solid; font-size: var(--fs-sm); line-height: var(--lh-snug); }
.note__icon { flex: none; margin-top: 1px; }
.note--info    { background: var(--info-bg);    border-color: color-mix(in oklab, var(--info) 26%, transparent);    color: var(--info-text); }
.note--warning { background: var(--warning-bg); border-color: color-mix(in oklab, var(--warning) 26%, transparent); color: var(--warning-text); }
.note--danger  { background: var(--danger-bg);  border-color: color-mix(in oklab, var(--danger) 26%, transparent);  color: var(--danger-text); }
.note--success { background: var(--success-bg); border-color: color-mix(in oklab, var(--success) 26%, transparent); color: var(--success-text); }
.note--neutral { background: var(--bg-surface-2); border-color: var(--border-subtle); color: var(--text-secondary); }

/* ---- Toast -------------------------------------------------------------- */
.toasts { position: fixed; bottom: var(--sp-6); right: var(--sp-6); z-index: var(--z-toast); display: grid; gap: var(--sp-3); width: min(360px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  background: var(--bg-surface); border: var(--bw-hair) solid var(--border-subtle);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  animation: toast-in var(--dur-slow) var(--ease-out);
}
@keyframes toast-in { from { opacity: 0; translate: 0 12px; } to { opacity: 1; translate: 0 0; } }
.toast__title { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.toast__desc { font-size: var(--fs-xs); color: var(--text-secondary); margin-top: 2px; }
.toast__close { margin-left: auto; color: var(--text-tertiary); }

/* ---- 头像 / 租户切换 ---------------------------------------------------- */
.avatar { width: 24px; height: 24px; border-radius: var(--r-full); display: grid; place-items: center; font-size: var(--fs-2xs); font-weight: var(--fw-semi); background: var(--accent-subtle); color: var(--accent-text); flex: none; }
.switcher { display: flex; align-items: center; gap: var(--sp-2); min-height: 30px; padding: 0 var(--sp-2); border-radius: var(--r-sm); border: var(--bw-hair) solid var(--border-subtle); background: var(--bg-surface); }
.switcher:hover { border-color: var(--border-strong); }

/* ---- 进度 --------------------------------------------------------------- */
.progress { height: 6px; border-radius: var(--r-full); background: var(--bg-inset); overflow: hidden; }
.progress__fill { height: 100%; border-radius: var(--r-full); background: var(--accent); transition: width var(--dur-slow) var(--ease-out); }

/* ---- 表格 Table ---------------------------------------------------------
   立场：数据是给人扫读的，所以列要对齐、表头要粘住、长列表要能排序。
   容器自己滚动，表头才粘得住；横向溢出交给 wrap，不让表格挤压页面。
   ------------------------------------------------------------------------ */
.table-wrap {
  max-height: min(62vh, 640px);
  overflow: auto;
  border: var(--bw-hair) solid var(--border-subtle);
  border-radius: var(--r-lg);
  background: var(--bg-surface);
  -webkit-overflow-scrolling: touch;
}
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
.table th,
.table td {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  vertical-align: top;
  border-bottom: var(--bw-hair) solid var(--border-subtle);
  overflow-wrap: anywhere;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-surface-2);
  color: var(--text-tertiary);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.table tbody tr:hover { background: var(--bg-surface-2); }
.table th.is-num,
.table td.is-num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.is-actions { white-space: nowrap; }
.table td.is-actions .btn { min-height: 28px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.table th.is-sortable { cursor: pointer; user-select: none; }
.table th.is-sortable:hover { color: var(--text-primary); }
.table th.is-sortable:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.sort-ind { display: inline-block; width: 12px; margin-left: 4px; color: var(--text-tertiary); opacity: 0.45; }
.table th[aria-sort] .sort-ind::after { content: "\2195"; }
.table th[aria-sort="ascending"] .sort-ind::after { content: "\2191"; }
.table th[aria-sort="descending"] .sort-ind::after { content: "\2193"; }
.table th[aria-sort="ascending"] .sort-ind,
.table th[aria-sort="descending"] .sort-ind { opacity: 1; color: var(--accent); }
.cell-title { font-weight: var(--fw-medium); color: var(--text-primary); }
.cell-sub { margin-top: 2px; font-size: var(--fs-xs); color: var(--text-tertiary); }

/* ---- 表格为空 / 加载中 -------------------------------------------------- */
.table-empty { padding: var(--sp-6) var(--sp-4); text-align: center; color: var(--text-tertiary); font-size: var(--fs-sm); }
.table-empty__hint { margin-top: var(--sp-2); color: var(--text-secondary); }
.skeleton { display: grid; gap: var(--sp-3); padding: var(--sp-2) 0; }
.skeleton-row { height: 34px; border-radius: var(--r-sm); background: var(--bg-inset); animation: skeleton-pulse 1.4s var(--ease-out) infinite; }
/* 有人对闪烁敏感，动效一律给得出关掉的理由。 */
@media (prefers-reduced-motion: reduce) { .skeleton-row { animation: none; } }
@keyframes skeleton-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ---- 工具类 ------------------------------------------------------------- */
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row--wrap { flex-wrap: wrap; }
.col { display: grid; gap: var(--sp-4); }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-secondary); }
.micro { font-size: var(--fs-xs); }
.mono { font-family: var(--font-mono); font-size: var(--fs-sm); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.center { text-align: center; }
[hidden] { display: none !important; }

/* -------------------------------------------------------------------------
   商用控制台主题层
   Tabler supplies the component primitives; this layer owns GEO's visual
   hierarchy and is intentionally last so legacy compatibility cannot dilute
   the shell. Business markup and data attributes remain unchanged.
   ------------------------------------------------------------------------- */
:root {
  --geo-sidebar: 264px;
  --geo-content-max: 1480px;
  --geo-focus: 0 0 0 3px color-mix(in oklab, var(--accent) 24%, transparent);
}

body {
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  -webkit-font-smoothing: antialiased;
}

.shell { grid-template-columns: var(--geo-sidebar) minmax(0, 1fr); }
.nav {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  box-shadow: 1px 0 0 color-mix(in oklab, var(--border-subtle) 45%, transparent);
}
.nav__brand { min-height: 72px; padding: 0 var(--sp-5); background: var(--bg-surface); }
.nav__logo { width: 34px; height: 34px; border-radius: 9px; font-size: var(--fs-sm); box-shadow: 0 5px 12px color-mix(in oklab, var(--accent) 22%, transparent); }
.nav__title { font-size: var(--fs-md); letter-spacing: .01em; }
.nav__sub { margin-top: 3px; font-size: var(--fs-xs); }
.nav__scroll { padding: var(--sp-5) var(--sp-4); }
.nav__group + .nav__group { margin-top: var(--sp-6); }
.nav__group-label { padding: 0 var(--sp-3) var(--sp-2); color: var(--text-tertiary); font-size: 10px; letter-spacing: .12em; }
.nav__item { min-height: 38px; padding: 8px var(--sp-3); border-radius: var(--r-md); font-size: var(--fs-sm); }
.nav__item[aria-current="page"] { background: var(--accent-subtle); color: var(--accent-text); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--accent) 15%, transparent); }
.nav__item[aria-current="page"]::before { left: -16px; width: 3px; height: 22px; }
#customerGroup { margin-bottom: var(--sp-6); padding: var(--sp-3); border: 1px solid var(--border-subtle); border-radius: var(--r-md); background: var(--bg-surface-2); }
#customerGroup .nav__group-label { padding-inline: 0; color: var(--accent-text); }
#customerGroup .customer-search { margin-bottom: var(--sp-3) !important; }
#customerGroup .customer { padding: 8px; }
.nav__foot { padding: var(--sp-4); }
.nav-create { min-height: 36px; }

.topbar { height: 64px; padding: 0 clamp(20px, 3vw, 44px); background: color-mix(in oklab, var(--bg-surface) 94%, transparent); }
.topbar__context { display: grid; gap: 2px; min-width: 0; }
.topbar__context-label { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.topbar__context strong { font-size: var(--fs-sm); font-weight: var(--fw-semi); }
.topbar #roleBadge { min-height: 26px; }
.content { max-width: var(--geo-content-max); padding: clamp(28px, 4vw, 52px) clamp(20px, 4vw, 56px) 64px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-6); margin-bottom: var(--sp-6); }
.breadcrumb { min-height: 18px; color: var(--text-tertiary); font-size: var(--fs-xs); }
.page-head__title { margin-top: 4px; font-size: clamp(1.55rem, 1.15rem + .8vw, 2rem); line-height: 1.2; letter-spacing: -.025em; }
.page-head__desc { margin-top: 8px; font-size: var(--fs-sm); }
.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-6); }
.metric { min-height: 104px; padding: var(--sp-5); border-radius: var(--r-md); box-shadow: var(--shadow-xs); }
.metric__value { margin-top: 5px; font-size: clamp(1.5rem, 1.2rem + .8vw, 2rem); }

.workspace-hero { margin-bottom: var(--sp-6); padding: clamp(24px, 3vw, 36px); border-radius: var(--r-md); background: linear-gradient(120deg, var(--bg-surface), color-mix(in oklab, var(--accent-subtle) 45%, var(--bg-surface))); }
.workspace-hero h2 { max-width: 22ch; font-size: clamp(1.45rem, 1.1rem + .8vw, 2.1rem); }
.workspace-hero p { max-width: 58ch; line-height: var(--lh-loose); }
.workspace-hero__actions { align-self: flex-end; }
.workspace-guide { margin-bottom: var(--sp-6); padding: var(--sp-5); border: 1px solid var(--border-subtle); border-top: 2px solid var(--accent); background: var(--bg-surface); border-radius: var(--r-md); }
.workspace-guide__head { margin-bottom: var(--sp-4); }
.workspace-guide__head h2 { font-size: var(--fs-lg); }
.workspace-guide__steps { border-radius: var(--r-sm); overflow: hidden; }
.guide-step { min-height: 82px; padding: var(--sp-4); }

.surface.panel { border-radius: var(--r-md); box-shadow: var(--shadow-xs); }
.section-head { margin-bottom: var(--sp-5); }
.section-head h2 { font-size: var(--fs-md); font-weight: var(--fw-semi); }
.list, .table-wrap { border-radius: var(--r-md); }
.table-wrap { max-height: min(64vh, 680px); }
.table th { height: 42px; background: var(--bg-surface-2); }
.table td { min-height: 48px; }

.login { min-height: 100dvh; padding: clamp(20px, 5vw, 64px); background: var(--bg-canvas); }
.login__box { width: min(448px, 100%); border: 1px solid var(--border-subtle); border-radius: var(--r-lg); box-shadow: var(--shadow-xl); }
.login__box .card__body { padding: clamp(28px, 5vw, 44px); }
.login__brand { margin-bottom: var(--sp-8); }
.login__brand .nav__logo { width: 42px; height: 42px; }
.login__brand .nav__title { font-size: var(--fs-lg); }
.login__hint { line-height: var(--lh-loose); }
.login .btn[type="submit"] { width: 100%; min-height: 40px; margin-top: var(--sp-2); }
.field { gap: 6px; }
.field__label { font-size: var(--fs-sm); }

.btn { min-height: 36px; border-radius: var(--r-sm); transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out); }
.btn:not(:disabled):active { transform: translateY(1px); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; box-shadow: var(--geo-focus); }
input, select, textarea { min-height: 38px; border-radius: var(--r-sm); }
textarea { min-height: 96px; }

.scrim { backdrop-filter: blur(2px); }
.drawer { width: min(600px, 100vw); }
.drawer__head { min-height: 76px; padding: var(--sp-5) clamp(20px, 4vw, 32px); }
.drawer__body { padding: clamp(20px, 4vw, 32px); }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 232px minmax(0, 1fr); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace-guide__steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav { width: min(304px, 88vw); }
  .content { padding: 24px 18px 48px; }
  .topbar { padding-inline: 16px; }
  .workspace-guide__steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .page-head { align-items: flex-start; }
  .metrics { grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); }
  .metric { min-height: 88px; }
  .workspace-hero { align-items: stretch; padding: 24px; }
  .workspace-hero__actions { align-self: stretch; }
  .workspace-hero__actions .btn { flex: 1; }
  .workspace-guide__steps { grid-template-columns: minmax(0, 1fr); }
  .guide-step { min-height: 66px; }
  .table-wrap { margin-inline: -2px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
