/* Minimal, functional styling only — visual design pass comes later. */

* { box-sizing: border-box; }

body {
  font-family: -apple-system, system-ui, sans-serif;
  margin: 0;
  padding: 2rem;
  color: #141414;
  background: #fafafa;
}

.page { max-width: 960px; margin: 0 auto; }
.page-wide { max-width: 1200px; }

.section-title {
  margin: 2rem 0 0.75rem;
  font-size: 1.1rem;
  border-bottom: 2px solid #141414;
  padding-bottom: 0.4rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.kpi-card-detailed {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.kpi-card-detailed .kpi-label { font-size: 0.8rem; color: #666; }
.kpi-card-detailed .kpi-value { font-size: 1.4rem; font-weight: 600; }
.kpi-sub-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: #555;
  border-top: 1px solid #eee;
  padding-top: 0.35rem;
}
.kpi-sub-row .kpi-sub-label { color: #888; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}
.g2n-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 0.85rem;
  text-align: left;
}
.g2n-card .g2n-label { font-size: 0.78rem; color: #666; display: block; margin-bottom: 0.25rem; }
.g2n-card .g2n-value { font-size: 1.15rem; font-weight: 600; display: block; }
.g2n-card .g2n-change { font-size: 0.78rem; margin-top: 0.2rem; display: block; }

.page-header { margin-bottom: 1.5rem; }
.back-link { font-size: 0.85rem; color: #555; text-decoration: none; }
.back-link:hover { text-decoration: underline; }
.freshness { color: #666; font-size: 0.85rem; margin: 0.25rem 0 0; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 2rem;
}
.kpi-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.kpi-label { font-size: 0.8rem; color: #666; }
.kpi-value { font-size: 1.4rem; font-weight: 600; }

.panel {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
.panel h2 { margin-top: 0; font-size: 1rem; }

.chart-wrap { position: relative; height: 260px; margin-bottom: 1rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: right; padding: 0.4rem 0.6rem; border-bottom: 1px solid #eee; }
th:first-child, td:first-child { text-align: left; }
thead th { color: #666; font-weight: 500; font-size: 0.8rem; }

.delta-positive { color: #1a7f37; }
.delta-negative { color: #c0392b; }
.delta-neutral { color: #999; }

.brand-table a { color: #141414; text-decoration: none; font-weight: 500; }
.brand-table a:hover { text-decoration: underline; }

.subtle-note { color: #777; font-size: 0.82rem; margin: -0.25rem 0 0.75rem; }
.mt { margin-top: 1rem; }

.detail-table-wrap {
  overflow-x: auto;
  max-height: 520px;
  overflow-y: auto;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
}
.detail-table {
  border-collapse: collapse;
  font-size: 0.78rem;
  white-space: nowrap;
}
.detail-table th, .detail-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid #eee;
  border-right: 1px solid #f2f2f2;
  text-align: right;
}
.detail-table thead th {
  position: sticky;
  top: 0;
  background: #fafafa;
  z-index: 2;
  color: #444;
  font-weight: 600;
}
.detail-table .group-row th { top: 0; }
.detail-table .sub-row th { top: 27px; font-weight: 500; color: #777; }

.sticky-col {
  position: sticky;
  background: #fff;
  z-index: 1;
  text-align: left;
}
.sticky-col-1 { left: 0; min-width: 90px; }
.sticky-col-2 { left: 90px; min-width: 50px; }
thead .sticky-col { z-index: 3; background: #fafafa; }

.notes-cell { text-align: left; white-space: normal; min-width: 220px; color: #333; }
.not-connected-cell { color: #999; font-style: italic; text-align: center; }

/* ---- Sidebar layout ---- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  padding: 1.25rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 1rem;
}
.sidebar-nav a {
  display: block;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  color: #333;
  text-decoration: none;
  font-size: 0.85rem;
  margin-bottom: 0.15rem;
}
.sidebar-nav a:hover { background: #f0f0f0; }
.sidebar-nav a.active { background: #141414; color: #fff; font-weight: 600; }
.sidebar-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #999;
  margin: 1rem 0 0.35rem;
}
.content { flex: 1; padding: 2rem; min-width: 0; }
.content .page { margin: 0; max-width: 1200px; }

@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; border-right: none; border-bottom: 1px solid #e0e0e0; }
}

.tab-bar { display: flex; gap: 0.4rem; margin: 1rem 0; }
.tab-btn {
  padding: 0.5rem 1rem; border: 1px solid #e0e0e0; border-radius: 6px;
  background: #fff; cursor: pointer; font-size: 0.85rem; color: #444;
}
.tab-btn.active { background: #141414; color: #fff; border-color: #141414; }
.tab-btn:hover:not(.active) { background: #f0f0f0; }

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: #141414; }
th.sorted-asc::after { content: ' \25B2'; font-size: 0.7em; }
th.sorted-desc::after { content: ' \25BC'; font-size: 0.7em; }

.view-mode-bar { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.5rem; }
#day-select { padding: 0.45rem 0.6rem; border: 1px solid #e0e0e0; border-radius: 6px; font-size: 0.85rem; }

.week-tab-bar {
  display: flex; gap: 0.3rem; overflow-x: auto; padding-bottom: 0.4rem; margin-bottom: 0.25rem;
  scrollbar-width: thin;
}
.week-tab {
  flex-shrink: 0; padding: 0.4rem 0.7rem; border: 1px solid #e0e0e0; border-radius: 5px;
  background: #fff; cursor: pointer; font-size: 0.78rem; color: #555; white-space: nowrap;
}
.week-tab.active { background: #141414; color: #fff; border-color: #141414; }
.week-tab:hover:not(.active) { background: #f0f0f0; }

.table-controls { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin: 0.75rem 0; flex-wrap: wrap; }
#campaign-search {
  padding: 0.45rem 0.7rem; border: 1px solid #e0e0e0; border-radius: 6px;
  font-size: 0.85rem; min-width: 220px;
}
.funnel-filter-bar { display: flex; gap: 0.3rem; }
.funnel-filter-btn { padding: 0.35rem 0.7rem; font-size: 0.78rem; }

.funnel-badge {
  display: inline-block; padding: 0.15rem 0.5rem; border-radius: 4px;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.02em;
}
.funnel-badge-tofu { background: #dbeafe; color: #1e40af; }
.funnel-badge-mofu { background: #fef3c7; color: #92400e; }
.funnel-badge-bofu { background: #fee2e2; color: #b91c1c; }
.funnel-badge-combined { background: #f3e8ff; color: #7e22ce; }
.funnel-badge-none { color: #bbb; }

.panel-inset {
  background: #fafafa; border: 1px solid #eee; border-radius: 6px;
  padding: 1rem; margin: 1rem 0;
}
.panel-inset h4 { margin: 0 0 0.6rem; font-size: 0.85rem; color: #555; text-transform: uppercase; letter-spacing: 0.03em; }
.chart-wrap-medium { height: 220px; }

.kpi-card-highlight { border-color: #c0392b; box-shadow: 0 0 0 1px #c0392b inset; }
.kpi-card .kpi-sub-label { display: block; font-size: 0.75rem; margin-top: 0.2rem; color: #888; }
