:root {
  color-scheme: light;
  --background: #f3f6f8;
  --surface: #ffffff;
  --ink: #14213d;
  --muted: #617086;
  --line: #d8e0e8;
  --brand: #087f5b;
  --brand-dark: #066c4d;
  --danger: #c92a2a;
  --danger-soft: #fff1f0;
  --shadow: 0 8px 24px rgb(20 33 61 / 8%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--background);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; }

button, input, select, textarea {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

input, select, textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  background: var(--surface);
  color: var(--ink);
}

textarea { min-height: 80px; resize: vertical; }

button {
  padding: 0.65rem 1rem;
  font-weight: 700;
  cursor: pointer;
}

button:disabled { cursor: not-allowed; opacity: 0.55; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgb(8 127 91 / 30%);
  outline-offset: 2px;
}

.primary { border-color: var(--brand); background: var(--brand); color: white; }
.primary:hover:not(:disabled) { background: var(--brand-dark); }
.secondary { background: var(--surface); color: var(--ink); }

.page-header, main, .page-status {
  width: min(100% - 1.5rem, 760px);
  margin-inline: auto;
}

.page-header { padding: 1.5rem 0 0.75rem; }
.page-header h1 { margin: 0.15rem 0; font-size: clamp(1.55rem, 7vw, 2.2rem); }
.page-header p { margin: 0.2rem 0; }
.eyebrow { color: var(--brand); font-size: 0.78rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.muted { color: var(--muted); }

main { padding-bottom: calc(2rem + env(safe-area-inset-bottom)); }
section { margin-block: 1rem; }
h2 { margin: 0 0 0.75rem; font-size: 1.15rem; }
.cards { display: grid; gap: 0.8rem; }

.card, .panel, .summary, .submit-panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card { padding: 0.85rem; }
.panel, .summary, .submit-panel { padding: 1rem; }

.product-head { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 0.8rem; align-items: start; }
.product-image {
  display: grid;
  width: 84px;
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border-radius: 12px;
  background: #e8eef2;
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
}
.product-image img { width: 100%; height: 100%; object-fit: cover; }
.product-title { margin: 0 0 0.25rem; font-size: 1rem; }
.meta { margin: 0.1rem 0; color: var(--muted); font-size: 0.84rem; }
.purchase-note { margin: 0.65rem 0 0; padding: 0.65rem; border-radius: 10px; background: #f5f8fa; }
.product-title, .meta, .purchase-note, .confirmation-summary { overflow-wrap: anywhere; }

.fields, .discount-row { display: grid; gap: 0.7rem; margin-top: 0.85rem; }
label { display: grid; gap: 0.3rem; color: #34445a; font-size: 0.84rem; font-weight: 650; }
.price-facts { margin-top: 0.8rem; padding: 0.7rem; border-radius: 12px; background: #f7f9fb; font-size: 0.86rem; }
.price-facts p { margin: 0.2rem 0; }
.price-change { color: var(--danger); font-weight: 800; }

.section-heading { display: flex; gap: 0.75rem; align-items: center; justify-content: space-between; }
.section-heading h2 { margin: 0; }
.preview { display: block; max-width: 140px; max-height: 140px; margin-top: 0.5rem; border-radius: 10px; object-fit: cover; }
.remove-recommendation { margin-top: 0.75rem; border-color: #f1b5b5; background: var(--danger-soft); color: var(--danger); }

.summary dl { margin: 0; }
.summary dl > div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
.summary dl > div:last-child { border: 0; }
.summary dd { margin: 0; font-weight: 800; text-align: right; }
.summary .difference { color: var(--danger); font-size: 1.05rem; }
.error { color: var(--danger); font-weight: 700; }
.submit-panel .primary { width: 100%; margin-top: 0.8rem; }
.page-status { padding: 1rem; text-align: center; }

dialog {
  width: min(100% - 1.5rem, 560px);
  max-height: calc(100dvh - 2rem);
  padding: 0;
  border: 0;
  border-radius: 18px;
  color: var(--ink);
}
dialog::backdrop { background: rgb(9 20 36 / 65%); }
.dialog-content { padding: 1.15rem; }
.confirmation-summary { padding: 0.8rem; border-radius: 12px; background: #f5f8fa; white-space: pre-line; }
.dialog-actions { display: grid; gap: 0.65rem; margin-top: 1rem; }

@media (min-width: 600px) {
  .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .discount-row { grid-template-columns: 1fr 1fr; }
  .dialog-actions { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
