:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", Arial, sans-serif;
  background: #eef2f7;
  color: #1d2635;
  --blue: #1463d8;
  --green: #138a4d;
  --red: #c53a32;
  --ink: #1d2635;
  --muted: #657389;
  --line: #d7deea;
  --panel: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

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

button,
.button-link {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  min-height: 40px;
  padding: 9px 14px;
  text-decoration: none;
}

button.primary,
.button-link {
  background: var(--blue);
  color: #fff;
}

button.secondary {
  background: #3c4658;
  color: #fff;
}

button.danger {
  background: var(--red);
  color: #fff;
}

button.ghost {
  background: transparent;
  color: #d8e6ff;
  border: 1px solid rgba(255, 255, 255, 0.24);
}

button.small {
  min-height: 34px;
  padding: 7px 10px;
  background: #eef4ff;
  color: #164781;
  border: 1px solid #bed0eb;
}

button.small.danger-link {
  background: #fff1f0;
  color: var(--red);
  border-color: #efb3ae;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c8d2e0;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-weight: 700;
}

.login-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background: linear-gradient(135deg, #eef2f7 0%, #dfe8f4 100%);
}

.login-panel {
  display: grid;
  gap: 18px;
  width: min(440px, 100%);
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 22px 48px rgba(44, 62, 90, 0.15);
}

.login-panel h1,
.sidebar h1,
.topbar h2,
.section-title h3 {
  margin: 0;
}

.login-panel p {
  color: var(--muted);
  line-height: 1.65;
  margin: 8px 0 0;
}

.eyebrow {
  color: #3f6ea9;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.wide {
  width: 100%;
}

.message {
  color: var(--muted);
  min-height: 22px;
}

.message.is-error {
  color: var(--red);
}

.message.is-ok {
  color: var(--green);
}

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

.is-hidden {
  display: none !important;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 24px;
  background: #182234;
  color: #fff;
}

.sidebar .eyebrow {
  color: #8fb6f1;
}

.sidebar nav {
  display: grid;
  gap: 10px;
}

.nav-button {
  background: transparent;
  color: #d5e3f8;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.nav-button.is-active {
  background: #276bd4;
  border-color: #276bd4;
  color: #fff;
}

.operator {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.content {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.status-strip span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #334155;
}

.environment-notice {
  display: none;
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: #334155;
}

.environment-notice.is-ok,
.environment-notice.is-warning {
  display: block;
}

.environment-notice.is-ok {
  border-color: #b7dec8;
  background: #eefaf3;
  color: #146c3c;
}

.environment-notice.is-warning {
  border-color: #efd39a;
  background: #fff7df;
  color: #805600;
}

.capture-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.1fr) minmax(320px, 0.9fr);
  gap: 18px;
}

.video-panel,
.scan-panel,
.queue-panel,
.info-grid section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(49, 67, 96, 0.08);
}

.video-panel,
.scan-panel,
.queue-panel {
  padding: 16px;
}

video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0f172a;
  border-radius: 6px;
  object-fit: contain;
}

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

.compact-label {
  width: 150px;
  font-size: 13px;
}

.scan-panel {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.scanner-receiver {
  margin-bottom: 12px;
}

.scan-input {
  border-width: 1px;
  border-color: #9eb7d8;
  font-size: 16px;
  min-height: 42px;
  background: #fff;
}

.scan-debug-panel {
  border: 1px dashed #afc2dd;
  border-radius: 8px;
  padding: 10px;
  background: #fbfdff;
}

.scan-debug-panel summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.scan-debug-panel[open] summary {
  margin-bottom: 10px;
}

.scan-debug-list {
  display: grid;
  gap: 6px;
}

.scan-log-row {
  display: grid;
  grid-template-columns: 72px minmax(90px, 1fr) minmax(90px, 1fr) minmax(110px, 1.2fr);
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}

.scan-log-row strong,
.scan-log-row code,
.scan-log-row em {
  min-width: 0;
  overflow-wrap: anywhere;
  font-style: normal;
}

.scan-log-row strong {
  color: var(--text);
}

.scan-log-row code {
  color: #1f3f70;
}

.current-card {
  border: 1px solid #c9d6e8;
  border-radius: 8px;
  padding: 14px;
  background: #f8fbff;
}

.current-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.current-card-header .card-title {
  margin-bottom: 0;
}

.card-title {
  font-weight: 800;
  margin-bottom: 8px;
}

dl {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 8px 10px;
  margin: 0;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

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

.input-warning {
  border-color: #c83f49 !important;
  background: #fff5f5 !important;
}

.danger-pill {
  background: #fde8ea;
  color: #9b1c26;
}

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

.current-products {
  border-top: 1px solid #c9d6e8;
  margin-top: 14px;
  padding-top: 14px;
}

.manual-product-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
  margin-bottom: 12px;
}

.manual-product-remark {
  grid-column: 1 / -1;
}

.manual-product-form label,
.compact-field {
  gap: 5px;
  font-size: 13px;
}

.manual-product-form input,
.manual-product-form select,
.compact-field input {
  min-height: 36px;
  padding: 7px 9px;
}

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

.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px 118px;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

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

.item-row > input[data-item-remark] {
  grid-column: 1 / 3;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  gap: 6px;
  align-items: center;
}

.qty-controls {
  display: block;
}

.qty-controls input {
  text-align: center;
  padding: 8px 4px;
  background: #fff;
  color: var(--text);
}

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

.queue-panel {
  margin-top: 18px;
}

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

.queue-item,
.record-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) 140px 120px;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef4ff;
  color: #1e4f91;
  font-size: 13px;
}

.pill.warning {
  background: #fff4d6;
  color: #8a5a00;
}

.records-table {
  display: grid;
  gap: 10px;
}

.inventory-adjustment-panel {
  margin-bottom: 16px;
  padding: 14px 0 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.inventory-adjustment-panel h3,
.inventory-adjustment-panel p {
  margin: 0;
}

.inventory-add-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(170px, 1fr) 130px minmax(150px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.logs-table {
  display: grid;
  gap: 8px;
}

.log-row {
  display: grid;
  grid-template-columns: 180px 140px 140px minmax(260px, 1fr);
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  align-items: start;
}

.log-detail {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

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

.inventory-summary article {
  display: grid;
  gap: 4px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(49, 67, 96, 0.08);
}

.inventory-summary span {
  color: var(--muted);
}

.inventory-summary strong {
  font-size: 32px;
}

.inventory-summary small {
  color: #42526a;
}

.inventory-sections {
  display: grid;
  gap: 18px;
}

.inventory-sections > section {
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(49, 67, 96, 0.08);
}

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

.inventory-row {
  display: grid;
  grid-template-columns: 28px minmax(180px, 1.2fr) 150px 170px minmax(160px, 0.9fr) minmax(170px, 0.9fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdff;
}

.inventory-check,
.inventory-check-placeholder {
  width: 18px;
  height: 18px;
  align-self: center;
  justify-self: center;
}

.inventory-section-tools,
.inventory-pagination,
.inventory-batch-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.inventory-section-tools {
  justify-content: flex-end;
}

.inventory-section-tools label,
.inventory-pagination label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.inventory-section-tools input,
.inventory-pagination select {
  min-height: 34px;
  padding: 6px 8px;
}

.inventory-pagination,
.inventory-batch-bar {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.inventory-pagination {
  justify-content: flex-end;
}

.inventory-batch-bar {
  justify-content: flex-start;
  margin: 0 0 12px;
  padding: 10px 0;
  border-top: 0;
  border-bottom: 1px solid var(--line);
}

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

.inventory-actions select {
  min-width: 110px;
}

.small-link {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
}

.record-row {
  grid-template-columns: 170px minmax(0, 1.1fr) minmax(0, 1fr) 170px;
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.product-review-list,
.product-review-line {
  display: grid;
  gap: 5px;
}

.product-review-line {
  padding: 7px 0;
  border-bottom: 1px solid #e7edf5;
}

.product-review-line:last-child {
  border-bottom: 0;
}

.command-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.command-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(49, 67, 96, 0.08);
}

.command-card h3 {
  margin: 0 0 6px;
}

.command-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.command-alias {
  font-size: 12px;
}

.barcode {
  width: 100%;
  height: 118px;
  padding: 14px 18px;
  border: 1px solid #d3dce9;
  border-radius: 6px;
  background: #fff;
}

.barcode svg {
  width: 100%;
  height: 100%;
  fill: #111827;
}

.command-card code {
  color: #1f3f70;
  font-weight: 800;
  overflow-wrap: anywhere;
}

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

.info-grid section {
  padding: 18px;
}

.info-grid p {
  color: var(--muted);
  line-height: 1.75;
}

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

  .sidebar {
    position: static;
  }

  .capture-grid,
  .manual-product-form,
  .inventory-add-form,
  .log-row,
  .info-grid {
    grid-template-columns: 1fr;
  }

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

  .queue-item,
  .record-row,
  .item-row,
  .inventory-row {
    grid-template-columns: 1fr;
  }

  .inventory-check,
  .inventory-check-placeholder {
    justify-self: start;
  }

  .inventory-section-tools,
  .inventory-pagination {
    justify-content: flex-start;
  }

  .inventory-summary {
    grid-template-columns: 1fr;
  }

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

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .topbar button,
  #captureView,
  #recordsView,
  #settingsView {
    display: none !important;
  }

  .app {
    display: block;
  }

  .content {
    padding: 0;
  }

  #commandsView {
    display: block !important;
  }

  .command-card {
    break-inside: avoid;
    box-shadow: none;
  }
}
