:root {
  color-scheme: light;
  --ink: #18212a;
  --muted: #60707d;
  --line: #cbd3d8;
  --line-strong: #96a4ad;
  --paper: #f4f1e9;
  --panel: #fffdf8;
  --navy: #17344a;
  --navy-2: #244d68;
  --orange: #c45b20;
  --orange-dark: #954015;
  --danger: #a22f2f;
  --success: #24653e;
  --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(23, 52, 74, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 52, 74, .035) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .62; }

.warehouse-shell {
  width: min(1880px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px 0 22px;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(560px, 1fr);
  gap: 10px;
}


.warehouse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 20px;
  border-top: 5px solid var(--orange);
}

.warehouse-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(--orange-dark); font-size: 12px; font-weight: 800; letter-spacing: .18em; }
.subtle { margin: 0; color: var(--muted); }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.version-chip { padding: 7px 10px; color: #fff; background: var(--navy); border-radius: 2px; font-weight: 800; }

.button:hover:not(:disabled) { border-color: var(--orange); color: var(--orange-dark); }
.button.primary { color: #fff; border-color: var(--navy); background: var(--navy); }
.button.primary:hover:not(:disabled) { color: #fff; background: var(--navy-2); }
.button.warn { color: #fff; border-color: var(--orange-dark); background: var(--orange); }
.button.danger { color: #fff; border-color: #7d2424; background: var(--danger); }
.button.compact { min-height: 28px; padding: 3px 9px; font-size: 12px; }

.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 10px; }
.metric-card { padding: 13px 15px; border-left: 5px solid var(--navy); 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(--danger); }
.metric-card.risk .metric-value { color: var(--danger); }

.desktop-tabs { display: flex; gap: 0; padding: 0; overflow-x: auto; box-shadow: none; }
.tab-button:hover { background: #eeeae0; }
.tab-button.active { color: #fff; border-bottom-color: var(--orange); background: var(--navy); }

.status-bar {
  display: block;
  min-height: 38px;
  padding: 9px 13px;
  border-left: 5px solid var(--navy-2);
  color: var(--navy);
  background: #e8f0f4;
  font-size: 13px;
}
.status-bar.error { border-left-color: var(--danger); color: #762121; background: #f9e5e3; }
.status-bar.success { border-left-color: var(--success); color: #194a2e; background: #e6f2e9; }

.page-root { min-height: 560px; }
.work-page { min-height: 560px; display: grid; gap: 10px; align-content: stretch; }
.work-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(340px, .65fr); gap: 10px; min-height: 0; }
.work-grid.equal { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.work-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.desktop-document-grid { grid-template-columns: minmax(0, .86fr) minmax(420px, 1.14fr); }
.desktop-stocktake-grid { grid-template-columns: minmax(0, .72fr) minmax(420px, 1.28fr); }
.stack { min-width: 0; display: grid; gap: 10px; align-content: start; }
.content-panel { min-width: 0; padding: 15px; }
.fill-panel { min-height: 430px; display: grid; grid-template-rows: auto auto minmax(260px, 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.6; }

.toolbar, .action-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.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: #384a57; font-size: 12px; font-weight: 800; }
textarea.input { min-height: 88px; resize: vertical; line-height: 1.55; }
.input:focus { outline: 2px solid rgba(196, 91, 32, .2); border-color: var(--orange); }
.input[readonly] { color: #4f5e69; background: #f2f2ed; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
tbody tr:nth-child(even) { background: #f7f6f1; }
tbody tr[data-row-index]:hover { background: #fcebdc; }
tbody tr.selected { background: #f7d8bf; }
.empty-row td { height: 88px; color: var(--muted); text-align: center; vertical-align: middle; }

.photo-grid { display: grid; grid-template-columns: repeat(6, minmax(100px, 1fr)); gap: 8px; }
.photo-slot { min-height: 118px; display: grid; place-items: center; border: 1px dashed var(--line-strong); background: #faf9f4; overflow: hidden; }
.photo-slot img { width: 100%; height: 118px; object-fit: contain; }
.preview-image { min-height: 290px; display: grid; place-items: center; border: 1px dashed var(--line-strong); background: #f1f2ed; }
.preview-image img { max-width: 100%; max-height: 420px; object-fit: contain; }

.scan-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.scan-tabs .button.active { color: #fff; background: var(--orange); border-color: var(--orange-dark); }
.step-strip { display: flex; flex-wrap: wrap; gap: 6px; counter-reset: step; }
.step-strip span { padding: 7px 10px; border: 1px solid var(--line); background: #f5f3ed; font-size: 12px; font-weight: 700; }
.blocked-note { padding: 10px; border: 1px solid #e3bf91; color: #734314; background: #fff5e7; font-size: 12px; line-height: 1.55; }
.confirmation-note { margin-top: 12px; padding: 10px; border-left: 4px solid var(--danger); color: #682323; background: #f9e5e3; font-size: 12px; line-height: 1.55; }
.hidden-desktop-parity { display: none !important; }

.detail-dialog { width: min(900px, calc(100% - 32px)); max-height: calc(100vh - 40px); padding: 0; border: 1px solid var(--line-strong); }
.detail-dialog::backdrop { background: rgba(10, 24, 34, .55); }
.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; }

@media (max-width: 1180px) {
  .work-grid, .work-grid.equal, .work-grid.three { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
  .photo-grid { grid-template-columns: repeat(3, minmax(100px, 1fr)); }
}

@media (max-width: 700px) {
  .warehouse-shell { width: calc(100% - 16px); padding-top: 8px; }
  .warehouse-header { align-items: flex-start; flex-direction: column; }
  .summary-grid, .field-grid, .field-grid.three, .field-grid.two { grid-template-columns: 1fr; }
  .photo-grid { grid-template-columns: repeat(2, minmax(100px, 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; }
