/**
 * Component Styles
 * Pure CSS + Vanilla JS Components
 */

/* ============================================
   SIDEBAR
   ============================================ */
#sidebar {
  width: 220px;
  transition: width 200ms ease;
  overflow: hidden;
}

#sidebar.collapsed {
  width: 56px;
}

#sidebar.collapsed .nav-label {
  display: none;
}

.sidebar {
  height: 100vh;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  transition: width 200ms ease;
}

.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.sidebar-logo {
  font-size: var(--text-subheading);
  font-weight: var(--font-bold);
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  opacity: 1;
  transition: opacity var(--transition-fast);
}

#sidebar.collapsed .sidebar-logo {
  display: none;
}

/* Top row of the sidebar: hamburger + credit block sharing a single row so
   the credit has the whole width (minus hamburger) to lay out its eyebrow
   label, the BI line, and the We logo without wrapping. */
.sidebar-top-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-hamburger {
  width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

/* Pacing page wrapper: topbar (fixed) stacked over a scrollable content-area.
   Only applies when sidebar.js toggles this element to display:flex. */
#page-pacing {
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Cross-filter chips strip. Shown above the stat cards when any cross-filter
   is active (click on chart slice, channel bar, or a top-level table row). */
.active-filters-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding: 8px var(--space-3);
  background: var(--color-bg-subtle, rgba(148,163,184,0.08));
  border-radius: var(--radius-md);
  border: 1px dashed var(--color-border);
  flex-wrap: wrap;
}
.active-filters-bar.is-empty {
  display: none;
}
.active-filters-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.active-filters-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  flex: 1;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 10px;
  background: var(--color-accent-light, rgba(124,58,237,0.12));
  color: var(--color-text-primary);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.filter-chip-dim {
  color: var(--color-text-muted);
  font-weight: 500;
}
.filter-chip-value {
  font-weight: 600;
}
.filter-chip-remove {
  width: 18px;
  height: 18px;
  border: none;
  background: rgba(0,0,0,0.08);
  color: var(--color-text-primary);
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.filter-chip-remove:hover {
  background: rgba(0,0,0,0.18);
}
[data-theme="dark"] .filter-chip-remove {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
[data-theme="dark"] .filter-chip-remove:hover {
  background: rgba(255,255,255,0.22);
}

/* Credit strip in the sidebar top row — eyebrow label + BI line on the left,
   We logo centered vertically on the right. Hidden when the sidebar is
   collapsed (no room). */
.sidebar-credit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 8px 12px;
  flex: 1;
  min-width: 0;
}
.sidebar-credit-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  line-height: 1.15;
}
.sidebar-credit-eyebrow {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.sidebar-credit-title {
  font-size: 9px;
  font-weight: 600;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
[data-theme="dark"] .sidebar-credit-eyebrow,
[data-theme="dark"] .sidebar-credit-title {
  color: #ffffff;
}
.sidebar-credit-logo {
  height: 24px;
  width: auto;
  flex-shrink: 0;
}
#sidebar.collapsed .sidebar-credit {
  display: none;
}
#sidebar.collapsed .sidebar-top-row {
  justify-content: center;
}

.sidebar-hamburger:hover {
  background: var(--color-accent-light);
  color: var(--color-accent);
}

.sidebar-toggle {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
  background: var(--color-accent-light);
  color: var(--color-accent);
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4);
  overflow-y: auto;
}

.nav-section {
  margin-bottom: var(--space-6);
}

.nav-label {
  font-size: var(--text-label);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  padding: 0 var(--space-3);
  margin-bottom: var(--space-3);
  white-space: nowrap;
  opacity: 1;
  transition: opacity var(--transition-fast);
}

.sidebar.sidebar-collapsed .nav-label {
  opacity: 0;
}

.nav-divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-4) 0;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-weight: var(--font-medium);
  text-decoration: none;
  transition: all var(--transition-fast);
  margin-bottom: var(--space-1);
}

#sidebar:not(.collapsed) .nav-item {
  justify-content: flex-start;
  gap: 16px;
  padding: 0 var(--space-3);
}

.nav-item:hover {
  background: var(--color-accent-light);
  color: var(--color-accent);
}

.nav-item.active {
  background: var(--color-accent-light);
  color: var(--color-accent);
}

.nav-item .nav-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.nav-item .nav-text {
  white-space: nowrap;
  opacity: 1;
  transition: opacity var(--transition-fast);
}

#sidebar.collapsed .nav-item .nav-text {
  display: none;
}

/* Sidebar Settings — quick language + theme controls under the logo */
.sidebar-settings {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sidebar-settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.sidebar-settings-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  white-space: nowrap;
}

#sidebar.collapsed .sidebar-settings { display: none; }

/* Sidebar Footer - Language Toggle */
.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.lang-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-family: var(--font-family);
  font-size: var(--text-body);
  font-weight: var(--font-medium);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

#sidebar:not(.collapsed) .lang-btn {
  justify-content: flex-start;
  padding: 0 var(--space-3);
  gap: 16px;
}

.lang-btn:hover {
  background: var(--color-accent-light);
  color: var(--color-accent);
}

.lang-btn.active {
  background: var(--color-accent-light);
  color: var(--color-accent);
}

#sidebar.collapsed .lang-btn {
  font-size: 0;
}

#sidebar.collapsed .lang-btn::before {
  font-size: 20px;
  content: attr(data-flag);
}

/* ============================================
   TOPBAR
   ============================================ */
.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.topbar-title {
  font-size: var(--text-subheading);
  font-weight: var(--font-semibold);
  color: var(--color-text-primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Date Range Filter */
.date-range {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.date-label {
  font-size: var(--text-body);
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.date-input {
  width: 140px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-family: var(--font-family);
  font-size: var(--text-body);
  color: var(--color-text-primary);
  transition: all var(--transition-fast);
}

.date-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-light);
}

@media (max-width: 768px) {
  .date-input {
    width: 120px;
  }
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--text-body);
  font-weight: var(--font-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--color-accent);
  color: white;
}

.btn-primary:hover {
  background: var(--color-accent-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-bg);
  border-color: var(--color-accent);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}

.btn-ghost:hover {
  background: var(--color-accent-light);
  color: var(--color-accent);
}

.btn-danger {
  background: var(--color-danger);
  color: white;
}

.btn-danger:hover {
  background: #DC2626;
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-caption);
}

.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-body);
}

/* Pacing — per-channel cards (horizontal, full-width, stacked) */
.pacing-channel-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Comparative totals strip in the Pacing trend chart header. One pill per
   metric — actual delivered, expected goal, and % of goal — so users can
   read the comparison at a glance without hovering the line chart. */
.pacing-totals {
  display: inline-flex;
  align-items: stretch;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.pacing-total {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--color-bg-subtle, rgba(148,163,184,0.12));
  min-width: 90px;
}
.pacing-total-label {
  font-size: 10px;
  color: var(--color-text-muted);
  font-weight: 500;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}
.pacing-total-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
}
/* Colored left accent matching each line in the chart legend so users can
   map the number back to its series. */
.pacing-total-actual   { box-shadow: inset 3px 0 0 #2563EB; }
.pacing-total-expected { box-shadow: inset 3px 0 0 #9CA3AF; }
.pacing-total-delta    { box-shadow: inset 3px 0 0 var(--color-accent, #7C3AED); }

/* Heatmap Canal × Formato — coloured grid where each cell is one combo.
   The grid uses CSS Grid with a fixed first column (canal labels) and
   the rest auto-sized. Header rotation is avoided so the labels stay
   readable; instead they truncate with ellipsis on narrow viewports. */
.heatmap-container {
  width: 100%;
  overflow-x: auto;
  padding: var(--space-3) var(--space-4) var(--space-4);
}
.heatmap-grid {
  display: grid;
  gap: 2px;
  min-width: 600px;
}
.heatmap-corner {
  background: transparent;
}
.heatmap-col-head,
.heatmap-row-head {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 6px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.heatmap-col-head {
  text-align: center;
}
.heatmap-row-head {
  text-align: left;
  display: flex;
  align-items: center;
}
.heatmap-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 4px 6px;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border-radius: 4px;
  cursor: default;
}
.heatmap-cell-empty {
  background: var(--color-bg-subtle, rgba(148,163,184,0.10));
  color: var(--color-text-muted);
}
.heatmap-empty {
  padding: var(--space-6);
  text-align: center;
  color: var(--color-text-muted);
  font-size: 12px;
}
.heatmap-metric-toggle {
  display: inline-flex;
  gap: var(--space-1);
}

/* Pacing ranking section headers — sit above each delivery-rate bucket
   (Em atenção / Em risco / No ritmo). The dot colour matches the gauge
   threshold so headers tie back to the cards below. */
.pacing-section-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-primary);
  letter-spacing: 0.2px;
}
.pacing-section-header + .pacing-channel-card {
  margin-top: 4px;
}
.pacing-section-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
}
.pacing-section-critical .pacing-section-dot { background: var(--color-danger); }
.pacing-section-risk     .pacing-section-dot { background: var(--color-warning); }
.pacing-section-ontrack  .pacing-section-dot { background: var(--color-success); }
.pacing-section-label    { text-transform: uppercase; }
.pacing-section-hint {
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: 500;
}
.pacing-section-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--color-bg-subtle, rgba(148,163,184,0.12));
}

.pacing-channel-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pacing-channel-card .pc-body {
  display: grid;
  grid-template-columns: 140px 110px 130px 220px 1fr;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-5);
}
@media (max-width: 1100px) {
  .pacing-channel-card .pc-body {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
  }
}

.pacing-channel-card .pc-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0;
  letter-spacing: -0.01em;
}

.pacing-channel-card .pc-kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: var(--space-4);
  border-left: 1px solid var(--color-border);
}
.pacing-channel-card .pc-kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1;
}
.pacing-channel-card .pc-kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.pacing-channel-card .pc-gauge {
  position: relative;
  width: 200px;
  height: 140px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 2px;
}
.pacing-channel-card .pc-gauge-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  margin-bottom: 8px;
}
.pacing-channel-card .pc-gauge canvas {
  display: block;
  margin: 0 auto;
}
.pacing-channel-card .pc-gauge-value {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text-primary);
  text-align: center;
  line-height: 1;
}

.pacing-channel-card .pc-estimate {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}
.pacing-channel-card .pc-estimate-header .pc-estimate-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}
.pacing-channel-card .pc-estimate-header .pc-estimate-total {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.1;
}
.pacing-channel-card .pc-estimate-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pacing-channel-card .pc-estimate-item {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 10px;
  background: var(--color-surface-alt, rgba(156, 163, 175, 0.1));
  border-radius: var(--radius-sm);
  font-size: 12px;
  overflow: hidden;
}
.pacing-channel-card .pc-estimate-item .pc-estimate-item-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--color-accent-light);
  z-index: 0;
}
.pacing-channel-card .pc-estimate-item .pc-estimate-item-name,
.pacing-channel-card .pc-estimate-item .pc-estimate-item-value {
  position: relative;
  z-index: 1;
}
.pacing-channel-card .pc-estimate-item .pc-estimate-item-name {
  color: var(--color-text-primary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 8px;
}
.pacing-channel-card .pc-estimate-item .pc-estimate-item-value {
  color: var(--color-text-primary);
  font-weight: 600;
  white-space: nowrap;
}

.pacing-channel-card .pc-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-border);
  background: rgba(124, 111, 247, 0.04);
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}
.pacing-channel-card .pc-footer .pc-insight-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--color-accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pacing-channel-card .pc-footer .pc-insight-icon i {
  width: 14px;
  height: 14px;
  color: var(--color-accent);
}
.pacing-channel-card .pc-footer .pc-insight-text {
  font-size: 12px;
  color: var(--color-text-secondary);
  line-height: 1.5;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pacing-channel-card .pc-footer .pc-insight-line {
  /* Each analysis (pacing / VTR / engagement) lives on its own row. */
}

/* Overview table drill group (Agrupar por) */
.table-drill-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.table-drill-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  white-space: nowrap;
}
.table-drill-buttons {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}

/* Breadcrumb showing the ordered drill path */
.table-drill-path {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
  width: 100%;
  margin-top: var(--space-2);
}
.table-drill-path:empty { display: none; }
.drill-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  background: var(--color-accent-light);
  color: var(--color-accent);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.drill-chip-remove {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  padding: 0 0 0 4px;
  cursor: pointer;
  opacity: 0.7;
}
.drill-chip-remove:hover { opacity: 1; }
.drill-sep {
  color: var(--color-text-muted);
  font-size: 14px;
  font-weight: 600;
}

/* Hierarchical table row adornments */
.drill-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 6px 0 0;
  font-size: 12px;
  color: var(--color-text-secondary);
}
.drill-toggle-spacer {
  display: inline-block;
  width: 18px;
}
.child-row td:first-child {
  color: var(--color-text-secondary);
}
.child-row.depth-1 { background: rgba(124, 111, 247, 0.04); }
.child-row.depth-2 { background: rgba(124, 111, 247, 0.07); }
.child-row.depth-3 { background: rgba(124, 111, 247, 0.10); }
.child-row.depth-4 { background: rgba(124, 111, 247, 0.13); }
.child-row.depth-5 { background: rgba(124, 111, 247, 0.16); }

/* Language Switcher (topbar) */
.lang-switcher {
  display: inline-flex;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: white;
  overflow: hidden;
  padding: 2px;
  gap: 2px;
}
.lang-pill {
  padding: 4px 12px;
  border: none;
  background: transparent;
  border-radius: 999px;
  font-family: var(--font-family);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 150ms ease;
  min-width: 36px;
}
.lang-pill:hover {
  color: var(--color-accent);
}
.lang-pill.active {
  background: var(--color-accent);
  color: white;
}

/* Year & Quarter Filter Buttons */
.year-btn,
.quarter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid #ddd;
  background: white;
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  color: #555;
  transition: all 200ms ease;
}
.quarter-btn { padding: 6px 12px; }
.year-btn:hover,
.quarter-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}
.year-btn.active,
.quarter-btn.active {
  background: var(--color-accent) !important;
  color: white !important;
  border-color: var(--color-accent) !important;
}
.year-btn.active:hover,
.quarter-btn.active:hover {
  background: var(--color-accent-dark) !important;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* ============================================
   CARDS
   ============================================ */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition-default);
}

.card:hover {
  box-shadow: var(--shadow-card-hover);
}

.card-header {
  padding: var(--space-5);
  border-bottom: 1px solid var(--color-border-light);
}

.card-title {
  font-size: var(--text-subheading);
  font-weight: var(--font-semibold);
  color: var(--color-text-primary);
}

.card-body {
  padding: var(--space-5);
}

.card-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border-light);
}

/* Stat Card */
.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
  transition: all var(--transition-default);
  cursor: pointer;
  border: 2px solid transparent;
}

.stat-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}

.stat-card.active {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
}

.stat-card.active .stat-value {
  color: var(--color-accent);
}

/* Efficiency cost-per-X cards (CPM/CPC/CPV) — informational variant of the
   stat card. Smaller value, no click affordance, no active state. */
.stat-card.stat-card-secondary {
  cursor: default;
  background: var(--color-surface);
  padding: var(--space-4);
}
.stat-card.stat-card-secondary:hover {
  transform: none;
  box-shadow: var(--shadow-card);
}
.stat-card.stat-card-secondary .stat-value {
  font-size: 20px;
}
.stat-card.stat-card-secondary.active {
  /* Secondary cards never become the active KPI driver. */
  background: var(--color-surface);
}

.stat-label {
  font-size: var(--text-caption);
  font-weight: var(--font-medium);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-2);
}

.stat-value {
  font-size: 28px;
  font-weight: var(--font-bold);
  color: var(--color-text-primary);
  transition: color var(--transition-fast);
}

.stat-change {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-caption);
  font-weight: var(--font-medium);
  margin-top: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

.stat-change.positive {
  color: var(--color-success);
  background: var(--color-success-light);
}

.stat-change.negative {
  color: var(--color-danger);
  background: var(--color-danger-light);
}

/* ============================================
   BADGES
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-caption);
  font-weight: var(--font-semibold);
}

.badge-blue {
  background: var(--color-accent-light);
  color: var(--color-accent);
}

.badge-green {
  background: var(--color-success-light);
  color: var(--color-success);
}

.badge-red {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.badge-amber {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

/* ============================================
   AVATAR
   ============================================ */
.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  color: white;
  font-size: var(--text-caption);
  font-weight: var(--font-semibold);
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-lg {
  width: 48px;
  height: 48px;
  font-size: var(--text-body);
}

/* ============================================
   INPUTS
   ============================================ */
.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.input-label {
  font-size: var(--text-caption);
  font-weight: var(--font-semibold);
  color: var(--color-text-primary);
}

.input-helper {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
}

.input {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-family: var(--font-family);
  font-size: var(--text-body);
  transition: all var(--transition-fast);
}

.input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-light);
}

.input.error {
  border-color: var(--color-danger);
}

.input.error:focus {
  box-shadow: 0 0 0 3px var(--color-danger-light);
}

/* ============================================
   SELECT
   ============================================ */
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
}

/* ============================================
   TABLE
   ============================================ */
.table-container {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-caption);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast);
}

.table th:hover {
  background: var(--color-border-light);
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
  font-size: var(--text-body);
  color: var(--color-text-primary);
}

.table tr:hover td {
  background: var(--color-bg);
}

.table-sort-icon {
  display: inline-block;
  margin-left: var(--space-1);
  opacity: 0.5;
}

/* ============================================
   MODAL
   ============================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal-backdrop);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-default);
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 480px;
  margin: var(--space-4);
  transform: scale(0.95);
  transition: transform var(--transition-default);
}

.modal-backdrop.active .modal {
  transform: scale(1);
}

.modal-header {
  padding: var(--space-5);
  border-bottom: 1px solid var(--color-border-light);
}

.modal-title {
  font-size: var(--text-heading);
  font-weight: var(--font-semibold);
}

.modal-body {
  padding: var(--space-5);
}

.modal-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border-light);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ============================================
   TOAST
   ============================================ */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.toast {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 300px;
  max-width: 400px;
  transform: translateX(100%);
  opacity: 0;
  transition: all var(--transition-default);
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.toast-success .toast-icon {
  color: var(--color-success);
}

.toast-error .toast-icon {
  color: var(--color-danger);
}

.toast-warning .toast-icon {
  color: var(--color-warning);
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: var(--font-semibold);
  color: var(--color-text-primary);
}

.toast-message {
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
}

/* ============================================
   SKELETON
   ============================================ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-border-light) 25%,
    var(--color-border) 50%,
    var(--color-border-light) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================
   CHART CONTAINER
   ============================================ */
.chart-container {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.chart-title {
  font-size: var(--text-subheading);
  font-weight: var(--font-semibold);
  color: var(--color-text-primary);
}

/* KPI card accent colors */
.stat-card[data-metric="impressions"] { border-top: 2px solid var(--color-kpi-impressions); }
.stat-card[data-metric="clicks"]      { border-top: 2px solid var(--color-kpi-clicks); }
.stat-card[data-metric="ctr"]         { border-top: 2px solid var(--color-kpi-ctr); }
.stat-card[data-metric="views"]       { border-top: 2px solid var(--color-kpi-views); }

.stat-card[data-metric="impressions"] .stat-value { color: var(--color-kpi-impressions); }
.stat-card[data-metric="clicks"]      .stat-value { color: var(--color-kpi-clicks); }
.stat-card[data-metric="ctr"]         .stat-value { color: var(--color-kpi-ctr); }
.stat-card[data-metric="views"]       .stat-value { color: var(--color-kpi-views); }

/* stat-label uppercase caps style */
.stat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

/* stat-value bigger and bolder */
.stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--color-text-primary);
}

/* Dark mode — input and select styling */
[data-theme="dark"] .input,
[data-theme="dark"] .select {
  background: var(--color-surface-elevated);
  color: var(--color-text-primary);
  border-color: var(--color-border);
}

/* Dark mode — table row hover */
[data-theme="dark"] .table tbody tr:hover {
  background: var(--color-surface-elevated);
}

/* Dark mode — table header */
[data-theme="dark"] .table thead th {
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Dark mode — chart container */
[data-theme="dark"] .chart-container {
  background: var(--color-surface);
  border-color: var(--color-border);
}

/* Theme toggle button */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.theme-toggle:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* Logo theme switching */
.logo-dark { display: none; }
.logo-light { display: block; }

[data-theme="dark"] .logo-dark { display: none; }
[data-theme="dark"] .logo-light { display: block; }

:root:not([data-theme="dark"]) .logo-dark { display: block; }
:root:not([data-theme="dark"]) .logo-light { display: none; }
