:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #d9dee7;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --warn: #9a3412;
  --warn-bg: #fff7ed;
  --ok-bg: #ecfdf5;
  --card-radius: 8px;
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 28px;
  border-right: 1px solid var(--line);
  background: #ffffff;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 10px;
  font-size: 18px;
}

h3 {
  margin-bottom: 4px;
  font-size: 16px;
}

.subtle {
  color: var(--muted);
  line-height: 1.6;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

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

.metric strong {
  font-size: 22px;
}

.quick-examples {
  display: grid;
  gap: 8px;
}

.quick-examples button,
.ghost-button,
.composer button,
.card-actions button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.quick-examples button {
  padding: 10px 12px;
  text-align: left;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(520px, 1.05fr);
  gap: 18px;
  padding: 22px;
  min-width: 0;
}

.chat-panel,
.data-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: var(--panel);
}

.chat-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.section-title.compact {
  align-items: baseline;
  padding: 16px 18px 8px;
  border-bottom: 0;
}

.section-title h2,
.section-title p {
  margin-bottom: 0;
}

.ghost-button {
  padding: 8px 12px;
}

.messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 360px;
  max-height: calc(100vh - 230px);
  padding: 18px;
  overflow: auto;
}

.assistant-message,
.user-message,
.draft-card {
  border-radius: var(--card-radius);
  line-height: 1.55;
}

.assistant-message,
.draft-card {
  padding: 14px;
  border: 1px solid var(--line);
  background: #fbfcfd;
}

.user-message {
  align-self: flex-end;
  max-width: 88%;
  padding: 12px 14px;
  background: var(--brand);
  color: #fff;
}

.composer {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 10px;
  padding: 18px;
  border-top: 1px solid var(--line);
}

.composer textarea {
  width: 100%;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  outline: none;
}

.composer textarea:focus {
  border-color: var(--brand);
}

.composer button,
.confirm-button {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}

.draft-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.pill,
.confidence {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--ok-bg);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 700;
}

.confidence.low {
  background: var(--warn-bg);
  color: var(--warn);
}

.draft-body table,
.table-wrap table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: #4b5563;
  font-size: 12px;
  font-weight: 700;
  background: #f8fafc;
}

.warnings {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  color: var(--warn);
}

.field-line {
  display: grid;
  grid-template-columns: 64px 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.field-line span {
  color: var(--muted);
  font-size: 13px;
}

.field-line input,
.field-line select,
.editable-table input,
.price-form input,
.price-form select,
.bulk-import textarea,
.detail-actions input,
.detail-actions select,
.detail-panel input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 9px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.field-line input:focus,
.field-line select:focus,
.editable-table input:focus,
.price-form input:focus,
.price-form select:focus,
.bulk-import textarea:focus,
.detail-actions input:focus,
.detail-actions select:focus,
.detail-panel input:focus {
  border-color: var(--brand);
}

.editable-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.editable-table th,
.editable-table td {
  padding: 7px;
}

.editable-table input {
  min-width: 72px;
}

.draft-total {
  margin: 10px 0 0;
}

.mini-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  background: #fff;
  color: var(--ink);
}

.add-row {
  margin-top: 10px;
}

.warning-line {
  padding: 8px 10px;
  border: 1px solid #fed7aa;
  border-radius: 6px;
  background: var(--warn-bg);
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.card-actions button {
  padding: 8px 12px;
}

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

.tabs {
  display: flex;
  gap: 6px;
  padding: 14px 14px 0;
}

.tab {
  padding: 9px 12px;
  border: 0;
  border-radius: 6px 6px 0 0;
  background: #eef2f7;
  color: #4b5563;
}

.tab.active {
  background: var(--brand);
  color: #fff;
}

.tab-content {
  display: none;
  padding: 0 18px 18px;
}

.tab-content.active {
  display: block;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
}

.price-form {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 100px 90px 104px;
  gap: 8px;
  padding: 0 18px 14px;
}

.price-form button {
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}

.bulk-import {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: #fbfcfd;
}

.bulk-import h3,
.bulk-import p {
  margin-bottom: 0;
}

.bulk-import textarea {
  resize: vertical;
}

.bulk-import button {
  justify-self: start;
  border: 1px solid var(--brand);
  border-radius: 6px;
  padding: 8px 12px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}

.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding-top: 16px;
}

.report-grid section {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
}

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

.list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 6px;
  background: #f8fafc;
  color: #374151;
}

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

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

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

.task-card strong {
  font-size: 20px;
}

.detail-panel {
  display: grid;
  gap: 14px;
}

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

.detail-summary div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: #fbfcfd;
}

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

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 120px 150px 170px;
  gap: 8px;
  align-items: center;
}

.detail-actions .field-line {
  grid-template-columns: 50px 1fr;
  margin-bottom: 0;
}

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

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

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 720px) {
  .price-form {
    grid-template-columns: 1fr 1fr;
  }

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

  .task-grid,
  .detail-summary,
  .detail-actions {
    grid-template-columns: 1fr;
  }
}
