@font-face {
  font-family: "Inter";
  font-weight: 400;
  font-style: normal;
  src: url("../fonts/inter-400.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  font-weight: 500;
  font-style: normal;
  src: url("../fonts/inter-500.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  font-weight: 600;
  font-style: normal;
  src: url("../fonts/inter-600.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  font-weight: 700;
  font-style: normal;
  src: url("../fonts/inter-700.woff2") format("woff2");
  font-display: swap;
}

:root {
  --bvk-black: #1a1a1a;
  /* BVK Pulse brand (2026 guidelines). Names kept as --ucd-* to avoid a
     repo-wide var rename; values are BVK's. Per-client accent still overrides
     --ucd-navy at runtime (portal.js) so client dashboards keep their own color. */
  --ucd-navy: #252020;   /* BVK near-black (brand accent5) — was UC Davis navy #022851 */
  --ucd-gold: #F05E4D;   /* BVK orange-red (brand accent1) — was UC Davis gold #ffbf00 */
  --accent-orange: #e8983c;
  --accent-navy: #1f3a5f;
  --up-green: #7aad6e;
  --down-red: #d18b83;
  --bar-blue: #8fb8db;
  --page-bg: #f7f7f5;
  --card-bg: #ffffff;
  --border-color: #e2e2de;
  --text-primary: #1a1a1a;
  --text-secondary: #666663;
  --text-muted: #8a8a86;
  --radius-card: 10px;
  --radius-sm: 6px;
  --heat-0: #eef4fb;
  --heat-1: #c9def3;
  --heat-2: #a0c4ea;
  --heat-3: #6fa3dd;
  --heat-4: #3f7cc4;
  --heat-5: #205a9e;
}

/* Dark theme: token-level override, applied via data-theme on <html>
   (set by portal.js from the saved Settings choice). Brand navy/gold
   stay; surfaces and text flip. */
:root[data-theme="dark"] {
  --page-bg: #241e1d;        /* BVK warm dark base — not pure black, sits below the sidebar */
  --card-bg: #2f2726;        /* elevated card, a clear step up from the page for depth */
  --border-color: #423835;
  --text-primary: #f1eae6;
  --text-secondary: #c6b8b2;
  --text-muted: #9b8c86;
  --heat-0: #132a44;
  --heat-1: #1a3a5c;
  --heat-2: #245081;
  --heat-3: #3168a6;
  --heat-4: #4a86c8;
  --heat-5: #6ea3dd;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--page-bg);
  color: var(--text-primary);
}

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 0 3rem;
}

/* Section nav (top-level LOB tabs) */
.section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 12px 24px 0;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
}

.section-nav button {
  border: none;
  background: transparent;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  border-bottom: 2px solid transparent;
}

.section-nav button:hover {
  background: var(--page-bg);
}

.section-nav button.active {
  color: var(--accent-navy);
  font-weight: 600;
  border-bottom: 2px solid var(--accent-navy);
}

/* Header */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 32px 24px 16px;
  background: var(--card-bg);
}

.logo-bvk {
  height: 40px;
  width: auto;
}

.logo-ucd {
  height: 52px;
  width: auto;
}

.dashboard-title {
  text-align: center;
  flex: 1;
}

.dashboard-title h1 {
  font-size: 20px;
  font-weight: 500;
  margin: 0;
}

.dashboard-title .fy {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Filter bar -- five columns to match the real dashboard (Previous Period
   Comparison, Date Range, Vendor Source, Campaign Name, Marketing Channel) */
.filter-bar {
  display: grid;
  /* 5 equal filters + a narrower Download PDF button column */
  grid-template-columns: repeat(5, 1fr) 130px;
  gap: 16px;
  padding: 0 24px 24px;
  background: var(--card-bg);
}

.filter-bar .filter label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
}

.filter-bar .filter select,
.filter-bar .filter input {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--card-bg);
  color: var(--text-secondary);
}

.filter-bar .filter:has(input[type="date"]) {
  display: flex;
  flex-direction: column;
}
.filter-bar .filter input[type="date"] {
  display: inline-block;
  width: auto;
  flex: 1;
}
.filter-bar .filter input[type="date"] + input[type="date"] {
  margin-top: 4px;
}

/* KPI section -- each metric is its own bordered/rounded card with a gap
   between them (not a shared grid-line background trick). */
.kpi-banner {
  background: var(--page-bg);
  text-align: center;
  padding: 20px 0;
  margin: 0 24px;
}

.kpi-banner h2 {
  font-size: 22px;
  font-weight: 500;
  margin: 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin: 0 24px;
}

.kpi-grid.row2 {
  grid-template-columns: repeat(5, 1fr);
}

.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  padding: 20px 12px 16px;
  text-align: center;
}

.kpi-card .label {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--text-muted);
  color: var(--text-muted);
  font-size: 9px;
  font-style: normal;
  font-weight: 600;
  cursor: default;
  position: relative;
  flex-shrink: 0;
}

.info-icon .tooltip {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bvk-black);
  color: #fff;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
  padding: 8px 10px;
  border-radius: 4px;
  width: 190px;
  text-align: left;
  z-index: 10;
  transition: opacity 0.15s ease;
}

.info-icon:hover .tooltip {
  visibility: visible;
  opacity: 1;
}

.kpi-card .accent-bar {
  width: 70%;
  height: 2px;
  background: var(--accent-navy);
  margin: 0 auto 10px;
}

.kpi-card .value {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 6px;
}

.kpi-card .value.empty {
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 400;
}

.delta-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 4px;
}

.delta-badge .dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  font-size: 9px;
  color: #fff;
  line-height: 1;
}

.delta-badge.up { color: var(--up-green); background: rgba(76, 175, 80, 0.12); }
.delta-badge.up .dot { background: var(--up-green); }
.delta-badge.down { color: var(--down-red); background: rgba(217, 83, 79, 0.12); }
.delta-badge.down .dot { background: var(--down-red); }

.kpi-card .previously {
  font-size: 11px;
  color: var(--text-muted);
}

/* Sub-tabs -- these DO have a bordered-button look in the real dashboard */
.sub-tabs {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 24px 24px 0;
}

.sub-tabs button {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

.sub-tabs button.active {
  color: var(--accent-navy);
  border: 1px solid var(--accent-navy);
  font-weight: 600;
}

.sub-tab-content {
  margin: 0 24px;
  background: var(--card-bg);
  padding: 0 0 24px;
}

.section-banner {
  background: var(--accent-orange);
  color: var(--bvk-black);
  text-align: center;
  padding: 16px;
  margin: 20px 0;
  border-radius: var(--radius-card);
}

.section-banner h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.local-filter-bar {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 16px;
}

.local-filter-bar .filter label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
}

.local-filter-bar .filter select,
.local-filter-bar .filter input {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--card-bg);
  color: var(--text-primary);
}

.local-filter-bar .filter:has(input[type="date"]) {
  display: flex;
  flex-direction: column;
}
.local-filter-bar .filter input[type="date"] {
  display: inline-block;
  width: auto;
  flex: 1;
}
.local-filter-bar .filter input[type="date"] + input[type="date"] {
  margin-top: 4px;
}

.section-banner .sub {
  font-size: 12px;
  font-style: italic;
  margin-top: 4px;
  opacity: 0.9;
}

.chart-wrap {
  padding: 0 16px;
  height: 320px;
}

.chart-wrap.medium {
  height: 280px;
}

.chart-title {
  font-size: 14px;
  font-weight: 500;
  padding: 0 16px;
  margin-bottom: 8px;
}

.perf-shared-filter {
  margin: 24px 0 8px;
}

.perf-no-data {
  padding: 40px 24px;
  text-align: center;
  color: var(--text-secondary, #767672);
  font-size: 13px;
  font-style: italic;
}

/* "Download PDF" button in the top filter bar -- opens the print-ready
   report preview (report.html) in a new tab. */
.download-filter {
  display: flex;
  align-items: flex-end;
}

.download-pdf-btn {
  display: block;
  width: 100%;
  text-align: center;
  background: var(--accent-navy);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.download-pdf-btn:hover {
  background: var(--ucd-navy);
}

/* Creative Performance table (Image Extension tab + PDF report): first three
   columns are long text -- give them room and let the 6 numeric columns share
   the rest. Vendor name prints only on its group's first row. */
table.creative-table th:first-child {
  width: 120px;
}
table.creative-table th:nth-child(2) {
  width: 90px;
}
table.creative-table th:nth-child(3) {
  width: 170px;
}
table.creative-table td:first-child {
  font-weight: 600;
}
table.creative-table th:first-child,
table.creative-table td:first-child,
table.creative-table td:nth-child(2),
table.creative-table td:nth-child(3) {
  text-align: left;
}

.placeholder-note {
  padding: 40px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.table-caption {
  font-size: 14px;
  font-weight: 500;
  padding: 16px 16px 8px;
}

/* Data tables */
.data-table-wrap {
  padding: 0 16px 24px;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10.5px;
  table-layout: fixed;
}

table.data-table th,
table.data-table td {
  border-bottom: 1px solid var(--border-color);
  padding: 5px 6px;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* table-layout:fixed takes column widths from the header row's `width`
   (not min/max-width, which it largely ignores past the first row) --
   give the dimension column a real fixed width and let the rest share
   the remainder evenly. */
table.data-table th:first-child {
  width: 190px;
}

table.data-table th:first-child,
table.data-table td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
}

table.data-table td:first-child {
  background: var(--card-bg);
}

table.data-table th {
  font-weight: 700;
  color: var(--text-primary);
  background: #e9e9e5;
  border-bottom: 1px solid var(--border-color);
  /* Full header text wraps onto multiple lines at word boundaries (e.g.
     "Visits" / "with Action") instead of being abbreviated, truncated, or
     broken mid-word. */
  white-space: normal;
  word-break: normal;
  overflow-wrap: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.25;
  vertical-align: bottom;
  font-size: 10px;
}

table.data-table th:first-child {
  background: #e9e9e5;
}

/* Conditional formatting: % change cells (MoM tables) -- full-cell fill so
   the direction pops rather than just tinting the text. */
td.pct-change {
  font-weight: 700;
  text-align: right;
}
td.pct-change.up { color: #2f5e26; background: rgba(122, 173, 110, 0.28); }
td.pct-change.down { color: #7a3830; background: rgba(209, 139, 131, 0.28); }
td.pct-change.flat { color: var(--text-muted); }

/* Conditional formatting: heatmap cells (Fiscal YoY tables). Background color
   is a continuous gradient set inline per-cell (see heatColor() in app.js);
   this class just sets the shared text alignment. */
td.heat-cell {
  text-align: right;
  color: var(--text-primary);
}
td.heat-null {
  background: var(--card-bg);
  color: var(--text-muted);
  font-style: italic;
}

/* Fiscal YoY pivot tables: two-tier field-name header (metric + "Fiscal Year"
   over the year columns, "Campaign Name" over the dimension column), a bold
   unshaded Grand Total column/row, and minimal row borders -- matches the
   live Sigma pivot table's clean, near-borderless look. */
table.fiscal-yoy-table {
  /* auto (not fixed) layout -- the two-tier header's colspan row would
     otherwise be used to derive column widths and throw off alignment
     with the real per-column header row underneath it. */
  table-layout: auto;
}
table.fiscal-yoy-table thead tr:first-child th {
  text-align: left;
  background: #f1f1ee;
  border-bottom: none;
}
table.fiscal-yoy-table thead tr:first-child th[colspan] {
  text-align: center;
}
table.fiscal-yoy-table .chevron {
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 2px;
}
table.fiscal-yoy-table td {
  border-bottom: 1px solid #f0f0ec;
}
table.fiscal-yoy-table td.fiscal-total {
  font-weight: 700;
  text-align: right;
  background: var(--card-bg);
  color: var(--text-primary);
}
table.fiscal-yoy-table tr.fiscal-grand-total td {
  font-weight: 700;
  background: #dedcd5;
  border-bottom: none;
}

/* Pivot tables (MoM tabs): Campaign Name parent rows + grey Vendor Source
   child rows, with an expand/collapse chevron and a bold Grand Total row. */
table.pivot-table tr.pivot-parent {
  cursor: pointer;
  font-weight: 700;
}
table.pivot-table tr.pivot-parent td:first-child {
  background: var(--card-bg);
}
table.pivot-table tr.pivot-parent:hover td {
  background: #f0f0ec;
}
.pivot-toggle {
  display: inline-block;
  width: 14px;
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}
table.pivot-table tr.pivot-parent.collapsed .pivot-toggle {
  transform: rotate(-90deg);
}
/* Only the dimension column (Campaign Name / Vendor Source) is grey for
   child rows -- every other cell stays white so conditional-formatting
   fills (pct-change, heatmap) remain visible. */
table.pivot-table tr.pivot-child td {
  color: var(--text-secondary);
  font-weight: 400;
}
table.pivot-table tr.pivot-child td.pivot-child-label {
  padding-left: 28px;
  background: #ececE8;
}
table.pivot-table tr.pivot-grand-total td {
  font-weight: 700;
  background: #dedcd5;
  border-top: 2px solid var(--border-color);
  border-bottom: none;
}
table.pivot-table tr.pivot-grand-total td:first-child {
  background: #dedcd5;
}

/* Month over Month bottom bar-chart grid */
.mom-chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px 16px 24px;
}

.chart-wrap.small {
  height: 280px;
  padding: 0;
}

@media (max-width: 900px) {
  .mom-chart-grid { grid-template-columns: 1fr; }
}

.section-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 0 16px 24px;
}

@media (max-width: 900px) {
  .section-grid { grid-template-columns: 1fr; }
}

/* Image Extension */
.image-ext-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 0 16px 24px;
}

.image-ext-card .badge {
  background: var(--accent-orange);
  color: #fff;
  text-align: center;
  font-weight: 600;
  font-size: 13px;
  padding: 8px;
  border-radius: 4px 4px 0 0;
}

.image-ext-card .thumb {
  height: 130px;
  background: var(--page-bg);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 4px 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
  padding: 8px;
}

.footer-note {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 24px;
}

#live-status-note {
  padding: 4px 24px 12px;
  font-weight: 600;
  color: #2f7a3d;
}
#live-status-note.live-status-error {
  color: #b3302a;
}
