:root {
  color-scheme: dark;
  --page: #151019;
  --panel: #221b28;
  --panel-soft: #2b2331;
  --line: #6f6278;
  --line-soft: rgba(223, 197, 150, 0.2);
  --gold: #dfbd70;
  --cream: #fff3d8;
  --muted: #d7cade;
  --purple: #5c3f87;
  --green: #71b96b;
  --danger: #d85f68;
}

body {
  background:
    radial-gradient(circle at top right, rgba(100, 63, 143, 0.22), transparent 32rem),
    var(--page);
  color: var(--cream);
  font-family: Arial, Helvetica, sans-serif;
  margin: 0;
  min-height: 100vh;
}

body[data-theme="light"] {
  --page: #f4ecdc;
  --panel: #fffaf0;
  --panel-soft: #f0e2c8;
  --line: #b79b6d;
  --line-soft: rgba(117, 84, 44, 0.18);
  --cream: #241c21;
  --muted: #594d57;
}

main {
  display: grid;
  gap: 22px;
  margin: 0 auto;
  max-width: 1120px;
  padding: 18px 18px 42px;
}

footer {
  color: var(--muted);
  font-size: 12px;
  padding: 10px 18px 28px;
  text-align: center;
}

.tool-hero,
.panel {
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tool-hero {
  padding: clamp(24px, 5vw, 46px);
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1,
h2 {
  color: var(--gold);
  line-height: 1;
  margin: 0;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.45);
}

h1 {
  font-size: clamp(44px, 8vw, 78px);
  margin-top: 8px;
}

h2 {
  font-size: 30px;
}

p {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.45;
}

.shopping-layout {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) 330px;
}

.side-stack {
  display: grid;
  gap: 18px;
}

.panel {
  padding: 18px;
}

.collapsible-panel {
  padding: 0;
}

.collapsible-panel summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  list-style: none;
  padding: 18px;
}

.collapsible-panel summary::-webkit-details-marker {
  display: none;
}

.collapsible-panel summary::after {
  color: var(--gold);
  content: "Open";
  font-size: 13px;
  font-weight: 900;
}

.collapsible-panel[open] summary::after {
  content: "Close";
}

.collapsible-panel summary span {
  display: grid;
  gap: 5px;
}

.collapsible-panel summary small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.panel-title {
  align-items: start;
  display: flex;
  gap: 14px;
  justify-content: space-between;
}

.panel-title p,
.panel-help {
  margin: 7px 0 0;
}

button,
input {
  background: #1b1620;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--cream);
  font: inherit;
}

button {
  cursor: pointer;
  font-weight: 900;
  min-height: 42px;
  padding: 0 13px;
}

button:hover {
  border-color: var(--gold);
}

input {
  box-sizing: border-box;
  min-height: 42px;
  padding: 8px 10px;
  width: 100%;
}

.quick-add {
  display: grid;
  gap: 8px;
  margin: 18px 0;
}

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

.search-wrap {
  position: relative;
}

.search-results {
  background: var(--panel);
  border: 1px solid var(--gold);
  border-radius: 8px;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.35);
  display: grid;
  gap: 4px;
  left: 0;
  max-height: 330px;
  overflow: auto;
  padding: 8px;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
}

.search-results button {
  align-items: center;
  background: transparent;
  border: 0;
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  min-height: 48px;
  text-align: left;
}

.search-results button:hover {
  background: var(--panel-soft);
}

.shopping-rows {
  display: grid;
  gap: 10px;
}

.shopping-row {
  align-items: center;
  background: #1b1620;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(170px, 1fr) 92px 104px 92px 112px auto;
  padding: 10px;
}

.item-name {
  align-items: center;
  display: flex;
  gap: 10px;
  min-width: 0;
}

.item-name img,
.search-results img {
  height: 38px;
  object-fit: contain;
  width: 38px;
}

.item-name span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.item-name strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-name small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.truck-heading {
  align-items: center;
  display: flex;
  gap: 12px;
}

.truck-heading img {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  height: 52px;
  object-fit: contain;
  padding: 6px;
  width: 52px;
}

.check-row {
  align-items: center;
  background: #1b1620;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  margin-top: 12px;
  min-height: 42px;
  padding: 0 12px;
}

.check-row input {
  accent-color: var(--gold);
  min-height: 0;
  width: auto;
}

.row-total {
  color: var(--gold);
  font-size: 20px;
  font-weight: 900;
  text-align: right;
}

.coin-input {
  align-items: stretch;
  display: flex;
}

.coin-input input {
  border-radius: 6px 0 0 6px;
}

.coin-input span {
  align-items: center;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 6px 6px 0;
  color: var(--gold);
  display: inline-flex;
  font-size: 12px;
  font-weight: 900;
  padding: 0 8px;
  text-transform: uppercase;
}

.remove-row {
  background: transparent;
  color: var(--muted);
  min-width: 42px;
  padding: 0;
}

.field-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.inventory-rows {
  border-top: 1px solid var(--line-soft);
  display: grid;
  gap: 9px;
  padding: 14px 18px 18px;
}

.inventory-row {
  align-items: center;
  background: #1b1620;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 34px minmax(0, 1fr) 78px;
  min-height: 58px;
  padding: 8px;
}

.inventory-row img {
  height: 34px;
  object-fit: contain;
  width: 34px;
}

.inventory-row span {
  color: var(--cream);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-row input {
  min-height: 36px;
  padding: 6px 8px;
  text-align: center;
}

.wide-button,
.export-actions button {
  background: var(--purple);
  border-color: #8b68bb;
  margin-top: 12px;
  width: 100%;
}

.export-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  padding: 22px;
  text-align: center;
}

.empty-state.compact {
  padding: 14px;
}

@media (max-width: 960px) {
  .shopping-layout {
    grid-template-columns: 1fr;
  }

  .side-stack {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .shopping-row {
    grid-template-columns: minmax(160px, 1fr) repeat(3, 86px) 96px auto;
  }
}

@media (max-width: 760px) {
  main {
    padding-inline: 12px;
  }

  .side-stack,
  .field-grid,
  .export-actions {
    grid-template-columns: 1fr;
  }

  .shopping-row {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .item-name {
    grid-column: 1 / -1;
  }

  .row-total {
    text-align: left;
  }
}
