:root {
  --paper: #ffffff;
  --ink: #1c2a3a;
  --ink-soft: #52606f;
  --fog: #eef2f6;
  --line: #d5dce4;
  --route: #1e4fd8;
  --route-dark: #163da8;
  --stamp: #b8322a;
  --ok: #1f7a4d;
  --radius-sm: 6px;
  --radius-lg: 14px;
  font-family: "Public Sans", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font-size: 16px; line-height: 1.5; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--route); }
:focus-visible { outline: 3px solid var(--route); outline-offset: 2px; }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: 1fr 420px; height: 100%; }
@media (min-width: 861px) { body:has(.shell) { overflow: hidden; } }
#map { height: 100%; min-height: 320px; background: var(--fog); }
.map-wrap { position: relative; height: 100%; min-height: 320px; }

/* Loading: a card over the map plus a moving bar on the count, so it's obvious the app is working. */
.map-loading { position: absolute; z-index: 1000; left: 50%; top: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; background: var(--paper); color: var(--ink); padding: 12px 16px; border-radius: 14px; box-shadow: 0 6px 24px rgba(28, 42, 58, 0.22); font-size: 0.95rem; max-width: calc(100% - 32px); }
.map-loading strong { display: block; white-space: nowrap; }
.map-loading-sub { display: block; font-size: 0.8rem; color: var(--ink-soft); }
.spinner { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 3px solid #f2d6d3; border-top-color: var(--stamp); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.map-wrap.is-loading #map { filter: saturate(0.6) brightness(0.97); transition: filter 0.2s; }
.readout { position: relative; overflow: hidden; }
.readout[data-state="loading"]::before { content: ""; position: absolute; left: 0; top: 0; height: 3px; width: 40%; background: var(--stamp); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.readout[data-state="loading"] .readout-count { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.panel { overflow-y: auto; border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.panel-head { padding: 28px 28px 20px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 22px; height: 22px; border: 2px dashed var(--stamp); border-radius: 4px; }
.lede { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; margin-top: 18px; }
.sub { color: var(--ink-soft); margin: 8px 0 0; max-width: 34ch; }

.demo-note { margin: 16px 28px 0; padding: 10px 14px; background: #fff7e0; border: 1px solid #efd58a; border-radius: var(--radius-sm); font-size: 0.875rem; }

.step { padding: 24px 28px; border-bottom: 1px solid var(--line); }
.step[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
.step-title { display: flex; gap: 12px; align-items: baseline; font-size: 1.05rem; font-weight: 700; }
.step-num { font-variant-numeric: tabular-nums; color: var(--stamp); font-weight: 800; }
.step-body { margin-top: 14px; display: grid; gap: 14px; }
.hint { color: var(--ink-soft); font-size: 0.9rem; margin: 0; }

.fineprint { font-size: 0.75rem; line-height: 1.5; color: var(--ink-soft); padding: 20px 28px 28px; margin: 0; }
.fineprint a { color: inherit; }

.gap-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: rgba(28, 42, 58, 0.28); vertical-align: -1px; margin-right: 6px; }
.gap-label { font-weight: 600; }

/* ---------- postcard back examples ---------- */
.back-examples { display: flex; gap: 16px; align-items: flex-end; }
.back-examples figure { margin: 0; display: grid; gap: 6px; }
.back-examples figcaption { font-size: 0.75rem; color: var(--ink-soft); }
.card-back { position: relative; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); box-shadow: 0 1px 2px rgba(28, 42, 58, 0.08); }
.card-4x6 { width: 120px; aspect-ratio: 6 / 4; }
.card-6x11 { width: 150px; aspect-ratio: 11 / 6; }
.card-design, .card-reserved { position: absolute; display: grid; place-items: center; font-size: 0.65rem; font-weight: 600; text-align: center; }
/* Everything except the bottom-right quarter is the customer's to design. */
.card-design { inset: 0; clip-path: polygon(0 0, 100% 0, 100% 50%, 50% 50%, 50% 100%, 0 100%); background: #f3f6fe; }
.card-label { position: absolute; left: 0; top: 0; width: 100%; height: 50%; display: grid; place-items: center; font-size: 0.65rem; font-weight: 600; color: var(--route); white-space: nowrap; }
.card-reserved { right: 0; bottom: 0; width: 50%; height: 50%; border-left: 1.5px dashed var(--stamp); border-top: 1.5px dashed var(--stamp); color: var(--stamp); background: repeating-linear-gradient(135deg, transparent 0 5px, rgba(184, 50, 42, 0.07) 5px 10px); }

/* ---------- policy pages ---------- */
.legal h1 { margin-top: 18px; }
.legal h2 { font-size: 1.05rem; margin: 28px 0 8px; }
.legal p, .legal li { color: var(--ink); }
.legal ul { padding-left: 20px; display: grid; gap: 6px; }
.legal-date { color: var(--ink-soft); font-size: 0.875rem; }
.legal-nav { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 0.875rem; }

/* ---------- artwork preview ---------- */
.art-preview { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.art-preview figure { margin: 0; display: grid; gap: 6px; }
.art-preview figcaption { font-size: 0.75rem; color: var(--ink-soft); }
.pv-card { position: relative; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; background: var(--fog); box-shadow: 0 1px 2px rgba(28, 42, 58, 0.08); }
.pv-card canvas { display: block; width: 100%; height: auto; }
/* The part of the back the printer covers with the address block. */
.pv-reserved { position: absolute; right: 0; bottom: 0; width: 50%; height: 50%; display: grid; place-items: center; text-align: center; padding: 4px; background: rgba(28, 42, 58, 0.55); color: #fff; font-size: 0.65rem; font-weight: 700; line-height: 1.25; border-left: 1.5px dashed #fff; border-top: 1.5px dashed #fff; }
.art-ok { color: var(--ok); font-weight: 600; }

/* ---------- account ---------- */
.topline { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.account { font-size: 0.9rem; font-weight: 600; display: flex; gap: 14px; }
.account a, .linkish { color: var(--route); text-decoration: none; background: none; border: 0; padding: 0; cursor: pointer; font-weight: 600; }
.account a:hover, .linkish:hover { text-decoration: underline; }
.past-label { background: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px; font: 600 12px/1.3 "Public Sans", Arial, sans-serif; color: var(--ink); box-shadow: none; }
.past-label::before { display: none; }

/* ---------- history ---------- */
.history { display: grid; grid-template-columns: 1fr 420px; height: 100%; }
.mailing-item { border-bottom: 1px solid var(--line); }
.mailing-item:has(.mailing[aria-current="true"]), .mailing-item:hover { background: #f3f6fe; }
.mailing { width: 100%; text-align: left; background: none; border: 0; padding: 16px 28px 4px; display: grid; gap: 4px; cursor: pointer; }
.mailing-top { display: flex; justify-content: space-between; gap: 12px; font-weight: 700; }
.mailing-meta { font-size: 0.875rem; color: var(--ink-soft); }
.mailing-actions { display: flex; gap: 18px; font-size: 0.875rem; padding: 4px 28px 16px; }
.status-pill { font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--fog); color: var(--ink-soft); white-space: nowrap; }
.status-pill[data-s="sent"] { background: #e3f3ea; color: var(--ok); }
.status-pill[data-s="rejected"], .status-pill[data-s="failed"] { background: #fbe9e7; color: var(--stamp); }
.empty { padding: 28px; color: var(--ink-soft); }
.signin-box { max-width: 420px; display: grid; gap: 14px; margin-top: 24px; }
.success { background: #e3f3ea; color: var(--ok); padding: 12px 14px; border-radius: var(--radius-sm); font-weight: 600; margin: 0; }

/* ---------- controls ---------- */
.row { display: flex; gap: 8px; }
.field { display: grid; gap: 6px; font-size: 0.9rem; font-weight: 600; }
.input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); font-weight: 400; }
.input:focus { border-color: var(--route); outline: none; box-shadow: 0 0 0 3px rgba(30, 79, 216, 0.18); }
.btn { border: 0; border-radius: var(--radius-sm); padding: 11px 16px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.btn-primary { background: var(--route); color: #fff; }
.btn-primary:hover { background: var(--route-dark); }
.btn-primary:disabled { background: #9aaede; cursor: not-allowed; }
.btn-quiet { background: var(--fog); color: var(--ink); }
.btn-quiet:hover { background: #e2e8ef; }
.btn-danger { background: #fbe9e7; color: var(--stamp); }
.btn-wide { width: 100%; padding: 14px 16px; font-size: 1rem; }

.sizes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.size { position: relative; }
.size input { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.size > span { display: grid; gap: 2px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); text-align: center; cursor: pointer; font-size: 0.85rem; color: var(--ink-soft); }
.size strong { font-size: 1rem; color: var(--ink); }
.size input:checked + span { border-color: var(--route); box-shadow: inset 0 0 0 1px var(--route); background: #f3f6fe; }
.size input:focus-visible + span { outline: 3px solid var(--route); outline-offset: 2px; }

.file { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: var(--radius-sm); font-size: 0.9rem; }
.file-name { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file input { width: 0; height: 0; opacity: 0; position: absolute; left: 0; top: 0; }
.file label { cursor: pointer; }

.check { display: flex; gap: 10px; font-size: 0.875rem; color: var(--ink-soft); align-items: flex-start; }
.check input { margin-top: 3px; accent-color: var(--route); }

/* ---------- the count readout: the one loud element ---------- */
.readout {
  border: 2px dashed var(--stamp);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: grid;
  gap: 4px;
}
.readout-count { font-size: 2.6rem; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.readout-unit { font-size: 1rem; font-weight: 600; color: var(--ink-soft); }
.readout-meta { font-size: 0.875rem; color: var(--ink-soft); }
.readout[data-state="loading"] .readout-count { color: var(--line); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.8rem; color: var(--ink-soft); margin-top: 4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-home { background: #1e4fd8; }
.dot-unknown { background: #6b7785; }
.dot-off { background: #fff; box-shadow: inset 0 0 0 1.5px var(--stamp); }
.dot-apt { background: #fff; box-shadow: inset 0 0 0 2px #6b7785; }
.areas { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.areas li { display: inline-flex; align-items: center; gap: 6px; background: var(--fog); border-radius: 99px; padding: 5px 6px 5px 12px; font-size: 0.85rem; font-weight: 600; }
.areas button { border: 0; background: none; cursor: pointer; color: var(--ink-soft); font-size: 1rem; line-height: 1; padding: 2px 6px; border-radius: 99px; }
.areas button:hover { background: #dfe5ec; color: var(--ink); }

.total { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; }
.total-amount { font-size: 1.4rem; font-variant-numeric: tabular-nums; }

.error { color: var(--stamp); font-size: 0.9rem; margin: 0; font-weight: 600; }
.error:empty { display: none; }

/* Leaflet overrides */
.leaflet-container { font-family: inherit; }
.leaflet-draw-tooltip { font-family: inherit; }

/* ---------- status + admin pages ---------- */
.page { max-width: 720px; margin: 0 auto; padding: 40px 24px 64px; }
.page-wide { max-width: 1100px; }
.timeline { list-style: none; padding: 0; margin: 28px 0; display: grid; gap: 0; }
.timeline li { display: grid; grid-template-columns: 28px 1fr; gap: 12px; padding: 10px 0; color: var(--ink-soft); }
.timeline li::before { content: ""; width: 14px; height: 14px; margin: 5px 0 0 6px; border-radius: 50%; border: 2px solid var(--line); background: var(--paper); }
.timeline li.done { color: var(--ink); }
.timeline li.done::before { background: var(--ok); border-color: var(--ok); }
.timeline li.now { color: var(--ink); font-weight: 700; }
.timeline li.now::before { border-color: var(--route); background: var(--route); box-shadow: 0 0 0 4px rgba(30, 79, 216, 0.18); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.fact { background: var(--fog); border-radius: var(--radius-sm); padding: 14px; }
.fact dt { font-size: 0.8rem; color: var(--ink-soft); }
.fact dd { margin: 2px 0 0; font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: var(--fog); border-radius: 99px; overflow: hidden; margin-top: 18px; }
.bar > div { height: 100%; background: var(--ok); width: 0; transition: width 0.4s ease; }

.review { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; display: grid; gap: 16px; margin-top: 16px; }
.review-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.art { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.art figure { margin: 0; }
.art img { width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); display: block; }
.art figcaption { font-size: 0.8rem; color: var(--ink-soft); margin-top: 4px; }
.mini-map { height: 180px; border-radius: var(--radius-sm); }
.addr { font-size: 0.875rem; color: var(--ink-soft); margin: 0; padding-left: 18px; }
.warn { color: var(--stamp); font-weight: 700; font-size: 0.875rem; }
table.orders { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin-top: 12px; }
table.orders th, table.orders td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.orders th { color: var(--ink-soft); font-weight: 600; }
.scroll-x { overflow-x: auto; }

@media (max-width: 860px) {
  .history { grid-template-columns: 1fr; grid-template-rows: 45vh auto; height: auto; }
  .mailing, .mailing-actions { padding-left: 20px; padding-right: 20px; }
  .fineprint { padding-left: 20px; padding-right: 20px; }
  .shell { grid-template-columns: 1fr; grid-template-rows: 52vh auto; height: auto; }
  .panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .panel-head, .step { padding-left: 20px; padding-right: 20px; }
  .demo-note { margin-left: 20px; margin-right: 20px; }
  .lede { font-size: 1.35rem; }
  .art { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
