:root {
  --ink: #16242e; --muted: #5b6b76; --line: #d5dde2; --paper: #fff; --wash: #f3f6f8;
  --brand: #0b5a73; --brand-ink: #fff; --warn: #9a5b00; --warn-bg: #fff4d6;
  --bad: #a3231f; --bad-bg: #fde8e6; --good: #1c6b3c; --good-bg: #e4f4ea;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* a class with display: flex must not show a hidden element */
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--wash); }
a { color: var(--brand); }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; }
.muted { color: var(--muted); }

.top { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .6rem 1rem; background: var(--brand); color: var(--brand-ink); }
.top a { color: var(--brand-ink); text-decoration: none; }
.top .brand { font-weight: 700; }
.top nav { display: flex; gap: 1rem; flex: 1; }
.top .signout { display: flex; gap: .6rem; align-items: center; margin: 0; font-size: .9rem; }
button.link { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; }

main { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: .6rem .8rem; border-radius: 6px; margin-bottom: .4rem; background: var(--good-bg); color: var(--good); }
.messages li.warning { background: var(--warn-bg); color: var(--warn); }
.messages li.error { background: var(--bad-bg); color: var(--bad); }

.btn { display: inline-block; padding: .65rem 1rem; min-height: 44px; border-radius: 6px; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.secondary { background: var(--paper); color: var(--brand); }
.btn.danger { background: var(--paper); color: var(--bad); border-color: var(--bad); }
.btn.small { padding: .3rem .6rem; min-height: 32px; font-weight: 500; font-size: .9rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .2rem; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: .55rem .6rem; min-height: 42px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: var(--paper); color: var(--ink);
}
.field { margin-bottom: .8rem; }
.field .help { font-size: .85rem; color: var(--muted); }
.field .errorlist { list-style: none; margin: .2rem 0 0; padding: 0; color: var(--bad); font-size: .9rem; }
.field.uncertain input, .field.uncertain textarea { border-color: var(--warn); background: var(--warn-bg); }
.field.missing input, .field.missing textarea { border-color: var(--bad); background: var(--bad-bg); }
.flag { font-weight: 500; font-size: .8rem; margin-left: .4rem; }
.flag.uncertain { color: var(--warn); }
.flag.missing { color: var(--bad); }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 1rem; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.tile { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: .8rem; text-decoration: none; color: var(--ink); }
.tile .n { font-size: 1.8rem; font-weight: 700; display: block; }
.tile .t { font-size: .9rem; color: var(--muted); }

.review { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 900px) { .review { grid-template-columns: minmax(280px, 2fr) 3fr; align-items: start; } .review .photo { position: sticky; top: 1rem; } }
.review .photo img { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #000; }

table { width: 100%; border-collapse: collapse; background: var(--paper); }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; font-size: .92rem; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.pill { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; background: var(--wash); border: 1px solid var(--line); white-space: nowrap; }
.pill.read, .pill.waiting { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill.failed { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.pill.confirmed { background: var(--good-bg); color: var(--good); border-color: transparent; }

label.btn { display: inline-flex; align-items: center; margin: 0; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: .5rem; margin-top: .6rem; }
.thumbs.large { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.thumb { position: relative; display: block; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; text-decoration: none; }
.thumb img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.thumb button { position: absolute; top: 2px; right: 2px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 18px; line-height: 1; cursor: pointer; }
.thumb .pill { position: absolute; left: 4px; bottom: 4px; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; align-items: end; }
.inline { display: inline; margin: 0; }
.narrow { max-width: 460px; margin: 2rem auto; }
.spinner { display: inline-block; width: 1em; height: 1em; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin 1s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.tile-map { display: block; width: 100%; height: auto; border-radius: 6px; margin-bottom: .5rem; background: #eef3f5; }
.map-wrap { margin: 1rem 0; }
#map { width: 100%; height: 480px; border-radius: 8px; border: 1px solid var(--line); }
@media (max-width: 640px) { #map { height: 360px; } }
.map-legend { font-size: .9rem; margin-top: .4rem; }
.map-legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 2px; vertical-align: -1px; margin: 0 .2rem 0 .6rem; }
.map-legend .sw.closed { background: #c0392b; opacity: .8; }
.map-legend .sw.open { background: #2a8fb0; opacity: .5; }

.top nav a { padding: .35rem .7rem; border-radius: 6px; }
.top nav a.active { background: rgba(255,255,255,.18); font-weight: 600; }
.top .who { color: #fff; text-decoration: none; border-bottom: 1px dotted rgba(255,255,255,.6); }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.crumb { margin: 0 0 .5rem; font-size: .9rem; }
.tile .t { display: block; }
.tile.on { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.pill.stage-contacted, .pill.stage-talking { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill.stage-trial, .pill.stage-paying { background: var(--good-bg); color: var(--good); border-color: transparent; }
.pill.stage-lost { color: var(--muted); }
.pill.prio1 { background: var(--brand); color: #fff; border-color: transparent; }
details.card summary { cursor: pointer; }

/* Front page, free scans and visitor tabs. Written for a phone first; wider screens add room. */
.small { font-size: .9rem; }
.center { text-align: center; }
.btn.big { padding: .8rem 1.4rem; min-height: 52px; font-size: 1.05rem; display: inline-flex; align-items: center; justify-content: center; }

.hero { max-width: 980px; margin: 0 auto; padding: 1.25rem 0 1rem; text-align: center; }
.hero h1, .hero-title { font-size: clamp(1.9rem, 8.5vw, 3.4rem); line-height: 1.1; letter-spacing: -.02em; font-weight: 700; margin: 0 0 .6rem; }
.hero .lede { font-size: 1.05rem; color: var(--muted); margin: 0 0 1.25rem; }
.hero-top { padding-bottom: 0; }

.tabs { display: flex; width: 100%; max-width: 420px; gap: .25rem; padding: .3rem; margin: 0 auto 1.5rem; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; }
.tabs a { flex: 1; justify-content: center; padding: .6rem .5rem; border-radius: 999px; text-decoration: none; color: var(--ink); font-weight: 600; min-height: 46px; display: inline-flex; align-items: center; white-space: nowrap; }
.tabs a.on { background: var(--brand); color: #fff; }
.tabs a:not(.on):hover { background: var(--wash); }

.showcase { display: flex; flex-direction: column; align-items: center; gap: .6rem; margin: 0 0 1.5rem; }
.tag-photo { width: 100%; max-width: 480px; height: auto; border-radius: 10px; box-shadow: 0 8px 24px rgba(22,36,46,.18); transform: rotate(-1deg); }
.showcase-arrow { display: flex; align-items: center; gap: .5rem; color: var(--brand); line-height: 1; }
.showcase-arrow .speed { font-size: .95rem; font-weight: 700; white-space: nowrap; }
.showcase-arrow span[aria-hidden] { font-size: 2rem; transform: rotate(90deg); }
.read-card { width: 100%; max-width: 420px; margin: 0; text-align: left; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem; box-shadow: 0 8px 24px rgba(22,36,46,.10); }
.read-card > div:not(.read-ok) { display: flex; justify-content: space-between; gap: 1rem; padding: .4rem 0; border-bottom: 1px solid var(--line); }
.read-card > div:last-child { border-bottom: 0; }
.read-card dt { color: var(--muted); font-size: .9rem; flex: none; }
.read-card dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.read-ok { display: inline-block; color: var(--good); background: var(--good-bg); border-radius: 6px; padding: .25rem .6rem; font-weight: 600; margin-bottom: .5rem; }

.hero-actions { display: flex; gap: .75rem; flex-wrap: wrap; justify-content: center; margin-bottom: .9rem; }
.hero-actions .btn { flex: 1 1 100%; }
.free-line { font-size: 1.15rem; font-weight: 700; color: var(--ink); margin: .25rem 0 .2rem; }
/* While a free scan is read: a full-screen cover, so it shows wherever the page is scrolled. */
.scan-form .reading { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(22,36,46,.55); }
.reading-box { max-width: 340px; padding: 1.5rem 1.25rem; text-align: center; background: var(--paper); border-radius: 12px; box-shadow: 0 8px 24px rgba(22,36,46,.25); }
.reading-box p { margin: .6rem 0 0; }
.reading-box strong { font-size: 1.15rem; }
.spinner.big { width: 2.5rem; height: 2.5rem; border-width: 4px; }
.bottom-cta { margin-top: .5rem; }

.tiers { display: flex; gap: .75rem; justify-content: center; margin: 1rem 0 .75rem; }
.tier { flex: 1 1 0; min-width: 0; max-width: 240px; display: flex; flex-direction: column; align-items: center; gap: .2rem; padding: 1rem .5rem; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; color: var(--ink); text-align: center; }
.tier-name { font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-size: .8rem; }
.tier-price { font-size: 1.7rem; font-weight: 700; white-space: nowrap; }
.tier-price small { font-size: .9rem; font-weight: 500; color: var(--muted); }
.tier-amount { font-size: .95rem; }

.try-result { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-bottom: 1rem; text-align: left; }
.try-result .photo img { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #000; }
.try-result td { overflow-wrap: anywhere; }
/* The label column keeps whole words; otherwise a phone squeezes it to one letter a line. */
.try-result td:first-child { overflow-wrap: normal; width: 40%; }
.card.start { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }

/* Top bar on a phone: the name, then the sign-in button or the account on the right. */
.top .btn.signin { margin-left: auto; background: #fff; color: var(--brand); border-color: #fff; white-space: nowrap; }
.top .btn.signin:hover { background: #e8f1f4; }
.top .brand { white-space: nowrap; }
.top .who { display: inline-block; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

@media (min-width: 481px) {
  .hero-actions .btn { flex: 0 1 auto; }
  .tier { padding: 1.1rem 1.5rem; }
  .tier-price { font-size: 2rem; }
}
@media (min-width: 820px) {
  .hero { padding: 3.5rem 0 2rem; }
  .hero .lede { font-size: 1.2rem; margin-bottom: 1.75rem; }
  .showcase { display: grid; grid-template-columns: 1.25fr auto 1fr; gap: 1.25rem; align-items: center; justify-items: center; margin-bottom: 2rem; }
  .showcase-arrow { flex-direction: column; gap: .2rem; }
  .showcase-arrow span[aria-hidden] { font-size: 2.4rem; transform: none; }
  .tag-photo { transform: rotate(-1.5deg); }
  .try-result { grid-template-columns: minmax(260px, 2fr) 3fr; align-items: start; }
}
@media (max-width: 380px) {
  main { padding: .75rem; }
  .tabs a { font-size: .95rem; }
  .tier-price { font-size: 1.45rem; }
}

/* Toggle buttons in place of checkboxes (closure alert states): one row, wrapping on a phone */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { position: relative; margin: 0; font-weight: 500; cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span { display: inline-flex; align-items: center; min-height: 44px; padding: .45rem 1.1rem; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--ink); user-select: none; }
.chip:hover span { border-color: var(--brand); }
.chip input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip input:checked + span::before { content: "✓"; margin-right: .4rem; }
.chip input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
