:root {
  --ink: #173d31;
  --ink-deep: #0f2d25;
  --ink-2: #255947;
  --ink-3: #e7f0eb;
  --accent: #b48736;
  --accent-2: #d7ad55;
  --accent-soft: #f7efe0;
  --bg: #f3f5f1;
  --surface: #ffffff;
  --surface-2: #fafbf9;
  --line: #dfe6df;
  --line-strong: #c9d5cc;
  --text: #1e2722;
  --muted: #68766f;
  --muted-2: #8a9690;
  --danger: #a23a32;
  --danger-soft: #fae9e7;
  --shadow: 0 1px 2px rgba(23, 61, 49, 0.04), 0 16px 38px rgba(23, 61, 49, 0.08);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(23, 61, 49, 0.06) 0, rgba(23, 61, 49, 0) 280px),
    var(--bg);
  font-family: "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", system-ui, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 24px;
  color: #fff;
  background: linear-gradient(135deg, var(--ink-deep) 0%, var(--ink) 58%, #1f5947 100%);
  box-shadow: 0 10px 28px rgba(15, 45, 37, 0.22);
}

.brand,
.top-actions,
.pane-head,
.dialog-head,
.items-head,
.dialog-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  min-width: 260px;
}

.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: #f1dfb8;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.10));
}

.brand-icon {
  width: 27px;
  height: 27px;
  fill: currentColor;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 16px;
  line-height: 1.2;
}

.brand span {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
}

.top-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stage-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.file-button input {
  display: none;
}

.top-primary,
.top-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.top-primary {
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.92);
  background: #fff;
  box-shadow: 0 8px 20px rgba(5, 20, 16, 0.18);
}

.top-primary:hover {
  background: #f7faf7;
}

.top-secondary {
  color: rgba(255, 255, 255, 0.90);
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.10);
}

.top-secondary:hover {
  border-color: rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.16);
}

.shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 22px 24px 32px;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px;
  align-items: stretch;
  gap: 20px;
  margin-bottom: 16px;
  padding: 0;
  border: 1px solid rgba(23, 61, 49, 0.12);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 22px 60px rgba(23, 61, 49, 0.10);
  overflow: hidden;
}

.hero-copy {
  padding: 28px 28px 24px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(245, 249, 246, 0.92) 100%),
    linear-gradient(90deg, rgba(180, 135, 54, 0.08), rgba(23, 61, 49, 0.08));
}

.kicker {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  color: var(--ink);
  letter-spacing: 0;
}

h1 {
  max-width: 920px;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.22;
}

h2 {
  font-size: 15px;
  font-weight: 800;
}

.hero-note {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100%;
  width: 100%;
  padding: 22px;
  border-left: 1px solid var(--line);
  background: linear-gradient(180deg, #fbfcfa 0%, #f3f7f4 100%);
}

.hero-note span,
.hero-note strong,
.hero-note small {
  display: block;
}

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

.hero-note strong {
  margin-top: 3px;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.25;
}

.hero-note small {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.hero-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.hero-steps span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 11px;
  border: 1px solid rgba(23, 61, 49, 0.14);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  font-size: 12px;
  font-weight: 760;
  box-shadow: 0 1px 2px rgba(23, 61, 49, 0.04);
}

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

.stat-card {
  position: relative;
  padding: 15px 16px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(23, 61, 49, 0.03);
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent-2);
}

.stat-card span,
.stat-card strong,
.stat-card small {
  display: block;
}

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

.stat-card strong {
  margin-top: 5px;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.1;
}

.stat-card small {
  margin-top: 7px;
  color: var(--muted-2);
  font-size: 11px;
}

.import-summary {
  margin-bottom: 14px;
  padding: 13px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--ink-3);
  font-size: 13px;
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 360px;
  gap: 14px;
  align-items: start;
}

.left-pane,
.table-pane,
.detail-pane {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.left-pane,
.detail-pane {
  position: sticky;
  top: 78px;
  padding: 18px;
}

.table-pane {
  min-width: 0;
  overflow: hidden;
}

.pane-head {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 15px;
}

.table-head {
  padding: 18px 18px 0;
}

.result-meta {
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.input {
  width: 100%;
  height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  font-size: 13px;
  outline: none;
}

.input:focus {
  border-color: var(--ink-2);
  box-shadow: 0 0 0 3px rgba(37, 89, 71, 0.12);
}

.side-actions {
  display: grid;
  gap: 9px;
  margin-top: 16px;
}

.primary-button,
.ghost-button,
.text-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.primary-button,
.ghost-button {
  min-height: 38px;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 750;
}

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

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

.ghost-button {
  color: var(--ink);
  border: 1px solid var(--line-strong);
  background: var(--surface);
}

.ghost-button:hover {
  border-color: var(--ink-2);
  background: var(--surface-2);
}

.ghost-button.danger {
  color: var(--danger);
  border-color: #e7c5c0;
  background: #fff;
}

.ghost-button.danger:hover {
  background: var(--danger-soft);
}

.text-button {
  padding: 0;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
}

.text-button:hover {
  color: var(--ink);
}

.icon-button {
  width: 34px;
  height: 34px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 22px;
  line-height: 1;
}

.full {
  width: 100%;
}

.small {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12px;
}

.table-wrap {
  position: relative;
  overflow-x: auto;
  padding: 0 18px 18px;
}

.orders-table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
  font-size: 13px;
}

.orders-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 9px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
  text-align: left;
  white-space: nowrap;
}

.orders-table td {
  padding: 12px 9px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.orders-table tbody tr {
  cursor: pointer;
}

.orders-table tbody tr:hover,
.orders-table tbody tr.selected {
  background: #f4f8f5;
}

.orders-table .main-cell {
  color: var(--ink);
  font-weight: 760;
}

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

.number {
  text-align: right;
  white-space: nowrap;
}

.invoice-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--ink);
  background: var(--ink-3);
  font-size: 12px;
  white-space: nowrap;
}

.invoice-pill.warn {
  color: #8a5b14;
  background: var(--accent-soft);
}

.empty-state,
.detail-empty {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong,
.detail-empty h2 {
  color: var(--ink);
}

.empty-state span,
.detail-empty span {
  display: block;
  max-width: 270px;
  margin-top: 6px;
  font-size: 13px;
}

.detail-title {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

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

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 15px 0;
}

.detail-grid div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

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

dt,
dd {
  margin: 0;
}

dt {
  color: var(--muted);
  font-size: 11px;
}

dd {
  margin-top: 4px;
  color: var(--text);
  font-size: 13px;
  word-break: break-word;
}

.items-head {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.items-head strong {
  color: var(--ink);
  font-size: 14px;
}

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

.detail-items {
  display: grid;
  gap: 8px;
}

.detail-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.detail-item strong {
  display: block;
  color: var(--text);
  font-size: 13px;
}

.detail-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.order-dialog {
  width: min(920px, calc(100vw - 34px));
  max-height: min(86vh, 860px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 22px 80px rgba(23, 61, 49, 0.26);
}

.order-dialog::backdrop {
  background: rgba(13, 31, 25, 0.42);
}

#orderForm {
  padding: 20px;
}

.dialog-head {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

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

.form-grid .wide {
  grid-column: span 2;
}

.line-editor {
  margin-top: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.item-rows {
  display: grid;
  gap: 8px;
}

.item-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.6fr) minmax(110px, 1fr) 86px 96px 100px 34px;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
}

.item-row .field {
  margin-bottom: 0;
}

.amount-preview {
  display: grid;
  height: 38px;
  align-items: center;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font-size: 13px;
  font-weight: 760;
}

.remove-row {
  width: 34px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--danger);
  background: #fff;
  font-size: 18px;
}

.remove-row:hover {
  background: var(--danger-soft);
}

.dialog-actions {
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.form-errors {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #e7c5c0;
  border-radius: 8px;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 13px;
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .detail-pane {
    grid-column: 1 / -1;
    position: static;
  }
}

@media (max-width: 860px) {
  .topbar,
  .hero-panel {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    justify-content: flex-start;
  }

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

  .left-pane {
    position: static;
  }

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

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