:root {
  --bg: #f3f6f8;
  --panel: #ffffff;
  --panel-2: #eef3f7;
  --line: #dde3ea;
  --text: #172033;
  --muted: #667085;
  --accent: #0f766e;
  --accent-2: #0f766e;
  --blue: #2563eb;
  --amber: #b7791f;
  --ink: #101827;
  --danger: #b42318;
  --warn: #b7791f;
  --ok: #138a5b;
  --info: #2563eb;
  --shadow: 0 8px 18px rgba(18, 31, 54, 0.05);
}

* { box-sizing: border-box; }

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

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

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

  button:hover {
  border-color: #9aa7b8;
  background: #f9fafb;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

button.blue {
  border-color: var(--accent-2);
  background: var(--accent-2);
  color: white;
}

button.ghost {
  background: transparent;
}

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

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--text);
  padding: 9px 10px;
  outline: none;
}

textarea {
  min-height: 168px;
  resize: vertical;
  line-height: 1.5;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .13);
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 252px 1fr;
}

.sidebar {
  background: #ffffff;
  color: var(--text);
  padding: 16px 12px;
  min-height: 100vh;
  border-right: 1px solid var(--line);
}

.brand {
  display: grid;
  gap: 8px;
  justify-items: center;
  text-align: center;
  padding: 8px 10px 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.brand-logo {
  width: 118px;
  height: auto;
  object-fit: contain;
}

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

.brand-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav button {
  width: 100%;
  justify-content: flex-start;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  background: transparent;
  color: #465366;
  text-align: left;
  padding: 0 10px;
  min-height: 38px;
}

.nav button.active {
  background: #dff5f1;
  color: #075e54;
  font-weight: 800;
}

.nav-badge {
  margin-left: auto;
  min-width: 52px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #fff0ed;
  color: #b42318;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  height: 66px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

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

.top-meta {
  color: var(--muted);
  display: flex;
  gap: 14px;
  align-items: center;
}

.content {
  padding: 20px 24px 32px;
  overflow: auto;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(172px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric, .panel, .table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 14px 14px 12px;
  min-height: 82px;
  border-top: 3px solid #d8e2f3;
}

.metric.warn {
  border-color: #fed7aa;
  border-top-color: #f59e0b;
  background: #fffaf3;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.metric-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
}

.metric-note {
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

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

.balance-item {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.balance-item.warn {
  border-color: #fed7aa;
  background: #fff7ed;
}

.balance-amount {
  font-weight: 800;
  white-space: nowrap;
}

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

.rule-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
  min-height: 112px;
}

.rule-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  margin-bottom: 8px;
}

.rule-num {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #dff5f1;
  color: #075e54;
  font-size: 12px;
  flex: 0 0 auto;
}

.rule-text {
  color: #465366;
  line-height: 1.5;
  font-size: 13px;
}

.deployment-panel {
  border-left: 4px solid #f59e0b;
}

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

.deployment-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.deployment-item.blocker {
  border-color: #ffc8bd;
  background: #fff7f5;
}

.deployment-item.warning {
  border-color: #fed7aa;
  background: #fffaf3;
}

.deployment-item.info {
  border-color: #c8dcff;
  background: #f7fbff;
}

.panel {
  padding: 16px;
  margin-bottom: 16px;
}

.workbench .panel {
  margin-bottom: 0;
}

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

.panel-title {
  font-size: 15px;
  font-weight: 800;
}

.panel-note {
  color: var(--muted);
  font-size: 12px;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(360px, .92fr) minmax(420px, 1.25fr);
  gap: 16px;
  align-items: start;
}

.workbench-stack {
  display: grid;
  gap: 12px;
}

.demand-input-panel {
  border-color: #9fd9cf;
  box-shadow: 0 0 0 2px rgba(15, 118, 110, .06);
}

.demand-textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.55;
  font-size: 14px;
}

.demand-input-panel #btnParse {
  min-width: 150px;
  min-height: 42px;
  font-weight: 800;
}

.recognition-empty {
  display: grid;
  gap: 6px;
  min-height: 120px;
  place-content: center;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  background: #f8fafc;
}

.recognition-empty strong {
  color: #334155;
}

.recognition-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.recognition-summary > div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  background: #f8fafc;
}

.recognition-summary span {
  color: var(--muted);
  font-size: 11px;
}

.recognition-summary strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recognition-summary .summary-missing {
  color: var(--danger);
  background: #fff7ed;
  border-color: #fed7aa;
}

.next-step-guide {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 12px;
  border-left: 4px solid #0f766e;
  background: #eefbf8;
  color: #135f57;
}

.next-step-guide strong {
  white-space: nowrap;
}

.review-decision {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.review-validation {
  margin-top: 0;
  font-weight: 700;
}

.review-validation.validation-pass {
  display: flex;
  align-items: center;
  gap: 8px;
  border-color: #86d2a4;
  background: #eaf9f0;
  color: #116437;
}

.review-validation.validation-pass::before {
  content: "✓";
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 50%;
  background: #168a4b;
  color: #fff;
  font-weight: 900;
}

.review-sheet-preview {
  padding: 14px;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: #1e293b;
  white-space: pre-wrap;
  line-height: 1.65;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}

.v2-sheet-preview {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid #c7d2fe;
  background: #f8fbff;
  color: #1e293b;
  border-radius: 8px;
}

.v2-preview-title {
  font-size: 15px;
  font-weight: 900;
  color: #1e40af;
}

.v2-note {
  color: #64748b;
  font-size: 13px;
  line-height: 1.5;
}

.v2-plan {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #fff;
}

.v2-plan.warn {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #8a4b08;
}

.v2-plan-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.v2-plan-head strong {
  color: #0f172a;
}

.v2-plan-head span {
  color: #1d4ed8;
  font-weight: 800;
}

.v2-grid {
  display: grid;
  grid-template-columns: minmax(96px, 140px) minmax(0, 1fr);
  gap: 8px 12px;
  align-items: center;
}

.v2-grid span {
  color: #64748b;
  font-size: 13px;
}

.v2-grid strong,
.v2-grid code {
  min-width: 0;
  overflow-wrap: anywhere;
}

.v2-grid code {
  padding: 3px 6px;
  border-radius: 6px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
}

.message-auto-section {
  display: grid;
  gap: 8px;
  padding-top: 4px;
}

.message-auto-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.message-auto-head strong {
  font-size: 15px;
}

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

.transfer-sop-alert,
.transfer-sop-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid #f2c66d;
  border-left: 4px solid #d97706;
  background: #fffaf0;
  color: #7c4707;
  line-height: 1.5;
}

.transfer-sop-alert strong,
.transfer-sop-card strong {
  flex: 0 0 auto;
  white-space: nowrap;
}

.transfer-sop-card {
  margin-bottom: 12px;
}

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

.quick-card {
  min-height: 70px;
  border: 1px solid var(--line);
  background: #fbfcfe;
  display: grid;
  align-content: center;
  gap: 3px;
  text-align: left;
  padding: 10px 12px;
  position: relative;
}

.quick-card.active {
  border-color: #0f766e;
  background: #e8f7f4;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .14);
}

.quick-card.active::after {
  content: "已选";
  position: absolute;
  right: 10px;
  top: 9px;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: #0f766e;
  color: white;
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 800;
}

.quick-card.ai-detected::after {
  content: "AI识别";
  background: #2563eb;
}

.quick-card strong {
  font-size: 14px;
}

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

.quick-card.primary-action {
  border-color: var(--line);
  background: #fbfcfe;
}

.quick-card.money-action {
  border-color: var(--line);
  background: #fbfcfe;
}

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

.utility-grid button {
  justify-content: flex-start;
  text-align: left;
  min-height: 40px;
}

.section-kicker {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
  font-weight: 700;
}

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

.field {
  display: grid;
  gap: 5px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
}

.field.missing label {
  color: #9a5b00;
  font-weight: 800;
}

.field.missing input,
.field.missing select,
.field.missing textarea,
.batch-table .missing-control {
  border-color: #f59e0b;
  background: #fffaf0;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .14);
}

.field.valid input,
.field.valid select {
  border-color: #86d2bd;
  background: #fbfffd;
}

.field-hint {
  display: none;
  color: #9a5b00;
  font-size: 12px;
  line-height: 1.35;
}

.field.missing .field-hint {
  display: block;
}

.row-issue {
  margin-top: 6px;
  color: #9a5b00;
  font-size: 12px;
  line-height: 1.35;
}

.batch-table tr.row-missing td {
  background: #fffaf0;
}

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

.inline-actions {
  margin-top: 0;
  justify-content: flex-end;
}

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin: 4px 0 14px;
  padding-bottom: 8px;
  flex-wrap: wrap;
}

.tabs button {
  min-height: 32px;
  padding: 0 10px;
  background: var(--panel-2);
  border-color: transparent;
}

.tabs button.active {
  background: #dff5f1;
  border-color: #8bd3c6;
  color: #075e54;
  font-weight: 700;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}

.status.draft { background: #eef2f7; color: #475569; border-color: #d9e0ea; }
.status.confirm { background: #e8f1ff; color: #1d4ed8; border-color: #c8dcff; }
.status.wait { background: #fff4df; color: #9a5b00; border-color: #ffd48a; }
.status.ok { background: #e5f7ec; color: var(--ok); border-color: #bce6cb; }
.status.bad { background: #fff0ed; color: var(--danger); border-color: #ffc8bd; }

.notice {
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 8px;
  padding: 10px 12px;
  color: #334155;
  line-height: 1.45;
  margin-top: 10px;
}

.notice.warn {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #8a4b08;
}

.notice.ok {
  background: #eefbf4;
  border-color: #bfebcf;
  color: #126337;
}

.notice.bad {
  background: #fff0ed;
  border-color: #ffc8bd;
  color: var(--danger);
}

.balance-risk {
  margin-top: 6px;
  font-weight: 900;
}

.required-mark {
  color: var(--danger);
  font-size: 11px;
  font-weight: 800;
}

.pending-account-list {
  display: grid;
  gap: 10px;
}

.pending-client-group {
  border: 1px solid #b7eadf;
  background: #f4fffc;
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.pending-client-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pending-client-head > div:first-child {
  display: grid;
  gap: 3px;
}

.pending-client-head span,
.pending-client-summary {
  color: var(--muted);
  font-size: 12px;
}

.pending-client-head strong {
  font-size: 18px;
  color: var(--ink);
}

.pending-client-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.pending-client-tip {
  padding: 8px 10px;
  border-radius: 6px;
  background: #e8f7f3;
  color: #0f766e;
  font-size: 13px;
  font-weight: 700;
}

.pending-account-card {
  border: 1px solid #f2c66d;
  background: #fffdf7;
  border-radius: 8px;
  padding: 14px;
}

.pending-card-head,
.pending-card-head > div,
.pending-context-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pending-card-head > div {
  justify-content: flex-start;
}

.pending-meta-grid,
.pending-context-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.pending-meta-grid > div,
.pending-context-grid > div {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
}

.pending-meta-grid span,
.pending-context-grid span,
.pending-raw > span,
.pending-context-raw > span {
  color: var(--muted);
  font-size: 11px;
}

.pending-raw,
.pending-context-raw {
  margin-top: 10px;
  padding: 10px;
  background: #f8fafc;
  border-left: 3px solid #94a3b8;
}

.pending-raw p,
.pending-context-raw p {
  margin: 4px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.pending-missing,
.pending-context-missing {
  margin-top: 10px;
  color: #8a4b08;
}

.pending-missing span {
  margin-left: 10px;
  color: #475569;
}

.pending-empty {
  display: grid;
  gap: 4px;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  text-align: center;
}

.pending-context {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid #f2c66d;
  background: #fffdf7;
  border-radius: 8px;
}

.account-modal {
  width: min(920px, 100%);
}

.pending-batch-section {
  display: grid;
  gap: 10px;
}

.pending-batch-section textarea {
  min-height: 150px;
  resize: vertical;
  line-height: 1.55;
}

.pending-batch-actions {
  margin-top: 0;
}

.pending-batch-table {
  width: 100%;
  min-width: 820px;
  table-layout: fixed;
}

.pending-batch-table th,
.pending-batch-table td {
  box-sizing: border-box;
  overflow: hidden;
  vertical-align: top;
}

.pending-batch-table th:nth-child(1),
.pending-batch-table td:nth-child(1) { width: 60px; }
.pending-batch-table th:nth-child(2),
.pending-batch-table td:nth-child(2) { width: 34%; }
.pending-batch-table th:nth-child(3),
.pending-batch-table td:nth-child(3) { width: 31%; }
.pending-batch-table th:nth-child(4),
.pending-batch-table td:nth-child(4) { width: 220px; }

.pending-batch-table input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pending-batch-table tr.needs-review td {
  background: #fffaf0;
}

.pending-batch-table tr.saved td {
  background: #f2fbf6;
}

.pending-batch-status {
  display: grid;
  gap: 5px;
  width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
}

.pending-batch-status .status {
  justify-self: start;
  max-width: 100%;
}

.pending-batch-status small {
  color: var(--muted);
  line-height: 1.35;
}

.pending-batch-confirm {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #8a4b08;
}

.pending-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.danger-action {
  color: var(--danger);
  border-color: #ffc8bd;
}

.danger-action:hover {
  background: #fff0ed;
}

button.is-loading {
  opacity: 0.72;
  cursor: wait;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.preview {
  background: var(--ink);
  color: #e5edf7;
  border-radius: 8px;
  padding: 12px;
  min-height: 118px;
  white-space: pre-wrap;
  line-height: 1.55;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}

.send-preview {
  display: grid;
  gap: 10px;
  background: transparent;
  color: var(--text);
  border: 0;
  padding: 0;
  min-height: 0;
  font-family: inherit;
  white-space: normal;
}

.send-split-notice {
  padding: 10px 12px;
  border: 1px solid #99f6e4;
  border-left: 4px solid #0f766e;
  background: #f0fdfa;
  color: #115e59;
  font-weight: 900;
  border-radius: 6px;
}

.send-block {
  border: 2px solid #0f766e;
  background: #ecfdf8;
  border-radius: 8px;
  overflow: hidden;
}

.send-target {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: #0f766e;
  color: white;
  font-weight: 900;
}

.send-body {
  margin: 0;
  padding: 12px;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  line-height: 1.55;
  color: #102033;
  background: #f8fffd;
}

.batch-table {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.batch-table table {
  min-width: 1160px;
}

.batch-table input,
.batch-table select {
  min-height: 34px;
  padding: 6px 8px;
  font-size: 13px;
}

.row-account-candidates td {
  background: #fff8e8;
}

.account-candidate-panel {
  border: 1px solid #f2c46b;
  border-radius: 8px;
  padding: 12px;
  color: #633d00;
  background: #fffaf0;
}

.account-candidate-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.account-candidate-card {
  display: grid;
  grid-template-columns: 1fr 1fr 0.8fr 1.4fr 1.3fr 1fr auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid #f5d68f;
  border-radius: 8px;
  background: #fff;
}

.account-candidate-card span {
  display: block;
  margin-bottom: 3px;
  font-size: 12px;
  color: #8a6215;
}

.account-candidate-card strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #1e293b;
}

.account-candidate-card button {
  white-space: nowrap;
}

.mobile-demand-cards,
.mobile-action-bar {
  display: none;
}

.mobile-demand-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
}

.mobile-demand-card + .mobile-demand-card {
  margin-top: 10px;
}

.mobile-demand-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.mobile-demand-title {
  font-weight: 800;
}

.mobile-demand-grid {
  display: grid;
  gap: 9px;
}

.mobile-demand-field {
  display: grid;
  gap: 4px;
}

.mobile-demand-field label {
  color: var(--muted);
  font-size: 12px;
}

.mobile-demand-issue {
  margin-top: 10px;
  color: #9a5b00;
  font-size: 12px;
  line-height: 1.4;
}

.batch-index {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #eef2f7;
  color: #475569;
  font-weight: 800;
  font-size: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 10px 9px;
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

th {
  color: var(--muted);
  background: #f8fafc;
  font-size: 12px;
  font-weight: 700;
}

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

.table-wrap {
  overflow: hidden;
  margin-bottom: 16px;
}

.table-scroll {
  overflow: auto;
}

.small {
  font-size: 12px;
  color: var(--muted);
}

.hidden { display: none !important; }

.copy-toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: #132033;
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: .18s ease;
  pointer-events: none;
}

.copy-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #f4f6f8;
}

.login-card {
  width: min(420px, 100%);
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(18, 31, 54, .16);
  padding: 22px;
}

.login-logo {
  width: 118px;
  display: block;
  margin: 0 auto 12px;
}

.login-title {
  text-align: center;
  font-size: 20px;
  font-weight: 900;
  margin-bottom: 6px;
}

.login-sub {
  text-align: center;
  color: var(--muted);
  margin-bottom: 18px;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  white-space: nowrap;
}

.avatar {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #dff5f1;
  color: #075e54;
  font-size: 12px;
  font-weight: 800;
}

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

.modal {
  width: min(760px, 100%);
  max-height: min(720px, 92vh);
  overflow: auto;
  background: var(--panel);
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(15, 23, 42, .22);
  padding: 16px;
}

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

.modal-title {
  font-size: 16px;
  font-weight: 800;
}

@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    min-height: auto;
    padding: 12px;
    position: sticky;
    top: 0;
    z-index: 10;
  }
  .brand {
    grid-template-columns: auto 1fr;
    justify-items: start;
    text-align: left;
    padding: 6px 8px 12px;
  }
  .brand-logo { width: 72px; }
  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-height: 188px;
    overflow: auto;
  }
  .nav button {
    justify-content: center;
    min-height: 42px;
    padding: 0 8px;
  }
  .topbar {
    height: auto;
    min-height: 64px;
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 18px;
    gap: 10px;
  }
  .top-meta { flex-wrap: wrap; gap: 8px 12px; }
  .content { padding: 16px 14px 28px; }
  .panel { padding: 14px; }
  .field-grid { grid-template-columns: 1fr; }
  .workbench, .split, .grid-4, .rule-grid { grid-template-columns: 1fr; }
  .table-scroll table {
    min-width: 760px;
  }
  .actions button {
    min-height: 44px;
  }
  .metric-value {
    font-size: 24px;
  }
}

@media (max-width: 640px) {
  body:has(#workbench:not(.hidden)) {
    padding-bottom: 78px;
  }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brand-title { font-size: 14px; }
  .top-meta {
    width: 100%;
    justify-content: space-between;
  }
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }
  .panel-head button {
    width: 100%;
  }
  .balance-item {
    grid-template-columns: 1fr;
  }
  .deployment-item {
    grid-template-columns: 1fr;
  }
  #workbench .batch-table {
    display: none;
  }
  #workbench .mobile-demand-cards {
    display: grid;
    gap: 10px;
    margin-top: 12px;
  }
  #workbench .mobile-demand-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #workbench .mobile-demand-field:nth-child(5),
  #workbench .mobile-demand-field:nth-child(8),
  #workbench .mobile-demand-field:nth-child(9) {
    grid-column: 1 / -1;
  }
  .mobile-action-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, .96);
    border-top: 1px solid var(--line);
    box-shadow: 0 -12px 28px rgba(18, 31, 54, .12);
  }
  .mobile-action-bar button {
    min-height: 44px;
    padding: 0 8px;
  }
  .page.hidden .mobile-action-bar,
  #workbench.hidden .mobile-action-bar {
    display: none;
  }
  .preview {
    font-size: 12px;
  }
}
