:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #617080;
  --line: #dbe2ea;
  --accent: #126a6f;
  --accent-dark: #0d5257;
  --danger: #b42318;
  --success: #137333;
}

* {
  box-sizing: border-box;
}

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

[hidden] {
  display: none !important;
}

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

.login-shell {
  align-items: center;
  display: flex;
  min-height: 100vh;
  padding: 24px;
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0 auto;
  max-width: 420px;
  padding: 28px;
  width: 100%;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

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

.page-header {
  margin-bottom: 24px;
}

.header-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.user-summary {
  border-right: 1px solid var(--line);
  display: grid;
  gap: 2px;
  padding-right: 14px;
  text-align: right;
}

.user-summary span {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.user-summary strong {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  margin-bottom: 20px;
}

.summary-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px;
}

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

.summary-item strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.summary-warning strong {
  color: var(--danger);
}

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

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 20px;
}

h3 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
  min-height: 42px;
  padding: 0 16px;
}

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

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.secondary-button {
  background: #e9eef2;
  color: #263544;
}

.secondary-button:hover {
  background: #dbe4ea;
}

.scan-panel,
.data-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 20px;
  padding: 20px;
}

.scan-panel {
  display: grid;
  gap: 18px;
}

.scan-form {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) minmax(110px, 1fr) minmax(160px, 1fr) minmax(150px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.last-scan {
  border: 2px solid rgba(18, 106, 111, 0.35);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  padding: 16px;
}

.last-scan p {
  color: var(--muted);
  margin: 4px 0 0;
}

.last-scan-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
}

.last-scan-grid strong {
  display: block;
  font-size: 28px;
}

.last-scan.needs-review {
  border-color: #b7791f;
  background: #fff8e6;
}

.last-scan.negative-stock {
  border-color: var(--danger);
  background: #fff3f1;
}

.last-scan-notice {
  color: var(--danger) !important;
  font-weight: 800;
}

label {
  color: var(--muted);
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  background: #ffffff;
  border: 1px solid #c8d2dc;
  border-radius: 6px;
  color: var(--text);
  min-height: 42px;
  padding: 8px 10px;
  width: 100%;
}

input:focus,
select:focus,
button:focus {
  outline: 3px solid rgba(18, 106, 111, 0.22);
  outline-offset: 1px;
}

.status-text {
  color: var(--muted);
  min-height: 20px;
  margin: 8px 0 0;
}

.status-text.success {
  color: var(--success);
}

.status-text.error {
  color: var(--danger);
}

.count-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

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

table {
  border-collapse: collapse;
  width: 100%;
}

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

th {
  background: #eef3f6;
  color: #394958;
  font-size: 13px;
  font-weight: 800;
}

td {
  font-size: 14px;
}

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

.product-critical td {
  background: #fff3f1;
}

.stock-low {
  color: var(--danger);
  font-weight: 800;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 20px 0;
  }

  .page-header,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .user-summary {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0 0 10px;
    text-align: left;
  }

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

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

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

  button {
    width: 100%;
  }
}
