/* GeoRouter. Tokens and rules are documented in app/templates/_design.md */

:root {
  --ink: #121417;
  --ink-2: #3d434b;
  --muted: #5f6670;
  --rule: #e4e6e9;
  --line-ui: #8a919b;
  --plate: #f3f4f5;
  --bg: #fff;
  --bg-app: #f6f7f8;
  --accent: #0e6e37;
  --accent-press: #0a5a2c;
  --danger: #b42318;
  --heat-1: #eaf5ee;
  --heat-2: #d3ebdc;
  --heat-3: #b5ddc4;
  --heat-4: #8fcba6;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r-sm: 4px; --r-md: 8px; --r-panel: 6px;
  --t-fast: 120ms;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, dl, dd, ol, ul { margin: 0; padding: 0; }
ol, ul { list-style: none; }
a { color: inherit; }
img, svg { display: block; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ico { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.flag { width: 21px; height: 14px; flex: none; outline: 1px solid rgb(18 20 23 / .16); outline-offset: -1px; }
.cc { display: inline-block; min-width: 28px; padding: 0 var(--s1); border-radius: var(--r-sm); background: var(--plate); color: var(--ink-2); font: 600 12px/20px var(--mono); text-align: center; }
/* Keeps a 44px-tall hit area on controls that are visually smaller. */
.hit { position: relative; }
.hit::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 44px; transform: translateY(-50%); }

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

/* ---------- Public storefront ---------- */

.lp { font-size: 16px; line-height: 22px; }
.lp-wrap { max-width: 460px; margin: 0 auto; padding: 0 var(--s4) var(--s6); }

.lp-mast { display: flex; align-items: center; min-height: 48px; border-bottom: 1px solid var(--rule); font-size: 12px; line-height: 16px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.lp-head { padding: var(--s5) 0; }
.lp-geo { display: flex; align-items: center; gap: var(--s2); font-size: 14px; line-height: 20px; font-weight: 500; color: var(--ink-2); }
.lp-geo .cc { min-width: 0; line-height: 16px; }
.lp-title { margin-top: var(--s1); font-size: 28px; line-height: 32px; font-weight: 800; letter-spacing: -.02em; text-wrap: balance; }
.lp-title--quiet { font-size: 20px; line-height: 24px; font-weight: 700; letter-spacing: -.01em; }
.lp-note { margin-top: var(--s2); font-size: 14px; line-height: 20px; color: var(--ink-2); }

.offer {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  grid-template-areas: "logo brand cta" "logo lic cta" "facts facts facts";
  column-gap: var(--s3);
  padding: var(--s4) 0 var(--s5);
  border-top: 1px solid var(--rule);
  -webkit-tap-highlight-color: transparent;
}
.offer--lead {
  grid-template-columns: 44px minmax(0, 1fr);
  grid-template-areas: "tag tag" "logo brand" "logo lic" "facts facts" "cta cta";
  border-top: 2px solid var(--ink);
}
.offer__tag { grid-area: tag; margin-bottom: var(--s3); font-size: 12px; line-height: 16px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

.logo { grid-area: logo; position: relative; display: grid; place-items: center; width: 44px; height: 44px; overflow: hidden; border-radius: var(--r-md); background: var(--plate); color: var(--ink-2); font-size: 20px; font-weight: 700; }
/* The letter stays visible while the image loads; a loaded logo gets a solid backing. */
.logo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.logo img.is-loaded { background: var(--bg); }

.offer__brand { grid-area: brand; font-size: 20px; line-height: 24px; font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere; }
.offer__license { grid-area: lic; justify-self: start; display: inline-flex; align-items: center; gap: var(--s1); padding: 0 6px 0 var(--s1); border-radius: var(--r-sm); background: var(--plate); color: var(--ink-2); font-size: 14px; line-height: 20px; font-weight: 500; }
.offer__license .ico { width: 14px; height: 14px; }

.offer__facts { grid-area: facts; display: grid; row-gap: var(--s1); margin-top: var(--s3); }
.offer__facts div { display: grid; grid-template-columns: 52px minmax(0, 1fr); align-items: baseline; }
.offer__facts dt { font-size: 14px; line-height: 20px; color: var(--muted); }
.offer__facts dd { font-size: 14px; line-height: 20px; color: var(--ink-2); }
.offer__facts .offer__bonus { font-size: 16px; line-height: 22px; font-weight: 600; color: var(--ink); }

.offer__cta {
  grid-area: cta;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 var(--s4);
  border: 2px solid var(--accent);
  border-radius: var(--r-sm);
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
/* Whole offer is the link target; the accessible name stays "Visitar <brand>". */
.offer__cta::after { content: ""; position: absolute; inset: 0; }
.offer--lead .offer__cta { justify-content: space-between; min-height: 48px; margin-top: var(--s4); background: var(--accent); color: #fff; }
.offer:hover .offer__cta, .offer:active .offer__cta { border-color: var(--accent-press); background: var(--accent-press); color: #fff; }
@supports selector(:has(*)) {
  .offer__cta:focus-visible { outline: none; }
  .offer:has(.offer__cta:focus-visible) { outline: 2px solid var(--ink); outline-offset: 4px; }
}

.lp-foot { display: flex; align-items: flex-start; gap: var(--s3); padding-top: var(--s4); border-top: 1px solid var(--rule); color: var(--muted); font-size: 14px; line-height: 20px; }
.age { flex: none; display: inline-grid; place-items: center; height: 20px; padding: 0 var(--s1); border: 1.5px solid var(--muted); border-radius: var(--r-sm); color: var(--ink-2); font-size: 12px; font-weight: 700; }

@media (min-width: 600px) {
  .lp-wrap { padding-top: var(--s6); }
}

/* ---------- Admin ---------- */

.ad { background: var(--bg-app); font-size: 14px; line-height: 20px; }
.ad-top { display: flex; align-items: center; gap: var(--s5); height: 48px; padding: 0 var(--s5); border-bottom: 1px solid var(--rule); background: var(--bg); }
.ad-brand { font-weight: 800; letter-spacing: -.01em; text-decoration: none; }
.ad-nav { display: flex; align-self: stretch; gap: var(--s5); }
.ad-nav a { display: flex; align-items: center; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--ink-2); text-decoration: none; }
.ad-nav a:hover { color: var(--ink); }
.ad-nav a[aria-current="page"] { border-bottom-color: var(--ink); color: var(--ink); font-weight: 600; }
.ad-user { margin-left: auto; color: var(--muted); font: 12px/16px var(--mono); }
.ad-main { max-width: 1440px; margin: 0 auto; padding: var(--s5); }

.ad-flash { margin-bottom: var(--s4); padding: var(--s2) var(--s3); border: 1px solid var(--heat-3); border-radius: var(--r-sm); background: var(--heat-1); }
.ad-split { display: grid; gap: var(--s5); align-items: start; }
.ad-section + .ad-section { margin-top: var(--s6); }
.ad-head { display: flex; align-items: center; gap: var(--s3); min-height: 44px; margin-bottom: var(--s2); }
.ad-head h1, .ad-head h2 { font-size: 20px; line-height: 24px; font-weight: 700; letter-spacing: -.01em; }
.ad-head .count { color: var(--muted); }
.ad-head .tools { display: flex; gap: var(--s2); margin-left: auto; }
.ad-empty { padding: var(--s4); color: var(--muted); }

.panel, .group { border: 1px solid var(--rule); border-radius: var(--r-panel); background: var(--bg); }
.panel + .panel { margin-top: var(--s4); }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 44px; padding: 0 var(--s4); border-bottom: 1px solid var(--rule); font-weight: 700; }
.panel__head h2 { font-size: inherit; line-height: inherit; }
.panel__head a { font-weight: 400; }
.panel__foot { padding: var(--s2) var(--s4); border-top: 1px solid var(--rule); }
.panel__foot .link-btn { margin-left: calc(-1 * var(--s2)); }

.group + .group { margin-top: var(--s2); }
.group > summary { display: flex; align-items: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s3); list-style: none; cursor: pointer; user-select: none; }
.group > summary::-webkit-details-marker { display: none; }
.group > summary::before { content: ""; width: 7px; height: 7px; margin: 0 var(--s1); border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(-45deg); transition: transform var(--t-fast); }
.group[open] > summary::before { transform: rotate(45deg); }
.group[open] > summary { border-bottom: 1px solid var(--rule); }
.group > summary:hover { background: var(--plate); }
.group > summary:focus-visible { outline-offset: -2px; }
.group__name { font-weight: 600; }
.group__meta { color: var(--muted); }

.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th { padding: var(--s2) var(--s3); border-bottom: 1px solid var(--rule); color: var(--muted); font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: .04em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.tbl td { padding: var(--s3); border-top: 1px solid var(--rule); vertical-align: top; }
.tbl tbody tr:first-child td { border-top: 0; }
.tbl tfoot td { border-top: 1px solid var(--ink); font-weight: 600; }
.tbl .num { font-family: var(--mono); text-align: right; white-space: nowrap; }
.tbl th.num { font-family: var(--font); }
.tbl .w-min { width: 1%; white-space: nowrap; }
.tbl tr.is-off td:not(.actions) { color: var(--muted); }
.tbl tr[aria-current] td { background: var(--plate); }
.tbl--offers { table-layout: fixed; }
.tbl--offers .c-pos { width: 56px; }
.tbl--offers .c-brand { width: 22%; }
.tbl--offers .c-lic { width: 112px; }
.tbl--offers .c-status { width: 128px; }
.tbl--offers .c-act { width: 104px; }
.tbl tr.is-off .cell-main { text-decoration: line-through; text-decoration-color: var(--line-ui); }
.cell-main { font-weight: 600; }
.cell-sub { display: block; color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; line-height: 20px; }
.trunc { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }

.status { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 var(--s2); border: 0; border-radius: var(--r-sm); background: none; color: var(--ink); font: inherit; white-space: nowrap; cursor: pointer; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.status.is-off { color: var(--muted); }
.status.is-off::before { background: none; box-shadow: inset 0 0 0 1.5px var(--line-ui); }
.status:hover { background: var(--plate); }

.actions { text-align: right; white-space: nowrap; }
.actions form { display: inline; }
.link-btn { display: inline-flex; align-items: center; height: 28px; padding: 0 var(--s2); border: 0; border-radius: var(--r-sm); background: none; color: var(--ink-2); font: inherit; text-decoration: underline; text-decoration-color: var(--line-ui); text-underline-offset: 3px; cursor: pointer; }
.link-btn:hover { background: var(--plate); color: var(--ink); text-decoration-color: currentColor; }
.link-btn--danger, .link-btn--danger:hover { color: var(--danger); }

.previews { display: flex; align-items: center; margin-top: 2px; color: var(--muted); font: 12px/16px var(--mono); }
.previews a { display: inline-flex; align-items: center; height: 24px; padding: 0 6px; border-radius: var(--r-sm); color: var(--ink-2); text-decoration: none; }
.previews a:first-child { margin-left: -6px; }
.previews a:hover { background: var(--plate); color: var(--ink); text-decoration: underline; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 var(--s4); border: 1px solid var(--line-ui); border-radius: var(--r-sm); background: var(--bg); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; transition: background-color var(--t-fast); }
.btn:hover { background: var(--plate); }
.btn--primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.btn--primary:hover { border-color: var(--accent-press); background: var(--accent-press); }
.btn--sm { min-height: 32px; padding: 0 var(--s3); font-weight: 500; }

.form { display: grid; gap: var(--s3); padding: var(--s4); }
.form__row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.form__actions { display: flex; align-items: center; gap: var(--s2); }
.field { display: grid; gap: var(--s1); align-content: start; }
.field > label { font-weight: 600; }
.input { width: 100%; height: 44px; padding: 0 var(--s3); border: 1px solid var(--line-ui); border-radius: var(--r-sm); background: var(--bg); color: var(--ink); font: inherit; }
.input:focus-visible { border-color: var(--ink); outline-offset: 0; }
.input[aria-invalid="true"] { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.input--mono { font-family: var(--mono); font-size: 12px; }
.hint, .error { font-size: 12px; line-height: 16px; }
.hint { color: var(--muted); }
.error { color: var(--danger); font-weight: 600; }
.check { display: flex; align-items: center; gap: var(--s2); min-height: 44px; font-weight: 600; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

.periods { display: inline-flex; margin-left: auto; border: 1px solid var(--line-ui); border-radius: var(--r-sm); background: var(--bg); }
.periods a { display: flex; align-items: center; height: 34px; padding: 0 var(--s3); border-left: 1px solid var(--rule); color: var(--ink-2); text-decoration: none; }
.periods a:first-child { border-left: 0; border-radius: 3px 0 0 3px; }
.periods a:last-child { border-radius: 0 3px 3px 0; }
.periods a:hover { background: var(--plate); color: var(--ink); }
.periods a[aria-current="page"] { background: var(--ink); color: #fff; font-weight: 600; }

.kpis { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s7); margin-bottom: var(--s5); padding: var(--s4); }
.kpis dt { color: var(--muted); font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.kpis dd { margin-top: var(--s1); font: 600 24px/32px var(--mono); font-variant-numeric: tabular-nums; }
.stats-grid { display: grid; gap: var(--s5); align-items: start; }
.stats-grid > .panel { margin-top: 0; }
.heat-1 { background: var(--heat-1); }
.heat-2 { background: var(--heat-2); }
.heat-3 { background: var(--heat-3); }
.heat-4 { background: var(--heat-4); }

/* Narrow screens: wide tables scroll inside their panel, not the page. */
@media (max-width: 1099px) {
  .panel, .group { overflow-x: auto; }
}

@media (min-width: 1100px) {
  .ad-split { grid-template-columns: minmax(0, 1fr) 320px; }
  .ad-aside { position: sticky; top: var(--s4); }
  .stats-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
}
