/* Cohort ROAS Report Styles — Modernized Dashboard Architecture */

.coh-page {
  max-width: 1560px;
  margin: 0 auto;
  color: var(--ink);
  padding-bottom: 10px;
}

/* 1. Unified Filter Bar */
.coh-filter-bar {
  display: flex;
  position: relative;
  z-index: 20;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  background: #f5f6f8;
  border: 1px solid #f0f1f3;
  border-radius: 15px;
  padding: 10px 12px;
}

.coh-filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.coh-filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #eceef1;
  border-radius: 11px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(28, 39, 56, 0.04);
  transition: border-color .15s, box-shadow .15s;
}

.coh-filter-item:focus-within {
  border-color: #f0b28e;
  box-shadow: 0 0 0 2px rgba(232, 90, 12, 0.09);
}

.coh-initial-state {
  min-height: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
}

.coh-initial-state h2 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 650;
}

.coh-initial-state p {
  max-width: 430px;
  margin: 8px 0 0;
  color: var(--ink3);
  font-size: 13px;
  line-height: 1.6;
}

.coh-page > .coh-filter-bar {
  margin-bottom: 12px;
  padding: 7px 9px;
}

.coh-page .coh-filter-item {
  min-height: 40px;
  padding: 0 10px;
}

.coh-page .coh-dropdown-trigger {
  min-height: 34px;
}

.coh-filter-label {
  color: #718096;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.coh-dropdown {
  position: relative;
  display: flex;
  align-items: center;
}

.coh-dropdown-trigger {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 0;
  padding: 0 2px 0 0;
  background: transparent;
  color: #29384c;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.coh-dropdown-trigger:focus-visible {
  outline: 2px solid rgba(232, 90, 12, 0.28);
  outline-offset: 3px;
  border-radius: 3px;
}

.coh-dropdown-caret {
  width: 7px;
  height: 7px;
  flex: none;
  margin: -4px 3px 0 0;
  border-right: 1.7px solid #8390a1;
  border-bottom: 1.7px solid #8390a1;
  transform: rotate(45deg);
  transition: transform .15s;
}

.coh-dropdown.open .coh-dropdown-caret {
  margin-top: 4px;
  transform: rotate(225deg);
}

.coh-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 7px);
  left: -13px;
  z-index: 100;
  min-width: 100%;
  width: max-content;
  max-width: min(320px, calc(100vw - 32px));
  padding: 5px;
  border: 1px solid #e9edf2;
  border-radius: 11px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(31, 43, 59, 0.16), 0 2px 6px rgba(31, 43, 59, 0.06);
}

.coh-dropdown.open .coh-dropdown-menu {
  display: flex;
  flex-direction: column;
}

.coh-dropdown-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: 100%;
  min-height: 36px;
  border: 0;
  border-radius: 7px;
  padding: 0 10px;
  background: transparent;
  color: #3b4a5d;
  font-size: 12.5px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: background .12s, color .12s;
}

.coh-dropdown-option:hover {
  background: #f5f7fa;
  color: #202f43;
}

.coh-dropdown-option.selected {
  background: #fff1e8;
  color: var(--od);
  font-weight: 650;
}

.coh-dropdown-option i {
  width: 14px;
  color: var(--o);
  font-size: 13px;
  font-style: normal;
  text-align: center;
}

.coh-dropdown[data-cohort-dropdown="campaign"] .coh-dropdown-trigger {
  width: 220px;
  max-width: 220px;
}

.coh-dropdown[data-cohort-dropdown="campaign"] .coh-dropdown-trigger > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.coh-dropdown[data-cohort-dropdown="brand"] .coh-dropdown-trigger {
  min-width: 132px;
}

.coh-dropdown[data-cohort-dropdown="revenueType"] .coh-dropdown-trigger {
  min-width: 55px;
}

.coh-dropdown[data-cohort-dropdown="campaign"] .coh-dropdown-menu {
  min-width: 280px;
  max-height: min(360px, calc(100vh - 180px));
  overflow-y: auto;
}

.coh-campaign-option {
  justify-content: flex-start;
  gap: 9px;
}

.coh-campaign-checkbox {
  width: 15px;
  height: 15px;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  border: 1px solid #c9d0d9;
  border-radius: 4px;
  background: #ffffff;
  color: #ffffff;
  font-size: 10px;
  line-height: 1;
}

.coh-campaign-checkbox.checked {
  border-color: var(--o);
  background: var(--o);
}

.coh-campaign-option-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.coh-dropdown[data-cohort-dropdown="window"] .coh-dropdown-trigger {
  min-width: 148px;
}

.coh-filter-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.coh-view-toggle {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid #e8ebef;
  border-radius: 11px;
  background: #e9edf2;
}

.coh-view-toggle button {
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #566579;
  padding: 0 12px;
  height: 32px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.coh-view-toggle.compact button {
  height: 27px;
  padding: 0 10px;
  font-size: 11.5px;
}

.coh-matrix-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.coh-matrix-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 7px;
  margin-left: auto;
}

.coh-matrix-actions .coh-view-toggle {
  gap: 1px;
  padding: 2px;
  border-radius: 8px;
}

.coh-matrix-actions .coh-view-toggle button {
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 10.5px;
}

.coh-revenue-mode-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 22px;
}

.coh-radio-option {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #69717c;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.coh-radio-option input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--o);
}

.coh-view-toggle button.on {
  background: #ffffff;
  color: #28364a;
  box-shadow: 0 1px 3px rgba(28, 39, 56, 0.12);
}

/* 2. Executive KPI Grid */
.coh-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.coh-kpi-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.coh-kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.coh-kpi-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.coh-kpi-val {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 4px 0 1px;
  font-variant-numeric: tabular-nums;
}

.coh-kpi-sub {
  font-size: 11.5px;
  color: var(--ink3);
  line-height: 1.4;
}

.coh-kpi-sub strong {
  color: var(--ink2);
  font-weight: 600;
}

/* 3. Primary Heatmap Matrix Card */
.coh-matrix-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  margin-bottom: 0;
}

.coh-matrix-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 88px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.coh-matrix-head h3 {
  font-size: 15px;
  font-weight: 750;
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.01em;
}

.coh-matrix-head p {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--ink3);
}

.coh-matrix-heading {
  min-width: 260px;
}

.coh-heat-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 18px;
  font-size: 11px;
  color: var(--ink2);
  flex-wrap: wrap;
}

.coh-legend-label {
  font-size: 11px;
  font-weight: 650;
  color: var(--ink3);
  margin-right: 2px;
}

.coh-legend-key {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink2);
}

.coh-legend-key i {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  display: inline-block;
}

.coh-legend-low { background: #fef4ec; border: 1px solid #fed7aa; }
.coh-legend-warm { background: #fedec6; }
.coh-legend-near { background: #fdb884; }
.coh-legend-target { background: #f97316; }
.coh-legend-super { background: #c2410c; }

.coh-revenue-swatch {
  display: inline-block;
  width: 15px;
  height: 11px;
  border-radius: 3px;
}

.coh-legend-end {
  color: var(--ink3);
  font-size: 10px;
}

/* Table Component */
.coh-table-scroll {
  overflow: auto;
  max-height: max(180px, calc(100vh - 330px));
  min-height: 180px;
}

.coh-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-family: var(--sans);
}

.coh-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  height: 35px;
  padding: 0 10px;
  background: #faf9f8;
  border-right: 1px solid #f0ece8;
  border-bottom: 1px solid #e7e2de;
  color: var(--ink2);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.coh-table .coh-sticky {
  position: sticky;
  z-index: 2;
  background: #ffffff;
}

.coh-table thead .coh-sticky {
  z-index: 6;
  background: #faf9f8;
}

.coh-table .coh-date-col {
  left: 0;
  width: 120px;
  min-width: 120px;
  text-align: left;
  padding-left: 18px;
}

.coh-table .coh-installs-col {
  left: 120px;
  width: 76px;
  min-width: 76px;
  text-align: right;
}

.coh-table .coh-spend-col {
  left: 196px;
  width: 88px;
  min-width: 88px;
  text-align: right;
}

.coh-table .coh-ecpi-col {
  left: 284px;
  width: 78px;
  min-width: 78px;
  text-align: right;
  border-right: 2px solid #e2ddd8 !important;
}

.coh-table tbody td {
  height: 34px;
  padding: 0 6px;
  border-right: 1px solid #ffffff;
  border-bottom: 1px solid #ffffff;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}

.coh-table tbody .coh-date-cell {
  color: var(--ink);
  font-weight: 600;
  font-size: 11.5px;
}

.coh-table tbody .coh-num-cell {
  color: var(--ink2);
  text-align: right;
  padding-right: 12px;
}

.coh-roas-pill {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 99px;
  background: #fff2ea;
  color: #c2410c;
  font-size: 10.5px;
  font-weight: 700;
}

.coh-roas-pill.target-met {
  background: #ecfdf5;
  color: #047857;
}

/* Heatmap cell color grades */
.coh-table .coh-heat-cell {
  cursor: default;
}

.coh-table .coh-cell-val {
  display: inline-block;
  width: 100%;
  text-align: center;
}

.coh-table .coh-heat-empty {
  background: #fafaf9;
  color: #d6ceca;
  text-align: center;
  font-size: 12px;
}

.coh-empty-dash {
  font-weight: 700;
  opacity: 0.6;
}

.coh-heat-low {
  background: #fef4ec;
  color: #8a5736;
}

.coh-heat-warm {
  background: #fedec6;
  color: #853e0d;
}

.coh-heat-near {
  background: #fdb884;
  color: #6e2d05;
}

.coh-heat-target {
  background: #f97316;
  color: #ffffff;
}

.coh-heat-super {
  background: #c2410c;
  color: #ffffff;
}

.coh-revenue-1 { background: #fff1ec; color: #9b341c; }
.coh-revenue-2 { background: #ffd9cc; color: #8f2f17; }
.coh-revenue-3 { background: #ffb49c; color: #762914; }
.coh-revenue-4 { background: #ff8665; color: #ffffff; }
.coh-revenue-5 { background: #f04417; color: #ffffff; }

/* Responsive adjustments */
@media (max-width: 1200px) {
  .coh-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .coh-table-scroll {
    max-height: max(180px, calc(100vh - 350px));
  }
}

@media (max-width: 800px) {
  .coh-filter-bar {
    align-items: stretch;
  }

  .coh-filter-group {
    width: 100%;
  }

  .coh-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .coh-matrix-head {
    align-items: flex-start;
  }

  .coh-matrix-controls {
    margin-left: 0;
  }

  .coh-table-scroll {
    max-height: max(180px, calc(100vh - 430px));
  }
}

@media (max-width: 520px) {
  .coh-filter-group {
    flex-direction: column;
    align-items: stretch;
  }

  .coh-filter-item {
    justify-content: space-between;
  }

  .coh-kpi-grid {
    grid-template-columns: 1fr;
  }

  .coh-matrix-head {
    flex-direction: column;
  }

  .coh-matrix-controls {
    width: 100%;
    align-items: flex-start;
    margin-left: 0;
  }
}
