*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f8fbff;
  color: #092467;
  line-height: 1.5;
  font-size: 15px;
  font-weight: 400;
}

/* ── Header ─────────────────────────────────────────── */
header {
  background: #092467;
  color: #fff;
  padding: 1.1rem 2rem;
  border-bottom: 3px solid #1f2868;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
}

header h1 {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-style: italic;
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: 0;
  color: #fff;
}

.header-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: rgba(255,255,255,0.85);
  font-size: 0.85rem;
}

.user-email {
  font-weight: 500;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signout-btn {
  background: transparent;
  border: 1.5px solid rgba(255,255,255,0.3);
  color: #fff;
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}

.signout-btn:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.5);
}

.country-tabs {
  display: flex;
  gap: 0.35rem;
  background: rgba(255,255,255,0.08);
  padding: 0.25rem;
  border-radius: 999px;
}

.country-tab {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.75);
  padding: 0.4rem 0.95rem;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
}

.country-tab:hover:not(.active) {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

.country-tab.active {
  background: #fff;
  color: #262b89;
  font-weight: 600;
}

/* Price ⇄ Weight view toggle (header) — pill style, like the country tabs */
.mode-toggle {
  display: flex;
  gap: 0.25rem;
  background: rgba(255,255,255,0.08);
  padding: 0.25rem;
  border-radius: 999px;
}

.mode-tab {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.75);
  padding: 0.4rem 1.05rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
}

.mode-tab:hover:not(.active) {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

.mode-tab.active {
  background: #fff;
  color: #262b89;
}

/* View switching: show one summary card and hide the other; in weight mode the
   price-only input cards are hidden too (v1 weight = headstone only). */
#weight-card { display: none; }
body.mode-weight #weight-card { display: block; }
body.mode-weight #price-card { display: none; }
body.mode-weight #base-section,
body.mode-weight #addons-section,
body.mode-weight #grave-frame-section,
body.mode-weight #flower-frame-section { display: none !important; }

/* The Base weight tab reveals the Base Dimensions card so its size can be weighed —
   including when the quote is priced without a base, since the customer's existing
   sokkel can still be weighed. #base-body is hidden by JS in price mode only. */
body.mode-weight.weight-ptype-base #base-section { display: block !important; }
body.mode-weight.weight-ptype-base #base-body    { display: block !important; }
/* Base mode + the existing-foundation figures are pricing concepts — irrelevant on the
   weight tab, which just weighs whatever block is in the base fields. */
body.mode-weight #base-mode-row   { display: none; }
body.mode-weight #foundation-body { display: none; }

/* Base shape toggle — only relevant to weight, hidden everywhere except the Base tab. */
.base-shape-row { display: none; align-items: center; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.85rem; }

/* Two-state base mode, in the Base card header row. */
.base-mode-row { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; }

/* Existing-foundation fields: two numbers, so half the width of .dimensions-grid's three. */
.foundation-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; margin-bottom: 0.75rem; }
body.mode-weight.weight-ptype-base .base-shape-row { display: flex; }

/* Product-type tabs inside the Weight card */
.product-type-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 1rem;
}

.ptype-tab {
  background: #f0f2fa;
  border: 1px solid transparent;
  color: #475569;
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
}

.ptype-tab.active {
  background: #262b89;
  color: #fff;
}

.ptype-tab:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: #f1f5f9;
  color: #94a3b8;
}

.ptype-soon {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 0.25rem;
  opacity: 0.8;
}

/* ── Layout ──────────────────────────────────────────── */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.75rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.calculator-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.25rem;
  align-items: start;
}

.inputs-col {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── Cards ───────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 12px;
  padding: 1.4rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
}

.form-section {
  /* slight bottom margin handled by gap in inputs-col */
}

.sticky-card {
  position: sticky;
  top: 1rem;
}

h2 {
  font-size: 0.7rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.9rem;
}

.summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.summary-header h2 {
  margin-bottom: 0;
}

.summary-country {
  font-size: 0.78rem;
  font-weight: 600;
  color: #1a1f6a;
  background: #f0f2fa;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}

h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #092467;
  margin-bottom: 0.75rem;
}

.divider {
  height: 1.5px;
  background: #f1f5f9;
  margin: 1rem 0;
}

/* ── Material selector ───────────────────────────────── */
.material-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.material-btn {
  padding: 0.65rem 0.875rem;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  background: #fff;
  text-align: left;
  font-size: 0.82rem;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: border-color 0.12s, background 0.12s;
  white-space: nowrap;
}

.material-btn:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.material-btn.selected {
  border-color: #262b89;
  background: #f0f2fa;
  color: #1a1f6a;
  font-weight: 600;
}

.material-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.15);
}

/* ── Dimension inputs ────────────────────────────────── */
.dimensions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: #475569;
}

.required {
  color: #ef4444;
}

input[type="number"],
input[type="text"],
textarea,
select {
  padding: 0.45rem 0.7rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 7px;
  font-size: 0.875rem;
  color: #092467;
  background: #fff;
  width: 100%;
  transition: border-color 0.12s, box-shadow 0.12s;
  font-family: inherit;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: #262b89;
  box-shadow: 0 0 0 3px rgba(38,43,137,0.14);
}

textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.5;
}

/* ── Modifier list ───────────────────────────────────── */
.modifier-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.modifier-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.875rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  user-select: none;
}

.modifier-item:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.modifier-item.selected {
  border-color: #262b89;
  background: #f0f2fa;
}

.modifier-name {
  font-size: 0.85rem;
  color: #092467;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modifier-name input[type="checkbox"] {
  width: auto;
  accent-color: #262b89;
}

.modifier-price {
  font-size: 0.82rem;
  color: #64748b;
  font-weight: 500;
}

/* ── Price summary ───────────────────────────────────── */
.price-breakdown {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
}

.price-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.875rem;
  color: #475569;
  padding: 0.2rem 0;
}

.price-line span:last-child {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.price-line.total {
  font-size: 1.05rem;
  font-weight: 700;
  color: #262b89;
  border-top: 2px solid #f1f5f9;
  padding-top: 0.65rem;
  margin-top: 0.2rem;
}

.price-line.total span:last-child {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-weight: 400;
  font-size: 1.25rem;
  color: #262b89;
}

.price-line.size-detail {
  color: #94a3b8;
  font-size: 0.74rem;
  padding: 0.05rem 0;
  font-variant-numeric: tabular-nums;
}

.price-line.multiplier-line {
  font-size: 0.85rem;
  color: #092467;
  background: #f0f2fa;
  border-radius: 6px;
  padding: 0.35rem 0.55rem;
  margin: 0.25rem 0;
}

.price-line.multiplier-line span:last-child {
  color: #1a1f6a;
  font-weight: 500;
}

.price-empty {
  text-align: center;
  color: #94a3b8;
  font-size: 0.85rem;
  padding: 1.75rem 0;
  line-height: 1.6;
}

/* ── Save form ───────────────────────────────────────── */
.save-form {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.12s, border-color 0.12s;
  width: 100%;
  font-family: inherit;
}

.btn-primary {
  background: #262b89;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #1a1f6a;
}

.btn-primary:disabled {
  background: #9ea2c8;
  cursor: not-allowed;
}

.btn-sm {
  width: auto;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
}

.btn-ghost {
  background: #f8fafc;
  color: #475569;
  border: 1.5px solid #e2e8f0;
}

.btn-ghost:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.btn-danger-ghost {
  background: #fff;
  color: #dc2626;
  border: 1.5px solid #fecaca;
}

.btn-danger-ghost:hover {
  background: #fef2f2;
  border-color: #dc2626;
}

/* ── History ─────────────────────────────────────────── */
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.history-header h2 {
  margin-bottom: 0;
}

.search-input {
  width: 280px;
}

.history-empty {
  text-align: center;
  color: #94a3b8;
  font-size: 0.875rem;
  padding: 3rem 0;
}

/* ── Calculation cards ───────────────────────────────── */
.calc-card {
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 1rem 1.2rem;
  margin-bottom: 0.65rem;
  transition: border-color 0.12s;
}

.calc-card:last-child {
  margin-bottom: 0;
}

.calc-card:hover {
  border-color: #94a3b8;
}

.calc-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.calc-customer {
  font-weight: 600;
  color: #092467;
  font-size: 0.95rem;
}

.calc-ref {
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 0.1rem;
}

.calc-top-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.calc-date {
  font-size: 0.78rem;
  color: #64748b;
  white-space: nowrap;
}

.age-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}

.age-recent   { background: #dcfce7; color: #15803d; }
.age-review   { background: #fef9c3; color: #a16207; }
.age-old      { background: #fee2e2; color: #dc2626; }

.calc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.45rem;
}

.chip {
  background: #f1f5f9;
  color: #475569;
  font-size: 0.75rem;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  font-weight: 500;
}

.calc-notes {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 0.5rem;
  font-style: italic;
}

.calc-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1.5px solid #f1f5f9;
  gap: 1rem;
}

.calc-price-block {
  min-width: 0;
}

.calc-total {
  font-size: 1.1rem;
  font-weight: 700;
  color: #092467;
  font-variant-numeric: tabular-nums;
}

.calc-subtotals {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 0.15rem;
}

.calc-approved-by {
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 0.1rem;
}

.calc-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* ── Model picker ────────────────────────────────────── */
/* ── Headstone type switch (standing / flat) ─────────── */
.type-card {
  margin-bottom: 1rem;
}

.type-switch-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.type-switch-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}

.type-switch {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.type-card .auto-hint {
  margin-top: 0.6rem;
  margin-bottom: 0;
}

.model-card {
  /* spans full width above the calculator-layout */
}

.model-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.model-card-header h2 {
  margin-bottom: 0;
  flex-shrink: 0;
}

.model-mode-toggle,
.match-toggle {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.radio-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.8rem;
  color: #475569;
  font-weight: 500;
  background: #fff;
  transition: all 0.12s;
  user-select: none;
}

.radio-pill:hover {
  border-color: #94a3b8;
}

.radio-pill input[type="radio"] {
  width: auto;
  margin: 0;
  accent-color: #262b89;
}

.radio-pill:has(input:checked) {
  border-color: #262b89;
  background: #f0f2fa;
  color: #1a1f6a;
}

.model-search {
  width: 100%;
  margin-bottom: 0.85rem;
}

.model-table-wrap {
  max-height: 380px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}

.model-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
}

.model-table thead th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  border-bottom: 1.5px solid #e2e8f0;
  padding: 0.55rem 0.85rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
  white-space: nowrap;
}

.model-table thead th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.12s, background 0.12s;
}

.model-table thead th.sortable:hover {
  background: #f1f5f9;
  color: #092467;
}

.model-table thead th.sorted {
  color: #1a1f6a;
}

.model-table .col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.model-table .col-image {
  width: 64px;
  text-align: center;
  padding: 0.3rem 0.5rem;
}

.model-thumb {
  display: block;
  width: 48px;
  height: 48px;
  object-fit: contain;
  margin: 0 auto;
  background: #f8fbff;
  border-radius: 4px;
}

.model-table tbody td {
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid #f1f5f9;
  color: #092467;
  vertical-align: middle;
}

.model-table tbody tr:last-child td {
  border-bottom: none;
}

.model-table tbody tr.model-row {
  cursor: pointer;
  transition: background 0.1s;
}

.model-table tbody tr.model-row:hover {
  background: #f8fafc;
}

.model-table tbody tr.model-row.selected {
  background: #f0f2fa;
}

.model-table tbody tr.model-row.selected td {
  color: #1a1f6a;
}

.model-table tbody tr.model-row.selected td.col-name {
  font-weight: 600;
}

.model-table .col-name {
  font-weight: 500;
}

.model-table .col-price {
  color: #262b89;
  font-weight: 500;
}

.model-table .feature-chip {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  margin-right: 0.2rem;
  white-space: nowrap;
}

.model-table .muted {
  color: #cbd5e1;
}

.model-empty {
  text-align: center;
  color: #94a3b8;
  font-size: 0.85rem;
  padding: 1.5rem 0;
}

.selected-model-info {
  margin-top: 0.85rem;
  padding: 0.7rem 0.9rem;
  background: #f0f2fa;
  border: 1.5px solid #c5c8e6;
  border-radius: 8px;
  font-size: 0.82rem;
  color: #1a1f6a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.selected-model-info strong {
  font-weight: 600;
}

/* ── Special material ────────────────────────────────── */
.special-material-row {
  margin-top: 0.65rem;
  display: flex;
  justify-content: flex-end;
}

.special-material-form {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1.5px dashed #e2e8f0;
}

.special-material-form.active {
  background: #fefce8;
  border: 1.5px solid #fde047;
  border-radius: 8px;
  padding: 0.85rem;
  margin-top: 0.65rem;
}

.special-material-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0.75rem;
}

#toggle-special-material.active {
  background: #fef3c7;
  border-color: #fbbf24;
  color: #92400e;
}

/* ── Shape toggle ────────────────────────────────────── */
.shape-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.85rem;
  flex-wrap: wrap;
}

.shape-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 0.25rem;
}

/* ── Section header w/ trailing action ───────────────── */
.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
  gap: 1rem;
  /* Every use of this row pairs the title with a wordy trailing control — the Base card's
     mode pills + reset link, "Add a Grave Frame", "Add a flower bed frame" — so all three
     must be free to drop that control onto its own line on narrow phones. */
  flex-wrap: wrap;
}

.section-header-row h2 {
  margin-bottom: 0;
}

.link-btn {
  background: none;
  border: none;
  color: #262b89;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.15rem 0.3rem;
  font-family: inherit;
}

.link-btn:hover {
  text-decoration: underline;
}

.auto-hint {
  font-size: 0.78rem;
  color: #94a3b8;
  margin-bottom: 0.75rem;
  font-style: italic;
}

.ratio-lock-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.85rem;
}

.ratio-lock-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: #262b89;
  cursor: pointer;
  user-select: none;
}

.ratio-lock-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #262b89;
  cursor: pointer;
}

.ratio-lock-readout {
  font-size: 0.78rem;
  color: #475569;
  font-weight: 500;
}

.ratio-lock-hint {
  margin-top: 0.75rem;
  margin-bottom: 0;
  padding: 0.55rem 0.8rem;
  background: #f0f2fa;
  color: #1a1f6a;
  border-left: 3px solid #262b89;
  border-radius: 4px;
  font-size: 0.85rem;
}

.field.ratio-locked > input,
.field.ratio-locked > select {
  background: #f0f2fa;
  border-color: #262b89;
}
.field.ratio-locked::before {
  content: '🔗';
  position: absolute;
  top: -0.1rem;
  right: 0.25rem;
  font-size: 0.85rem;
  opacity: 0.7;
}
.field.ratio-locked {
  position: relative;
}

/* ── Match type chip on history cards ────────────────── */
.match-chip {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}

.match-chip-exact   { background: #e0e3f0; color: #1a1f6a; }
.match-chip-similar { background: #fef3c7; color: #92400e; }

/* ── Catalog editor ──────────────────────────────────── */
.catalog-editor {
  padding: 0;
}

.catalog-editor > summary {
  cursor: pointer;
  list-style: none;
  padding: 1.4rem 1.5rem;
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
}

.catalog-editor > summary::-webkit-details-marker { display: none; }
.catalog-editor > summary::before {
  content: '▸';
  color: #94a3b8;
  font-size: 0.8rem;
  transition: transform 0.15s;
}
.catalog-editor[open] > summary::before { transform: rotate(90deg); }

.catalog-editor > summary h2 {
  margin-bottom: 0;
}

.catalog-summary-hint {
  font-size: 0.78rem;
  color: #94a3b8;
}

.catalog-editor-body {
  padding: 0 1.5rem 1.4rem;
}

.catalog-table-wrap {
  max-height: 480px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.catalog-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8rem;
}

.catalog-table thead th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  border-bottom: 1.5px solid #e2e8f0;
  text-align: left;
  padding: 0.55rem 0.75rem;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}

.catalog-table tbody td {
  border-bottom: 1px solid #f1f5f9;
  padding: 0.4rem 0.75rem;
  vertical-align: middle;
}

.catalog-table tbody tr:last-child td { border-bottom: none; }

.catalog-table tbody tr.changed td {
  background: #fef9c3;
}

.catalog-table .col-name {
  font-weight: 500;
  color: #092467;
  white-space: nowrap;
}

.catalog-table .col-feature,
.catalog-table .col-shape {
  text-align: center;
}

.catalog-table .col-dims {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: #475569;
}

.catalog-table select {
  padding: 0.25rem 0.5rem;
  font-size: 0.78rem;
}

.catalog-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #262b89;
  cursor: pointer;
}

.catalog-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1rem;
}

.catalog-actions .btn { width: auto; }

.catalog-status {
  font-size: 0.8rem;
  color: #64748b;
}

.catalog-status.success { color: #16a34a; }
.catalog-status.error   { color: #dc2626; }

/* ── Grave Frame section ─────────────────────────────── */
.frame-enable {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: #262b89;
  cursor: pointer;
  user-select: none;
}

.frame-enable input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #262b89;
  cursor: pointer;
}

.frame-body {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 0.25rem;
}

.frame-config-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Flat frame: width | length on the first row, profile H | W on the second. */
.frame-flat-grid {
  grid-template-columns: repeat(2, 1fr);
}

.frame-material-readout {
  margin-bottom: 0;
  margin-top: 0.25rem;
}

/* ── Additional frame pieces ─────────────────────────── */
.frame-pieces {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.frame-pieces-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.frame-pieces-menu {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem;
  background: #f8fbff;
  border: 1px solid #e0e3f0;
  border-radius: 8px;
}

.frame-piece-option {
  text-align: left;
  font-family: inherit;
  font-size: 0.82rem;
  color: #1a1f6a;
  background: #fff;
  border: 1px solid #e0e3f0;
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  cursor: pointer;
}

.frame-piece-option:hover {
  background: #f0f2fa;
  border-color: #262b89;
}

.frame-pieces-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.frame-pieces-list:empty {
  display: none;
}

.frame-piece-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  background: #f0f2fa;
  border-radius: 6px;
  font-size: 0.82rem;
  flex-wrap: wrap;
}

.frame-piece-main {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex: 1;
  min-width: 12rem;
  flex-wrap: wrap;
}

.frame-piece-label {
  font-weight: 600;
  color: #1a1f6a;
  white-space: nowrap;
}

.frame-piece-desc {
  color: #64748b;
  font-size: 0.76rem;
}

.frame-piece-dims {
  display: flex;
  gap: 0.4rem;
}

.frame-piece-dim {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.74rem;
  font-weight: 600;
  color: #475569;
}

.frame-piece-dim input {
  width: 3.4rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 400;
}

.frame-piece-remove {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
}

.frame-piece-remove:hover {
  color: #b91c1c;
  background: #fef2f2;
}

.frame-summary {
  margin-top: 0.9rem;
  padding-top: 0.85rem;
  border-top: 1px dashed #cbd5e1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.frame-summary-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  color: #262b89;
  margin-bottom: 0.2rem;
}

.frame-summary-note {
  font-size: 0.72rem;
  color: #94a3b8;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.frame-summary-error {
  font-size: 0.8rem;
  color: #b91c1c;
  background: #fef2f2;
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
}

.price-line.total.grand-total {
  border-top-style: dashed;
}

/* ── Tablet & narrower: collapse the two-column calculator ─ */
@media (max-width: 820px) {
  main {
    padding: 1.25rem 1rem;
  }

  /* Single column: inputs stack above the price/weight summary. */
  .calculator-layout {
    grid-template-columns: 1fr;
  }

  /* No sticky in a single-column flow — the summary just follows the inputs. */
  .sticky-card {
    position: static;
  }
}

/* ── Mobile / narrow viewports ───────────────────────── */
@media (max-width: 640px) {
  /* Belt-and-suspenders: nothing should push the page wider than the screen.
     Wide tables scroll inside their own bordered wrappers instead. */
  html, body {
    overflow-x: hidden;
  }

  main {
    padding: 1rem 0.85rem;
    gap: 1.1rem;
  }

  .card {
    padding: 1.1rem 1rem;
  }

  header {
    padding: 0.85rem 1rem;
  }

  .header-inner {
    align-items: flex-start;
    gap: 0.75rem;
  }

  header h1 {
    font-size: 1.25rem;
  }

  .brand-logo {
    width: 34px;
    height: 34px;
  }

  /* Let the controls wrap onto their own full-width rows instead of running
     off the right edge of the screen. */
  .header-right {
    width: 100%;
    justify-content: flex-start;
    gap: 0.6rem 0.9rem;
  }

  /* Push the email + sign-out to their own line and keep the button on-screen
     by letting the (possibly long) email shrink/ellipsis. */
  .user-menu {
    flex: 1 1 100%;
    justify-content: space-between;
  }

  .user-email {
    max-width: none;
    flex: 1 1 auto;
    min-width: 0;
  }

  .signout-btn {
    flex: 0 0 auto;
  }

  /* Model picker: keep a small thumbnail + name + H/W/T + price, but drop the
     Shape and Built-in columns so the whole row fits without scrolling. */
  .model-table {
    font-size: 0.8rem;
  }

  .model-table thead th,
  .model-table tbody td {
    padding: 0.4rem 0.4rem;
  }

  /* Hide the lower-priority columns on phones. */
  .model-table .col-shape,
  .model-table .col-features {
    display: none;
  }

  /* Bring the thumbnail back, smaller. */
  .model-table .col-image {
    width: 34px;
    padding: 0.25rem 0.3rem;
  }

  .model-table .model-thumb {
    width: 30px;
    height: 30px;
  }

  /* H/W/T pulled tight together so name and price keep the two ends. */
  .model-table .col-height,
  .model-table .col-width,
  .model-table .col-thickness {
    width: 2.1rem;
    padding-left: 0.2rem;
    padding-right: 0.2rem;
  }

  /* Keep the price on one line at the right edge. */
  .model-table .col-price {
    white-space: nowrap;
  }

  /* Catalog editor: variable feature columns can't fit — scroll within the wrap. */
  .catalog-table {
    font-size: 0.76rem;
  }

  .catalog-table thead th,
  .catalog-table tbody td {
    padding: 0.4rem 0.5rem;
  }

  .catalog-editor > summary {
    padding: 1.1rem 1rem;
  }

  .catalog-editor-body {
    padding: 0 1rem 1.1rem;
  }

  /* Tighten the dimension grids and stack the special-material pair. */
  .dimensions-grid {
    gap: 0.5rem;
  }

  .special-material-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Utility ─────────────────────────────────────────── */
.hidden { display: none !important; }
