:root {
  color-scheme: light;
  --primary: #1677ff;
  --primary-hover: #0958d9;
  --ink: #1f2329;
  --muted: #646a73;
  --line: #dee2e7;
  --line-light: #edf0f2;
  --page: #f3f5f7;
  --panel: #fff;
  --soft-blue: #eaf3ff;
  --success: #2f9e68;
  --danger: #c64242;
  font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
*[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; min-width: 320px; overflow: hidden; }
body { color: var(--ink); background: var(--page); overscroll-behavior: none; }
button, select, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .58; }

.app-shell {
  display: grid;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  grid-template-rows: 64px 48px minmax(0, 1fr);
}
.topbar {
  z-index: 30;
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 28px;
  border-top: 2px solid #30343b;
  border-bottom: 1px solid var(--line-light);
  background: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; }
.menu-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  color: #41464d;
  background: transparent;
  font-size: 18px;
}
.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: #fff;
  border-radius: 6px;
  background: var(--primary);
  font-size: 17px;
  font-weight: 800;
}
.brand-title { font-size: 20px; font-weight: 760; letter-spacing: .01em; }
.brand-subtitle { margin-top: 1px; color: #8a9099; font-size: 11px; }
.system-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #c6cad0; }
.system-status.ok .status-dot { background: #38b87c; box-shadow: 0 0 0 4px #e6f7ef; }
.system-status.error .status-dot { background: #e25555; box-shadow: 0 0 0 4px #fdecec; }

.tabbar {
  display: flex;
  height: 48px;
  align-items: flex-end;
  gap: 8px;
  padding: 0 16px;
  background: #fff;
}
.tab { height: 40px; padding: 0 20px; border: 1px solid transparent; background: transparent; }
.tab.active {
  color: var(--primary);
  border-color: var(--line);
  border-bottom-color: #fff;
  border-radius: 7px 7px 0 0;
  background: #fff;
  font-weight: 700;
}
.tab-placeholder { padding: 0 10px 12px; color: #777d85; }

.workspace {
  display: grid;
  min-height: 0;
  padding: 14px 16px 16px;
  overflow: hidden;
  grid-template-rows: auto minmax(0, 1fr);
}
.scope-panel, .process-panel, .dialogue-panel { border: 1px solid var(--line-light); border-radius: 7px; background: var(--panel); }
.scope-panel {
  position: relative;
  z-index: 20;
  padding: 15px 24px 12px;
  box-shadow: 0 6px 18px rgba(31, 35, 41, .06);
}
.panel-heading, .dialogue-heading, .card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}
.panel-heading h1, .dialogue-heading h2 { margin: 0; font-size: 18px; }
.panel-heading p, .dialogue-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.panel-state { flex: none; padding: 5px 9px; color: #4d5866; border-radius: 4px; background: #f1f3f5; font-size: 11px; }
.panel-state.loading { color: #8a5b12; background: #fff7e6; }
.panel-state.ready { color: #246b4d; background: #eaf7f0; }
.panel-state.error { color: #9f3535; background: #fff0f0; }

.scope-form {
  display: grid;
  grid-template-columns: minmax(260px, 1.5fr) minmax(190px, 1fr) minmax(120px, .55fr) auto;
  gap: 14px;
  align-items: end;
  margin-top: 15px;
}
.field { min-width: 0; }
.field > span { display: block; margin-bottom: 7px; color: #383d44; font-size: 12px; font-weight: 650; }
.field em { color: #dd3e3e; font-style: normal; }
select, input[type="number"], input[type="text"] {
  width: 100%;
  height: 38px;
  padding: 0 30px 0 11px;
  color: #30343a;
  border: 1px solid #d6d9de;
  border-radius: 5px;
  outline: none;
  background: #fff;
}
select:focus, input[type="number"]:focus, input[type="text"]:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(22, 119, 255, .1); }
.number-field { position: relative; }
.number-field input { padding-right: 34px; }
.number-field > span { position: absolute; top: 50%; right: 11px; color: var(--muted); transform: translateY(-50%); font-size: 11px; pointer-events: none; }
.field-hint { margin-top: 9px; color: #7a818a; font-size: 10px; }
.scope-actions { display: flex; gap: 8px; }
.primary-button, .secondary-button, .send-button {
  min-height: 38px;
  padding: 0 16px;
  border-radius: 5px;
  font-weight: 700;
  white-space: nowrap;
}
.primary-button, .send-button { color: #fff; border: 1px solid var(--primary); background: var(--primary); }
.primary-button:hover:not(:disabled), .send-button:hover:not(:disabled) { border-color: var(--primary-hover); background: var(--primary-hover); }
.secondary-button { color: #3d4249; border: 1px solid #d5d9de; background: #fff; }
.secondary-button:hover:not(:disabled) { color: var(--primary); border-color: var(--primary); }
.scope-feedback { min-height: 42px; margin-top: 10px; }
.scope-summary {
  display: flex;
  min-height: 42px;
  align-items: center;
  padding: 0 11px;
  color: var(--muted);
  border: 1px dashed #dce3eb;
  border-radius: 5px;
  background: #fafbfd;
  font-size: 11px;
}
.branch-preview {
  display: flex;
  min-height: 42px;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 6px 10px;
  overflow: hidden;
  border: 1px solid #dce3eb;
  border-radius: 5px;
  background: #f8fafc;
}
.preview-stats { display: flex; flex: none; align-items: center; }
.preview-stats div { display: flex; align-items: baseline; gap: 5px; padding: 0 12px; border-right: 1px solid #dfe5ec; }
.preview-stats div:first-child { padding-left: 2px; }
.preview-stats strong { color: #1f4f8b; font-size: 15px; }
.preview-stats span { color: var(--muted); font-size: 10px; }
.route-chips { display: flex; min-width: 0; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; }
.route-chips::before { flex: none; color: #7a818a; content: "涉及路线"; font-size: 10px; }
.route-chips span { flex: none; padding: 3px 7px; color: #315981; border: 1px solid #d6e3f2; border-radius: 3px; background: #fff; font-size: 10px; }
.blocking-list { flex: 1 0 100%; margin-top: 4px; padding: 9px 11px; color: #923a3a; border-left: 3px solid #d9534f; background: #fff2f2; font-size: 11px; }
.blocking-list p { margin: 5px 0 0; }
.inline-error { margin-top: 7px; padding: 8px 10px; color: var(--danger); border: 1px solid #f2caca; border-radius: 4px; background: #fff7f7; font-size: 12px; }

.decision-layout {
  display: grid;
  min-height: 0;
  overflow: hidden;
  grid-template-columns: minmax(0, 1.8fr) minmax(340px, .72fr);
  gap: 14px;
  align-items: stretch;
  margin-top: 14px;
}
.process-panel, .dialogue-panel { display: grid; min-width: 0; min-height: 0; overflow: hidden; }
.process-panel { grid-template-rows: auto minmax(0, 1fr); }
.dialogue-panel { grid-template-rows: auto minmax(0, 1fr) auto; }
.dialogue-heading { align-items: center; padding: 15px 22px; border-bottom: 1px solid var(--line-light); }
.text-button { flex: none; color: var(--primary); border: 0; background: transparent; font-size: 12px; white-space: nowrap; }
.process-timeline {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px;
  background: #fafbfc;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}
.conversation {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px;
  background: #fafbfc;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}
.welcome-card {
  max-width: 670px;
  margin: 36px auto;
  padding: 26px;
  text-align: center;
  border: 1px dashed #cad8ea;
  border-radius: 7px;
  background: #fff;
}
.welcome-icon { display: grid; width: 42px; height: 42px; margin: 0 auto 12px; place-items: center; color: var(--primary); border-radius: 50%; background: var(--soft-blue); font-size: 20px; }
.welcome-card h2 { margin: 0; font-size: 18px; }
.welcome-card p { margin: 10px auto 16px; color: var(--muted); font-size: 13px; line-height: 1.75; }
.feature-list { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.feature-list span { padding: 5px 9px; color: #4e5c6e; border-radius: 4px; background: #f2f5f8; font-size: 11px; }
.chat-placeholder { margin: 28px auto; padding: 20px 14px; color: var(--muted); text-align: center; }
.chat-placeholder h2 { margin: 0; color: var(--ink); font-size: 16px; }
.chat-placeholder p { margin: 9px 0 0; font-size: 12px; line-height: 1.7; }

.assistant-card, .error-card, .saved-card, .progress-card, .complete-card {
  width: min(1180px, 100%);
  margin: 0 auto 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 3px 10px rgba(31, 35, 41, .04);
}
.assistant-label { margin-bottom: 6px; color: var(--primary); font-size: 11px; font-weight: 700; }
.card-heading h2 { margin: 0; font-size: 18px; }
.verified-badge { padding: 5px 8px; color: #26704f; border-radius: 4px; background: #eaf7f0; font-size: 11px; }
.scope-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 17px; overflow: hidden; border: 1px solid var(--line-light); background: var(--line-light); }
.scope-item { min-width: 0; padding: 11px 12px; background: #fff; }
.scope-item span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; }
.scope-item strong { font-size: 13px; overflow-wrap: anywhere; }
.scope-item.scope-wide { grid-column: span 2; }
.defaults-box { margin-top: 12px; padding: 10px 12px; color: #66511e; border-left: 3px solid #efb84f; background: #fffbef; font-size: 11px; }
.defaults-box ul { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 6px 0 0; padding-left: 18px; }
.card-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.action-note { margin: 8px 0 0; color: #8a9099; text-align: right; font-size: 10px; }
.error-card { color: #8c3333; border-color: #efcaca; background: #fff8f8; }
.saved-card, .complete-card { color: #235e45; border-color: #cbe6d8; background: #f5fbf8; }
.complete-card.partial { color: #735315; border-color: #ead9aa; background: #fffaf0; }
.error-card strong, .saved-card strong, .progress-card strong, .complete-card strong { display: block; margin-bottom: 5px; }
.error-card p, .saved-card p, .progress-card p, .complete-card p { margin: 0; font-size: 12px; line-height: 1.6; }
.progress-track { height: 7px; margin: 12px 0 8px; overflow: hidden; border-radius: 4px; background: #e8ebee; }
.progress-bar { width: 3%; height: 100%; background: var(--primary); transition: width .3s; }
.progress-meta { color: var(--muted); font-size: 10px; }
.progress-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.progress-heading strong { margin: 0; }
.elapsed-time { flex: none; padding: 4px 8px; color: #175ea8; border-radius: 4px; background: #eaf3ff; font-size: 11px; font-variant-numeric: tabular-nums; }
.artifact-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.artifact-links a { padding: 6px 9px; color: var(--primary); text-decoration: none; border: 1px solid #b8d4fa; border-radius: 4px; background: #fff; font-size: 11px; }
.summary-overview { margin-top: 14px !important; padding: 10px 12px; color: #34465c; border-left: 3px solid var(--primary); background: #f2f7ff; }
.completion-summary { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .8fr); gap: 12px; margin-top: 13px; }
.outcome-summary, .review-summary { padding: 17px 18px; color: var(--ink); border: 1px solid #dfe7ef; border-radius: 7px; background: #fff; }
.summary-section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.summary-section-heading div > span { display: block; margin-bottom: 4px; color: #697586; font-size: 10px; }
.summary-section-heading div > strong { margin: 0; color: #25364a; font-size: 13px; }
.summary-section-heading > small { color: #ad5f22; font-size: 10px; font-weight: 700; }
.outcome-track { height: 8px; margin: 15px 0 14px; overflow: hidden; border-radius: 999px; background: #e5f2eb; }
.maintenance-share { display: block; height: 100%; border-radius: inherit; background: #e58a36; }
.outcome-values { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.outcome-value { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 2px 10px; min-width: 0; }
.outcome-value span { color: #586474; font-size: 11px; }
.outcome-value strong { grid-row: 2; margin: 0; color: #25364a; font-size: 28px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.outcome-value small { grid-row: 2; color: #8993a0; font-size: 11px; }
.outcome-value.maintenance { padding-right: 20px; border-right: 1px solid var(--line-light); }
.outcome-value.maintenance strong { color: #bd641f; }
.outcome-value.no-maintenance strong { color: #287652; }
.review-summary dl { display: grid; gap: 0; margin: 11px 0 0; }
.review-summary dl > div { display: flex; min-height: 36px; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line-light); }
.review-summary dt { color: #586474; font-size: 11px; }
.review-summary dd { margin: 0; color: #25364a; font-size: 16px; font-weight: 750; font-variant-numeric: tabular-nums; }
.review-summary dd small { margin-left: 4px; color: #8b949f; font-size: 9px; font-weight: 400; }
.healthy-text { color: #287652 !important; }
.attention-text { color: #b4553e !important; }
.execution-summary { display: grid; grid-template-columns: 1fr 1fr 1.25fr; gap: 8px; margin-top: 8px; color: var(--ink); }
.execution-summary > div { display: grid; min-width: 0; min-height: 78px; align-content: center; padding: 12px 14px; border: 1px solid #e3e8ee; border-radius: 6px; background: rgba(255, 255, 255, .84); }
.execution-summary span { color: #697586; font-size: 10px; }
.execution-summary strong { margin: 4px 0 2px; color: #25364a; font-size: 19px; line-height: 1.2; }
.execution-summary small { overflow: hidden; color: #8b949f; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.execution-summary .quality-summary { padding-left: 40px; background-repeat: no-repeat; background-position: 14px center; background-size: 16px 16px; }
.quality-summary.healthy { border-color: #cfe7d9; background-color: #f8fcfa; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232f9e68' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m8 12 2.5 2.5L16.5 8.5'/%3E%3C/svg%3E"); }
.quality-summary.healthy strong { color: #287652; }
.quality-summary.attention { border-color: #efd9aa; background-color: #fffaf0; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b47714' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 3.6 2.2 18a2 2 0 0 0 1.8 3h16a2 2 0 0 0 1.8-3L13.7 3.6a2 2 0 0 0-3.4 0Z'/%3E%3Cpath d='M12 9v4M12 17h.01'/%3E%3C/svg%3E"); }
.quality-summary.attention strong { color: #9b6813; }
.complete-card h3 { margin: 16px 0 8px; font-size: 12px; }
.measure-list { display: flex; flex-wrap: wrap; gap: 6px; }
.measure-list span { padding: 5px 8px; color: #425269; border: 1px solid #dce5ef; border-radius: 4px; background: #f7f9fb; font-size: 10px; }
.summary-note { margin-top: 11px !important; color: var(--muted); font-size: 10px !important; }
.result-level { margin-top: 18px; color: var(--ink); }
.result-level h3 { margin: 0 0 9px; font-size: 14px; }
.table-shell { overflow: auto; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.table-shell table { width: 100%; min-width: 1180px; border-collapse: collapse; font-size: 11px; }
.table-shell th, .table-shell td { padding: 9px 10px; text-align: center; white-space: nowrap; border-right: 1px solid var(--line-light); border-bottom: 1px solid var(--line-light); }
.table-shell th { position: sticky; top: 0; z-index: 1; color: #303842; background: #f7f8fa; font-weight: 700; }
.table-shell tbody tr:nth-child(even) { background: #fbfcfd; }
.overview-table table { min-width: 1450px; }
.route-tabs { display: flex; flex-wrap: wrap; gap: 0; margin-bottom: 10px; }
.route-tab { min-width: 62px; height: 34px; padding: 0 14px; color: #44505e; border: 1px solid #d7dce2; background: #fff; }
.route-tab + .route-tab { margin-left: -1px; }
.route-tab.active { position: relative; z-index: 1; color: #fff; border-color: var(--primary); background: var(--primary); }
.table-link { color: var(--primary); border: 0; background: transparent; }
.result-loading, .empty-cell { padding: 24px; color: var(--muted); text-align: center; }
.result-note { margin: 7px 0 0; color: var(--muted); font-size: 10px; }

.detail-drawer { position: fixed; inset: 0; z-index: 100; visibility: hidden; pointer-events: none; }
.detail-drawer.open { visibility: visible; pointer-events: auto; }
.drawer-backdrop { position: absolute; inset: 0; width: 100%; border: 0; opacity: 0; background: rgba(20, 28, 38, .34); transition: opacity .2s; }
.detail-drawer.open .drawer-backdrop { opacity: 1; }
.drawer-panel {
  position: absolute;
  inset: 4vh 3vw;
  overflow: hidden;
  border-radius: 8px;
  opacity: 0;
  transform: scale(.985);
  background: #fff;
  box-shadow: 0 18px 55px rgba(20, 28, 38, .22);
  transition: opacity .18s ease, transform .18s ease;
}
.detail-drawer.open .drawer-panel { opacity: 1; transform: scale(1); }
.drawer-heading { display: flex; min-height: 72px; align-items: center; justify-content: space-between; padding: 15px 22px; border-bottom: 1px solid var(--line); }
.drawer-heading span { color: var(--primary); font-size: 11px; }
.drawer-heading h2 { margin: 4px 0 0; font-size: 18px; }
.drawer-close { width: 38px; height: 38px; color: #747b84; border: 0; background: transparent; font-size: 28px; }
.drawer-body { height: calc(100% - 72px); overflow: auto; padding: 18px 20px; }
.drawer-table table { min-width: 2600px; }
.modal-route-tabs { position: sticky; top: -18px; z-index: 4; padding: 10px 0; background: #fff; }
.drawer-back-button { margin-bottom: 12px; padding: 7px 10px; color: var(--primary); border: 1px solid #b8d4fa; border-radius: 4px; background: #fff; }
.reason-cell { max-width: 420px; white-space: normal !important; text-align: left !important; line-height: 1.55; }
body.drawer-open { overflow: hidden; }

.composer { padding: 14px; border-top: 1px solid var(--line-light); background: #fff; }
.composer-inner { display: flex; gap: 10px; align-items: flex-end; width: min(820px, 100%); margin: 0 auto; }
textarea { flex: 1; min-height: 56px; resize: none; padding: 11px 12px; color: #777; line-height: 1.55; border: 1px solid #d8dce1; border-radius: 5px; background: #f7f8f9; }
.send-button { min-width: 74px; }
.composer-meta { display: flex; align-items: center; gap: 8px; width: min(820px, 100%); margin: 8px auto 0; color: #8a9099; font-size: 10px; }
.future-badge { padding: 3px 6px; color: #7a5a18; border-radius: 3px; background: #fff3d6; }

@media (max-width: 1180px) {
  .scope-form { grid-template-columns: repeat(3, minmax(160px, 1fr)); }
  .scope-actions { justify-content: flex-end; grid-column: 1 / -1; }
}

@media (max-width: 1000px) {
  .decision-layout { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .topbar { min-height: 58px; padding: 0 14px; }
  .brand-mark, .brand-subtitle { display: none; }
  .brand-title { font-size: 17px; }
  .system-status span:last-child { display: none; }
  .tabbar { height: 44px; padding-left: 8px; }
  .app-shell { grid-template-rows: 58px 44px minmax(0, 1fr); }
  .workspace { padding: 8px; }
  .scope-panel { padding: 15px 13px 12px; }
  .panel-heading { display: block; }
  .panel-state { display: inline-block; margin-top: 9px; }
  .scope-form { grid-template-columns: 1fr 1fr; gap: 11px 9px; }
  .field-branch { grid-column: 1 / -1; }
  .scope-actions { grid-column: 1 / -1; }
  .scope-actions button { flex: 1; }
  .dialogue-heading { padding: 13px; }
  .dialogue-heading p { max-width: 260px; }
  .process-timeline { padding: 12px 10px; }
  .conversation { padding: 18px 10px; }
  .welcome-card { margin: 15px auto; padding: 22px 14px; }
  .scope-grid { grid-template-columns: 1fr 1fr; }
  .scope-item.scope-wide { grid-column: 1 / -1; }
  .card-actions { flex-direction: column-reverse; }
  .card-actions button { width: 100%; }
  .action-note { text-align: left; }
  .composer { padding: 12px 10px; }
  .composer-meta { align-items: flex-start; }
  .completion-summary { grid-template-columns: 1fr; }
  .execution-summary { grid-template-columns: 1fr 1fr; }
  .execution-summary .quality-summary { grid-column: 1 / -1; }
  .branch-preview { align-items: flex-start; flex-direction: column; gap: 6px; }
  .drawer-panel { inset: 0; border-radius: 0; }
  .progress-heading { align-items: flex-start; flex-direction: column; gap: 7px; }
}

@media (max-width: 420px) {
  .scope-form, .scope-grid { grid-template-columns: 1fr; }
  .field-branch, .scope-actions, .scope-item.scope-wide { grid-column: auto; }
  .outcome-values, .execution-summary { grid-template-columns: 1fr; }
  .outcome-value.maintenance { padding: 0 0 12px; border-right: 0; border-bottom: 1px solid var(--line-light); }
  .execution-summary .quality-summary { grid-column: auto; }
}
