:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  background: #f5f7f8;
  color: #182126;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f5f7f8;
}

button,
input {
  font: inherit;
}

.shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid #d8e0e4;
  border-radius: 8px;
  background: #ffffff;
}

.label,
.field span,
.group-head,
.history-head {
  display: block;
  margin-bottom: 8px;
  color: #5b6970;
  font-size: 14px;
  font-weight: 700;
}

#activePallet {
  display: block;
  font-size: 30px;
  line-height: 1.1;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

button {
  min-height: 48px;
  border: 1px solid #1f6b5b;
  border-radius: 8px;
  padding: 0 16px;
  background: #227864;
  color: #ffffff;
  cursor: pointer;
  font-weight: 800;
}

button:focus,
input:focus {
  outline: 3px solid #f5c84c;
  outline-offset: 2px;
}

.secondary {
  border-color: #b9c5ca;
  background: #ffffff;
  color: #182126;
}

.primary {
  flex: 1;
  min-height: 60px;
  font-size: 20px;
}

.status {
  margin: 12px 0;
  min-height: 48px;
  padding: 14px 16px;
  border-radius: 8px;
  background: #eaf3ef;
  color: #145344;
  font-weight: 800;
}

.status.error {
  background: #ffe8e2;
  color: #9b2c16;
}

.status.pending {
  background: #fff3ce;
  color: #654b00;
}

.panel,
.history {
  border: 1px solid #d8e0e4;
  border-radius: 8px;
  background: #ffffff;
  padding: 16px;
}

.group + .group,
.field-grid,
.photo-group,
.scan-field,
.actions,
.settings {
  margin-top: 18px;
}

.photo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.photo-head strong {
  color: #145344;
}

.photo-actions {
  display: flex;
  gap: 8px;
}

.camera-button {
  display: inline-flex;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  border: 1px solid #1f6b5b;
  border-radius: 8px;
  padding: 0 18px;
  background: #227864;
  color: #ffffff;
  cursor: pointer;
  font-weight: 800;
}

.camera-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.photo-preview {
  display: grid;
  margin-top: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.photo-tile {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  border: 1px solid #d8e0e4;
  border-radius: 8px;
  background: #edf1f3;
}

.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 36px;
  min-height: 36px;
  border-color: #ffffff;
  padding: 0;
  background: #9b2c16;
  color: #ffffff;
  font-size: 20px;
  line-height: 1;
}

.segments {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.segments.compact {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.segment {
  min-height: 64px;
  border-color: #c7d1d5;
  background: #f8fafb;
  color: #1f2a30;
  font-size: 18px;
}

.segment.active {
  border-color: #145344;
  background: #145344;
  color: #ffffff;
}

.segment.parcel {
  display: flex;
  min-height: 72px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  line-height: 1.05;
}

.segment.parcel strong {
  font-size: 24px;
}

.segment.parcel span {
  font-size: 13px;
  font-weight: 800;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 12px;
}

.field input {
  width: 100%;
  height: 58px;
  border: 1px solid #b9c5ca;
  border-radius: 8px;
  padding: 0 14px;
  background: #ffffff;
  color: #182126;
  font-size: 22px;
  font-weight: 700;
}

.scan-field input {
  height: 72px;
  font-size: 28px;
}

.alternate-ean {
  padding-top: 18px;
  border-top: 1px solid #d8e0e4;
}

.alternate-ean span {
  color: #9b2c16;
}

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

.stepper input {
  text-align: center;
}

.stepper button {
  padding: 0;
  font-size: 26px;
}

.actions {
  display: flex;
  gap: 10px;
}

.settings {
  padding-top: 18px;
  border-top: 1px solid #e3e8eb;
}

.history {
  margin-top: 14px;
}

.history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.link-button {
  min-height: 34px;
  border: 0;
  background: transparent;
  color: #1f6b5b;
  padding: 0;
}

#historyList {
  margin: 0;
  padding-left: 24px;
}

#historyList li {
  padding: 8px 0;
  border-top: 1px solid #edf1f3;
}

@media (max-width: 620px) {
  .shell {
    padding: 10px;
  }

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

  .topbar-actions,
  .actions,
  .photo-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

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

  .segments,
  .segments.compact {
    grid-template-columns: 1fr;
  }

  .segments.compact {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
