/* ╔════════════════════════════════════════════════════════════════════════════╗
   ║ PROFITABILITY DASHBOARD CSS — Enterprise SaaS Production Architecture      ║
   ║ Inspired by: Linear, Stripe, Ramp, Notion, Uber Fleet, Vercel, Retool    ║
   ║ ARCHITECTURE: Zero overflow, Zero clipping, Pixel-perfect responsive      ║
   ╚════════════════════════════════════════════════════════════════════════════╝ */

/* ════════════════════════════════════════════════════════════════════════════
   GLOBAL RESET & NORMALIZATION
   ════════════════════════════════════════════════════════════════════════════ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #F6F8FC;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ════════════════════════════════════════════════════════════════════════════
   DESIGN TOKENS & CUSTOM PROPERTIES
   ════════════════════════════════════════════════════════════════════════════ */

:root {
  /* ─ Enterprise Color Palette ─ */
  --bg-base: #F6F8FC;
  --bg-card: #FFFFFF;
  --primary: #6C4CF1;
  --primary-light: #F3F0FF;
  --primary-dark: #5844D4;
  --success: #12B76A;
  --success-light: #ECFDF5;
  --success-border: #ABEFC6;
  --danger: #F04438;
  --danger-light: #FEF3F2;
  --danger-border: #FECDCA;
  --warning: #F79009;
  --warning-light: #FEF3C7;
  --text-primary: #101828;
  --text-secondary: #667085;
  --text-tertiary: #98A2B3;
  --border: #EAECF0;
  --border-light: #F0F1F3;

  /* ─ Spacing System: 4px base scale ─ */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 20px;
  --space-2xl: 24px;
  --space-3xl: 32px;
  --space-4xl: 40px;

  /* ─ Border Radius ─ */
  --radius-sm: 12px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-pill: 9999px;

  /* ─ Enterprise Shadow System ─ */
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.1), 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, 0.08);

  /* ─ Transitions ─ */
  --duration-fast: 150ms;
  --duration-base: 200ms;
  --easing: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ════════════════════════════════════════════════════════════════════════════
   ROOT DASHBOARD CONTAINER
   Fixed architecture: NO overflow, NO clipping, NO width:100vw
   ════════════════════════════════════════════════════════════════════════════ */

.dispatch-container .profitability-dashboard {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: auto;

  display: flex;
  flex-direction: column;
  gap: var(--space-2xl);

  padding: var(--space-2xl);

  background: var(--bg-base);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);

  min-height: 0;
  flex: 1;
}

/* Scrollbar styling */
.profitability-dashboard::-webkit-scrollbar {
  width: 8px;
}

.profitability-dashboard::-webkit-scrollbar-track {
  background: transparent;
}

.profitability-dashboard::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-pill);
  transition: background var(--duration-base) var(--easing);
}

.profitability-dashboard::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* ════════════════════════════════════════════════════════════════════════════
   HEADER SECTION — Premium Top Header
   ════════════════════════════════════════════════════════════════════════════ */

.profitability-dashboard .profitability-header {
  width: 100%;
  max-width: 100%;

  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);

  padding: 10px 16px;

  background: linear-gradient(135deg, rgba(108, 76, 241, 0.04) 0%, rgba(108, 76, 241, 0.01) 100%);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);

  min-width: 0;
}

.profitability-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 0;
  flex: 1 1 auto;
}

.profitability-header-icon {
  width: 36px;
  height: 36px;
  min-width: 36px;

  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), #7C58E8);

  display: flex;
  align-items: center;
  justify-content: center;

  color: white;
  font-size: 18px;

  box-shadow: var(--shadow-sm);

  flex-shrink: 0;
}

.profitability-header-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  min-width: 0;
}

.profitability-header-content h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.profitability-header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.profitability-header-subtitle {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin: 0;
}

.profitability-header-stat {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.profitability-header-stat-value {
  font-weight: 600;
  color: var(--text-primary);
}

.profitability-header-stat-value.profit {
  color: var(--success);
}

.profitability-header-stat-value.loss {
  color: var(--danger);
}

.header-divider {
  width: 1px;
  height: 16px;
  background: var(--border);
}

.profitability-header-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-tertiary);
  display: inline-block;
  margin: 0 4px;
}

.profitability-kpi-group {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.profitability-dashboard .profitability-kpi-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  transition: all var(--duration-base) var(--easing);
}

.profitability-kpi-chip--profit {
  background: var(--success-light);
  border-color: var(--success-border);
  color: var(--success);
}

.profitability-kpi-chip--loss {
  background: var(--danger-light);
  border-color: var(--danger-border);
  color: var(--danger);
}

.profitability-kpi-chip:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.profitability-kpi-chip-icon {
  font-size: 14px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.profitability-kpi-chip-content {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.profitability-kpi-chip-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.8;
}

.profitability-kpi-chip-amount {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ════════════════════════════════════════════════════════════════════════════
   KPI CARDS GRID — 4-column responsive, pixel-perfect
   ════════════════════════════════════════════════════════════════════════════ */

.profitability-summary-row {
  width: 100%;
  max-width: 100%;

  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-xl);

  margin-bottom: var(--space-lg);
}

/* ════════════════════════════════════════════════════════════════════════════
   INTERACTIVE ENHANCEMENTS — Premium micro-interactions
   ════════════════════════════════════════════════════════════════════════════ */

/* Enhanced KPI card interactions */
.profitability-dashboard .profitability-summary-card {
  position: relative;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;

  display: flex;
  flex-direction: column;
  gap: 6px;

  padding: 12px 16px;

  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);

  transition: all var(--duration-base) var(--easing);
}

.profitability-summary-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, transparent 100%);
  opacity: 0;
  pointer-events: none;
  border-radius: var(--radius-lg);
  transition: opacity var(--duration-base) var(--easing);
}

.profitability-summary-card:hover::after {
  opacity: 0.1;
}

/* Enhanced rider card interactions */
.rider-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-lg);

  padding: var(--space-lg);

  cursor: pointer;
  user-select: none;

  transition: all var(--duration-fast) var(--easing);
  position: relative;
}

.rider-card-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(108, 76, 241, 0) 0%, rgba(108, 76, 241, 0.02) 100%);
  opacity: 0;
  pointer-events: none;
  border-radius: var(--radius-lg);
  transition: opacity var(--duration-fast) var(--easing);
}

.rider-card-header:hover::before {
  opacity: 1;
}

.rider-card-header:hover {
  background: linear-gradient(135deg, rgba(108, 76, 241, 0.02) 0%, transparent 100%);
}

/* Smooth expand/collapse animation */
@keyframes expandCardIn {
  from {
    opacity: 0;
    transform: scaleY(0.95);
  }

  to {
    opacity: 1;
    transform: scaleY(1);
  }
}

.rider-detail-panel {
  animation: expandCardIn 0.2s var(--easing);
  transform-origin: top;
}

.profitability-summary-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--border);
  transition: all var(--duration-base) var(--easing);
}

.profitability-summary-card--primary::before {
  background: linear-gradient(90deg, var(--primary), #7C58E8);
}

.profitability-summary-card--success::before {
  background: linear-gradient(90deg, var(--success), #13C296);
  height: 4px;
}

.profitability-summary-card--danger::before {
  background: linear-gradient(90deg, var(--danger), #F66358);
  height: 4px;
}

.profitability-summary-card--loss::before {
  background: linear-gradient(90deg, var(--warning), #F79009);
  height: 4px;
}

.profitability-summary-card--profit::before {
  background: linear-gradient(90deg, var(--success), #13C296);
  height: 4px;
}

.profitability-summary-card--success {
  border-top-color: var(--success-light);
}

.profitability-summary-card--danger {
  border-top-color: var(--danger-light);
}

.profitability-summary-card--loss {
  border-top-color: var(--warning-light);
}

.profitability-summary-card--profit {
  border-top-color: var(--success-light);
}

.profitability-summary-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.profitability-summary-card--success:hover {
  border-color: var(--success);
  box-shadow: 0 8px 24px rgba(18, 183, 106, 0.1);
}

.profitability-summary-card--danger:hover {
  border-color: var(--danger);
  box-shadow: 0 8px 24px rgba(240, 68, 56, 0.1);
}

.profitability-summary-card.card-profit:hover {
  border-color: var(--success);
  box-shadow: 0 8px 24px rgba(18, 183, 106, 0.1);
}

.profitability-summary-card.card-loss:hover {
  border-color: var(--danger);
  box-shadow: 0 8px 24px rgba(240, 68, 56, 0.1);
}

.profitability-summary-card:hover::before {
  height: 5px;
}

.profitability-summary-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0;
}

.profitability-summary-value {
  font-size: clamp(20px, 2.2vw, 24px);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 0;
  overflow-wrap: break-word;
}

.profitability-summary-value--success {
  color: var(--success);
  text-shadow: 0 0 12px rgba(18, 183, 106, 0.12);
}

.profitability-summary-value--danger {
  color: var(--danger);
  text-shadow: 0 0 12px rgba(240, 68, 56, 0.10);
}

.profitability-summary-detail {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0;
  margin-top: var(--space-xs);
}

.profitability-summary-detail.margin-positive {
  color: var(--success) !important;
  text-shadow: 0 0 12px rgba(18, 183, 106, 0.12);
  font-weight: 600;
}

.profitability-summary-detail.margin-negative {
  color: var(--danger) !important;
  text-shadow: 0 0 12px rgba(240, 68, 56, 0.1);
  font-weight: 600;
}

/* ════════════════════════════════════════════════════════════════════════════
   CONTROLS BAR — Search, Filter, Sort
   ════════════════════════════════════════════════════════════════════════════ */

.profitability-dashboard .profitability-controls-bar {
  width: 100%;
  max-width: 100%;

  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-lg);

  padding: var(--space-lg);

  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);

  min-width: 0;
}

/* Search Input */
.profitability-search-wrapper {
  position: relative;
  flex: 1 1 280px;
  min-width: 0;
  max-width: 100%;
}

.profitability-search-icon {
  position: absolute;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: 16px;
  pointer-events: none;
  transition: color var(--duration-fast) var(--easing);
  flex-shrink: 0;
}

.profitability-dashboard .profitability-search-input {
  width: 100%;
  height: 40px;

  padding: 0 var(--space-md) 0 36px;

  border: 1px solid var(--border);
  border-radius: var(--radius-md);

  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;

  outline: none;
  transition: all var(--duration-fast) var(--easing);

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profitability-search-input::placeholder {
  color: var(--text-tertiary);
}

.profitability-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 76, 241, 0.1);
}

.profitability-search-input:focus~.profitability-search-icon {
  color: var(--primary);
}

/* Filter Tabs */
.profitability-filter-tabs {
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-xs);
  background: var(--bg-base);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.profitability-dashboard .profitability-tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);

  padding: 6px 12px;

  border: none;
  border-radius: var(--radius-sm);

  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;

  cursor: pointer;
  transition: all var(--duration-fast) var(--easing);
  white-space: nowrap;
}

.profitability-tab-btn:hover {
  background: var(--bg-card);
  color: var(--primary);
}

.profitability-tab-btn.tab-active {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.profitability-tab-count {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.1);
  opacity: 0.8;
}

.profitability-tab-btn.tab-active .profitability-tab-count {
  background: rgba(255, 255, 255, 0.3);
}

/* Sort Wrapper */
.profitability-sort-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-left: auto;
  flex-shrink: 0;
}

.profitability-sort-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  display: none;
}

.profitability-dashboard .profitability-sort-select {
  height: 40px;
  padding: 0 32px 0 var(--space-md);

  border: 1px solid var(--border);
  border-radius: var(--radius-md);

  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;

  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;

  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;

  transition: all var(--duration-fast) var(--easing);
  padding-right: 32px;
}

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

.profitability-sort-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 76, 241, 0.1);
}

/* ════════════════════════════════════════════════════════════════════════════
   RIDERS LIST SECTION
   ════════════════════════════════════════════════════════════════════════════ */

.rider-profitability-feed {
  width: 100%;
  max-width: 100%;

  display: flex;
  flex-direction: column;
  gap: var(--space-md);

  flex: 1;
  min-width: 0;
}

.rider-feed-heading {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 var(--space-md);
}

.profitability-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);

  padding: 60px var(--space-xl);

  text-align: center;

  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}

.profitability-empty-state svg {
  font-size: 48px;
  color: var(--primary);
  opacity: 0.3;
}

.profitability-empty-message {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0;
}

/* ════════════════════════════════════════════════════════════════════════════
   RIDER CARD — Modern Enterprise SaaS Card
   ════════════════════════════════════════════════════════════════════════════ */

.profitability-dashboard .rider-profitability-card {
  width: 100%;
  max-width: 100%;
  min-width: 0;

  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);

  overflow: hidden;

  transition: all var(--duration-base) var(--easing);
}

.rider-profitability-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.rider-profitability-card--profitable {
  border-left: 4px solid var(--success);
  background: linear-gradient(135deg, rgba(18, 183, 106, 0.02) 0%, transparent 100%);
}

.rider-profitability-card--unprofitable {
  border-left: 4px solid var(--danger);
  background: linear-gradient(135deg, rgba(240, 68, 56, 0.02) 0%, transparent 100%);
}

.rider-profitability-card--selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light), var(--shadow-md);
}

.profitability-dashboard .rider-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-lg);

  padding: var(--space-lg);

  cursor: pointer;
  user-select: none;

  transition: all var(--duration-fast) var(--easing);
  position: relative;
}

.rider-card-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(108, 76, 241, 0) 0%, rgba(108, 76, 241, 0.02) 100%);
  opacity: 0;
  pointer-events: none;
  border-radius: var(--radius-lg);
  transition: opacity var(--duration-fast) var(--easing);
}

.rider-card-header:hover::before {
  opacity: 1;
}

.rider-card-header:hover {
  background: linear-gradient(135deg, rgba(108, 76, 241, 0.02) 0%, transparent 100%);
}

.rider-avatar {
  width: 40px;
  height: 40px;
  min-width: 40px;

  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-light), rgba(108, 76, 241, 0.15));
  color: var(--primary);

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;

  flex-shrink: 0;
}

.rider-identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.rider-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rider-order-summary {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rider-order-summary-separator {
  opacity: 0.5;
  margin: 0 6px;
}

.rider-metrics-row {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  margin-right: var(--space-lg);
  flex-shrink: 0;
}

.rider-metric {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.rider-metric-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.rider-metric-amount {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.rider-metric-amount--success {
  color: var(--success);
  text-shadow: 0 0 8px rgba(18, 183, 106, 0.08);
}

.rider-metric-amount--danger {
  color: var(--danger);
  text-shadow: 0 0 8px rgba(240, 68, 56, 0.08);
}

.rider-metric-amount--revenue {
  color: var(--success);
}

.rider-metric-amount--cost {
  color: var(--warning);
}

.rider-metric-amount--net-profit {
  color: var(--success);
  text-shadow: 0 0 8px rgba(18, 183, 106, 0.08);
}

.rider-metric-amount--net-loss {
  color: var(--danger);
  text-shadow: 0 0 8px rgba(240, 68, 56, 0.08);
}

.rider-net-profit-column {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  width: 100px;
  flex-shrink: 0;
}

.rider-margin-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-base);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.rider-margin-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width var(--duration-base) var(--easing);
}

.rider-margin-bar-fill--profit {
  background: linear-gradient(90deg, var(--success), #13C296);
  box-shadow: 0 0 8px rgba(18, 183, 106, 0.2);
}

.rider-margin-bar-fill--danger {
  background: linear-gradient(90deg, var(--danger), #F66358);
  box-shadow: 0 0 8px rgba(240, 68, 56, 0.2);
}

.rider-expand-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;

  border-radius: var(--radius-sm);

  color: var(--text-tertiary);
  font-size: 20px;

  flex-shrink: 0;

  transition: all var(--duration-fast) var(--easing);
}

.rider-card-header:hover .rider-expand-toggle {
  color: var(--primary);
  background: var(--primary-light);
}

.rider-expand-toggle--open {
  transform: rotate(180deg);
  color: var(--primary);
  background: var(--primary-light);
}

/* ════════════════════════════════════════════════════════════════════════════
   RIDER DETAIL PANEL — Expandable cost breakdown
   ════════════════════════════════════════════════════════════════════════════ */

.rider-detail-panel {
  border-top: 1px solid var(--border);
  background: var(--bg-base);
  animation: slideDown 0.2s var(--easing);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.profitability-dashboard .rider-detail-inner {
  padding: var(--space-lg);
}

.cost-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.profitability-dashboard .cost-tile {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-lg);

  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);

  transition: all var(--duration-base) var(--easing);
}

.cost-tile:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  background: linear-gradient(135deg, var(--primary-light), transparent);
}

.cost-tile-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;

  border-radius: var(--radius-md);

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 18px;

  flex-shrink: 0;
}

.cost-tile-icon--fixed {
  background: #EEF2FF;
  color: #5B6CF1;
}

.cost-tile-icon--variable {
  background: #FEF3C7;
  color: #D97706;
}

.cost-tile-icon--profit {
  background: var(--success-light);
  color: var(--success);
}

.cost-tile-icon--loss {
  background: var(--danger-light);
  color: var(--danger);
}

.cost-tile-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cost-tile-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.cost-tile-amount {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  overflow-wrap: break-word;
}

.cost-tile-amount--profit {
  color: var(--success);
  text-shadow: 0 0 12px rgba(18, 183, 106, 0.12);
}

.cost-tile-amount--loss {
  color: var(--danger);
  text-shadow: 0 0 12px rgba(240, 68, 56, 0.10);
}

.cost-tile-footnote {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ════════════════════════════════════════════════════════════════════════════
   ORDERS TABLE — Revenue breakdown
   ════════════════════════════════════════════════════════════════════════════ */

.revenue-breakdown {
  width: 100%;
  max-width: 100%;

  border: 1px solid var(--border);
  border-radius: var(--radius-md);

  background: var(--bg-card);

  overflow: hidden;
}

.profitability-dashboard .revenue-breakdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: var(--space-lg);

  background: var(--bg-base);
  border-bottom: 1px solid var(--border);
}

.revenue-breakdown-title {
  display: flex;
  align-items: center;
  gap: var(--space-md);

  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.revenue-breakdown-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

.orders-table-container {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

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

.profitability-dashboard .orders-table thead th {
  padding: var(--space-md) var(--space-lg);
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--bg-base);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.orders-table tbody tr {
  transition: background var(--duration-fast) var(--easing);
  border-bottom: 1px solid var(--border-light);
}

.orders-table tbody tr:hover {
  background: var(--bg-base);
}

.orders-table tbody tr:last-child {
  border-bottom: none;
}

.profitability-dashboard .orders-table tbody td {
  padding: var(--space-md) var(--space-lg);
  vertical-align: middle;
  font-size: 13px;
}

.customer-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.customer-phone {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 2px;
}

.customer-location {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--primary);
  margin-top: 2px;
}

.order-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.order-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.distance-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.distance-unit {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  margin-left: 2px;
}

.revenue-amount {
  font-size: 13px;
  font-weight: 700;
  color: var(--success);
  text-shadow: 0 0 8px rgba(18, 183, 106, 0.08);
}

.orders-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);

  padding: 40px var(--space-xl);

  color: var(--text-tertiary);
}

.orders-empty-state svg {
  font-size: 32px;
  color: var(--primary);
  opacity: 0.3;
}

.orders-empty-message {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ════════════════════════════════════════════════════════════════════════════
   PROFIT/LOSS COLOR STATES — Universal fintech UX pattern
   Green = Profit, Red = Loss, Instant visual scanability
   ════════════════════════════════════════════════════════════════════════════ */

.net-positive {
  color: var(--success) !important;
  text-shadow: 0 0 12px rgba(18, 183, 106, 0.12);
}

.net-negative {
  color: var(--danger) !important;
  text-shadow: 0 0 12px rgba(240, 68, 56, 0.1);
}

.margin-positive {
  color: var(--success) !important;
  text-shadow: 0 0 12px rgba(18, 183, 106, 0.12);
}

.margin-negative {
  color: var(--danger) !important;
  text-shadow: 0 0 12px rgba(240, 68, 56, 0.1);
}

.card-profit {
  border-top-color: var(--success) !important;
}

.card-profit::before {
  background: linear-gradient(90deg, var(--success), #13C296) !important;
}

.card-loss {
  border-top-color: var(--danger) !important;
}

.card-loss::before {
  background: linear-gradient(90deg, var(--danger), #F66358) !important;
}

/* ════════════════════════════════════════════════════════════════════════════
   RESPONSIVE DESIGN — Mobile First + Breakpoints
   ════════════════════════════════════════════════════════════════════════════ */

/* DESKTOP: 1440px - Full 4-column layout */
@media (min-width: 1440px) {
  .profitability-dashboard {
    padding: var(--space-2xl);
  }
}

/* LAPTOP: 1280px - 5-column works since cards are smaller */
@media (max-width: 1440px) {
  .profitability-summary-row {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

/* TABLET: 1024px - Transition to 2 columns */
@media (max-width: 1200px) {
  .profitability-summary-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .profitability-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .profitability-kpi-group {
    width: 100%;
  }
}

/* TABLET: 768px - Mobile optimized */
@media (max-width: 768px) {
  .profitability-dashboard {
    padding: var(--space-lg);
    gap: var(--space-lg);
  }

  .profitability-header {
    flex-direction: column;
    gap: var(--space-lg);
    align-items: flex-start;
  }

  .profitability-header-left {
    width: 100%;
  }

  .profitability-kpi-group {
    width: 100%;
    flex-direction: column;
  }

  .profitability-summary-row {
    grid-template-columns: 1fr;
  }

  .profitability-controls-bar {
    flex-direction: column;
  }

  .profitability-search-wrapper {
    max-width: 100%;
    width: 100%;
    flex: 1 1 auto;
  }

  .profitability-filter-tabs {
    width: 100%;
    justify-content: space-between;
  }

  .profitability-sort-wrapper {
    margin-left: 0;
    width: 100%;
  }

  .rider-metrics-row {
    display: none;
  }

  .cost-breakdown-grid {
    grid-template-columns: 1fr;
  }

  .orders-table {
    font-size: 12px;
  }

  .orders-table thead th,
  .orders-table tbody td {
    padding: var(--space-sm) var(--space-md);
  }
}

/* MOBILE: 640px - Stacked layout */
@media (max-width: 640px) {
  .profitability-dashboard {
    padding: var(--space-lg);
    gap: var(--space-lg);
  }

  .profitability-header-icon {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }

  .profitability-header-content h2 {
    font-size: 20px;
  }

  .profitability-header-subtitle {
    font-size: 12px;
  }

  .profitability-dashboard .profitability-kpi-chip {
    padding: var(--space-sm) var(--space-md);
    font-size: 11px;
  }

  .profitability-kpi-chip-amount {
    font-size: 14px;
  }

  .profitability-dashboard .profitability-summary-card {
    padding: var(--space-lg);
  }

  .profitability-summary-value {
    font-size: 24px;
  }

  .profitability-controls-bar {
    gap: var(--space-md);
    padding: var(--space-md);
  }

  .profitability-search-wrapper {
    min-width: auto;
    width: 100%;
    flex: 1 1 auto;
  }

  .profitability-search-input {
    height: 36px;
    font-size: 12px;
  }

  .rider-card-header {
    gap: var(--space-md);
    padding: var(--space-md);
  }

  .rider-metrics-row {
    display: none;
  }

  .cost-breakdown-grid {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  .cost-tile {
    padding: var(--space-md);
  }
}

/* EXTRA SMALL: 480px - Minimal layout */
@media (max-width: 480px) {
  .profitability-dashboard {
    padding: var(--space-md);
    gap: var(--space-md);
  }

  .profitability-header {
    padding: var(--space-md);
  }

  .profitability-header-content h2 {
    font-size: 18px;
  }

  .profitability-kpi-group {
    flex-direction: column;
    gap: var(--space-sm);
  }

  .profitability-kpi-chip {
    width: 100%;
  }

  .rider-identity {
    flex: 1;
  }

  .rider-expand-toggle {
    width: 28px;
    height: 28px;
  }

  .profitability-summary-value {
    font-size: 22px;
  }

  .profitability-controls-bar {
    padding: var(--space-md);
  }

  .profitability-sort-label {
    display: none;
  }
}