:root {
  color-scheme: light;
  --fg: #101418;
  --bg: #ffffff;
  --muted: #55606a;
  --border: #c7cdd3;
  --control-border: #828d99;
  --accent: #0b4f8a;
  --focus: #0b4f8a;
  --danger: #7a1414;
  --danger-bg: #fdecec;
  --warn-bg: #fff6e0;
  --ok-bg: #e9f5ea;
  /* Overview pattern trends (pattern-trends.js). */
  --trend-line: #0b4f8a;
  --trend-fit: #a8481a;
  --trend-area: #e4eef7;
  --trend-grid: #e2e6ea;
  --trend-bad: #b3261e;
  --trend-good: #1d6b35;
  --trend-mark: #fff1b8;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --radius: 0.5rem;
  --control-height: 2.75rem;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 100;
}
.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}
/* Announced by screen readers, not shown (used by home.html and admin_users.html). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

a { color: var(--accent); }
a:focus, button:focus, input:focus, select:focus, textarea:focus, [tabindex]:focus {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
}
.site-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}
.site-title {
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
}
.nav-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
}
.signed-in-as {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.9rem;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem;
}

.site-footer {
  text-align: center;
  color: var(--muted);
  padding: 1rem;
  font-size: 0.85rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

/* Homepage-only console: six live summaries, with native keyboard links. */
.console-heading {
  background: #152035;
  color: #e3eaf3;
  padding: 1.5rem;
  border: 1px solid #3c536f;
  border-bottom: 4px solid #f3d15c;
}
.console-heading h1 { margin: 0.5rem 0; }
.console-heading p { margin: 0; }
.console-wordmark { font-size: 2rem; font-weight: 700; letter-spacing: 0.12em; }
.console-wordmark span { display: inline-block; font-size: 0.8rem; color: #f3d15c; }
.overview-tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin: 1rem 0; gap: 1px; background: #3c536f; border: 1px solid #3c536f; }
.overview-tile { display: flex; flex-direction: column; gap: 0.25rem; padding: 1rem; background: #1c2b43; color: #a5c9ff; text-decoration: none; min-width: 0; }
.overview-tile span { color: #d0daea; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; }
.overview-tile strong { font-size: clamp(1.5rem, 2.5vw, 2rem); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.overview-tile small { color: #d0daea; }
a.overview-tile:hover { background: #273c5b; }
a.overview-tile:focus { outline-color: #f3d15c; outline-offset: -4px; }
.tile-urgent strong { color: #ff9b8a; }
.tile-strategise strong { color: #f3d15c; }
.tile-sources strong { color: #87dfa0; }
#mentions-by-source, #connections { scroll-margin-top: 1rem; margin-top: 2rem; }
@media (max-width: 900px) { .overview-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 540px) { .overview-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .console-wordmark span { display: block; margin-top: 0.5rem; } }
th, td {
  border: 1px solid var(--border);
  padding: 0.5rem;
  text-align: left;
  vertical-align: top;
}
th { background: #f2f4f6; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 0.25rem;
  border: 1px solid var(--border);
  font-size: 0.85rem;
}
.badge-urgent, .badge-failed, .badge-denied { background: var(--danger-bg); border-color: var(--danger); }
.badge-strategise, .badge-partial, .badge-paused { background: var(--warn-bg); }
.badge-watch, .badge-success, .badge-active, .badge-published { background: var(--ok-bg); }

.notice {
  border: 1px solid var(--border);
  border-left-width: 6px;
  border-left-color: var(--accent);
  background: #f2f7fb;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
}
.notice-warning {
  border-left-color: #8a5a0b;
  background: var(--warn-bg);
}
[role="alert"] {
  border: 1px solid var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
  padding: 0.75rem 1rem;
  margin: 1rem 0;
}

form.inline { display: inline; }
fieldset { border: 1px solid var(--border); margin: 1rem 0; }
label { display: block; margin: 0.5rem 0 0.2rem; font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%;
  max-width: 40rem;
  padding: 0.4rem;
  border: 1px solid var(--control-border);
  border-radius: 0.2rem;
  font: inherit;
}
button, input[type=submit] {
  padding: 0.4rem 0.9rem;
  border-radius: 0.25rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}
button.secondary { background: #fff; color: var(--accent); }
button.danger, .danger button { background: var(--danger); border-color: var(--danger); }

.filters { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; }
.filters > div { min-width: 10rem; }

@media (max-width: 640px) {
  .nav-list { gap: 0.5rem; }
  th, td { padding: 0.35rem; }
}

/* Wide tables scroll inside their own region instead of overflowing the page. */
.table-wrap { overflow-x: auto; max-width: 100%; margin: 1rem 0; }
/* Patterns page: keep place names whole (the body allows breaks anywhere); the table scrolls. */
.patterns-table td { overflow-wrap: break-word; }
.patterns-table .where { min-width: 14rem; }
.patterns-table .time { white-space: nowrap; }
.table-wrap:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.table-wrap > table { margin: 0; }
td .notice, td .badge { display: inline-block; margin: 0.25rem 0 0; padding: 0.15rem 0.5rem; white-space: normal; }
td small { display: block; max-width: 28rem; color: var(--muted); }
.issue-summary { max-width: 70ch; white-space: pre-line; }
.table-wrap .issue-summary { margin: 0.375rem 0 0; }

/* Shared presentation primitives. Forms keep their native, no-script behavior. */
body { min-height: 100vh; overflow-wrap: anywhere; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.025em; }
h1 { font-size: clamp(1.75rem, 4vw, 2.25rem); margin: 0 0 1rem; }
h2 { font-size: 1.4rem; margin: 2rem 0 1rem; }
h3 { font-size: 1.1rem; margin: 1.5rem 0 0.75rem; }
p { margin: 0.75rem 0 1rem; }
main { max-width: 1280px; padding: 2rem 1.5rem; }
.site-header-inner { max-width: 1232px; justify-content: space-between; }
.site-title { letter-spacing: -0.03em; white-space: nowrap; }
.signed-in-as { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-left: 0; }
.signed-in-as span { max-width: 32rem; }
.desktop-nav { width: 100%; }
.mobile-nav { display: none; }
.account-menu { display: none; }
.nav-list { gap: 0.25rem; }
.nav-list a { display: block; padding: 0.625rem 0.75rem; border-radius: var(--radius); text-decoration: none; }
.nav-list a[aria-current=page] { background: var(--accent); color: #fff; font-weight: 650; }
.nav-list a:hover:not([aria-current=page]) { text-decoration: underline; }
.client-context { font-size: 0.9rem; color: var(--muted); margin: 0 0 1rem; }
.client-context a { padding: 0.5rem 0; }
.site-footer { border-top: 1px solid var(--border); margin-top: 2rem; }
.page-intro { max-width: 70ch; color: var(--muted); }
.panel, .form-panel { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin: 1.5rem 0; }
.panel > :first-child, .form-panel > :first-child { margin-top: 0; }
.auth-panel { max-width: 28rem; margin: clamp(1rem, 7vh, 5rem) auto; }
.auth-panel .page-intro { margin-bottom: 1.5rem; }
form:not(.inline):not(.filters) { max-width: 44rem; }
form:not(.inline):not(.filters) > label { margin-top: 1rem; }
input:not([type=hidden]):not([type=checkbox]):not([type=radio]), select, textarea {
  display: block; min-width: 0; max-width: 100%; min-height: var(--control-height);
  padding: 0.625rem 0.75rem; font: inherit;
}
textarea { resize: vertical; min-height: 7rem; }
label { margin-bottom: 0.5rem; }
button, input[type=submit], .button-link { min-height: var(--control-height); padding: 0.625rem 1rem; font-weight: 600; }
button { max-width: 100%; }
button:hover { filter: brightness(0.9); }
button:active { transform: translateY(1px); }
button:disabled { cursor: wait; opacity: 0.65; }
[aria-invalid=true] { outline: 2px solid var(--danger); outline-offset: 1px; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-top: 1.5rem; }
form > button { margin-top: 1rem; }
form.inline > button, .filters button { margin-top: 0; }
.auth-panel button[type=submit] { width: 100%; }
.help { font-size: 0.9rem; color: var(--muted); margin: 0.5rem 0 1rem; max-width: 65ch; }
.filters { padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); gap: 1rem; margin: 1.5rem 0; }
.filters > div { flex: 1 1 12rem; min-width: 0; }
.filters .filter-actions { flex: 0 1 auto; display: flex; gap: 1rem; align-items: center; }
.table-wrap { position: relative; border-radius: var(--radius); }
.table-wrap table { min-width: 38rem; }
.table-wrap table.compact { min-width: 0; }
th { font-size: 0.875rem; }
th, td { padding: 0.875rem 1rem; }
td { min-width: 7rem; }
td:first-child { min-width: 14rem; }
td.time { min-width: 12rem; font-variant-numeric: tabular-nums; }
td small { margin-top: 0.375rem; }
td .badge { white-space: nowrap; }
td form { min-width: 14rem; }
td form + form { margin-top: 1rem; }
td form.inline { display: block; }
td .row-actions { min-width: 16rem; }
td .row-actions form { margin-top: 1rem; }
summary { min-height: var(--control-height); cursor: pointer; padding: 0.625rem 0; font-weight: 600; }
summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
details[open] > summary { margin-bottom: 0.75rem; }
.confirm-action { margin-top: 1rem; max-width: 44rem; }
.confirm-action p { max-width: 55ch; }
.confirm-action form { margin: 0; }
.notice, [role=alert] { border-radius: var(--radius); }
.notice-success { background: var(--ok-bg); }
.notice[tabindex], [role=alert][tabindex] { scroll-margin-top: 1rem; }
.pagination, nav[aria-label=Pagination], nav[aria-label="Alert pages"] { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin: 1rem 0; }
.pagination a, nav[aria-label=Pagination] a, nav[aria-label="Alert pages"] a { padding: 0.625rem 0; }
.summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
.summary-grid .table-wrap { margin-top: 0; }
.summary-grid table { min-width: 0; }
.summary-grid td:first-child { min-width: 0; }
.summary-grid caption { text-align: left; font-weight: 650; padding: 0.5rem 0; }
.empty-state { padding: 1.5rem; }
[hidden] { display: none !important; }
@media (max-width: 800px) {
  main { padding: 1.5rem 1rem; }
  .site-header-inner { gap: 0.75rem; }
  .signed-in-as { font-size: 0.875rem; gap: 0.5rem; }
  .signed-in-as span { max-width: 13rem; }
  .signed-in-as button { padding: 0.5rem 0.75rem; }
  .desktop-nav { display: none; }
  .desktop-account { display: none; }
  .account-menu { display: block; }
  .account-menu[open] { flex-basis: 100%; }
  .account-menu .signed-in-as { padding: 0.75rem 0; }
  .mobile-nav { display: block; width: 100%; }
  .mobile-nav > summary { padding: 0.5rem 0; }
  .nav-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel, .form-panel { padding: 1rem; }
  .summary-grid { grid-template-columns: 1fr; gap: 0; }
  .filters > div { flex-basis: 100%; }
  .filters .filter-actions { flex-basis: 100%; }
  .auth-panel { margin-top: 1rem; }
  td .row-actions { min-width: 14rem; }
}
@media (prefers-reduced-motion: reduce) { button:active { transform: none; } }

/* Overview location choices stay tucked behind the compact Filter control. */
.overview-location-filter { margin: 1rem 0 1.5rem; }
.overview-location-filter summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: fit-content;
  max-width: 100%;
  padding: 0;
  list-style: none;
}
.overview-location-filter summary::-webkit-details-marker { display: none; }
.location-filter-toggle {
  flex: none;
  padding: 0.625rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 0.25rem;
  background: var(--accent);
  color: #fff;
}
.overview-location-filter fieldset { margin: 1rem 0 0; padding: 1rem; border-radius: var(--radius); }
.overview-location-filter .summary-grid { gap: 0.25rem 1rem; }
@media print { .site-header, .site-footer, .skip-link, form, .confirm-action { display: none; } main { max-width: none; padding: 0; } .table-wrap { overflow: visible; } }

/* Canonical-fact values (facts.html): wrap long JSON instead of widening the page. */
pre.fact-value { max-width: 100%; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Overview pattern trends (partials/pattern_trends.html, pattern-trends.js). SVG is styled
   here, not by attributes, because the CSP allows no inline style. */
#pattern-trends { scroll-margin-top: 1rem; }
.trend-method { max-width: 75ch; }
.trend-controls { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; margin: 1rem 0 1.5rem; }
.trend-theme { flex: 1 1 14rem; max-width: 24rem; }
.trend-theme label { margin-top: 0; }
.trend-seg { display: inline-flex; flex-wrap: wrap; }
.trend-seg button { background: var(--bg); color: var(--accent); border-radius: 0; margin: 0; }
.trend-seg button + button { border-left-width: 0; }
.trend-seg button:first-child { border-radius: 0.25rem 0 0 0.25rem; }
.trend-seg button:last-child { border-radius: 0 0.25rem 0.25rem 0; }
.trend-seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.trend-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; margin-bottom: 0.75rem; }
/* A client viewer has no Trend card (VD-068): three columns, not a gap. */
.trend-kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.trend-kpi, .trend-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.trend-kpi p { margin: 0; }
.trend-kpi-label, .trend-kpi-note, .trend-span, .trend-readout, .trend-mini-meta, .wm-kicker, .wm-meta { color: var(--muted); font-size: 0.875rem; }
.trend-kpi-value { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.trend-badge { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.1rem 0.5rem; border: 1px solid currentColor; border-radius: 999px; font-size: 0.875rem; font-weight: 600; white-space: nowrap; }
.trend-kpi { min-width: 0; }
.trend-kpi-value .trend-badge { max-width: 100%; font-size: 1rem; white-space: normal; }
.trend-bad { color: var(--trend-bad); }
.trend-good { color: var(--trend-good); }
.trend-flat, .trend-few { color: var(--muted); }
.trend-chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.75rem; }
.trend-chart-head h3 { margin: 0; }
.trend-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; font-size: 0.875rem; }
.trend-swatch { display: inline-block; width: 1rem; height: 0; margin-right: 0.375rem; vertical-align: middle; border-top: 2px solid var(--trend-line); }
.trend-swatch-fit { border-top: 2px dashed var(--trend-fit); }
.trend-span { margin: 0.5rem 0 0; }
.trend-readout { margin: 0.25rem 0 0; min-height: 1.5em; font-variant-numeric: tabular-nums; }
.trend-chart { margin-top: 0.5rem; border-radius: 0.25rem; touch-action: pan-y; }
.trend-chart svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.trend-axis text { fill: var(--muted); font-size: 12px; }
.trend-gridline { stroke: var(--trend-grid); stroke-width: 1; }
.trend-area { fill: var(--trend-area); }
.trend-series { fill: none; stroke: var(--trend-line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.trend-fit { stroke: var(--trend-fit); stroke-width: 2; stroke-dasharray: 6 5; vector-effect: non-scaling-stroke; }
.trend-cursor { stroke: var(--muted); stroke-width: 1; }
.trend-dot { fill: var(--trend-line); stroke: var(--bg); stroke-width: 2; }
.trend-hit { fill: transparent; cursor: crosshair; }
/* A month with findings opens its month page on click. */
.trend-hit.trend-hit-link { cursor: pointer; }
.trend-table { margin-top: 0.75rem; }
.trend-table th[scope=row] { font-weight: 400; background: none; }
.trend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.75rem; }
.trend-mini { display: flex; flex-direction: column; gap: 0.5rem; }
.trend-mini-select { display: flex; flex-direction: column; align-items: stretch; gap: 0.25rem; width: 100%; padding: 0.75rem; text-align: left; font-weight: 400; background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: var(--radius); }
.trend-mini-select[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
/* The badge wraps under a long theme name rather than splitting the name mid-word. */
.trend-mini-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.25rem 0.5rem; }
.trend-mini-name { font-weight: 650; overflow-wrap: normal; }
.trend-spark { display: block; width: 100%; height: 2.75rem; }
.trend-mini-foot { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; }
.trend-small-button { flex: none; min-height: 2rem; padding: 0.25rem 0.75rem; background: var(--bg); color: var(--accent); border-radius: 999px; font-size: 0.875rem; white-space: nowrap; overflow-wrap: normal; }
/* The chart's Narratives link, drawn like the Word map button beside it (a button's border is the accent). */
a.trend-small-button { display: inline-flex; align-items: center; border: 1px solid; font-weight: 600; text-decoration: none; }
a.trend-small-button:hover { text-decoration: underline; }
dialog.wm-drawer { margin: 0 0 0 auto; width: min(34rem, 100%); max-width: 100%; height: 100%; max-height: 100%; padding: 1.25rem 1.25rem 2rem; border: 0; border-left: 1px solid var(--border); background: var(--bg); color: var(--fg); overflow-y: auto; }
dialog.wm-drawer::backdrop { background: rgba(16, 20, 24, 0.35); }
.wm-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.wm-head h2 { margin: 0.25rem 0 0; }
.wm-kicker { margin: 0; }
.wm-note { font-size: 0.9rem; }
.wm-legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; padding: 0; margin: 0 0 0.75rem; list-style: none; font-size: 0.875rem; }
.wm-legend-dot { display: inline-block; width: 0.625rem; height: 0.625rem; margin-right: 0.375rem; border-radius: 50%; background: var(--muted); }
.wm-legend-dot.wm-rising { background: var(--trend-fit); }
.wm-cloud { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0.25rem 0.75rem; min-height: 10rem; padding: 1rem 0.5rem; border: 1px solid var(--trend-grid); border-radius: var(--radius); }
.wm-cloud button { min-height: 1.5rem; padding: 0.125rem 0.25rem; border: 0; border-radius: 0.25rem; background: none; color: var(--muted); font-weight: 450; line-height: 1.1; }
.wm-cloud button.wm-rising { color: var(--trend-fit); }
.wm-cloud button:hover, .wm-cloud button[aria-pressed="true"] { background: var(--trend-area); color: var(--fg); filter: none; }
.wm-cloud button[aria-pressed="true"] { outline: 2px solid var(--accent); }
.wm-size-1 { font-size: 0.8125rem; }
.wm-size-2 { font-size: 0.9375rem; }
.wm-size-3 { font-size: 1.125rem; font-weight: 550; }
.wm-size-4 { font-size: 1.375rem; font-weight: 550; }
.wm-size-5 { font-size: 1.625rem; font-weight: 650; }
.wm-size-6 { font-size: 1.875rem; font-weight: 650; }
.wm-term h3 { margin-top: 1.25rem; }
.wm-term h4 { margin: 1rem 0 0.5rem; font-size: 1rem; }
.wm-row { margin: 0.25rem 0; }
.wm-quote { margin: 0.5rem 0; padding: 0.25rem 0.75rem; border-left: 3px solid var(--border); }
.wm-quote p { margin: 0.25rem 0; }
.wm-quote mark { background: var(--trend-mark); color: var(--fg); padding: 0 0.125rem; }
.wm-narratives { padding-left: 1.25rem; }
/* Month page (pattern_month.html). */
.month-steps { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1.5rem; margin: 1rem 0; }
.month-findings td { vertical-align: top; }
.month-excerpt { margin: 0.25rem 0 0; font-size: 0.9rem; }
@media (max-width: 720px) { .trend-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .trend-theme { max-width: none; } }
@media print { .trends-app [data-wm-current], .trend-small-button, dialog.wm-drawer { display: none; } }
