:root {
  color-scheme: light;
  --ink: #122033;
  --muted: #64748b;
  --line: #afc0d4;
  --paper: #f4f7fb;
  --panel: #ffffff;
  --primary: #1f5eff;
  --primary-dark: #123fb5;
  --teal: #0f8b7e;
  --warn: #a8550d;
  --danger: #b91c1c;
  --success: #21784b;
  --shadow: none;
  font-family: "Microsoft YaHei UI", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(31, 94, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 94, 255, .035) 1px, transparent 1px),
    var(--paper);
  background-size: 30px 30px;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }

.purchase-shell {
  width: min(1900px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px 0 22px;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(660px, 1fr);
  gap: 10px;
}

.purchase-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 20px;
  border-top: 5px solid var(--primary);
}
.purchase-header h1 { margin: 2px 0 4px; font-family: Georgia, "Microsoft YaHei UI", serif; font-size: clamp(24px, 2.3vw, 36px); }
.eyebrow { margin: 0; color: var(--primary-dark); font-size: 12px; font-weight: 800; letter-spacing: .18em; }
.subtle { margin: 0; color: var(--muted); }
.header-actions, .toolbar, .action-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.header-actions { justify-content: flex-end; }
.version-chip { padding: 7px 10px; color: #fff; background: var(--primary-dark); border-radius: 4px; font-weight: 800; }

.button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary-dark); }
.button.primary { color: #fff; border-color: var(--primary); background: var(--primary); }
.button.teal { color: #fff; border-color: var(--teal); background: var(--teal); }
.button.warn { color: #fff; border-color: var(--warn); background: var(--warn); }
.button.danger { color: #fff; border-color: var(--danger); background: var(--danger); }
.button.compact { min-height: 28px; padding: 3px 9px; font-size: 12px; }

.summary-grid { display: grid; grid-template-columns: repeat(5, minmax(140px, 1fr)); gap: 10px; }
.metric-card { padding: 13px 15px; border-left: 5px solid var(--primary); background: var(--panel); box-shadow: var(--shadow); }
.metric-label { color: var(--muted); font-size: 13px; font-weight: 700; }
.metric-value { margin-top: 4px; font-family: Georgia, serif; font-size: 28px; font-weight: 800; }
.metric-card.risk { border-left-color: var(--warn); }
.metric-card.risk .metric-value { color: var(--warn); }

.desktop-tabs { display: flex; gap: 0; overflow-x: auto; box-shadow: none; }
.tab-button:hover { background: #e5edf8; }
.tab-button.active { color: #fff; border-bottom-color: #7de2d3; background: var(--primary-dark); }

.status-bar {
  display: block;
  min-height: 38px;
  padding: 9px 13px;
  border-left: 5px solid var(--primary);
  color: #173f82;
  background: #e8efff;
  font-size: 13px;
}
.status-bar.error { border-left-color: var(--danger); color: #78231c; background: #fde8e6; }
.status-bar.success { border-left-color: var(--success); color: #175637; background: #e5f4eb; }

.page-root { min-height: 660px; height: 100%; }
.work-page { min-height: 660px; height: 100%; display: grid; gap: 10px; align-content: stretch; }
.work-grid { min-height: 0; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); gap: 10px; }
.work-grid.equal { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.work-grid.three { grid-template-columns: repeat(3, minmax(300px, 1fr)); }
.stack { min-width: 0; display: grid; gap: 10px; align-content: start; }
.content-panel { min-width: 0; padding: 15px; }
.fill-panel { min-height: 500px; display: grid; grid-template-rows: auto auto minmax(300px, 1fr) auto; }
.section-title { margin: 0 0 10px; font-family: Georgia, "Microsoft YaHei UI", serif; font-size: 19px; }
.section-title.small { font-size: 16px; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.65; }
.toolbar { margin-bottom: 10px; }
.toolbar .grow { flex: 1 1 260px; }

.field-grid { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 10px; }
.field-grid.three { grid-template-columns: repeat(3, minmax(160px, 1fr)); }
.field-grid.two { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
.field.wide { grid-column: 1 / -1; }
.field label { color: #435166; font-size: 12px; font-weight: 800; }
textarea.input { min-height: 88px; resize: vertical; line-height: 1.55; }
.input:focus { outline: 2px solid rgba(31, 94, 255, .18); border-color: var(--primary); }
.input[readonly] { color: #536277; background: #f1f4f8; }

.table-wrap.tall { min-height: 390px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
tbody tr:nth-child(even) { background: #f8fafd; }
tbody tr[data-row-type]:hover { background: #eaf0ff; }
tbody tr.selected { background: #d9e5ff; }
.empty-row td { height: 92px; color: var(--muted); text-align: center; vertical-align: middle; }

.boundary-note { padding: 12px; border: 1px solid #f0c188; color: #6f3d10; background: #fff6e9; line-height: 1.65; }
.guide-list { margin: 0; padding-left: 22px; color: #4f5f73; line-height: 1.75; }
.guide-list strong { color: var(--ink); }
.blocked-card { border-left: 5px solid var(--danger); }
.blocked-label { display: inline-block; margin-bottom: 8px; padding: 3px 7px; color: #fff; background: var(--danger); font-size: 12px; font-weight: 800; }

.detail-dialog { width: min(900px, calc(100% - 32px)); max-height: calc(100vh - 40px); padding: 0; border: 1px solid var(--line); }
.detail-dialog::backdrop { background: rgba(12, 27, 47, .58); }
.detail-dialog form { padding: 16px; }
.dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.dialog-header h2 { margin: 0; }
.detail-json { max-height: 65vh; overflow: auto; padding: 12px; color: #dce8ff; background: #13233a; white-space: pre-wrap; }

@media (max-width: 1250px) {
  .work-grid, .work-grid.equal, .work-grid.three { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
}
@media (max-width: 760px) {
  .purchase-shell { width: calc(100% - 16px); padding-top: 8px; }
  .purchase-header { align-items: flex-start; flex-direction: column; }
  .summary-grid, .field-grid, .field-grid.three, .field-grid.two { grid-template-columns: 1fr; }
}

/* === 桌面版DataGrid对齐 === */
thead tr { background: #f3f7fc; }
th { color: #435166; font-weight: 600; text-align: left; padding: 0 8px; height: 34px; border-bottom: 1px solid #afc0d4; }
td { padding: 0 8px; height: 25px; border-bottom: 1px solid #e8eef5; }
tbody tr:nth-child(even) { background: #fafcff; }
tbody tr:hover { background: #f4f8ff; }
