:root {
  color-scheme: light;
  --bg: #f6f3ed;
  --panel: #fffdfa;
  --ink: #202124;
  --muted: #72706b;
  --line: #e3ded3;
  --green: #28735b;
  --blue: #315f9b;
  --red: #aa4b45;
  --gold: #9a6b22;
  --sidebar: #242622;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 17px;
  letter-spacing: 0;
}

button,
select {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.login-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(32, 33, 36, 0.08);
}

.login-card .brand-mark {
  width: 48px;
}

.login-card h1 {
  font-size: 30px;
}

.login-card p,
.login-card label {
  color: var(--muted);
}

.login-card label {
  display: grid;
  gap: 8px;
  font-size: 15px;
}

.login-card input {
  width: 100%;
}

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 74px minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-height: 0;
  padding: 24px 18px;
  overflow: auto;
  background: var(--sidebar);
  color: #f8f4eb;
}

.app-shell.sidebar-collapsed .sidebar {
  align-items: center;
  gap: 18px;
  padding: 20px 12px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.app-shell.sidebar-collapsed .brand-block {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 0 0 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  aspect-ratio: 1;
  border-radius: 8px;
  background: #d4b36b;
  color: #25231e;
  font-weight: 800;
}

.brand-copy {
  min-width: 0;
}

.brand-title {
  font-size: 20px;
  font-weight: 800;
}

.brand-subtitle {
  margin-top: 2px;
  color: rgba(248, 244, 235, 0.7);
  font-size: 14px;
}

.sidebar-toggle,
.icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #f8f4eb;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.sidebar-toggle {
  margin-left: auto;
}

.icon-button {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.app-shell.sidebar-collapsed .brand-copy,
.app-shell.sidebar-collapsed .nav-list,
.app-shell.sidebar-collapsed .sidebar-footer {
  display: none;
}

.app-shell.sidebar-collapsed .sidebar-toggle {
  margin-left: 0;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(248, 244, 235, 0.72);
  font-size: 16px;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
}

.muted-label {
  color: rgba(248, 244, 235, 0.56);
  font-size: 14px;
}

.source-name {
  margin-top: 6px;
  font-size: 15px;
  line-height: 1.5;
}

.sync-chip {
  margin-top: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(248, 244, 235, 0.82);
  font-size: 14px;
  line-height: 1.4;
}

.main {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  min-width: 0;
  padding: 28px;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.2;
}

.topbar p {
  max-width: 720px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
}

.app-shell[data-view="diagnosis"] .topbar {
  margin-bottom: 8px;
}

.primary-button {
  min-height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: #202124;
  color: white;
  font-size: 16px;
  cursor: pointer;
  white-space: nowrap;
}

.secondary-button {
  align-self: end;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  cursor: pointer;
  white-space: nowrap;
}

.secondary-button:hover {
  border-color: #c9c1b3;
  background: #f8f6f1;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-actions span {
  color: var(--muted);
  font-size: 15px;
  white-space: nowrap;
}

.primary-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  align-content: start;
  flex: 1 1 auto;
  gap: 18px;
  min-height: 0;
  overflow: auto;
}

#diagnosis-view.view.active {
  align-content: stretch;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.dashboard-filter-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 220px)) auto;
  align-items: end;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.dashboard-filter-bar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 15px;
}

.metric-card {
  min-height: 120px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric-card span {
  color: var(--muted);
  font-size: 15px;
}

.metric-card strong {
  display: block;
  margin-top: 18px;
  font-size: 31px;
  line-height: 1;
}

.accent-green strong {
  color: var(--green);
}

.accent-blue strong {
  color: var(--blue);
}

.accent-red strong {
  color: var(--red);
}

.content-band {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.sync-stage-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 18px;
}

.sync-stage-card {
  border: 1px solid var(--line, #dbe3ea);
  border-radius: 10px;
  padding: 12px;
  background: #fbfcfe;
}

.sync-stage-card strong, .sync-stage-card span, .sync-stage-card small { display: block; }
.sync-stage-card span { margin-top: 6px; font-weight: 600; }
.sync-stage-card small { margin-top: 5px; color: #677589; line-height: 1.4; }
.sync-stage-card.is-running { border-color: #4b8df8; background: #f2f7ff; }
.sync-stage-card.is-success { border-color: #56a36c; }
.sync-stage-card.is-partial, .sync-stage-card.is-failed, .sync-stage-card.is-blocked { border-color: #d98b43; background: #fff9f2; }

.cycle-report {
  padding: 16px 18px;
}

.cycle-report > strong {
  display: block;
  padding-bottom: 10px;
  border-bottom: 1px solid #e5e9ee;
}

.cycle-report-body {
  padding-top: 8px;
}

.cycle-report-body p {
  margin: 0;
  padding: 9px 0;
  color: #465466;
  line-height: 1.8;
  white-space: pre-wrap;
}

.cycle-report-body p + p {
  border-top: 1px dashed #e5e9ee;
}

.cycle-report-body p:not(:first-child) {
  padding-left: 4px;
}

@media (max-width: 780px) {
  .sync-stage-grid { grid-template-columns: 1fr; }
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-heading h2 {
  font-size: 22px;
}

.section-heading span {
  color: var(--muted);
  font-size: 15px;
}

.store-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.store-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.store-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.store-card h3 {
  margin: 0;
  font-size: 19px;
}

.badge {
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef3ef;
  color: var(--green);
  font-size: 14px;
  white-space: nowrap;
}

.store-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  min-width: 0;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.stat strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  font-size: 19px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 8px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #eee8dc;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--gold));
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.dashboard-table-wrap {
  max-height: calc(100vh - 390px);
  min-height: 280px;
}

.performance-table {
  min-width: 1680px;
}

.performance-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fffdfa;
}

.performance-table td,
.performance-table th {
  padding: 12px 10px;
  white-space: nowrap;
}

.store-name-cell {
  display: block;
  max-width: 130px;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
}

.muted-cell {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.pending-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: #f1eee7;
  color: var(--muted);
  font-size: 14px;
}

.performance-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
}

.performance-card {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-top: 4px solid #bcb39f;
  border-radius: 8px;
  background: #fff;
}

.performance-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.performance-card-head h3 {
  margin: 0;
  overflow: hidden;
  font-size: 19px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.performance-card-head span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.performance-card-head strong {
  flex: 0 0 auto;
  padding: 4px 9px;
  border-radius: 999px;
  background: #f1eee7;
  color: var(--muted);
  font-size: 14px;
}

.performance-hero {
  display: grid;
  gap: 6px;
}

.performance-hero span,
.performance-main-metrics span,
.performance-people-row span,
.performance-risk-row span {
  color: var(--muted);
  font-size: 14px;
}

.performance-hero strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 30px;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.performance-meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #eee8dc;
}

.performance-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.performance-main-metrics,
.performance-people-row,
.performance-risk-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.performance-main-metrics div,
.performance-people-row div,
.performance-risk-row div {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: #f8f6f1;
}

.performance-main-metrics strong,
.performance-people-row strong,
.performance-risk-row strong {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  font-size: 18px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.performance-people-row div {
  background: #f4f7f6;
}

.performance-people-row strong {
  color: var(--green);
}

.performance-risk-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.performance-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.performance-footer span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.risk-normal {
  border-top-color: var(--green);
}

.risk-normal .performance-footer span:first-child {
  color: var(--green);
}

.risk-watch {
  border-top-color: var(--gold);
}

.risk-watch .performance-footer span:first-child {
  color: var(--gold);
}

.risk-high {
  border-top-color: var(--red);
}

.risk-high .performance-footer span:first-child {
  color: var(--red);
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
  color: var(--muted);
  font-size: 15px;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pagination-controls label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pagination-controls select {
  min-width: 86px;
}

.diagnosis-layout {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
  min-width: 0;
}

.diagnosis-layout.results-collapsed {
  grid-template-columns: 48px minmax(0, 1fr);
}

.diagnosis-layout > .content-band {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
}

.diagnosis-panel-restore {
  writing-mode: vertical-rl;
  min-width: 48px;
  min-height: 180px;
  padding: 12px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.diagnosis-list {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  overflow: auto;
}

.diagnosis-item {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.diagnosis-item:hover,
.diagnosis-item.active {
  border-color: #bcb39f;
  background: #faf7ef;
}

.diagnosis-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.diagnosis-item span,
.diagnosis-item small {
  color: var(--muted);
  line-height: 1.45;
}

.diagnosis-item strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 14px;
}

.status-warning {
  background: #fff3df;
  color: var(--gold);
}

.status-blocked {
  background: #fbe8e6;
  color: var(--red);
}

.status-normal {
  background: #eaf3ed;
  color: var(--green);
}

.status-unknown {
  background: #f1eee7;
  color: var(--muted);
}

.report-preview {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 0;
  min-width: 0;
  padding-right: 6px;
  overflow-y: auto;
  overflow-x: hidden;
  font-size: 16px;
  line-height: 1.6;
}

.report-preview > *,
.report-section,
.report-metric-list,
.report-metric,
.report-info-list,
.report-info-item,
.report-action-list,
.ai-report-box,
.ai-report-group {
  min-width: 0;
  max-width: 100%;
}

.report-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border: 1px solid #e7dcc6;
  border-radius: 8px;
  background: #fffaf0;
}

.report-title h3 {
  margin: 0;
  font-size: 26px;
  line-height: 1.25;
}

.report-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--gold);
  font-size: 14px;
  font-weight: 700;
}

.report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
}

.report-meta span {
  padding: 6px 10px;
  border-radius: 8px;
  background: #f7f3eb;
}

.report-meta-primary {
  margin-top: -4px;
}

.report-section {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.report-section-lead {
  border-color: #e7dcc6;
  background: #fffdf8;
}

.feedback-panel {
  border-color: #e7dcc6;
  background: #fffdf8;
}

.feedback-panel-head,
.feedback-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.feedback-panel-head {
  justify-content: space-between;
  color: var(--muted);
}

.feedback-summary-box,
.feedback-summary-inline {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 8px;
  background: #f8f6f1;
}

.feedback-summary-box p,
.feedback-summary-inline {
  color: var(--muted);
}

.feedback-mini {
  justify-self: start;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 13px;
}

.report-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee7db;
}

.report-section-title::before {
  content: "";
  width: 4px;
  height: 18px;
  border-radius: 999px;
  background: var(--gold);
}

.compact-heading {
  margin-bottom: 0;
}

.agent-layout,
.feedback-grid {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
}

.agent-sidebar-panel,
.agent-workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.agent-workspace {
  grid-template-rows: auto auto minmax(260px, 1fr) auto auto;
  gap: 12px;
}

.agent-conversation-list,
.feedback-list {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  overflow: auto;
}

.agent-conversation-item,
.feedback-item {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.agent-conversation-item {
  cursor: pointer;
}

.agent-conversation-item:hover,
.agent-conversation-item.active {
  border-color: #8fb9a8;
  background: #f4faf7;
}

.agent-conversation-item span,
.feedback-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.agent-conversation-item strong,
.feedback-item strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-conversation-item small,
.feedback-item p,
.feedback-item span {
  color: var(--muted);
}

.agent-stage-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f6f1;
}

.agent-stage-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.agent-stage-step i {
  display: grid;
  place-items: center;
  width: 20px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #e7e1d5;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
}

.agent-stage-step.active {
  border-color: #8fb9a8;
  background: #fff;
  color: var(--green);
  font-weight: 700;
}

.agent-stage-step.done {
  color: var(--green);
}

.agent-stage-step.active i,
.agent-stage-step.done i {
  background: var(--green);
  color: #fff;
}

.agent-messages {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 0;
  padding: 18px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
}

.agent-message {
  display: flex;
}

.agent-message.from-user {
  justify-content: flex-end;
}

.agent-message-bubble {
  display: grid;
  gap: 8px;
  max-width: min(680px, 86%);
  padding: 12px 14px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
}

.agent-message.from-user .agent-message-bubble {
  background: #eaf3ed;
  border-color: #cce1d5;
}

.agent-message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.agent-message-head span {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 8px;
  background: #f1eee7;
  color: var(--muted);
  font-size: 13px;
}

.agent-message-bubble p {
  color: var(--ink);
  line-height: 1.65;
  white-space: pre-wrap;
}

.agent-message-bubble small {
  color: var(--muted);
  font-size: 13px;
}

.agent-message.is-loading .agent-message-bubble {
  width: min(260px, 78%);
  background: #fffdf8;
}

.agent-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
}

.agent-typing span {
  width: 7px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #9a8f7b;
  animation: agentTyping 1s infinite ease-in-out;
}

.agent-typing span:nth-child(2) {
  animation-delay: 0.16s;
}

.agent-typing span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes agentTyping {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

.agent-message-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px 44px;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.agent-message-form .icon-button {
  display: inline-grid;
  place-items: center;
  align-self: end;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 8px;
}

.agent-message-form .icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.agent-voice-button {
  border-color: #d9d1c4;
  background: #fff;
  color: #3f3a33;
}

.agent-voice-button.recording {
  border-color: #b8453c;
  background: #fff1ee;
  color: #b8453c;
}

.agent-voice-button.transcribing {
  border-color: #8fb9a8;
  background: #f2faf6;
  color: var(--green);
}

.agent-send-button {
  border: 1px solid #202124;
  background: #202124;
  color: #fff;
}

textarea {
  width: 100%;
  min-height: 44px;
  max-height: 120px;
  padding: 0 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  resize: none;
  overflow: auto;
  line-height: 1.55;
  outline: none;
}

.agent-submit-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid #cce1d5;
  border-radius: 8px;
  background: #f4faf7;
}

.agent-submit-panel strong {
  display: block;
  margin-bottom: 4px;
}

.agent-submit-panel p {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.agent-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.agent-form-grid label,
.agent-summary-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 15px;
}

.agent-form-grid input {
  min-width: 0;
}

.feedback-item-head span {
  flex: 0 0 auto;
}

.report-section h4 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}

.report-section p {
  color: var(--muted);
  line-height: 1.75;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.report-hint {
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff8e8;
  color: var(--gold);
  font-size: 14px;
  line-height: 1.5;
}

.report-metric-list {
  display: grid;
  gap: 12px;
}

.report-metric {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdfa;
}

.report-metric-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.report-metric-head span {
  color: var(--muted);
  font-size: 14px;
}

.report-data-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.report-data-grid div {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: #f8f6f1;
}

.report-data-grid span {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.report-data-grid strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-action-list {
  display: grid;
  gap: 8px;
}

.report-action-list div,
.report-empty {
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8f6f1;
  color: var(--muted);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.report-info-list {
  display: grid;
  gap: 12px;
}

.report-info-item {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdfa;
}

.report-info-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.report-info-head strong {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.report-info-head span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 14px;
}

.report-info-item p {
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.report-chip-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.report-chip {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: #f8f6f1;
}

.report-chip strong,
.report-chip span,
.report-chip small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-chip span,
.report-chip small {
  color: var(--muted);
  font-size: 14px;
}

.report-meta.compact {
  gap: 8px;
}

.report-meta.compact span {
  padding: 4px 8px;
  font-size: 14px;
}

.action-plan-item {
  border-color: #e7dcc6;
  background: #fffdf8;
}

.ai-report-box {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid #e7dcc6;
  border-radius: 8px;
  background: #fffdf8;
}

.ai-report-group {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid #eee7db;
}

.ai-report-group ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.ai-report-group li {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ai-report-text {
  margin: 0;
  padding: 14px;
  border-radius: 8px;
  background: #f8f6f1;
  color: var(--ink);
  font: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.metric-detail-group {
  display: grid;
  gap: 10px;
}

.metric-detail-title {
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.metric-detail-table {
  display: grid;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.metric-detail-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.1fr) minmax(110px, 1fr) minmax(110px, 1fr) minmax(110px, 1fr) minmax(86px, 0.8fr) minmax(72px, 0.7fr);
  gap: 10px;
  min-width: 760px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  align-items: center;
}

.metric-detail-row:last-child {
  border-bottom: 0;
}

.metric-detail-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-detail-head {
  background: #f8f6f1;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.secondary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

td {
  font-size: 17px;
}

.filter-row {
  display: flex;
  align-items: end;
  gap: 12px;
}

.filter-row label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 15px;
}

select,
input {
  min-width: 180px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
}

.empty-state {
  padding: 38px 18px;
  color: var(--muted);
  text-align: center;
}

.anomaly-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.6fr);
  gap: 18px;
  align-items: start;
}

#anomalyTracking-view.view.active {
  align-content: stretch;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
}

#anomalyTracking-view .anomaly-layout {
  min-height: 0;
  height: 100%;
  align-items: stretch;
}

#anomalyTracking-view .anomaly-layout > .content-band {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.anomaly-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.anomaly-stat-card { display: grid; gap: 6px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); text-align: left; cursor: pointer; }
.anomaly-stat-card span { color: var(--muted); font-size: 14px; }
.anomaly-stat-card strong { font-size: 26px; }
.anomaly-stat-card.active { border-color: #d97941; background: #fff8f2; }

.anomaly-case-list,
.anomaly-observation-list {
  display: grid;
  gap: 10px;
}

.anomaly-case-list {
  display: block;
  min-height: 0;
  height: 0;
  flex: 1 1 auto;
  max-height: none;
  overflow-y: scroll;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 0 8px 8px 0;
}
.anomaly-store-group + .anomaly-store-group { margin-top: 10px; }
.anomaly-store-group { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.anomaly-store-group.has-active { border-color: #d97941; box-shadow: 0 0 0 2px rgba(217, 121, 65, 0.1); }
.anomaly-store-group-head { display: flex; width: 100%; justify-content: space-between; gap: 10px; align-items: center; padding: 12px 14px; border: 0; background: #f8f6f1; color: var(--ink); text-align: left; cursor: pointer; }
.anomaly-store-group-head > div { display: grid; gap: 3px; }
.anomaly-store-group-head > div span, .anomaly-store-group-head > span { color: var(--muted); font-size: 13px; }
.anomaly-store-group-summary { display: inline-flex; align-items: center; gap: 8px; }
.anomaly-store-group-summary b { color: #d97941; font-size: 18px; line-height: 1; transition: transform 160ms ease; }
.anomaly-store-group.expanded .anomaly-store-group-summary b { transform: rotate(180deg); }
.anomaly-store-group-items {
  display: grid;
  max-height: min(42vh, 360px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.anomaly-case {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.anomaly-case + .anomaly-case { border-top: 1px solid var(--line); }
.anomaly-case.active { background: #fff8f2; }
.anomaly-case-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.anomaly-case-metric { font-size: 15px; font-weight: 650; }
.anomaly-case small, .anomaly-case-metric small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.anomaly-case-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
.anomaly-case-comparisons { color: #8b6d57; font-size: 12px; }
.anomaly-detail { display: grid; min-height: 0; flex: 1 1 auto; gap: 18px; overflow: auto; padding-right: 6px; align-content: start; }
.anomaly-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.anomaly-summary-grid > div { display: grid; gap: 5px; padding: 14px; border-radius: 10px; background: #f8f6f1; }
.anomaly-summary-grid span { color: var(--muted); font-size: 14px; }
.anomaly-summary-grid strong { font-size: 20px; }
.anomaly-summary-grid small { color: var(--muted); }
.anomaly-rule-note { padding: 11px 13px; border-left: 3px solid #d97941; border-radius: 4px; background: #fff8f2; color: #73553f; font-size: 14px; line-height: 1.65; }
.anomaly-chart-legend { display: flex; gap: 18px; align-items: center; color: var(--muted); font-size: 14px; }
.anomaly-chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { display: inline-block; width: 18px; border-top: 3px solid; border-radius: 4px; }
.legend-dot.actual { border-color: #d97941; }
.legend-dot.reference-0 { border-color: #718096; border-top-style: dashed; }
.legend-dot.reference-1 { border-color: #6f9274; border-top-style: dashed; }
.legend-dot.reference-2 { border-color: #97748f; border-top-style: dashed; }
.anomaly-trend-chart { width: 100%; height: 320px; margin-top: -8px; }
.anomaly-observation { display: grid; grid-template-columns: 100px 92px 1fr 1fr; gap: 12px; align-items: center; padding: 12px; border-bottom: 1px solid var(--line); }
.anomaly-analysis { padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.anomaly-analysis summary { cursor: pointer; font-weight: 700; }
.anomaly-analysis pre { white-space: pre-wrap; font-family: inherit; line-height: 1.7; }
.anomaly-report-list { display: grid; gap: 10px; margin-top: 12px; }
.anomaly-report-list article { padding: 12px; border-radius: 8px; background: #f8f6f1; }
.anomaly-report-list p { margin: 7px 0 0; color: var(--muted); line-height: 1.65; }
.anomaly-feedback-list { display: grid; gap: 10px; margin-top: 12px; }
.anomaly-feedback-list article { padding: 12px; border-radius: 8px; background: #f8f6f1; }
.anomaly-feedback-list article > div { display: flex; justify-content: space-between; gap: 10px; }
.anomaly-feedback-list article span { color: var(--muted); font-size: 13px; }
.anomaly-feedback-list p { margin: 8px 0 0; line-height: 1.65; }
.anomaly-pause-button { margin-left: 10px; color: #8a4f2e; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #202124;
  color: white;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
}

@media (max-width: 1100px) {
  .metric-grid,
  .store-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-filter-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 14px;
  }

  .brand-block,
  .sidebar-footer {
    display: none;
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-item {
    min-height: 38px;
    padding: 0 8px;
    text-align: center;
    font-size: 15px;
  }

  .main {
    padding: 18px;
  }

  .topbar {
    display: grid;
  }

  .top-actions {
    align-items: stretch;
    justify-content: space-between;
  }

  h1 {
    font-size: 28px;
  }

  .metric-grid,
  .report-data-grid,
  .store-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-filter-bar {
    grid-template-columns: 1fr;
  }

  .filter-row {
    display: grid;
  }

  .pagination-bar,
  .pagination-controls,
  .diagnosis-layout,
  .anomaly-layout,
  .agent-layout,
  .feedback-grid,
  .agent-submit-panel,
  .agent-message-form,
  .agent-form-grid {
    display: grid;
    justify-items: stretch;
  }

  .diagnosis-layout,
  .anomaly-layout,
  .agent-layout,
  .feedback-grid,
  .agent-form-grid {
    grid-template-columns: 1fr;
  }

  .anomaly-summary-grid { grid-template-columns: 1fr; }
  .anomaly-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #anomalyTracking-view.view.active { grid-template-rows: none; overflow: auto; }
  #anomalyTracking-view .anomaly-layout { height: auto; }
  #anomalyTracking-view .anomaly-layout > .content-band { overflow: visible; }
  .anomaly-case-list, .anomaly-detail { height: auto; flex: initial; max-height: none; overflow: visible; }
  .anomaly-observation { grid-template-columns: 1fr 1fr; }

  select,
  input {
    width: 100%;
  }
}

/* 窄桌面窗口仍保留异常追踪的双栏独立滚动；仅手机宽度才切换为单列。 */
@media (min-width: 561px) and (max-width: 760px) {
  #anomalyTracking-view.view.active {
    grid-template-rows: auto auto minmax(0, 1fr);
    overflow: hidden;
  }

  #anomalyTracking-view .anomaly-layout {
    height: 100%;
    grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.6fr);
  }

  #anomalyTracking-view .anomaly-layout > .content-band {
    display: flex;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
  }

  #anomalyTracking-view .anomaly-case-list,
  #anomalyTracking-view .anomaly-detail {
    height: 0;
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
  }
}
