:root {
  --ink: #17211f;
  --muted: #64716c;
  --line: #dde4de;
  --paper: #f6f3eb;
  --panel: #ffffff;
  --wash: #eef5ef;
  --green: #17684e;
  --green-dark: #124536;
  --gold: #c8892e;
  --red: #b84a35;
  --blue: #2e6689;
  --shadow: 0 14px 34px rgba(18, 69, 54, 0.12);
  --radius: 8px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--green-dark);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, var(--green-dark) 0, #1f6f55 260px, var(--paper) 260px);
}

button,
input {
  font: inherit;
}

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

.topbar,
.pane-header,
.actions,
.basket-totals,
.result-head,
.price-row,
.phone-panel,
.progress-copy {
  display: flex;
}

.topbar {
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  min-height: 160px;
  padding: 16px 0 24px;
  color: #fff;
}

.eyebrow {
  margin: 0 0 8px;
  color: #bfe7d4;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 10px;
  font-size: clamp(2.25rem, 5vw, 4.8rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.subhead {
  max-width: 620px;
  margin-bottom: 0;
  color: #e6f3eb;
  font-size: 1rem;
  line-height: 1.5;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 16px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

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

button.primary {
  border-color: #f3f0e8;
  background: #f3f0e8;
  color: var(--green-dark);
}

button.ghost {
  background: rgba(255, 255, 255, 0.92);
}

button.compact {
  min-height: 34px;
  padding: 0 12px;
}

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

.actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: -56px 0 14px;
}

.summary-panel,
.settings-pane,
.basket-pane,
.results-pane,
.phone-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.summary-panel {
  min-height: 92px;
  padding: 18px;
}

.summary-panel span,
.phone-panel span,
.results-pane .pane-header span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.summary-panel strong,
.phone-panel strong {
  display: block;
  margin-top: 8px;
  font-size: 1.28rem;
}

.catalogue-pane {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.catalogue-subhead {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.catalogue-search-row {
  display: flex;
  gap: 10px;
}

.catalogue-status {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

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

.catalogue-store-result {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 108px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #fff;
}

.catalogue-store-result.best-price-result {
  border-color: #39a96b;
  background: #f0faf4;
  box-shadow: 0 0 0 1px rgba(57, 169, 107, 0.16);
}

.best-price-badge {
  display: inline-block !important;
  width: fit-content;
  margin: 0 0 6px !important;
  border-radius: 999px;
  padding: 4px 8px;
  background: #16864b;
  color: #fff !important;
  font-size: 0.7rem !important;
  font-weight: 900 !important;
  line-height: 1 !important;
}

.catalogue-image,
.catalogue-image img,
.catalogue-image-placeholder {
  width: 76px;
  height: 76px;
}

.catalogue-image img {
  display: block;
  border-radius: 7px;
  background: var(--paper);
  object-fit: contain;
}

.catalogue-image-placeholder {
  display: grid;
  place-items: center;
  border-radius: 7px;
  padding: 8px;
  background: var(--paper);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
}

.catalogue-product-copy {
  min-width: 0;
}

.catalogue-product-copy strong,
.catalogue-product-copy span,
.catalogue-product-copy small,
.catalogue-product-copy a {
  display: block;
}

.catalogue-product-copy strong {
  color: var(--green-dark);
  font-size: 0.82rem;
}

.catalogue-product-copy span {
  margin-top: 4px;
  font-weight: 800;
  line-height: 1.25;
}

.catalogue-product-copy small,
.catalogue-product-copy a {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.3;
}

.catalogue-product-copy a {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.catalogue-special {
  color: var(--red) !important;
  font-weight: 800;
}

.catalogue-price {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
  min-width: 82px;
  text-align: right;
}

.catalogue-add-btn {
  margin-top: 8px;
  padding: 7px 9px;
  white-space: nowrap;
}

.catalogue-price strong {
  display: block;
  color: var(--ink);
  font-size: 1.03rem;
}

.catalogue-price .catalogue-unit-price {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  white-space: nowrap;
}

.best-price-result .catalogue-unit-price {
  color: #117a43;
}

.best-price-result .catalogue-price strong {
  color: #117a43;
  font-size: 1.12rem;
}

.best-price-result .catalogue-add-btn {
  border-color: #16864b;
  background: #16864b;
  color: #fff;
}

.catalogue-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.catalogue-pagination span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.muted-result {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

@media (max-width: 1080px) {
  .catalogue-results {
    grid-template-columns: 1fr;
  }
}

.phone-panel {
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding: 14px 16px;
}

.phone-panel strong {
  color: var(--green-dark);
  font-size: 0.98rem;
  overflow-wrap: anywhere;
}

.workspace {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 14px;
  align-items: start;
  min-width: 0;
}

.settings-pane,
.basket-pane,
.results-pane {
  padding: 16px;
}

.basket-pane {
  min-width: 0;
}

.pane-header {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.results-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
}

input:focus {
  border-color: var(--green);
  outline: 3px solid rgba(23, 104, 78, 0.14);
}

fieldset {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

legend {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.store-toggles {
  display: grid;
  gap: 8px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 700;
}

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

.source-note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.table-wrap {
  max-width: 100%;
  overflow-x: hidden;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 7px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
}

th:first-child,
td.item-name {
  width: 46%;
}

th:nth-child(2),
td.basket-store-cell {
  width: 20%;
}

th:nth-child(3),
td.basket-price-cell {
  width: 14%;
}

th:nth-child(4),
td.quantity {
  width: 10%;
}

th:last-child,
td.remove {
  width: 10%;
}

.basket-product strong,
.basket-product span {
  display: block;
}

.basket-product strong {
  overflow-wrap: anywhere;
  line-height: 1.3;
}

.basket-product span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.basket-store {
  color: var(--green-dark);
  font-size: 0.86rem;
  font-weight: 800;
}

.basket-price {
  color: var(--green-dark);
  white-space: nowrap;
}

td.quantity input {
  min-width: 58px;
}

td.remove {
  text-align: right;
}

.remove button {
  color: var(--red);
}

.results-pane {
  margin-top: 14px;
}

.basket-totals {
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.scan-progress {
  margin: -2px 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--wash);
}

.scan-progress[hidden] {
  display: none;
}

.progress-copy {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--green-dark);
  font-size: 0.85rem;
}

.progress-copy span {
  color: var(--muted);
  font-weight: 800;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe8e2;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--gold));
  transition: width 0.35s ease;
}

.total-chip {
  min-width: 170px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #fff;
}

.total-chip.best {
  border-color: var(--green);
  background: var(--wash);
}

.total-chip span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.total-chip strong {
  display: block;
  margin-top: 4px;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #fff;
}

.result-head {
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.result-head h3 {
  margin-bottom: 4px;
}

.badge {
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--wash);
  color: var(--green-dark);
  font-size: 0.75rem;
  font-weight: 900;
  white-space: nowrap;
}

.price-row {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 11px 0;
}

.price-row:first-of-type {
  border-top: 0;
}

.price-row.best {
  color: var(--green-dark);
  font-weight: 800;
}

.price-row small {
  display: block;
  color: var(--muted);
  font-weight: 500;
}

.price-row .deal-line {
  margin-top: 4px;
  font-weight: 800;
}

.price-row .deal-line.applied {
  color: var(--green-dark);
}

.price-row .deal-line.note {
  color: var(--gold);
}

.supplier-result {
  min-width: 0;
}

.direct-url {
  display: block;
  margin-top: 4px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.direct-url:hover {
  text-decoration: underline;
}

.direct-url.muted {
  color: var(--muted);
  font-weight: 600;
}

.price {
  text-align: right;
  white-space: nowrap;
  font-weight: 900;
}

.was-price {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: line-through;
}

.status {
  color: var(--muted);
  font-size: 0.84rem;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 920px) {
  .app-shell {
    width: min(100% - 20px, 780px);
    padding-top: 12px;
  }

  .topbar {
    display: grid;
    min-height: 0;
    padding-bottom: 76px;
  }

  .actions {
    justify-content: stretch;
  }

  .actions button {
    flex: 1 1 140px;
  }

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

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

  .phone-panel {
    display: grid;
  }
}

@media (max-width: 680px) {
  body {
    background:
      linear-gradient(180deg, var(--green-dark) 0, #1f6f55 300px, var(--paper) 300px);
  }

  .app-shell {
    width: min(100% - 16px, 520px);
    padding-bottom: 92px;
  }

  h1 {
    font-size: 2.45rem;
  }

  .summary-grid {
    margin-top: -48px;
  }

  .settings-pane,
  .basket-pane,
  .results-pane,
  .summary-panel,
  .phone-panel {
    padding: 14px;
  }

  .table-wrap {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
  }

  thead {
    display: none;
  }

  tr {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px;
    background: #fff;
  }

  td {
    width: 100% !important;
    min-width: 0 !important;
    border: 0;
    padding: 7px 0;
  }

  td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
  }

  td.remove {
    text-align: left;
  }

  td.remove button {
    width: 100%;
  }

  .results-actions,
  .pane-header {
    align-items: stretch;
    display: grid;
  }

  .results-actions button,
  .phone-panel button {
    width: 100%;
  }

  .basket-totals,
  .results-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .catalogue-pane {
    padding: 14px;
  }

  .catalogue-store-result {
    grid-template-columns: 64px minmax(0, 1fr);
    min-height: 92px;
  }

  .catalogue-price {
    grid-column: 2;
    align-items: center;
    flex-flow: row wrap;
    gap: 8px;
    text-align: left;
  }

  .catalogue-add-btn {
    margin-top: 0;
  }

  .catalogue-image,
  .catalogue-image img,
  .catalogue-image-placeholder {
    width: 64px;
    height: 64px;
  }

  .price-row {
    align-items: flex-start;
  }

  .direct-url {
    display: none;
  }
}

