:root {
  color-scheme: light;
  --ink: #17201d;
  --muted: #64726d;
  --line: #dbe5df;
  --paper: #fffef9;
  --canvas: #f1f4ef;
  --green: #174d3c;
  --green-2: #2c725d;
  --mint: #dceee6;
  --amber: #f3bd56;
  --danger: #a33b36;
  --shadow: 0 18px 45px rgba(22, 47, 38, .08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button, summary, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.site-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 72px; padding: 10px clamp(16px, 4vw, 48px); background: rgba(241,244,239,.9); border-bottom: 1px solid rgba(219,229,223,.85); backdrop-filter: blur(16px); }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: var(--green); color: white; font-size: 21px; font-weight: 850; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: -.01em; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 11px; letter-spacing: .09em; text-transform: uppercase; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.status-pill { padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.7); color: var(--muted); font-size: 12px; }

main { width: min(1480px, 100%); margin: 0 auto; padding: clamp(18px, 3vw, 40px); }
.app-shell { display: grid; gap: 22px; }
.panel { background: var(--paper); border: 1px solid rgba(211,223,216,.9); border-radius: 22px; padding: clamp(18px, 2.5vw, 28px); box-shadow: var(--shadow); }
.hero { position: relative; overflow: hidden; display: flex; justify-content: space-between; gap: 28px; align-items: end; min-height: 230px; padding: clamp(26px, 5vw, 58px); background: var(--green); color: white; }
.hero::after { content: ""; position: absolute; width: 380px; height: 380px; right: -140px; top: -210px; border: 80px solid rgba(255,255,255,.07); border-radius: 50%; }
.hero > * { position: relative; z-index: 1; }
.hero h1 { max-width: 760px; margin: 8px 0 10px; font-size: clamp(34px, 6vw, 70px); line-height: .96; letter-spacing: -.055em; }
.hero p { max-width: 650px; margin: 0; color: rgba(255,255,255,.72); line-height: 1.55; }
.eyebrow { display: block; margin-bottom: 6px; color: var(--green-2); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.hero .eyebrow { color: #a9dcc8; }
.hero-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-stats div { min-width: 92px; padding: 14px 16px; border: 1px solid rgba(255,255,255,.16); border-radius: 15px; background: rgba(255,255,255,.08); }
.hero-stats strong, .hero-stats span { display: block; }
.hero-stats strong { font-size: 26px; }
.hero-stats span { color: rgba(255,255,255,.65); font-size: 11px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: 22px; align-items: start; }
.content-column, .sidebar { display: grid; gap: 22px; }
.sticky-card { position: sticky; top: 94px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 18px; }
h2 { margin: 0; font-size: clamp(22px, 3vw, 31px); letter-spacing: -.035em; }
p { line-height: 1.55; }

.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; border-radius: 12px; padding: 9px 14px; cursor: pointer; font-weight: 750; text-decoration: none; transition: transform .14s ease, background .14s ease, border-color .14s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .42; cursor: not-allowed; }
.button-primary { background: var(--green); color: white; }
.button-primary:hover:not(:disabled) { background: #0f3d2f; }
.button-secondary { border-color: var(--line); background: white; color: var(--green); }
.button-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.button-large { min-height: 52px; padding: 12px 19px; border-radius: 14px; }
.icon-button { width: 42px; height: 42px; border: 0; border-radius: 50%; background: #edf2ee; cursor: pointer; color: var(--ink); font-size: 26px; line-height: 1; }
.search-field { display: block; margin-bottom: 18px; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 11px; background: white; color: var(--ink); outline: none; }
input, select { min-height: 43px; padding: 9px 11px; }
textarea { padding: 13px; resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(44,114,93,.12); }
.search-field input { min-height: 48px; padding-left: 16px; background: #f7f9f6; }

.product-list { display: grid; gap: 11px; }
.product-card { display: grid; grid-template-columns: auto 72px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 17px; background: white; }
.product-select { width: 21px; height: 21px; accent-color: var(--green); }
.product-image { width: 72px; height: 72px; object-fit: contain; border-radius: 12px; background: #f3f5f1; }
.product-image-placeholder { display: grid; place-items: center; color: #91a098; font-weight: 800; }
.product-copy { min-width: 0; }
.product-copy h3 { margin: 0 0 5px; font-size: 16px; line-height: 1.3; }
.product-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--muted); font-size: 12px; }
.offer-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.offer-chip { display: inline-flex; gap: 5px; padding: 5px 8px; border-radius: 999px; background: #eef4f0; color: #315c4e; font-size: 11px; }
.offer-chip.stale { background: #f8efda; color: #745113; }
.price { min-width: 88px; text-align: right; }
.price strong, .price span { display: block; }
.price strong { font-size: 18px; }
.price span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.product-details { grid-column: 2 / -1; border-top: 1px solid #edf1ee; padding-top: 11px; }
.product-details summary { cursor: pointer; color: var(--green-2); font-size: 12px; font-weight: 750; }
.product-editor { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.product-editor label, .settings-form label, .retailer-form label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.product-editor .span-all { grid-column: 1 / -1; }
.offers-table { grid-column: 1 / -1; display: grid; gap: 7px; }
.offer-row { display: grid; grid-template-columns: 1fr 92px 92px auto; gap: 8px; align-items: end; padding: 9px; border-radius: 11px; background: #f7f9f6; }
.offer-row a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--green-2); font-size: 12px; }
.offer-row input { min-height: 38px; }

.selection-list { display: grid; gap: 8px; margin: 14px 0; }
.selection-item { display: grid; grid-template-columns: minmax(0, 1fr) 70px auto; gap: 8px; align-items: center; padding: 9px 0; border-bottom: 1px solid #edf1ee; }
.selection-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.selection-item input { min-height: 37px; text-align: center; }
.selection-item button { border: 0; background: transparent; color: var(--danger); cursor: pointer; font-size: 18px; }
.stack-actions { display: grid; gap: 8px; }
.settings-form { display: grid; gap: 11px; margin-top: 18px; }
.check-row { display: flex !important; align-items: center; gap: 9px !important; color: var(--ink) !important; }
.check-row input { width: 18px; min-height: 18px; accent-color: var(--green); }
details > summary { list-style: none; display: flex; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: "+"; margin-left: auto; font-size: 25px; color: var(--green-2); }
details[open] > summary::after { content: "−"; }
details > summary strong { font-size: 18px; }
.divider { height: 1px; margin: 22px 0; background: var(--line); }
.retailer-settings { display: grid; gap: 12px; }
.retailer-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; }
.retailer-form h3 { grid-column: 1 / -1; margin: 0 0 2px; font-size: 14px; }
.retailer-form button, .retailer-form .span-all { grid-column: 1 / -1; }
.saved-lists { display: grid; gap: 9px; }
.saved-list { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 14px; }
.saved-list strong, .saved-list small { display: block; }
.saved-list small { margin-top: 3px; color: var(--muted); }
.empty-state { padding: 28px 18px; border: 1px dashed #bdcbc4; border-radius: 15px; background: #f8faf7; color: var(--muted); text-align: center; }
.empty-state p { margin: 5px 0 0; }
.empty-state.compact { padding: 13px; }

.login-shell { min-height: calc(100vh - 150px); display: grid; place-items: center; }
.login-card { width: min(680px, 100%); padding: clamp(30px, 6vw, 72px); border: 1px solid var(--line); border-radius: 28px; background: var(--paper); box-shadow: var(--shadow); }
.login-card h1 { margin: 9px 0 18px; font-size: clamp(34px, 7vw, 66px); line-height: 1; letter-spacing: -.055em; }
.login-card > p { max-width: 560px; color: var(--muted); }
.login-card .button { margin-top: 16px; }
.fine-print { color: var(--muted); font-size: 12px; }

.dialog { width: min(650px, calc(100% - 24px)); max-height: calc(100vh - 24px); border: 0; border-radius: 22px; padding: 24px; color: var(--ink); box-shadow: 0 30px 90px rgba(16,44,35,.25); }
.dialog::backdrop { background: rgba(13,31,25,.52); backdrop-filter: blur(4px); }
.dialog-wide { width: min(900px, calc(100% - 24px)); }
.dialog-heading { display: flex; justify-content: space-between; gap: 20px; align-items: start; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.import-progress { display: grid; gap: 9px; margin-top: 16px; }
.import-result { padding: 10px 12px; border-radius: 11px; background: #eef4f0; font-size: 13px; }
.import-result.failed { background: #f9e8e6; color: #78352f; }
.tesco-import-helper { margin-top: 16px; padding: 15px; border: 1px solid #cad9e8; border-radius: 13px; background: #f4f8fc; }
.tesco-import-helper h3 { margin: 0; font-size: 16px; }
.tesco-import-helper ol { margin: 10px 0 13px; padding-left: 20px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.tesco-import-helper .fine-print { margin-bottom: 0; }
.manual-import { margin-top: 16px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: #f8faf7; }
.manual-import > summary { color: var(--green); font-size: 13px; font-weight: 750; }
.manual-import-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 13px; }
.manual-import-grid label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.manual-import-grid .span-all { grid-column: 1 / -1; }
.candidate-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.candidate-actions button { border: 1px solid #b8c8c0; border-radius: 999px; background: white; padding: 5px 9px; cursor: pointer; color: var(--green); font-size: 11px; }
.comparison-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; }
.comparison-summary div { padding: 14px; border-radius: 13px; background: #eff4f0; }
.comparison-summary strong, .comparison-summary span { display: block; }
.comparison-summary strong { font-size: 23px; }
.comparison-summary span { color: var(--muted); font-size: 11px; }
.comparison-store { margin-top: 12px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.comparison-store header { display: flex; justify-content: space-between; padding: 12px 14px; background: #f3f6f2; }
.comparison-lines { display: grid; }
.comparison-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 10px 14px; border-top: 1px solid #edf1ee; font-size: 13px; }
.warning-list { padding: 12px 16px; border-radius: 12px; background: #fff3d9; color: #71501b; font-size: 13px; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 22px; transform: translateX(-50%); max-width: calc(100% - 30px); padding: 11px 16px; border-radius: 999px; background: #14251f; color: white; box-shadow: 0 12px 30px rgba(0,0,0,.18); font-size: 13px; }

@media (max-width: 920px) {
  .grid-main { grid-template-columns: 1fr; }
  .sidebar { grid-row: 1; }
  .sticky-card { position: static; }
  .hero { align-items: start; flex-direction: column; }
}

@media (max-width: 620px) {
  main { padding: 12px; }
  .site-header { min-height: 62px; padding: 8px 12px; }
  .brand-mark { width: 38px; height: 38px; }
  .status-pill { display: none; }
  .panel { border-radius: 18px; }
  .hero { min-height: 250px; padding: 26px 22px; }
  .hero-stats { width: 100%; }
  .hero-stats div { flex: 1; min-width: 78px; }
  .product-card { grid-template-columns: auto 56px minmax(0, 1fr); gap: 10px; }
  .product-image { width: 56px; height: 56px; }
  .price { grid-column: 3; min-width: 0; text-align: left; }
  .product-details { grid-column: 2 / -1; }
  .product-editor { grid-template-columns: 1fr; }
  .product-editor .span-all { grid-column: auto; }
  .offer-row { grid-template-columns: 1fr 1fr; }
  .offer-row a { grid-column: 1 / -1; }
  .comparison-summary { grid-template-columns: 1fr; }
  .retailer-form { grid-template-columns: 1fr; }
  .retailer-form h3, .retailer-form button, .retailer-form .span-all { grid-column: auto; }
  .manual-import-grid { grid-template-columns: 1fr; }
  .manual-import-grid .span-all { grid-column: auto; }
}
