/* ============================================================
   InfoQ Campaign Benchmarks Dashboard
   Brand: InfoQ blue #1A4A8A · green #2E8B3A · CTA #2974D8
   Style: clean, minimal, white backgrounds, Helvetica, no decoration
   ============================================================ */

:root {
  /* Brand colours */
  --iq-blue:        #1A4A8A;
  --iq-blue-dark:   #133870;
  --iq-blue-light:  #2560AA;
  --iq-green:       #2E8B3A;
  --iq-green-light: #3AAA48;
  --cta:            #2974D8;
  --cta-dark:       #1E5FB8;
  --bg-highlight:   #EDF5EE;

  /* Neutrals */
  --bg:             #F7F9FC;
  --surface:        #FFFFFF;
  --surface-2:      #F7F9FC;
  --border:         #DDE3EC;
  --border-light:   #EEF1F6;
  --text:           #1A1A2A;
  --text-muted:     #5A6478;
  --text-light:     #8A94A6;

  /* Semantic */
  --green-bg:       #EDF5EE;
  --green-text:     #1E6B28;
  --blue-bg:        #EBF2FF;
  --blue-text:      #1A4A8A;
  --yellow-bg:      #FEF9E7;
  --yellow-text:    #7A5C00;
  --red-bg:         #FEF0EF;
  --red-text:       #C0392B;

  /* Spacing & shape */
  --radius:    8px;
  --radius-sm: 6px;
  --radius-xs: 4px;
  --shadow-sm: 0 1px 3px rgba(26,74,138,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 3px 8px rgba(26,74,138,.10), 0 1px 3px rgba(0,0,0,.05);
  --shadow-lg: 0 8px 24px rgba(26,74,138,.12), 0 2px 6px rgba(0,0,0,.06);
}

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

body {
  font-family: Helvetica, 'Helvetica Neue', Arial, sans-serif;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
  background: var(--iq-blue);
  border-bottom: 3px solid var(--iq-green);
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-lg);
}
.header-inner {
  max-width: 1440px; margin: 0 auto;
  padding: 0 28px;
  height: 60px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.header-brand  { display: flex; align-items: center; gap: 16px; }
.logo          { height: 32px; filter: brightness(0) invert(1); }
.logo-fallback { display: none; align-items: center; }
.logo-text     { font-size: 26px; font-weight: 900; color: #fff; letter-spacing: -1px; }
.logo-q        { color: var(--iq-green-light); }
.header-title-block h1    { font-size: 16px; font-weight: 700; color: #fff; letter-spacing: -.2px; }
.header-subtitle          { font-size: 11px; color: rgba(255,255,255,.55); margin-top: 1px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; text-decoration: none;
  transition: background .15s, box-shadow .15s, transform .1s;
  white-space: nowrap; letter-spacing: -.1px;
}
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn-primary  { background: var(--cta); color: #fff; }
.btn-primary:hover { background: var(--cta-dark); box-shadow: var(--shadow); transform: translateY(-1px); }
.btn-ghost    { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm       { padding: 5px 12px; font-size: 12px; }
.btn-close    { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--text-muted); padding: 4px 8px; line-height: 1; }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky; top: 63px; z-index: 90;
}
.filter-inner {
  max-width: 1440px; margin: 0 auto;
  padding: 10px 28px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
}
.filter-group { display: flex; flex-direction: column; gap: 3px; }
.filter-group label {
  font-size: 10px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .6px;
}
.filter-group select,
.filter-group input {
  height: 32px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px; color: var(--text);
  background: var(--surface); min-width: 145px; cursor: pointer;
  transition: border-color .15s;
}
.filter-group select:focus,
.filter-group input:focus { outline: none; border-color: var(--cta); box-shadow: 0 0 0 3px rgba(41,116,216,.12); }
.filter-group--reset { justify-content: flex-end; }
.filter-summary {
  max-width: 1440px; margin: 0 auto;
  padding: 4px 28px 8px;
  font-size: 11px; color: var(--iq-blue); font-weight: 600;
  min-height: 22px;
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.main-content  { max-width: 1440px; margin: 0 auto; padding: 28px; }
.section       { margin-bottom: 40px; }
.section-header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.section-header h2 {
  font-size: 18px; font-weight: 700; color: var(--iq-blue);
  border-left: 3px solid var(--iq-green); padding-left: 10px;
  letter-spacing: -.2px;
}
.section-subtitle { font-size: 12px; color: var(--text-muted); }
.table-controls  { display: flex; align-items: center; gap: 10px; }
.row-count       { font-size: 11px; color: var(--text-muted); }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 14px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, transform .15s;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-label  { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 8px; }
.stat-value  { font-size: 28px; font-weight: 800; color: var(--iq-blue); line-height: 1; letter-spacing: -1px; }
.stat-sub    { font-size: 11px; color: var(--text-light); margin-top: 5px; }
.stat-card.highlight          .stat-value { color: var(--iq-blue); }
.stat-card.highlight-green    .stat-value { color: var(--iq-green); }
.stat-card.highlight-blue     .stat-value { color: var(--cta); }

/* ============================================================
   SPONSOR LOGO GRID
   ============================================================ */
.logo-grid-wrap { position: relative; }
.logo-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.logo-grid.is-collapsed { max-height: 192px; overflow: hidden; }
.logo-grid-fade {
  position: absolute; bottom: 44px; left: 0; right: 0; height: 56px;
  background: linear-gradient(to bottom, transparent, var(--bg));
  pointer-events: none; transition: opacity .2s;
}
.logo-grid-fade.hidden { opacity: 0; pointer-events: none; }
.logo-grid-toggle { display: flex; justify-content: center; margin-top: 10px; }
.btn-expand {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 20px; border-radius: 20px; font-family: inherit;
  font-size: 12px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); transition: all .15s;
}
.btn-expand:hover { border-color: var(--cta); color: var(--cta); }
.btn-expand svg { width: 14px; height: 14px; transition: transform .2s; }
.btn-expand.expanded svg { transform: rotate(180deg); }

.sponsor-tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 7px; cursor: pointer; text-align: center;
  min-height: 86px; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.sponsor-tile:hover {
  border-color: var(--cta); box-shadow: var(--shadow); transform: translateY(-2px);
}
.sponsor-tile.active {
  border-color: var(--iq-blue); border-width: 2px;
  background: var(--blue-bg); box-shadow: 0 0 0 3px rgba(26,74,138,.1);
}
.sponsor-logo    { max-width: 84px; max-height: 38px; object-fit: contain; filter: grayscale(15%); }
.sponsor-tile:hover .sponsor-logo { filter: grayscale(0); }
.sponsor-name    { font-size: 11px; font-weight: 700; color: var(--text); line-height: 1.3; }
.sponsor-count   { font-size: 10px; color: var(--text-muted); }
.sponsor-initials {
  width: 44px; height: 44px; border-radius: 6px;
  background: var(--iq-blue); color: #fff;
  font-weight: 800; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}

/* ============================================================
   SPONSOR DETAIL PANEL
   ============================================================ */
.sponsor-detail {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 26px;
  box-shadow: var(--shadow); margin-bottom: 36px;
}
.detail-header {
  display: flex; align-items: center; gap: 18px;
  margin-bottom: 22px; flex-wrap: wrap;
}
.detail-header h2 { font-size: 22px; font-weight: 800; color: var(--iq-blue); letter-spacing: -.3px; }
.detail-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px;
}
.detail-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px;
}
.detail-card h4 {
  font-size: 10px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .6px; margin-bottom: 10px;
}
.detail-chart-wrap { height: 190px; position: relative; }

.campaign-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--border-light); gap: 10px;
}
.campaign-row:last-child { border-bottom: none; }
.campaign-row-left  { flex: 1; min-width: 0; }
.campaign-row-type  { font-size: 12px; font-weight: 600; color: var(--iq-blue); }
.campaign-row-meta  { font-size: 11px; color: var(--text-muted); margin-top: 2px; line-height: 1.4; }
.meta-dates         { color: var(--iq-blue); font-weight: 600; }

.metric-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 0; border-bottom: 1px solid var(--border-light); font-size: 12px;
}
.metric-row:last-child { border-bottom: none; }
.metric-label { color: var(--text-muted); }
.metric-value { font-weight: 700; color: var(--iq-blue); }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: 10px; font-weight: 700; white-space: nowrap; line-height: 1.6;
}
.badge-geo    { background: var(--blue-bg);   color: var(--iq-blue); }
.badge-nogeo  { background: var(--green-bg);  color: var(--green-text); }
.badge-leads  { background: var(--blue-bg);   color: var(--cta); }
.badge-clicks { background: var(--yellow-bg); color: var(--yellow-text); }

/* ============================================================
   CHARTS
   ============================================================ */
.charts-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 16px; }
.charts-grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 16px; }
.chart-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow-sm);
}
.chart-card h3 {
  font-size: 12px; font-weight: 700; color: var(--iq-blue);
  margin-bottom: 14px; line-height: 1.4;
}
.chart-card canvas { max-height: 260px; }

/* ============================================================
   BENCHMARKS
   ============================================================ */
.benchmarks-tabs {
  display: flex; gap: 4px; margin-bottom: 20px; flex-wrap: wrap;
}
.tab-btn {
  padding: 7px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); font-family: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.tab-btn.active { background: var(--iq-blue); color: #fff; border-color: var(--iq-blue); }
.tab-btn:hover:not(.active) { background: var(--surface-2); color: var(--text); border-color: var(--border); }

.bench-explainer {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 14px;
  margin-bottom: 18px; font-size: 12px; color: var(--text-muted); line-height: 1.5;
}
.bench-badge {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 20px; font-size: 10px; font-weight: 800;
  letter-spacing: .4px; white-space: nowrap; flex-shrink: 0;
}
.bench-badge--conv  { background: var(--blue-bg);   color: var(--iq-blue);    border: 1px solid #C5D9F8; }
.bench-badge--ctr   { background: var(--yellow-bg); color: var(--yellow-text); border: 1px solid #F0E0A0; }
.bench-badge--email { background: var(--green-bg);  color: var(--green-text);  border: 1px solid #B2D9B8; }

.bench-table-section { margin-top: 24px; }
.bench-table-label {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px; font-size: 12px; color: var(--text-muted); font-weight: 600;
}

.benchmark-panel { }
.benchmark-panel.hidden { display: none; }
.benchmark-table-wrap { overflow-x: auto; }

.bench-table {
  width: 100%; border-collapse: collapse; font-size: 11px;
  background: var(--surface); border-radius: var(--radius-sm);
  overflow: hidden; box-shadow: var(--shadow-sm);
}
.bench-table th.cat-header {
  background: var(--iq-blue); color: rgba(255,255,255,.9);
  padding: 7px 12px; text-align: center;
  font-size: 10px; font-weight: 700; letter-spacing: .5px;
  border-left: 2px solid rgba(255,255,255,.2);
}
.bench-table th.cat-header:first-child { border-left: none; text-align: left; }
.bench-table th.yr-header {
  background: var(--iq-blue-light); color: rgba(255,255,255,.75);
  padding: 4px 7px; text-align: center;
  font-size: 10px; font-weight: 600; white-space: nowrap;
  border-left: 1px solid rgba(255,255,255,.12);
}
.bench-table th.yr-header.yr-first { border-left: 2px solid rgba(255,255,255,.25); }
.bench-table td.ad-type {
  font-weight: 600; color: var(--text); font-size: 11px;
  padding: 7px 12px; white-space: nowrap;
  border-right: 1px solid var(--border); background: var(--surface-2);
  position: sticky; left: 0;
}
.bench-table td {
  padding: 6px 7px; border-bottom: 1px solid var(--border-light);
  text-align: center;
}
.bench-table tr:last-child td { border-bottom: none; }
.bench-table tr:hover td          { background: var(--blue-bg); }
.bench-table tr:hover td.ad-type  { background: #E0ECF8; }
.bench-table td.cat-divider       { border-left: 2px solid var(--border); }

.bench-value {
  font-weight: 700; padding: 2px 6px; border-radius: var(--radius-xs);
  font-size: 10px; display: inline-block; min-width: 44px; text-align: center;
}
.bench-value.good { background: var(--green-bg); color: var(--green-text); }
.bench-value.mid  { background: var(--yellow-bg); color: var(--yellow-text); }
.bench-value.low  { background: var(--red-bg);    color: var(--red-text); }
.bench-value.na   { color: var(--text-light); font-weight: 400; }

/* ============================================================
   DATA TABLE
   ============================================================ */
.table-wrap    { overflow-x: auto; margin-top: 14px; }
.data-table    { width: 100%; border-collapse: collapse; font-size: 12px; background: var(--surface); }
.data-table th {
  background: var(--iq-blue); color: rgba(255,255,255,.9);
  padding: 9px 12px; text-align: left; font-weight: 600;
  white-space: nowrap; cursor: pointer; user-select: none;
  font-size: 11px; letter-spacing: -.1px;
}
.data-table th:hover { background: var(--iq-blue-light); }
.data-table td { padding: 7px 12px; border-bottom: 1px solid var(--border-light); }
.data-table tr:hover td { background: var(--blue-bg); }
.data-table tr:last-child td { border-bottom: none; }
.text-right  { text-align: right; }
.text-center { text-align: center; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(26,74,138,.25); backdrop-filter: blur(3px);
  z-index: 200; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 460px; overflow: hidden;
}
.modal-header {
  background: var(--iq-blue); color: #fff;
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3    { font-size: 15px; font-weight: 700; }
.modal-header .btn-close { color: rgba(255,255,255,.65); }
.modal-body         { padding: 20px; }
.modal-body p       { color: var(--text-muted); margin-bottom: 14px; font-size: 12px; }
.modal-footer       { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.pdf-filter-summary {
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 9px 12px; margin-bottom: 14px;
  font-size: 11px; color: var(--text-muted); line-height: 1.8;
}
.form-group           { margin-bottom: 12px; }
.form-group label     { display: block; font-size: 11px; font-weight: 700; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .5px; }
.form-input {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-family: inherit; font-size: 13px; color: var(--text);
}
.form-input:focus { outline: none; border-color: var(--cta); box-shadow: 0 0 0 3px rgba(41,116,216,.12); }

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden { display: none !important; }

/* ============================================================
   PRINT / PDF
   ============================================================ */
@media print {
  .site-header, .filter-bar  { page-break-before: auto; }
  .btn, .filter-bar, .benchmarks-tabs, #tableSection, .logo-grid-toggle { display: none !important; }
  .benchmark-panel.hidden    { display: block !important; }
  .chart-card                { break-inside: avoid; }
  body                       { background: #fff; font-size: 11px; }
  .main-content              { padding: 0; max-width: 100%; }
  .stat-card, .chart-card    { box-shadow: none; border: 1px solid #ddd; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .header-inner, .filter-inner, .main-content { padding-left: 16px; padding-right: 16px; }
  .logo-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .logo-grid.is-collapsed { max-height: 196px; }
  .charts-grid-3 { grid-template-columns: 1fr; }
}
