/* Design direction: OmiClaw-aligned gradient clinical workspace (impeccable, user brief).
 * Palette and surface rules taken from the reverse-engineered OmiClaw storefront CSS:
 * brand #6f5cff, sky #4ab6ff, emerald #10b981, amber #f59e0b, rose #f43f5e, shell #f4f5fb. */
@import url("./tokens.css");
@import url("./base.css");

html, body { overflow-x: clip; }
.hidden { display: none !important; }
.muted { color: var(--color-muted); }

/* shell */
.app-shell { display: grid; grid-template-columns: clamp(220px, 16vw, 248px) minmax(0, 1fr); min-height: 100dvh; }

.sidebar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky-nav);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  height: 100dvh;
  padding: var(--space-lg) var(--space-sm) var(--space-md);
  background: var(--grad-sidebar);
  border-right: var(--rule-hair) solid #6f5cff14;
  overflow: hidden;
}
.sidebar::before,
.sidebar::after { content: ""; position: absolute; z-index: 0; border-radius: 50%; filter: blur(48px); pointer-events: none; }
.sidebar::before { top: -104px; right: -116px; width: 312px; height: 312px; background: radial-gradient(circle, #4ab6ff57, #6f5cff3d 48%, #0000 72%); }
.sidebar::after { bottom: 112px; left: -116px; width: 264px; height: 264px; background: radial-gradient(circle, #6f5cff38, #7fd6ff1f 50%, #0000 72%); }
.sidebar > * { position: relative; z-index: 1; }

.brand {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 100%;
  padding: var(--space-md) var(--space-xs) var(--space-sm);
  text-align: center;
}
.brand-text { min-width: 0; text-align: center; }
.brand-text strong {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-text small { display: block; margin-top: var(--space-2xs); color: var(--color-muted); font-size: var(--text-xs); }

.nav { display: flex; flex-direction: column; gap: var(--space-2xs); }
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  height: 48px;
  padding: 0 var(--space-sm);
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--color-ink);
  font-size: var(--text-md);
  text-align: left;
  transition: background-color var(--dur-short), color var(--dur-short), box-shadow var(--dur-short);
}
.nav-item svg { flex: none; color: #9097bb; transition: color var(--dur-short); }
.nav-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.nav-text em { font-style: normal; font-size: 0.6875rem; font-weight: 400; line-height: 1.2; color: var(--color-muted-2); }
.nav-item:hover { background: #ffffff6b; }
.nav-item:active { background: #ffffff8f; }
.nav-item.active { background: #ffffff80; box-shadow: var(--shadow-sm); font-weight: 600; }
.nav-item.active svg { color: var(--color-brand); }
.nav-item.active .nav-text em { color: var(--color-brand-deep); }


.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  padding: var(--space-sm);
  border: var(--rule-hair) solid #ffffff75;
  border-radius: 14px;
  background: #ffffff59;
  box-shadow: inset 0 1px #ffffff47, var(--shadow-sm);
}
.foot-status { color: var(--color-ink-2); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.foot-status + .foot-status { color: var(--color-muted); }
.foot-status.warn { color: var(--color-danger); }
.foot-note { margin-top: var(--space-xs); color: var(--color-muted-2); font-size: var(--text-xs); line-height: 1.6; }
.foot-logout { align-self: flex-start; margin-top: var(--space-xs); padding: 0; border: 0; background: none; color: var(--color-muted); font: inherit; font-size: var(--text-xs); text-align: left; cursor: pointer; }
.foot-logout:hover { color: var(--color-brand); }

.main-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: calc(100dvh - (2 * var(--space-md)));
  min-height: 0;
  margin: var(--space-md) var(--space-md) var(--space-md) 0;
  border-radius: var(--radius-panel);
  background: rgb(255 255 255 / 0.55);
  overflow: hidden;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  height: var(--header-height);
  padding: 0 var(--space-xl);
  background: transparent;
}
.topbar-title { min-width: 0; }
.page-kicker { display: block; margin-bottom: var(--space-3xs); color: var(--color-muted); font-size: var(--text-xs); }
.page-title { font-size: 1.875rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.12; color: var(--color-ink); }
.topbar-note {
  padding: var(--space-2xs) var(--space-sm);
  border: var(--rule-hair) solid var(--color-border-soft);
  border-radius: var(--radius-pill);
  background: rgb(255 255 255 / 0.7);
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.main { flex: 1; min-height: 0; width: 100%; max-width: none; margin-inline: auto; padding: 0 var(--space-xl) var(--space-xl); overflow-y: auto; }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 var(--space-md);
  border: var(--rule-hair) solid var(--color-rule-strong);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-ink);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: background-color var(--dur-short), border-color var(--dur-short), box-shadow var(--dur-short);
}
.btn:hover { background: var(--color-surface-2); border-color: var(--color-muted-2); box-shadow: var(--shadow-sm); }
.btn:active { background: var(--color-surface-3); }
.btn.primary { background: var(--grad-brand); border-color: transparent; color: var(--color-primary-ink); box-shadow: var(--shadow-sm); }
.btn.primary:hover { background: var(--grad-brand-hover); box-shadow: var(--shadow-md); }
.btn.primary:active { background: var(--grad-brand-hover); }
.btn.ghost { background: var(--color-surface); }
.btn.small { min-height: 30px; padding: 0 var(--space-sm); font-size: var(--text-xs); }
.btn:disabled { background: var(--color-surface-2); border-color: var(--color-rule); color: var(--color-muted-2); cursor: not-allowed; box-shadow: none; }

/* page head as the gradient banner */
.page-head {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
  padding: 26px 30px;
  border: var(--rule-hair) solid var(--color-border-soft);
  border-radius: var(--radius-card);
  background: var(--grad-hero);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.page-head::after {
  content: "";
  position: absolute;
  right: 8%;
  top: -40px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffb84f5c, #ffb84f00 70%);
  pointer-events: none;
}
.page-head > * { position: relative; z-index: 1; }
.page-head h2 { font-size: var(--text-2xl); letter-spacing: -0.02em; }
.page-head p { color: var(--color-ink-2); font-size: var(--text-sm); margin-top: var(--space-xs); max-width: 72ch; }

/* chat */
#view-chat { height: 100%; }
.chat-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: var(--gap-columns);
  height: 100%;
  min-height: 0;
}
.chat-side {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: 28px;
  border: var(--rule-hair) solid var(--color-border-soft);
  border-radius: var(--radius-card);
  background: var(--grad-hero);
  box-shadow: var(--shadow-md);
  overflow-y: auto;
}
.chat-side::before,
.chat-side::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.chat-side::before { top: -70px; right: -70px; width: 190px; height: 190px; background: radial-gradient(circle, #4ab6ff66, #4ab6ff00 70%); }
.chat-side::after { bottom: -90px; left: -70px; width: 200px; height: 200px; background: radial-gradient(circle, #ffb84f59, #ffb84f00 70%); }
.chat-side > * { position: relative; z-index: 1; }
.chat-side-title { font-size: var(--text-xl); letter-spacing: -0.02em; }
.side-copy { color: var(--color-ink-2); font-size: var(--text-sm); line-height: 1.65; }
.side-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-sm); }
.side-stat { padding: var(--space-sm); border-radius: 14px; background: rgb(255 255 255 / 0.66); min-width: 0; }
.side-stat span { display: block; color: var(--color-muted); font-size: var(--text-xs); }
.side-stat strong { display: block; margin-top: var(--space-3xs); color: var(--color-ink); font-size: var(--text-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
.side-label { color: var(--color-muted); font-size: var(--text-xs); }
.quick-list { display: flex; flex-direction: column; gap: var(--space-2xs); }
.quick-list button {
  padding: var(--space-xs) var(--space-sm);
  border: var(--rule-hair) solid transparent;
  border-radius: var(--radius-control);
  background: rgb(255 255 255 / 0.66);
  color: var(--color-ink);
  font-size: var(--text-sm);
  line-height: 1.5;
  text-align: left;
  transition: background-color var(--dur-short), border-color var(--dur-short);
}
.quick-list button:hover { background: #ffffff; border-color: #6f5cff33; }
.quick-list button:active { background: var(--color-brand-subtle); }

.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: var(--rule-hair) solid var(--color-border-soft);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
  color: var(--color-ink);
  overflow: hidden;
}
.panel-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); padding: var(--space-sm) var(--space-lg); border-bottom: var(--rule-hair) solid var(--color-rule-2); }
.panel-bar-title { font-size: var(--text-md); font-weight: 600; }
.panel-bar-state { color: var(--color-muted); font-size: var(--text-xs); }
.daily-strip { display: flex; align-items: center; gap: var(--space-xs); padding: var(--space-xs) var(--space-lg); border-bottom: var(--rule-hair) solid var(--color-rule-2); overflow-x: auto; background: var(--color-surface-2); }
.daily-label { color: var(--color-muted); font-size: var(--text-xs); white-space: nowrap; padding-right: var(--space-2xs); }
.daily-strip button {
  padding: var(--space-2xs) var(--space-sm);
  border: var(--rule-hair) solid var(--color-rule);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-ink-2);
  font-size: var(--text-xs);
  white-space: nowrap;
  transition: background-color var(--dur-micro), border-color var(--dur-micro), color var(--dur-micro);
}
.daily-strip button:hover { background: var(--color-brand-subtle); border-color: #6f5cff33; color: var(--color-brand-deep); }
.daily-strip button:active { background: var(--color-primary-soft-2); }

.chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-lg); display: flex; flex-direction: column; gap: var(--space-md); }
.chat-empty { position: relative; margin: auto; max-width: 470px; padding: var(--space-xl); border: var(--rule-hair) solid var(--color-border-soft); border-radius: 20px; background: var(--grad-hero); text-align: center; color: var(--color-muted); overflow: hidden; }
.chat-empty::before,
.chat-empty::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.chat-empty::before { top: -52px; right: -46px; width: 140px; height: 140px; background: radial-gradient(circle, #4ab6ff5c, #4ab6ff00 70%); }
.chat-empty::after { bottom: -58px; left: -46px; width: 140px; height: 140px; background: radial-gradient(circle, #ffb84f52, #ffb84f00 70%); }
.chat-empty > * { position: relative; z-index: 1; }

.delta { display: inline-flex; align-self: flex-start; padding: var(--space-3xs) var(--space-xs); border-radius: 6px; font-size: 0.6875rem; font-style: normal; font-weight: 600; line-height: 1.4; }
.delta.up { background: #bef0d2; color: #0f7a5a; }
.delta.down { background: #fde8ea; color: #b42318; }
.delta.flat { background: var(--color-surface-2); color: var(--color-muted); }
.empty-title { font-size: var(--text-lg); color: var(--color-ink); }
.chat-empty p { font-size: var(--text-sm); margin-top: var(--space-xs); line-height: 1.6; }

.msg { display: flex; gap: var(--space-sm); min-width: 0; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { max-width: 78%; padding: var(--space-sm) var(--space-md); border-radius: 16px; background: var(--grad-brand); color: var(--color-primary-ink); }
.msg.assistant { align-items: flex-start; }
.avatar { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 10px; background: var(--color-brand-subtle); color: var(--color-brand-deep); font-size: var(--text-xs); font-weight: 600; }
.bubble { flex: 1; min-width: 0; }
.msg.assistant .bubble { padding-top: var(--space-3xs); }

.skill-row { display: flex; align-items: center; gap: var(--space-xs); margin-bottom: var(--space-xs); }
.skill-row-label { color: var(--color-muted); font-size: var(--text-xs); white-space: nowrap; }
.skill-combobox { position: relative; flex: 1; max-width: 340px; min-width: 0; }
.skill-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
  width: 100%;
  height: 34px;
  padding: 0 var(--space-sm);
  border: var(--rule-hair) solid var(--color-rule);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-ink-2);
  font-size: var(--text-xs);
  text-align: left;
  transition: border-color var(--dur-micro), box-shadow var(--dur-micro);
}
.skill-trigger:hover { border-color: var(--color-rule-strong); }
.skill-trigger[aria-expanded="true"] { border-color: #6f5cff66; box-shadow: 0 0 0 4px var(--color-brand-glow); }
.skill-trigger svg { flex: none; color: var(--color-muted); }
.skill-trigger-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skill-popover {
  position: absolute;
  left: 0;
  bottom: calc(100% + var(--space-xs));
  z-index: var(--z-dropdown);
  width: 380px;
  max-width: min(86vw, 380px);
  padding: var(--space-xs);
  border: var(--rule-hair) solid var(--color-border-soft);
  border-radius: 16px;
  background: var(--color-surface);
  box-shadow: 0 18px 42px rgb(31 34 51 / 0.14);
}
.skill-search-wrap { position: relative; padding: var(--space-3xs) var(--space-3xs) var(--space-xs); }
.skill-search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--color-muted); }
.skill-search { width: 100%; height: 34px; padding: 0 var(--space-sm) 0 32px; border: var(--rule-hair) solid var(--color-rule); border-radius: 10px; background: var(--color-surface-2); color: var(--color-ink); font-size: var(--text-xs); }
.skill-search:focus-visible { outline: none; border-color: #6f5cff66; box-shadow: 0 0 0 4px var(--color-brand-glow); }
.skill-options { max-height: 300px; overflow-y: auto; }
.skill-group-label { padding: var(--space-xs) var(--space-xs) var(--space-3xs); color: var(--color-muted); font-size: 0.6875rem; }
.skill-option {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  width: 100%;
  padding: var(--space-xs);
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--color-ink);
  text-align: left;
  transition: background-color var(--dur-micro);
}
.skill-option:hover, .skill-option.is-active { background: var(--color-surface-2); }
.skill-option.is-selected { background: var(--color-primary-soft); color: var(--color-brand-deep); }
.skill-option svg { flex: none; color: var(--color-brand); }
.skill-option-main { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
.skill-option-main strong { font-size: var(--text-xs); font-weight: 600; }
.skill-option-main small { color: var(--color-muted); font-size: 0.6875rem; }
.skill-option.is-selected .skill-option-main small { color: var(--color-brand-deep); opacity: 0.75; }
.skill-empty { padding: var(--space-lg); color: var(--color-muted); font-size: var(--text-xs); text-align: center; }

.composer { padding: var(--space-sm) var(--space-lg) var(--space-md); border-top: var(--rule-hair) solid var(--color-rule-2); }
.composer-field { display: flex; align-items: flex-end; gap: var(--space-xs); padding: var(--space-2xs) var(--space-2xs) var(--space-2xs) var(--space-md); border: var(--rule-hair) solid transparent; border-radius: 14px; background: var(--color-surface-2); transition: border-color var(--dur-short), box-shadow var(--dur-short); }
.composer-field:focus-within { border-color: #6f5cff66; box-shadow: 0 0 0 4px var(--color-brand-glow); background: var(--color-surface); }
.composer-field textarea { flex: 1; min-width: 0; max-height: 120px; padding: var(--space-xs) 0; border: 0; background: none; resize: none; font-size: var(--text-md); line-height: 1.5; outline: none; }
.composer-send { min-height: 34px; padding-inline: var(--space-md); }
.composer-hint { display: flex; gap: var(--space-sm); margin-top: var(--space-xs); color: var(--color-muted-2); font-size: var(--text-xs); }
.composer-hint span + span { padding-left: var(--space-sm); border-left: var(--rule-hair) solid var(--color-rule); }

/* answer blocks */
.answer-head { display: flex; justify-content: space-between; gap: var(--space-md); margin-bottom: var(--space-sm); }
.answer-title { font-size: var(--text-lg); font-weight: 700; }
.answer-sub { margin-top: var(--space-2xs); color: var(--color-muted); font-size: var(--text-sm); line-height: 1.55; }
.answer-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-xs); margin: var(--space-sm) 0; }
.answer-kpi { display: flex; flex-direction: column; gap: var(--space-2xs); padding: var(--space-sm); border-radius: 14px; background: var(--color-surface-2); min-width: 0; }
.answer-kpi span { color: var(--color-muted); font-size: var(--text-xs); }
.answer-kpi strong { font-size: var(--text-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
.answer-chart { height: 200px; margin: var(--space-sm) 0; }
.answer-actions { display: flex; flex-wrap: wrap; gap: var(--space-xs); margin-top: var(--space-sm); }

/* action list */
.action-list { display: flex; flex-direction: column; gap: var(--space-xs); }
.action-card { display: grid; grid-template-columns: 88px minmax(0, 1fr) 96px; gap: var(--space-md); padding: var(--space-sm); border: var(--rule-hair) solid var(--color-border-soft); border-radius: 16px; background: var(--color-surface); }
.action-priority { color: var(--color-danger); font-size: var(--text-xs); font-weight: 600; }
.action-priority.mid { color: var(--color-warning); }
.action-main { min-width: 0; }
.action-main strong { font-size: var(--text-md); font-weight: 600; }
.action-main p { margin-top: var(--space-2xs); color: var(--color-muted); font-size: var(--text-sm); line-height: 1.5; }
.action-meta { color: var(--color-muted); font-size: var(--text-xs); text-align: right; font-variant-numeric: tabular-nums; }
.action-meta strong { display: block; color: var(--color-ink); font-size: var(--text-lg); font-weight: 700; }
.action-customers { grid-column: 1 / -1; overflow-x: auto; }

/* tables */
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
thead th { position: sticky; top: 0; z-index: var(--z-raised); padding: var(--space-xs) var(--space-sm); border-bottom: var(--rule-hair) solid var(--color-rule); background: var(--color-surface-2); color: var(--color-muted); font-size: var(--text-xs); font-weight: 600; text-align: left; white-space: nowrap; }
tbody td { padding: var(--space-xs) var(--space-sm); border-bottom: var(--rule-hair) solid var(--color-rule-2); color: var(--color-ink-2); }
tbody tr:hover td { background: var(--color-surface-2); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
th.nowrap, td.nowrap { white-space: nowrap; }

.ai-answer { margin: var(--space-sm) 0; padding: var(--space-md); border-radius: var(--radius-control); background: var(--color-surface-2); color: var(--color-ink-2); font-size: var(--text-md); line-height: 1.75; }

.plan-sections { display: flex; flex-direction: column; gap: 14px; margin: 4px 0 16px; }
.plan-section { padding: 14px 16px; border-radius: 14px; background: var(--color-surface-2); }
.plan-section h3 { margin-bottom: 6px; font-size: 15px; font-weight: 600; }
.plan-section p { color: var(--color-ink-2); font-size: 13px; line-height: 1.65; }
.plan-section ul { margin: 8px 0 0; padding-left: 18px; color: var(--color-muted); font-size: 13px; line-height: 1.7; }
.plan-section li::marker { color: var(--color-brand); }

.skill-launcher { max-width: 720px; }
.skill-followup { margin-top: var(--space-lg); padding-top: var(--space-md); border-top: var(--rule-hair) solid var(--color-rule-2); }
.skill-need-label { display: block; margin: var(--space-md) 0 var(--space-xs); color: var(--color-ink-2); font-size: var(--text-sm); font-weight: 600; }
.skill-need { width: 100%; padding: var(--space-sm); border: var(--rule-hair) solid var(--color-rule-strong); border-radius: var(--radius-control); background: var(--color-surface); font-size: var(--text-md); line-height: 1.6; resize: vertical; }
.skill-need:focus-visible { outline: none; border-color: #6f5cff66; box-shadow: 0 0 0 4px var(--color-brand-glow); }
.skill-examples { display: flex; flex-direction: column; gap: var(--space-2xs); margin-top: var(--space-sm); }
.skill-example { padding: var(--space-xs) var(--space-sm); border: var(--rule-hair) dashed var(--color-rule); border-radius: var(--radius-control); background: var(--color-surface-2); color: var(--color-muted); font-size: var(--text-xs); text-align: left; }
.skill-example:hover { border-color: var(--color-rule-strong); color: var(--color-ink-2); }

#ops-catalog-list .catalog-item { grid-template-columns: minmax(0, 1fr) 40px; }
#ops-catalog-list .catalog-no { display: none; }

/* customer 360 drawer */
.drawer-backdrop { position: fixed; inset: 0; z-index: 350; background: rgb(31 34 51 / 0.28); }
.customer-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 400;
  width: min(620px, 100vw);
  height: 100dvh;
  padding: var(--space-lg);
  overflow-y: auto;
  background: var(--color-paper);
  border-left: var(--rule-hair) solid var(--color-rule);
  box-shadow: var(--shadow-lg);
}
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-md); padding-bottom: var(--space-md); border-bottom: var(--rule-hair) solid var(--color-rule); }
.drawer-kicker { color: var(--color-muted); font-size: var(--text-xs); }
.drawer-head h2 { margin-top: var(--space-2xs); font-size: var(--text-xl); }
.drawer-head p { margin-top: var(--space-2xs); color: var(--color-muted); font-size: var(--text-sm); }
.drawer-close { width: 32px; height: 32px; border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-control); background: var(--color-surface); font-size: 18px; line-height: 1; }
.drawer-badges { display: flex; flex-wrap: wrap; gap: var(--space-2xs); margin: var(--space-sm) 0; }
.drawer-badges .tag.warn { background: var(--tint-rose); color: var(--tint-rose-ink); }
.drawer-badges .tag.ok { background: var(--tint-green); color: var(--tint-green-ink); }
.drawer-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--rule-hair); margin: var(--space-md) 0; border: var(--rule-hair) solid var(--color-rule); background: var(--color-rule); }
.drawer-stat { padding: var(--space-sm); background: var(--color-surface); }
.drawer-stat span { display: block; color: var(--color-muted); font-size: var(--text-xs); }
.drawer-stat strong { display: block; margin-top: var(--space-3xs); font-size: var(--text-lg); font-weight: 600; font-variant-numeric: tabular-nums; }
.drawer-section { margin-top: var(--space-lg); }
.drawer-section h3 { margin-bottom: var(--space-sm); font-size: var(--text-md); }
.task-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-xs); padding: var(--space-sm); border-radius: var(--radius-control); background: var(--color-surface-2); }
.task-form input, .task-form select, .task-form textarea { width: 100%; min-height: 34px; padding: var(--space-2xs) var(--space-xs); border: var(--rule-hair) solid var(--color-rule); border-radius: 8px; background: var(--color-surface); font-size: var(--text-sm); }
.task-form textarea { grid-column: 1 / -1; min-height: 60px; resize: vertical; }
.task-form .full { grid-column: 1 / -1; }
.task-list { display: flex; flex-direction: column; gap: var(--space-xs); margin-top: var(--space-sm); }
.task-item { padding: var(--space-sm); border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-control); background: var(--color-surface); }
.task-item.done { opacity: 0.62; }
.task-item-head { display: flex; justify-content: space-between; gap: var(--space-sm); }
.task-item strong { font-size: var(--text-sm); }
.task-item p { margin-top: var(--space-2xs); color: var(--color-muted); font-size: var(--text-xs); }
.task-item button { margin-top: var(--space-xs); }
.timeline { display: flex; flex-direction: column; }
.timeline-row { display: grid; grid-template-columns: 82px 46px minmax(0, 1fr) auto; gap: var(--space-xs); padding: var(--space-xs) 0; border-bottom: var(--rule-hair) solid var(--color-rule-2); font-size: var(--text-xs); }
.timeline-date { color: var(--color-muted); font-variant-numeric: tabular-nums; }
.timeline-type { color: var(--color-brand-deep); }
.timeline-main strong { display: block; color: var(--color-ink); font-size: var(--text-sm); font-weight: 500; }
.timeline-main span { color: var(--color-muted); }
.timeline-amount { text-align: right; font-variant-numeric: tabular-nums; color: var(--color-ink-2); }
.top-projects { display: flex; flex-wrap: wrap; gap: var(--space-2xs); }
@media (max-width: 640px) { .customer-drawer { width: 100vw; padding: var(--space-md); } .drawer-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .timeline-row { grid-template-columns: 74px 42px minmax(0, 1fr); } .timeline-amount { grid-column: 3; text-align: left; } }

/* pager */
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); padding: var(--space-sm) var(--space-lg); border-top: var(--rule-hair) solid var(--color-rule-2); color: var(--color-muted); font-size: var(--text-xs); }
.pager-actions { display: flex; align-items: center; gap: var(--space-xs); }
.pager-size { height: 32px; padding: 0 var(--space-xs); border: var(--rule-hair) solid var(--color-rule-strong); border-radius: 8px; background: var(--color-surface); color: var(--color-ink); font-size: var(--text-xs); }
@media (max-width: 640px) { .pager { flex-direction: column; align-items: flex-start; } }

/* chips and tags */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2xs); margin-bottom: var(--space-md); }
.chip, .tag { display: inline-flex; align-items: center; padding: var(--space-3xs) var(--space-sm); border-radius: var(--radius-pill); background: var(--tint-purple); color: var(--tint-purple-ink); font-size: var(--text-xs); font-weight: 500; }

/* query */
.query-panel { margin-bottom: var(--space-md); border: var(--rule-hair) solid var(--color-border-soft); border-radius: var(--radius-card); background: var(--color-surface); box-shadow: var(--shadow-sm); overflow: hidden; }
.query-panel-head { display: flex; justify-content: space-between; gap: var(--space-md); padding: var(--space-xs) var(--space-lg); border-bottom: var(--rule-hair) solid var(--color-rule-2); background: var(--color-surface-2); }
.field-label { color: var(--color-ink); font-size: var(--text-xs); font-weight: 600; }
.field-hint { color: var(--color-muted); font-size: var(--text-xs); }
.query-panel-body { display: flex; gap: var(--space-xs); padding: var(--space-md) var(--space-lg); }
.query-input { flex: 1; min-width: 0; height: 44px; padding: 0 var(--space-md); border: var(--rule-hair) solid var(--color-rule-strong); border-radius: 14px; background: var(--color-surface); font-size: var(--text-md); }
.query-input:focus-visible,
.ask-bar input:focus-visible,
.field input:focus-visible,
.field select:focus-visible { outline: none; border-color: #6f5cff66; box-shadow: 0 0 0 4px var(--color-brand-glow); }

/* measurements */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap-columns); margin-bottom: var(--space-lg); }
.kpi-card { display: flex; flex-direction: column; gap: var(--space-2xs); padding: 24px 26px; border: var(--rule-hair) solid var(--color-border-soft); border-radius: var(--radius-card); background: var(--color-surface); box-shadow: var(--shadow-sm); color: var(--color-ink); min-width: 0; }
.kpi-label { color: var(--color-muted); font-size: var(--text-xs); font-weight: 500; }
.kpi-value { font-size: 2rem; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-note { align-self: flex-start; padding: var(--space-3xs) var(--space-xs); border-radius: 6px; background: var(--color-surface-2); color: var(--color-muted); font-size: var(--text-xs); }
#query-kpis:empty, #query-charts:empty, #query-chips:empty, #data-kpis:empty { display: none; }

/* charts */
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap-columns); margin-bottom: var(--space-lg); }
.chart-card { min-width: 0; padding: 24px; border: var(--rule-hair) solid var(--color-border-soft); border-radius: var(--radius-card); background: var(--color-surface); box-shadow: var(--shadow-sm); color: var(--color-ink); }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-sm); padding-bottom: var(--space-xs); border-bottom: var(--rule-hair) solid var(--color-rule-2); }
.chart-title { font-size: var(--text-md); font-weight: 700; }
.chart-title::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: var(--space-xs); border-radius: 50%; background: var(--color-brand); vertical-align: 2px; }
.chart-card:nth-child(2n) .chart-title::before { background: var(--color-blue); }
.chart-card:nth-child(3n) .chart-title::before { background: var(--color-success); }
.chart-card:nth-child(4n) .chart-title::before { background: var(--color-warning); }
.chart-sub { color: var(--color-muted); font-size: var(--text-xs); }
.chart-box { height: 220px; margin-top: var(--space-sm); }
.chart-box.tall { height: 280px; }
.chart-box canvas, .result-chart canvas, .answer-chart canvas { width: 100% !important; height: 100% !important; }

/* panels */
.surface.panel { margin-bottom: var(--space-md); border: var(--rule-hair) solid var(--color-border-soft); border-radius: var(--radius-card); background: var(--color-surface); box-shadow: var(--shadow-sm); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); padding: var(--space-sm) var(--space-lg); border-bottom: var(--rule-hair) solid var(--color-rule-2); }
.panel-title { font-size: var(--text-md); font-weight: 700; }
.panel-sub { margin-top: var(--space-3xs); color: var(--color-muted); font-size: var(--text-xs); }

.empty-state { padding: var(--space-2xl) var(--space-lg); text-align: center; color: var(--color-muted); }
.empty-state .empty-title { color: var(--color-ink); }
.empty-state p { margin-top: var(--space-xs); font-size: var(--text-sm); }
.empty-rule { width: 32px; height: var(--rule-hair); margin: 0 auto var(--space-md); background: var(--color-rule-strong); }

/* ask bar and catalog */
.ask-bar { display: flex; align-items: center; gap: var(--space-xs); margin-bottom: var(--space-md); padding: var(--space-2xs); border: var(--rule-hair) solid var(--color-border-soft); border-radius: 20px; background: var(--color-surface); box-shadow: var(--shadow-sm); }
.ask-label { padding-inline: var(--space-sm); color: var(--color-muted); font-size: var(--text-xs); white-space: nowrap; }
.ask-bar input { flex: 1; min-width: 0; height: 42px; padding: 0 var(--space-sm); border: 0; border-radius: var(--radius-control); background: var(--color-surface-2); font-size: var(--text-md); }

.catalog-tabs { display: flex; gap: var(--space-lg); margin-bottom: var(--space-md); border-bottom: var(--rule-hair) solid var(--color-rule); }
.catalog-tab { position: relative; padding: var(--space-xs) 0; border: 0; background: none; color: var(--color-muted); font-size: var(--text-md); }
.catalog-tab:hover { color: var(--color-ink-2); }
.catalog-tab.active { color: var(--color-brand-deep); font-weight: 700; }
.catalog-tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: calc(-1 * var(--rule-hair)); height: 2px; border-radius: var(--radius-pill); background: var(--grad-brand); }

.catalog-shell { display: grid; grid-template-columns: clamp(280px, 22vw, 340px) minmax(0, 1fr); gap: var(--gap-columns); align-items: stretch; }
#view-analysis { height: 100%; }
#view-analysis .catalog-shell { height: 100%; min-height: 0; }
#view-analysis .catalog-rail, #view-analysis .catalog-result { height: 100%; min-height: 0; max-height: none; }
#view-ops { height: 100%; display: flex; flex-direction: column; }
#view-ops .catalog-shell { flex: 1; min-height: 0; }
#view-ops .catalog-rail, #view-ops .catalog-result { height: 100%; min-height: 0; max-height: none; }
#view-analysis .catalog-result.is-empty { align-self: stretch; height: 100%; min-height: 0; max-height: none; padding: var(--space-lg) var(--space-lg) calc(var(--space-lg) + var(--space-xs)); border: var(--rule-hair) solid var(--color-border-soft); background: var(--color-surface); box-shadow: var(--shadow-sm); overflow-y: auto; }
#view-analysis .catalog-result.is-empty::after { content: ""; position: sticky; bottom: 0; display: block; height: 24px; margin-top: -24px; background: linear-gradient(to bottom, rgb(255 255 255 / 0), var(--color-surface)); pointer-events: none; }
.analysis-welcome { display: flex; flex-direction: column; justify-content: flex-start; gap: var(--space-lg); min-height: 100%; }
.welcome-head h2 { font-size: var(--text-2xl); letter-spacing: -0.02em; }
.welcome-head p { margin-top: var(--space-xs); color: var(--color-muted); font-size: var(--text-sm); }
.welcome-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-md); flex: none; }
.welcome-group { display: flex; flex-direction: column; min-height: 0; padding: var(--space-md); border: var(--rule-hair) solid var(--color-border-soft); border-radius: 16px; background: var(--color-surface-2); }
.welcome-group-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-xs); }
.welcome-group-head h3 { font-size: var(--text-md); font-weight: 700; }
.welcome-group-head span { color: var(--color-muted); font-size: var(--text-xs); }
.welcome-group-desc { margin-top: var(--space-2xs); color: var(--color-muted); font-size: var(--text-xs); line-height: 1.5; }
.welcome-links { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 6px; margin-top: var(--space-sm); }
.welcome-links button { padding: 5px 9px; border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-pill); background: var(--color-surface); color: var(--color-ink-2); font-size: var(--text-xs); text-align: left; }
.welcome-links button:hover { border-color: #6f5cff66; color: var(--color-brand-deep); background: var(--tint-purple); }
.catalog-rail { max-height: calc(100dvh - 220px); padding-bottom: var(--space-sm); overflow-y: auto; border: var(--rule-hair) solid var(--color-border-soft); border-radius: var(--radius-card); background: var(--color-surface); box-shadow: var(--shadow-sm); }
.catalog-rail::after { content: ""; position: sticky; bottom: 0; display: block; height: 24px; margin-top: -24px; background: linear-gradient(to bottom, rgb(255 255 255 / 0), var(--color-surface)); pointer-events: none; }
.catalog-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 40px;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 0;
  border-bottom: var(--rule-hair) solid var(--color-rule-2);
  background: var(--color-surface);
  color: var(--color-ink-2);
  text-align: left;
  transition: background-color var(--dur-micro), color var(--dur-micro);
}
.catalog-item:has(.cap-badge) { grid-template-columns: 28px minmax(0, 1fr) auto 40px; }
#analysis-catalog-list .catalog-item { grid-template-columns: minmax(0, 1fr) 40px; }
#analysis-catalog-list .catalog-item:has(.cap-badge) { grid-template-columns: minmax(0, 1fr) auto 40px; }
#ops-catalog-list .catalog-item:has(.cap-badge) { grid-template-columns: minmax(0, 1fr) auto 40px; }
.cap-badge { align-self: center; padding: 1px 7px; border-radius: var(--radius-pill); font-size: 10px; font-weight: 600; white-space: nowrap; }
.cap-ready { background: #e8f6ef; color: #0f7a5a; }
.cap-degraded { background: var(--tint-amber); color: var(--tint-amber-ink); }
.cap-unavailable { background: var(--tint-rose); color: var(--tint-rose-ink); }
.cap-demo { background: var(--tint-sky); color: var(--tint-sky-ink); }
.capability-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2xs) var(--space-sm);
  margin: var(--space-sm) 0;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-control);
  font-size: var(--text-xs);
  line-height: 1.6;
}
.capability-banner strong { font-size: var(--text-xs); }
.capability-banner.degraded { background: var(--tint-amber); color: var(--tint-amber-ink); }
.capability-banner.unavailable { background: var(--tint-rose); color: var(--tint-rose-ink); }
.capability-banner.demo { background: var(--tint-sky); color: var(--tint-sky-ink); }
.capability-card { padding: var(--space-lg); margin-bottom: var(--space-md); }
.capability-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-md); margin-bottom: var(--space-md); }
.capability-head h3 { font-size: var(--text-lg); }
.capability-head p { margin-top: 4px; color: var(--color-muted); font-size: var(--text-sm); max-width: 80ch; }
.cap-db { color: var(--color-muted-2); font-size: var(--text-xs); white-space: nowrap; }
.capability-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-sm); }
.cap-sum { display: flex; flex-direction: column; gap: 2px; padding: var(--space-md); border-radius: var(--radius-control); background: var(--color-surface-2); }
.cap-sum span { color: var(--color-muted); font-size: var(--text-xs); }
.cap-sum strong { color: var(--color-ink); font-size: var(--text-lg); }
.cap-sum small { color: var(--color-muted-2); font-size: var(--text-xs); }
.capability-details { margin-top: var(--space-md); }
.capability-details summary { cursor: pointer; color: var(--color-brand-deep); font-size: var(--text-sm); font-weight: 600; }
.capability-details h4 { margin: var(--space-md) 0 var(--space-xs); color: var(--color-muted); font-size: var(--text-xs); }
.cap-issue-row { display: grid; grid-template-columns: auto minmax(120px, 0.6fr) minmax(0, 2fr); gap: var(--space-sm); align-items: center; padding: var(--space-xs) 0; border-bottom: var(--rule-hair) solid var(--color-rule-2); font-size: var(--text-xs); color: var(--color-ink-2); }
.cap-field-row { display: flex; justify-content: space-between; gap: var(--space-md); padding: 4px 0; border-bottom: var(--rule-hair) solid var(--color-rule-2); color: var(--color-ink-2); font-size: var(--text-xs); }
@media (max-width: 640px) {
  .capability-summary { grid-template-columns: minmax(0, 1fr); }
  .cap-issue-row { grid-template-columns: auto minmax(0, 1fr); }
  .cap-issue-row > span:last-child { grid-column: 1 / -1; }
}
#analysis-catalog-list .catalog-no { display: none; }
.catalog-group-title { padding: var(--space-md) var(--space-md) var(--space-2xs); margin-top: var(--space-2xs); border-top: var(--rule-hair) solid var(--color-rule-2); color: var(--color-brand-deep); font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.02em; }
.catalog-group-subtitle { padding: var(--space-2xs) var(--space-md); color: var(--color-muted); font-size: var(--text-xs); background: var(--color-surface-2); }
.catalog-item:hover { background: var(--color-surface-2); }
.catalog-item:active { background: var(--color-surface-3); }
.catalog-item.active { background: var(--tint-purple); color: var(--color-ink); }
.catalog-no { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--color-surface-2); color: var(--color-muted); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.catalog-item.active .catalog-no { background: #ffffffcc; color: var(--color-brand-deep); font-weight: 700; }
.catalog-title { display: block; font-size: var(--text-sm); font-weight: 600; }
.catalog-item.active .catalog-title { color: var(--color-brand-deep); }
.catalog-desc { display: block; margin-top: var(--space-3xs); color: var(--color-muted); font-size: var(--text-xs); line-height: 1.5; }
.catalog-go { color: var(--color-muted-2); font-size: var(--text-xs); text-align: right; }
.catalog-item.active .catalog-go { color: var(--color-brand-deep); }
.catalog-item.disabled { color: var(--color-muted-2); cursor: not-allowed; }
.catalog-item.disabled .catalog-title { color: var(--color-muted-2); }
.catalog-item:focus-visible, .quick-list button:focus-visible, .daily-strip button:focus-visible, .catalog-tab:focus-visible { outline-offset: calc(-1 * var(--space-3xs)); }

.catalog-result { min-height: 480px; max-height: calc(100dvh - 220px); overflow-y: auto; overscroll-behavior: contain; padding: var(--space-lg); border: var(--rule-hair) solid var(--color-border-soft); border-radius: var(--radius-card); background: var(--color-surface); box-shadow: var(--shadow-sm); }
.result-empty { position: relative; max-width: 52ch; margin-inline: auto; padding: var(--space-2xl) var(--space-md); border: var(--rule-hair) solid var(--color-border-soft); border-radius: 20px; background: var(--grad-hero); text-align: center; color: var(--color-muted); overflow: hidden; }
.result-empty::before { content: ""; position: absolute; top: -56px; right: -48px; width: 150px; height: 150px; border-radius: 50%; background: radial-gradient(circle, #6f5cff3d, #6f5cff00 70%); pointer-events: none; }
.result-empty > * { position: relative; z-index: 1; }
.result-empty p { margin-top: var(--space-xs); font-size: var(--text-sm); line-height: 1.6; }
.result-loading { padding: var(--space-2xl) var(--space-md); color: var(--color-muted); font-size: var(--text-sm); text-align: center; }

/* loading skeleton */
.result-skeleton { display: flex; flex-direction: column; gap: var(--space-md); }
.sk { position: relative; overflow: hidden; border-radius: 10px; background: var(--color-surface-2); }
.sk::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, #ffffffb3, transparent); animation: sk-shimmer 1.3s infinite; }
@keyframes sk-shimmer { 100% { transform: translateX(100%); } }
.sk-head { display: flex; flex-direction: column; gap: var(--space-xs); }
.sk-kicker { width: 90px; height: 12px; }
.sk-title { width: 42%; height: 26px; }
.sk-desc { width: 64%; height: 14px; }
.sk-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-sm); }
.sk-metric { height: 78px; border-radius: 14px; }
.sk-chart { height: 220px; border-radius: 16px; }
.sk-rows { display: flex; flex-direction: column; gap: var(--space-xs); }
.sk-row { height: 38px; }
.sk-note { color: var(--color-muted); font-size: var(--text-xs); }
.result-loading .loading-dots { justify-content: center; margin-bottom: var(--space-xs); }
.result-head { display: flex; justify-content: space-between; gap: var(--space-md); padding-bottom: var(--space-sm); margin-bottom: var(--space-md); border-bottom: var(--rule-hair) solid var(--color-rule-2); }
.result-kicker { color: var(--color-muted); font-size: var(--text-xs); }
.result-title { margin-top: var(--space-2xs); font-size: var(--text-section); font-weight: 700; letter-spacing: -0.02em; }
.result-desc { margin-top: var(--space-2xs); color: var(--color-muted); font-size: var(--text-sm); line-height: 1.55; }
.result-actions { flex: none; }
.result-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-xs); margin-bottom: var(--space-md); }
.result-metrics.cols-1 { grid-template-columns: minmax(0, 1fr); }
.result-metrics.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.result-metrics.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.result-metric { display: flex; flex-direction: column; gap: var(--space-2xs); padding: var(--space-sm); border-radius: 14px; background: var(--color-surface-2); min-width: 0; }
.result-metric span { color: var(--color-muted); font-size: var(--text-xs); }
.result-metric strong { font-size: var(--text-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
.result-metric small { color: var(--color-muted-2); font-size: var(--text-xs); }
.result-chart { height: 240px; margin: var(--space-md) 0; }
.result-note { margin-top: var(--space-sm); padding-top: var(--space-xs); border-top: var(--rule-hair) solid var(--color-rule-2); color: var(--color-muted); font-size: var(--text-xs); }
.text-link { padding: 0; border: 0; background: transparent; color: var(--color-brand-deep); font-size: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.analysis-params { display: flex; flex-direction: column; gap: var(--space-md); }
.param-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-md); padding-bottom: var(--space-sm); border-bottom: var(--rule-hair) solid var(--color-rule-2); }
.param-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-md); }
.param-field { display: flex; flex-direction: column; gap: var(--space-2xs); max-width: 280px; color: var(--color-muted); font-size: var(--text-xs); }
.param-field input, .param-field select { height: 40px; padding: 0 var(--space-sm); border: var(--rule-hair) solid var(--color-rule-strong); border-radius: var(--radius-control); background: var(--color-surface); color: var(--color-ink); font-size: var(--text-sm); }
.param-inline { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-xs); }
.param-field input:focus-visible, .param-field select:focus-visible { outline: none; border-color: #6f5cff66; box-shadow: 0 0 0 4px var(--color-brand-glow); }
.param-presets { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
.param-presets button { padding: 5px 10px; border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-pill); background: var(--color-surface); color: var(--color-muted); font-size: var(--text-xs); }
.param-presets button:hover { border-color: #6f5cff66; color: var(--color-brand-deep); background: var(--tint-purple); }
.param-note { color: var(--color-muted); font-size: var(--text-xs); line-height: 1.6; }

/* funnel */
.funnel-box { display: flex; flex-direction: column; gap: var(--space-2xs); padding: var(--space-sm) 0; }
.funnel-stage { display: flex; align-items: center; gap: var(--space-sm); min-height: 34px; padding: var(--space-xs) var(--space-sm); border-radius: 10px; color: var(--color-primary-ink); font-size: var(--text-xs); }
.funnel-stage span { flex: 1; }
.funnel-stage strong { font-variant-numeric: tabular-nums; }
.funnel-stage em { font-style: normal; opacity: 0.85; }
.funnel-empty { padding: var(--space-lg); color: var(--color-muted); font-size: var(--text-sm); }

/* loading */
.loading-dots { display: flex; align-items: center; gap: var(--space-2xs); height: 12px; }
.loading-dots span { width: 6px; height: 6px; border-radius: var(--radius-pill); background: var(--color-brand); animation: dot-pulse 1.2s infinite ease-in-out; }
.loading-dots span:nth-child(2) { animation-delay: 0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0.32s; }
@keyframes dot-pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
.query-steps { display: flex; gap: var(--space-sm); margin-top: var(--space-xs); color: var(--color-muted-2); font-size: var(--text-xs); }
.query-steps span + span { padding-left: var(--space-sm); border-left: var(--rule-hair) solid var(--color-rule); }

/* report */
.report-builder { position: relative; z-index: 5; margin-bottom: var(--space-md); padding: 22px 26px; border: var(--rule-hair) solid var(--color-border-soft); border-radius: var(--radius-card); background: var(--grad-hero); box-shadow: var(--shadow-sm); }
.report-builder::after { content: ""; position: absolute; right: 8%; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: radial-gradient(circle, #ffb84f5c, #ffb84f00 70%); pointer-events: none; }
.report-builder > * { position: relative; z-index: 1; }
.report-builder > .builder-controls { z-index: 10; }
.builder-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-md); }
.builder-controls > .btn { height: 40px; }
.field { display: flex; flex-direction: column; gap: var(--space-2xs); color: var(--color-muted); font-size: var(--text-xs); }
.field select, .field input { min-width: 160px; height: 40px; padding: 0 var(--space-sm); border: var(--rule-hair) solid var(--color-rule-strong); border-radius: var(--radius-control); background: var(--color-surface); color: var(--color-ink); font-size: var(--text-sm); }
.select-combobox { position: relative; z-index: 10; min-width: 220px; }
.select-combobox.is-open { z-index: var(--z-dropdown); }
.select-native { display: none; }
.select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
  width: 100%;
  height: 40px;
  padding: 0 var(--space-sm);
  border: var(--rule-hair) solid var(--color-rule-strong);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-ink);
  font-size: var(--text-sm);
  text-align: left;
  transition: border-color var(--dur-micro), box-shadow var(--dur-micro);
}
.select-trigger:hover { border-color: #6f5cff66; }
.select-trigger[aria-expanded="true"] { border-color: #6f5cff66; box-shadow: 0 0 0 4px var(--color-brand-glow); }
.select-trigger svg { flex: none; color: var(--color-muted); }
.select-trigger-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-popover {
  position: absolute;
  left: 0;
  top: calc(100% + var(--space-xs));
  z-index: var(--z-dropdown);
  min-width: 100%;
  width: max-content;
  max-width: min(86vw, 420px);
  padding: var(--space-3xs);
  border: var(--rule-hair) solid var(--color-border-soft);
  border-radius: 14px;
  background: var(--color-surface);
  box-shadow: 0 18px 42px rgb(31 34 51 / 0.14);
}
.select-options { max-height: 300px; overflow-y: auto; }
.select-option { display: flex; align-items: center; gap: var(--space-xs); width: 100%; padding: var(--space-xs) var(--space-sm); border: 0; border-radius: 10px; background: transparent; color: var(--color-ink); font-size: var(--text-sm); text-align: left; }
.select-option:hover, .select-option.is-active { background: var(--color-surface-2); }
.select-option.is-selected { background: var(--color-primary-soft); color: var(--color-brand-deep); font-weight: 600; }
.select-option svg { flex: none; color: var(--color-brand); }
.select-option span { flex: 1; }
.param-field .select-combobox, .param-inline .select-combobox, .task-form .select-combobox { min-width: 0; width: 100%; }
.select-combobox.drop-up .select-popover { top: auto; bottom: calc(100% + var(--space-xs)); }
.select-combobox.compact { min-width: 96px; width: auto; }
.select-combobox.compact .select-trigger { height: 32px; padding: 0 10px; font-size: var(--text-xs); }
.select-combobox.compact .select-popover { min-width: 120px; }
.task-form .select-trigger { height: 34px; font-size: var(--text-sm); border-radius: 8px; }
.builder-presets { display: flex; flex-wrap: wrap; gap: var(--space-xs); margin-top: var(--space-md); }
.builder-presets button { padding: var(--space-2xs) var(--space-sm); border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-pill); background: var(--color-surface); color: var(--color-muted); font-size: var(--text-xs); transition: background-color var(--dur-micro), border-color var(--dur-micro), color var(--dur-micro); }
.builder-presets button:hover { background: var(--color-surface-2); color: var(--color-ink-2); }
.builder-presets button.active { background: var(--tint-purple); border-color: transparent; color: var(--color-brand-deep); font-weight: 600; }
.custom-metrics { display: flex; flex-wrap: wrap; gap: var(--space-xs); margin-top: var(--space-sm); padding-top: var(--space-sm); border-top: var(--rule-hair) solid var(--color-rule-2); }
.custom-metric { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-pill); background: var(--color-surface); color: var(--color-ink-2); font-size: var(--text-xs); cursor: pointer; }
.custom-metric input { accent-color: var(--color-brand); }
.custom-metric:has(input:checked) { border-color: #6f5cff66; background: var(--tint-purple); color: var(--color-brand-deep); font-weight: 600; }

.report-actions { display: flex; justify-content: flex-end; gap: var(--space-xs); margin-bottom: var(--space-md); }
.report-empty { max-width: 640px; margin: var(--space-lg) auto 0; }
.report { max-width: none; scroll-margin-top: var(--space-md); padding: var(--space-xl) var(--space-2xl) var(--space-2xl); border: var(--rule-hair) solid var(--color-border-soft); border-radius: var(--radius-card); background: var(--color-surface); box-shadow: var(--shadow-md); }
.report-head { position: relative; padding: var(--space-xl) var(--space-2xl) var(--space-lg); margin: calc(-1 * var(--space-xl)) calc(-1 * var(--space-2xl)) var(--space-lg); border-radius: var(--radius-card) var(--radius-card) 0 0; background: var(--grad-hero); border-bottom: var(--rule-hair) solid var(--color-border-soft); overflow: hidden; }
.report-head::after { content: ""; position: absolute; right: 6%; top: -54px; width: 170px; height: 170px; border-radius: 50%; background: radial-gradient(circle, #ffb84f59, #ffb84f00 70%); pointer-events: none; }
.report-head > * { position: relative; z-index: 1; }
.report-head h1, .report-head h2 { font-size: 1.875rem; letter-spacing: -0.03em; line-height: 1.15; }
.report-meta { margin-top: var(--space-sm); color: var(--color-ink-2); font-size: var(--text-xs); line-height: 1.7; }
.report section { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: var(--space-md); padding: var(--space-lg) 0; border-bottom: var(--rule-hair) solid var(--color-rule-2); }
.section-no { padding-top: var(--space-2xs); color: var(--color-brand-deep); font-size: var(--text-xs); font-weight: 700; }
.report section h2 { margin-bottom: var(--space-xs); font-size: var(--text-xl); letter-spacing: -0.02em; }
.report section p { max-width: 75ch; color: var(--color-ink-2); font-size: var(--text-md); line-height: 1.75; }
.report .chart-grid { margin-top: var(--space-md); margin-bottom: 0; }
.boundary { padding: var(--space-md); border-radius: 14px; background: var(--color-surface-2); }
.boundary strong { font-weight: 600; }
.boundary ul, .boundary-list { margin: var(--space-xs) 0 0; padding-left: var(--space-md); color: var(--color-muted); font-size: var(--text-sm); line-height: 1.7; }

/* data page */
.meta-list { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: var(--space-xs) var(--space-md); margin: 0; padding: var(--space-md) var(--space-lg); font-size: var(--text-sm); }
.meta-list dt { color: var(--color-muted); }
.meta-list dd { margin: 0; color: var(--color-ink-2); }
.steps { margin: 0; padding: var(--space-md) var(--space-lg) var(--space-md) var(--space-xl); color: var(--color-ink-2); font-size: var(--text-sm); line-height: 1.8; }
.steps li::marker { color: var(--color-brand-deep); font-weight: 700; }
.notice { margin: 0 var(--space-lg) var(--space-md); padding-top: var(--space-sm); border-top: var(--rule-hair) solid var(--color-rule-2); color: var(--color-muted); font-size: var(--text-xs); }
.boundary-list { margin: 0; padding: var(--space-md) var(--space-lg) var(--space-md) var(--space-xl); }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: var(--space-lg);
  z-index: var(--z-toast);
  padding: var(--space-sm) var(--space-md);
  border: var(--rule-hair) solid var(--color-border-soft);
  border-radius: 14px;
  background: var(--color-surface);
  box-shadow: var(--shadow-lg);
  color: var(--color-ink);
  font-size: var(--text-sm);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(var(--space-xs));
  transition: opacity var(--dur-short) var(--ease-out), transform var(--dur-short) var(--ease-out);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* responsive */
@media (max-width: 1180px) {
  .chart-grid { grid-template-columns: minmax(0, 1fr); }
  .kpi-grid, .result-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* 数据接入 */
.import-panel { display: flex; align-items: flex-end; gap: var(--space-sm); margin-bottom: var(--space-md); }
.import-dir-field { flex: 1; max-width: none; }
.import-dir-field input, .import-dir-field textarea { width: 100%; }
.import-dir-field textarea { min-height: 74px; padding: var(--space-sm); border: var(--rule-hair) solid var(--color-rule-strong); border-radius: var(--radius-control); font-family: inherit; font-size: var(--text-sm); resize: vertical; }
.import-card { padding: var(--space-lg); margin-bottom: var(--space-md); }
.import-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-md); margin-bottom: var(--space-md); }
.import-card-head h3 { font-size: var(--text-lg); }
.import-card-head p { margin-top: 4px; color: var(--color-muted); font-size: var(--text-sm); word-break: break-all; }
.import-card-head > span { color: var(--color-muted-2); font-size: var(--text-xs); white-space: nowrap; }
.import-file { border: var(--rule-hair) solid var(--color-rule-2); border-radius: var(--radius-control); margin-bottom: var(--space-sm); overflow: hidden; }
.import-file > summary { display: flex; justify-content: space-between; gap: var(--space-md); padding: var(--space-sm) var(--space-md); cursor: pointer; background: var(--color-surface-2); font-size: var(--text-sm); }
.import-file > summary span { color: var(--color-muted); font-size: var(--text-xs); }
.import-mapping { padding: var(--space-sm) var(--space-md) var(--space-md); }
.import-required { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--space-sm); }
.import-field { display: flex; flex-direction: column; gap: 4px; color: var(--color-muted); font-size: var(--text-xs); }
.import-field .select-combobox { min-width: 0; width: 100%; }
.import-optional { margin-top: var(--space-sm); border-top: var(--rule-hair) solid var(--color-rule-2); padding-top: var(--space-sm); }
.import-optional > summary { cursor: pointer; color: var(--color-brand-deep); font-size: var(--text-xs); font-weight: 600; margin-bottom: var(--space-sm); }
.import-warn { margin-top: var(--space-sm); color: var(--tint-amber-ink); font-size: var(--text-xs); }
.import-method { margin-left: 6px; padding: 1px 5px; border-radius: var(--radius-pill); background: var(--color-surface-3); color: var(--color-muted); font-size: 10px; font-style: normal; }
.import-method.profile { background: var(--tint-green); color: var(--tint-green-ink); }
.import-method.fuzzy { background: var(--tint-amber); color: var(--tint-amber-ink); }
.import-issue { margin-top: 4px; font-size: var(--text-xs); }
.import-issue.error { color: var(--tint-rose-ink); }
.import-issue.warning { color: var(--tint-amber-ink); }
.import-profile-save { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm); }
.import-checkbox { display: inline-flex; align-items: center; gap: 6px; color: var(--color-ink-2); font-size: var(--text-xs); }
.import-checkbox input { accent-color: var(--color-brand); }
.import-profile-save input[type="text"] { flex: 1 1 220px; height: 38px; padding: 0 var(--space-sm); border: var(--rule-hair) solid var(--color-rule-strong); border-radius: var(--radius-control); font-size: var(--text-sm); }
.import-adapter-files { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-md); }
.import-adapter-file { display: flex; justify-content: space-between; gap: var(--space-md); padding: 6px 10px; border-radius: 9px; background: var(--color-surface-2); font-size: var(--text-xs); }
.import-adapter-file span { color: var(--color-muted); }
.import-profiles { margin-top: var(--space-md); }
.import-profiles h4 { margin-bottom: var(--space-xs); font-size: var(--text-sm); }
.import-profiles .tag { margin-right: 4px; margin-bottom: 4px; }
.import-build-panel { display: flex; flex-direction: column; gap: var(--space-md); margin-top: var(--space-md); padding-top: var(--space-md); border-top: var(--rule-hair) solid var(--color-rule-2); }
.import-build-panel .btn { align-self: flex-start; }
.import-building, .import-error { margin-top: var(--space-md); padding: var(--space-md); border-radius: var(--radius-control); background: var(--color-surface-2); font-size: var(--text-sm); }
.import-error { background: var(--tint-rose); color: var(--tint-rose-ink); }
.import-check { padding: 1px 7px; border-radius: var(--radius-pill); font-size: 10px; font-weight: 600; }
.import-check.pass { background: #e8f6ef; color: #0f7a5a; }
.import-check.warn { background: var(--tint-amber); color: var(--tint-amber-ink); }
.import-check.fail { background: var(--tint-rose); color: var(--tint-rose-ink); }
.import-check-table { margin: var(--space-md) 0; }
.import-activation { margin-top: var(--space-md); padding-top: var(--space-md); border-top: var(--rule-hair) solid var(--color-rule-2); }
.import-activation h4 { margin-bottom: var(--space-xs); font-size: var(--text-sm); }
.import-activation pre { padding: var(--space-sm); border-radius: var(--radius-control); background: #1f2233; color: #e8eaf6; font-size: 11px; line-height: 1.6; white-space: pre-wrap; word-break: break-all; }
.import-activation p { margin-top: var(--space-xs); color: var(--color-muted); font-size: var(--text-xs); }
@media (max-width: 640px) {
  .import-panel { flex-direction: column; align-items: stretch; }
  .import-panel .btn { width: 100%; }
}

/* 口径中心 */
.definitions-head { align-items: flex-end; }
.definitions-version {
  padding: 8px 14px;
  border: var(--rule-hair) solid #6f5cff33;
  border-radius: var(--radius-pill);
  background: var(--tint-purple);
  color: var(--tint-purple-ink);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}
.definition-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-sm); margin-bottom: var(--space-md); }
.definition-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-md) var(--space-lg);
  border: var(--rule-hair) solid var(--color-border-soft);
  border-radius: var(--radius-card);
  background: var(--grad-panel);
  box-shadow: var(--shadow-sm);
}
.definition-stat span { color: var(--color-muted); font-size: var(--text-xs); }
.definition-stat strong { color: var(--color-ink); font-size: 1.5rem; letter-spacing: -0.02em; }
.definition-stat small { color: var(--color-muted-2); font-size: var(--text-xs); }
.definition-stat.version strong { color: var(--color-brand-deep); font-size: 1.1rem; }
.definition-empty-note {
  padding: 14px 18px;
  border: var(--rule-hair) dashed var(--color-rule-strong);
  border-radius: var(--radius-control);
  background: var(--color-surface-2);
  color: var(--color-muted);
  font-size: var(--text-sm);
  line-height: 1.7;
}
.rm-console {
  margin-top: var(--space-md);
  padding: 0;
}
.rm-console-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  border-bottom: var(--rule-hair) solid var(--color-rule-2);
}
.rm-console-head h3 { margin: 0; font-size: var(--text-lg); }
.rm-console-head p {
  max-width: 70ch;
  margin: 4px 0 0;
  color: var(--color-muted);
  font-size: var(--text-xs);
  line-height: 1.65;
}
.rm-count {
  flex: none;
  align-self: flex-start;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-2);
  color: var(--color-muted);
  font-size: 11px;
}
.rm-console-grid {
  display: grid;
  grid-template-columns: minmax(250px, 310px) minmax(0, 1fr);
  min-height: 520px;
}
.rm-list {
  max-height: 680px;
  overflow-y: auto;
  padding: 10px;
  border-right: var(--rule-hair) solid var(--color-rule-2);
  background: #fcfcff;
}
.rm-group + .rm-group { margin-top: 10px; }
.rm-group-label {
  padding: 8px 10px 4px;
  color: var(--color-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.rm-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 9px 10px;
  border: var(--rule-hair) solid transparent;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur-micro) var(--ease-out);
}
.rm-row:hover { background: var(--color-surface-2); }
.rm-row.is-active {
  background: var(--color-brand-subtle);
  border-color: #6f5cff33;
}
.rm-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.rm-row-top strong { font-size: var(--text-sm); font-weight: 600; }
.rm-row-meta {
  overflow: hidden;
  color: var(--color-muted);
  font-size: 10px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rm-pill {
  flex: none;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-3);
  color: var(--color-muted);
  font-size: 9px;
  font-style: normal;
  font-weight: 600;
}
.rm-pill.custom {
  background: var(--tint-green);
  color: var(--tint-green-ink);
}
.rm-detail-card {
  min-width: 0;
  padding: var(--space-lg);
}
.rm-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
}
.rm-detail-head h4 { margin: 0; font-size: var(--text-xl); }
.rm-detail-head p {
  max-width: 70ch;
  margin: 5px 0 0;
  color: var(--color-muted);
  font-size: var(--text-xs);
  line-height: 1.65;
}
.rm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--space-sm);
}
.rm-chips span {
  padding: 4px 8px;
  border: var(--rule-hair) solid var(--color-rule);
  border-radius: 6px;
  background: var(--color-surface-2);
  color: var(--color-ink-2);
  font-size: 10px;
}
.rm-settings {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: var(--rule-hair) solid var(--color-rule-2);
}
.rm-settings-head h5 { margin: 0; font-size: var(--text-sm); }
.rm-settings-head p {
  margin: 3px 0 var(--space-sm);
  color: var(--color-muted);
  font-size: 11px;
  line-height: 1.55;
}
.rm-settings .metric-settings-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  margin: 0 0 var(--space-sm);
}
.rm-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.rm-field > span {
  color: var(--color-muted);
  font-size: 10px;
  font-weight: 600;
}
.rm-field-wide { grid-column: 1 / -1; }
.rm-field .select-combobox { width: 100%; min-width: 0; }
.rm-field .select-trigger { height: 36px; font-size: var(--text-xs); }
.rm-number { display: flex; align-items: center; gap: 6px; }
.rm-number input,
.rm-field input[type="text"] {
  width: 100%;
  height: 36px;
  padding: 0 9px;
  border: var(--rule-hair) solid var(--color-rule);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-ink);
  font-size: var(--text-xs);
}
.rm-settings-foot {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.rm-settings-foot span { color: var(--color-muted-2); font-size: 10px; }
.rm-empty { padding: 20px; color: var(--color-muted); font-size: 12px; }
@media (max-width: 1000px) {
  .rm-console-grid { grid-template-columns: minmax(0, 1fr); }
  .rm-list {
    max-height: 300px;
    border-right: 0;
    border-bottom: var(--rule-hair) solid var(--color-rule-2);
  }
  .rm-detail-card { padding: var(--space-md); }
  .rm-settings .metric-settings-form { grid-template-columns: minmax(0, 1fr); }
}
.definition-badge.default {
  background: var(--color-surface-3);
  color: var(--color-muted);
}
.metric-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}
.metric-summary li {
  color: var(--color-ink-2);
  font-size: 11px;
}
.metric-summary li::before {
  content: "·";
  margin-right: 4px;
  color: var(--color-brand);
}
.metric-settings-note {
  margin: 8px 0 0;
  color: var(--color-muted);
  font-size: 11px;
  line-height: 1.6;
}
.metric-settings-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px 14px;
  margin: 10px 0;
}
.metric-settings-form .definition-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.metric-settings-form select,
.metric-settings-form input[type="text"],
.metric-settings-form input[type="number"] {
  height: 34px;
  padding: 0 9px;
  border: var(--rule-hair) solid var(--color-rule);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-ink);
  font-size: var(--text-xs);
}
.metric-settings-form small {
  color: var(--color-muted-2);
  font-size: 10px;
}
.metric-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}
.metric-checkboxes label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--color-ink-2);
  font-size: 11px;
}
.metric-owner-note {
  margin: 8px 0 0;
  color: var(--color-muted);
  font-size: 11px;
}
.report-metric-card { margin-top: 8px; }
.report-metric-card summary {
  color: var(--color-brand-deep);
  font-size: var(--text-xs);
  cursor: pointer;
}
.report-metric-card dl {
  display: grid;
  gap: 6px;
  margin: 8px 0 0;
}
.report-metric-card dl > div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 8px;
}
.report-metric-card dt { color: var(--color-muted); font-size: 11px; }
.report-metric-card dd { margin: 0; color: var(--color-ink-2); font-size: 11px; line-height: 1.6; }
.definition-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}
.definition-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border: var(--rule-hair) solid var(--color-border-soft);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}
.definition-tab {
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-ink-2);
  font-size: var(--text-xs);
  font-weight: 500;
}
.definition-tab:hover { background: var(--color-surface-2); }
.definition-tab.active { background: var(--tint-purple); color: var(--tint-purple-ink); font-weight: 700; }
.definition-search {
  flex: 1 1 240px;
  min-width: 200px;
  height: 40px;
  padding: 0 var(--space-md);
  border: var(--rule-hair) solid var(--color-rule-strong);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-ink);
  font-size: var(--text-sm);
}
.definition-search:focus-visible { outline: none; border-color: #6f5cff66; box-shadow: 0 0 0 4px var(--color-brand-glow); }
.definitions-list { display: flex; flex-direction: column; gap: var(--space-md); }
.definition-group {
  border: var(--rule-hair) solid var(--color-border-soft);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.definition-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  list-style: none;
  background: var(--color-surface-2);
}
.definition-group-head::-webkit-details-marker { display: none; }
.definition-group-head h3 { font-size: var(--text-md); color: var(--color-ink); }
.definition-group-head p { margin-top: 2px; color: var(--color-muted); font-size: var(--text-xs); }
.definition-group-count { color: var(--color-muted); font-size: var(--text-xs); white-space: nowrap; }
.definition-items { display: flex; flex-direction: column; }
.definition-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-sm) var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  border-top: var(--rule-hair) solid var(--color-rule-2);
}
.definition-item-main { min-width: 0; }
.definition-item-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs); }
.definition-item-head strong { color: var(--color-ink); font-size: var(--text-md); }
.definition-badge { padding: 2px 8px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 600; white-space: nowrap; }
.definition-badge.pending { background: var(--tint-amber); color: var(--tint-amber-ink); }
.definition-badge.confirmed { background: var(--tint-green); color: var(--tint-green-ink); }
.definition-badge.modified { background: var(--tint-purple); color: var(--tint-purple-ink); }
.definition-badge.submitted { background: var(--tint-sky); color: var(--tint-sky-ink); }
.definition-badge.effect-live { background: #e8f6ef; color: #0f7a5a; }
.definition-badge.effect-readonly { background: #eef0f7; color: #5b6178; }
.definition-badge.effect-pending-data { background: var(--tint-amber); color: var(--tint-amber-ink); }
.definition-source { color: var(--color-muted-2); font-size: 11px; }
.definition-date { color: var(--color-muted-2); font-size: 11px; }
.definition-desc { margin-top: var(--space-2xs); color: var(--color-ink-2); font-size: var(--text-sm); line-height: 1.6; }
.definition-current {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2xs) var(--space-xs);
  margin-top: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: 10px;
  background: var(--color-surface-2);
  font-size: var(--text-xs);
}
.definition-current span { color: var(--color-muted); }
.definition-current b { color: var(--color-ink); font-size: var(--text-sm); }
.definition-current small { color: var(--color-muted-2); }
.definition-item-actions { display: flex; align-items: flex-start; gap: var(--space-2xs); }
.definition-readonly { color: var(--color-muted-2); font-size: var(--text-xs); }
.definition-editor {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border: var(--rule-hair) dashed #6f5cff40;
  border-radius: var(--radius-control);
  background: #faf9ff;
}
.definition-field { display: flex; flex-direction: column; gap: 4px; min-width: 150px; color: var(--color-muted); font-size: var(--text-xs); }
.definition-field > span { font-weight: 500; }
.definition-field input {
  height: 38px;
  padding: 0 var(--space-sm);
  border: var(--rule-hair) solid var(--color-rule-strong);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-ink);
  font-size: var(--text-sm);
}
.definition-field input:focus-visible { outline: none; border-color: #6f5cff66; box-shadow: 0 0 0 4px var(--color-brand-glow); }
.definition-field .select-combobox { min-width: 180px; }
.definition-input-row { display: flex; align-items: center; gap: 6px; }
.definition-input-row em { color: var(--color-muted-2); font-style: normal; font-size: var(--text-xs); white-space: nowrap; }
.definition-struct { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--space-sm); width: 100%; }
.definition-editor-actions { display: flex; gap: var(--space-2xs); }
.term-section { margin-top: var(--space-xl); }
.term-card { padding: var(--space-lg); }
.term-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-md); margin-bottom: var(--space-md); }
.term-head h3 { font-size: var(--text-lg); }
.term-head p { margin-top: 4px; color: var(--color-muted); font-size: var(--text-sm); max-width: 70ch; }
.term-head > span { color: var(--color-muted); font-size: var(--text-xs); white-space: nowrap; }
.term-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-xl); }
.term-grid h4 { margin-bottom: var(--space-xs); color: var(--color-brand-deep); font-size: var(--text-sm); }
.term-row { display: grid; grid-template-columns: 88px minmax(0, 1fr) auto; align-items: center; gap: var(--space-xs); padding: 6px 0; border-bottom: var(--rule-hair) solid var(--color-rule-2); }
.term-name { color: var(--color-ink); font-size: var(--text-sm); font-weight: 600; }
.term-input {
  height: 34px;
  padding: 0 10px;
  border: var(--rule-hair) solid var(--color-rule-2);
  border-radius: 9px;
  background: var(--color-surface);
  color: var(--color-ink-2);
  font-size: var(--text-xs);
}
.term-input:focus-visible { outline: none; border-color: #6f5cff66; box-shadow: 0 0 0 3px var(--color-brand-glow); }
@media (max-width: 900px) {
  .definition-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .definition-item { grid-template-columns: minmax(0, 1fr); }
  .definition-item-actions { justify-content: flex-start; }
  .term-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .definition-stats { grid-template-columns: minmax(0, 1fr); }
  .definition-toolbar .definition-search { flex-basis: 100%; }
  .definition-toolbar .btn { width: 100%; }
  .definition-group-head { padding: var(--space-sm) var(--space-md); }
  .definition-item { padding: var(--space-sm) var(--space-md); }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); align-content: start; }
  .sidebar { position: relative; align-self: start; align-content: flex-start; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--space-xs) var(--space-md); padding: var(--space-xs) var(--space-md); border-right: 0; border-bottom: var(--rule-hair) solid #6f5cff14; }
  .brand { width: 100%; padding: var(--space-2xs) 0; }
  .brand-text small { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; width: 100%; gap: var(--space-3xs); }
  .nav-item { width: auto; height: 34px; padding: 0 var(--space-sm); white-space: nowrap; }
  .nav-text em { display: none; }
  .nav-item svg { display: none; }
  .sidebar-foot { display: none; }
  .main-col { height: auto; margin: 0; border-radius: 0; background: transparent; min-height: 0; }
  .main { overflow-y: visible; }
  #view-chat, #view-analysis, #view-ops { height: auto; }
  .topbar { height: auto; padding: var(--space-md) var(--gutter) var(--space-xs); }
  .page-title { font-size: 1.5rem; }
  .main { padding: 0 var(--gutter) var(--space-xl); }
  .page-head { flex-direction: column; align-items: flex-start; padding: 20px; }
  .chat-layout { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 0; }
  .chat-side { order: 2; padding: 22px; }
  .chat-panel { height: 70dvh; min-height: 520px; }
  .catalog-shell { grid-template-columns: minmax(0, 1fr); }
  #view-analysis .catalog-shell { height: auto; min-height: 0; }
  .catalog-rail { max-height: 320px; }
  #view-analysis .catalog-rail { height: auto; max-height: 320px; }
  .catalog-result { max-height: 70dvh; }
  #view-analysis .catalog-result, #view-analysis .catalog-result.is-empty { height: auto; max-height: 70dvh; }
  .action-card { grid-template-columns: minmax(0, 1fr); }
  .action-meta { text-align: left; }
  .report { padding: var(--space-lg); }
  .report-head { padding: var(--space-lg) var(--space-lg) var(--space-md); margin: calc(-1 * var(--space-lg)) calc(-1 * var(--space-lg)) var(--space-lg); }
  .report section { grid-template-columns: minmax(0, 1fr); }
  .meta-list { grid-template-columns: minmax(0, 1fr); padding-inline: var(--space-md); }
}
@media (max-width: 640px) {
  .kpi-grid, .answer-kpis, .result-metrics { grid-template-columns: minmax(0, 1fr); }
  .sk-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sk-title { width: 70%; }
  .composer-send { min-height: 44px; }
  .composer-hint { display: none; }
  .query-panel-body { flex-direction: column; }
  .query-submit { width: 100%; }
  .sidebar { gap: var(--space-sm); padding: var(--space-sm) var(--space-md); }
  .brand { padding: var(--space-2xs) 0; }
  .brand-text strong { font-size: 0.95rem; }
  .nav { gap: 2px; }
  .nav-item { height: 32px; padding: 0 10px; font-size: var(--text-sm); }
  .topbar { padding: var(--space-sm) var(--gutter) 0; }
  .page-title { font-size: 1.35rem; }
  .main { padding-bottom: var(--space-lg); }
  .report-builder { padding: 18px; }
  .builder-controls { display: grid; grid-template-columns: minmax(0, 1fr); align-items: stretch; gap: var(--space-md); }
  .field { width: 100%; }
  .field select, .field input, .select-combobox, .select-trigger { width: 100%; min-width: 0; }
  #report-generate { width: 100%; }
  .builder-presets { gap: var(--space-2xs); }
  .builder-presets button { flex: 1 1 auto; }
  .select-popover { width: 100%; max-width: none; }
  .report-actions { flex-wrap: wrap; justify-content: flex-start; }
  .report-actions .btn { flex: 1 1 auto; }
  .report { padding: var(--space-md); }
  .report-head { padding: var(--space-lg) var(--space-md) var(--space-md); margin: calc(-1 * var(--space-md)) calc(-1 * var(--space-md)) var(--space-md); }
  .report-head h1, .report-head h2 { font-size: 1.5rem; }
  .report-meta { font-size: 0.75rem; }
  .report section { grid-template-columns: minmax(0, 1fr); gap: var(--space-sm); padding: var(--space-md) 0; }
  .report section h2 { font-size: var(--text-lg); }
  .report section p { font-size: var(--text-sm); }
  .report .chart-grid { grid-template-columns: minmax(0, 1fr); }
  .welcome-groups { grid-template-columns: minmax(0, 1fr); }
}

@media print {
  .sidebar, .topbar, .report-builder, .report-actions { display: none !important; }
  .app-shell { display: block; }
  .main-col { margin: 0; border-radius: 0; background: var(--color-surface); }
  .main { max-width: none; padding: 0; }
  .report { max-width: none; border: 0; box-shadow: none; padding: 0; }
  .report-head { margin: 0 0 var(--space-lg); border-radius: 0; }
  .report section { break-inside: avoid; }
}
