:root {
  --rp-red: #C8102E;
  --rp-red-soft: rgba(200, 16, 46, .12);
  --text: #1a1a1a;
  --grey: #666;
  --grey-2: #999;
  --line: #E0E0E0;
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --zone-bg: #F5F5F5;
  --shadow-drag: 0 4px 14px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.04);
  /* Spacing — 4px sub-unit, 8px base */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  /* Legacy aliases — kept so older selectors continue to resolve. New code
     should reference --sp-* directly. */
  --gap: var(--sp-3);
  --gap-lg: var(--sp-5);
  --pad: var(--sp-4);
  --pad-lg: var(--sp-6);
  --maxw: 880px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  /* Type scale. Off-scale values (10 / 10.5 / 11.5 / 17 px) are deliberate
     component-level fine-tuning and stay inline. */
  --fs-xs:   11px;   /* caption, label, code, brand-count */
  --fs-sm:   12px;   /* hint, helper, error message */
  --fs-md:   13px;   /* button, secondary body, brand-tag */
  --fs-lg:   14px;   /* body, section head, review item */
  --fs-base: 15px;   /* default body */
  --fs-xl:   16px;   /* emphasized total, review grand-row */
  --fs-2xl:  18px;   /* big number, brand mark, line-menu-trigger */
  --fs-3xl:  22px;   /* review screen heading */
  /* Weight scale */
  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;
  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in:  cubic-bezier(0.4, 0, 1, 1);
  --ease-std: cubic-bezier(0.4, 0, 0.2, 1);
  --d-fast: 120ms;
  --d-norm: 180ms;
  --d-slow: 300ms;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

button { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--rp-red);
  outline-offset: 2px;
  border-radius: var(--radius);
}
:focus { outline: none; }

.page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: var(--sp-3) var(--sp-5);
  display: flex;
  align-items: center;
  gap: var(--gap-lg);
  flex-wrap: wrap;
  position: sticky; top: 0; z-index: 10;
}

.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark {
  font-weight: var(--fw-bold); color: var(--rp-red);
  letter-spacing: -.01em; font-size: var(--fs-2xl);
}
.brand-tag { color: var(--grey); font-size: var(--fs-md); }

.mode-tabs { display: flex; gap: var(--sp-1); margin-left: auto; }
.mode-tab {
  padding: 6px var(--sp-3);
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  cursor: pointer;
  font-size: var(--fs-md);
  color: var(--grey);
}
.mode-tab.is-active {
  background: var(--text); color: var(--surface);
  border-color: var(--text);
}
.mode-tab[disabled] { opacity: .5; cursor: not-allowed; }

.container {
  max-width: var(--maxw);
  margin: var(--sp-6) auto;
  padding: 0 var(--sp-4);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  margin-bottom: var(--sp-4);
  box-shadow: var(--shadow);
}
@media (max-width: 720px) {
  .card { padding: var(--sp-4); }
}

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 0 0 14px 0;
}
.section-head h2 {
  font-size: var(--fs-lg); font-weight: var(--fw-bold);
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--grey); margin: 0;
}
.hint { font-size: var(--fs-sm); color: var(--grey-2); }

.grid { display: grid; gap: var(--gap); margin-bottom: var(--gap); }
.grid.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }

@media (max-width: 720px) {
  .grid.grid-3 { grid-template-columns: 1fr; }
}

.field { display: flex; flex-direction: column; gap: var(--sp-1); }
.label {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em;
  color: var(--grey); font-weight: var(--fw-semibold);
}

input[type="text"],
input[type="date"],
input[type="number"],
input[type="search"],
select,
textarea {
  font: inherit;
  width: 100%;
  padding: 9px 10px;
  min-height: 40px;
  line-height: 1.3;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--d-fast) var(--ease-std),
              box-shadow var(--d-fast) var(--ease-std);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--rp-red);
  box-shadow: 0 0 0 3px var(--rp-red-soft);
}
select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: var(--sp-8);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%23666' stroke-width='1.5' d='M1 1.5l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
textarea { min-height: auto; }

.op-summary {
  padding: 9px 10px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--grey);
  font-size: var(--fs-md);
  min-height: 40px;
  display: flex; align-items: center;
  background: var(--bg);
}

textarea { resize: vertical; }

/* ---- line items ---- */

.lines { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }

.line {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.line.is-comp .line-product { text-decoration: line-through; color: var(--grey); }
.line.is-dragging {
  opacity: .85;
  box-shadow: var(--shadow-drag);
}
.line.is-drag-over { border-color: var(--rp-red); }

.line-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px var(--sp-3);
  user-select: none;
}

.drag-handle {
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  color: var(--grey-2);
  cursor: grab;
  touch-action: none;
}
.drag-handle:active { cursor: grabbing; }

.line-product {
  font-weight: var(--fw-medium);
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
}
.line-product .sku-code {
  font-size: var(--fs-xs); color: var(--grey-2);
  font-family: ui-monospace, SFMono-Regular, monospace;
}

.pill {
  font-size: 10.5px; font-weight: var(--fw-bold); letter-spacing: .03em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--zone-bg); color: var(--grey);
}
.pill-discount { background: #FEF2F2; color: var(--rp-red); }
.pill-free { background: var(--rp-red); color: var(--surface); }

.line-qty {
  width: 64px;
  text-align: center;
}

.line-price {
  text-align: right;
  font-variant-numeric: tabular-nums;
  min-width: 110px;
}
.line-price small { display: block; font-size: var(--fs-xs); color: var(--grey); font-weight: var(--fw-regular); }

.line-menu-trigger {
  background: transparent; border: 0; color: var(--grey-2);
  cursor: pointer; padding: var(--sp-1) var(--sp-2); font-size: var(--fs-2xl); line-height: 1;
  border-radius: var(--radius);
  letter-spacing: 1px;
}
.line-menu-trigger:hover  { background: var(--zone-bg); color: var(--text); }
.line-menu-trigger.is-open { background: var(--zone-bg); color: var(--text); }

.line-popover {
  border-top: 1px solid var(--line);
  background: var(--bg);
  padding: var(--sp-2);
}

.line-menu-list { display: flex; flex-direction: column; gap: 2px; }
.line-menu-list button {
  text-align: left;
  background: transparent; border: 0;
  padding: 9px var(--sp-3);
  font: inherit; color: var(--text);
  cursor: pointer;
  border-radius: var(--radius);
  display: flex; align-items: center; gap: var(--sp-3);
}
.line-menu-list button:hover { background: var(--zone-bg); }
.line-menu-list button.danger { color: var(--rp-red); }
.line-menu-list .menu-icon {
  width: 18px; text-align: center;
  color: var(--grey-2);
  font-size: var(--fs-lg);
}
.line-menu-list button.danger .menu-icon { color: var(--rp-red); }

.line-panel {
  padding: 6px var(--sp-2) var(--sp-2);
}
.line-panel-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.line-panel-row .label { flex: 0 0 auto; color: var(--grey); font-size: var(--fs-sm); }
.line-panel-row input { flex: 1; min-width: 140px; }
.line-panel-actions {
  display: flex; gap: 6px; margin-left: auto;
}
.btn-sm { padding: 6px var(--sp-3); font-size: var(--fs-md); }
.btn-link {
  background: transparent; border: 0; padding: 6px 6px;
  color: var(--grey); font: inherit; font-size: var(--fs-md); cursor: pointer;
  text-decoration: underline;
}
.btn-link:hover { color: var(--rp-red); }

/* ---- add buttons ---- */

.add-row { display: flex; gap: var(--sp-2); margin-bottom: 14px; }

.btn {
  font: inherit; cursor: pointer;
  padding: 9px var(--sp-4);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  display: inline-flex; align-items: center; gap: 6px;
  transition: background-color var(--d-fast) var(--ease-std),
              border-color    var(--d-fast) var(--ease-std),
              color           var(--d-fast) var(--ease-std),
              transform       60ms var(--ease-std);
}
@media (hover: hover) {
  .btn:hover         { background: var(--zone-bg); border-color: var(--grey-2); }
  .btn-primary:hover { background: #000;          border-color: #000; }
  .btn-red:hover     { background: #a30d25;       border-color: #a30d25; }
  .btn-ghost:hover   { background: var(--zone-bg); }
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--text); color: var(--surface); border-color: var(--text);
}
.btn-red {
  background: var(--rp-red); color: var(--surface); border-color: var(--rp-red);
  font-weight: var(--fw-semibold);
}
.btn-ghost   { background: transparent; }
.btn-lg      { padding: var(--sp-3) var(--sp-5); font-weight: var(--fw-semibold); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---- totals ---- */

.totals-block {
  border-top: 1px solid var(--line);
  padding: 14px var(--sp-1) 6px var(--sp-1);
  background: var(--surface);
}
.totals-block.sticky {
  position: sticky;
  bottom: 0;
  z-index: 1;
}
.totals-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: var(--sp-1) 0;
  font-size: var(--fs-lg); color: var(--grey);
}
.totals-row .num { font-variant-numeric: tabular-nums; color: var(--text); font-weight: var(--fw-medium); }
.totals-grand {
  border-top: 1px solid var(--text);
  margin-top: 6px; padding-top: 10px;
  font-weight: var(--fw-bold); color: var(--text); font-size: var(--fs-xl);
}
.totals-grand .num { color: var(--rp-red); font-weight: var(--fw-bold); font-size: 17px; }
.totals-savings .num { color: var(--rp-red); }
.is-hidden { display: none !important; }

.toggle {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-md); color: var(--grey);
  margin-top: var(--sp-3);
  cursor: pointer;
}
.toggle-block {
  display: flex; align-items: flex-start; gap: 10px;
  margin-top: 14px;
  cursor: pointer;
}
.toggle-block input { margin-top: var(--sp-1); flex: 0 0 auto; }
.toggle-text { display: flex; flex-direction: column; gap: 2px; }
.toggle-title { color: var(--text); font-weight: var(--fw-medium); font-size: var(--fs-lg); }
.toggle-help { color: var(--grey); font-size: var(--fs-sm); line-height: 1.4; }

/* ---- final actions ---- */

.actions {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 6px;
}

.draft-state {
  text-align: right;
  font-size: var(--fs-sm); color: var(--grey-2);
  padding: var(--sp-2) var(--sp-1) var(--sp-6);
}

/* ---- picker dialog ---- */

dialog.picker {
  width: min(640px, 92vw);
  max-height: 80vh;
  border: 0;
  border-radius: var(--radius-lg);
  padding: 0;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
dialog::backdrop { background: rgba(0,0,0,.35); }

.picker-head {
  display: flex; gap: var(--sp-2); align-items: center;
  padding: var(--sp-3) 14px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.picker-head input[type="search"] { flex: 1; }

.picker-tree {
  max-height: 70vh;
  overflow-y: auto;
  background: var(--surface);
}

.tree-cat-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-md); font-weight: var(--fw-bold);
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.tree-cat-head:hover { background: var(--zone-bg); }
.tree-cat-head .chev {
  font-size: var(--fs-xs); color: var(--grey-2);
  transition: transform .15s ease;
  margin-right: var(--sp-2);
}
.tree-cat-head.is-expanded .chev { transform: rotate(90deg); }
.tree-cat-head .left { display: flex; align-items: center; }
.tree-cat-count {
  font-size: var(--fs-xs); color: var(--grey-2);
  font-weight: var(--fw-semibold); letter-spacing: 0; text-transform: none;
}
/* grid-template-rows trick for smooth expand/collapse */
.tree-cat-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--d-norm) var(--ease-std);
}
.tree-cat-body > .tree-cat-body-inner { overflow: hidden; }
.tree-cat-body.is-open { grid-template-rows: 1fr; }

.tree-brand-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-2) 14px var(--sp-2) 28px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  font-size: var(--fs-xs); font-weight: var(--fw-bold);
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--grey);
  cursor: pointer;
  user-select: none;
}
.tree-brand-head:hover { background: var(--zone-bg); }
.tree-brand-head .chev {
  font-size: 10px; color: var(--grey-2);
  transition: transform .15s ease;
  margin-right: var(--sp-2);
}
.tree-brand-head.is-expanded .chev { transform: rotate(90deg); }
.tree-brand-head .left { display: flex; align-items: center; }
.tree-brand-count {
  font-size: 10px; color: var(--grey-2);
  font-weight: var(--fw-semibold); letter-spacing: 0;
}
.tree-brand-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--d-norm) var(--ease-std);
}
.tree-brand-body > .tree-brand-body-inner { overflow: hidden; }
.tree-brand-body.is-open { grid-template-rows: 1fr; }

.tree-item {
  display: flex; gap: 14px;
  padding: 10px 14px 10px 36px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  align-items: flex-start;
  text-align: left;
  width: 100%;
  border-left: 0; border-right: 0; border-bottom: 0;
  font: inherit;
  color: var(--text);
}
.tree-item:hover { background: var(--zone-bg); }
.tree-item-info { flex: 1 1 auto; min-width: 0; }
.tree-item-name {
  font-size: var(--fs-lg); line-height: 1.3;
  word-break: break-word;
}
.tree-item-name .code {
  font-size: var(--fs-xs); color: var(--grey-2);
  font-family: ui-monospace, SFMono-Regular, monospace;
  margin-left: var(--sp-2);
}
.tree-item-meta {
  font-size: 11.5px; color: var(--grey);
  margin-top: 3px; line-height: 1.4;
}
.tree-item-price {
  flex: 0 0 auto;
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.tree-item-price .amt {
  display: block;
  color: var(--text); font-weight: var(--fw-medium); font-size: var(--fs-lg);
}
.tree-item-price small {
  display: block;
  color: var(--grey-2); font-size: var(--fs-xs); font-weight: var(--fw-regular);
}

.tree-empty { padding: 28px; text-align: center; color: var(--grey-2); }

/* ---- toast ---- */

.toast-region {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 6px;
  z-index: 100;
  pointer-events: none;
}
.toast {
  background: var(--text); color: var(--surface);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: var(--fs-md);
  box-shadow: var(--shadow);
  display: flex; gap: var(--sp-3); align-items: center;
  pointer-events: auto;
  animation: toast-in .15s ease-out;
}
.toast button {
  background: transparent; border: 0; color: var(--rp-red);
  font-weight: var(--fw-bold); cursor: pointer; font-size: var(--fs-md);
}
@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

.invalid { border-color: var(--rp-red) !important; }

/* ========================================================================
   Motion + polish + new views (review, payment terms)
   ======================================================================== */

/* ---- typography refinements ---- */
.line-price, .line-qty, .num,
.tree-item-price, .totals-row .num,
.review-amount {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
.totals-grand .num { letter-spacing: -.01em; }

/* ---- field error messages ---- */
.field-error {
  display: block;
  max-height: 0; overflow: hidden;
  font-size: var(--fs-sm); color: var(--rp-red);
  margin-top: 0;
  opacity: 0;
  transition:
    max-height var(--d-norm) var(--ease-std),
    opacity   var(--d-norm) var(--ease-std),
    margin-top var(--d-norm) var(--ease-std);
}
.field.is-invalid .field-error {
  max-height: 32px;
  margin-top: var(--sp-1);
  opacity: 1;
}
.field input.invalid,
.field select.invalid {
  border-color: var(--rp-red);
}

/* ---- custom payment stages ---- */
.custom-stages { margin-top: var(--sp-3); }
.custom-stages-list {
  display: flex; flex-direction: column; gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.custom-stage {
  display: grid;
  grid-template-columns: 1fr 80px auto;
  gap: var(--sp-2); align-items: center;
}
.custom-stage input { min-height: 36px; padding: 6px 10px; }
.custom-stage-remove {
  background: transparent; border: 0;
  color: var(--grey-2); cursor: pointer;
  font-size: var(--fs-2xl); padding: var(--sp-1) var(--sp-2); line-height: 1;
  border-radius: var(--radius);
  transition: background-color var(--d-fast) var(--ease-std), color var(--d-fast) var(--ease-std);
}
.custom-stage-remove:hover { color: var(--rp-red); background: var(--zone-bg); }
.custom-stages-bar {
  display: flex; align-items: center; gap: var(--sp-3);
}
.custom-stages-sum {
  margin-left: auto;
  font-size: var(--fs-sm); color: var(--grey);
  font-variant-numeric: tabular-nums;
}
.custom-stages-sum.is-bad { color: var(--rp-red); font-weight: var(--fw-semibold); }

/* ---- pickup/menu open animations ---- */
@keyframes line-enter {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes line-leave {
  from { opacity: 1; }
  to   { opacity: 0; }
}
.line.is-entering {
  animation: line-enter 200ms var(--ease-out);
}
.line.is-leaving {
  pointer-events: none;
  overflow: hidden;
  /* JS sets a max-height on the element so it can collapse */
  transition:
    max-height 200ms var(--ease-in),
    opacity    150ms var(--ease-in),
    margin     200ms var(--ease-in),
    padding    200ms var(--ease-in);
  opacity: 0;
}

/* The line-popover (menu, discount panel, price panel) */
@keyframes popover-in {
  from { opacity: 0; transform: scaleY(.95) translateY(-2px); }
  to   { opacity: 1; transform: scaleY(1)   translateY(0); }
}
.line-popover {
  transform-origin: top center;
  animation: popover-in 120ms var(--ease-out);
}

/* ---- picker dialog animation ---- */
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}
dialog.picker[open] {
  animation: dialog-in var(--d-norm) var(--ease-out);
}
dialog.picker::backdrop {
  background: rgba(0, 0, 0, .35);
  animation: backdrop-in 150ms var(--ease-out);
}
@keyframes backdrop-in {
  from { opacity: 0; } to { opacity: 1; }
}

/* ---- search input subtle red focus ---- */
#picker-search:focus { border-color: var(--rp-red); box-shadow: 0 0 0 3px var(--rp-red-soft); }

/* ---- saved indicator animation ---- */
.draft-state {
  transition: opacity var(--d-norm) var(--ease-std);
}
.draft-state.is-fading { opacity: 0; }

/* ---- toast accessibility -- already role=status on parent ---- */

/* ========================================================================
   Stage + form ↔ review transitions
   ======================================================================== */

.stage { position: relative; }

.view-form, .view-review { display: none; }
.stage[data-view="form"]   .view-form   { display: block; animation: form-in   var(--d-norm) var(--ease-out); }
.stage[data-view="review"] .view-review { display: block; animation: review-in var(--d-slow) var(--ease-out); }

.view-review.is-leaving { animation: review-out 200ms var(--ease-in); }

@keyframes review-in {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes review-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(40px); }
}
@keyframes form-in {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ---- review screen layout ---- */

.review-card { padding: var(--sp-6); }
@media (max-width: 720px) { .review-card { padding: var(--sp-4); } }

.review-head {
  margin-bottom: var(--sp-5);
  border-bottom: 1px solid var(--line);
  padding-bottom: var(--sp-4);
}
.review-head h2 {
  font-size: var(--fs-3xl); letter-spacing: -.01em; font-weight: var(--fw-bold);
  margin: 0 0 var(--sp-2) 0; color: var(--text);
  text-transform: none;
}
.review-sub {
  margin: 0; color: var(--grey); font-size: var(--fs-md);
}
.review-sub strong { color: var(--text); font-weight: var(--fw-medium); }

.review-body { display: flex; flex-direction: column; gap: var(--sp-5); }

.review-section { display: flex; flex-direction: column; gap: var(--sp-2); }
.review-section h3 {
  margin: 0 0 var(--sp-1) 0;
  font-size: var(--fs-xs); font-weight: var(--fw-bold);
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--grey-2);
}

.review-meta {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3) var(--sp-5);
}
@media (max-width: 540px) { .review-meta { grid-template-columns: 1fr; } }
.review-meta .field-row {
  display: flex; flex-direction: column; gap: 2px;
}
.review-meta .review-label {
  font-size: var(--fs-xs); text-transform: uppercase;
  letter-spacing: .04em; color: var(--grey-2); font-weight: var(--fw-semibold);
}
.review-meta .review-value {
  font-size: var(--fs-lg); color: var(--text);
}

.review-lines {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.review-line {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--sp-3);
  padding: 10px 0;
  border-top: 1px solid var(--line);
  align-items: baseline;
}
.review-line:first-child { border-top: 0; }
.review-line.is-comp .review-product {
  text-decoration: line-through; color: var(--grey);
}
.review-qty {
  color: var(--grey); font-size: var(--fs-md);
  min-width: 36px;
}
.review-product {
  font-size: var(--fs-lg);
  display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-2);
}
.review-product .sku-code {
  font-size: var(--fs-xs); color: var(--grey-2);
  font-family: ui-monospace, SFMono-Regular, monospace;
}
.review-amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text);
}
.review-line.is-comp .review-amount { text-decoration: line-through; color: var(--grey-2); }

.review-totals {
  display: flex; flex-direction: column; gap: var(--sp-1);
}
.review-tot-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: var(--fs-lg); color: var(--grey);
}
.review-tot-row .num { color: var(--text); font-weight: var(--fw-medium); }
.review-tot-row.is-savings .num { color: var(--rp-red); }
.review-tot-row.is-grand {
  border-top: 1px solid var(--text);
  margin-top: var(--sp-2); padding-top: var(--sp-3);
  font-size: var(--fs-xl); color: var(--text); font-weight: var(--fw-bold);
}
.review-tot-row.is-grand .num {
  color: var(--rp-red); font-size: var(--fs-2xl); font-weight: var(--fw-bold);
  letter-spacing: -.01em;
}

.review-summary-line {
  font-size: var(--fs-md); color: var(--grey);
  line-height: 1.5;
}

.review-actions {
  margin-top: var(--sp-5);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--line);
  justify-content: space-between;
}

/* ---- mobile-friendly review actions stack ---- */
@media (max-width: 540px) {
  .review-actions { flex-direction: column-reverse; gap: var(--sp-2); }
  .review-actions .btn { width: 100%; justify-content: center; }
}

/* ---- pictures of pills, ensure they don't block clicks ---- */
.pill { user-select: none; }

/* ========================================================================
   Status colours
   ======================================================================== */
:root {
  --status-success: #16a34a;          /* "Proposal sent" green */
  --status-success-soft: rgba(22, 163, 74, .12);
}

/* ========================================================================
   Password gate
   ======================================================================== */

.gate {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: var(--sp-4);
  animation: gate-fade-in var(--d-norm) var(--ease-out);
}
html.is-unlocked .gate { display: none; }

@keyframes gate-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.gate-card {
  display: flex; flex-direction: column;
  gap: var(--sp-3);
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  box-shadow: var(--shadow);
  text-align: center;
}

.gate-logo {
  width: 300px; height: auto;
  max-width: 100%;
  display: block;
  /* No top margin: card padding-top (sp-6 / 24px) already gives breathing
     room above the logo. Bottom margin keeps a clean step down to the input. */
  margin: 0 auto var(--sp-3) auto;
  user-select: none;
  -webkit-user-drag: none;
}

/* Password field — input with the eye toggle anchored inside on the right.
   The standard pattern (Apple / Google / GitHub login forms): wrapper holds
   the input and an absolutely-positioned button. */
.password-field {
  position: relative;
  width: 100%;
}

.password-input {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: var(--fs-xl);
  line-height: 1.3;
  min-height: 46px;
  padding: 12px var(--sp-4);
  padding-right: 44px;             /* leave room for the eye toggle */
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color var(--d-fast) var(--ease-std),
              box-shadow   var(--d-fast) var(--ease-std);
}
.password-input:focus {
  border-color: var(--rp-red);
  box-shadow: 0 0 0 3px var(--rp-red-soft);
}
.password-input::placeholder { color: var(--grey-2); }

.password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: var(--grey-2);
  border-radius: var(--radius);
  transition: color var(--d-fast) var(--ease-std),
              background-color var(--d-fast) var(--ease-std);
}
@media (hover: hover) {
  .password-toggle:hover { color: var(--text); background: var(--zone-bg); }
}
.password-toggle svg { display: block; }

.gate-submit { width: 100%; justify-content: center; }

.gate-error {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--rp-red);
}

.gate-card.is-shaking { animation: gate-shake 250ms var(--ease-std); }
@keyframes gate-shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

/* ========================================================================
   Review screen — sending / error / success
   ======================================================================== */

.review-error {
  margin: var(--sp-4) 0 0 0;
  padding: var(--sp-3) var(--sp-4);
  background: var(--rp-red-soft);
  border: 1px solid var(--rp-red);
  border-radius: var(--radius);
  color: var(--rp-red);
  font-size: var(--fs-md);
  line-height: 1.5;
  animation: review-error-in var(--d-norm) var(--ease-out);
}
@keyframes review-error-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.btn .spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: var(--surface);
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: -2px;
  animation: spinner-rotate 700ms linear infinite;
}
@keyframes spinner-rotate {
  to { transform: rotate(360deg); }
}

/* Success state */

.review-success {
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: var(--sp-6) var(--sp-4) var(--sp-2);
  gap: var(--sp-3);
  animation: success-in var(--d-slow) var(--ease-out);
}
@keyframes success-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.review-success-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--status-success-soft);
  color: var(--status-success);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  font-weight: var(--fw-bold);
  margin-bottom: var(--sp-2);
}

.review-success-title {
  margin: 0;
  font-size: var(--fs-3xl);
  font-weight: var(--fw-bold);
  letter-spacing: -.01em;
  color: var(--text);
}

.review-success-body {
  margin: 0;
  max-width: 460px;
  color: var(--grey);
  font-size: var(--fs-lg);
  line-height: 1.5;
}
.review-success-body strong { color: var(--text); font-weight: var(--fw-medium); }

/* ========================================================================
   Mode toggle (segmented control at top of form)
   ======================================================================== */

.mode-bar {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}
.mode-bar > .mode-toggle { margin-bottom: 0; }

.mode-toggle {
  display: inline-flex;
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--sp-1);
  gap: var(--sp-1);
  margin-bottom: var(--sp-4);
  box-shadow: var(--shadow);
}
.mode-toggle button {
  font: inherit;
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  padding: 8px 16px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--grey);
  cursor: pointer;
  transition: background-color var(--d-fast) var(--ease-std),
              color           var(--d-fast) var(--ease-std);
}
@media (hover: hover) {
  .mode-toggle button:hover { color: var(--text); }
}
.mode-toggle button.is-active {
  background: var(--text);
  color: var(--surface);
}

/* ========================================================================
   Zones (zoned mode)
   ======================================================================== */

.zones {
  display: flex; flex-direction: column;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.zone {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  transition: border-color var(--d-fast) var(--ease-std),
              box-shadow var(--d-fast) var(--ease-std);
}
.zone.is-zone-drag-over { border-color: var(--rp-red); }
.zone.is-drag-over      { border-color: var(--rp-red); }   /* line drop target */
.zone.is-dragging       { opacity: .85; box-shadow: var(--shadow-drag); }

.zone-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: var(--sp-2) var(--sp-3);
  background: var(--zone-bg);
  border-bottom: 1px solid var(--line);
  user-select: none;
}
.zone[data-expanded="false"] .zone-header { border-bottom-color: transparent; }

.zone-drag-handle {
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  color: var(--grey-2);
  cursor: grab;
  touch-action: none;
}
.zone-drag-handle:active { cursor: grabbing; }

.zone-header-main { flex: 1; min-width: 0; }

.zone-name {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: var(--fs-lg);
  font-weight: var(--fw-medium);
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  transition: border-color var(--d-fast) var(--ease-std),
              background-color var(--d-fast) var(--ease-std);
  outline: none;
}
.zone-name::placeholder { color: var(--grey-2); font-weight: var(--fw-regular); }
.zone-name:focus {
  background: var(--surface);
  border-color: var(--rp-red);
  box-shadow: 0 0 0 3px var(--rp-red-soft);
}
.zone-name.invalid { border-color: var(--rp-red); }

.zone-summary {
  display: flex; align-items: baseline;
  gap: 4px;
  padding: 6px 8px;
  font-size: var(--fs-lg);
  cursor: pointer;
}
.zone-summary-name { font-weight: var(--fw-medium); color: var(--text); }
.zone-summary-meta { color: var(--grey); font-size: var(--fs-md); }

.zone-collapse-btn,
.zone-delete {
  background: transparent;
  border: 0;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--grey-2);
  font-size: var(--fs-2xl);
  line-height: 1;
  border-radius: var(--radius);
  transition: color var(--d-fast) var(--ease-std),
              background-color var(--d-fast) var(--ease-std);
}
@media (hover: hover) {
  .zone-collapse-btn:hover { color: var(--text); background: var(--surface); }
  .zone-delete:hover       { color: var(--rp-red); background: var(--surface); }
}
.zone-collapse-btn .caret { display: inline-block; }

.zone-body {
  padding: var(--sp-3);
}
.zone-lines {
  display: flex; flex-direction: column;
  gap: 10px;
  margin-bottom: var(--sp-3);
}
.zone-add-row { margin-bottom: var(--sp-3); }
.zone-add-row .btn { font-size: var(--fs-md); }

.zone-subtotal-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-top: var(--sp-3);
  border-top: 1px solid var(--line);
  font-size: var(--fs-lg);
  color: var(--grey);
}
.zone-subtotal-row .num {
  color: var(--text);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
}

/* Show / hide based on data-expanded */
.zone[data-expanded="true"]  .only-when-collapsed,
.zone[data-expanded="false"] .only-when-expanded {
  display: none;
}

/* Review screen — zones */
.review-zone {
  display: flex; flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--line);
}
.review-zone:first-child { border-top: 0; padding-top: 0; }
.review-zone-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 2px;
}
.review-zone-head h4 {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: var(--rp-red);
  letter-spacing: 0;
  text-transform: none;
}
.review-zone-subtotal {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: var(--sp-1);
  font-size: var(--fs-md);
  color: var(--grey);
  border-top: 1px dashed var(--line);
  padding-top: var(--sp-2);
}
.review-zone-subtotal .num { color: var(--text); font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; }

/* ========================================================================
   Tiers (tiered villa mode)
   Tiers are alternative proposals — visually heavier than zones so the
   operator never confuses "alternative" with "additional".
   ======================================================================== */

.tiers {
  display: flex; flex-direction: column;
  gap: var(--sp-5);
}

.tier {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-lg);
  /* No overflow:hidden — would clip the (i)-icon tooltip pseudo-element
     when it extends past the tier card boundary. The tier-header's
     subtle gradient will hug the rounded corners visually fine without
     it because there's no content that actually overflows. */
  transition:
    border-color var(--d-fast) var(--ease-std),
    box-shadow   var(--d-fast) var(--ease-std);
  box-shadow: var(--shadow);
}
.tier.is-tier-drag-over { border-color: var(--rp-red); }
.tier.is-dragging       { opacity: .85; box-shadow: var(--shadow-drag); }

.tier-header {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: linear-gradient(180deg, rgba(0,0,0,.02), transparent);
  border-bottom: 1px solid var(--line);
}
.tier[data-expanded="false"] .tier-header { border-bottom-color: transparent; }

.tier-drag-handle {
  cursor: grab;
  color: var(--grey-2);
  user-select: none;
  font-size: var(--fs-lg);
  padding: 4px;
  touch-action: none;
}
.tier-drag-handle:active { cursor: grabbing; }

.tier-header-main { flex: 1; min-width: 0; }
.tier-name {
  width: 100%;
  font: inherit;
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 6px 10px;
  margin: -6px -10px;
  letter-spacing: -.01em;
  transition: border-color var(--d-fast) var(--ease-std), background var(--d-fast) var(--ease-std);
}
.tier-name::placeholder { color: var(--grey-2); font-weight: var(--fw-regular); }
.tier-name:focus { outline: none; border-color: var(--line); background: var(--bg); }
.tier-name.invalid { border-color: var(--rp-red); }

.tier-summary {
  display: flex; align-items: baseline; gap: var(--sp-2); cursor: pointer;
  padding: 6px 10px;
  margin: -6px -10px;
}
.tier-summary-name { font-weight: var(--fw-bold); color: var(--text); font-size: var(--fs-xl); }
.tier-summary-meta { color: var(--grey); font-size: var(--fs-md); font-variant-numeric: tabular-nums; }

.tier-collapse-btn,
.tier-delete {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: var(--fs-lg);
  color: var(--grey);
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: background-color var(--d-fast) var(--ease-std), color var(--d-fast) var(--ease-std);
}
@media (hover: hover) {
  .tier-collapse-btn:hover { background: var(--bg); color: var(--text); }
  .tier-delete:hover       { background: var(--rp-red-soft); color: var(--rp-red); }
}
.tier-collapse-btn .caret { display: inline-block; }

.tier-body {
  padding: var(--sp-4);
  display: flex; flex-direction: column;
  gap: var(--sp-4);
}

.tier-zones-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: calc(-1 * var(--sp-2));
}
.tier-zones-head h3 {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--grey);
}

.tier-zones {
  display: flex; flex-direction: column;
  gap: var(--sp-3);
}
/* Zones-inside-a-tier: lighter visual treatment than the top-level
   zoned-mode card so the tier wrapper can carry the visual weight. */
.tier .zone {
  border-width: 1px;
  background: var(--bg);
}

.tier-add-row { margin-top: var(--sp-1); }
.tier-add-row .tier-add-zone { font-size: var(--fs-md); }

/* Outer "+ Add tier" button: needs breathing room from the last tier
   card. .tiers uses `gap` for inter-card spacing (which doesn't apply
   to siblings outside the container), so add an explicit top margin. */
#tiers-container > .add-row { margin-top: var(--sp-5); }

/* Locked zones (tier scaffolding: Technical Design, Control System, etc.).
   Visually distinguished by a softer header background and the absence of
   drag/×/rename controls. The collapse toggle is the only header action. */
.zone.is-locked > .zone-header {
  background: var(--bg);
  border-bottom-color: var(--line);
}
.zone.is-locked .zone-locked-name {
  margin: 0;
  padding: 6px 10px;
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: var(--text);
  letter-spacing: -.005em;
}
.zone.is-locked .zone-summary { cursor: pointer; }

/* Tier name row: input + small "i" info icon side by side. */
.tier-name-row {
  display: flex; align-items: center; gap: var(--sp-2);
  width: 100%;
}
.tier-name-row .tier-name { flex: 1; min-width: 0; }

/* "i" info-icon tooltip: small circle next to the tier name; on
   hover/focus, reveals the tier's architectural description. */
.tier-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--grey-2);
  color: var(--surface);
  font-size: 11px;
  font-weight: var(--fw-bold);
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  cursor: help;
  position: relative;
  flex-shrink: 0;
  user-select: none;
  transition: background-color var(--d-fast) var(--ease-std);
}
.tier-info:hover, .tier-info:focus { background: var(--text); outline: none; }

/* Tooltip pops ABOVE the icon (not below) so it can't bleed visually
   into the next tier card. width: max-content sizes to the natural
   line, capped at max-width so long descriptions wrap inside the
   bubble. High z-index lets it overlay neighbouring tiers. */
.tier-info::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--surface);
  padding: 8px 12px;
  border-radius: var(--radius);
  font: inherit;
  font-size: var(--fs-sm, 12px);
  font-style: normal;
  font-weight: var(--fw-regular);
  white-space: normal;
  width: max-content;
  max-width: 320px;
  visibility: hidden;
  opacity: 0;
  transition: opacity 150ms var(--ease-std);
  z-index: 100;
  pointer-events: none;
  line-height: 1.4;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .15);
}
.tier-info::after {
  content: "";
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--text);
  visibility: hidden;
  opacity: 0;
  transition: opacity 150ms var(--ease-std);
  pointer-events: none;
}
.tier-info:hover::before, .tier-info:focus::before,
.tier-info:hover::after,  .tier-info:focus::after {
  visibility: visible;
  opacity: 1;
}

/* Tier-summary collapsed view: keep the info icon inline at the same
   visual rhythm as the meta text. */
.tier-summary .tier-info { margin: 0 var(--sp-1); }

.tier-totals {
  display: flex; flex-direction: column;
  gap: 2px;
  padding-top: var(--sp-3);
  border-top: 1px solid var(--line);
  font-size: var(--fs-md);
  color: var(--grey);
}
.tier-tot-row {
  display: flex; justify-content: space-between; align-items: baseline;
}
.tier-tot-row .num {
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.tier-tot-row.tier-tot-grand {
  margin-top: var(--sp-1);
  padding-top: var(--sp-2);
  border-top: 1px dashed var(--line);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: var(--text);
}

/* Tier expand/collapse — scoped to tier-specific class names so the rules
   don't cascade INTO child zones (which use the same .only-when-X classes
   for their own header/body toggling). Without this scoping the cascade
   would hide zone-summary inside any collapsed zone whose parent tier was
   expanded — making the zone render as a header bar with no name visible. */
.tier[data-expanded="true"]  .tier-summary,
.tier[data-expanded="false"] .tier-name-row,
.tier[data-expanded="false"] > .tier-body {
  display: none;
}

/* Totals widget — tiered mode (overrides direct/zoned single-grand layout) */
.totals-block .totals-tiered-head {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--grey);
  margin-bottom: var(--sp-2);
}
.totals-block .totals-row.tier-row {
  font-size: var(--fs-md);
}
/* Per-tier savings sub-row: indented under its tier line, plain label,
   red amount via the existing .totals-savings .num rule. */
.totals-block .totals-row.tier-savings-row {
  padding-left: var(--sp-4);
  font-size: var(--fs-sm, var(--fs-md));
}
.totals-block .totals-row.tier-savings-row > span:first-child {
  color: var(--grey);
}
/* Same indentation pattern in the review screen's tier-totals comparison. */
.review-totals .review-tot-row.tier-savings-row {
  padding-left: var(--sp-4);
  font-size: var(--fs-sm, var(--fs-md));
}

/* Currency toggle (tiered mode only) */
.currency-toggle {
  display: flex; flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: var(--sp-4);
}
.currency-toggle .currency-show { margin: 0; }
.exchange-rate-row {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-md);
  color: var(--grey);
  flex-wrap: wrap;
}
.exchange-rate-row .rate-label { font-weight: var(--fw-medium); color: var(--text); }
.exchange-rate-row #exchange-rate {
  width: 90px;
  font: inherit;
  font-variant-numeric: tabular-nums;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  text-align: right;
}
.exchange-rate-row .rate-suffix { font-weight: var(--fw-medium); color: var(--text); }
.exchange-rate-row .rate-fetched {
  font-size: var(--fs-xs);
  color: var(--grey-2);
  font-style: italic;
}

/* Review screen — tiers */
.review-tier {
  display: flex; flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4) 0;
  border-top: 2px solid var(--line);
}
.review-tier:first-child { border-top: 0; padding-top: 0; }
.review-tier-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: var(--sp-1);
}
.review-tier-head h3 {
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  color: var(--rp-red);
}
.review-tier-desc {
  margin: 0 0 var(--sp-2);
  font-size: var(--fs-md);
  color: var(--grey);
  line-height: 1.5;
}
.review-tier-totals {
  margin-top: var(--sp-3);
  padding-top: var(--sp-2);
  border-top: 1px dashed var(--line);
  display: flex; flex-direction: column;
  gap: 2px;
  font-size: var(--fs-md);
}
.review-tier-totals .num { font-variant-numeric: tabular-nums; }
.review-tier-totals .review-tot-row.is-grand {
  font-weight: var(--fw-bold);
  font-size: var(--fs-lg);
  color: var(--text);
}
.review-fx-row {
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px dashed var(--line);
  font-size: var(--fs-xs);
  color: var(--grey);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ========================================================================
   Confirm modal — replaces window.confirm()
   ======================================================================== */

dialog.confirm-dialog {
  width: min(440px, 92vw);
  border: 0;
  border-radius: var(--radius-lg);
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
dialog.confirm-dialog[open] {
  animation: dialog-in var(--d-norm) var(--ease-out);
}
dialog.confirm-dialog::backdrop {
  background: rgba(0, 0, 0, .5);
  animation: backdrop-in 150ms var(--ease-out);
}

.confirm-card {
  padding: var(--sp-6);
  display: flex; flex-direction: column;
  gap: var(--sp-3);
}

.confirm-title {
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  letter-spacing: -.01em;
  color: var(--text);
  line-height: 1.3;
}

.confirm-body {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-md);
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}

@media (max-width: 540px) {
  .confirm-actions {
    flex-direction: column-reverse;
    gap: var(--sp-2);
  }
  .confirm-actions .btn { width: 100%; justify-content: center; }
}

