:root {
  color-scheme: light;
  --orange: #f3a15d;
  --orange-deep: #b85f22;
  --orange-soft: #fff0df;
  --peach: #ffe1bf;
  --ink: #3c2618;
  --muted: #866b58;
  --paper: #fffaf5;
  --surface: #ffffff;
  --surface-soft: #fff5ea;
  --line: #f2cfaa;
  --danger: #c84646;
  --shadow: 0 14px 34px rgba(184, 95, 34, 0.15);
}

* {
  box-sizing: border-box;
}

html {
  background: #fff0df;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, rgba(243, 161, 93, 0.26), rgba(255, 255, 255, 0) 230px),
    var(--paper);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

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

.app-shell {
  width: min(100%, 480px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px max(24px, env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 2px 14px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--orange-deep);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.summary-pill {
  min-width: 82px;
  padding: 10px 12px;
  border: 1px solid rgba(184, 95, 34, 0.18);
  border-radius: 8px;
  background: #ffffffdd;
  box-shadow: 0 8px 18px rgba(184, 95, 34, 0.1);
  text-align: center;
}

.summary-pill span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-pill strong {
  display: block;
  margin-top: 2px;
  font-size: 24px;
  color: var(--orange-deep);
}

.entry-panel,
.location-panel,
.tools-panel {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tools-panel {
  box-shadow: none;
}

.entry-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 2px solid #edc9a5;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fffdf9;
  color: var(--ink);
  font-size: 16px;
}

input,
select {
  min-height: 46px;
}

textarea {
  min-height: 62px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--orange);
  outline: 3px solid rgba(243, 161, 93, 0.22);
}

.primary-button,
.ghost-button,
.delete-button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  font-weight: 900;
}

.primary-button {
  width: 100%;
  background: var(--orange);
  color: #fff;
  box-shadow: 0 10px 18px rgba(184, 95, 34, 0.22);
}

.ghost-button {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--orange-deep);
}

.secondary-action {
  margin-top: 8px;
}

.delete-button {
  border: 1px solid rgba(200, 70, 70, 0.35);
  background: #fff3f3;
  color: var(--danger);
}

.small-delete {
  width: auto;
  min-height: 36px;
  padding: 8px 12px;
  font-size: 13px;
  justify-self: start;
}

.list-section {
  padding-bottom: 14px;
}

.empty-state {
  display: grid;
  gap: 6px;
  padding: 26px 14px;
  border: 2px dashed #edc9a5;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
  font-size: 18px;
}

.inventory-groups {
  display: grid;
  gap: 16px;
}

.location-group {
  position: relative;
  padding: 22px 10px 10px;
  border: 2px solid var(--orange);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
}

.location-title-button {
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  max-width: calc(100% - 40px);
  padding: 4px 14px;
  border-radius: 8px;
  background: var(--orange);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 0;
}

.inventory-list {
  display: grid;
  gap: 10px;
}

.inventory-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 136px;
  gap: 10px;
  width: 100%;
  min-height: 96px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--orange);
  border-radius: 8px;
  padding: 11px 10px;
  background: var(--surface);
  box-shadow: 0 8px 18px rgba(184, 95, 34, 0.1);
  color: var(--ink);
  text-align: left;
  touch-action: manipulation;
}

.inventory-card.checked {
  border-left-color: var(--orange-deep);
  background: var(--peach);
  color: var(--ink);
}

.inventory-card.reordering {
  border-color: var(--orange);
  background: var(--orange-soft);
  box-shadow: 0 0 0 3px rgba(243, 161, 93, 0.2), 0 8px 18px rgba(184, 95, 34, 0.1);
}

.item-main {
  min-width: 0;
}

.item-name {
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 18px;
  font-weight: 900;
}

.item-subline {
  display: block;
  min-height: 20px;
  margin-top: 6px;
  color: var(--orange-deep);
  font-size: 14px;
  font-weight: 800;
}

.item-subline.muted {
  color: var(--muted);
  font-weight: 700;
}

.item-side {
  display: grid;
  grid-template-columns: 1fr 1fr 38px;
  gap: 5px;
  align-content: center;
}

.count-box {
  display: grid;
  place-items: center;
  min-height: 66px;
  grid-template-rows: auto 1fr auto;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--orange-deep);
  padding: 5px 2px;
}

.count-box span {
  font-size: 12px;
  font-weight: 900;
}

.count-box strong {
  font-size: 16px;
  font-weight: 900;
  word-break: break-all;
}

.count-box small {
  max-width: 100%;
  font-size: clamp(8px, 2.4vw, 11px);
  font-weight: 900;
  line-height: 1.05;
  overflow-wrap: anywhere;
  text-align: center;
}

.stock-box {
  border: 2px solid var(--orange);
  background: #fff;
}

.check-button {
  display: grid;
  place-items: center;
  width: 38px;
  min-height: 66px;
  border: 2px solid var(--orange);
  border-radius: 8px;
  background: #fff;
  color: var(--orange-deep);
  font-size: 24px;
  font-weight: 900;
}

.inventory-card.checked .check-button {
  background: var(--orange-deep);
  border-color: var(--orange-deep);
  color: white;
}

.reorder-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

.move-button {
  display: grid;
  place-items: center;
  min-height: 44px;
  border-radius: 8px;
  background: white;
  color: var(--orange-deep);
  font-weight: 900;
}

.move-button.done {
  background: var(--orange);
  color: white;
}

.editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  background: rgba(58, 32, 14, 0.45);
}

.editor-overlay.hidden,
.hidden {
  display: none;
}

.editor-sheet,
.stock-sheet {
  width: min(100%, 440px);
  max-height: calc(100vh - 28px);
  overflow: auto;
  padding: 16px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
}

.editor-heading,
.editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.editor-heading {
  margin-bottom: 12px;
}

.editor-heading h2 {
  margin: 0;
  font-size: 22px;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--orange-deep);
  font-size: 28px;
  line-height: 1;
}

.editor-actions {
  margin: 4px 0 10px;
}

.stock-item-name {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
}

.stock-stepper {
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  gap: 10px;
  align-items: center;
}

.stock-stepper button {
  min-height: 64px;
  border: 0;
  border-radius: 8px;
  background: var(--orange);
  color: white;
  font-size: 32px;
  font-weight: 900;
}

.stock-stepper input {
  min-height: 64px;
  text-align: center;
  font-size: 28px;
  font-weight: 900;
}

.stock-unit-label {
  margin: 10px 0 16px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.location-order-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.location-order-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--orange);
  border-radius: 8px;
  background: var(--surface-soft);
}

.location-order-item strong,
.location-order-item small {
  display: block;
  overflow-wrap: anywhere;
}

.location-order-item small {
  margin-top: 3px;
  color: var(--muted);
  font-weight: 800;
}

.location-order-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.location-order-actions button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--orange);
  color: white;
  font-weight: 900;
}

.location-order-actions button:disabled {
  opacity: 0.35;
}

@media (max-width: 380px) {
  .app-shell {
    padding-left: 10px;
    padding-right: 10px;
  }

  h1 {
    font-size: 25px;
  }

  .inventory-card {
    grid-template-columns: minmax(0, 1fr) 128px;
  }
}
