/* Global Opportunity Intelligence - shared styles.
   Colours are role tokens; the dark values are selected steps, not an automatic flip. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f1f0ec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6b6965;
  --hairline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-strong: #1c5cab;
  --accent-wash: #e9f2fd;
  --track: #cde2fb;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --info: #2a78d6;
  --neutral: #898781;
  --tone-mix: var(--ink);
  --radius: 10px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 6px 20px rgba(11, 11, 11, 0.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242422;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #a3a199;
    --hairline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-strong: #86b6ef;
    --accent-wash: #132a47;
    --track: #123c6e;
    --info: #3987e5;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #242422;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #a3a199;
  --hairline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --accent-strong: #86b6ef;
  --accent-wash: #132a47;
  --track: #123c6e;
  --info: #3987e5;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.35);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 var(--font);
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; }
a { color: var(--accent-strong); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.icon { width: 16px; height: 16px; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------ page chrome */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}
.site-header .inner {
  max-width: 1240px; margin: 0 auto; padding: 10px 24px;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 650; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 700; letter-spacing: 0.02em;
}
.site-nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.site-nav a {
  padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-weight: 550;
}
.site-nav a:hover { background: var(--surface-2); color: var(--ink); }
.site-nav a[aria-current="page"] { background: var(--accent-wash); color: var(--accent-strong); }
.theme-toggle {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  display: grid; place-items: center; cursor: pointer;
}
.theme-toggle:hover { background: var(--surface-2); }
main { max-width: 1240px; margin: 0 auto; padding: 28px 24px 64px; }
.page-title { font-size: 26px; line-height: 1.2; font-weight: 680; letter-spacing: -0.01em; }
.page-lede { color: var(--ink-2); max-width: 70ch; margin-top: 6px; }
.site-footer { max-width: 1240px; margin: 0 auto; padding: 24px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--hairline); }
.site-footer p + p { margin-top: 4px; }

/* ------------------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 14px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
:root[data-theme="dark"] .btn.primary { background: var(--accent); border-color: var(--accent); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn.primary { background: var(--accent); border-color: var(--accent); }
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.small { min-height: 30px; padding: 3px 10px; font-size: 13px; }
.linklike {
  border: 0; background: none; padding: 0; text-align: left; cursor: pointer; color: inherit; font: inherit;
}
.linklike:hover { text-decoration: underline; text-underline-offset: 2px; }
.field { display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.field select, .field input, .search input {
  min-height: 38px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 400; width: 100%;
}
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); padding: 2px; flex-wrap: wrap; }
.segmented button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.segmented button:hover { background: var(--surface-2); }
.segmented button[aria-pressed="true"] { background: var(--accent-wash); color: var(--accent-strong); }
.filter-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 20px 0 4px; }
.filter-label { font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* ------------------------------------------------------------ badges, chips, meters */
.badge, .chip, .tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; line-height: 1.2;
  border-radius: 999px; padding: 4px 9px; white-space: nowrap;
}
.badge { background: color-mix(in srgb, var(--tone) 13%, var(--surface)); color: var(--ink); border: 1px solid color-mix(in srgb, var(--tone) 30%, var(--surface)); }
.badge .icon { color: color-mix(in srgb, var(--tone) 72%, var(--tone-mix)); width: 14px; height: 14px; }
.badge.quiet { background: transparent; border-color: var(--border); color: var(--ink-2); font-weight: 550; }
.tone-good { --tone: var(--good); }
.tone-warning { --tone: var(--warning); }
.tone-serious { --tone: var(--serious); }
.tone-critical { --tone: var(--critical); }
.tone-info { --tone: var(--info); }
.tone-muted { --tone: var(--neutral); }
.chip { background: var(--surface-2); color: var(--ink); border: 1px solid transparent; }
.chip.removable { cursor: pointer; border-color: var(--border); background: var(--surface); }
.chip.removable:hover { background: var(--surface-2); }
.chip.removable .icon { width: 12px; height: 12px; color: var(--muted); }
.tag { background: var(--accent-wash); color: var(--accent-strong); padding: 3px 8px; font-size: 12px; }
.tag-soft { background: var(--surface-2); color: var(--ink-2); }
.tag-archive { background: var(--surface-2); color: var(--muted); }
.meter { display: inline-flex; gap: 2px; vertical-align: middle; }
.meter span { width: 9px; height: 9px; border-radius: 2px; background: var(--track); }
.meter span.on { background: var(--accent); }
.left { margin-left: 8px; font-weight: 650; }

/* ------------------------------------------------------------ dashboard */
.hero { margin-top: 18px; }
.hero-figure { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.hero-value { font-size: 64px; line-height: 1; font-weight: 700; letter-spacing: -0.03em; }
.hero-label { font-size: 18px; font-weight: 600; }
.hero-label .muted { font-weight: 400; }
.hero p { margin-top: 8px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 22px; }
.tile {
  display: grid; gap: 2px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); text-decoration: none; color: var(--ink);
}
.tile:hover { border-color: var(--accent); }
.tile-label { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.tile-value { font-size: 30px; line-height: 1.15; font-weight: 680; letter-spacing: -0.02em; }
.tile-hint { font-size: 12px; color: var(--muted); }
.columns { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 20px; margin-top: 28px; align-items: start; }
.stack { display: grid; gap: 20px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.panel > h2, .panel-head h2 { font-size: 17px; font-weight: 660; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.panel-sub { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.queue { list-style: none; counter-reset: q; display: grid; }
.queue > li {
  counter-increment: q; display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 4px 12px;
  padding: 14px 0; border-top: 1px solid var(--hairline); align-items: start;
}
.queue > li:first-child { border-top: 0; padding-top: 4px; }
.queue > li::before {
  content: counter(q); width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2);
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--ink-2); margin-top: 1px;
}
.queue-title { font-weight: 650; font-size: 15.5px; }
.queue-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 6px; font-size: 13px; }
.queue-deadline { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.queue-action { margin-top: 6px; color: var(--ink-2); font-size: 14px; }
.queue-buttons { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.monitor { list-style: none; display: grid; }
.monitor > li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 9px 0; border-top: 1px solid var(--hairline); }
.monitor > li:first-child { border-top: 0; }
.monitor-label { font-weight: 600; }
.monitor-count { font-weight: 700; font-variant-numeric: tabular-nums; }
.monitor > li.empty { color: var(--muted); }
.monitor > li.empty .monitor-label, .monitor > li.empty .monitor-count { font-weight: 500; }
.monitor ul { grid-column: 1 / -1; list-style: none; display: grid; gap: 3px; font-size: 13.5px; }
.lead-list { list-style: none; display: grid; gap: 10px; }
.lead-list li { display: grid; gap: 1px; }
.lead-list a { font-weight: 550; text-decoration: none; }
.lead-list a:hover { text-decoration: underline; }
.more { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; margin-top: 12px; text-decoration: none; }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 20px; }
.section-title { font-size: 19px; font-weight: 670; margin-top: 36px; }

/* charts: thin single-hue bars, square at the baseline, rounded data end */
.viz figcaption { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 12px; }
.viz h3 { font-size: 15.5px; font-weight: 650; }
.bars { display: grid; gap: 2px; }
.bar-row {
  display: grid; grid-template-columns: minmax(110px, 40%) minmax(0, 1fr) 30px; align-items: center; gap: 10px;
  padding: 5px 6px; margin: 0 -6px; border-radius: 6px; text-decoration: none; color: var(--ink);
}
.bar-row:hover, .bar-row:focus-visible { background: var(--surface-2); }
.bar-row:hover .bar, .bar-row:focus-visible .bar { filter: brightness(1.15); }
.bar-label { font-size: 13.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { border-left: 1px solid var(--baseline); height: 20px; display: flex; align-items: center; }
.bar { display: block; height: 14px; min-width: 3px; background: var(--accent); border-radius: 0 4px 4px 0; }
.bar-value { font-size: 13.5px; font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.viz-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.viz-table th, .viz-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--hairline); font-weight: 400; }
.viz-table thead th { font-weight: 650; color: var(--ink-2); font-size: 12.5px; }
.viz-table td { font-variant-numeric: tabular-nums; }
.viz-tip {
  position: absolute; z-index: 50; pointer-events: none; background: var(--ink); color: var(--page);
  padding: 6px 10px; border-radius: 7px; font-size: 12.5px; display: grid; gap: 1px; max-width: 260px; box-shadow: var(--shadow);
}
.viz-tip strong { font-size: 13.5px; }

/* ------------------------------------------------------------ notices */
.notice {
  display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 10px; padding: 12px 14px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--tone) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--tone) 32%, var(--surface));
}
.notice > .icon { width: 18px; height: 18px; margin-top: 2px; color: color-mix(in srgb, var(--tone) 72%, var(--tone-mix)); }
.notice p + p, .notice strong + p, .notice strong + ul { margin-top: 3px; }
.notice strong { display: block; }
details.method { margin-top: 20px; }
details.method summary { cursor: pointer; font-weight: 650; font-size: 16px; }
details.method .method-body { margin-top: 14px; display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.method-body h3 { font-size: 14px; font-weight: 650; margin-bottom: 6px; }
.method-body ul { list-style: none; display: grid; gap: 6px; font-size: 13.5px; color: var(--ink-2); }
.method-body li { display: grid; gap: 3px; justify-items: start; }

/* ------------------------------------------------------------ explorer */
.toolbar { display: grid; grid-template-columns: minmax(0, 1fr) 220px auto; gap: 12px; align-items: end; margin-top: 20px; }
.search { position: relative; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 34px; min-height: 42px; font-size: 15px; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; font-weight: 550; color: var(--ink-2); font-size: 14px; }
details.filters { margin-top: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 12px 16px; }
details.filters summary { cursor: pointer; font-weight: 650; }
details.filters[open] summary { margin-bottom: 12px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.results-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 16px 0 12px; }
.results-bar #count { color: var(--ink-2); font-weight: 600; margin-right: 6px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 16px; }
.card {
  display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--surface)); box-shadow: var(--shadow); }
.card.archived { opacity: 0.78; }
.card-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.card-title { font-size: 16.5px; line-height: 1.3; font-weight: 660; }
.card-org { color: var(--ink-2); font-size: 13.5px; margin-top: -6px; }
.facts { display: grid; gap: 7px; font-size: 13.5px; padding: 10px 0; border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline); }
.facts > div { display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: 8px; align-items: center; }
.facts dt { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.facts dd { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.facts dd .icon { color: var(--muted); width: 14px; height: 14px; }
.facts .chip { padding: 2px 0; background: none; font-size: 13.5px; font-weight: 500; }
.card-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.card-foot { margin-top: auto; padding-top: 4px; }
.card-foot .btn { width: 100%; justify-content: center; }
.empty-state { grid-column: 1 / -1; padding: 48px 20px; text-align: center; border: 1px dashed var(--baseline); border-radius: var(--radius); }

/* ------------------------------------------------------------ detail dialog */
.detail-dialog {
  width: min(900px, 96vw); max-height: 92vh; padding: 0; border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); color: var(--ink); box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35); overflow: hidden;
}
.detail-dialog[open] { display: flex; flex-direction: column; }
.detail-dialog::backdrop { background: rgba(11, 11, 11, 0.55); }
.dialog-bar { display: flex; justify-content: flex-end; padding: 8px 10px; border-bottom: 1px solid var(--hairline); flex: none; }
.dialog-body { overflow-y: auto; padding: 22px 28px 32px; }
.detail { display: grid; gap: 22px; }
.d-head { display: grid; gap: 10px; }
.d-head h2 { font-size: 24px; line-height: 1.2; font-weight: 690; letter-spacing: -0.01em; }
.d-org { color: var(--ink-2); margin-top: -4px; }
.d-keyfacts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 20px; padding: 14px 0; border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline); }
.d-keyfacts dt, .facts-inline dt, .relevance dt { font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.d-keyfacts dd { font-weight: 550; margin-top: 2px; }
.d-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.d-section { display: grid; gap: 10px; }
.d-section > h3 { font-size: 16px; font-weight: 670; padding-bottom: 6px; border-bottom: 1px solid var(--hairline); }
.d-section h4 { font-size: 13.5px; font-weight: 650; margin-bottom: 4px; }
.plain-list { padding-left: 20px; display: grid; gap: 5px; }
.plain-list.sources { list-style: none; padding-left: 0; }
.plain-list.sources li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.facts-inline { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 20px; }
.facts-inline dd { margin-top: 2px; }
.coverage { width: 100%; border-collapse: collapse; font-size: 14px; }
.coverage th, .coverage td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--hairline); font-weight: 400; }
.coverage thead th { font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.cov { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.cov .icon { color: color-mix(in srgb, var(--tone) 72%, var(--tone-mix)); }
.relevance { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 18px; }
.relevance dd { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-top: 3px; }

/* ------------------------------------------------------------ leads */
.lead-table { list-style: none; display: grid; }
.lead-table li { display: flex; justify-content: space-between; gap: 14px; align-items: start; padding: 13px 0; border-top: 1px solid var(--hairline); }
.lead-table li:first-child { border-top: 0; }
.lead-main a { font-weight: 600; text-decoration: none; display: inline-flex; gap: 6px; align-items: baseline; }
.lead-main a:hover { text-decoration: underline; }
.lead-main a .icon { width: 13px; height: 13px; color: var(--muted); align-self: center; }
.lead-main p { margin-top: 3px; }
.lead-tools { display: grid; grid-template-columns: minmax(0, 1fr) 180px 220px; gap: 12px; align-items: end; margin: 20px 0 8px; }

/* ------------------------------------------------------------ small screens */
@media (max-width: 900px) {
  .columns, .charts { grid-template-columns: minmax(0, 1fr); }
  .toolbar, .lead-tools { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .site-header .inner { padding: 10px 16px; gap: 10px; }
  .site-nav { margin-left: 0; order: 3; width: 100%; }
  .theme-toggle { margin-left: auto; }
  main { padding: 20px 16px 48px; }
  .hero-value { font-size: 52px; }
  .page-title { font-size: 22px; }
  .queue > li { grid-template-columns: 28px minmax(0, 1fr); }
  .queue-buttons { grid-column: 2; justify-content: flex-start; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .detail-dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; border: 0; margin: 0; }
  .dialog-body { padding: 18px 16px 28px; }
  .d-head h2 { font-size: 20px; }
  .lead-table li { flex-direction: column; gap: 8px; }
  .bar-row { grid-template-columns: minmax(84px, 40%) minmax(0, 1fr) 26px; }
}
@media (prefers-reduced-motion: no-preference) {
  .card, .tile, .btn { transition: border-color 0.15s, box-shadow 0.15s, background 0.15s; }
}
@media print {
  .site-header, .toolbar, details.filters, .card-foot, .theme-toggle { display: none; }
  body { background: #fff; }
}

#flags { display: grid; gap: 12px; }
#flags:empty { display: none; }
