:root {
  color-scheme: light;
  --ink: #17211e;
  --muted: #5f6b67;
  --paper: #f4f5f2;
  --surface: #ffffff;
  --surface-soft: #f8faf7;
  --line: #d8ded8;
  --line-strong: #bac6bf;
  --accent: #0b6b58;
  --accent-soft: #e1f0eb;
  --danger: #9b2f24;
  --danger-soft: #f8e5e1;
  --warning: #7a5a13;
  --warning-soft: #f6edcf;
  --success-soft: #dff2e9;
  --shadow: 0 12px 34px rgb(23 33 30 / 10%);
}

* {
  box-sizing: border-box;
}

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

.shell {
  width: min(100%, 920px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 40px 20px;
  display: grid;
  place-items: center;
}

.shell-workspace {
  width: min(100%, 1180px);
  align-items: start;
  place-items: start stretch;
}

.shell-narrow {
  width: min(100%, 560px);
}

.panel,
.workspace {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: clamp(28px, 5vw, 56px);
}

.workspace {
  padding: clamp(18px, 3vw, 32px);
}

.kicker {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 6px 0 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
  letter-spacing: 0;
}

.panel h1 {
  font-size: clamp(40px, 7vw, 64px);
}

h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

.lead,
.note {
  max-width: 680px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.5;
}

.top-bar,
.section-header,
.user-bar {
  display: flex;
  align-items: center;
  gap: 16px;
}

.top-bar,
.section-header {
  justify-content: space-between;
}

.top-bar {
  margin-bottom: 24px;
}

.user-bar {
  flex-wrap: wrap;
  justify-content: flex-end;
}

#user-status {
  max-width: 320px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.mode-tab {
  min-width: 0;
  min-height: 48px;
  border-color: var(--line-strong);
  background: #fff;
  color: var(--ink);
  white-space: normal;
}

.mode-tab:hover:not(:disabled) {
  background: var(--surface-soft);
}

.mode-tab.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  opacity: 1;
}

.scan-board {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.scan-board.is-busy {
  border-color: #d6ba55;
  background: #fbf7e8;
}

.field-group {
  min-width: 0;
  display: grid;
  gap: 7px;
}

label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-width: 0;
  height: 52px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgb(11 107 88 / 22%);
  outline-offset: 2px;
}

input::placeholder {
  color: #6b7973;
}

input[readonly] {
  background: #eef2ef;
  color: var(--muted);
  cursor: wait;
}

button,
.button-link {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  white-space: nowrap;
}

button:hover:not(:disabled),
.button-link:hover {
  background: #085746;
}

button:disabled {
  cursor: default;
  opacity: 0.62;
}

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

.button-secondary:hover:not(:disabled),
.button-link.button-secondary:hover {
  background: var(--surface-soft);
}

.operation-status {
  min-height: 48px;
  margin: 14px 0 24px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.operation-status.success {
  border-color: #9cccb9;
  background: var(--success-soft);
  color: #155642;
}

.operation-status.error {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
  box-shadow: inset 0 0 0 2px rgb(155 47 36 / 16%);
}

.operation-status.pending {
  border-color: #dfcb88;
  background: var(--warning-soft);
  color: var(--warning);
}

.scan-log {
  display: grid;
  gap: 12px;
}

.scan-panel[hidden] {
  display: none;
}

.table-wrap {
  position: relative;
  min-height: 180px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  font-size: 15px;
  line-height: 1.35;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.gtin-cell {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  white-space: nowrap;
}

.empty-state {
  margin: 0;
  padding: 26px 14px;
  color: var(--muted);
  font-weight: 700;
}

.empty-state[hidden] {
  display: none;
}

.login-form {
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

.login-form button {
  margin-top: 10px;
}

.form-message {
  min-height: 24px;
  margin: 4px 0 0;
  color: var(--danger);
  font-weight: 800;
}

@media (max-width: 820px) {
  .shell {
    padding: 16px;
    align-items: start;
  }

  .top-bar,
  .section-header {
    align-items: stretch;
    flex-direction: column;
  }

  .user-bar {
    justify-content: space-between;
  }

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

  .mode-tabs {
    grid-template-columns: 1fr;
  }

  .scan-board button {
    width: 100%;
  }

  .lead,
  .note {
    font-size: 16px;
  }
}

@media (max-width: 520px) {
  .panel,
  .workspace {
    padding: 18px;
  }

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

  .button-secondary,
  #logout-button {
    width: 100%;
  }
}
