:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --ink: #14211f;
  --muted: #63706d;
  --line: #dbe4e1;
  --primary: #126c5a;
  --primary-strong: #0b4f42;
  --accent: #2f5f9f;
  --warning-bg: #fff4de;
  --warning-ink: #7a4300;
  --shadow: 0 18px 44px rgba(19, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 28px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h1,
.section-heading h2,
.create-panel h2,
.scan-panel h1 {
  margin: 0;
  line-height: 1.1;
}

.topbar h1 {
  font-size: clamp(1.8rem, 3vw, 2.7rem);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.summary-pill,
.stock-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
}

.summary-pill {
  padding: 0 16px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(270px, 360px) minmax(0, 1fr);
  gap: 24px;
  width: min(1180px, calc(100% - 36px));
  margin: 28px auto 56px;
  align-items: start;
}

.panel,
.product-card,
.empty-state,
.scan-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.create-panel {
  padding: 22px;
  position: sticky;
  top: 118px;
}

.create-panel h2,
.section-heading h2 {
  font-size: 1.15rem;
}

.product-form {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.product-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.product-form input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfdfc;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

.product-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(18, 108, 90, 0.14);
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 7px;
  padding: 0 14px;
  border: 1px solid transparent;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

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

.primary-button:hover {
  background: var(--primary-strong);
  transform: translateY(-1px);
}

.primary-button:disabled {
  background: #a6b7b2;
  cursor: not-allowed;
  transform: none;
}

.secondary-button {
  background: #fbfdfc;
  border-color: var(--line);
  color: var(--ink);
}

.secondary-button:hover {
  border-color: #b8c7c2;
  transform: translateY(-1px);
}

.as-link {
  width: fit-content;
}

.form-status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.form-status[data-tone="success"] {
  color: var(--primary-strong);
}

.form-status[data-tone="error"] {
  color: #9a2b2b;
}

.inventory-section {
  min-width: 0;
}

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

.filter-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
}

.search-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.search-field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfdfc;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

.search-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(18, 108, 90, 0.14);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.product-card {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.product-info {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.product-info h3 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.product-info p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.stock-badge {
  flex: 0 0 auto;
  min-width: 92px;
  padding: 0 12px;
  color: var(--primary-strong);
  background: #ebf7f3;
  border-color: #c8e7df;
}

.product-card[data-empty="true"] .stock-badge {
  background: var(--warning-bg);
  border-color: #f3d59c;
  color: var(--warning-ink);
}

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

.stock-button {
  display: inline-grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfdfc;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.35rem;
  font-weight: 850;
  line-height: 1;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.stock-button:hover {
  border-color: #b8c7c2;
  transform: translateY(-1px);
}

.stock-button:disabled {
  color: #9aaaa5;
  cursor: not-allowed;
  transform: none;
}

.stock-set-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.stock-set-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.stock-set-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfdfc;
  color: var(--ink);
  padding: 8px 10px;
  outline: none;
}

.stock-set-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(18, 108, 90, 0.14);
}

.stock-set-form .secondary-button {
  align-self: end;
}

.qr-button {
  width: 100%;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  color: var(--muted);
}

.empty-state h3 {
  margin: 0;
  font-size: 1rem;
}

.scan-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.scan-shell {
  width: min(460px, 100%);
}

.scan-panel {
  display: grid;
  gap: 22px;
  padding: clamp(24px, 6vw, 36px);
}

.scan-panel h1 {
  font-size: clamp(2rem, 8vw, 3.3rem);
  overflow-wrap: anywhere;
}

.scan-result {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 0;
}

.scan-result div {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 14px;
  background: #fbfdfc;
}

.scan-result dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.scan-result dd {
  margin: 7px 0 0;
  font-size: 1.6rem;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.scan-status {
  margin: 0;
  color: var(--primary-strong);
  font-weight: 750;
}

.secondary-link {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.qr-dialog {
  width: min(430px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 22px;
}

.qr-dialog::backdrop {
  background: rgba(20, 33, 31, 0.36);
}

.dialog-close-form {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 8px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfdfc;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
}

.print-label {
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
}

.print-label h2 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.qr-sku {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.print-label img {
  width: min(280px, 100%);
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  padding: 12px;
}

.dialog-actions {
  display: grid;
  margin-top: 18px;
}

@media (max-width: 780px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .create-panel {
    position: static;
  }
}

@media (max-width: 420px) {
  .section-heading,
  .filter-bar,
  .product-info {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-bar {
    grid-template-columns: 1fr;
  }

  .scan-result {
    grid-template-columns: 1fr;
  }

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

@media print {
  body > *:not(.qr-dialog) {
    display: none !important;
  }

  .qr-dialog {
    display: block !important;
    position: static;
    width: 100%;
    max-width: none;
    border: 0;
    box-shadow: none;
    padding: 0;
  }

  .dialog-close-form,
  .dialog-actions {
    display: none !important;
  }

  .print-label {
    min-height: 100vh;
    align-content: center;
  }

  .print-label img {
    width: 72mm;
    border: 0;
  }
}
