/* ==========================================================================
   BLOC Calculator Marketing — light and dark themes, desktop and mobile.
   Colour tokens of the light theme can be overridden from the admin panel.
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #f0f0ed;
  --topbar-bg: #f4f4f2;
  --tab-bg: #e8e8e5;
  --item-bg: #ffffff;
  --input-bg: #ffffff;
  --disabled-bg: #f0f0ed;
  --ink: #111111;
  --muted: #6b6b68;
  --line: #e2e2de;
  --accent: #111111;
  --accent-2: #3a3a3a;
  --button-bg: #ffffff;
  --button-text: #111111;
  --button-active-bg: #111111;
  --button-active-text: #ffffff;
  --good: #1f7a4d;
  --bad: #c0362c;
  --warn: #a35b00;
  --badge-text: #ffffff;
  --neutral-bg: #efe7d6;
  --neutral-text: #4a3920;
  --notice-bg: #fff8e6;
  --notice-text: #5a3d00;
  --notice-border: #f0d9a0;

  --shadow: 0 1px 2px rgb(17 17 17 / 0.04), 0 8px 24px rgb(17 17 17 / 0.05);
  --shadow-pop: 0 12px 40px rgb(17 17 17 / 0.16);
  --focus: color-mix(in srgb, var(--accent) 35%, transparent);
  --hover: color-mix(in srgb, var(--ink) 5%, transparent);
  --radius: 14px;
  --radius-sm: 10px;
  --topbar-height: 68px;
  --page-pad: clamp(16px, 3vw, 32px);

  font-family: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "Roboto", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

/* Dark palette: explicit choice, or the system setting when no choice was made. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0c0c;
  --surface: #161616;
  --surface-2: #1f1f1f;
  --topbar-bg: #0c0c0c;
  --tab-bg: #1f1f1f;
  --item-bg: #1a1a1a;
  --input-bg: #111111;
  --disabled-bg: #1b1b1b;
  --ink: #f2f2f0;
  --muted: #9b9b97;
  --line: #2b2b2b;
  --accent: #f2f2f0;
  --accent-2: #cfcfcb;
  --button-bg: #1d1d1d;
  --button-text: #f2f2f0;
  --button-active-bg: #f2f2f0;
  --button-active-text: #0c0c0c;
  --good: #4cc38a;
  --bad: #ff6b5e;
  --warn: #f0a640;
  --badge-text: #0c0c0c;
  --neutral-bg: #3a3222;
  --neutral-text: #f0dfbd;
  --notice-bg: #261f12;
  --notice-text: #f3d9a4;
  --notice-border: #4d3c1d;
  --shadow: 0 0 0 1px rgb(255 255 255 / 0.02);
  --shadow-pop: 0 16px 48px rgb(0 0 0 / 0.6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c0c0c;
    --surface: #161616;
    --surface-2: #1f1f1f;
    --topbar-bg: #0c0c0c;
    --tab-bg: #1f1f1f;
    --item-bg: #1a1a1a;
    --input-bg: #111111;
    --disabled-bg: #1b1b1b;
    --ink: #f2f2f0;
    --muted: #9b9b97;
    --line: #2b2b2b;
    --accent: #f2f2f0;
    --accent-2: #cfcfcb;
    --button-bg: #1d1d1d;
    --button-text: #f2f2f0;
    --button-active-bg: #f2f2f0;
    --button-active-text: #0c0c0c;
    --good: #4cc38a;
    --bad: #ff6b5e;
    --warn: #f0a640;
    --badge-text: #0c0c0c;
    --neutral-bg: #3a3222;
    --neutral-text: #f0dfbd;
    --notice-bg: #261f12;
    --notice-text: #f3d9a4;
    --notice-border: #4d3c1d;
    --shadow: 0 0 0 1px rgb(255 255 255 / 0.02);
    --shadow-pop: 0 16px 48px rgb(0 0 0 / 0.6);
  }
}

/* ------------------------------------------------------------ base */

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

html {
  background: var(--bg);
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

svg {
  flex: none;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.is-hidden {
  display: none !important;
}

/* ------------------------------------------------------------ controls */

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--button-text);
  background: var(--button-bg);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, opacity 120ms ease;
}

button:hover:not(:disabled),
.button-link:hover {
  border-color: color-mix(in srgb, var(--ink) 30%, var(--line));
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button svg,
.button-link svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary-action {
  border-color: var(--button-active-bg);
  color: var(--button-active-text);
  background: var(--button-active-bg);
}

.primary-action:hover:not(:disabled) {
  border-color: var(--button-active-bg);
  background: color-mix(in srgb, var(--button-active-bg) 85%, var(--bg));
}

.primary-action.is-loading {
  opacity: 0.7;
}

.ghost-button,
.link-button {
  min-height: 34px;
  padding: 0 10px;
  border-color: transparent;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
}

.ghost-button:hover:not(:disabled),
.link-button:hover:not(:disabled) {
  border-color: transparent;
  color: var(--ink);
  background: var(--hover);
}

.link-button {
  justify-self: start;
  padding: 0;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-button:hover:not(:disabled) {
  background: transparent;
}

.icon-button {
  width: 40px;
  min-width: 40px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.danger-text {
  color: var(--bad) !important;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--input-bg);
  font-size: 15px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
}

input[type="color"] {
  padding: 3px;
  cursor: pointer;
}

select {
  appearance: none;
  padding-right: 38px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 19px) 50%,
    calc(100% - 14px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

input:hover:not(:disabled),
select:hover:not(:disabled),
textarea:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--ink) 25%, var(--line));
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--focus);
}

input:disabled,
select:disabled {
  color: var(--muted);
  background-color: var(--disabled-bg);
  cursor: not-allowed;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field > span:first-child,
.field-heading {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
}

.form-error {
  min-height: 0;
  color: var(--bad);
  font-size: 14px;
  font-weight: 600;
}

.form-error:empty {
  display: none;
}

.input-with-unit {
  position: relative;
  display: block;
}

.input-with-unit input {
  padding-right: 42px;
  font-variant-numeric: tabular-nums;
}

.input-with-unit .unit {
  position: absolute;
  top: 50%;
  right: 12px;
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
  transform: translateY(-50%);
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  cursor: pointer;
}

/* ------------------------------------------------------------ help tooltips */

.help-wrap {
  position: relative;
  display: inline-flex;
}

.help-button {
  width: 18px;
  min-width: 18px;
  min-height: 18px;
  padding: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  font-weight: 700;
}

.help-tooltip {
  position: absolute;
  z-index: 40;
  top: calc(100% + 8px);
  left: -8px;
  display: none;
  width: min(280px, calc(100vw - 48px));
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
}

.help-wrap.is-open .help-tooltip {
  display: block;
}

/* ------------------------------------------------------------ top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--topbar-bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
}

.topbar-inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  max-width: 1480px;
  min-height: var(--topbar-height);
  margin: 0 auto;
  padding: 10px var(--page-pad);
}

.brand {
  display: flex;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}

.logo-svg {
  display: block;
  width: auto;
  height: 22px;
}

.tabs {
  display: inline-flex;
  justify-self: center;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--tab-bg);
}

.tab {
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
}

.tab:hover:not(:disabled) {
  color: var(--ink);
}

.tab.is-active {
  color: var(--button-active-text);
  background: var(--button-active-bg);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.12);
}

.tab-icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 8px;
}

.theme-toggle svg {
  width: 19px;
  height: 19px;
}

.theme-toggle .icon-sun,
:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-moon {
    display: none;
  }

  :root:not([data-theme="light"]) .theme-toggle .icon-sun {
    display: block;
  }
}

.user-menu {
  position: relative;
}

.user-button {
  gap: 8px;
  padding: 0 10px 0 4px;
}

.avatar {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  color: var(--button-active-text);
  background: var(--button-active-bg);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.user-name {
  max-width: 160px;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron {
  width: 16px !important;
  height: 16px !important;
  color: var(--muted);
}

.user-dropdown {
  position: absolute;
  z-index: 40;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  min-width: 230px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}

.user-dropdown-head {
  display: grid;
  gap: 2px;
  margin-bottom: 4px;
  padding: 10px 10px 12px;
  border-bottom: 1px solid var(--line);
}

.user-dropdown-head small {
  color: var(--muted);
}

.user-dropdown button {
  justify-content: flex-start;
  border: 0;
  background: transparent;
}

.user-dropdown button:hover {
  background: var(--hover);
}

/* ------------------------------------------------------------ layout */

main {
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px var(--page-pad) 48px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
  animation: fade-in 160ms ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

.loading-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 50vh;
  color: var(--muted);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.layout {
  display: grid;
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  align-items: start;
  gap: 24px;
}

/* ------------------------------------------------------------ inputs */

.input-panel {
  position: sticky;
  top: calc(var(--topbar-height) + 20px);
  max-height: calc(100vh - var(--topbar-height) - 40px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.input-panel .panel-head {
  position: sticky;
  z-index: 2;
  top: 0;
  background: var(--surface);
}

.form-grid {
  display: grid;
  gap: 4px;
  padding: 8px 20px 20px;
}

.input-group {
  padding: 12px 0;
}

.input-group + .input-group {
  border-top: 1px solid var(--line);
}

.input-group-title {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.input-group-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 12px;
}

.input-group-fields > .field {
  grid-column: 1 / -1;
}

.input-group-fields > .field[data-field="apartmentArea"],
.input-group-fields > .field[data-field="bathroomArea"],
.input-group-fields > .field[data-field="year"],
.input-group-fields > .field[data-field="contractType"],
.input-group-fields > .field[data-field="manualCommission"],
.input-group-fields > .field[data-field="benefitType"] {
  grid-column: span 1;
}

.info-slot {
  display: grid;
  gap: 10px;
}

.info-slot:empty {
  display: none;
}

.input-panel .info-slot {
  padding: 16px 20px 0;
}

.info-block,
.notice {
  padding: 12px 16px;
  border: 1px solid var(--notice-border);
  border-radius: var(--radius-sm);
  color: var(--notice-text);
  background: var(--notice-bg);
  line-height: 1.5;
  white-space: pre-wrap;
}

.notice {
  display: none;
}

.notice.is-visible {
  display: block;
}

/* ------------------------------------------------------------ results */

.result-stack {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.hero {
  display: grid;
  gap: 20px;
  padding: 24px;
}

.hero-figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px 24px;
  transition: opacity 160ms ease;
}

.hero.is-updating .hero-figures {
  opacity: 0.5;
}

.figure {
  display: grid;
  align-content: start;
  gap: 4px;
  min-width: 0;
}

.figure.is-main {
  grid-column: 1 / -1;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.figure-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.figure-value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.figure.is-main .figure-value {
  font-size: clamp(34px, 4.4vw, 52px);
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.figure-hint {
  color: var(--muted);
  font-size: 13px;
}

.hero-actions {
  display: flex;
  justify-content: flex-end;
}

.hero-actions .primary-action {
  min-height: 48px;
  padding: 0 22px;
  font-size: 15px;
}

.details-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  margin: 0;
}

.detail {
  display: grid;
  gap: 4px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.detail dt {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.detail dd {
  display: grid;
  gap: 2px;
  margin: 0;
}

.detail-value {
  font-weight: 650;
  overflow-wrap: anywhere;
}

.detail small {
  color: var(--muted);
  font-size: 12px;
}

/* ------------------------------------------------------------ benefit / gifts */

.promo-body {
  display: grid;
  gap: 14px;
  padding: 18px 20px 20px;
}

.benefit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.benefit-summary {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.benefit-kind {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.benefit-summary strong {
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}

.benefit-summary small {
  color: var(--muted);
}

.benefit-photo {
  position: relative;
  width: 72px;
  min-width: 72px;
  height: 72px;
  padding: 0;
  overflow: hidden;
  border-radius: var(--radius-sm);
}

.benefit-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.benefit-photo span {
  position: absolute;
  right: 4px;
  bottom: 4px;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  color: #fff;
  background: rgb(0 0 0 / 0.65);
  font-size: 11px;
}

.gift-picker {
  display: grid;
  gap: 8px;
}

.gift-picker-trigger {
  justify-content: space-between;
  width: 100%;
  min-height: 52px;
  padding: 8px 14px;
  text-align: left;
}

.gift-picker-trigger[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.gift-picker-label {
  display: grid;
  gap: 2px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.gift-picker-label small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.gift-picker-list {
  display: grid;
  gap: 12px;
  max-height: 420px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.gift-search {
  min-height: 40px;
}

.gift-picker-group {
  display: grid;
  gap: 4px;
}

.gift-picker-group h3 {
  margin: 4px 4px 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.gift-option {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 18px;
  justify-content: stretch;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 6px 10px 6px 6px;
  border-color: transparent;
  background: var(--item-bg);
  text-align: left;
  font-weight: 500;
}

.gift-option:hover:not(:disabled) {
  border-color: var(--line);
}

.gift-option.is-selected {
  border-color: var(--accent);
}

.gift-option-photo {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
}

.gift-option-photo.is-empty {
  background:
    linear-gradient(135deg, transparent 47%, var(--line) 47% 53%, transparent 53%),
    var(--surface-2);
}

.gift-option-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.gift-option-copy strong {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.gift-option-copy small {
  color: var(--muted);
  font-size: 12px;
}

.gift-option-check {
  font-weight: 800;
}

/* ------------------------------------------------------------ mobile bottom bar */

.mobile-bar {
  display: none;
}

/* ------------------------------------------------------------ admin */

.admin-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  align-items: start;
  gap: 24px;
}

.admin-menu {
  position: sticky;
  top: calc(var(--topbar-height) + 20px);
  display: grid;
  gap: 2px;
  max-height: calc(100vh - var(--topbar-height) - 40px);
  overflow-y: auto;
  padding: 10px;
}

.admin-menu h2 {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.admin-tab {
  justify-content: flex-start;
  min-height: 36px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
}

.admin-tab:hover:not(:disabled) {
  color: var(--ink);
  background: var(--hover);
}

.admin-tab.is-active {
  color: var(--button-active-text);
  background: var(--button-active-bg);
  font-weight: 600;
}

.admin-actions {
  display: grid;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.admin-content {
  min-width: 0;
  overflow: hidden;
}

.admin-title p {
  max-width: 70ch;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.save-status {
  padding: 8px 20px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.save-status:empty {
  display: none;
}

.save-status.is-error {
  color: var(--bad);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.filters select,
.filters button {
  width: auto;
  min-width: 150px;
  min-height: 36px;
  font-size: 13px;
}

.table-wrap {
  max-height: calc(100vh - var(--topbar-height) - 220px);
  min-height: 240px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

th {
  position: sticky;
  z-index: 1;
  top: 0;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  min-width: 120px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tbody tr:hover td {
  background: var(--hover);
}

td input,
td select,
td textarea {
  min-height: 36px;
  padding: 6px 10px;
  font-size: 13px;
}

td select {
  padding-right: 32px;
}

td textarea {
  min-height: 64px;
}

td .field-hint {
  font-size: 11px;
}

.textarea-cell,
.color-cell {
  min-width: 240px;
}

.color-edit {
  display: grid;
  grid-template-columns: 40px minmax(100px, 1fr);
  gap: 6px;
  align-items: center;
}

.color-edit input[type="color"] {
  min-height: 36px;
}

.row-actions {
  width: 1%;
  min-width: 0;
  white-space: nowrap;
}

.row-actions > * + * {
  margin-left: 6px;
}

.row-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.row-disabled td:not(.row-actions) {
  opacity: 0.45;
}

.delete-row {
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  color: var(--bad);
  font-size: 18px;
}

.empty {
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

.muted-note {
  color: var(--muted);
}

.admin-photos {
  min-width: 200px;
}

.photo-upload {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.photo-upload:hover {
  border-color: var(--ink);
}

.photo-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.photo-thumbnails {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.photo-thumbnails:empty {
  display: none;
}

.admin-photo {
  position: relative;
  display: block;
  width: 52px;
  height: 52px;
}

.admin-photo img {
  width: 100%;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
}

.admin-photo.is-main img {
  border: 2px solid var(--accent);
}

.admin-photo small {
  position: absolute;
  right: 3px;
  bottom: 3px;
  left: 3px;
  overflow: hidden;
  border-radius: 4px;
  color: #fff;
  background: rgb(0 0 0 / 0.7);
  font-size: 8px;
  line-height: 14px;
  text-align: center;
}

.admin-photo button {
  position: absolute;
  width: 22px;
  min-width: 22px;
  min-height: 22px;
  padding: 0;
  border: 2px solid var(--surface);
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
}

.admin-photo .delete-photo {
  top: -7px;
  right: -7px;
  color: #fff;
  background: var(--bad);
}

.admin-photo .set-main-photo {
  bottom: -7px;
  left: -7px;
  background: var(--surface);
}

.admin-photo .set-main-photo:disabled {
  color: var(--button-active-text);
  background: var(--button-active-bg);
  opacity: 1;
}

/* ------------------------------------------------------------ dialogs */

dialog {
  max-width: calc(100vw - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.5);
  backdrop-filter: blur(2px);
}

dialog[open] {
  animation: dialog-in 160ms ease;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 12px 20px;
  border-bottom: 1px solid var(--line);
}

.form-dialog {
  width: min(460px, calc(100vw - 32px));
}

.form-dialog-body {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.form-dialog-body h2 {
  font-size: 20px;
}

.form-dialog-body p:not(.form-error) {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.dialog-fields {
  display: grid;
  gap: 14px;
  max-height: min(60vh, 560px);
  overflow-y: auto;
  padding: 2px;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.photo-viewer {
  width: min(820px, calc(100vw - 32px));
  max-height: 92vh;
}

.photo-viewer-stage {
  display: grid;
  min-height: 240px;
  place-items: center;
  padding: 12px;
  background: #0b0b0b;
}

.photo-viewer-stage img {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 200px);
  object-fit: contain;
}

.photo-viewer-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px;
}

.photo-viewer-thumbs:empty {
  display: none;
}

.photo-viewer-thumbs button {
  width: 64px;
  min-width: 64px;
  height: 64px;
  padding: 0;
  overflow: hidden;
}

.photo-viewer-thumbs img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-viewer-thumbs button.is-active {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* The offer is a printable document: always black on white. */
.offer-dialog {
  width: min(780px, calc(100vw - 32px));
  max-height: 92vh;
  color: #141414;
  background: #ffffff;
}

.offer-sheet {
  display: grid;
  gap: 28px;
  padding: 44px 48px 40px;
  color: #141414;
  background: #ffffff;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.offer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid #e6e6e3;
}

.offer-logo {
  color: #111111;
}

.offer-logo .bloc-svg {
  display: block;
  width: auto;
  height: 22px;
}

.offer-meta {
  display: grid;
  justify-items: end;
  gap: 2px;
  text-align: right;
}

.offer-meta span {
  color: #8a8a86;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.offer-meta time {
  font-size: 14px;
  font-weight: 600;
}

.offer-title {
  display: grid;
  gap: 6px;
}

.offer-title h1 {
  font-size: 30px;
  font-weight: 750;
  line-height: 1.1;
  letter-spacing: -0.025em;
}

.offer-title p {
  color: #6b6b68;
  font-size: 15px;
}

.offer-total {
  display: grid;
  gap: 6px;
  padding: 26px 28px;
  border-radius: 16px;
  color: #ffffff;
  background: #111111;
}

.offer-total-label {
  color: rgb(255 255 255 / 0.62);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.offer-total-value {
  font-size: 44px;
  font-weight: 750;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
}

.offer-total-hint {
  color: rgb(255 255 255 / 0.72);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.offer-gift {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 20px;
  border: 1px solid #e6e6e3;
  border-radius: 16px;
  background: #fafaf8;
}

.offer-gift img {
  width: 88px;
  height: 88px;
  flex: none;
  border-radius: 12px;
  object-fit: cover;
}

.offer-gift > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.offer-kicker {
  color: #8a8a86;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.offer-gift strong {
  font-size: 18px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.offer-gift small {
  color: #6b6b68;
  font-size: 13px;
}

.offer-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px 40px;
}

.offer-section h2 {
  margin-bottom: 6px;
  padding-bottom: 8px;
  border-bottom: 2px solid #111111;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.offer-section dl {
  margin: 0;
}

.offer-section dl > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid #ededea;
}

.offer-section dt {
  flex: none;
  color: #6b6b68;
  font-size: 13px;
}

.offer-section dd {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  text-align: right;
  overflow-wrap: anywhere;
}

.offer-section.is-price dd {
  font-variant-numeric: tabular-nums;
}

.offer-footer {
  padding-top: 18px;
  border-top: 1px solid #e6e6e3;
  color: #8a8a86;
  font-size: 12px;
  line-height: 1.5;
}
.offer-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #e5e5e2;
  background: #ffffff;
}

.offer-actions button:not(.primary-action) {
  border-color: #dcdcd8;
  color: #141414;
  background: #ffffff;
}

.offer-actions .primary-action {
  border-color: #111111;
  color: #ffffff;
  background: #111111;
}

/* ------------------------------------------------------------ login page */

.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
}

.auth-theme {
  position: fixed;
  top: 16px;
  right: 16px;
}

.auth-shell {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 28px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 72px 16px 40px;
}

.auth-logo {
  color: var(--ink);
}

.auth-logo .logo-svg {
  width: min(300px, 80vw);
  height: auto;
}

.auth-card {
  width: min(400px, 100%);
  padding: 28px;
}

.auth-card h1 {
  font-size: 24px;
  letter-spacing: -0.02em;
}

.auth-lead {
  margin-top: 8px !important;
  color: var(--muted);
  font-size: 14px;
}

.auth-form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.auth-form .primary-action {
  min-height: 48px;
  margin-top: 4px;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
}

.password-toggle[aria-pressed="true"] {
  color: var(--ink);
}

/* ------------------------------------------------------------ tablet */

@media (max-width: 1100px) {
  .layout,
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .input-panel,
  .admin-menu {
    position: static;
    max-height: none;
  }

  .admin-menu {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 6px;
    scrollbar-width: none;
  }

  .admin-menu::-webkit-scrollbar {
    display: none;
  }

  .admin-menu h2 {
    display: none;
  }

  .admin-tab {
    flex: none;
    white-space: nowrap;
  }

  .admin-actions {
    margin: 0 0 0 4px;
    padding: 0 0 0 8px;
    border-top: 0;
    border-left: 1px solid var(--line);
  }

  .admin-actions .button-link {
    min-height: 36px;
    border: 0;
    white-space: nowrap;
  }

  .table-wrap {
    max-height: none;
  }
}

/* ------------------------------------------------------------ phone */

@media (max-width: 760px) {
  :root {
    --topbar-height: 56px;
    --radius: 12px;
  }

  .topbar-inner {
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .logo-svg {
    height: 17px;
  }

  .tabs {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    justify-self: stretch;
  }

  .user-name,
  .user-button .chevron {
    display: none;
  }

  .user-button {
    width: 40px;
    min-width: 40px;
    padding: 0;
  }

  main {
    padding-top: 16px;
    padding-bottom: 32px;
  }

  body[data-view="calculator"] main {
    padding-bottom: 104px;
  }

  .layout {
    gap: 16px;
  }

  .panel-head {
    padding: 14px 16px;
  }

  .form-grid {
    gap: 8px;
    padding: 12px;
  }

  .input-panel .info-slot {
    padding: 12px 12px 0;
  }

  .input-group.is-collapsible {
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
  }

  .input-group.is-collapsible + .input-group {
    border-top: 1px solid var(--line);
  }

  .input-group.is-collapsible > summary {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 2px 12px;
    min-height: 56px;
    padding: 10px 14px;
    list-style: none;
    cursor: pointer;
  }

  .input-group.is-collapsible > summary::-webkit-details-marker {
    display: none;
  }

  .input-group.is-collapsible > summary::after {
    grid-row: 1 / span 2;
    grid-column: 2;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    content: "";
    transform: rotate(45deg);
    transition: transform 150ms ease;
  }

  .input-group.is-collapsible[open] > summary::after {
    transform: rotate(-135deg);
  }

  .input-group.is-collapsible .input-group-title {
    margin: 0;
    color: var(--ink);
    font-size: 15px;
    letter-spacing: 0;
    text-transform: none;
  }

  .input-group-summary {
    overflow: hidden;
    color: var(--muted);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .input-group.is-collapsible[open] .input-group-summary {
    display: none;
  }

  .input-group.is-collapsible .input-group-fields {
    padding: 4px 14px 16px;
  }

  /* 16px inputs stop iOS from zooming in on focus. */
  input,
  select,
  textarea {
    min-height: 48px;
    font-size: 16px;
  }

  .hero {
    gap: 16px;
    padding: 18px;
  }

  .hero-figures {
    grid-template-columns: 1fr 1fr;
    gap: 14px 16px;
  }

  .figure-value {
    font-size: 18px;
  }

  .figure.is-main .figure-value {
    font-size: 36px;
  }

  .hero-actions .primary-action {
    width: 100%;
  }

  .details-list {
    grid-template-columns: 1fr 1fr;
  }

  .detail {
    padding: 12px 16px;
  }

  .promo-body {
    padding: 14px 16px 16px;
  }

  .benefit-summary strong {
    font-size: 19px;
  }

  /* Help opens as a panel at the bottom so it never runs off the screen. */
  .help-tooltip {
    position: fixed;
    top: auto;
    right: 12px;
    bottom: 12px;
    left: 12px;
    z-index: 60;
    width: auto;
    padding: 14px 16px;
    font-size: 14px;
  }

  .mobile-bar {
    position: fixed;
    z-index: 25;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transform: translateY(110%);
    transition: transform 200ms ease;
  }

  .mobile-bar.is-visible {
    transform: none;
  }

  .mobile-bar-total {
    display: grid;
    min-width: 0;
  }

  .mobile-bar-total span {
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-bar-total strong {
    font-size: 20px;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
  }

  .mobile-bar .primary-action {
    min-height: 46px;
  }

  .filters select,
  .filters button {
    flex: 1 1 140px;
  }

  .admin-title {
    flex-wrap: wrap;
  }

  /* Dialogs become bottom sheets. */
  dialog.form-dialog,
  dialog.offer-dialog,
  dialog.photo-viewer {
    width: 100vw;
    max-width: 100vw;
    max-height: 94dvh;
    margin: auto 0 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 18px 18px 0 0;
  }

  .form-dialog-body {
    padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
  }

  .dialog-actions button {
    flex: 1;
    min-height: 48px;
  }

  .offer-sheet {
    gap: 22px;
    padding: 24px 18px;
  }

  .offer-header {
    align-items: flex-start;
  }

  .offer-title h1 {
    font-size: 24px;
  }

  .offer-total {
    padding: 20px;
  }

  .offer-total-value {
    font-size: 32px;
  }

  .offer-gift img {
    width: 64px;
    height: 64px;
  }

  .offer-sections {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .offer-actions {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }

  .offer-actions button {
    flex: 1;
    min-height: 48px;
  }
}

@media (max-width: 380px) {
  .input-group-fields > .field[data-field] {
    grid-column: 1 / -1;
  }

  .hero-figures,
  .details-list {
    grid-template-columns: 1fr;
  }
}

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

/* ------------------------------------------------------------ print */

@page {
  size: A4;
  margin: 16mm;
}

@media print {
  body.printing-offer > * {
    visibility: hidden !important;
  }

  body.printing-offer #offerDialog,
  body.printing-offer #offerDialog * {
    visibility: visible !important;
  }

  body.printing-offer #offerDialog {
    position: absolute !important;
    inset: 0 !important;
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    overflow: visible !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    animation: none !important;
  }

  body.printing-offer .offer-sheet {
    padding: 0 !important;
  }

  body.printing-offer .offer-actions {
    display: none !important;
  }
}
