:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #64707d;
  --line: #d9ded7;
  --accent: #167a72;
  --accent-dark: #0f5f59;
  --warn: #9a5a00;
  --soft: #eef6f3;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(246, 247, 244, 0.96);
}

.auth-card {
  width: min(360px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 18px 45px rgba(31, 41, 51, 0.16);
}

.auth-card h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.auth-card p {
  margin: 0 0 14px;
  color: var(--muted);
}

.auth-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  font-size: 16px;
}

.auth-card button {
  width: 100%;
  margin-top: 12px;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 700;
}

.auth-error {
  min-height: 18px;
  margin-top: 10px;
  color: var(--danger);
  font-size: 14px;
}

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

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  cursor: pointer;
}

button:active {
  transform: translateY(1px);
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.entry-panel,
.table-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.inventory-panel {
  margin-top: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

#versionBadge {
  display: inline-block;
  margin-left: 8px;
  color: var(--muted);
  font-weight: 600;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(26px, 7vw, 42px);
  line-height: 1.1;
}

h2 {
  font-size: 20px;
}

.input-label {
  display: block;
  margin-top: 18px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--ink);
  background: #fbfcfb;
  line-height: 1.6;
}

textarea:focus,
input:focus,
select:focus {
  outline: 3px solid rgba(22, 122, 114, 0.18);
  border-color: var(--accent);
}

.actions,
.samples,
.table-actions,
.panel-heading {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.actions {
  margin-top: 12px;
}

.voice {
  border-color: #c9d5ee;
  background: #eef3ff;
  color: #1d4b8f;
  font-weight: 700;
}

.voice.listening {
  border-color: #b42318;
  background: #fff1f0;
  color: #b42318;
}

.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.primary:hover {
  background: var(--accent-dark);
}

.samples {
  margin-top: 14px;
}

.voice-status {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.voice-status.warn {
  color: var(--warn);
}

.voice-status.ok {
  color: var(--accent-dark);
}

.sync-status {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.sync-status.ok {
  color: var(--accent-dark);
}

.sync-status.warn {
  color: var(--warn);
}

.samples button {
  background: var(--soft);
  border-color: #cbe3dc;
  color: #124f4b;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.status-strip > div {
  min-width: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.filter-panel {
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) repeat(3, minmax(100px, 0.75fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.filter-field {
  min-width: 0;
}

.filter-field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.filter-field input,
.filter-field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 0 10px;
}

.label {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.status-strip strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

.panel-heading {
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.message {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff7e6;
  color: var(--warn);
  font-size: 14px;
}

.message.ok {
  background: var(--soft);
  color: #155c55;
}

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

table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
  background: #fff;
}

.inventory-table {
  min-width: 840px;
}

.match-table {
  min-width: 760px;
}

.picklist-input {
  min-height: 112px;
  margin-bottom: 10px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 6px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f1f4ef;
  color: #3d4a56;
  font-size: 13px;
  white-space: nowrap;
}

td input,
td select {
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #f8faf8;
  padding: 7px;
}

td input[type="number"] {
  min-width: 0;
}

.delete-btn {
  color: var(--danger);
  min-width: 42px;
  padding: 0 10px;
}

.sku-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #f8faf8;
  display: block;
}

.no-image {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  background: #fafbf9;
}

.stock-badge {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border-radius: 8px;
  padding: 0 12px;
  font-weight: 700;
  white-space: nowrap;
  font-size: 15px;
}

.stock-badge.ok {
  background: #087f5b;
  color: #fff;
  box-shadow: 0 0 0 3px rgba(8, 127, 91, 0.18);
}

.inventory-table tr.outbound-alert td {
  background: #fff1f1;
  border-top-color: #f4aaaa;
  border-bottom-color: #f4aaaa;
}

.inventory-table tr.outbound-alert {
  outline: 2px solid #d92d20;
  outline-offset: -2px;
}

.outbound-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  min-height: 28px;
  border-radius: 6px;
  padding: 0 9px;
  background: #d92d20;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

table th:nth-child(1),
table td:nth-child(1) {
  width: 56px;
  min-width: 56px;
}

table th:nth-child(2),
table td:nth-child(2) {
  width: 78px;
  min-width: 78px;
}

table th:nth-child(3),
table td:nth-child(3) {
  width: 58px;
  min-width: 58px;
}

table th:nth-child(4),
table td:nth-child(4) {
  width: 54px;
  min-width: 54px;
}

table th:nth-child(5),
table td:nth-child(5) {
  width: 58px;
  min-width: 58px;
}

table td:nth-child(2) input,
table td:nth-child(3) input,
table td:nth-child(4) input,
table td:nth-child(5) input {
  padding-left: 6px;
  padding-right: 6px;
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
  }

  .entry-panel,
  .table-panel {
    padding: 14px;
  }

  .status-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .filter-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-keyword {
    grid-column: 1 / -1;
  }

  #resetFiltersBtn {
    grid-column: 1 / -1;
  }

  .panel-heading {
    align-items: stretch;
  }

  .table-actions {
    width: 100%;
  }

  .table-actions button {
    flex: 1 1 130px;
  }

  table {
    min-width: 820px;
  }

  .inventory-table {
    min-width: 520px;
  }

  .match-table {
    min-width: 650px;
  }

  th,
  td {
    padding: 5px;
  }

  td input,
  td select {
    padding: 6px;
  }
}
