/* Tablet first: read at arm's length, used with a finger, often shown to somebody else.
   The yellow, red and warm rule are the ones of the Excel tariff BWT sends (tariff_export). */
:root {
  --accent: #FFB829;
  --wash: #FFF3D1;
  --red: #ED0000;
  --ink: #1A1A1A;
  --muted: #6B6558;
  --rule: #DED8C8;
  --paper: #FBF8F1;
  --card: #FFFFFF;
  --radius: 14px;
  --bar: 64px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: none;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }

.muted { color: var(--muted); }
.primary {
  min-height: 48px; padding: 0 22px; border: 0; border-radius: 12px;
  background: var(--ink); color: #fff; font-weight: 650;
}
.primary:disabled { opacity: .5; }
.link { border: 0; background: none; padding: 8px 4px; text-decoration: underline; color: var(--ink); }

/* ---- activation ---- */
.activate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.activate-card {
  width: min(440px, 100%); display: grid; gap: 14px; padding: 32px;
  background: var(--card); border: 1px solid var(--rule); border-radius: 20px;
}
.activate-card h1 { font-size: 1.6rem; }
.activate-card label { font-weight: 650; font-size: .9rem; }
.activate-card input {
  min-height: 56px; padding: 0 16px; border: 2px solid var(--rule); border-radius: 12px;
  font-size: 1.5rem; letter-spacing: .12em; text-transform: uppercase; text-align: center;
}
.activate-card input:focus { outline: none; border-color: var(--accent); }
.error { color: var(--red); font-weight: 600; }

/* ---- top bar ---- */
.bar {
  position: sticky; top: 0; z-index: 5; min-height: var(--bar);
  display: flex; align-items: center; gap: 12px; padding: 8px 16px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--accent);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 750; font-size: 1.1rem; }
.brand img { border-radius: 8px; background: #fff; }
.customer-button {
  display: grid; text-align: left; min-height: 48px; padding: 4px 14px; max-width: 34vw;
  border: 2px dashed rgba(26, 26, 26, .55); border-radius: 12px; background: rgba(255, 255, 255, .45);
}
.customer-button.chosen { border-style: solid; border-color: var(--ink); background: #fff; }
.customer-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.customer-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 16px;
  border: 1px solid rgba(26, 26, 26, .25); border-radius: 12px; background: #fff;
}
.search:focus { outline: 2px solid var(--ink); outline-offset: 1px; }
.switch { display: flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; min-height: 48px; }
.switch input { width: 22px; height: 22px; accent-color: var(--ink); }

/* ---- range chips ---- */
.sections {
  position: sticky; top: var(--bar); z-index: 4;
  display: flex; gap: 8px; padding: 10px 16px; overflow-x: auto; scrollbar-width: none;
  background: var(--paper); border-bottom: 1px solid var(--rule);
}
.sections::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 40px; padding: 0 16px; border: 1px solid var(--rule); border-radius: 999px;
  background: var(--card); font-weight: 600; font-size: .92rem; white-space: nowrap;
}
.chip:active { background: var(--wash); }

/* ---- catalogue ---- */
.catalogue { padding: 4px 16px 88px; }
.range { scroll-margin-top: calc(var(--bar) + 68px); padding-top: 22px; }
.range h2 {
  font-size: 1.15rem; padding-bottom: 8px; margin-bottom: 14px;
  color: var(--red); border-bottom: 2px solid var(--red);
}
.count { color: var(--muted); font-weight: 500; font-size: .9rem; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.card {
  position: relative; display: flex; flex-direction: column; gap: 4px; text-align: left;
  padding: 14px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--card);
}
.card:active { border-color: var(--ink); }
.card-picture { width: 100%; aspect-ratio: 1; object-fit: contain; margin-bottom: 6px; }
.no-picture {
  display: grid; place-items: center; background: var(--paper); border-radius: 10px;
  color: var(--muted); font-size: .85rem;
}
.card-name { font-weight: 700; line-height: 1.25; }
.card-ref, .card-pack { font-size: .85rem; color: var(--muted); }
.prices { margin-top: auto; padding-top: 10px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.price { font-size: 1.35rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.pvp { font-size: .85rem; color: var(--muted); width: 100%; }
.prices .muted { font-size: .85rem; }
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
}
.tag.new { position: absolute; top: 10px; left: 10px; background: var(--red); color: #fff; }
.tag.proposed { background: var(--wash); color: var(--ink); border: 1px solid var(--accent); }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }

/* ---- status line ---- */
.status {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4;
  display: flex; align-items: center; gap: 12px; padding: 6px 16px;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--rule); font-size: .82rem; color: var(--muted);
}
.status .net { margin-left: auto; font-weight: 600; color: var(--ink); }

/* ---- sheets (product, customers) ---- */
.sheet {
  width: min(960px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  padding: 28px; border: 0; border-radius: 20px; background: var(--card); color: var(--ink);
}
.sheet::backdrop { background: rgba(26, 26, 26, .55); }
.close {
  position: absolute; top: 10px; right: 10px; width: 48px; height: 48px; border: 0; border-radius: 50%;
  background: var(--paper); font-size: 1.6rem; line-height: 1;
}
.product { display: grid; gap: 28px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.product-picture { width: 100%; max-width: 420px; justify-self: center; aspect-ratio: 1; object-fit: contain; }
.eyebrow { color: var(--red); font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; }
.product-body h2 { font-size: 1.5rem; line-height: 1.2; margin: 6px 0 16px; padding-right: 40px; }
.facts { margin: 0; }
.fact { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.fact dt { color: var(--muted); }
.fact dd { margin: 0; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }
.note { margin-top: 14px; padding: 12px 14px; border-left: 4px solid var(--accent); background: var(--wash); border-radius: 0 10px 10px 0; font-size: .9rem; }

.customers { display: grid; gap: 28px; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); min-height: min(560px, 70dvh); }
.customers-left { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.customers-left .search { flex: none; }
.customer-list { overflow-y: auto; max-height: 60dvh; display: grid; gap: 8px; align-content: start; }
.customer-row {
  display: grid; gap: 2px; text-align: left; padding: 12px 14px; min-height: 56px;
  border: 1px solid var(--rule); border-radius: 12px; background: var(--card);
}
.customer-row.selected { border-color: var(--ink); background: var(--wash); }
.customer-row .muted, .tariff-line { font-size: .85rem; }
.tariff-line { color: var(--muted); }
.tariff-line.warn { color: var(--red); font-weight: 600; }
.customers-right { display: flex; flex-direction: column; gap: 16px; padding-top: 44px; }
.customer-detail { flex: 1; }
.customer-sheet { display: grid; gap: 12px; }
.customer-sheet h2 { font-size: 1.35rem; }
.addresses { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
.address h3, .contacts h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
.actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

@media (max-width: 760px) {
  :root { --bar: 116px; }
  .bar { flex-wrap: wrap; }
  .brand span { display: none; }
  .customer-button { flex: 1; max-width: none; }
  .search { flex-basis: 100%; order: 3; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .product, .customers, .addresses { grid-template-columns: 1fr; }
  .customers-right { padding-top: 0; }
  .sheet { padding: 20px; }
  .status #status-data { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
