/* ============================================================
   Maine Gov 2026 Ad Tracker — SBMedia branded dashboard
   ============================================================ */

:root {
  /* SBMedia brand palette */
  --delft-blue:    #223555;  /* Primary brand color */
  --lapis-lazuli:  #296598;  /* Secondary brand color */
  --anti-flash:    #EFF1F3;  /* Brand neutral / app background */
  --jet-black:     #313131;  /* Brand body text (not pure black) */

  /* Tints & shades derived from brand */
  --delft-80:      #4e5d77;  /* Delft Blue at 80% saturation */
  --delft-60:      #7a8497;  /* Delft Blue at 60% */
  --delft-40:      #a7adb9;  /* Delft Blue at 40% */
  --delft-20:      #d3d6dc;  /* Delft Blue at 20% */
  --lapis-80:      #5483ad;  /* Lapis at 80% */
  --lapis-20:      #d4e0eb;  /* Lapis at 20% — soft tint for backgrounds */

  /* Semantic aliases — used throughout the CSS so brand swaps are easy */
  --paper:         #ffffff;            /* Card/surface background */
  --cream:         var(--anti-flash);  /* App background (renamed but kept for legacy class names) */
  --cream-warm:    #e3e6eb;            /* Slightly deeper accent on app bg */
  --ink:           var(--jet-black);   /* Body text */
  --ink-soft:      #4f5360;            /* De-emphasized text */
  --ink-muted:     #7a7f8a;            /* Muted labels */
  --rule:          #d0d4dc;            /* Hairline dividers */
  --rule-soft:     #e1e4ea;            /* Softer dividers */

  /* Accents — re-mapped to brand */
  --navy:          var(--delft-blue);
  --crimson:       var(--lapis-lazuli); /* Was crimson; now lapis blue as primary accent */
  --gold:          #c4923f;             /* Kept for filter pill state contrast */
  --sage:          #5a7a4b;             /* Kept; used elsewhere subtly */

  /* Sources */
  --meta-blue:     #1877f2;
  --google-tan:    #8a6a3b;

  /* Type — Red Hat Display per brand guide */
  --serif:         'Source Serif Pro', Georgia, serif;       /* Accent/eyebrow only */
  --sans:          'Red Hat Display', system-ui, sans-serif; /* Headers + body */
  --mono:          'IBM Plex Mono', monospace;               /* Tabular/numeric */

  --radius: 4px;
  --shadow-sm: 0 1px 2px rgba(34, 53, 85, 0.06);
  --shadow-md: 0 2px 8px rgba(34, 53, 85, 0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--anti-flash);
  color: var(--jet-black);
  font-family: var(--sans);
  font-weight: 500;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--lapis-lazuli); text-decoration: none; }
a:hover { color: var(--delft-blue); }

h1, h2, h3, h4 {
  font-family: var(--sans);
  font-weight: 900;
  letter-spacing: -0.015em;
  color: var(--delft-blue);
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(41, 101, 152, 0.06), transparent 60%),
    radial-gradient(circle at 80% 80%, rgba(34, 53, 85, 0.06), transparent 60%),
    var(--anti-flash);
}
.login-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 56px 48px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-md);
}
.login-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--crimson);
  margin-bottom: 16px;
}
.login-title {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 38px;
  line-height: 1.05;
  margin: 0 0 12px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.login-title em { font-style: italic; color: var(--crimson); font-weight: 400; }
.login-desc {
  color: var(--ink-muted);
  margin: 0 0 32px;
  font-size: 14px;
}
.login-card form { display: flex; gap: 8px; }
.login-card input[type="password"] {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  background: var(--cream);
  font-family: var(--sans);
  font-size: 15px;
  border-radius: var(--radius);
}
.login-card input:focus {
  outline: none;
  border-color: var(--navy);
  background: var(--paper);
}
.login-card button {
  padding: 12px 22px;
  background: var(--navy);
  color: var(--paper);
  border: none;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.02em;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 0.15s ease;
}
.login-card button:hover { background: var(--crimson); }
.login-error { color: var(--crimson); margin-top: 14px; font-size: 13px; }

/* ============================================================
   MASTHEAD
   ============================================================ */
.masthead {
  background: var(--paper);
  border-bottom: 3px solid var(--delft-blue);
  padding: 32px 40px 26px;
}
.masthead.small { padding: 18px 40px; }
.masthead-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}
.masthead-left {
  display: flex;
  align-items: center;
  gap: 20px;
}
.masthead-logo {
  height: 38px;
  width: auto;
  flex-shrink: 0;
}
.masthead-logo-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--delft-blue);
  color: var(--paper);
  font-family: var(--sans);
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 0.02em;
  border-radius: 4px;
  flex-shrink: 0;
}
.masthead-rule {
  width: 1px;
  height: 36px;
  background: var(--rule);
  flex-shrink: 0;
}
.masthead-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--lapis-lazuli);
  margin-bottom: 8px;
  font-weight: 500;
}
.masthead-title {
  font-family: var(--sans);
  font-weight: 900;
  font-size: 36px;
  line-height: 1.05;
  margin: 0;
  letter-spacing: -0.02em;
  color: var(--delft-blue);
}
.masthead-title span {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  color: var(--ink-muted);
  letter-spacing: -0.01em;
}
.masthead-right {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-shrink: 0;
}
.pull-status {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-muted);
  text-align: right;
}
.pull-line { display: flex; gap: 12px; justify-content: flex-end; }
.pull-label { color: var(--ink); font-weight: 500; min-width: 50px; }
.pull-time.muted { opacity: 0.5; font-style: italic; }
.logout-link {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.back-link {
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
}

/* ============================================================
   ENTITY COLOR PALETTE
   Refreshed for SBMedia brand: colors sit clean against white,
   each distinct from Delft Blue / Lapis Lazuli so brand colors
   remain dominant. Each entity gets a hue applied to:
   - left border accent on ad cards
   - dot before entity name (everywhere)
   - top border on entity strip cards
   - left border on spend rows
   ============================================================ */
.entity-hannah-pingree         { --entity-color: #0d7378; }  /* deep teal */
.entity-mcv-action-fund        { --entity-color: #4a7d3e; }  /* forest green */
.entity-angus-king             { --entity-color: #1e4f99; }  /* cobalt — sits beside brand blues */
.entity-shenna-bellows         { --entity-color: #803668; }  /* plum */
.entity-nirav-shah             { --entity-color: #c95a1a; }  /* burnt orange */
.entity-troy-jackson           { --entity-color: #b08020; }  /* mustard */
.entity-maine-peoples-alliance { --entity-color: #a02e2e; }  /* brick red */

.entity-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--entity-color, var(--ink-muted));
  margin-right: 8px;
  vertical-align: 1px;
  flex-shrink: 0;
}

/* Ad cards: left border accent in entity color */
.ad-card {
  border-left: 4px solid var(--entity-color, var(--rule));
}
.ad-card .ad-card-name {
  color: var(--entity-color, var(--ink));
}

/* Entity strip: top border accent in entity color */
.entity-card {
  border-top: 3px solid var(--entity-color, var(--rule));
}
.entity-card.is-active {
  background: color-mix(in srgb, var(--entity-color) 8%, var(--paper));
  border-color: var(--entity-color, var(--ink));
}

/* Spend snapshot rows: left accent + colored name */
.spend-row {
  border-left: 3px solid var(--entity-color, transparent);
  padding-left: 12px;
}
.spend-row-name a {
  color: var(--entity-color, var(--ink));
}

/* Ad detail page: header accent in entity color */
.ad-detail {
  border-top: 4px solid var(--entity-color, var(--rule));
}
.ad-detail .ad-detail-eyebrow {
  color: var(--entity-color, var(--ink-muted));
}
.cycle-bar {
  background: var(--ink);
  color: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.cycle-bar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.cycle-label { color: rgba(247, 243, 236, 0.85); }
.cycle-label strong { color: var(--paper); font-weight: 600; }
.cycle-label.cycle-all strong { color: var(--gold); }
.cycle-toggle {
  color: var(--gold);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.cycle-toggle:hover { color: var(--paper); }
@media (max-width: 700px) {
  .cycle-bar-inner { flex-direction: column; align-items: flex-start; gap: 6px; }
}

/* ============================================================
   STATS STRIP
   ============================================================ */
.stats-strip {
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 40px 8px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--rule);
}
.stat {
  padding: 14px 28px 32px 0;
  border-right: 1px solid var(--rule-soft);
}
.stat:last-child { border-right: none; padding-right: 0; }
.stat-value {
  font-family: var(--sans);
  font-weight: 900;
  font-size: 48px;
  line-height: 1;
  color: var(--delft-blue);
  letter-spacing: -0.025em;
}
.stat.accent .stat-value { color: var(--lapis-lazuli); }
.stat-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-muted);
  margin-top: 10px;
  font-weight: 500;
}

/* ============================================================
   SPEND SNAPSHOT
   ============================================================ */
.spend-snapshot {
  max-width: 1400px;
  margin: 0 auto;
  padding: 36px 40px 32px;
  border-bottom: 1px solid var(--rule);
}
.spend-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 20px;
}
.spend-snapshot h2 {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 22px;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.spend-snapshot h2 .by-platform {
  font-style: italic;
  color: var(--ink-muted);
  font-weight: 400;
}
.spend-caveat {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin: 0;
}
.spend-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-end;
}
.spend-toggle-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.toggle-group-label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-muted);
  font-weight: 500;
}
.spend-source-toggle {
  display: flex;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}
.spend-toggle-pill {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 500;
  padding: 7px 14px;
  color: var(--ink-muted);
  border-right: 1px solid var(--rule);
  transition: all 0.15s ease;
}
.spend-toggle-pill:last-child { border-right: none; }
.spend-toggle-pill:hover { background: var(--anti-flash); color: var(--delft-blue); }
.spend-toggle-pill.is-active {
  background: var(--delft-blue);
  color: var(--paper);
}
.spend-toggle-pill.is-active.meta { background: var(--meta-blue); }
.spend-toggle-pill.is-active.google { background: var(--google-tan); }
.spend-legend {
  display: flex;
  gap: 18px;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  font-weight: 500;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 1px;
}
.swatch.meta { background: var(--meta-blue); }
.swatch.google { background: var(--google-tan); }

.spend-rows {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.spend-row {
  display: grid;
  grid-template-columns: 230px 1fr 280px;
  align-items: center;
  gap: 20px;
  padding: 26px 0 26px 24px;
  border-bottom: 1px solid var(--rule-soft);
}
.spend-row:last-child { border-bottom: none; }

.spend-row-name a {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 15px;
  color: var(--delft-blue);
  line-height: 1.3;
  display: block;
}
.spend-row-name a:hover { color: var(--lapis-lazuli); }
.spend-row-type {
  display: inline-block;
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  margin-top: 8px;
  font-weight: 500;
}
.spend-row-type.type-outside_group { color: var(--gold); }

.spend-row-bar-wrap { width: 100%; }
.spend-bar-track {
  width: 100%;
  height: 18px;
  background: var(--cream-warm);
  border-radius: 2px;
  display: flex;
  overflow: hidden;
}
.bar-segment {
  height: 100%;
  display: block;
  transition: opacity 0.15s ease;
}
.bar-segment:hover { opacity: 0.8; }
.bar-segment.meta {
  background: var(--meta-blue);
}
.bar-segment.google {
  background: var(--google-tan);
}

.spend-row-numbers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px 12px;
  font-family: var(--mono);
  font-size: 11px;
}
.num-line {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.num-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
}
.meta-line .num-label { color: var(--meta-blue); }
.google-line .num-label { color: var(--google-tan); }
.num-val {
  color: var(--ink);
  font-weight: 500;
}
.num-val.total {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
}

.spend-totals-row {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 2px solid var(--ink);
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
}
.overall-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--crimson);
  font-weight: 600;
}
.overall-meta, .overall-google {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.overall-total {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  margin-left: auto;
}

@media (max-width: 800px) {
  .spend-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 14px 0;
  }
  .spend-row-numbers {
    grid-template-columns: repeat(3, 1fr);
  }
  .spend-totals-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .overall-total { margin-left: 0; }
}

/* ============================================================
   ENTITY STRIP
   ============================================================ */
.entity-strip {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 40px;
  display: flex;
  gap: 24px;
  align-items: flex-start;
  border-bottom: 1px solid var(--rule);
}
.entity-strip-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-muted);
  padding-top: 14px;
  flex-shrink: 0;
  font-weight: 500;
}
.entity-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1px;
  background: var(--rule-soft);
  flex: 1;
  border: 1px solid var(--rule-soft);
}
.entity-card {
  padding: 14px 16px;
  background: var(--paper);
  display: block;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
}
.entity-card:hover {
  background: var(--anti-flash);
  border-left-color: var(--lapis-lazuli);
}
.entity-card.is-active {
  background: var(--delft-blue);
  color: var(--paper);
  border-left-color: var(--lapis-lazuli);
}
.entity-card.is-active .entity-card-meta { color: rgba(239, 241, 243, 0.75); }
.entity-card.is-active .entity-card-name { color: var(--paper); }
.entity-card.type-outside_group { border-left-color: var(--gold); }
.entity-card.type-outside_group.is-active { border-left-color: var(--gold); }
.entity-card-name {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.25;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  color: var(--delft-blue);
}
.entity-card-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-muted);
  display: flex;
  gap: 6px;
  align-items: center;
}
.dot { opacity: 0.4; }
.new-pill { color: var(--lapis-lazuli); font-weight: 700; }
.entity-card.is-active .new-pill { color: #b4d4ee; }
.client-badge {
  background: var(--crimson);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  padding: 2px 6px;
  border-radius: 2px;
  font-weight: 500;
}
.client-badge.sm { font-size: 8px; padding: 1px 5px; }

/* ============================================================
   VIEW TABS / FILTERS
   ============================================================ */
.view-tabs {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 40px;
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  background: var(--anti-flash);
  z-index: 10;
}
.view-tabs-inner {
  display: flex;
  gap: 22px;
  align-items: center;
  flex-wrap: wrap;
}
.tab {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 14px;
  padding: 8px 0;
  color: var(--ink-muted);
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
}
.tab:hover { color: var(--delft-blue); }
.tab.is-active {
  color: var(--delft-blue);
  border-bottom-color: var(--lapis-lazuli);
}
.search-form {
  margin-left: auto;
  flex: 0 1 280px;
}
.search-form input {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--rule);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 13px;
  border-radius: var(--radius);
}
.search-form input:focus { outline: none; border-color: var(--lapis-lazuli); }
.source-filter { display: flex; gap: 6px; }
.src-pill {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 6px 12px;
  border: 1px solid var(--rule);
  background: var(--paper);
  border-radius: var(--radius);
  font-weight: 500;
}
.src-pill.is-active {
  background: var(--delft-blue);
  color: var(--paper);
  border-color: var(--delft-blue);
}
.clear-filters {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--lapis-lazuli);
  font-weight: 500;
}

/* ============================================================
   AD GRID
   ============================================================ */
.ad-grid {
  max-width: 1400px;
  margin: 0 auto;
  padding: 36px 40px 80px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 28px;
}
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--ink-muted);
}
.empty-state h3 {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 22px;
  margin: 0 0 8px;
  color: var(--ink);
}

.ad-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.ad-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.ad-card.is-client { border-color: var(--crimson); border-width: 1px 1px 1px 3px; }
.ad-card.src-meta { border-top: 3px solid var(--meta-blue); }
.ad-card.src-google { border-top: 3px solid var(--google-tan); }

.ad-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--rule-soft);
  background: var(--anti-flash);
}
.ad-card-entity {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ad-card-name {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 12px;
  color: var(--ink);
}
.ad-card-source {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
}
.ad-card-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.variation-badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 2px;
  letter-spacing: 0.04em;
}
.group-toggle {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 5px 10px;
  border: 1px solid var(--rule);
  background: var(--paper);
  border-radius: var(--radius);
  color: var(--ink-muted);
}
.group-toggle.is-grouped {
  color: var(--crimson);
  border-color: var(--crimson);
}
.group-toggle:hover { color: var(--ink); }

.status-toggle {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 5px 10px;
  border: 1px solid var(--rule);
  background: var(--paper);
  border-radius: var(--radius);
  color: var(--ink-muted);
}
.status-toggle.is-filtered {
  color: var(--gold);
  border-color: var(--gold);
}
.status-toggle:hover { color: var(--ink); }

.ad-preview {
  background: #fafaf6;
  position: relative;
  border-bottom: 1px solid var(--rule-soft);
}
.ad-preview.meta {
  min-height: 200px;
  background: linear-gradient(135deg, #1877f2 0%, #0d5ec9 100%);
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 28px 20px;
  transition: filter 0.15s ease;
}
.ad-preview.meta:hover {
  filter: brightness(1.08);
  color: white;
}
.meta-preview-icon {
  margin-bottom: 14px;
  opacity: 0.95;
}
.meta-preview-label {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 18px;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.meta-preview-sub {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.75;
}
.ad-preview.google {
  padding: 28px 16px;
  text-align: center;
  background: linear-gradient(135deg, #faf6ec, #f3ebd6);
}
.google-creative-type {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--google-tan);
  margin-bottom: 12px;
}
.google-link {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 15px;
}

.ad-card-title {
  padding: 16px 18px 8px;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 16px;
  line-height: 1.3;
  color: var(--delft-blue);
}
.ad-card-body {
  padding: 10px 18px 18px;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-soft);
  white-space: pre-wrap;
  max-height: 200px;
  overflow: hidden;
  position: relative;
  flex: 1;
}
.ad-card-body::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 36px;
  background: linear-gradient(to bottom, transparent, var(--paper));
  pointer-events: none;
}

.ad-card-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--rule-soft);
  background: var(--anti-flash);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}
.ad-card-meta { font-size: 11px; flex: 1; }
.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 1px 0;
}
.meta-label {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  font-size: 10px;
}
.meta-value {
  font-family: var(--mono);
  color: var(--ink);
  font-size: 11px;
}
.me-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sage);
  border: 1px solid var(--sage);
  padding: 2px 5px;
  border-radius: 2px;
  margin-top: 4px;
}
.ad-card-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.active { background: var(--sage); box-shadow: 0 0 0 3px rgba(90, 122, 75, 0.15); }
.status-dot.inactive { background: var(--ink-muted); opacity: 0.4; }
.detail-link {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--navy);
}

/* ============================================================
   AD DETAIL
   ============================================================ */
.ad-detail {
  max-width: 1100px;
  margin: 32px auto 80px;
  padding: 0 36px;
}
.ad-detail-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--crimson);
  margin-bottom: 8px;
}
.ad-detail h1 {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 32px;
  margin: 0 0 32px;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.ad-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 40px;
  align-items: flex-start;
}
.detail-preview iframe {
  width: 100%;
  min-height: 600px;
  border: 1px solid var(--rule);
  background: var(--paper);
}
.detail-meta-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 60px 24px;
  background: linear-gradient(135deg, #1877f2 0%, #0d5ec9 100%);
  color: white;
  text-decoration: none;
  border-radius: var(--radius);
  transition: filter 0.15s ease;
}
.detail-meta-link:hover {
  filter: brightness(1.08);
  color: white;
}
.detail-meta-link svg { margin-bottom: 8px; }
.detail-meta-link span {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 22px;
}
.detail-meta-link small {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.8;
}
.detail-body { margin-top: 28px; }
.detail-body h3, .detail-link-block h3, .ad-detail-side h3 {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-muted);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}
.detail-body-text {
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
}
.detail-link-block { margin-top: 28px; }
.link-url {
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
}
.ad-detail-side dl {
  margin: 0;
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px 12px;
  font-size: 13px;
}
.ad-detail-side dt {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  padding-top: 2px;
}
.ad-detail-side dd { margin: 0; color: var(--ink); }
.mono { font-family: var(--mono); font-size: 11px; color: var(--ink-muted); }
.raw-json {
  margin-top: 48px;
  border-top: 1px solid var(--rule);
  padding-top: 20px;
}
.raw-json summary {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-muted);
  cursor: pointer;
}
.raw-json pre {
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 11px;
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 16px;
  overflow: auto;
  max-height: 400px;
  border-radius: var(--radius);
}

/* ============================================================
   FOOTER
   ============================================================ */
.page-footer {
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 36px;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  display: flex;
  gap: 12px;
}
.footer-sep { opacity: 0.4; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .stats-strip { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(2) { border-right: none; }
  .masthead-inner { flex-direction: column; align-items: flex-start; }
  .masthead-right { align-self: flex-end; }
  .ad-detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .masthead, .stats-strip, .entity-strip, .view-tabs, .ad-grid, .ad-detail, .page-footer {
    padding-left: 18px;
    padding-right: 18px;
  }
  .masthead-title { font-size: 30px; }
  .ad-grid { grid-template-columns: 1fr; }
  .view-tabs-inner { gap: 12px; }
  .search-form { flex: 1 1 100%; order: 99; }
}

/* ============================================================
   WEEKLY HEATMAP
   ============================================================ */
.weekly-heatmap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 36px 40px 32px;
  border-bottom: 1px solid var(--rule);
}
.heatmap-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 24px;
}
.heatmap-header h2 {
  font-family: var(--sans);
  font-weight: 900;
  font-size: 22px;
  margin: 0 0 6px;
  color: var(--delft-blue);
  letter-spacing: -0.015em;
}
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  font-weight: 500;
}
.heatmap-legend-bar {
  display: flex;
  gap: 1px;
}
.heatmap-legend-bar span {
  display: inline-block;
  width: 18px;
  height: 14px;
  border-radius: 1px;
}
.heatmap-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.heatmap-table {
  border-collapse: separate;
  border-spacing: 2px;
  width: 100%;
  table-layout: fixed;
}
.row-label-header {
  width: 200px;
  text-align: left;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  font-weight: 500;
  padding: 0 12px 10px 0;
}
.week-header {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  padding: 0 0 10px;
  text-align: center;
}
.week-header.is-election {
  color: var(--lapis-lazuli);
  font-size: 14px;
}
.row-label {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 13px;
  color: var(--delft-blue);
  padding: 4px 12px 4px 16px;
  border-left: 3px solid var(--entity-color, var(--rule));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.heatmap-cell {
  height: 28px;
  border-radius: 2px;
  background: rgba(34, 53, 85, calc(0.05 + var(--cell-intensity, 0) * 0.85));
  transition: transform 0.1s ease, outline 0.1s ease;
  cursor: default;
}
.heatmap-cell:hover {
  outline: 2px solid var(--delft-blue);
  outline-offset: -1px;
  transform: scale(1.05);
}
.empty-heatmap {
  font-family: var(--sans);
  color: var(--ink-muted);
  padding: 24px 0;
}
@media (max-width: 900px) {
  .heatmap-header { flex-direction: column; }
  .row-label-header { width: 140px; }
  .row-label { padding-left: 12px; font-size: 12px; }
}

/* ============================================================
   HEATMAP POPOVER
   ============================================================ */
.heatmap-cell { cursor: pointer; }
.heatmap-popover {
  display: none;
  position: absolute;
  z-index: 100;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 320px;
  font-family: var(--sans);
  overflow: hidden;
}
.popover-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--rule-soft);
  background: var(--anti-flash);
}
.popover-entity {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 14px;
  color: var(--delft-blue);
  line-height: 1.3;
}
.popover-week {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin-top: 4px;
  font-weight: 500;
}
.popover-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 0 4px;
  font-weight: 400;
  font-family: var(--sans);
}
.popover-close:hover { color: var(--delft-blue); }
.popover-rows {
  padding: 12px 16px 14px;
}
.popover-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 14px;
  align-items: baseline;
  padding: 6px 0;
}
.popover-row-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
}
.popover-row-value {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--delft-blue);
  font-weight: 600;
}
.popover-row-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-muted);
}
.popover-row-total {
  border-top: 1px solid var(--rule-soft);
  margin-top: 4px;
  padding-top: 10px;
  font-weight: 700;
}
.popover-row-total .popover-row-label { font-weight: 700; color: var(--delft-blue); }
.popover-row-total .popover-row-value { font-size: 14px; }
.popover-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--rule-soft);
  background: var(--anti-flash);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-muted);
  letter-spacing: 0.04em;
}

/* ============================================================
   AD TYPE TOGGLE (persuasion vs fundraising)
   ============================================================ */
.ad-type-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 2px;
}
.ad-type-label {
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-muted);
  font-weight: 500;
  margin-right: 4px;
}
.ad-type-pill {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
  color: var(--ink-muted);
  background: transparent;
  border: 1px solid var(--rule-soft);
  border-radius: 12px;
  padding: 4px 10px;
  text-decoration: none;
  transition: all 0.12s ease;
}
.ad-type-pill:hover {
  border-color: var(--delft-blue);
  color: var(--delft-blue);
}
.ad-type-pill.is-active {
  background: var(--delft-blue);
  border-color: var(--delft-blue);
  color: var(--paper);
}
.ad-type-pill.is-active.persuasion {
  background: #0d7378;
  border-color: #0d7378;
}
.ad-type-pill.is-active.fundraising {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--ink);
}

/* ============================================================
   CYCLE BAR AD-TYPE TOGGLE (top-of-page, on dark background)
   ============================================================ */
.cycle-bar-inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}
.cycle-ad-type-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.cycle-ad-type-label {
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: rgba(255, 255, 255, 0.55);
  font-weight: 500;
  margin-right: 6px;
}
.cycle-pill {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  padding: 5px 12px;
  text-decoration: none;
  transition: all 0.12s ease;
}
.cycle-pill:hover {
  border-color: rgba(255, 255, 255, 0.45);
  color: var(--paper);
}
.cycle-pill.is-active {
  background: var(--paper);
  border-color: var(--paper);
  color: var(--delft-blue);
}
.cycle-pill.is-active.persuasion {
  background: #2faab1;
  border-color: #2faab1;
  color: var(--paper);
}
.cycle-pill.is-active.fundraising {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--ink);
}

/* ============================================================
   CYCLE BAR "CLEAR ALL FILTERS" BUTTON
   ============================================================ */
.cycle-clear-all {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 5px 12px;
  text-decoration: none;
  transition: all 0.12s ease;
  margin-left: 8px;
}
.cycle-clear-all:hover {
  color: var(--paper);
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.05);
}
