:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --line: #d8dee7;
  --line-strong: #b9c3d0;
  --text: #17202a;
  --muted: #5b6776;
  --primary: #176b5d;
  --primary-dark: #105347;
  --primary-soft: #e8f5f1;
  --accent: #2f5f98;
  --danger: #b42318;
  --warning: #966100;
  --ok: #16703c;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}

button:hover {
  border-color: var(--primary);
}

button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

button.primary:hover {
  background: var(--primary-dark);
}

button.primary.subtle {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

button.primary.subtle:hover {
  background: #d8eee7;
}

button.danger {
  border-color: var(--danger);
  color: var(--danger);
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 12px 28px rgba(16, 24, 40, .08);
}

.login-panel h1 {
  font-size: 22px;
  margin: 0 0 6px;
}

.login-panel p {
  color: var(--muted);
  margin: 0 0 22px;
}

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

.sidebar {
  background: #17202a;
  color: #f8fafc;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  min-width: 0;
}

.brand h1 {
  font-size: 16px;
  line-height: 1.3;
  margin: 0 0 8px;
  overflow-wrap: anywhere;
}

.brand small {
  color: #cad5df;
  overflow-wrap: anywhere;
}

.nav {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.nav button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  border-color: transparent;
  color: #dce6ef;
  background: transparent;
  min-height: 40px;
  font-weight: 600;
}

.nav button.active,
.nav button:hover {
  background: #243241;
  color: #fff;
}

.user-box {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,.14);
  padding-top: 14px;
  color: #dce6ef;
  min-width: 0;
  overflow-wrap: anywhere;
}

.user-box button {
  margin-top: 10px;
  width: 100%;
}

.main {
  padding: 22px;
  min-width: 0;
}

.topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.topline > * {
  min-width: 0;
}

.topline h2 {
  margin: 0 0 4px;
  font-size: 24px;
}

.topline p {
  color: var(--muted);
  margin: 0;
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.toolbar > * {
  width: auto;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  white-space: nowrap;
}

.inline-check input {
  width: auto;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

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

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.panel h3 {
  font-size: 16px;
  margin: 0 0 12px;
}

.panel.nested {
  box-shadow: none;
  background: #fbfcfd;
}

.section-title,
.agent-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title h3,
.agent-heading h3 {
  margin-bottom: 4px;
}

.section-title p,
.agent-heading p {
  margin: 0;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr);
  gap: 16px;
  align-items: start;
}

.master-agent-dashboard {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.agent-console {
  padding: 18px;
  margin-bottom: 16px;
  border-color: #b8d8d0;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbfa 100%);
}

.master-chat-panel {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 44px);
  overflow: auto;
}

.agent-workspace-panel {
  min-height: calc(100vh - 140px);
}

.dashboard-agent-messages {
  max-height: 360px;
  margin-bottom: 10px;
}

.agent-input-label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 600;
}

.agent-input {
  min-height: 92px;
  font-size: 15px;
  line-height: 1.55;
  border-color: #b8c9d7;
}

.master-agent-input {
  width: 100%;
  min-height: 118px;
  margin: 8px 0 10px;
}

.quick-command-row {
  margin-top: 10px;
}

.quick-command-row button:not(.primary) {
  background: #f7fafc;
  border-color: var(--line);
}

.task-panel {
  position: sticky;
  top: 18px;
}

.compact-task-list {
  display: grid;
  gap: 10px;
}

.compact-task {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcfd;
}

.compact-task strong {
  display: block;
  margin-bottom: 4px;
}

.compact-task span:not(.status) {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
  background: #fbfcfd;
}

.dashboard-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
  background: #fff;
  color: var(--muted);
}

.stat-pill strong {
  color: var(--text);
  font-size: 15px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.metric strong {
  display: block;
  font-size: 24px;
  margin-top: 4px;
}

.flow-data-dashboard {
  display: grid;
  gap: 16px;
  max-width: 1180px;
}

.dashboard-refresh,
.dashboard-detail-filter,
.dashboard-detail-filter > div,
.dashboard-module-filter,
.dashboard-module-legend {
  display: flex;
  align-items: center;
}

.dashboard-refresh {
  justify-content: flex-end;
  gap: 10px;
}

.dashboard-refresh span {
  color: var(--muted);
  font-size: 12px;
}

.dashboard-kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.dashboard-kpi {
  min-height: 136px;
  display: grid;
  align-content: space-between;
  gap: 10px;
  border-top: 4px solid var(--primary);
  border-right: 1px solid var(--line);
  padding: 18px;
}

.dashboard-kpi:last-child {
  border-right: 0;
}

.dashboard-kpi.tasks {
  border-top-color: #aa7410;
}

.dashboard-kpi.completed {
  border-top-color: var(--accent);
}

.dashboard-kpi.rate {
  border-top-color: #596574;
}

.dashboard-kpi span,
.dashboard-kpi small {
  color: var(--muted);
}

.dashboard-kpi strong {
  font-size: 38px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.dashboard-kpi small {
  font-size: 13px;
}

.dashboard-detail-filter {
  min-height: 48px;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 0 2px 12px;
}

.dashboard-detail-filter > div:first-child {
  flex: 0 0 auto;
  gap: 10px;
  white-space: nowrap;
}

.dashboard-detail-filter span {
  color: var(--muted);
  font-size: 13px;
}

.dashboard-module-filter {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.dashboard-module-filter button {
  min-height: 30px;
  padding: 4px 9px;
  color: var(--muted);
}

.dashboard-module-filter button.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.dashboard-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
  gap: 16px;
  align-items: start;
}

.dashboard-column {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 16px;
}

.dashboard-running-panel,
.dashboard-module-panel,
.dashboard-attention-panel,
.dashboard-completed-panel {
  padding: 18px;
}

.dashboard-workflow-list,
.dashboard-module-list,
.dashboard-compact-list {
  border-bottom: 1px solid var(--line);
}

.dashboard-workflow-list,
.dashboard-compact-list {
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.dashboard-workflow-list {
  max-height: 610px;
}

.dashboard-compact-list {
  max-height: 390px;
}

.dashboard-workflow-row {
  display: grid;
  grid-template-columns: minmax(190px, 1.4fr) minmax(130px, 1fr) minmax(110px, .8fr) 92px auto;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

.dashboard-workflow-row > div,
.dashboard-workflow-name,
.dashboard-compact-row > div {
  min-width: 0;
}

.dashboard-workflow-row span,
.dashboard-workflow-row strong,
.dashboard-workflow-name span,
.dashboard-compact-row span,
.dashboard-compact-row strong {
  display: block;
}

.dashboard-workflow-row > div > span,
.dashboard-workflow-name span,
.dashboard-compact-row span {
  color: var(--muted);
  font-size: 12px;
}

.dashboard-workflow-row > div > strong,
.dashboard-workflow-name strong,
.dashboard-compact-row strong {
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.dashboard-workflow-name strong {
  margin-top: 0;
  font-size: 14px;
}

.dashboard-workflow-row button,
.dashboard-compact-row button {
  white-space: nowrap;
}

.attention-medium {
  color: var(--warning);
}

.attention-high {
  color: var(--danger);
}

.dashboard-module-legend {
  justify-content: flex-end;
  gap: 12px;
  margin: -4px 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.dashboard-module-legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 5px;
  border-radius: 2px;
  background: var(--primary);
}

.dashboard-module-legend i.completed {
  background: var(--accent);
}

.dashboard-module-row {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(90px, auto) 52px minmax(90px, 1fr);
  align-items: center;
  gap: 10px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  padding: 8px 0;
  text-align: left;
}

.dashboard-module-row:hover,
.dashboard-module-row.active {
  background: var(--primary-soft);
}

.dashboard-module-name {
  overflow-wrap: anywhere;
}

.dashboard-module-count {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.dashboard-module-track {
  height: 10px;
  overflow: hidden;
  border-radius: 5px;
  background: var(--surface-2);
}

.dashboard-module-volume {
  height: 100%;
  display: flex;
  overflow: hidden;
  border-radius: 5px;
}

.dashboard-module-volume i {
  height: 100%;
  background: var(--primary);
}

.dashboard-module-volume i.completed {
  background: var(--accent);
}

.dashboard-cycle-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
}

.dashboard-cycle-summary span {
  color: var(--muted);
}

.dashboard-cycle-summary strong {
  font-variant-numeric: tabular-nums;
}

.dashboard-compact-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 11px 0;
}

.dashboard-compact-row > span {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.status.ok {
  background: #e8f5ee;
  color: var(--ok);
}

.status.warn {
  background: #fff4d7;
  color: var(--warning);
}

.status.bad {
  background: #fee4e2;
  color: var(--danger);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

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

th {
  background: #f0f3f7;
  color: #263241;
  font-weight: 600;
}

tr:last-child td {
  border-bottom: 0;
}

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

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.module-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.preset-group {
  margin-top: 12px;
}

.preset-group h4 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

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

.preset-button {
  text-align: left;
  min-height: 68px;
  padding: 10px 11px;
  display: grid;
  gap: 4px;
  align-content: start;
  border-color: var(--line);
  background: #fbfcfd;
}

.preset-button strong {
  color: var(--text);
}

.preset-button span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.preset-button:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.agent-prepare {
  display: grid;
  gap: 12px;
}

.agent-workspace-start {
  display: grid;
  gap: 14px;
}

.workspace-focus {
  display: grid;
  gap: 10px;
}

.workspace-focus > strong {
  font-size: 15px;
}

.compact-preset-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.compact-preset-list button {
  text-align: left;
  display: grid;
  gap: 4px;
  align-content: start;
  min-height: 62px;
  background: #fbfcfd;
  border-color: var(--line);
}

.compact-preset-list span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.agent-empty {
  min-height: 92px;
  display: grid;
  place-items: center;
}

.workflow-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}

.workflow-stage {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 8px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 11px 12px;
  min-height: 82px;
}

.workflow-stage span {
  grid-row: span 2;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}

.workflow-stage strong {
  font-size: 14px;
}

.workflow-stage small {
  color: var(--muted);
  line-height: 1.4;
}

.agent-decision pre {
  margin-top: 8px;
}

.inline-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
}

.package-board {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  padding: 14px;
}

.package-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.package-head h3 {
  margin: 0 0 4px;
  font-size: 17px;
}

.package-head p {
  margin: 0;
}

.package-summary-grid {
  display: grid;
  grid-template-columns: 1.1fr .55fr .55fr 1.35fr;
  gap: 10px;
  margin-bottom: 12px;
}

.package-summary {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 10px 11px;
  min-height: 72px;
}

.package-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.package-summary strong {
  display: block;
  line-height: 1.45;
  word-break: break-word;
}

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

.process-step-list {
  display: grid;
  gap: 10px;
}

.process-step-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 12px;
}

.process-step-index {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.process-step-title {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 5px;
}

.process-step-main > p {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.5;
}

.process-step-files {
  display: grid;
  gap: 7px;
}

.package-doc {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 10px;
}

.package-doc.compact {
  grid-template-columns: minmax(0, 1fr) auto;
  background: #fff;
  padding: 9px 10px;
}

.package-doc-index {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 700;
}

.package-doc-title {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.package-doc-main p {
  margin: 0 0 4px;
  line-height: 1.45;
}

.package-doc-main small {
  color: var(--muted);
  line-height: 1.4;
}

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

.package-note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 10px;
  color: var(--muted);
  line-height: 1.45;
}

.package-note strong {
  color: var(--text);
  min-width: max-content;
}

.package-workspace {
  display: grid;
  gap: 12px;
}

.package-overview {
  border-color: #b8d8d0;
}

.package-progress {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 9px 11px;
  margin-bottom: 10px;
}

.package-progress strong {
  font-size: 20px;
  color: var(--primary);
}

.package-file-card {
  display: grid;
  gap: 10px;
}

.task-process-workspace {
  display: grid;
  gap: 12px;
}

.task-process-summary {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.task-process-summary h3 {
  margin: 0 0 6px;
}

.task-process-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}

.task-process-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.task-step-list {
  display: grid;
  gap: 8px;
  position: sticky;
  top: 12px;
}

.task-step-item {
  width: 100%;
  min-height: 64px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 10px;
}

.task-step-item.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(16, 119, 101, 0.12);
}

.task-step-item.done {
  background: #f6fbf9;
}

.task-step-item.needs-template:not(.done) {
  background: #fffaf0;
}

.task-step-number {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #eef4f2;
  color: var(--primary);
  font-weight: 800;
}

.task-step-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.task-step-main strong,
.task-step-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-step-main small {
  color: var(--muted);
}

.task-step-panel {
  display: grid;
  gap: 14px;
  min-height: 520px;
}

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

.task-step-head h3 {
  margin: 4px 0 6px;
  font-size: 24px;
}

.task-step-eyebrow {
  color: var(--primary);
  font-weight: 800;
  font-size: 13px;
}

.task-step-purpose {
  margin: 0;
  font-weight: 700;
  line-height: 1.55;
}

.task-source-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
}

.task-source-box.ok {
  border-color: #b7d6ce;
  background: #f4faf8;
}

.task-source-box.warn {
  border-color: #e5c46d;
  background: #fffaf0;
}

.task-source-box > div:first-child {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.task-source-box span,
.task-source-box small {
  color: var(--muted);
  word-break: break-word;
}

.task-template-picker {
  grid-column: 1 / -1;
}

.task-template-picker summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 800;
}

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

.task-file-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.task-file-row span {
  color: var(--muted);
}

.task-file-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-action-row {
  align-items: center;
}

.package-file-hint {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  color: var(--muted);
  padding: 8px 10px;
  line-height: 1.45;
}

.template-state {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fbfcfd;
}

.template-state.ok {
  border-color: #b7d6ce;
  background: #f4faf8;
}

.template-state.warn {
  border-color: #e5c46d;
  background: #fffaf0;
}

.template-state p {
  margin: 4px 0;
  color: var(--muted);
}

.template-state small {
  color: var(--muted);
}

.template-candidates {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}

.template-candidate {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 10px;
}

.template-candidate p {
  margin: 4px 0;
  color: var(--muted);
}

.template-candidate small {
  color: var(--muted);
  word-break: break-word;
}

.structured-editor {
  display: grid;
  gap: 10px;
}

.structured-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fff;
}

.structured-form h4 {
  grid-column: 1 / -1;
  margin: 4px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--text);
  font-size: 14px;
}

.structured-form h4:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.structured-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 600;
}

.structured-form label.wide {
  grid-column: 1 / -1;
}

.structured-form textarea {
  min-height: 92px;
  line-height: 1.5;
}

.rules-panel {
  border-color: #c8d5e1;
}

.form-grid.compact textarea {
  min-height: 72px;
}

.package-template-results {
  display: grid;
  gap: 8px;
}

.agent-return-preview {
  margin-top: 10px;
}

.agent-return-preview pre {
  max-height: 240px;
  overflow: auto;
  background: #fff;
  border: 1px solid #d8e1eb;
  border-radius: var(--radius);
  padding: 10px;
  color: #293645;
}

.file-status-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.editor-label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 600;
}

.online-document-editor {
  color: #111827;
  background: #fff;
  border: 1px solid #d8dee7;
  border-radius: 8px;
  padding: 18px;
}

.online-document-head {
  border: 2px solid #111827;
  padding: 14px 16px;
  margin-bottom: 14px;
  text-align: center;
}

.online-document-head h4 {
  margin: 0 0 8px;
  font-size: 22px;
  color: #111827;
}

.online-document-head p {
  margin: 0;
  color: #4b5563;
  font-weight: 500;
}

.online-document-table {
  border: 1px solid #9ca3af;
  border-bottom: 0;
  margin-bottom: 18px;
}

.online-document-row {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  min-height: 360px;
}

.online-document-th {
  border-right: 1px solid #9ca3af;
  border-bottom: 1px solid #9ca3af;
  background: #f3f4f6;
  padding: 9px 10px;
  color: #111827;
  font-weight: 700;
}

.package-editor {
  width: 100%;
  min-height: 360px;
  border: 0;
  border-bottom: 1px solid #9ca3af;
  border-radius: 0;
  background: #fff;
  color: #111827;
  padding: 9px 10px;
  line-height: 1.58;
  font-family: inherit;
  resize: vertical;
}

.package-editor:focus {
  outline: 2px solid rgba(16, 119, 101, 0.2);
  outline-offset: -2px;
}

.package-rich-editor {
  width: 100%;
  min-height: 720px;
  overflow: auto;
  border: 1px solid #9ca3af;
  border-radius: 6px;
  background: #fff;
  color: #111827;
  padding: 30px;
  line-height: 1.6;
  font-weight: 400;
}

.table-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  width: 100%;
  margin: 8px 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafb;
}

.table-editor-tool-group {
  display: flex;
  gap: 4px;
  align-items: center;
  padding-right: 10px;
  border-right: 1px solid var(--line);
}

.table-editor-tool-group:last-child {
  padding-right: 0;
  border-right: 0;
}

.table-editor-toolbar button {
  min-height: 32px;
  padding: 5px 9px;
  border-radius: 4px;
  white-space: nowrap;
}

.table-history-tools {
  flex-wrap: nowrap;
}

.table-history-button {
  flex: 0 0 32px;
  font-size: 20px;
  line-height: 1;
}

.table-multi-select-button.active,
.table-multi-select-button[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.table-selection-count {
  min-width: 82px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  white-space: nowrap;
}

.table-editor-tool-group.compact button {
  min-width: 32px;
  padding-inline: 7px;
}

.package-rich-editor:focus {
  outline: 2px solid rgba(16, 119, 101, 0.24);
  outline-offset: 2px;
}

.package-rich-editor h1,
.package-rich-editor h2,
.package-rich-editor h3,
.package-rich-editor h4 {
  color: #111827;
  text-align: center;
  letter-spacing: 0;
}

.package-rich-editor table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}

.package-rich-editor th,
.package-rich-editor td {
  border: 1px solid #4b5563;
  padding: 8px 10px;
  vertical-align: top;
  white-space: pre-wrap;
}

.package-rich-editor th {
  background: #f3f4f6;
  text-align: left;
}

.package-rich-editor td[contenteditable="true"],
.package-rich-editor p[contenteditable="true"],
.package-rich-editor li[contenteditable="true"],
.package-rich-editor .line[contenteditable="true"] {
  cursor: text;
}

.package-rich-editor td[contenteditable="true"] {
  min-width: 120px;
  min-height: 36px;
  background: #fffef7;
}

.package-rich-editor td[contenteditable="true"]:focus,
.package-rich-editor p[contenteditable="true"]:focus,
.package-rich-editor li[contenteditable="true"]:focus,
.package-rich-editor .line[contenteditable="true"]:focus {
  outline: 2px solid rgba(16, 119, 101, 0.38);
  outline-offset: -2px;
  background: #fff;
}

.package-rich-editor .template-cell-selected,
.flow-template-edit-frame .template-cell-selected {
  background: #edf8f4;
  box-shadow: inset 0 0 0 2px rgba(16, 119, 101, 0.42);
}

.package-rich-editor .template-cell-active,
.flow-template-edit-frame .template-cell-active {
  background: #e1f3ec;
  box-shadow: inset 0 0 0 3px rgba(16, 119, 101, 0.78);
}

.package-rich-editor p,
.package-rich-editor pre {
  white-space: pre-wrap;
  word-break: break-word;
}

.package-rich-editor pre {
  font-family: inherit;
}

.office-template-layout {
  width: max-content;
  min-width: 100%;
  margin: 0 auto;
}

.package-rich-editor .office-template-layout table,
.flow-template-edit-frame .office-template-layout table {
  width: auto;
  max-width: none;
  margin-left: auto;
  margin-right: auto;
}

.package-rich-editor .office-template-layout th,
.package-rich-editor .office-template-layout td,
.flow-template-edit-frame .office-template-layout th,
.flow-template-edit-frame .office-template-layout td {
  min-width: 0;
  white-space: normal;
}

.online-document-sign {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-top: 42px;
}

.online-document-sign div {
  border-top: 1px solid #111827;
  padding-top: 8px;
  min-height: 36px;
  color: #111827;
  font-weight: 500;
}

.package-file-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.upload-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 5px 10px;
  background: #fff;
  cursor: pointer;
}

.upload-inline input {
  display: none;
}

.upload-format-hint {
  color: var(--muted);
  font-size: 12px;
}

.package-upload-status {
  margin-top: 10px;
  border-left: 3px solid var(--primary);
  background: var(--surface-subtle);
  padding: 8px 10px;
  color: var(--text);
}

.package-upload-status.error {
  border-left-color: #c9372c;
  background: #fff5f4;
  color: #a12820;
}

.notice.slim {
  margin-bottom: 0;
  padding: 8px 10px;
}

.compact-task-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.compact-task-actions button {
  min-height: 28px;
  padding: 3px 8px;
}

.confirm-row {
  margin-bottom: 0;
}

.debug-details {
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 10px 12px;
}

.debug-details summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
}

.debug-details .ai-output {
  margin-top: 10px;
}

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

.admin-card {
  min-height: 132px;
  text-align: left;
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 14px;
  background: var(--surface);
  border-color: var(--line);
  min-width: 0;
  max-width: 100%;
}

.admin-card strong {
  font-size: 16px;
}

.admin-card span {
  color: var(--primary);
  font-weight: 700;
}

.admin-card small {
  color: var(--muted);
  line-height: 1.45;
}

.admin-card:hover {
  border-color: var(--primary);
  background: #f4faf8;
}

.master-flow-agent,
.agent-native-result,
.agent-native-empty {
  width: min(980px, 100%);
}

.flow-agent-layout {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.flow-agent-layout .master-flow-agent,
.flow-agent-layout .agent-native-result,
.flow-agent-layout .agent-native-empty {
  width: 100%;
}

.flow-workspace-pane {
  min-width: 0;
}

.master-flow-agent {
  position: sticky;
  top: 16px;
  border-color: #b7d6ce;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbfa 100%);
}

.master-flow-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.master-flow-head h3 {
  margin-bottom: 5px;
  font-size: 18px;
}

.master-flow-head p {
  margin: 0;
}

.master-flow-metrics {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.master-flow-metrics span {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #b7d6ce;
  border-radius: 999px;
  padding: 2px 9px;
  color: var(--primary);
  background: #fff;
  font-size: 12px;
  font-weight: 700;
}

.master-flow-input {
  min-height: 92px;
  font-size: 15px;
  line-height: 1.55;
  margin-bottom: 10px;
}

.agent-native-empty {
  margin-top: 14px;
}

.agent-native-empty p {
  margin: 6px 0 0;
}

.agent-native-result {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.agent-loading {
  border-color: #b7d6ce;
  background: #f8fbfa;
}

.bailian-skill-panel {
  display: grid;
  gap: 12px;
}

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

.agent-config-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fafc;
}

.agent-config-summary span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.agent-config-summary strong {
  display: block;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.config-preview {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #0f172a;
  color: #e5e7eb;
  font-size: 12px;
  line-height: 1.55;
}

.agent-message {
  border-left: 3px solid var(--primary);
  padding-left: 12px;
}

.agent-message strong {
  display: block;
  margin-bottom: 5px;
}

.agent-message p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.agent-message.success {
  border-left-color: var(--ok);
}

.intent-card,
.change-target {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 12px;
}

.intent-card strong,
.change-target strong {
  display: block;
  font-size: 15px;
  margin-bottom: 5px;
}

.intent-card p,
.change-target p {
  margin: 0 0 8px;
}

.intent-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.native-flow-details {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 10px 12px;
}

.native-flow-current {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 12px;
}

.native-flow-current strong {
  display: block;
  margin-bottom: 8px;
}

.flow-overview {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 12px;
}

.flow-overview-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.flow-overview-head strong {
  display: block;
  font-size: 15px;
  margin-bottom: 5px;
}

.flow-overview-head p {
  margin: 0;
  line-height: 1.55;
}

.flow-overview-tags,
.flow-node-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.flow-overview-tags {
  justify-content: flex-end;
}

.flow-overview-tags span,
.flow-node-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfcfd;
  color: var(--muted);
  font-size: 12px;
  padding: 3px 8px;
}

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

.flow-meta-grid > div {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 10px;
}

.flow-meta-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.flow-meta-grid strong {
  display: block;
  font-size: 13px;
  line-height: 1.45;
}

.flow-node-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.flow-node-head > div {
  display: grid;
  gap: 4px;
}

.flow-node-head button {
  white-space: nowrap;
}

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

.flow-node-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 10px;
}

.flow-node-card.selected {
  border-color: var(--primary);
  background: #f5f8ff;
}

.flow-node-index {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}

.flow-node-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 5px;
}

.flow-node-title strong {
  font-size: 14px;
}

.flow-node-main p {
  margin: 0 0 8px;
  color: var(--muted);
  line-height: 1.5;
}

.flow-node-condition {
  color: #7a5a1b !important;
}

.flow-node-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 132px;
}

.flow-node-actions button {
  white-space: nowrap;
}

.flow-node-actions .selected-action {
  border-color: var(--primary);
  color: var(--primary);
  background: #eef4ff;
  font-weight: 700;
}

button.danger.subtle {
  border-color: #f2c7c7;
  color: #a73535;
  background: #fff8f8;
}

button.danger.subtle.selected-action {
  border-color: #c84545;
  color: #9f2a2a;
  background: #fff0f0;
}

button.danger-primary {
  background: #b83232;
  border-color: #b83232;
  color: #fff;
}

.change-save-note {
  border: 1px solid #cfe0ff;
  border-radius: 6px;
  background: #f5f8ff;
  padding: 10px 12px;
}

.change-save-note strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.change-save-note p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.selected-target {
  border-color: var(--primary);
  background: #f5f8ff;
}

.flow-action-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 14px;
}

.flow-work-context {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 14px;
}

.flow-work-context > strong {
  font-size: 14px;
}

.flow-work-context p {
  margin: 0;
  line-height: 1.55;
}

.flow-action-panel .section-title {
  align-items: flex-start;
  margin-bottom: 0;
}

.flow-action-panel h3 {
  margin: 0 0 5px;
  font-size: 16px;
}

.flow-action-panel .muted {
  margin: 3px 0 0;
}

.flow-action-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.flow-action-panel input,
.flow-action-panel select,
.flow-action-panel textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.flow-action-panel textarea {
  min-height: 82px;
  resize: vertical;
}

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

.flow-editor-grid .wide,
.flow-action-panel .wide {
  grid-column: 1 / -1;
}

.flow-agent-dialogue {
  display: grid;
  gap: 12px;
}

.flow-chat-messages {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  padding: 2px;
}

.flow-chat-message {
  width: min(86%, 760px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
}

.flow-chat-message.user {
  justify-self: end;
  border-color: #b8d6ff;
  background: #f4f9ff;
}

.flow-chat-message.progress {
  border-color: #d7e3f5;
  background: #f7f9fc;
}

.flow-chat-message.error {
  border-color: #efb8b8;
  background: #fff8f8;
}

.flow-chat-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.flow-chat-meta strong {
  color: var(--text);
  font-size: 12px;
}

.flow-chat-message p {
  margin: 0;
  line-height: 1.55;
  white-space: pre-wrap;
}

.flow-template-editor {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.flow-template-preview {
  width: 100%;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.flow-template-candidates {
  display: grid;
  gap: 8px;
}

.flow-template-textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  font: inherit;
  line-height: 1.55;
}

.flow-chat-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.flow-chat-input-row button {
  min-width: 112px;
}

.agent-bubble {
  border: 1px solid #cfe0ff;
  border-radius: 8px;
  background: #f5f8ff;
  padding: 12px;
}

.agent-bubble strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}

.agent-bubble p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.node-context-mini {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  gap: 6px 10px;
  margin-top: 10px;
  border-top: 1px solid #d9e6ff;
  padding-top: 10px;
}

.node-context-mini span {
  color: var(--muted);
  font-size: 12px;
}

.node-context-mini b {
  font-weight: 600;
  line-height: 1.45;
}

.prompt-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.prompt-chip-row button {
  height: auto;
  min-height: 30px;
  border-color: #cfe0ff;
  background: #fff;
  color: var(--accent);
  text-align: left;
}

.delete-node-preview,
.delete-proposal {
  border: 1px solid #efb8b8;
  border-radius: 6px;
  background: #fff8f8;
  padding: 14px;
}

.delete-node-preview strong {
  display: block;
  margin-bottom: 10px;
  color: #8f2424;
}

.delete-node-fields {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 8px 12px;
  align-items: start;
}

.delete-node-fields span {
  color: var(--muted);
  font-size: 12px;
}

.delete-node-fields b {
  color: var(--text);
  font-weight: 600;
  line-height: 1.45;
}

.native-flow-details summary {
  cursor: pointer;
  font-weight: 600;
}

.native-doc-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.native-doc-list span,
.alt-flow {
  border: 1px solid var(--line);
  background: #fbfcfd;
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--muted);
  font-size: 12px;
}

.alt-flow {
  width: auto;
  margin: 8px 8px 0 0;
  border-radius: 6px;
  color: var(--text);
}

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

.change-compare div {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 12px;
}

.change-compare span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.change-compare strong {
  font-size: 18px;
}

.agent-check-list {
  display: grid;
  gap: 8px;
  border: 1px solid #d9e6ff;
  border-radius: 6px;
  background: #f8fbff;
  padding: 12px;
}

.agent-check-list > strong {
  font-size: 13px;
}

.agent-source-note {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.agent-check-list > div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 8px;
  align-items: center;
}

.agent-check-list p {
  grid-column: 2;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.editable-proposal,
.delete-proposal {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 14px;
}

.delete-proposal {
  border-color: #efb8b8;
  background: #fff8f8;
}

.flow-studio-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.agent-roster {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 8px;
}

.agent-roster-item {
  width: 100%;
  min-height: 96px;
  display: grid;
  gap: 6px;
  align-content: start;
  text-align: left;
  border-color: var(--line);
  background: var(--surface);
  padding: 12px;
}

.agent-roster-item strong,
.agent-roster-item span,
.agent-roster-item small {
  min-width: 0;
}

.agent-roster-item strong {
  font-size: 15px;
}

.agent-roster-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.agent-roster-item small {
  color: var(--primary);
  font-weight: 700;
}

.agent-roster-item.active,
.agent-roster-item:hover {
  border-color: #9cc8bd;
  background: var(--primary-soft);
}

.flow-workbench {
  display: grid;
  gap: 14px;
}

.agent-workbench-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-color: #bdd6d0;
}

.agent-workbench-head h3 {
  font-size: 18px;
  margin-bottom: 5px;
}

.agent-workbench-head p {
  margin: 0;
  line-height: 1.45;
}

.flow-head-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.flow-agent-console textarea {
  min-height: 82px;
  margin-bottom: 10px;
}

.flow-suggestion-box {
  border: 1px solid #b7d6ce;
  border-radius: 6px;
  background: #f8fbfa;
  padding: 12px;
  display: grid;
  gap: 10px;
}

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

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

.flow-suggestion-candidate {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 11px;
}

.flow-suggestion-candidate strong {
  display: block;
  margin-bottom: 5px;
}

.flow-suggestion-candidate p {
  margin: 0 0 6px;
  color: var(--muted);
  line-height: 1.45;
}

.flow-suggestion-candidate small {
  color: var(--muted);
}

.flow-card-grid {
  display: grid;
  gap: 10px;
}

.flow-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 12px;
}

.flow-card.archived {
  background: #fbfcfd;
  opacity: .78;
}

.flow-card-title {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 5px;
}

.flow-card-title strong {
  font-size: 15px;
}

.flow-card-main p {
  margin: 0 0 8px;
  color: var(--muted);
  line-height: 1.45;
}

.flow-card-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.flow-card-tags span,
.template-note {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
  background: #fbfcfd;
  font-size: 12px;
}

.flow-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.flow-editor-panel {
  border-color: #b7c9dc;
}

.flow-editor-panel textarea {
  min-height: 78px;
}

.flow-doc-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 12px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.flow-doc-editor-head h3 {
  margin-bottom: 4px;
}

.flow-doc-editor-head p {
  margin: 0;
}

.flow-doc-editor-list {
  display: grid;
  gap: 10px;
}

.flow-doc-editor-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 12px;
}

.flow-doc-editor-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.flow-doc-editor-top strong {
  font-size: 14px;
}

.template-note {
  width: 100%;
  justify-content: flex-start;
  border-radius: 6px;
  margin-top: 10px;
}

.flow-summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.flow-summary-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.flow-summary-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 12px;
}

.flow-summary-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.flow-summary-item strong {
  font-size: 22px;
  color: var(--text);
}

.flow-library-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.flow-library-nav {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 12px;
}

.flow-agent-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px;
}

.flow-agent-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 2px 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}

.flow-agent-head span {
  color: var(--muted);
  font-size: 12px;
}

.flow-nav-item {
  width: 100%;
  min-height: 58px;
  display: grid;
  gap: 4px;
  text-align: left;
  align-content: center;
  border-color: transparent;
  background: transparent;
  padding: 8px;
}

.flow-nav-item strong,
.flow-nav-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flow-nav-item span {
  color: var(--muted);
  font-size: 12px;
}

.flow-nav-item.active,
.flow-nav-item:hover {
  border-color: #b7d6ce;
  background: var(--primary-soft);
}

.flow-detail-panel {
  min-height: 520px;
}

.flow-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.flow-detail-head h3 {
  margin: 0 0 6px;
  font-size: 20px;
}

.flow-detail-head p {
  margin: 0;
  line-height: 1.45;
}

.flow-detail-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.flow-detail-metrics div,
.flow-meta-block > div,
.flow-question-block {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 10px;
}

.flow-detail-metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.flow-detail-metrics strong {
  font-size: 20px;
}

.flow-meta-block {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.flow-meta-block strong,
.flow-question-block strong {
  display: block;
  margin-bottom: 6px;
}

.flow-meta-block p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.flow-question-block {
  margin-bottom: 14px;
}

.flow-question-block ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.55;
}

.flow-doc-section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

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

.flow-doc-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, .35fr);
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 11px;
}

.flow-doc-title {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 5px;
}

.flow-doc-main p {
  margin: 0 0 5px;
  color: var(--muted);
  line-height: 1.45;
}

.flow-doc-main small,
.flow-template-cell small {
  display: block;
  color: var(--muted);
  line-height: 1.4;
}

.flow-template-cell {
  display: grid;
  gap: 5px;
}

.flow-template-cell strong {
  color: var(--text);
}

.collapsible-admin-block summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}

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

.draft-meta {
  border: 1px solid var(--line);
  background: #fbfcfd;
  border-radius: 6px;
  padding: 12px;
}

.draft-meta h4 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
}

.draft-meta p {
  margin: 0 0 6px;
}

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

.file-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px;
}

.file-result p {
  margin: 4px 0;
}

.file-result small {
  color: var(--muted);
  word-break: break-word;
}

.file-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.module-tabs button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.notice {
  border: 1px solid #b7d6ce;
  background: #edf8f5;
  color: #174a42;
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}

.error {
  border: 1px solid #f3b5af;
  background: #fff0ef;
  color: var(--danger);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 14px;
}

.ai-output {
  background: #f7fafc;
  color: #243241;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 104px;
}

.print-link {
  color: var(--primary);
  text-decoration: none;
}

.text-command {
  min-height: 0;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  text-decoration: none;
}

.text-command:hover,
.text-command:focus-visible {
  background: transparent;
  color: var(--primary-strong);
  text-decoration: underline;
}

.flow-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
}

.flow-list p {
  margin: 0 0 10px;
}

.flow-steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.flow-steps li {
  counter-increment: step;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px 10px 42px;
  position: relative;
  background: #fbfcfd;
}

.flow-steps li::before {
  content: counter(step);
  position: absolute;
  left: 12px;
  top: 10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}

.app-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 32, 42, .42);
}

.app-dialog {
  width: min(520px, 100%);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 20px 48px rgba(16, 24, 40, .18);
  padding: 18px;
}

.app-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.app-dialog h3 {
  margin: 0;
  font-size: 18px;
}

.app-dialog p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.6;
}

.app-dialog label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.app-dialog textarea {
  min-height: 92px;
  color: var(--text);
}

.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.app-toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1200;
  display: grid;
  gap: 8px;
  width: min(380px, calc(100vw - 40px));
}

.app-toast {
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--primary);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(16, 24, 40, .16);
  padding: 12px 14px;
  color: var(--text);
  line-height: 1.5;
}

.app-toast.success {
  border-left-color: #18794e;
}

.app-toast.error {
  border-left-color: #c9372c;
}

.icon-button {
  width: 32px;
  min-height: 32px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 18px;
}

.flow-manager-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.flow-manager-sidebar {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 18px;
}

.flow-manager-sidebar-head,
.flow-editor-head,
.flow-node-toolbar,
.flow-node-editor-head,
.flow-template-row,
.flow-check-issue {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.flow-sidebar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.flow-module-create {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.flow-module-create label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.flow-module-create-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.hidden-file-input {
  display: none;
}

.flow-template-inline-editor {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.flow-template-inline-editor.compact {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.flow-template-inline-head {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
}

.flow-template-edit-frame {
  width: 100%;
  min-height: 760px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 32px;
  overflow: auto;
  color: #111827;
  cursor: text;
}

.flow-template-edit-frame .template-label-input {
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  line-height: inherit;
}

.flow-template-edit-frame .template-label-input:focus {
  outline: 2px solid #157a6e;
  outline-offset: 2px;
}

.flow-template-edit-frame:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.flow-template-edit-frame .doc-head {
  border: 2px solid #111827;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.flow-template-edit-frame h1 {
  font-size: 22px;
  text-align: center;
  margin: 0 0 8px;
}

.flow-template-edit-frame .sub {
  text-align: center;
  color: #4b5563;
}

.flow-template-edit-frame table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

.flow-template-edit-frame th,
.flow-template-edit-frame td {
  border: 1px solid #9ca3af;
  padding: 9px 10px;
  vertical-align: top;
}

.flow-template-edit-frame th {
  width: 190px;
  text-align: left;
  background: #f3f4f6;
}

.flow-template-edit-frame pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  font-family: inherit;
}

.flow-template-edit-frame .section-row td {
  background: #e5e7eb;
  font-weight: 700;
}

.flow-template-edit-frame .sign {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-top: 42px;
}

.flow-template-edit-frame .line {
  border-top: 1px solid #111827;
  padding-top: 8px;
  min-height: 36px;
}

.flow-template-edit-frame .footer {
  margin-top: 18px;
  color: #6b7280;
  font-size: 12px;
}

@media (max-width: 860px) {
  .table-editor-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .table-editor-tool-group {
    flex: 0 0 auto;
  }
}

.section-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-heading-row h3,
.section-heading-row p {
  margin-top: 0;
}

.user-management-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.8fr);
  align-items: start;
}

.table-scroll {
  min-width: 0;
  overflow-x: auto;
}

.table-scroll > .data-table {
  min-width: 720px;
}

.table-scroll > .document-table {
  min-width: 1320px;
}

.document-status-select {
  min-width: 96px;
  padding: 6px 8px;
}

.table-scroll > .task-list-table {
  min-width: 900px;
}

.audit-filter-panel {
  margin-bottom: 14px;
}

.audit-toolbar input {
  flex: 1 1 320px;
  min-width: 220px;
}

.audit-table {
  min-width: 980px;
}

.audit-table th:nth-child(1),
.audit-table td:nth-child(1) {
  width: 70px;
}

.audit-table th:nth-child(2),
.audit-table td:nth-child(2) {
  width: 170px;
}

.audit-table th:nth-child(3),
.audit-table td:nth-child(3) {
  width: 120px;
}

.audit-table th:nth-child(4),
.audit-table td:nth-child(4) {
  width: 180px;
}

.audit-code {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.audit-detail > span {
  display: block;
  max-width: 560px;
  overflow-wrap: anywhere;
}

.audit-raw {
  margin-top: 6px;
}

.audit-raw summary {
  color: var(--primary);
  cursor: pointer;
  font-size: 12px;
}

.audit-raw pre {
  max-width: 560px;
  max-height: 240px;
  margin: 8px 0 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
}

.audit-pagination {
  justify-content: flex-end;
  margin-top: 14px;
}

.user-editor {
  min-width: 0;
  border-left: 1px solid var(--line);
  padding-left: 20px;
}

.user-editor h4 {
  margin: 0 0 14px;
}

.user-role-picker {
  display: grid;
  gap: 10px;
}

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

.checkbox-grid label,
.checkbox-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.checkbox-grid input,
.checkbox-line input {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  margin-top: 2px;
}

.flow-module-list {
  display: grid;
  gap: 6px;
}

.flow-module-active-actions {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
}

.flow-module-active-actions span {
  font-weight: 700;
}

.flow-module-active-actions small {
  color: var(--muted);
  line-height: 1.4;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 0 4px;
  color: var(--muted);
}

.segmented-control {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.segmented-control button {
  min-height: 34px;
  border: 0;
  background: transparent;
}

.segmented-control button.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 2px rgb(15 23 42 / 10%);
}

.flow-module-list button,
.flow-list-card {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.flow-module-list button.active,
.flow-list-card.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.flow-module-list small,
.flow-list-card span {
  color: var(--muted);
}

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

.flow-list-card {
  display: grid;
  justify-content: stretch;
  min-height: 64px;
}

.flow-list-card strong,
.flow-list-card span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flow-manager-main {
  min-height: 520px;
}

.flow-editor,
.flow-editor-empty {
  display: grid;
  gap: 18px;
}

.flow-editor h3,
.flow-editor-empty h3 {
  margin: 0;
  font-size: 20px;
}

.flow-editor-actions,
.flow-node-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.flow-form-grid label,
.flow-node-fields label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.flow-form-grid label.wide,
.flow-node-fields label.wide {
  grid-column: 1 / -1;
}

.flow-form-grid textarea {
  min-height: 76px;
}

.flow-node-editor-list {
  display: grid;
  gap: 14px;
}

.flow-node-editor {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.flow-node-number {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 700;
  flex: 0 0 auto;
}

.flow-node-name {
  min-width: 220px;
  flex: 1 1 320px;
  font-weight: 700;
}

.flow-node-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.flow-template-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fafbfc;
  padding: 12px;
}

.flow-template-row p {
  margin: 4px 0 0;
}

.flow-template-binding-list {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.flow-template-binding-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 2px;
}

.flow-template-binding-row + .flow-template-binding-row {
  border-top: 1px solid var(--line);
}

.flow-template-binding-index {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.flow-template-binding-info {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.flow-template-binding-info strong,
.flow-template-binding-info span {
  overflow-wrap: anywhere;
}

.flow-template-binding-info span {
  color: var(--muted);
  font-size: 13px;
}

.flow-template-candidates {
  display: grid;
  gap: 8px;
}

.flow-template-candidates button {
  min-height: 56px;
  display: grid;
  gap: 4px;
  text-align: left;
  justify-content: stretch;
}

.flow-template-candidates span {
  color: var(--muted);
}

.flow-check-result {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.flow-check-result.ok {
  border-color: #a8d6c4;
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.flow-check-result.warn {
  border-color: #e4c36c;
  background: #fff9ec;
  color: var(--warning);
}

.flow-check-issue {
  color: var(--text);
}

@media (max-width: 1200px) {
  .dashboard-kpi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-kpi:nth-child(2) {
    border-right: 0;
  }

  .dashboard-kpi:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

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

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

  .sidebar {
    position: static;
    height: auto;
    background: var(--surface);
    color: var(--text);
    border-bottom: 1px solid var(--line);
    padding: 12px;
    gap: 10px;
    width: 100%;
    max-width: 100vw;
  }

  .brand h1 {
    font-size: 15px;
    margin-bottom: 3px;
  }

  .brand small {
    color: var(--muted);
  }

  .nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    width: 100%;
    max-width: 100%;
  }

  .nav button {
    width: auto;
    min-width: max-content;
    color: var(--text);
    background: #f7fafc;
    border-color: var(--line);
    min-height: 36px;
    flex: 0 0 auto;
  }

  .nav button.active,
  .nav button:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
  }

  .user-box {
    margin-top: 0;
    border-top: 0;
    padding-top: 0;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .user-box > * {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .user-box button {
    margin-top: 0;
    width: auto;
  }

  .grid.two,
  .grid.four,
  .dashboard-layout,
  .master-agent-dashboard,
  .draft-meta-grid,
  .admin-grid,
  .workflow-strip,
  .package-summary-grid,
  .structured-form,
  .flow-agent-layout,
  .flow-manager-layout,
  .master-flow-head,
  .intent-card,
  .change-target,
  .change-compare,
  .flow-overview-head,
  .flow-meta-grid,
  .flow-node-card,
  .flow-summary-grid,
  .flow-studio-layout,
  .flow-library-layout,
  .flow-detail-metrics,
  .flow-meta-block,
  .flow-doc-item,
  .flow-card,
  .flow-suggestion-candidate,
  .flow-chat-input-row,
  .task-process-layout,
  .task-process-summary,
  .task-source-box,
  .online-document-row,
  .online-document-sign,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-detail-filter {
    display: grid;
    justify-content: stretch;
  }

  .dashboard-module-filter {
    justify-content: flex-start;
  }

  .flow-manager-sidebar {
    position: static;
  }

  .flow-form-grid,
  .flow-node-fields {
    grid-template-columns: 1fr;
  }

  .flow-editor-head,
  .flow-node-toolbar,
  .flow-node-editor-head,
  .flow-template-row {
    display: grid;
    justify-content: stretch;
  }

  .flow-node-name {
    min-width: 0;
  }

  .flow-template-binding-row {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .flow-template-binding-row .toolbar {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .flow-chat-message {
    width: 100%;
  }

  .task-panel {
    position: static;
  }

  .task-process-summary {
    display: grid;
  }

  .task-process-meta {
    justify-content: flex-start;
  }

  .task-step-list {
    position: static;
  }

  .task-step-head {
    display: grid;
  }

  .task-file-row {
    grid-template-columns: 1fr;
  }

  .preset-grid {
    grid-template-columns: 1fr;
  }

  .compact-preset-list {
    grid-template-columns: 1fr;
  }

  .file-result {
    grid-template-columns: 1fr;
  }

  .template-state {
    grid-template-columns: 1fr;
  }

  .template-candidate {
    grid-template-columns: 1fr;
  }

  .flow-library-nav {
    position: static;
  }

  .agent-roster {
    position: static;
    grid-template-columns: 1fr;
  }

  .master-flow-agent {
    position: static;
  }

  .master-chat-panel {
    position: static;
    max-height: none;
  }

  .agent-workbench-head,
  .flow-doc-editor-head,
  .flow-card-actions {
    display: grid;
    justify-content: stretch;
  }

  .flow-head-actions,
  .flow-card-actions,
  .intent-actions,
  .master-flow-metrics {
    justify-content: flex-start;
  }

  .package-head {
    display: grid;
  }

  .package-doc {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .package-doc-actions {
    grid-column: 1 / -1;
  }

  .package-doc-actions button {
    width: 100%;
  }

  .main {
    padding: 14px;
    width: 100%;
    max-width: 100vw;
  }

  .topline {
    margin-bottom: 12px;
  }

  .topline h2 {
    font-size: 21px;
  }

  .section-title,
  .agent-heading {
    display: grid;
  }

  .toolbar > * {
    width: auto;
  }

  .toolbar input,
  .toolbar select {
    flex: 1 1 180px;
  }

  .quick-command-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-command-row > * {
    width: 100%;
  }

  .quick-command-row .primary {
    grid-column: 1 / -1;
  }

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

  .agent-config-summary {
    grid-template-columns: 1fr;
  }

  .user-management-grid,
  .checkbox-grid {
    grid-template-columns: 1fr;
  }

  .user-editor {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 18px 0 0;
  }

  .section-heading-row {
    display: grid;
  }

  .stat-pill {
    justify-content: space-between;
  }
}

@media (max-width: 680px) {
  .dashboard-refresh {
    display: grid;
    justify-items: end;
  }

  .dashboard-kpi {
    min-height: 126px;
    padding: 15px;
  }

  .dashboard-kpi strong {
    font-size: 34px;
  }

  .dashboard-workflow-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .dashboard-workflow-row > div:not(.dashboard-workflow-name) {
    grid-column: 1 / -1;
  }

  .dashboard-workflow-row > button {
    grid-column: 2;
    grid-row: 1;
  }

  .dashboard-compact-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .dashboard-compact-row > button {
    grid-column: 2;
  }

  .dashboard-module-row {
    grid-template-columns: minmax(90px, 1fr) 52px;
  }

  .dashboard-module-track {
    grid-column: 1 / -1;
  }

  .dashboard-workflow-list,
  .dashboard-compact-list {
    max-height: none;
    overflow: visible;
  }
}
