/* Dashboard Styles */
:root {
  --primary-color: #2563eb;
  --success-color: #16a34a;
  --danger-color: #dc2626;
  --warning-color: #ca8a04;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.5;
  padding: 20px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

/* Header */
.header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-200);
}

.header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 4px;
}

.header .timestamp {
  font-size: 0.875rem;
  color: var(--gray-500);
}

/* Loading & Error States */
.loading, .error {
  text-align: center;
  padding: 60px 20px;
}

.loading {
  color: var(--gray-500);
}

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

.error h2 {
  margin-bottom: 12px;
}

.error code {
  display: block;
  background: var(--gray-100);
  padding: 12px;
  border-radius: 6px;
  margin-top: 12px;
  font-size: 0.875rem;
  color: var(--gray-700);
}

/* Archive Divider */
.archive-divider {
  margin: 40px 0 20px 0;
  padding: 16px 20px;
  background: var(--gray-200);
  border-radius: 8px;
  border-left: 4px solid var(--gray-500);
}

.archive-divider h3 {
  margin: 0 0 4px 0;
  color: var(--gray-700);
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.archive-divider p {
  margin: 0;
  color: var(--gray-500);
  font-size: 0.875rem;
}

/* Section */
.section {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  margin-bottom: 20px;
  overflow: hidden;
}

.section-header {
  background: var(--gray-100);
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
}

.section-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-700);
}

.section-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.section-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  background: white;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-600);
}

.section-toggle-btn:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
}

.section-toggle-btn.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.section-collapsible .section-body {
  padding: 16px;
}

.header-buttons {
  display: flex;
  gap: 8px;
}

.toggle-btn {
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--gray-600);
  background: white;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.toggle-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.toggle-btn.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

.section-body {
  padding: 16px;
}

/* Config Grid */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.config-item {
  display: flex;
  flex-direction: column;
}

.config-item .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--gray-500);
  margin-bottom: 2px;
}

.config-item .value {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--gray-900);
}

/* Config Timeline */
.config-timeline {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
}

.timeline-container {
  display: flex;
  align-items: flex-start;
  gap: 0;
}

.timeline-segment {
  flex: 1;
  text-align: center;
}

.segment-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.pre-rollout .segment-label {
  color: var(--gray-600);
}

.post-rollout .segment-label {
  color: var(--primary-color);
}

.segment-bar {
  height: 12px;
  border-radius: 6px;
}

.pre-rollout .segment-bar {
  background: #9ca3af;
  border-radius: 6px 0 0 6px;
  margin-right: -1px;
}

.post-rollout .segment-bar {
  background: var(--primary-color);
  border-radius: 0 6px 6px 0;
  margin-left: -1px;
}

.segment-dates {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--gray-500);
  padding: 0 4px;
}

.timeline-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 8px;
  position: relative;
  z-index: 1;
}

.marker-line {
  width: 3px;
  height: 12px;
  background: #9333ea;
  border-radius: 2px;
  margin-top: 22px;
}

.marker-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #9333ea;
  text-transform: uppercase;
  margin-top: 4px;
}

.marker-date {
  font-size: 0.7rem;
  color: #9333ea;
  white-space: nowrap;
}

/* Summary Cards */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.summary-card {
  background: var(--gray-50);
  border-radius: 6px;
  padding: 16px;
  border: 1px solid var(--gray-200);
}

.summary-card .card-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 12px;
}

.summary-card .rate {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 4px;
}

.summary-card .stats {
  font-size: 0.875rem;
  color: var(--gray-500);
  margin-bottom: 8px;
}

.summary-card .change {
  font-size: 0.875rem;
  font-weight: 500;
}

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

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

.change.neutral {
  color: var(--gray-500);
}

/* Chart Container */
.chart-container {
  height: 400px;
  position: relative;
}

.chart-unavailable {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--gray-500);
  background: var(--gray-50);
  border-radius: 6px;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

th {
  background: var(--gray-50);
  font-weight: 600;
  color: var(--gray-700);
  white-space: nowrap;
}

td {
  color: var(--gray-900);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--gray-50);
}

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

.font-mono {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 0.8rem;
}

/* Aggregate Row */
tr.aggregate {
  font-weight: 600;
  background: var(--gray-100);
}

tr.aggregate td {
  border-top: 2px solid var(--gray-300);
}

/* Robocall Stats */
.robocall-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-item {
  background: var(--gray-50);
  padding: 12px;
  border-radius: 6px;
  text-align: center;
}

.stat-item .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

.stat-item .stat-label {
  font-size: 0.75rem;
  color: var(--gray-500);
  text-transform: uppercase;
}

/* Breakdown Pie Chart */
.breakdown-chart-container {
  max-width: 400px;
  margin: 20px auto;
  position: relative;
}

/* Breakdown Table Sections */
.breakdown-table-section {
  margin-top: 16px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  overflow: hidden;
}

.breakdown-table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.breakdown-table-header h4 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-700);
}

.table-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--gray-600);
  background: white;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.table-toggle-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.table-toggle-btn.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

.toggle-icon {
  font-weight: 700;
  font-size: 0.9rem;
}

.breakdown-table-content {
  padding: 16px;
}

.breakdown-table-section .table-wrapper {
  margin: 0;
}

/* Collapsible Table Sections (for daily rates) */
.collapsible-table-section {
  margin-top: 20px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  overflow: hidden;
}

.collapsible-table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.collapsible-table-header h4 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-700);
}

.collapsible-table-content {
  padding: 16px;
}

.collapsible-table-section .table-wrapper {
  margin: 0;
}

/* Reason Breakdown */
.reason-breakdown {
  margin-top: 16px;
}

.reason-item {
  padding: 12px;
  background: var(--gray-50);
  border-radius: 6px;
  margin-bottom: 8px;
}

.reason-item:last-child {
  margin-bottom: 0;
}

.reason-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.reason-name {
  font-weight: 600;
  color: var(--gray-700);
}

.reason-count {
  background: var(--warning-color);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.patient-list {
  font-size: 0.8rem;
  color: var(--gray-500);
}

.patient-id {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 0.7rem;
}

/* Responsive */
@media (max-width: 768px) {
  body {
    padding: 12px;
  }

  .header h1 {
    font-size: 1.5rem;
  }

  .summary-card .rate {
    font-size: 1.5rem;
  }

  .section-body {
    padding: 12px;
  }
}

/* Control Panel */
.section.control-panel {
  position: relative;
  z-index: 10;
  overflow: visible !important;
}

.control-panel .section-body {
  padding: 16px;
  overflow: visible;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 24px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  gap: 6px;
}

.control-label input[type="checkbox"] {
  margin: 0;
}

/* Date Picker */
.date-picker-wrapper {
  position: relative;
}

.date-picker-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: white;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--gray-700);
  cursor: pointer;
  min-width: 160px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.date-picker-btn:hover {
  border-color: var(--primary-color);
}

.date-picker-btn:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.date-picker-btn svg {
  color: var(--gray-500);
}

/* Calendar Dropdown */
.calendar-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  z-index: 1000;
  padding: 12px;
  min-width: 280px;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.calendar-title {
  font-weight: 600;
  color: var(--gray-700);
}

.calendar-nav {
  background: none;
  border: none;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--gray-500);
  font-size: 1rem;
  border-radius: 4px;
}

.calendar-nav:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-500);
  margin-bottom: 8px;
}

.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--gray-700);
  border: none;
  background: none;
}

.calendar-day:hover:not(.disabled):not(.selected) {
  background: var(--gray-100);
}

.calendar-day.other-month {
  color: var(--gray-300);
}

.calendar-day.today {
  font-weight: 600;
  color: var(--primary-color);
}

.calendar-day.selected {
  background: var(--primary-color);
  color: white;
}

.calendar-day.disabled {
  color: var(--gray-300);
  cursor: not-allowed;
}

/* Cache Status */
.cache-status {
  font-size: 0.8rem;
  color: var(--gray-500);
  max-width: 200px;
}

.cache-status.available {
  color: var(--success-color);
}

.cache-status.partial {
  color: #f59e0b; /* Amber/warning color for partial refresh */
}

.cache-status.unavailable {
  color: var(--warning-color);
}

/* Filter Hint */
.filter-hint {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 2px;
}

/* Run Button */
.run-btn {
  padding: 10px 20px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 18px;
}

.run-btn:hover:not(:disabled) {
  background: #1d4ed8;
}

.run-btn:disabled {
  background: var(--gray-300);
  cursor: not-allowed;
}

.run-btn.running {
  background: var(--gray-500);
}

.run-btn.secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.run-btn.secondary:hover:not(:disabled) {
  background: var(--gray-200);
  border-color: var(--gray-400);
}

.date-action-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Analysis Status */
.analysis-status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.875rem;
}

.analysis-status.running {
  background: #eff6ff;
  color: var(--primary-color);
}

.analysis-status.success {
  background: #f0fdf4;
  color: var(--success-color);
}

.analysis-status.error {
  background: #fef2f2;
  color: var(--danger-color);
}

.analysis-status.warning {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fcd34d;
}

.refresh-cache-btn {
  margin-left: 12px;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 500;
  color: white;
  background: #b45309;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}

.refresh-cache-btn:hover {
  background: #92400e;
}

/* Confounder Tooltip */
.confounder-tooltip {
  position: fixed;
  z-index: 1000;
  max-width: 320px;
  padding: 12px 14px;
  background: white;
  border: 1px solid var(--gray-200);
  border-left: 4px solid #dc2626;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-size: 0.85rem;
  pointer-events: none;
}

.confounder-tooltip-title {
  font-weight: 600;
  color: #dc2626;
  margin-bottom: 4px;
}

.confounder-tooltip-date {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-bottom: 8px;
}

.confounder-tooltip-desc {
  color: var(--gray-700);
  line-height: 1.4;
}

/* Side Navigation */
.side-nav {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.side-nav-title {
  padding: 8px 14px;
  background: var(--gray-700);
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 0 6px 0 0;
  border-left: none;
}

.side-nav-divider {
  padding: 8px 14px;
  background: var(--gray-200);
  color: var(--gray-600);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-left: none;
  margin-top: 8px;
}

.side-nav-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: white;
  border: 1px solid var(--gray-200);
  border-left: none;
  border-radius: 0 6px 6px 0;
  color: var(--gray-600);
  text-decoration: none;
  transition: all 0.2s;
  box-shadow: 2px 2px 8px rgba(0,0,0,0.08);
}

.side-nav-item:first-of-type {
  border-radius: 0;
}

.side-nav-item:last-of-type {
  border-radius: 0 0 6px 0;
}

.side-nav-item:hover {
  background: var(--gray-50);
  color: var(--primary-color);
}

.side-nav-item.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

.side-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.side-nav-label {
  font-size: 0.875rem;
  font-weight: 500;
  margin-left: 10px;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .side-nav {
    display: none;
  }
}

/* Print Styles */
@media print {
  body {
    background: white;
    padding: 0;
  }

  .section {
    box-shadow: none;
    border: 1px solid var(--gray-200);
    break-inside: avoid;
  }

  .chart-container {
    height: 250px;
  }
}

/* Extend Controls for Tables */
.extend-controls {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.extend-controls .more-count {
  color: var(--gray-500);
  font-size: 0.875rem;
}

.extend-btn {
  padding: 6px 12px;
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.15s;
}

.extend-btn:hover {
  background: var(--gray-200);
  border-color: var(--gray-400);
}

.extend-btn:active {
  background: var(--gray-300);
}

/* ========================================
   Insights Section Styles
   ======================================== */

.insights-subsection {
  margin-bottom: 32px;
}

.insights-subsection:last-child {
  margin-bottom: 0;
}

.insights-subsection h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--gray-200);
}

.insights-subsection h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gray-700);
  margin: 20px 0 12px 0;
}

.insights-meta {
  font-size: 0.875rem;
  color: var(--gray-500);
  margin-bottom: 12px;
}

/* Insights Table */
.insights-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.insights-table th,
.insights-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

.insights-table th {
  background: var(--gray-50);
  font-weight: 600;
  color: var(--gray-700);
}

.insights-table .highlight-row {
  background: #fef2f2;
}

.insights-table .highlight-row.negative td {
  color: var(--danger-color);
}

.text-danger {
  color: var(--danger-color) !important;
  font-weight: 600;
}

/* Insight Cards */
.insights-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 16px;
}

.insights-cards.no-effect {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.insight-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 16px;
  transition: box-shadow 0.2s;
}

.insight-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.insight-card.impact-high {
  border-left: 4px solid var(--danger-color);
}

.insight-card.impact-medium {
  border-left: 4px solid var(--warning-color);
}

.insight-card.neutral {
  border-left: 4px solid var(--gray-400);
  background: var(--gray-50);
}

.insight-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.insight-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--gray-800);
}

.impact-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 12px;
  white-space: nowrap;
}

.impact-badge.impact-high {
  background: #fecaca;
  color: #b91c1c;
}

.impact-badge.impact-medium {
  background: #fef3c7;
  color: #92400e;
}

.impact-badge.neutral {
  background: var(--gray-200);
  color: var(--gray-600);
}

.insight-hypothesis,
.insight-finding {
  font-size: 0.85rem;
  color: var(--gray-600);
  margin-bottom: 8px;
  line-height: 1.5;
}

.insight-conclusion {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-800);
  background: var(--gray-50);
  padding: 8px 10px;
  border-radius: 4px;
  margin-top: 8px;
}

.insight-card.neutral .insight-conclusion {
  background: white;
}

/* Future Steps */
.future-steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.future-steps-column {
  background: var(--gray-50);
  border-radius: 8px;
  padding: 16px;
}

.future-steps-column h4 {
  margin-top: 0;
  margin-bottom: 12px;
}

.steps-list {
  margin: 0;
  padding-left: 20px;
}

.steps-list li {
  font-size: 0.875rem;
  color: var(--gray-700);
  margin-bottom: 8px;
  line-height: 1.5;
}

.steps-list.questions li {
  color: var(--gray-600);
}

.decision-table {
  margin-bottom: 20px;
}

.decision-table .insights-table {
  max-width: 600px;
}

/* Key Takeaway */
.insights-subsection.takeaway h3 {
  border-bottom-color: var(--primary-color);
}

.takeaway-box {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #bfdbfe;
  border-left: 4px solid var(--primary-color);
  border-radius: 8px;
  padding: 20px;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--gray-800);
}

/* Responsive adjustments for insights */
@media (max-width: 768px) {
  .insights-cards {
    grid-template-columns: 1fr;
  }

  .future-steps-grid {
    grid-template-columns: 1fr;
  }

  .insight-card-header {
    flex-direction: column;
    gap: 8px;
  }
}

/* ================================================
   CASE-CONTROL REPORT STYLES
   ================================================ */

.case-control-subsection {
  margin-bottom: 32px;
}

.case-control-subsection h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--gray-200);
}

/* Summary Cards */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.summary-card {
  background: white;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  border: 1px solid var(--gray-200);
}

.summary-card.cases {
  border-left: 4px solid var(--danger-color);
}

.summary-card.controls {
  border-left: 4px solid var(--success-color);
}

.summary-card.gap {
  border-left: 4px solid var(--warning-color);
}

.summary-label {
  font-size: 0.85rem;
  color: var(--gray-600);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.summary-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 4px;
}

.summary-detail {
  font-size: 0.85rem;
  color: var(--gray-500);
}

/* Section Summaries (Hypothesis/Findings) */
.section-summaries {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-summary-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
}

.section-summary-header {
  background: var(--gray-100);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--gray-200);
}

.section-number {
  background: var(--primary-color);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  flex-shrink: 0;
}

.section-title {
  font-weight: 600;
  color: var(--gray-800);
  font-size: 0.95rem;
}

.section-summary-body {
  padding: 16px;
}

.hypothesis-row,
.findings-row {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--gray-700);
}

.hypothesis-row {
  margin-bottom: 8px;
}

.findings-row {
  background: #fefce8;
  padding: 8px 12px;
  border-radius: 4px;
  border-left: 3px solid var(--warning-color);
}

/* Case-Control Tables */
.case-control-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.case-control-table th,
.case-control-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-200);
}

.case-control-table th {
  background: var(--gray-100);
  font-weight: 600;
  text-align: left;
  color: var(--gray-700);
}

.case-control-table .group-header td {
  background: var(--gray-50);
  font-weight: 600;
  color: var(--gray-800);
  padding-top: 16px;
}

.case-control-table .indent {
  padding-left: 24px;
}

.case-control-table .subtotal {
  background: var(--gray-100);
  font-weight: 600;
}

.case-control-table .subtotal td {
  border-top: 2px solid var(--gray-300);
}

/* Key Insights Grid */
.key-insights-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.key-insight-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 16px;
}

.key-insight-title {
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 12px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--gray-200);
  padding-bottom: 8px;
}

.key-insight-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.key-insight-list li {
  font-size: 0.85rem;
  color: var(--gray-700);
  padding: 6px 0;
  padding-left: 16px;
  position: relative;
}

.key-insight-list li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--primary-color);
}

/* Expand/Collapse Button */
.expand-table-btn {
  margin-left: auto;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s;
}

.expand-table-btn:hover {
  background: #1d4ed8;
}

.expand-table-btn.active {
  background: var(--gray-600);
}

.expand-icon {
  font-weight: bold;
  font-size: 1rem;
  line-height: 1;
}

/* Expandable Table Content */
.section-table-content {
  border-top: 1px solid var(--gray-200);
  padding: 16px;
  background: var(--gray-50);
}

.section-table-content .table-wrapper {
  overflow-x: auto;
}

/* Table highlight for important values */
.highlight-cell {
  background: #dcfce7;
  font-weight: 600;
  color: var(--success-color);
}

.table-highlight {
  margin-top: 12px;
  padding: 8px 12px;
  background: #fef3c7;
  border-left: 3px solid var(--warning-color);
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--gray-700);
}

/* Case-Control Date Controls */
.case-control-controls {
  margin-bottom: 24px;
  padding: 16px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
}

.date-range-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.date-input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.date-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-700);
}

.optional-label {
  font-weight: 400;
  color: var(--gray-500);
  font-size: 0.75rem;
}

.date-input {
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  min-width: 160px;
  background: white;
}

.date-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.date-action-group {
  display: flex;
  align-items: flex-end;
}

.cc-run-btn {
  padding: 8px 20px;
  font-size: 0.9rem;
  white-space: nowrap;
}

.cc-run-btn.running {
  background: var(--gray-500);
  cursor: not-allowed;
}

.date-range-status {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
}

.date-range-status.running {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #7dd3fc;
}

.date-range-status.success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.date-range-status.error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.date-range-status.warning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.date-range-status .inline-btn {
  background: #16a34a;
  color: white;
  border: none;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  margin-left: 8px;
}

.date-range-status .inline-btn:hover {
  background: #15803d;
}

.date-range-status a {
  color: #2563eb;
  text-decoration: underline;
}

.date-range-status.cache {
  background: #f0f9ff;
  color: #075985;
  border: 1px solid #7dd3fc;
}

/* Cached reports row */
.cached-reports-row {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--gray-300);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.cached-select {
  padding: 6px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: inherit;
  min-width: 220px;
  background: white;
  cursor: pointer;
}

.cached-select:focus {
  outline: none;
  border-color: var(--primary-color);
}

.load-cached-btn {
  padding: 6px 14px;
  font-size: 0.85rem;
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  cursor: pointer;
  color: var(--gray-700);
  font-weight: 500;
  transition: all 0.15s ease;
}

.load-cached-btn:hover {
  background: var(--gray-200);
  border-color: var(--gray-400);
}

.load-cached-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Set as Default button */
.set-default-btn {
  padding: 6px 14px;
  font-size: 0.85rem;
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  cursor: pointer;
  color: var(--gray-700);
  font-weight: 500;
  transition: all 0.15s ease;
  margin-left: 8px;
}

.set-default-btn:hover {
  background: var(--gray-200);
  border-color: var(--gray-400);
}

.set-default-btn.is-default {
  background: #e8f5e9;
  border-color: #4caf50;
  color: #2e7d32;
}

/* Force refresh checkbox */
.cc-checkbox-label {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--gray-600);
}

.cc-checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Responsive for case-control */
@media (max-width: 768px) {
  .summary-cards {
    grid-template-columns: 1fr;
  }

  .key-insights-grid {
    grid-template-columns: 1fr;
  }

  .section-summary-header {
    flex-wrap: wrap;
  }

  .expand-table-btn {
    margin-top: 8px;
    width: 100%;
    justify-content: center;
  }

  .date-range-row {
    flex-direction: column;
    align-items: stretch;
  }

  .date-input-group {
    width: 100%;
  }

  .date-input {
    width: 100%;
  }

  .date-action-group {
    width: 100%;
  }

  .cc-run-btn {
    width: 100%;
    justify-content: center;
  }
}

/* ========================================
   Case-Control V2 (Redefined Analysis) Styles
   ======================================== */

/* Definitions Section */
.case-control-v2-definitions {
  margin-bottom: 24px;
}

.case-control-v2-definitions h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 12px;
}

.definition-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.definition-card {
  padding: 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  line-height: 1.6;
}

.definition-card.cases {
  background: #fef3c7;
  border: 1px solid #fcd34d;
}

.definition-card.cases.strict-mode {
  background: #fce7f3;
  border: 2px solid #ec4899;
}

.strict-badge {
  display: inline-block;
  background: #ec4899;
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  margin-left: 8px;
  vertical-align: middle;
  text-transform: uppercase;
}

.definition-card.controls {
  background: #eff6ff;
  border: 1px solid #93c5fd;
}

.definition-card ul {
  margin: 8px 0 0 0;
  padding-left: 20px;
}

.definition-card li {
  margin: 4px 0;
}

.definition-note {
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--gray-600);
  padding-top: 8px;
  border-top: 1px dashed var(--gray-300);
}

/* Population Summary */
.case-control-v2-population {
  margin-bottom: 24px;
}

.case-control-v2-population h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 8px;
}

.period-info {
  font-size: 0.875rem;
  color: var(--gray-600);
  margin-bottom: 16px;
}

.population-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.pop-stat {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.pop-stat.cases {
  background: #fffbeb;
  border-color: #fcd34d;
}

.pop-stat.controls {
  background: #eff6ff;
  border-color: #93c5fd;
}

.pop-stat.excluded {
  background: #f3f4f6;
  border-color: #d1d5db;
}

/* Larger styling for Cases and Controls */
.pop-stat.pop-stat-large .pop-stat-value {
  font-size: 2.5rem;
}

.pop-stat.pop-stat-large .pop-stat-label {
  font-size: 1rem;
  font-weight: 600;
}

/* Dark red styling for Excluded */
.pop-stat.pop-stat-excluded {
  background: #fef2f2;
  border-color: #b91c1c;
}

.pop-stat.pop-stat-excluded .pop-stat-value {
  color: #b91c1c;
}

.pop-stat.pop-stat-excluded .pop-stat-label {
  color: #991b1b;
}

.pop-stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gray-800);
}

.pop-stat-label {
  font-size: 0.8rem;
  color: var(--gray-600);
  margin-top: 4px;
}

.excluded-breakdown {
  font-size: 0.8rem;
  color: var(--gray-500);
  padding: 12px;
  background: var(--gray-50);
  border-radius: 4px;
}

/* Aggregate Rates */
.case-control-v2-aggregate {
  margin-bottom: 24px;
}

.case-control-v2-aggregate h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 12px;
}

/* New aggregate stats layout - matches population-stats */
.aggregate-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
  align-items: start;
}

.agg-stat {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.agg-stat.cases {
  background: #fffbeb;
  border-color: #fcd34d;
}

.agg-stat.controls {
  background: #eff6ff;
  border-color: #93c5fd;
}

.agg-stat.excluded {
  background: #f3f4f6;
  border-color: #d1d5db;
}

/* Larger styling for Cases and Controls */
.agg-stat.agg-stat-large .agg-stat-value {
  font-size: 2.5rem;
}

.agg-stat.agg-stat-large .agg-stat-label {
  font-size: 1rem;
  font-weight: 600;
}

/* Dark red styling for Excluded */
.agg-stat.agg-stat-excluded {
  background: #fef2f2;
  border-color: #b91c1c;
}

.agg-stat.agg-stat-excluded .agg-stat-value {
  color: #b91c1c;
}

.agg-stat.agg-stat-excluded .agg-stat-label {
  color: #991b1b;
}

.agg-stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gray-800);
}

.agg-stat-label {
  font-size: 0.8rem;
  color: var(--gray-600);
  margin-top: 4px;
}

.agg-stat-detail {
  font-size: 0.7rem;
  color: var(--gray-500);
  margin-top: 2px;
}

.aggregate-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.aggregate-card {
  padding: 16px;
  border-radius: 8px;
  text-align: center;
}

.aggregate-card.case-1day {
  background: #fef9c3;
  border: 1px solid #facc15;
}

.aggregate-card.case-more {
  background: #fed7aa;
  border: 1px solid #fb923c;
}

.aggregate-card.all-cases {
  background: #fffbeb;
  border: 2px solid #f59e0b;
}

.aggregate-card.controls {
  background: #dbeafe;
  border: 2px solid #3b82f6;
}

.agg-label {
  font-size: 0.8rem;
  color: var(--gray-600);
  margin-bottom: 8px;
}

.agg-rate {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-800);
}

.agg-detail {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 4px;
}

.rate-comparison {
  font-size: 0.9rem;
  padding: 12px 16px;
  background: var(--gray-50);
  border-radius: 6px;
  color: var(--gray-700);
}

/* Aggregate Comparison (Cases vs Controls focus) */
.aggregate-comparison {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-bottom: 16px;
}

.aggregate-card-large {
  padding: 24px 32px;
  border-radius: 12px;
  text-align: center;
  min-width: 200px;
}

.aggregate-card-large.cases {
  background: #fffbeb;
  border: 3px solid #f59e0b;
}

.aggregate-card-large.controls {
  background: #dbeafe;
  border: 3px solid #3b82f6;
}

.agg-label-large {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 8px;
}

.agg-rate-large {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--gray-800);
}

.agg-detail-large {
  font-size: 0.85rem;
  color: var(--gray-500);
  margin-top: 8px;
}

.aggregate-diff {
  text-align: center;
  padding: 16px;
}

.aggregate-diff .diff-label {
  font-size: 0.85rem;
  color: var(--gray-500);
  margin-bottom: 4px;
}

.aggregate-diff .diff-value {
  font-size: 1.75rem;
  font-weight: 700;
}

.aggregate-diff.positive .diff-value {
  color: #16a34a;
}

.aggregate-diff.negative .diff-value {
  color: #dc2626;
}

.aggregate-diff.neutral .diff-value {
  color: var(--gray-600);
}

/* Full comparison layout with All Visits and Excluded */
.aggregate-comparison-full {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.aggregate-card-small {
  padding: 16px 20px;
  border-radius: 10px;
  text-align: center;
  min-width: 120px;
}

.aggregate-card-small.all-visits {
  background: #f0fdf4;
  border: 2px solid #22c55e;
}

.aggregate-card-small.excluded {
  background: #fef2f2;
  border: 2px solid #ef4444;
}

.agg-label-small {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 4px;
}

.agg-rate-small {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-800);
}

.agg-detail-small {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 4px;
}

.aggregate-subgroups {
  font-size: 0.85rem;
  color: var(--gray-500);
  padding: 12px 16px;
  background: var(--gray-50);
  border-radius: 6px;
  text-align: center;
}

/* Excluded Column Container */
.excluded-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.excluded-column .agg-stat.excluded {
  margin-bottom: 0;
}

/* Excluded Subgroup Breakdown - Vertical Stack */
.excluded-subgroup-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.excl-subgroup-stat {
  background: white;
  border: 1px solid #e8c4c4;
  border-radius: 6px;
  padding: 8px 12px;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
}

.excl-subgroup-stat.coldcall {
  background: #fff0e6;
  border-color: #ffcc99;
}

.excl-stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: #b54545;
}

.excl-subgroup-stat.coldcall .excl-stat-value {
  color: #cc6600;
}

.excl-stat-label {
  font-size: 0.7rem;
  color: var(--gray-600);
  margin-top: 2px;
}

.excl-stat-detail {
  font-size: 0.65rem;
  color: var(--gray-500);
  margin-top: 1px;
}

/* Daily Rates Section */
.case-control-v2-daily {
  margin-bottom: 24px;
}

.daily-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.daily-header h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  margin: 0;
}

.daily-table-content {
  margin-top: 12px;
}

/* Observations Section */
.case-control-v2-observations {
  margin-top: 24px;
  padding: 16px;
  background: #f9fafb;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
}

.case-control-v2-observations h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  margin: 0 0 12px 0;
}

.observations-list {
  margin: 0;
  padding-left: 20px;
}

.observations-list li {
  font-size: 0.875rem;
  color: var(--gray-700);
  line-height: 1.6;
  margin-bottom: 8px;
}

.observations-list li:last-child {
  margin-bottom: 0;
}

/* Waterfall chart section */
.case-control-v2-waterfall {
  margin-top: 24px;
  padding: 16px;
  background: #f9fafb;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
}

.waterfall-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.waterfall-header h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  margin: 0;
}

.waterfall-content {
  margin-top: 16px;
}

.waterfall-note {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin: 0 0 16px 0;
  font-style: italic;
}

.waterfall-chart-container {
  background: white;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
  border: 1px solid var(--gray-200);
}

.waterfall-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.waterfall-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--gray-600);
}

.waterfall-legend .legend-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.waterfall-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 12px;
  background: white;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
}

.waterfall-summary .summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--gray-50);
  border-radius: 4px;
}

.waterfall-summary .summary-label {
  font-size: 0.8rem;
  color: var(--gray-600);
}

.waterfall-summary .summary-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-800);
}

.waterfall-summary .summary-value.completed {
  color: #16a34a;
}

.waterfall-summary .summary-value.not-completed {
  color: #dc2626;
}

/* Waterfall summary grid layout */
.waterfall-summary-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.waterfall-summary-grid .summary-group {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
}

.waterfall-summary-grid .summary-group-header {
  padding: 8px 12px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--gray-800);
}

.waterfall-summary-grid .summary-group-stats {
  display: flex;
  flex-direction: row;
  gap: 0;
}

.waterfall-summary-grid .stat-box {
  flex: 1;
  padding: 12px;
  text-align: center;
  border-left: 1px solid var(--gray-200);
  background: white;
}

.waterfall-summary-grid .stat-box:first-child {
  border-left: none;
}

.waterfall-summary-grid .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-800);
}

.waterfall-summary-grid .stat-label {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 4px;
}

/* Subgroup Breakdown Analysis Section */
.case-control-v2-subgroup-breakdown {
  margin-top: 24px;
  padding: 16px;
  background: #f9fafb;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
}

.definitions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.definitions-header h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  margin: 0;
}

.definitions-content {
  margin-top: 16px;
}

.subgroup-breakdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.subgroup-breakdown-header h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  margin: 0;
}

.subgroup-breakdown-content {
  margin-top: 16px;
}

.subgroup-note {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin: 0 0 16px 0;
  font-style: italic;
}

.subgroup-section {
  margin-bottom: 20px;
  background: white;
  border-radius: 8px;
  padding: 16px;
  border: 1px solid var(--gray-200);
}

.subgroup-section:last-child {
  margin-bottom: 0;
}

.subgroup-section h5 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-700);
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-200);
}

.subgroup-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.subgroup-table th,
.subgroup-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

.subgroup-table th {
  background: var(--gray-50);
  font-weight: 600;
  color: var(--gray-700);
}

.subgroup-table td {
  color: var(--gray-800);
}

.subgroup-table th:nth-child(2),
.subgroup-table th:nth-child(3),
.subgroup-table th:nth-child(4),
.subgroup-table td:nth-child(2),
.subgroup-table td:nth-child(3),
.subgroup-table td:nth-child(4) {
  text-align: right;
}

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

.subgroup-table tr.total-row {
  background: var(--gray-50);
}

.subgroup-table tr.total-row td {
  border-top: 2px solid var(--gray-300);
}

.subgroup-table tr.gap-row td {
  background: #fef3c7;
  border-top: 2px solid var(--gray-300);
}

.subgroup-table.summary-table {
  margin-top: 8px;
}

/* Responsive adjustments for V2 section */
@media (max-width: 768px) {
  .definition-cards {
    grid-template-columns: 1fr;
  }

  .population-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .aggregate-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .daily-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

/* ============================================================================
   LLM Transcript Analysis Section
   ============================================================================ */

.transcript-analysis-section {
  margin-top: 24px;
  padding: 16px;
  background: #fefce8;
  border: 1px solid #fde047;
  border-radius: 8px;
}

.transcript-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.transcript-header h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  margin: 0;
}

.transcript-type-toggle {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-left: auto;
  margin-right: 12px;
}

.transcript-type-btn {
  padding: 6px 14px;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  background: white;
  color: var(--gray-600);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.transcript-type-btn:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
}

.transcript-type-btn.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

.transcript-load-btn {
  padding: 6px 12px;
  border: 1px solid var(--primary-color);
  border-radius: 4px;
  background: white;
  color: var(--primary-color);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  margin-left: 8px;
  transition: all 0.15s ease;
}

.transcript-load-btn:hover {
  background: var(--primary-color);
  color: white;
}

.transcript-load-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.no-data-message {
  color: var(--gray-500);
  font-style: italic;
  padding: 20px;
  text-align: center;
  background: var(--gray-50);
  border-radius: 6px;
}

.error-message {
  color: var(--danger-color);
  padding: 20px;
  text-align: center;
  background: #fee2e2;
  border-radius: 6px;
}

.transcript-analysis-content {
  margin-top: 16px;
}

/* Overview stats */
.transcript-overview {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.transcript-stat {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 12px 20px;
  text-align: center;
  min-width: 100px;
}

.transcript-stat.completed {
  border-color: #22c55e;
  background: #f0fdf4;
}

.transcript-stat.not-completed {
  border-color: #ef4444;
  background: #fef2f2;
}

.transcript-stat .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-800);
}

.transcript-stat .stat-label {
  font-size: 0.75rem;
  color: var(--gray-600);
  margin-top: 4px;
}

/* Patterns table */
.transcript-tables-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  margin-bottom: 20px;
}

.patterns-section h5,
.robocall-mentions-section h5,
.call-duration-section h5,
.visit-table-section h5 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 12px;
}

.transcript-patterns-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 6px;
  overflow: hidden;
}

.transcript-patterns-table th,
.transcript-patterns-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.85rem;
}

.transcript-patterns-table th {
  background: var(--gray-100);
  font-weight: 600;
  color: var(--gray-700);
  text-align: left;
}

.transcript-patterns-table tr.section-header td {
  background: #f3f4f6;
  font-weight: 600;
  color: var(--gray-600);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 12px;
}

/* Robocall mentions table */
.robocall-mentions-section {
  min-width: 200px;
}

.robocall-mentions-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 6px;
  overflow: hidden;
}

.robocall-mentions-table th,
.robocall-mentions-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.85rem;
}

.robocall-mentions-table th {
  background: var(--gray-100);
  font-weight: 600;
  color: var(--gray-700);
}

/* Call duration section */
.call-duration-section {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 20px;
}

.duration-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.duration-stat {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.duration-label {
  font-size: 0.85rem;
  color: var(--gray-600);
}

.duration-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gray-800);
}

.duration-note {
  font-size: 0.75rem;
  color: var(--gray-500);
}

.duration-stat.diff .duration-value {
  color: #16a34a;
}

/* Visit details table */
.visit-table-section .table-wrapper {
  overflow-x: auto;
}

.visit-details-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 6px;
  font-size: 0.85rem;
}

.visit-details-table th,
.visit-details-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-200);
}

.visit-details-table th {
  background: var(--gray-100);
  font-weight: 600;
  color: var(--gray-700);
  text-align: left;
  white-space: nowrap;
}

.visit-details-table tr.completed-row {
  background: #f0fdf4;
}

.visit-details-table tr.not-completed-row {
  background: #fef2f2;
}

.visit-details-table .patient-id-cell {
  font-family: monospace;
  font-size: 0.75rem;
  color: var(--gray-500);
}

.visit-details-table .summary-cell {
  max-width: 300px;
  font-size: 0.8rem;
  color: var(--gray-600);
  line-height: 1.4;
}

.visit-details-table .status-success {
  color: #16a34a;
  font-weight: 600;
}

.visit-details-table .status-blocked {
  color: #dc2626;
  font-weight: 600;
}

.visit-details-table .status-no-show {
  color: #6b7280;
  font-style: italic;
}

.view-transcript-btn {
  padding: 4px 10px;
  font-size: 0.75rem;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

.view-transcript-btn:hover {
  background: #2563eb;
}

/* Modal for transcript popup */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  border-radius: 12px;
  max-width: 800px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
}

.modal-header h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--gray-500);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: var(--gray-800);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-body pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--gray-700);
  margin: 0;
}

/* Transcript search bar */
.modal-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}

.modal-search-bar input {
  flex: 1;
  padding: 6px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 0.875rem;
  outline: none;
}

.modal-search-bar input:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.modal-search-bar span {
  font-size: 0.75rem;
  color: var(--gray-500);
  min-width: 70px;
  text-align: center;
}

.modal-search-bar button {
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--gray-600);
}

.modal-search-bar button:hover {
  background: var(--gray-200);
  color: var(--gray-800);
}

/* Search highlights */
.search-highlight {
  background-color: #fef08a;
  padding: 1px 0;
  border-radius: 2px;
}

.search-highlight.current {
  background-color: #fb923c;
  color: white;
  padding: 1px 2px;
}

/* Responsive adjustments for transcript section */
@media (max-width: 768px) {
  .transcript-tables-grid {
    grid-template-columns: 1fr;
  }
  
  .duration-stats {
    flex-direction: column;
    gap: 12px;
  }
  
  .visit-details-table .summary-cell {
    max-width: 200px;
  }
}

/* Additional status styles for per-visit table */
.visit-details-table .status-completed {
  color: #16a34a;
  font-weight: 700;
  font-size: 0.75rem;
}

.visit-details-table .status-not-completed {
  color: #dc2626;
  font-weight: 700;
  font-size: 0.75rem;
}

.visit-details-table .status-rescheduled {
  color: #d97706;
  font-weight: 600;
}

/* Call Duration Color Styles */
.duration-stat.completed-duration .duration-value {
  color: #16a34a;
  font-weight: 700;
}

.duration-stat.completed-duration .duration-label {
  color: #16a34a;
}

.duration-stat.not-completed-duration .duration-value {
  color: #dc2626;
  font-weight: 700;
}

.duration-stat.not-completed-duration .duration-label {
  color: #dc2626;
}

/* Per-Visit Table Filters */
.visit-table-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--gray-50);
  border-radius: 6px;
  border: 1px solid var(--gray-200);
}

.visit-table-filters label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--gray-700);
}

.column-filter {
  padding: 6px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 0.85rem;
  background: white;
  min-width: 100px;
}

.column-filter:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

/* Diverging Bar Chart Styles */
.diverging-chart-container {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  overflow: hidden;
}

.diverging-chart-header {
  display: grid;
  grid-template-columns: 180px 1fr 70px;
  gap: 12px;
  padding: 12px 16px;
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--gray-600);
}

.diverging-header-bars {
  display: flex;
  justify-content: space-between;
  padding: 0 20px;
}

.completed-label {
  color: #16a34a;
}

.not-completed-label {
  color: #dc2626;
}

.diverging-header-diff {
  text-align: right;
}

.diverging-chart-body {
  padding: 8px 0;
}

.diverging-section-header {
  padding: 8px 16px;
  background: var(--gray-50);
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-top: 1px solid var(--gray-200);
  border-bottom: 1px solid var(--gray-200);
  margin: 4px 0;
}

.diverging-section-header:first-child {
  margin-top: 0;
  border-top: none;
}

.diverging-row {
  display: grid;
  grid-template-columns: 180px 1fr 70px;
  gap: 12px;
  padding: 8px 16px;
  align-items: center;
  border-bottom: 1px solid var(--gray-100);
}

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

.diverging-label {
  font-size: 0.85rem;
  color: var(--gray-700);
}

.diverging-bars {
  display: flex;
  align-items: center;
  height: 24px;
}

.diverging-left {
  flex: 1;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  padding-right: 4px;
}

.diverging-center {
  width: 2px;
  height: 28px;
  background: var(--gray-400);
  flex-shrink: 0;
}

.diverging-right {
  flex: 1;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 6px;
  padding-left: 4px;
}

.bar-completed {
  height: 18px;
  background: linear-gradient(90deg, #86efac, #16a34a);
  border-radius: 2px;
  min-width: 2px;
}

.bar-not-completed {
  height: 18px;
  background: linear-gradient(90deg, #dc2626, #fca5a5);
  border-radius: 2px;
  min-width: 2px;
}

.bar-annotation {
  font-size: 0.7rem;
  color: var(--gray-600);
  white-space: nowrap;
}

.bar-annotation.left {
  text-align: right;
}

.bar-annotation.right {
  text-align: left;
}

.diverging-diff {
  font-size: 0.8rem;
  font-weight: 600;
  text-align: right;
}

.diverging-diff.positive {
  color: #16a34a;
}

.diverging-diff.negative {
  color: #dc2626;
}

.diverging-diff.neutral {
  color: var(--gray-500);
}

/* Responsive for diverging chart */
@media (max-width: 768px) {
  .diverging-chart-header,
  .diverging-row {
    grid-template-columns: 120px 1fr 50px;
  }

  .diverging-label {
    font-size: 0.75rem;
  }

  .visit-table-filters {
    flex-direction: column;
    gap: 8px;
  }

  .visit-table-filters label {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .column-filter {
    width: 100%;
  }
}

/* Trend Section Controls */
.trend-controls {
  margin-bottom: 24px;
  padding: 16px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
}

.trend-subsection {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-200);
}

.trend-subsection:last-of-type {
  border-bottom: none;
  margin-bottom: 16px;
}

.trend-subsection h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 12px;
}
