/* Sortlist design tokens — extracted from sortlist.com */
:root {
  --primary: #477FFC;
  --primary-600: #2E66E8;
  --primary-tint: #DEEAFD;
  --primary-tint-2: #EEF4FE;
  --secondary: #BD0F58;
  --bg: #FFFFFF;
  --surface: #F7F8FA;
  --surface-2: #EEF0F4;
  --border: #E6E8EE;
  --border-strong: #D2D6DF;
  --text: #0F0D0A;
  --muted: #6B7280;
  --muted-2: #9CA3AF;
  --green: #16A34A;
  --green-bg: #DCFCE7;
  --red: #DC2626;
  --red-bg: #FEE2E2;
  --amber: #F59E0B;
  --amber-bg: #FEF3C7;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.04);
  --shadow-md: 0 4px 12px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.04);
  --shadow-primary: rgba(71,127,252,.18) 0 1px 2px 0, rgba(71,127,252,.12) 0 0 8px 0;
}

* , *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { background: var(--bg); color: var(--text); }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}

h1, h2, .serif {
  font-family: Georgia, 'Cambria', 'Times New Roman', serif;
  font-weight: 400;
  letter-spacing: -0.01em;
}
h1 { font-size: 32px; line-height: 1.15; }
h2 { font-size: 22px; line-height: 1.2; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout shell */
header.app {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg); border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { height: 22px; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.2px; }
.brand-chip {
  font-size: 11px; background: var(--primary-tint); color: var(--primary);
  padding: 3px 8px; border-radius: 999px; font-weight: 500;
}
.app-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.timestamp { font-size: 12px; color: var(--muted); white-space: nowrap; }
.timestamp strong { color: var(--text); font-weight: 600; }

nav.tabs {
  padding: 0 28px; background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex; gap: 0; position: sticky; top: 53px; z-index: 99;
}
nav.tabs a, nav.tabs button {
  background: none; border: none; font: inherit; cursor: pointer;
  padding: 11px 16px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  font-weight: 500; font-size: 13px;
}
nav.tabs a.active, nav.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
nav.tabs a:hover, nav.tabs button:hover { color: var(--text); }

main { padding: 22px 28px 80px; max-width: 1480px; margin: 0 auto; }
main > section + section { margin-top: 26px; }

/* Drop-alert banner */
.alert-banner {
  background: #FFF5F5; border: 1px solid var(--red-bg);
  color: #991B1B; padding: 12px 16px; border-radius: var(--radius);
  display: flex; align-items: flex-start; gap: 10px;
  box-shadow: var(--shadow-sm);
}
.alert-banner.hidden { display: none; }
.alert-banner .icon { font-size: 16px; line-height: 1; margin-top: 1px; }
.alert-banner .content strong { color: var(--red); }
.alert-banner .item { display: inline-block; margin-right: 12px; }

.stale-banner {
  background: var(--amber-bg); border: 1px solid var(--amber); color: #92400E;
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 12.5px;
}
.stale-banner.hidden { display: none; }

/* KPI grid */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.kpi-grid.primary { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.kpi {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 6px; position: relative;
}
.kpi.primary { border-color: var(--primary-tint); }
.kpi .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.kpi .unit { font-size: 10px; color: var(--muted-2); text-transform: uppercase; letter-spacing: .5px; }
.kpi .value {
  font-size: 28px; font-weight: 700; line-height: 1.1;
  font-variant-numeric: tabular-nums; color: var(--text);
}
.kpi.primary .value { color: var(--primary); font-size: 32px; }
.kpi .deltas { display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; margin-top: 2px; }
.delta { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.delta .caption { color: var(--muted); font-weight: 500; margin-right: 3px; }
.delta.up   { color: var(--green); }
.delta.down { color: var(--red); }
.delta.flat { color: var(--muted); }
.delta.secondary { font-size: 11px; color: var(--muted); font-weight: 500; }
.delta.secondary .pct { font-weight: 600; }
.delta.secondary .pct.up { color: var(--green); }
.delta.secondary .pct.down { color: var(--red); }

/* Tables */
.card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.card h2 { margin-bottom: 14px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.card-header h2 { margin: 0; }
.card-hint { font-size: 12px; color: var(--muted); }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td {
  padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted);
  font-weight: 600; background: var(--surface);
}
table.data tr:last-child td { border-bottom: none; }
table.data tr.alert td:first-child { border-left: 3px solid var(--red); padding-left: 10px; }
table.data tr:hover td { background: var(--surface); }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.chip.up   { background: var(--green-bg); color: var(--green); }
.chip.down { background: var(--red-bg);   color: var(--red); }
.chip.flat { background: var(--surface-2); color: var(--muted); }

/* Charts */
.chart-wrap { position: relative; height: 340px; }
.chart-wrap.sm { height: 260px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.chart-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

/* Buttons */
.btn {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  padding: 7px 14px; border-radius: var(--radius-sm); cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: var(--shadow-primary); }
.btn.primary:hover { background: var(--primary-600); }
.btn.ghost { background: var(--primary-tint); color: var(--primary); border-color: var(--primary-tint); border-radius: 10px; }
.btn.ghost:hover { background: #CCDBFB; }

.btn-group { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--bg); }
.btn-group button {
  background: transparent; border: none; padding: 6px 12px; cursor: pointer; font: inherit; font-size: 12.5px;
  color: var(--muted); border-right: 1px solid var(--border);
}
.btn-group button:last-child { border-right: none; }
.btn-group button.active { background: var(--primary-tint); color: var(--primary); font-weight: 600; }

.select {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 10px;
  font: inherit; font-size: 13px; background: var(--bg); color: var(--text); cursor: pointer;
}

/* Property tabs (SEO page) */
.prop-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.prop-tabs button {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 12.5px; font-weight: 500;
  color: var(--muted); cursor: pointer;
}
.prop-tabs button:hover { background: var(--surface); color: var(--text); }
.prop-tabs button.active { background: var(--primary-tint); color: var(--primary); border-color: var(--primary-tint); font-weight: 600; }

/* Footer */
footer { padding: 20px 28px; color: var(--muted); font-size: 12px; text-align: center; border-top: 1px solid var(--border); }
footer a { color: var(--muted); text-decoration: underline; }

/* Small helpers */
.muted { color: var(--muted); }
.sub { font-size: 11.5px; color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Composition bars (SEO traffic breakdown) */
.comp-bar {
  display: flex; flex-direction: column; gap: 10px;
}
.comp-row { display: flex; flex-direction: column; gap: 4px; }
.comp-row .comp-label {
  display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .4px; font-weight: 600;
}
.comp-row .comp-label .total { color: var(--text); font-variant-numeric: tabular-nums; text-transform: none; letter-spacing: 0; font-weight: 600; }
.comp-track {
  display: flex; height: 26px; background: var(--surface-2); border-radius: var(--radius-sm); overflow: hidden;
}
.comp-seg {
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #fff; font-weight: 600; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; padding: 0 6px;
  transition: filter .12s;
}
.comp-seg:hover { filter: brightness(.92); }
.comp-seg.tiny { font-size: 10px; padding: 0 2px; }
.comp-legend {
  display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 6px; font-size: 12px; color: var(--muted);
}
.comp-legend .item {
  display: inline-flex; align-items: center; gap: 6px;
  font-variant-numeric: tabular-nums;
}
.comp-legend .dot { width: 10px; height: 10px; border-radius: 3px; }
.comp-legend strong { color: var(--text); font-weight: 600; margin-left: 2px; }
.comp-legend .delta { margin-left: 4px; }

/* Action cards grid */
.action-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px;
}
.action-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 10px;
  min-height: 220px;
}
.action-card h3 {
  font-size: 13px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.action-card h3 .emoji { font-size: 16px; }
.action-card h3 .count {
  margin-left: auto; font-size: 10px; background: var(--primary-tint); color: var(--primary);
  padding: 2px 8px; border-radius: 999px; font-weight: 700; letter-spacing: .4px;
}
.action-card h3 .count.red { background: var(--red-bg); color: var(--red); }
.action-card h3 .count.amber { background: var(--amber-bg); color: #92400E; }
.action-card h3 .count.green { background: var(--green-bg); color: var(--green); }
.action-card .hint { font-size: 11.5px; color: var(--muted); margin-top: -4px; }
.action-list { display: flex; flex-direction: column; gap: 6px; }
.action-item {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: baseline;
  font-size: 12.5px; padding: 6px 8px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid transparent;
}
.action-item:hover { border-color: var(--border); }
.action-item .key { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.action-item .key a { color: inherit; text-decoration: none; }
.action-item .key a:hover { text-decoration: underline; color: var(--primary); }
.action-item .meta {
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.action-item .meta .muted-2 { color: var(--muted-2); }
.action-item.brand .key::before {
  content: 'brand'; display: inline-block; margin-right: 6px; padding: 1px 6px; border-radius: 3px;
  font-size: 9.5px; font-weight: 700; background: #FCE4EE; color: var(--secondary); letter-spacing: .4px; text-transform: uppercase;
}
.action-card .empty { color: var(--muted); font-size: 12px; padding: 10px; text-align: center; background: var(--surface); border-radius: var(--radius-sm); }

/* Filter chips (for pages/queries tables) */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.filter-chip {
  border: 1px solid var(--border); background: var(--bg); color: var(--muted);
  padding: 4px 12px; border-radius: 999px; font: inherit; font-size: 12px; font-weight: 500;
  cursor: pointer;
}
.filter-chip:hover { color: var(--text); background: var(--surface); }
.filter-chip.active { background: var(--primary-tint); color: var(--primary); border-color: var(--primary-tint); font-weight: 600; }

/* Shareable summary */
.summary-card {
  background: linear-gradient(180deg, #0F0D0A, #1A1A1E);
  color: #fff;
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: 0 6px 20px rgba(15,13,10,.2);
  margin-bottom: 22px;
}
.summary-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px;
  flex-wrap: wrap;
}
.summary-head h2 {
  font-family: Georgia, serif; font-weight: 400; color: #fff; font-size: 20px;
}
.summary-head .subtitle { color: #9CA3AF; font-size: 12px; margin-top: 2px; }
.summary-head .btn.copy {
  background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.14); color: #fff;
  border-radius: 999px;
}
.summary-head .btn.copy:hover { background: rgba(255,255,255,.14); }
.summary-head .btn.copy.copied { background: var(--green); border-color: var(--green); color: #fff; }
.summary-hero {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  padding: 12px 0 10px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 12px;
}
.summary-hero .big {
  font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.summary-hero .big .u { font-size: 13px; color: #9CA3AF; font-weight: 500; margin-left: 4px; }
.summary-hero .delta-big {
  display: inline-flex; align-items: baseline; gap: 8px; padding: 3px 10px; border-radius: 999px; font-weight: 600; font-size: 13px;
}
.summary-hero .delta-big.up   { background: rgba(22,163,74,.18); color: #4ADE80; }
.summary-hero .delta-big.down { background: rgba(220,38,38,.18); color: #FCA5A5; }
.summary-hero .delta-big.flat { background: rgba(255,255,255,.08); color: #D1D5DB; }
.summary-hero .composition { font-size: 12px; color: #9CA3AF; }
.summary-hero .composition strong { color: #fff; font-weight: 600; }

.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 760px) { .summary-grid { grid-template-columns: 1fr; } }
.summary-col h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: #9CA3AF; font-weight: 700; margin-bottom: 8px;
}
.summary-col ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.summary-col li {
  font-size: 13px; padding: 8px 12px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,.04); border-left: 2px solid var(--muted-2); color: #E5E7EB;
}
.summary-col li.good { border-left-color: #4ADE80; }
.summary-col li.warn { border-left-color: #FCA5A5; }
.summary-col li.info { border-left-color: #477FFC; }
.summary-col li strong { color: #fff; font-weight: 600; }
.summary-channels {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 12px 0 4px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 14px;
}
@media (max-width: 560px) { .summary-channels { grid-template-columns: 1fr; } }
.ch-card {
  background: rgba(255,255,255,.04); border-radius: var(--radius-sm);
  padding: 10px 12px; display: flex; flex-direction: column; gap: 4px;
}
.ch-card .name {
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: #9CA3AF; font-weight: 700;
  display: flex; align-items: center; gap: 6px;
}
.ch-card .name .dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; }
.ch-card .row { display: flex; justify-content: space-between; font-size: 12.5px; color: #D1D5DB; font-variant-numeric: tabular-nums; }
.ch-card .row .metric { color: #9CA3AF; }
.ch-card .row .value strong { color: #fff; font-weight: 600; margin-right: 4px; }
.ch-card .row .up   { color: #4ADE80; }
.ch-card .row .down { color: #FCA5A5; }

/* Section headers (for Visibility / Opportunity) */
.section-header {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  margin: 8px 2px 14px;
}
.section-header h2 {
  font-family: Georgia, 'Cambria', serif; font-size: 26px; font-weight: 400; letter-spacing: -0.01em;
}
.section-header .sub { color: var(--muted); font-size: 13px; }
.section-header .pill {
  background: var(--primary-tint); color: var(--primary);
  padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600;
  letter-spacing: .4px; text-transform: uppercase;
}
.section-header .pill.magenta { background: #FCE4EE; color: var(--secondary); }

/* Funnel */
.funnel {
  display: grid; align-items: stretch; gap: 0;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 24px; box-shadow: var(--shadow-sm); margin-bottom: 18px;
}
.funnel.three-stage { grid-template-columns: 1fr auto 1fr auto 1fr; }
.funnel-card { display: flex; flex-direction: column; gap: 3px; padding: 6px 10px; }
.funnel-card.accent {
  background: linear-gradient(180deg, var(--primary-tint-2), #fff);
  border-radius: var(--radius); padding: 14px 16px; margin: -8px -8px -8px 0;
  border: 1px solid var(--primary-tint);
}
.funnel-card.accent.magenta {
  background: linear-gradient(180deg, #FCE4EE, #fff);
  border-color: #F8BBD0;
}
.funnel-card .label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600;
}
.funnel-card .label .unit { text-transform: none; letter-spacing: 0; color: var(--muted-2); font-weight: 500; }
.funnel-card .value {
  font-size: 30px; font-weight: 700; line-height: 1.05; color: var(--text);
  font-variant-numeric: tabular-nums; margin-top: 2px;
}
.funnel-card.accent .value { color: var(--primary); font-size: 34px; }
.funnel-card.accent.magenta .value { color: var(--secondary); }
.funnel-card .sub { font-size: 11.5px; color: var(--muted); }
.funnel-card .sub strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.funnel-card .sparkline { margin-top: 8px; height: 34px; width: 100%; display: block; }
.funnel-card .sparkline path.fill { fill: var(--primary); opacity: 0.1; }
.funnel-card .sparkline path.stroke { fill: none; stroke: var(--primary); stroke-width: 1.5; stroke-linejoin: round; }
.funnel-card .sparkline circle.end { fill: var(--primary); }
.funnel-card.accent.magenta .sparkline path.fill { fill: var(--secondary); opacity: 0.1; }
.funnel-card.accent.magenta .sparkline path.stroke { stroke: var(--secondary); }
.funnel-card.accent.magenta .sparkline circle.end { fill: var(--secondary); }

.funnel-arrow {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0 14px; color: var(--muted); min-width: 92px; position: relative;
}
.funnel-arrow::before {
  content: ''; position: absolute; left: 6px; right: 6px; top: 50%;
  height: 1px; background: var(--border); z-index: 0;
}
.funnel-arrow .tag {
  position: relative; z-index: 1; background: var(--surface); padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; color: var(--text);
  border: 1px solid var(--border); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.funnel-arrow .tag-label {
  position: relative; z-index: 1; background: var(--bg); padding: 0 6px; margin-top: 4px;
  font-size: 9.5px; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); font-weight: 600;
}

@media (max-width: 960px) {
  .funnel.three-stage { grid-template-columns: 1fr; }
  .funnel-arrow { padding: 8px 0; min-width: 0; }
  .funnel-arrow::before { left: 50%; right: auto; top: 0; bottom: 0; width: 1px; height: auto; }
  .funnel-card.accent { margin: 0; }
}

@media (max-width: 720px) {
  header.app, nav.tabs, main { padding-left: 16px; padding-right: 16px; }
  .kpi .value { font-size: 24px; }
  .kpi.primary .value { font-size: 26px; }
  h1 { font-size: 26px; }
  .funnel-card .value { font-size: 26px; }
  .funnel-card.accent .value { font-size: 28px; }
}
