/*
 * Corbel. The palette and type carry over from the earlier Sherpa Consulting design; swap the
 * brand tokens below once Corbel's brand colors are set.
 */
:root {
  /* Brand tokens */
  --ink: #18181b;
  --bg: #f1f1ef;
  --orange: #ef8200;
  --orange-text: #a85800; /* Orange that passes contrast as text, used for hovers */
  --orange-tint: #fff4e5;
  --steel: #7c858c; /* Borders only: too light for text */
  --surface: #fff;
  --muted: #5c646b; /* Steel darkened to pass WCAG AA for text */
  --hairline: #d6d6d2;
  --danger: #b91c1c;
  --danger-tint: #fdecec;
  --success: #15803d;
  --success-tint: #e8f5ec;

  /* Heatmap ranks: semantic, deliberately independent of brand colors */
  --rank-top: #15803d;
  --rank-good: #65a30d;
  --rank-mid: #ca8a04;
  --rank-low: #ea580c;
  --rank-none: #b91c1c;
  --rank-pending: #d1d5db;
  --rank-failed: #6b7280;
  /* Rank change: a diverging pair (cool = better, warm = worse) around a neutral gray. */
  --change-up: #1d4ed8;
  --change-down: #c2410c;
  --change-same: #6b7280;
  --chart-grid: #e4e4e0;

  --font-heading: "Archivo", system-ui, sans-serif;
  --font-body: "Public Sans", system-ui, sans-serif;
  --lift-shadow: 4px 4px 0 var(--ink);
  --soft-shadow: 0 16px 32px rgb(24 24 27 / 14%);
  --tag-shadow: 0 14px 26px -16px rgb(24 24 27 / 30%);
  --radius: 12px;
  --gutter: 24px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(28px, 3.2vw, 40px);
}

h2 {
  font-size: 22px;
}

h3 {
  margin: 28px 0 10px;
  font-size: 17px;
}

p {
  margin: 0;
}

a {
  color: var(--ink);
  font-weight: 600;
  text-decoration-color: var(--orange);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--orange-text);
}

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

[hidden] {
  display: none !important;
}

.container {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px var(--gutter) 80px;
}

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

.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 12px;
  padding: 5px 12px;
  border-radius: 4px;
  background: var(--orange);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Header and footer */

.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgb(241 241 239 / 92%);
  border-bottom: 1px solid var(--hairline);
  backdrop-filter: blur(8px);
}

.header-wrap,
.footer-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 8px var(--gutter);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
}

/* Keyword ideas under the grid scan's keyword box */

.keyword-ideas {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.ideas-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.ideas-header > span:first-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.idea-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.idea-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  /* Long phrases wrap inside the chip instead of widening the page. */
  max-width: 100%;
  white-space: normal;
  text-align: left;
  padding: 6px 12px;
  border: 1px solid var(--steel);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: none;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.idea-chip:hover,
.idea-chip:focus-visible {
  border-color: var(--ink);
  background: var(--orange-tint);
  box-shadow: none;
  transform: none;
}

.idea-volume {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.idea-scanned {
  color: var(--success);
}

/* Sign-in page */

.login-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.login-main {
  display: grid;
  flex: 1;
  place-items: center;
  padding-block: 48px;
}

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

.login-card fieldset {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-card .eyebrow {
  align-self: flex-start;
}

.login-card h1 {
  margin: 0;
}

.login-card p {
  margin: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 26px;
  height: 26px;
}

.brand-name {
  color: var(--ink);
  font-family: var(--font-heading);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand-product {
  padding-left: 10px;
  border-left: 1px solid var(--steel);
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
}

.site-footer {
  border-top: 1px solid var(--hairline);
  color: var(--muted);
  font-size: 13px;
}

.footer-wrap {
  flex-wrap: wrap;
  padding-block: 14px;
}

.footer-link {
  color: var(--muted);
  font-weight: 500;
}

/* Page structure */

.back {
  display: inline-block;
  margin-bottom: 20px;
  font-size: 15px;
  text-decoration: none;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px 24px;
  margin-bottom: 28px;
}

.page-header > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.page-header .eyebrow {
  align-self: flex-start;
  margin-bottom: 4px;
}

/* Inline facts separated by dots: "Plumber · Dover, OH · example.com". */
.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 0;
  color: var(--muted);
  font-size: 15px;
}

.meta > span:not(.tag):not(:last-child)::after,
.meta > span:not(.tag):has(+ .tag)::after {
  content: "·";
  margin: 0 8px;
  color: var(--steel);
}

.meta .tag {
  margin-left: 4px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.panel {
  margin-top: 24px;
  padding: 28px;
  border: 1px solid var(--steel);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.panel-intro {
  max-width: 64ch;
  margin: -8px 0 16px;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 32px;
  border: 2px dashed var(--hairline);
  border-radius: var(--radius);
}

/* Forms */

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid var(--steel);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  font-weight: 400;
}

input::placeholder {
  color: #8b9298;
}

fieldset:disabled input,
fieldset:disabled select {
  background: var(--bg);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 16px;
}

.field-grid > label {
  grid-column: span 1;
}

.field-grid > .span-2 {
  grid-column: span 2;
}

.form-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--hairline);
}

.form-footer > button:last-of-type {
  margin-left: auto;
}

.form-error {
  flex-basis: 100%;
  padding: 10px 14px;
  border-left: 4px solid var(--danger);
  border-radius: 4px;
  background: var(--danger-tint);
  color: var(--danger);
  font-weight: 600;
}

.inline-form fieldset {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.inline-form input {
  flex: 1 1 280px;
  width: auto;
}

.inline-form .form-error {
  margin-top: 4px;
}

.inline-label {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.inline-label select {
  width: auto;
}

.estimate {
  font-size: 14px;
}

/* Two-option toggle (Live / Standard). */
.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--steel);
  border-radius: 8px;
  background: var(--bg);
}

.segmented label {
  position: relative;
  display: block;
  font-weight: 600;
  cursor: pointer;
}

.segmented input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: block;
  padding: 8px 14px;
  border-radius: 6px;
  white-space: nowrap;
}

.segmented input:checked + span {
  background: var(--ink);
  color: var(--surface);
}

.segmented input:focus-visible + span {
  outline: 3px solid var(--orange);
  outline-offset: 1px;
}

.disclosure {
  margin-top: 20px;
}

.disclosure summary {
  width: fit-content;
  font-weight: 600;
  cursor: pointer;
}

.disclosure[open] summary {
  margin-bottom: 16px;
}

.manual-form .form-footer {
  border-top: 0;
  padding-top: 0;
}

/* Buttons */

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 10px 22px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--orange);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background-color 0.15s ease;
}

button:hover,
.button:hover {
  color: var(--ink);
  box-shadow: var(--lift-shadow);
  transform: translate(-2px, -2px);
}

button:active,
.button:active {
  box-shadow: none;
  transform: none;
}

.secondary,
.danger {
  background: var(--surface);
}

.secondary:hover,
.danger:hover {
  background: var(--bg);
}

.danger,
.danger:hover {
  color: var(--danger);
}

.small {
  min-height: 36px;
  padding: 6px 14px;
  font-size: 14px;
}

.small:hover {
  box-shadow: 3px 3px 0 var(--ink);
}

fieldset:disabled button {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* Tags and statuses */

.tag,
.status,
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.tag.ok,
.status-complete {
  background: var(--success-tint);
  color: var(--success);
}

.tag.warn,
.status-failed {
  background: var(--danger-tint);
  color: var(--danger);
}

.status-running {
  background: var(--orange-tint);
  color: var(--orange-text);
}

.badge.mock {
  border-color: var(--ink);
  background: var(--orange);
  color: var(--ink);
}

/* Lists and tables */

.result-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.result-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--hairline);
}

.result-list li > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

#search-results .result-list {
  margin-top: 8px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.data-table td {
  overflow-wrap: anywhere;
}

/* Two short columns: a domain only breaks if it cannot fit on its own line. */
.data-table.site-table td {
  overflow-wrap: break-word;
}

.data-table th,
.data-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
}

.data-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table .num {
  text-align: right;
}

.data-table tr.clickable {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.data-table tr.clickable:hover {
  background: var(--bg);
}

.data-table.compact th,
.data-table.compact td {
  padding: 9px 6px;
  font-size: 14px;
}

.data-table tr.is-client td {
  background: var(--orange-tint);
  font-weight: 700;
}

/* Alerts and progress */

.alert {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 20px;
  padding: 16px 20px;
  border: 1px solid var(--steel);
  border-left-width: 6px;
  border-radius: 8px;
  background: var(--surface);
}

.alert.error {
  border-color: var(--danger);
  background: var(--danger-tint);
}

.alert.error strong {
  color: var(--danger);
}

.alert.info {
  border-left-color: var(--orange);
}

.alert.success {
  border-color: var(--success);
  background: var(--success-tint);
}

.progress-card {
  gap: 12px;
  border-left-color: var(--orange);
}

.progress-label {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.progress {
  height: 10px;
  overflow: hidden;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--bg);
}

.progress div {
  height: 100%;
  background: var(--orange);
  transition: width 0.4s ease;
}

.progress.indeterminate div {
  background: repeating-linear-gradient(-45deg, var(--orange) 0 12px, #f6a947 12px 24px);
  background-size: 34px 34px;
  animation: progress-stripes 1s linear infinite;
}

@keyframes progress-stripes {
  to {
    background-position: 34px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .progress.indeterminate div {
    animation: none;
  }
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 2000;
  max-width: 440px;
  margin-left: auto;
  padding: 14px 18px;
  border: 2px solid var(--ink);
  border-left: 6px solid var(--danger);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--lift-shadow);
  color: var(--ink);
  font-weight: 600;
}

/* Scan view */

.scan-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  align-items: start;
  gap: 20px;
}

/* The grid is square, so the map is too: no wasted space beside it. */
.map-frame {
  aspect-ratio: 1;
  /* Square, as large as the column allows without exceeding the viewport height. */
  width: min(100%, max(360px, calc(100vh - 160px)));
  margin-inline: auto;
  overflow: hidden;
  border: 1px solid var(--steel);
  border-radius: var(--radius);
  background: #e8e8e4;
}

.map {
  width: 100%;
  height: 100%;
}

.scan-panel {
  position: sticky;
  top: 96px;
  padding: 20px;
  border: 1px solid var(--steel);
  border-radius: var(--radius);
  background: var(--surface);
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 16px;
  padding: 24px;
  border-radius: 14px;
  background: radial-gradient(120% 140% at 0% 0%, #2a2a2d 0%, var(--ink) 55%);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-value {
  color: var(--orange);
  font-family: var(--font-heading);
  font-size: 34px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.stat-value.is-empty {
  color: #4b4f55;
}

.stat-label {
  color: var(--bg);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  font-weight: 500;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgb(0 0 0 / 35%);
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.rank-top {
  background: var(--rank-top);
}

.rank-good {
  background: var(--rank-good);
}

.rank-mid {
  background: var(--rank-mid);
}

.rank-low {
  background: var(--rank-low);
}

.rank-none {
  background: var(--rank-none);
}

/* Not found, but outside the area searched: an outline, not a solid miss. */
.rank-outside {
  background: var(--surface);
  color: var(--rank-none);
}

.pin.rank-outside,
.swatch.rank-outside {
  border: 2px solid var(--rank-none);
}

.rank-pending {
  background: var(--rank-pending);
}

.rank-failed {
  background: var(--rank-failed);
}

.pin-arrow {
  font-size: 8px;
}

/* Two-digit changes plus an arrow need a smaller face to fit small pins. */
.pin.pin-long {
  font-size: 10px;
}

.change-up {
  background: var(--change-up);
}

.change-down {
  background: var(--change-down);
}

.change-same {
  background: var(--change-same);
}

.legend-note {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 12px;
}

.scan-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* Grid scan: metrics with their meaning, map controls, competitors */

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
  padding: 24px;
  border-radius: 14px;
  background: radial-gradient(120% 140% at 0% 0%, #2a2a2d 0%, var(--ink) 55%);
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-value {
  color: var(--orange);
  font-family: var(--font-heading);
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
}

.metric-value.is-empty {
  color: #4b4f55;
}

.metric-label {
  color: var(--bg);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.metric-delta {
  color: #c9cdd1;
  font-size: 12px;
  font-weight: 600;
}

.metric-delta.better {
  color: #86efac;
}

.metric-delta.worse {
  color: #fdba74;
}

.metric-explain {
  margin-top: 4px;
  color: #b4b8bd;
  font-size: 13px;
  line-height: 1.45;
}

.leader-line {
  margin: 12px 0 20px;
  font-size: 15px;
}

.map-toolbar {
  display: flex;
  justify-content: flex-start;
}

.map-view-label {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.map-view-label select {
  min-width: 220px;
}

.competitor-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Each competitor is a button that shows it on the map. */
.competitor {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  box-shadow: none;
  color: var(--ink);
  font-weight: 600;
  text-align: left;
  /* Buttons do not wrap by default; long business names must. */
  white-space: normal;
}

.competitor:hover,
.competitor:focus-visible {
  border-color: var(--steel);
  background: var(--bg);
  box-shadow: none;
  transform: none;
}

.competitor.is-client {
  background: var(--orange-tint);
}

.competitor.is-selected {
  border-color: var(--ink);
  background: var(--surface);
}

.competitor-place {
  color: var(--muted);
  font-size: 13px;
}

.competitor-name {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.competitor-name .muted {
  font-weight: 500;
}

.competitor-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  white-space: nowrap;
}

/* A selected competitor's location: an ink diamond, distinct from the round pins. */
.subject-marker,
.swatch.subject {
  width: 14px;
  height: 14px;
  border: 2px solid var(--surface);
  border-radius: 2px;
  background: var(--ink);
  box-shadow: 0 0 0 2px var(--orange);
  transform: rotate(45deg);
}

/* Keyword suggestions */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.field-label {
  font-weight: 600;
}

.site-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Checkbox beside its text, with the detail line under the text. */
.check {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 2px 10px;
  font-weight: 500;
}

.check .small-text {
  grid-column: 2;
}

.check input,
.select-cell input {
  width: 18px;
  height: 18px;
  accent-color: var(--ink);
}

.select-cell {
  width: 32px;
}

.cell-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

/* Why they outrank you */

.outrank {
  margin-top: 20px;
}

.outrank h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.outrank-summary {
  margin-bottom: 20px;
}

.outrank-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
}

.outrank-categories {
  margin-bottom: 20px;
}

.outrank-categories .chips {
  margin: 0 0 6px;
}

.closed {
  color: var(--danger);
  font-weight: 600;
}

/* Trend charts */

.trends {
  margin-top: 20px;
}

.trend-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.trend-charts figure {
  margin: 0;
  min-width: 0;
}

.trend-charts figcaption {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
}

.chart-frame {
  position: relative;
}

.chart-frame svg {
  display: block;
  overflow: visible;
}

.chart-frame svg:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 4px;
  border-radius: 4px;
}

.chart-grid {
  stroke: var(--chart-grid);
  stroke-width: 1;
}

.chart-axis {
  fill: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart-line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-dot {
  stroke: var(--surface);
  stroke-width: 2;
}

.chart-hit {
  fill: transparent;
}

.chart-end-label {
  fill: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.chart-crosshair {
  stroke: var(--steel);
  stroke-width: 1;
  pointer-events: none;
}

.chart-tooltip {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--tag-shadow);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
}

.chart-tooltip strong {
  font-size: 15px;
}

.chart-tooltip span {
  color: var(--muted);
}

.chart-table {
  margin-top: 16px;
}

.chart-table summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.chart-table table {
  margin-top: 12px;
}

.sparkline {
  display: block;
  overflow: visible;
}

.pin.center,
.swatch.center {
  box-shadow: 0 0 0 3px var(--ink);
}

.swatch.center {
  background: var(--surface);
}

.leaflet-container {
  font-family: var(--font-body);
}

.leaflet-popup-content-wrapper {
  border: 1px solid var(--hairline);
  border-radius: 8px;
  box-shadow: var(--tag-shadow);
}

.leaflet-popup-content p {
  margin: 0;
}

.leaflet-popup-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 14px 16px;
  font-size: 14px;
  line-height: 1.45;
}

.popup-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 800;
}

.popup-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 8px 0;
  padding-left: 22px;
}

.popup-list li {
  padding: 2px 4px;
  border-radius: 4px;
}

.popup-name {
  display: block;
  font-weight: 600;
}

.popup-list .is-client {
  background: var(--orange-tint);
}

.popup-list .is-subject {
  outline: 2px solid var(--ink);
}

.popup-link {
  font-size: 13px;
}

/* Tabs */

.tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 4px;
  border-bottom: 2px solid var(--hairline);
}

.tabs a {
  margin-bottom: -2px;
  padding: 10px 18px;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}

.tabs a:hover {
  color: var(--ink);
}

.tabs a.active {
  border-bottom-color: var(--orange);
  color: var(--ink);
}

/* Keyword tracking */

textarea {
  width: 100%;
  min-height: 132px;
  padding: 10px 14px;
  border: 1px solid var(--steel);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  font-weight: 400;
  line-height: 1.5;
  resize: vertical;
}

.field-grid > .span-3 {
  grid-column: span 3;
}

.field-stack {
  display: grid;
  gap: 16px;
}

.hint {
  font-weight: 400;
}

.location-picker {
  position: relative;
}

.suggestions {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  z-index: 50;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--steel);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--tag-shadow);
  list-style: none;
}

.suggestions li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
}

.suggestions li:hover {
  background: var(--bg);
}

.stats-wide {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 20px;
}

.keyword {
  font-weight: 700;
}

.small-text {
  font-size: 13px;
}

.change {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.change.up {
  color: var(--success);
}

.change.down {
  color: var(--danger);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.chip {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 20px;
}

/* Client report */

.report-header .takeaway {
  max-width: 62ch;
  margin-top: 4px;
  padding-left: 14px;
  border-left: 4px solid var(--orange);
  font-size: 18px;
  font-weight: 600;
}

.report-header .muted {
  max-width: 62ch;
}

/* Phones and narrow tablets */

/* Clients on the home page and trackers on a business */

.summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.summary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 18px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
}

.summary-value {
  font-family: var(--font-heading);
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.summary-value.better {
  color: var(--success);
}

.summary-value.worse {
  color: var(--danger);
}

.summary-label {
  color: var(--muted);
  text-wrap: balance;
  font-size: 13px;
  font-weight: 600;
}

.client-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.client {
  padding: 18px 22px 8px;
  border: 1px solid var(--steel);
  border-radius: var(--radius);
  background: var(--surface);
}

.client > p {
  padding-bottom: 12px;
}

.client-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin-bottom: 8px;
  cursor: pointer;
}

.client-name,
.tracker-name {
  font-family: var(--font-heading);
  font-size: 19px;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
}

.tracker-table td {
  vertical-align: middle;
}

.tracker-table td:first-child {
  display: flex;
  flex-direction: column;
}

.tracker-table td.num strong {
  font-size: 17px;
}

.tracker-table .kpi-change {
  display: block;
}

.tracker-table tbody tr:last-child td {
  border-bottom: 0;
}

.tracker-card {
  border: 1px solid var(--steel);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition:
    box-shadow 0.2s ease,
    border-color 0.2s ease;
}

.tracker-card:hover {
  border-color: var(--ink);
  box-shadow: var(--soft-shadow);
}

.tracker-card header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, auto));
  justify-content: start;
  gap: 8px 28px;
  margin: 0;
}

.kpis div {
  display: flex;
  flex-direction: column;
}

.kpis dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.kpis dd {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kpis dd + dd {
  font-size: 12px;
}

.kpi-change {
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.kpi-change.better {
  color: var(--success);
}

.kpi-change.worse {
  color: var(--danger);
}

.sparkline polyline {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.sparkline circle {
  fill: var(--orange);
  stroke: var(--surface);
  stroke-width: 2;
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 28px 0 16px;
}

.section-header + .panel {
  margin-top: 0;
  margin-bottom: 24px;
}

.tracker-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.tracker-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 22px;
}

.tracker-body {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.tracker-card footer > span {
  flex: 1 1 200px;
}

.tracker-card footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
  margin-top: 20px;
}

.form-row .check,
.form-footer .check {
  display: inline-grid;
}

.schedule-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.schedule-fields label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

/* Tracker page */

.tracker-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 20px;
  padding: 14px 18px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
}

.tracker-bar .disclosure {
  margin: 0;
}

.tracker-bar .disclosure[open] {
  flex-basis: 100%;
}

.schedule-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  min-width: 0;
}

.schedule-text strong {
  margin-right: 6px;
}

.schedule-text.is-paused {
  color: var(--muted);
}

.schedule-actions {
  display: flex;
  gap: 8px;
}

.schedule-form {
  flex-basis: 100%;
}

.schedule-form fieldset {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.run-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  margin-bottom: 20px;
}

.keyword-picker {
  min-width: min(100%, 280px);
}

.timeline {
  display: flex;
  flex: 1 1 320px;
  gap: 0;
  min-width: 0;
  margin: 0;
  padding: 0 0 4px;
  overflow-x: auto;
  list-style: none;
}

.timeline li {
  position: relative;
  flex: 0 0 auto;
}

/* The line joining the dots. */
.timeline li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 13px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--hairline);
}

.timeline a {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 64px;
  padding: 4px 6px;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
}

.timeline a:hover {
  background: var(--bg);
}

.timeline-dot {
  width: 16px;
  height: 16px;
  margin-bottom: 4px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--steel);
}

.timeline-dot.rank-top {
  background: var(--rank-top);
}
.timeline-dot.rank-good {
  background: var(--rank-good);
}
.timeline-dot.rank-mid {
  background: var(--rank-mid);
}
.timeline-dot.rank-low {
  background: var(--rank-low);
}
.timeline-dot.rank-none {
  background: var(--rank-none);
}
.timeline-dot.rank-pending,
.timeline-dot.is-missing {
  background: var(--rank-pending);
}

.timeline-dot.is-running {
  animation: pulse 1.2s ease-in-out infinite;
}

.timeline .is-current .timeline-dot {
  box-shadow:
    0 0 0 2px var(--surface),
    0 0 0 4px var(--ink);
}

.timeline-date {
  font-size: 12px;
}

.timeline-value {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.timeline .is-current .timeline-date {
  color: var(--ink);
  font-weight: 800;
}

@keyframes pulse {
  50% {
    opacity: 0.4;
  }
}

.scan-footer {
  margin-top: 24px;
  text-align: right;
}

.link-button,
.link-button:hover {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: underline;
  transform: none;
}

.link-button:hover {
  color: var(--danger);
}

@media (width <= 1024px) {
  .field-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .field-grid > .span-2 {
    grid-column: span 3;
  }
}

@media (width <= 900px) {
  .scan-body,
  .two-column {
    grid-template-columns: minmax(0, 1fr);
  }

  .stats-wide {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-grid > .span-3 {
    grid-column: 1 / -1;
  }

  .scan-panel {
    position: static;
  }
}

@media (width <= 640px) {
  :root {
    --gutter: 16px;
  }

  .container {
    padding-top: 24px;
  }

  .brand-mark {
    width: 22px;
    height: 22px;
  }

  .brand-name {
    font-size: 17px;
  }

  .brand-product {
    font-size: 15px;
  }

  .badge.mock {
    padding: 2px 6px;
    font-size: 10px;
  }

  .panel {
    padding: 20px 16px;
  }

  .field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-grid > .span-2 {
    grid-column: span 2;
  }

  .form-footer > button:last-of-type,
  .inline-form button {
    width: 100%;
    margin-left: 0;
  }

  .segmented {
    width: 100%;
  }

  .segmented label {
    flex: 1;
    text-align: center;
  }

  .segmented span {
    padding-inline: 8px;
    white-space: normal;
  }

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

  .actions {
    width: 100%;
  }

  .actions > :not(.small) {
    flex: 1;
  }

  .map-frame {
    width: 100%;
  }

  .client {
    padding: 16px;
  }

  .tracker-table.data-table.stacked td:first-child {
    grid-column: 1 / -1;
  }

  .summary-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .summary {
    padding: 12px;
  }

  .summary-value {
    font-size: 24px;
  }

  .sparkline {
    max-width: 100%;
    height: auto;
  }

  .tracker-cards {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Tables become one card per row, each value labelled. */
  .data-table.stacked thead {
    display: none;
  }

  .data-table.stacked tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--hairline);
  }

  .data-table.stacked td {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0;
    border: 0;
    text-align: left;
  }

  .data-table.stacked td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .data-table.stacked td[data-label="Keyword"],
  .data-table.stacked td[data-label="Location"],
  .data-table.stacked td[data-label="On the page"] {
    grid-column: 1 / -1;
  }

  .keyword-table.stacked tr {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .keyword-table.stacked td:last-child {
    grid-column: 1 / -1;
  }

  /* Checkbox in its own narrow column; the row's values line up beside it. */
  .suggestion-table.stacked tr {
    grid-template-columns: 24px repeat(3, minmax(0, 1fr));
  }

  .suggestion-table.stacked td.select-cell {
    grid-area: 1 / 1;
  }

  .suggestion-table.stacked td[data-label="Keyword"] {
    grid-column: 2 / -1;
  }

  .suggestion-table.stacked td[data-label="Searches / mo"] {
    grid-area: 2 / 2;
  }

  .suggestion-table.stacked td[data-label="You"] {
    grid-area: 2 / 3;
  }

  .suggestion-table.stacked td[data-label="Competitors"] {
    grid-area: 3 / 2 / auto / -1;
  }

  /* A highlighted row is one block, not a set of tinted cells. */
  .data-table.stacked tr.is-client {
    margin-inline: -8px;
    padding-inline: 8px;
    border-radius: 8px;
    background: var(--orange-tint);
  }

  .data-table.stacked tr.is-client td {
    background: none;
  }

  .outrank-table.stacked td[data-label="Business"] {
    grid-column: 1 / -1;
  }

  .outrank-summary {
    gap: 16px;
  }

  .opportunity-table.stacked td[data-label="Site"] {
    grid-column: 1 / -1;
  }

  .opportunity-table.stacked td[data-label="Links to"] {
    grid-column: 2 / -1;
  }

  .keyword-table.stacked td.trend-cell {
    grid-column: span 2;
  }

  .trend-charts {
    grid-template-columns: minmax(0, 1fr);
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 16px;
    padding: 20px;
  }

  .metric-value {
    font-size: 28px;
  }

  .map-view-label,
  .map-view-label select {
    width: 100%;
    min-width: 0;
  }

  .tabs a {
    flex: 1;
    padding-inline: 8px;
    text-align: center;
  }

  .result-list li {
    align-items: flex-start;
  }

  .footer-wrap {
    flex-direction: column;
    align-items: flex-start;
  }
}
