/* Reports module — scoped under .rpt- */

.rpt-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.rpt-title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
}

.rpt-sub {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.rpt-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rpt-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg-secondary, #f3f4f6);
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='16' height='16'%3e%3cpath fill='%236b7280' d='M7 10l5 5 5-5z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 30px 7px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

.rpt-select:hover {
  border-color: var(--primary);
}

.rpt-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}

.rpt-main {
  min-width: 0;
}

.rpt-side {
  position: sticky;
  top: 16px;
  background: var(--bg-primary, #fff);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.rpt-side-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 12px;
}

.rpt-side-count {
  background: var(--bg-secondary, #f3f4f6);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  text-transform: none;
  letter-spacing: normal;
}

.rpt-side-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.rpt-side-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.rpt-side-item-btn {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  min-width: 0;
}

.rpt-side-item-btn:hover {
  background: var(--bg-secondary, #f3f4f6);
}

.rpt-side-icon {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: var(--bg-secondary, #f3f4f6);
  color: var(--primary, #00a97f);
  font-size: 0.9rem;
  margin-top: 1px;
}

.rpt-side-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.rpt-side-name {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rpt-side-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rpt-side-item-del {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.15s;
}

.rpt-side-item:hover .rpt-side-item-del {
  opacity: 1;
}

.rpt-side-item-del:hover {
  color: var(--danger);
  background: var(--bg-secondary, #f3f4f6);
}

.rpt-side-suggestion {
  border: 1px dashed var(--border);
}

.rpt-side-build {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: none;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
}

.rpt-side-build:hover {
  background: var(--bg-secondary, #f3f4f6);
}

.rpt-builder-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
}

/* Custom builder — query-summary bar, setup form, chip-style filters, and the
   results card (dynamic title/subtitle, chart + table). */

.rb-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-secondary, #f3f4f6);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: var(--text);
}

.rb-summary-icon {
  color: var(--text-muted);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.rb-summary-text {
  flex: 1;
}

.rb-summary-count {
  font-weight: 700;
  white-space: nowrap;
}

.rb-setup-title {
  margin: 0 0 14px;
  font-size: 0.95rem;
  font-weight: 700;
}

.rb-segmented {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.rb-seg-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 6px;
  background: var(--bg-primary, #fff);
  border: none;
  border-right: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.rb-seg-btn:last-child {
  border-right: none;
}

.rb-seg-btn:hover {
  background: var(--bg-secondary, #f3f4f6);
}

.rb-seg-btn.active {
  background: var(--primary-light, #e6f7f1);
  color: var(--primary, #00a97f);
}

.rb-filter-count {
  color: var(--text-muted);
  font-weight: 500;
}

.rb-chip-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  margin-bottom: 8px;
}

.rb-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-secondary, #f3f4f6);
  border-radius: 8px;
  padding: 6px 8px;
}

.rb-chip-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.rb-chip-select,
.rb-chip-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 2px 4px;
}

.rb-chip-select:focus,
.rb-chip-input:focus {
  outline: none;
  color: var(--text);
}

.rb-chip-custom {
  flex-wrap: wrap;
}

.rb-chip-x {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  flex-shrink: 0;
  border-radius: 4px;
}

.rb-chip-x:hover {
  color: var(--danger);
}

.rb-add-filter {
  width: 100%;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.8rem;
  color: var(--primary, #00a97f);
  font-weight: 600;
  cursor: pointer;
}

.rb-results-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.rb-results-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.rb-results-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.rb-icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.05rem;
  padding: 6px;
  border-radius: 7px;
  cursor: pointer;
}

.rb-icon-btn:hover {
  background: var(--bg-secondary, #f3f4f6);
  color: var(--text);
}

.rb-menu-wrap {
  position: relative;
  display: inline-block;
}

.rb-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--bg-primary, #fff);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-md, 0 4px 16px rgba(0,0,0,0.1));
  min-width: 170px;
  z-index: 20;
  overflow: hidden;
}

.rb-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 9px 12px;
  font-size: 0.8rem;
  color: var(--text);
  cursor: pointer;
}

.rb-menu button:hover {
  background: var(--bg-secondary, #f3f4f6);
}

.rb-chart-wrap {
  margin-bottom: 16px;
}

.rb-chart-wrap canvas {
  width: 100%;
  display: block;
}

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

.rb-results-table th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.rb-results-table td {
  padding: 10px;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.rb-results-table th:not(:first-child),
.rb-results-table td:not(:first-child) {
  text-align: right;
}

.rb-results-table tr:last-child td {
  border-bottom: none;
}

@media (max-width: 720px) {
  .rpt-builder-grid {
    grid-template-columns: 1fr;
  }
}

/* A plain, sentence-case stat-tile label — used where the reference design
   calls for quieter labels than the shared (uppercase, letter-spaced)
   .stat-label class. */
.rpt-stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 2px;
}

/* Overview tab — stat tiles with a period delta, and the pipeline-by-stage
   table with an inline value bar per row. */

.rpt-stat-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 2px;
}

.rpt-stat-row .stat-value {
  margin-bottom: 0;
}

.rpt-stat-sub {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.rpt-delta {
  font-size: 0.82rem;
  font-weight: 700;
}

.rpt-delta-up {
  color: var(--success, #16a34a);
}

.rpt-delta-down {
  color: var(--danger, #dc2626);
}

.rpt-stage-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: -6px 0 16px;
}

.rpt-stage-table {
  display: flex;
  flex-direction: column;
}

.rpt-stage-head,
.rpt-stage-row {
  display: grid;
  grid-template-columns: 140px 1fr 70px 110px 90px;
  align-items: center;
  gap: 16px;
}

.rpt-stage-head {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.rpt-stage-head span:nth-child(n+3),
.rpt-stage-num {
  text-align: right;
}

.rpt-stage-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.rpt-stage-row:last-child {
  border-bottom: none;
}

.rpt-stage-name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rpt-stage-bar-track {
  height: 10px;
  background: var(--bg-secondary, #f3f4f6);
  border-radius: 5px;
  overflow: hidden;
}

.rpt-stage-bar {
  display: block;
  height: 100%;
  border-radius: 5px;
  transition: width 0.4s ease;
}

.rpt-stage-num {
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.rpt-stage-age {
  font-weight: 500;
  color: var(--text-muted);
}

.rpt-stage-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.rpt-legend {
  display: flex;
  align-items: center;
  gap: 16px;
}

.rpt-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.rpt-legend-item i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.rpt-stage-summary {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Funnel tab — cumulative lifecycle funnel with a drop-off line between each
   bar, and the "biggest drop-off" stat tile/annotation highlighted in amber. */

.rpt-funnel-stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 2px;
}

.rpt-funnel-dropoff-value {
  color: #b45309;
}

.rpt-funnel-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: -6px 0 18px;
}

.rpt-funnel {
  display: flex;
  flex-direction: column;
}

.rpt-funnel-row {
  display: grid;
  grid-template-columns: 90px 1fr 36px 44px;
  align-items: center;
  gap: 14px;
}

.rpt-funnel-label {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rpt-funnel-bar-track {
  height: 28px;
  background: var(--bg-secondary, #f3f4f6);
  border-radius: 6px;
  overflow: hidden;
}

.rpt-funnel-bar {
  display: block;
  height: 100%;
  border-radius: 6px;
  transition: width 0.4s ease;
}

.rpt-funnel-count {
  font-size: 0.9rem;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.rpt-funnel-pct {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.rpt-funnel-drop {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 6px 104px;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.rpt-funnel-drop-tick {
  width: 14px;
  height: 1px;
  background: var(--border);
  flex-shrink: 0;
}

.rpt-funnel-drop-biggest {
  color: #b45309;
  font-weight: 700;
}

.rpt-funnel-drop-biggest .rpt-funnel-drop-tick {
  background: #b45309;
}

.rpt-funnel-drop-tag {
  font-weight: 700;
}

@media (max-width: 640px) {
  .rpt-funnel-row {
    grid-template-columns: 64px 1fr 30px 36px;
    gap: 8px;
  }

  .rpt-funnel-drop {
    margin-left: 72px;
  }
}

@media (max-width: 640px) {
  .rpt-stage-head,
  .rpt-stage-row {
    grid-template-columns: 90px 1fr 50px;
  }

  .rpt-stage-value,
  .rpt-stage-age,
  .rpt-stage-head span:nth-child(4),
  .rpt-stage-head span:nth-child(5) {
    display: none;
  }
}

@media (max-width: 960px) {
  .rpt-layout {
    grid-template-columns: 1fr;
  }

  .rpt-side {
    position: static;
  }

  .rpt-builder-grid {
    grid-template-columns: 1fr;
  }
}

/* Email & campaigns tab — campaign performance table with an inline open-rate
   bar per row, colored blue normally and amber when a campaign is
   significantly underperforming the period's average open rate. */

.rpt-camp-good {
  color: #2563eb;
}

.rpt-camp-warn {
  color: #d97706;
}

.rpt-camp-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

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

.rpt-camp-table th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.rpt-camp-table td {
  padding: 12px 16px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.rpt-camp-table tr:last-child td {
  border-bottom: none;
}

.rpt-camp-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.rpt-camp-rate-col {
  min-width: 180px;
}

.rpt-camp-name {
  font-weight: 600;
  color: var(--text);
}

.rpt-camp-sent {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.rpt-camp-rate {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rpt-camp-rate-track {
  flex: 1;
  height: 8px;
  background: var(--bg-secondary, #f3f4f6);
  border-radius: 4px;
  overflow: hidden;
  min-width: 70px;
}

.rpt-camp-rate-bar {
  display: block;
  height: 100%;
  border-radius: 4px;
}

.rpt-camp-good-bg {
  background: #3b82f6;
}

.rpt-camp-warn-bg {
  background: #d97706;
}

@media (max-width: 720px) {
  .rpt-camp-rate-col {
    min-width: 120px;
  }

  .rpt-camp-table th:nth-child(3),
  .rpt-camp-table td:nth-child(3) {
    display: none;
  }
}

/* Forecast tab — the quarterly-goal card's two-segment progress bar (closed
   won + weighted forecast layered on top), and the stage table's total row
   and "oldest deal" staleness flag. */

.rpt-goal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.rpt-goal-days {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.rpt-goal-track {
  display: flex;
  height: 14px;
  background: var(--bg-secondary, #f3f4f6);
  border-radius: 7px;
  overflow: hidden;
}

.rpt-goal-seg {
  height: 100%;
  transition: width 0.4s ease;
}

.rpt-goal-seg-won {
  background: #16a34a;
}

.rpt-goal-seg-weighted {
  background: #93c5fd;
}

.rpt-goal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.rpt-goal-footer .rpt-legend-item b {
  color: var(--text);
  font-weight: 700;
}

.rpt-goal-gap {
  font-size: 0.8rem;
  font-weight: 700;
  color: #b45309;
}

.rpt-goal-gap-met {
  color: #16a34a;
}

.rpt-goal-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

.rpt-goal-empty a {
  color: var(--primary, #00a97f);
  font-weight: 600;
}

.rpt-forecast-weighted {
  font-weight: 700;
}

.rpt-forecast-total td {
  font-weight: 700;
  border-top: 2px solid var(--border);
  border-bottom: none;
}

/* Tickets tab — priority/stage bar rows, and the "oldest open tickets" table
   with a colored priority dot per row. */

/* .card-header is a shared flex ROW (title + right-aligned action), so a
   title+subtitle pair must be wrapped in their own column to stack instead
   of being laid out as two side-by-side flex items — most visible on this
   tab's narrower two-column cards. */
.rpt-card-head-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rpt-tickets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.rpt-bar-row {
  display: grid;
  grid-template-columns: 80px 1fr 28px;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
}

.rpt-bar-row + .rpt-bar-row {
  border-top: 1px solid var(--border);
}

.rpt-bar-label {
  font-size: 0.85rem;
  font-weight: 600;
}

.rpt-bar-track {
  height: 10px;
  background: var(--bg-secondary, #f3f4f6);
  border-radius: 5px;
  overflow: hidden;
}

.rpt-bar-fill {
  display: block;
  height: 100%;
  border-radius: 5px;
  transition: width 0.4s ease;
}

.rpt-bar-count {
  font-size: 0.85rem;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.rpt-pri-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 7px;
}

.rpt-tickets-table td,
.rpt-tickets-table th {
  white-space: nowrap;
}

.rpt-tickets-table td:first-child {
  white-space: normal;
}

.rpt-tickets-company {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 860px) {
  .rpt-tickets-grid {
    grid-template-columns: 1fr;
  }
}
