:root {
  --blue: #1683c5;
  --blue-dark: #063f52;
  --green: #38b449;
  --green-dark: #248334;
  --page: #f4f8fb;
  --card: #ffffff;
  --text: #12333f;
  --muted: #5f7480;
  --border: #d9e7ee;
  --danger: #b42318;
  --success: #16753a;
  --shadow: 0 8px 22px rgba(8, 64, 82, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

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

.brand-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
}

.brand-logo {
  width: 50px;
  height: 50px;
  object-fit: contain;
  background: #fff;
  border-radius: 12px;
  padding: 4px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--green-dark);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: var(--blue-dark);
}

h1 {
  font-size: 1.08rem;
  line-height: 1.2;
}

.panel,
.warning-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}

.warning-panel {
  border-color: #f5c36b;
  background: #fff8e8;
  color: #6f4b00;
  font-weight: 700;
}

.stack {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

label {
  display: block;
  color: var(--blue-dark);
  font-size: 0.86rem;
  font-weight: 700;
  margin: 6px 0 4px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 1rem;
  padding: 9px 10px;
}

input:focus,
select:focus,
button:focus {
  outline: 3px solid rgba(22, 131, 197, 0.22);
  outline-offset: 2px;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 800;
}

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

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

.secondary-button,
.ghost-button {
  background: #e8f4fa;
  color: var(--blue-dark);
}

.scan-button {
  background: var(--blue);
  color: #fff;
}

.app-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.app-title-row h2 {
  font-size: 1rem;
}

.app-title-row .ghost-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.mode-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
  margin-top: 8px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.segment {
  min-height: 42px;
  background: #e8f4fa;
  color: var(--blue-dark);
}

.segment.active {
  background: var(--blue);
  color: #fff;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fcfe;
  margin: 0;
  white-space: nowrap;
}

.toggle-row input {
  width: 20px;
  min-height: 20px;
}

.progress-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}

.progress-card {
  min-height: 40px;
  border-radius: 10px;
  background: #f0f8f3;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.progress-label {
  color: var(--muted);
  font-size: 0.78rem;
}

.progress-value {
  color: var(--blue-dark);
  font-size: 1.05rem;
  font-weight: 800;
}

.product-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
}

.image-wrap {
  width: 112px;
  height: 112px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 10px;
  background: #f8fcfe;
  overflow: hidden;
}

.product-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
}

.image-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
  padding: 10px;
  background: #f8fcfe;
  font-size: 0.78rem;
}

.product-details {
  min-width: 0;
}

.product-code {
  display: inline-block;
  margin: 0 0 5px;
  padding: 5px 8px;
  border-radius: 999px;
  background: #e8f4fa;
  color: var(--blue-dark);
  font-weight: 800;
}

.product-title {
  margin-bottom: 6px;
  font-size: 0.98rem;
  line-height: 1.22;
  max-height: 2.45em;
  overflow: hidden;
}

.scanner-action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 8px;
}

.scanner-panel {
  position: relative;
  display: block;
  padding: 0;
  overflow: hidden;
}

#scannerVideo {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: block;
  background: #071f27;
  border-radius: 12px;
  object-fit: cover;
}

.scanner-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #c6d9df;
  font-weight: 800;
  pointer-events: none;
}

.scanner-panel.active .scanner-placeholder {
  display: none;
}

.action-stack {
  display: grid;
  grid-template-rows: 1fr 0.8fr 1fr;
  gap: 8px;
}

.action-stack button {
  height: 100%;
  min-height: 0;
  padding: 8px;
  font-size: 0.92rem;
}

.navigation-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.status-message {
  position: sticky;
  bottom: 8px;
  display: none;
  border-radius: 12px;
  padding: 12px;
  color: #fff;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.status-message.show {
  display: block;
}

.status-message.info {
  background: var(--blue-dark);
}

.status-message.success {
  background: var(--success);
}

.status-message.error {
  background: var(--danger);
}

.hidden {
  display: none !important;
}

@media (min-width: 640px) {
  .app-shell {
    padding: 16px;
  }

  h1 {
    font-size: 1.35rem;
  }

  .product-row {
    grid-template-columns: 150px minmax(0, 1fr);
  }

  .image-wrap {
    width: 150px;
    height: 150px;
  }

  .scanner-action-row {
    grid-template-columns: minmax(0, 1fr) 150px;
  }
}
