/* Shared scope, industry identity, and comparable reporting surfaces. */
/* Main remains the skip-link target; its focus indicator is confined to the heading. */
#main:focus { outline: none; }
#main:focus-visible #view-title,
#view-title:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
:root {
  --industry-research: #4976c7;
  --industry-vet: #cc762c;
  --industry-fishwildlife: #3b8859;
  --industry-industrial: #6c8290;
  --industry-shared: #7e8593;
  --plot-selected: #3979c7;
  --plot-comparison: #9063bf;
  --scope-color: var(--plot-selected);
  --uid-blue-wash: #f0f1ee;
  --uid-blue-dark: #43474f;
  --globe-background: #0b2233;
  --globe-light: #1e889e;
  --globe-mid: #155f70;
  --globe-edge: #0b2233;
  --globe-line: #b2d5dc;
  --globe-grid: #6eabb74d;
  --globe-outline: #72b4c3;
  --globe-halo: #1e889e40;
  --map-point: #edaa00;
  --map-shadow: #ee7530;
  --map-glow: #ee753038;
  --badge-ai-text: #7044a5;
  --badge-search-text: #196f60;
  --badge-social-text: #9a336b;
  --badge-referral-text: #835812;
  --badge-campaign-text: #aa4b2b;
  --badge-direct-text: #465362;
  color-scheme: light;
}

:root[data-industry="research"] { --scope-color: var(--industry-research); }
:root[data-industry="vet"] { --scope-color: var(--industry-vet); }
:root[data-industry="fishwildlife"] { --scope-color: var(--industry-fishwildlife); }
:root[data-industry="industrial"] { --scope-color: var(--industry-industrial); }
:root[data-industry="shared"] { --scope-color: var(--industry-shared); }

:root[data-theme="dark"] {
  --ink: #e9e9e5;
  --muted: #a4a6ad;
  --border: #36383d;
  --surface: #232529;
  --background: #191b1e;
  --accent: #92b7f4;
  --sidebar: #202226;
  --sidebar-text: #a8abb2;
  --sidebar-muted: #787c85;
  --soft-surface: #2a2c31;
  --hover-surface: #303237;
  --selected-surface: #34373c;
  --selected-ink: #f0f0ea;
  --panel-shadow: 0 2px 8px #00000010;
  --uid-blue-wash: #2c2e33;
  --uid-blue-dark: #d8dad3;
  --uid-green-wash: #263e34;
  --uid-green-dark: #a0d79f;
  --uid-orange-wash: #42372c;
  --uid-orange-dark: #eac19d;
  --uid-yellow-wash: #393b28;
  --uid-slate: #afc0ca;
  --industry-research: #86a8ed;
  --industry-vet: #e7a46e;
  --industry-fishwildlife: #7dc39a;
  --industry-industrial: #a0b8c6;
  --industry-shared: #abb2c5;
  --plot-selected: #79aaf5;
  --plot-comparison: #bb91ed;
  --chart-total: #79aaf5;
  --chart-ai: #b790ec;
  --chart-search: #64cbae;
  --chart-social: #e692be;
  --chart-referral: #deba6f;
  --chart-campaign: #f29b7c;
  --chart-direct: #a9b9cf;
  --badge-ai-text: #cda8ff;
  --badge-search-text: #8be0c6;
  --badge-social-text: #ee9fc9;
  --badge-referral-text: #eac589;
  --badge-campaign-text: #f4b295;
  --badge-direct-text: #ccd5e3;
  color-scheme: dark;
}

button, input, select, textarea,
.login-card, .series-toggle {
  color: var(--ink);
  background: var(--surface);
}

.app-header .brand { padding-bottom: 26px; }
.header-inner .primary-nav { gap: 7px; }
.header-inner .brand-logo { width: 42px; }

.filters {
  gap: 12px 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--panel-shadow);
}

.filter-group {
  flex-direction: column;
  gap: 5px;
  align-items: stretch;
}

.scope-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: -14px 0 22px; }
.scope-chips:empty { display: none; }
.scope-chips button { max-width: 100%; padding: 6px 9px; border-color: var(--border); border-radius: 6px; font-size: .75rem; text-align: left; background: var(--soft-surface); overflow-wrap: anywhere; }
.scope-chips span { margin-left: 8px; }

.filter-group label,
.contextual-report-controls label,
.section-heading label,
.raw-controls label,
.advanced-scope-fields label {
  display: grid;
  gap: 5px;
  font-size: .75rem;
  color: var(--muted);
}

.filters select { padding: 8px 10px; font-size: .8125rem; }
.filters .range-label { width: auto; font-size: .75rem; }
#range-label { width: 100%; }
.topbar .icon-button { display: inline-flex; flex: 0 0 38px; align-items: center; justify-content: center; width: 38px; height: 38px; margin: 0; padding: 0; border-radius: 8px; font-size: 1.2rem; line-height: 1; }
.appearance-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.location-filter,
.advanced-scope {
  position: relative;
  align-self: end;
  margin-bottom: 3px;
  font-size: .8125rem;
}

.location-filter summary,
.advanced-scope summary {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
}

#location-selection-label { color: var(--muted); }
.location-menu,
.advanced-scope-fields {
  display: grid;
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 25;
  gap: 14px;
  width: 350px;
  max-width: calc(100vw - 36px);
  margin-top: 7px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: 0 8px 24px #00000018;
}

#location-options { max-height: 280px; overflow-y: auto; }
.location-choice {
  display: flex;
  gap: 9px;
  align-items: center;
  min-height: 36px;
  padding: 7px 0;
  font-size: .8125rem;
}
.location-choice span { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); }
.location-choice input { width: 17px; height: 17px; accent-color: var(--scope-color); }
.location-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.advanced-scope-fields input { width: 100%; }
#reset-scope { align-self: end; margin-bottom: 3px; }

.overview-plots,
.overview-evidence {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.metric-group { padding: 18px; }
.metric-group-outcomes { border-top-color: var(--border); }
.metric-group-label { margin-bottom: 10px; }
.metric-description,
.selected-goals-summary { display: none; }
.metric-secondary { margin-top: 12px; padding-top: 12px; }
.metric-reading { margin-top: 7px; margin-bottom: 4px; }
.metric-primary .metric-value { font-size: 2.125rem; }

.chart-panel,
.report-panel { margin-bottom: 20px; padding: 24px; border-radius: 12px; box-shadow: var(--panel-shadow); }
.overview-plots > .chart-panel,
.overview-evidence > .report-panel { margin-bottom: 0; }
.chart-panel h2,
.report-panel h2 { font-size: 1.05rem; }
.chart-panel .section-heading,
.report-panel .section-heading { margin-bottom: 18px; }
.section-heading > a { font-size: .8125rem; color: var(--accent); }
.section-heading select { font-size: .8125rem; }
.panel-note { margin-top: 14px; font-size: .75rem; line-height: 1.65; color: var(--muted); }
.panel-note:first-child { margin-top: 0; }
.report-panel th,
.report-panel td { padding: 11px 12px; font-size: .8125rem; }
.report-panel td small { font-size: .6875rem; line-height: 1.6; color: var(--muted); }
.report-panel table { min-width: 570px; }

.industry-link,
.text-button {
  padding: 4px 0;
  border: 0;
  font-size: .8125rem;
  font-weight: 600;
  text-align: left;
  color: var(--accent);
  background: transparent;
}
.industry-link::before { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--section-color); content: ""; }
.industry-choices { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 22px; }
.industry-choices button { border-radius: 7px; font-size: .8125rem; }
.industry-choices button[aria-pressed="true"] { border-color: var(--muted); color: var(--ink); background: var(--soft-surface); }

.comparison-legend { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-bottom: 12px; font-size: .75rem; color: var(--muted); }
.additional-series-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.plot-series-key { display: inline-flex; gap: 6px; align-items: center; padding: 3px 0; border: 0; font-size: .75rem; color: var(--muted); background: transparent; }
.plot-series-key::before { width: 18px; height: 3px; background: var(--series-color); content: ""; }
.plot-series-key[aria-pressed="false"] { opacity: .4; }
.plot-series-key:hover { color: var(--ink); background: transparent; }
#industry-plot.has-industry-series { --scope-color: #9b72cf; --plot-comparison: #8f96a2; }
#industry-plot.has-industry-series .plot-current { stroke-width: 3.25; }
.plot-industry { fill: none; stroke: var(--series-color); stroke-width: 1.8; }
.plot-point-industry { fill: var(--series-color); stroke: var(--surface); stroke-width: 1.5; }
.comparison-legend span::before { display: inline-block; width: 18px; height: 3px; margin-right: 6px; vertical-align: middle; background: var(--scope-color); content: ""; }
.comparison-legend .prior-key::before { height: 0; border-top: 2px dashed var(--plot-comparison); background: transparent; }
.comparison-svg svg,
#acquisition-plot svg { display: block; width: 100%; overflow: visible; }
.comparison-svg text,
#acquisition-plot text { font-size: 12px; fill: var(--muted); }
.plot-grid { stroke: var(--border); stroke-width: 1; }
.plot-current { fill: none; stroke: var(--scope-color); stroke-width: 2.5; }
.plot-prior { fill: none; stroke: var(--plot-comparison); stroke-width: 1.75; stroke-dasharray: 5 5; }
.plot-inspector { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 4; opacity: .65; }
.plot-point-current { fill: var(--scope-color); stroke: var(--surface); stroke-width: 2; }
.plot-point-prior { fill: var(--plot-comparison); stroke: var(--surface); stroke-width: 2; }
.plot-baseline { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
#acquisition-plot circle { fill: var(--channel-color, var(--scope-color)); opacity: .85; }
#acquisition-plot a:focus circle,
#acquisition-plot a:hover circle { stroke: var(--ink); stroke-width: 2; opacity: 1; }
.comparison-svg svg { touch-action: pan-y; }
.comparison-tooltip { position: fixed; z-index: 60; width: 274px; max-width: calc(100vw - 24px); padding: 16px; border: 1px solid var(--border); border-radius: 10px; color: var(--ink); background: var(--surface); box-shadow: 0 10px 30px #00000030; pointer-events: none; }
.comparison-tooltip > strong { font-size: .875rem; }
.comparison-tooltip > p { margin-top: 4px; font-size: .6875rem; color: var(--muted); }
.comparison-tooltip dl { display: grid; gap: 14px; margin-top: 14px; }
.comparison-tooltip dl > div { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.comparison-tooltip dt { font-size: .75rem; }
.comparison-tooltip dt span { display: block; margin-top: 4px; font-size: .6875rem; line-height: 1.5; color: var(--muted); }
.comparison-tooltip dd { margin: 0; font-size: 1.125rem; font-weight: 600; }
.comparison-tooltip .current-reading dd { color: color-mix(in srgb, var(--scope-color) 60%, var(--ink)); }
.comparison-tooltip .prior-reading dd { color: color-mix(in srgb, var(--plot-comparison) 70%, var(--ink)); }
.comparison-tooltip .comparison-industry-readings { gap: 7px; padding-top: 12px; border-top: 1px solid var(--border); }
.comparison-industry-readings dt::before { display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--series-color); content: ""; }
.comparison-industry-readings dd { font-size: .875rem; color: color-mix(in srgb, var(--series-color) 65%, var(--ink)); }
.acquisition-chart { padding: 20px 24px; border-bottom: 1px solid var(--border); }
.acquisition-chart .section-heading { flex-wrap: wrap; }
.acquisition-chart .panel-note { margin: 0; }
.acquisition-color-key { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; font-size: .75rem; color: var(--muted); }
.acquisition-color-key span::before { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--channel-color); content: ""; }
#overview-goals-plot { --scope-color: var(--chart-search); }

.overview-evidence { align-items: start; }
.geography-panel { container-type: inline-size; }
.historical-geography { display: grid; grid-template-columns: 260px minmax(0,1fr); gap: 20px; align-items: start; margin-top: 20px; }
.paged-report { min-width: 0; }
.compact-pagination { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-top: 12px; font-size: .75rem; color: var(--muted); }
.compact-pagination button { padding: 6px 9px; font-size: .75rem; }
@container (max-width: 720px) {
  .historical-geography { grid-template-columns: minmax(0,1fr); }
  .historical-globe { width: 100%; max-width: 300px; margin: 0 auto; }
}
.historical-globe { min-width: 0; text-align: center; }
.globe-stage { position: relative; }
.historical-globe canvas { display: block; width: 100%; height: 260px; border-radius: 12px; background: var(--soft-surface); }
.geography-scope { margin-top: 7px; }
.historical-globe canvas.inspecting { cursor: help; }
.globe-tooltip { position: fixed; z-index: 60; width: 246px; max-width: calc(100vw - 24px); padding: 16px; border: 1px solid var(--border); border-radius: 10px; text-align: left; color: var(--ink); background: var(--surface); box-shadow: 0 10px 30px #00000030; pointer-events: none; }
.globe-tooltip strong { display: block; font-size: .875rem; }
.globe-tooltip > p { margin-top: 4px; font-size: .6875rem; line-height: 1.5; color: var(--muted); }
.globe-tooltip dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.globe-tooltip dt { font-size: .6875rem; color: var(--muted); }
.globe-tooltip dd { margin: 4px 0 0; font-size: 1rem; font-weight: 600; color: var(--accent); }
.historical-globe button { margin-top: 12px; }
.historical-geography table { min-width: 440px; }
.recent-visit { display: grid; gap: 7px; width: 100%; padding: 16px 0; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; text-align: left; background: transparent; }
.recent-visit strong { font-size: .8125rem; color: var(--accent); overflow-wrap: anywhere; }
.recent-visit span { font-size: .75rem; color: var(--muted); }
.records-link { display: grid; gap: 8px; margin-top: 22px; font-size: .8125rem; color: var(--accent); }
.report-definitions { margin: 20px 0; font-size: .8125rem; line-height: 1.7; color: var(--muted); }
.report-definitions p { margin-top: 12px; }
.contextual-report-controls { display: flex; gap: 16px; }
.contextual-report-controls select { font-size: .8125rem; }
.journey-bounds { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; width: 100%; margin: 6px 0 0; padding: 14px 0 0; border: 0; border-top: 1px solid var(--border); }
.journey-bounds legend { font-size: .75rem; color: var(--muted); }
.journey-bounds label { width: 130px; }
.journey-bounds input { width: 100%; }
.raw-controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; margin-bottom: 18px; }
.raw-controls .raw-search { flex: 1; min-width: 220px; }
.raw-controls input { width: 100%; }
#raw-records {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
}

#raw-records table {
  width: max-content;
  min-width: 100%;
  table-layout: auto;
}

#raw-records th,
#raw-records td,
#raw-records .session-link {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

#raw-records td {
  max-width: none;
  font-family: Consolas,monospace;
  font-size: .75rem;
}
#raw-copy-fallback { width: 100%; min-height: 150px; margin-top: 14px; padding: 12px; border: 1px solid var(--border); }

th,
.reports th { color: var(--muted); background: var(--background); }
td,
.metric-secondary { border-color: var(--border); }
.reports tbody tr:hover,
tbody tr:hover { background: var(--soft-surface); }
.comparison-panel,
.reports tbody tr.selected-row { border-color: var(--border); background: var(--soft-surface); }
.metric-change b { color: var(--industry-fishwildlife); }
.metric-change b.negative { color: var(--industry-vet); }
.badge { --badge-color: var(--chart-direct); border: 1px solid color-mix(in srgb, var(--badge-color) 30%, transparent); color: var(--badge-direct-text); background: color-mix(in srgb, var(--badge-color) 14%, var(--surface)); }
.badge.ai { --badge-color: var(--chart-ai); color: var(--badge-ai-text); background: color-mix(in srgb, var(--badge-color) 14%, var(--surface)); }
.badge.search { --badge-color: var(--chart-search); color: var(--badge-search-text); background: color-mix(in srgb, var(--badge-color) 14%, var(--surface)); }
.badge.social { --badge-color: var(--chart-social); color: var(--badge-social-text); background: color-mix(in srgb, var(--badge-color) 14%, var(--surface)); }
.badge.referral { --badge-color: var(--chart-referral); color: var(--badge-referral-text); background: color-mix(in srgb, var(--badge-color) 14%, var(--surface)); }
.badge.campaign { --badge-color: var(--chart-campaign); color: var(--badge-campaign-text); background: color-mix(in srgb, var(--badge-color) 14%, var(--surface)); }
.chart-guide,
.chart-footer { border-color: var(--border); }
.mobile-filter-toggle { display: none; }

button:hover { background: var(--hover-surface); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline-color: var(--accent); }
.filters input, .filters select, .filters summary { border-radius: 7px; }
.metric-group-audience, .metric-group-engagement { border-top: 1px solid var(--border); }
.metric-primary .metric-value { font-weight: 650; letter-spacing: -.045em; }
.metric-group-label { color: var(--muted); letter-spacing: .07em; }
.topbar .eyebrow { display: none; }
.topbar { margin-bottom: 26px; }
.topbar h1 { font-size: 1.875rem; font-weight: 650; }
.view-description { margin-top: 7px; }
.header-inner .primary-nav { gap: 6px; }
.nav-item:hover { background: var(--soft-surface); }
.nav-item.selected { color: var(--selected-ink); background: var(--selected-surface); }
.nav-item.selected span { color: var(--selected-ink); }
.reports { border-radius: 12px; box-shadow: var(--panel-shadow); }
.reports th { background: var(--soft-surface); }
.reports td { border-color: var(--border); }
.sort-button:hover, .industry-link:hover, .text-button:hover { color: var(--ink); background: transparent; }
.recent-visit:hover { background: transparent; }
.recent-visit:hover strong, .section-heading > a:hover, .text-link:hover { text-decoration: underline; }
.industry-choices button::before { display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: var(--section-color, var(--muted)); content: ""; }
.industry-choices button {
  border-color: color-mix(in srgb, var(--section-color, var(--muted)) 30%, var(--border));
  background: color-mix(in srgb, var(--section-color, var(--muted)) 8%, var(--surface));
}
.industry-choices button:hover {
  background: color-mix(in srgb, var(--section-color, var(--muted)) 15%, var(--surface));
}
.industry-choices button[aria-pressed="true"] {
  border-color: var(--section-color, var(--muted));
  font-weight: 600;
  background: color-mix(in srgb, var(--section-color, var(--muted)) 19%, var(--surface));
}
.industry-scope-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  margin: 0 0 20px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--panel-shadow);
}
.industry-scope-label {
  font-size: .75rem;
  font-weight: 500;
  color: var(--muted);
}
.scope-industry-choices { gap: 8px; margin: 0; }
.scope-industry-choices button { padding: 8px 11px; font-size: .75rem; }
#industry-view > #industry-choices { display: none; }
.bar-track { background: color-mix(in srgb, var(--bar-color, var(--scope-color)) 15%, var(--surface)); }
.bar-fill { background: var(--bar-color, var(--scope-color)); }
.comparison-cell input, .location-choice input { accent-color: var(--accent); }
.logout { margin-top: 14px; }

@media (max-width: 1500px) {
  .overview-evidence { grid-template-columns: minmax(0,1fr); }
}

@media (max-width: 1100px) {
  .overview-plots { grid-template-columns: minmax(0,1fr); }
  .historical-geography { grid-template-columns: 230px minmax(0,1fr); }
  .topbar .live-status { flex-wrap: wrap; justify-content: start; }
}

@media (max-width: 800px) {
  .filters { position: sticky; top: 0; padding: 12px; }
  .filters .mobile-filter-toggle { display: flex; flex: 0 0 100%; grid-column: 1 / -1; gap: 12px; align-items: center; width: 100%; min-height: 44px; text-align: left; }
  .mobile-filter-toggle span { flex: 1; min-width: 0; font-size: .75rem; line-height: 1.5; color: var(--muted); }
  .filters:not(.expanded) .filter-group,
  .filters:not(.expanded) .location-filter,
  .filters:not(.expanded) .advanced-scope,
  .filters:not(.expanded) #reset-scope,
  .filters:not(.expanded) #custom-dates,
  .filters:not(.expanded) #comparison-range-label { display: none !important; }
  .filters .filter-group { flex: 1; min-width: 130px; }
  .location-filter,
  .advanced-scope { flex: 1; min-width: 130px; }
  .location-menu,
  .advanced-scope-fields { position: static; width: 100%; max-width: none; box-shadow: none; }
  .location-filter[open],
  .advanced-scope[open] { grid-column: 1 / -1; width: 100%; flex-basis: 100%; }
  .chart-panel,
  .report-panel { padding: 18px; }
  .historical-geography { grid-template-columns: minmax(0,1fr); }
  .historical-globe { max-width: 350px; margin: 0 auto; }
  .historical-globe canvas { height: 280px; }
  .raw-controls label { flex: 1; min-width: 140px; }
  .raw-controls .raw-search { min-width: 100%; }
  .journey-bounds label { flex: 1; min-width: 100px; width: auto; }
  .acquisition-chart { padding: 18px; }
  .industry-scope-bar { gap: 10px; padding: 14px; }
  .industry-scope-label { flex: 0 0 100%; }
  input, select, textarea { font-size: 16px; }
  .topbar .icon-button { flex-basis: 44px; width: 44px; height: 44px; }
}
