/* tabs and links cross-fade instead of flashing a blank page (Chrome 126+, Safari 18.2+; others just navigate) */
@view-transition {
  navigation: auto;
}

:root {
  color-scheme: light dark;
  --bg: #f5f3ee;
  --surface: #fffdf9;
  --sunk: #eeebe3;
  --ink: #1c211e;
  --muted: #5b625d;
  --line: #ddd8cd;
  --accent: #1d6b48;
  --accent-ink: #ffffff;
  --accent-soft: #e2efe7;
  --accent-text: #175b3c;
  --est: #8a5300;
  --est-bg: #fbefd6;
  --est-line: #e9c98a;
  --bad: #b3261e;
  --bad-bg: #fdeceb;
  --bad-line: #f0b7b2;
  --focus: #1d6b48;
  --shadow: 0 1px 2px rgb(40 35 25 / 0.06), 0 4px 14px rgb(40 35 25 / 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --font: system-ui, -apple-system, "Segoe UI", "Noto Sans Hebrew", "Arial Hebrew", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121412;
    --surface: #1b1e1c;
    --sunk: #232724;
    --ink: #ebeae4;
    --muted: #a6aca7;
    --line: #313632;
    --accent: #5cc08d;
    --accent-ink: #0d1f15;
    --accent-soft: #1d3327;
    --accent-text: #7fd3a6;
    --est: #f0c070;
    --est-bg: #392a0f;
    --est-line: #6b4f1c;
    --bad: #ff8f84;
    --bad-bg: #3b1714;
    --bad-line: #7a2b25;
    --focus: #7fd3a6;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 6px 18px rgb(0 0 0 / 0.25);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

main {
  max-inline-size: 36rem;
  margin-inline: auto;
  padding-inline: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
  padding-block: 8px max(40px, env(safe-area-inset-bottom));
}

main.narrow {
  max-inline-size: 24rem;
  padding-block-start: 12vh;
}

h1,
h2 {
  margin: 0;
  line-height: 1.25;
  text-wrap: balance;
}

h1 {
  font-size: 1.625rem;
  font-weight: 700;
  margin-block: 12px 16px;
}

h2 {
  font-size: 1.125rem;
  font-weight: 650;
}

p {
  margin-block: 0 12px;
}

a {
  color: var(--accent-text);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.num,
time,
dd {
  font-variant-numeric: tabular-nums;
}

.num,
.name,
.pname,
bdi,
time {
  unicode-bidi: isolate;
}

.thumb {
  width: 2.5rem;
  height: 2.5rem;
  object-fit: contain;
  vertical-align: middle;
  margin-inline-end: 0.4rem;
  border-radius: 4px;
  background: #fff;
}

.muted,
.note {
  color: var(--muted);
}

.note {
  font-size: 0.875rem;
}

.empty {
  padding: 20px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}

.topbar {
  position: sticky;
  inset-block-start: 0;
  z-index: 1;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-block-end: 1px solid var(--line);
  padding-block-start: env(safe-area-inset-top);
}

.topbar nav {
  display: flex;
  gap: 4px;
  max-inline-size: 36rem;
  margin-inline: auto;
  padding-inline: 8px;
}

.topbar a {
  display: inline-flex;
  align-items: center;
  min-block-size: 48px;
  padding-inline: 12px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 550;
  border-block-end: 2px solid transparent;
}

.topbar a[aria-current="page"] {
  color: var(--ink);
  border-block-end-color: var(--ink);
}

.brand {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-block-size: 44px;
  padding-inline: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 150ms ease-out, border-color 150ms ease-out, transform 100ms ease-out;
  touch-action: manipulation;
}

button:active,
.btn:active {
  transform: scale(0.98);
}

button:disabled {
  opacity: 0.55;
  cursor: progress;
  transform: none;
}

button[aria-busy='true']::before {
  content: '';
  inline-size: 1em;
  block-size: 1em;
  border: 2px solid currentColor;
  border-inline-end-color: transparent;
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.flash:focus {
  outline: none;
}

button.primary,
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  min-block-size: 52px;
  inline-size: 100%;
  font-size: 1.0625rem;
}

button.choose {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-text);
}

button.quiet {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-weight: 500;
  padding-inline: 10px;
}

@media (hover: hover) {
  button:hover,
  .btn:hover {
    border-color: var(--muted);
  }
  button.primary:hover,
  .btn.primary:hover {
    background: color-mix(in srgb, var(--accent) 88%, var(--ink));
  }
  button.quiet:hover {
    color: var(--ink);
    border-color: transparent;
    background: var(--sunk);
  }
}

.stack {
  display: grid;
  gap: 10px;
  margin-block: 20px;
}

.stack > p {
  margin: 0;
}

.field {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

input:not([type=checkbox]):not([type=radio]),
textarea {
  inline-size: 100%;
  min-block-size: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 400;
}

textarea {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.875rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
}

.actions .btn {
  flex: 1 1 auto;
}

.flash,
.alert,
p.warning,
.caution {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-weight: 600;
}

.flash {
  scroll-margin-block-start: calc(64px + env(safe-area-inset-top));
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-text);
}

/* a store section's result is a toast: in view after a swap without moving the page */
section.store > .flash {
  position: fixed;
  inset-inline: 16px;
  inset-block-end: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 20;
  max-inline-size: 560px;
  margin-inline: auto;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.18);
  animation: toast-out 0.3s ease-in 4s forwards;
}

section.store > .flash.bad {
  animation-delay: 10s;
}

@keyframes toast-out {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  section.store > .flash {
    animation-duration: 0s;
  }
}

.flash.bad,
.alert,
p.warning {
  background: var(--bad-bg);
  border-color: var(--bad-line);
  color: var(--bad);
}

.alert a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-block-size: 44px;
  margin-block-start: 10px;
  border-radius: var(--radius-sm);
  background: var(--bad);
  color: var(--surface);
  text-decoration: none;
  font-weight: 650;
}

.empty a {
  display: inline-block;
  padding-block: 10px;
}

.caution {
  background: var(--est-bg);
  border-color: var(--est-line);
  color: var(--est);
}

span.warning {
  color: var(--bad);
  font-weight: 650;
}

.estimate {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--est-bg);
  color: var(--est);
  font-size: 0.8125rem;
  font-weight: 650;
  vertical-align: middle;
}

.est-price {
  color: var(--est);
  font-weight: 600;
}

.estimate-note {
  display: inline-block;
  margin-block: 0 10px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--est-bg);
  color: var(--est);
  font-size: 0.8125rem;
  font-weight: 600;
}

.unknown {
  color: var(--muted);
}

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1px;
  margin: 0 0 20px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.facts > div {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  background: var(--surface);
}

.facts dt {
  color: var(--muted);
  font-size: 0.8125rem;
}

.facts dd {
  margin: 0;
  font-weight: 600;
}

.facts .list-size {
  font-size: 1.5rem;
  line-height: 1.2;
}

.progress {
  margin-block: 0 8px;
  padding: 14px 16px 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.progress h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  margin-block-end: 6px;
}

.progress h2::before {
  content: "";
  inline-size: 10px;
  block-size: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.4s ease-out infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
  100% { box-shadow: 0 0 0 10px transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .progress h2::before { animation: none; }
  button, .btn { transition: none; }
  button[aria-busy='true']::before { animation: none; }
}

.progress ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.progress li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  gap: 12px;
  padding-block: 10px;
  border-block-start: 1px solid var(--line);
}

.progress .store {
  font-weight: 600;
}

.progress .phase {
  color: var(--muted);
}

.progress .count {
  min-inline-size: 3.5ch;
  text-align: end;
  font-weight: 600;
  direction: ltr;
}

.card {
  margin-block: 0 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}

.card > * {
  margin: 0;
}

.card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.card-head h2 {
  font-size: 1.25rem;
}

.card-head .status {
  margin: 0;
  margin-inline-start: auto;
  color: var(--muted);
  font-size: 0.875rem;
}

.totals {
  display: grid;
  margin: 0;
}

.totals > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding-block: 6px;
}

.totals dt {
  color: var(--muted);
}

.totals dd {
  margin: 0;
  text-align: end;
  white-space: nowrap;
}

.totals .grand {
  align-items: center;
  padding-block: 0 10px;
  margin-block-end: 4px;
  border-block-end: 1px solid var(--line);
}

.totals .grand dt {
  color: var(--ink);
  font-weight: 600;
}

.totals .grand .num {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.totals .grand .num.unknown {
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0;
}

.totals .best dt,
.totals .best .num {
  color: var(--est);
}

.totals .best dt {
  white-space: normal;
}

.totals .part {
  font-size: 0.875rem;
}

.coverage {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.attention {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--est-line);
  border-radius: var(--radius-sm);
  background: var(--est-bg);
  color: var(--est);
  font-weight: 600;
}

.attention p {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
}

.attention p.warning {
  color: var(--bad);
}

.stockups {
  font-size: 0.875rem;
}

.stockups p {
  margin: 0 0 4px;
  color: var(--accent-text);
  font-weight: 600;
}

.stockups ul {
  margin: 0;
  padding-inline-start: 18px;
}

.verdict {
  margin-block: 0 16px;
  padding: 16px;
  display: grid;
  gap: 6px;
  background: var(--accent-soft);
  border-radius: var(--radius);
  color: var(--accent-text);
}

.verdict[data-winner="none"] {
  background: var(--sunk);
  color: var(--ink);
}

.verdict > * {
  margin: 0;
}

.verdict h2 {
  font-size: 1.25rem;
}

.verdict .figure .num {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.verdict .basis,
.verdict .when {
  font-size: 0.875rem;
}

.verdict .saving {
  font-weight: 650;
}

.verdict-stores {
  display: grid;
  gap: 8px;
  margin-block: 8px 0;
  padding: 10px 0 0;
  list-style: none;
  border-block-start: 1px solid var(--line);
}

.verdict-stores li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
}

.verdict-stores .store-name {
  font-weight: 650;
}

.verdict .coverage {
  flex-basis: 100%;
  color: inherit;
  font-size: 0.875rem;
}

.verdict .leaves {
  flex-basis: 100%;
  font-size: 0.875rem;
}

.store-head {
  display: grid;
  gap: 6px;
  margin-block: 0 16px;
}

.store-head > * {
  margin: 0;
}

.store-head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.store-head .figure .num {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.store-head .best {
  color: var(--est);
  font-size: 0.875rem;
}

.counts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  list-style: none;
}

.counts li {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--sunk);
  font-size: 0.8125rem;
  font-weight: 550;
}

.counts li.bad {
  background: var(--bad-bg);
  color: var(--bad);
}

.removed {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--sunk);
  font-size: 0.875rem;
}

.removed summary {
  display: flex;
  align-items: center;
  min-block-size: 44px;
  margin-block: -10px;
  font-weight: 600;
  cursor: pointer;
}

.removed[open] summary {
  margin-block-end: 0;
}

.removed p {
  margin: 0 0 4px;
}

.removed ul {
  margin: 0;
  padding-inline-start: 18px;
}

.group {
  margin-block: 28px 0;
}

.group h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-block-end: 10px;
}

.tally {
  min-inline-size: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--sunk);
  color: var(--muted);
  font-size: 0.8125rem;
  text-align: center;
}

.items {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.items > li {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-block-start: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.items > li:first-child {
  border-block-start: 0;
}

.items .name {
  font-weight: 650;
}

.items .detail {
  margin: 0;
}

.items .label {
  color: var(--muted);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-block-start: 6px;
}

.row-actions form {
  margin: 0;
}

.items > li.compact {
  grid-template-columns: 1fr auto;
  align-items: center;
  padding-block: 8px;
  padding-inline-end: 8px;
}

.items > li.compact form {
  margin: 0;
}

.items > li.compact .name {
  font-weight: 600;
}

.items > li.compact .detail {
  color: var(--muted);
}

.items > li.compact .name,
.items > li.compact .warning {
  color: var(--ink);
}

.items > li.mismatch {
  background: var(--bad-bg);
}

.items > li.mismatch .warning {
  color: var(--bad);
}

.compare {
  display: grid;
  gap: 4px;
  margin: 4px 0 0;
}

.compare > div {
  display: flex;
  gap: 6px;
}

.compare dt {
  flex: none;
  min-inline-size: 3.5em;
  color: var(--muted);
}

.compare dd {
  margin: 0;
  display: grid;
}

.compare .price {
  font-weight: 600;
}

.compare .offer .price > .num {
  color: var(--est);
  font-weight: 650;
}

.unit {
  color: var(--muted);
  font-size: 0.8125rem;
}

.done {
  display: grid;
  gap: 8px;
  margin-block: 28px 0;
}

.done + .note {
  margin-block: 10px 0;
}

.list-changed {
  display: grid;
  gap: 8px;
  margin-block: 0 16px;
}

.list-changed p {
  margin: 0;
}

.verdict time {
  white-space: nowrap;
}

.plain-list {
  margin: 0 0 16px;
  padding: 4px 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.plain-list li {
  padding: 10px 16px;
  border-block-start: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.plain-list li:first-child {
  border-block-start: 0;
}

main > h2 {
  margin-block: 24px 10px;
}

.logins {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.logins li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 8px;
  padding: 12px 16px;
  border-block-start: 1px solid var(--line);
}

.logins li:first-child {
  border-block-start: 0;
}

.logins .who {
  font-weight: 650;
  min-inline-size: 5.5em;
}

.logins small {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 0.8125rem;
}

.state {
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 650;
  background: var(--sunk);
  color: var(--muted);
}

.state.ok {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.state.expired {
  background: var(--bad);
  color: var(--surface);
}

.state.saved {
  background: var(--est-bg);
  color: var(--est);
}

.panel {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel h2 {
  margin-block-end: 10px;
}

.steps {
  margin: 0 0 16px;
  padding-inline-start: 20px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.steps li + li {
  margin-block-start: 6px;
}

.qty {
  display: inline-block;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--sunk);
  color: var(--ink);
  font-size: 0.875em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  direction: ltr;
}

.amounts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-block-start: 6px;
}

.amount-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.amount-caption {
  flex-basis: 100%;
  font-size: 0.85rem;
  color: var(--muted);
}

.size {
  color: var(--muted);
  font-size: 0.9em;
}

.amounts label {
  display: inline-flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 6px;
  min-block-size: 44px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}

.amounts label .est-price {
  margin-inline-start: auto;
}

.amounts input {
  inline-size: auto;
  min-block-size: 0;
  margin: 0;
  accent-color: var(--accent);
}

.amounts label:has(input:checked) {
  background: var(--accent-soft);
}

.amounts label.preselected {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

.amounts label.current {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.pick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-block-start: 12px;
}

.plain-list li:has(> .check-row) {
  padding: 0;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-block-size: 52px;
  padding: 10px 16px;
  cursor: pointer;
}

.check-row input {
  flex: none;
  inline-size: 22px;
  block-size: 22px;
  margin: 0;
  accent-color: var(--accent);
}

.prematch-box {
  margin-block: 12px;
}

.prematch-box p {
  margin-block: 4px;
}

.push {
  margin-block: 16px;
}
