/* =============================================================================
   TradeRail PR235 — Reporting & Analytics
   Namespace : .rp-*
   Brand     : Primary Orange #FF6B00 | Wordmark Dark #1A1A2E
   ============================================================================= */

/* ── Reset / base ─────────────────────────────────────────────────────────── */
.rp-module *,
.rp-module *::before,
.rp-module *::after {
  box-sizing: border-box;
}

/* ── Module container ─────────────────────────────────────────────────────── */
.rp-module {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: #f5f6fa;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #1A1A2E;
  overflow: hidden;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.rp-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px 14px;
  background: #1A1A2E;
  color: #fff;
  flex-shrink: 0;
  border-bottom: 3px solid #FF6B00;
}

.rp-header-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #fff;
  flex: 1;
}

.rp-header-company {
  font-size: 12px;
  color: #aab0c0;
  font-weight: 400;
}

/* ── Tab bar ──────────────────────────────────────────────────────────────── */
.rp-tab-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: #fff;
  border-bottom: 2px solid #e8eaf0;
  padding: 0 24px;
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.rp-tab-bar::-webkit-scrollbar { display: none; }

.rp-tab {
  display: inline-flex;
  align-items: center;
  padding: 13px 18px 11px;
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  user-select: none;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  outline: none;
  margin-bottom: -2px;
}
.rp-tab:hover {
  color: #FF6B00;
}
.rp-tab-active {
  color: #FF6B00;
  border-bottom-color: #FF6B00;
  font-weight: 600;
}

/* ── Filter bar ───────────────────────────────────────────────────────────── */
.rp-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1px solid #e8eaf0;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.rp-filter-label {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 2px;
}

.rp-select {
  appearance: none;
  -webkit-appearance: none;
  background: #f5f6fa url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7280'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1.5px solid #d1d5db;
  border-radius: 7px;
  padding: 7px 30px 7px 11px;
  font-size: 13px;
  color: #1A1A2E;
  cursor: pointer;
  transition: border-color 0.15s;
  outline: none;
  min-width: 130px;
}
.rp-select:focus {
  border-color: #FF6B00;
}

.rp-date-range {
  display: flex;
  align-items: center;
  gap: 6px;
}
.rp-date-range input[type="date"] {
  border: 1.5px solid #d1d5db;
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 13px;
  color: #1A1A2E;
  background: #f5f6fa;
  outline: none;
  transition: border-color 0.15s;
}
.rp-date-range input[type="date"]:focus {
  border-color: #FF6B00;
}

/* ── Section / scrollable body ────────────────────────────────────────────── */
.rp-section {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 32px;
  min-height: 0;
}

.rp-section-title {
  font-size: 15px;
  font-weight: 700;
  color: #1A1A2E;
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e8eaf0;
  display: block;
}

/* ── Overview tiles ───────────────────────────────────────────────────────── */
.rp-overview-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.rp-tile {
  background: #fff;
  border-radius: 10px;
  padding: 18px 20px;
  border: 1.5px solid #e8eaf0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: box-shadow 0.15s;
  cursor: default;
}
.rp-tile:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.07);
}

.rp-tile-value {
  font-size: 28px;
  font-weight: 800;
  color: #1A1A2E;
  line-height: 1;
}

.rp-tile-label {
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.rp-tile-alert {
  font-size: 12px;
  color: #dc2626;
  font-weight: 600;
  margin-top: 2px;
}

.rp-tile-locked {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #9ca3af;
  font-style: italic;
}

/* ── Chart wrapper ────────────────────────────────────────────────────────── */
.rp-chart-wrap {
  background: #fff;
  border: 1.5px solid #e8eaf0;
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 16px;
  overflow-x: auto;
}
.rp-chart-wrap svg {
  display: block;
  width: 100%;
  height: auto;
}

/* ── Table wrapper ────────────────────────────────────────────────────────── */
.rp-table-wrap {
  background: #fff;
  border: 1.5px solid #e8eaf0;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 16px;
}

.rp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.rp-table thead tr {
  background: #f5f6fa;
  border-bottom: 2px solid #e8eaf0;
}
.rp-table thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.rp-table tbody tr {
  border-bottom: 1px solid #f0f1f5;
  transition: background 0.1s;
}
.rp-table tbody tr:last-child {
  border-bottom: none;
}
.rp-table tbody tr:hover {
  background: #fafbff;
}
.rp-table tbody td {
  padding: 10px 14px;
  color: #1A1A2E;
  vertical-align: middle;
}

/* ── Card header (report card title row) ─────────────────────────────────── */
.rp-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Badges ───────────────────────────────────────────────────────────────── */
.rp-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.2px;
}
.rp-badge-paid {
  background: #dcfce7;
  color: #16a34a;
}
.rp-badge-partial {
  background: #fef9c3;
  color: #854d0e;
}
.rp-badge-outstanding {
  background: #fff3e8;
  color: #FF6B00;
}
.rp-badge-overdue {
  background: #fee2e2;
  color: #dc2626;
}
.rp-badge-compliant {
  background: #dcfce7;
  color: #16a34a;
}
.rp-badge-noncompliant {
  background: #fee2e2;
  color: #dc2626;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.rp-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  outline: none;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.rp-btn:active { opacity: 0.85; }

.rp-btn-primary {
  background: #FF6B00;
  color: #fff;
}
.rp-btn-primary:hover { background: #e55f00; }

.rp-btn-secondary {
  background: #f5f6fa;
  color: #1A1A2E;
  border: 1.5px solid #d1d5db;
}
.rp-btn-secondary:hover { background: #e8eaf0; }

.rp-btn-export {
  background: #1A1A2E;
  color: #fff;
}
.rp-btn-export:hover { background: #2d2d48; }

.rp-btn-print {
  background: #f5f6fa;
  color: #1A1A2E;
  border: 1.5px solid #d1d5db;
}
.rp-btn-print:hover { background: #e8eaf0; }

.rp-btn-paid {
  background: #16a34a;
  color: #fff;
}
.rp-btn-paid:hover { background: #15803d; }

.rp-btn-sage {
  background: #0f766e;
  color: #fff;
}
.rp-btn-sage:hover { background: #0d6b63; }

/* ── Burden label ─────────────────────────────────────────────────────────── */
.rp-burden-label {
  display: block;
  font-size: 11px;
  color: #9ca3af;
  font-style: italic;
  margin-top: 6px;
  padding: 5px 10px;
  background: #f5f6fa;
  border-left: 3px solid #FF6B00;
  border-radius: 0 4px 4px 0;
}

/* ── Lily banner ──────────────────────────────────────────────────────────── */
.rp-lily-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #fff3e8 0%, #fff8f0 100%);
  border: 1.5px solid #ffb366;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: #cc5500;
  font-weight: 500;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.rp-lily-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #FF6B00;
  flex-shrink: 0;
  animation: rp-lily-pulse 2s infinite;
}

@keyframes rp-lily-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* ── Alert banner ─────────────────────────────────────────────────────────── */
.rp-alert-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fee2e2;
  border: 1.5px solid #fca5a5;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: #dc2626;
  font-weight: 500;
  margin-bottom: 14px;
}

/* ── AR Aging grid ────────────────────────────────────────────────────────── */
.rp-aging-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.rp-aging-bucket {
  background: #fff;
  border: 1.5px solid #e8eaf0;
  border-radius: 10px;
  padding: 14px 16px;
  text-align: center;
  transition: box-shadow 0.15s;
}
.rp-aging-bucket:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.rp-aging-amount {
  font-size: 22px;
  font-weight: 800;
  color: #1A1A2E;
  display: block;
  margin-bottom: 4px;
}

.rp-aging-label {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* Overdue bucket highlight */
.rp-aging-bucket:last-child .rp-aging-amount {
  color: #dc2626;
}

/* ── Billing stage indicators ─────────────────────────────────────────────── */
.rp-stage {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.rp-stage-active {
  background: #dbeafe;
  color: #1d4ed8;
}
.rp-stage-done {
  background: #dcfce7;
  color: #16a34a;
}
.rp-stage-pending {
  background: #f5f6fa;
  color: #6b7280;
  border: 1px solid #d1d5db;
}
.rp-stage-arrow {
  color: #9ca3af;
  font-size: 10px;
  margin: 0 1px;
}

/* ── Sidebar (no-access placeholder) ─────────────────────────────────────── */
.rp-sidebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  text-align: center;
  color: #6b7280;
  padding: 40px;
}

/* ── PIN overlay ──────────────────────────────────────────────────────────── */
.rp-pin-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 46, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}

.rp-pin-modal {
  background: #fff;
  border-radius: 16px;
  padding: 28px 32px 32px;
  width: 320px;
  max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.rp-pin-title {
  font-size: 17px;
  font-weight: 700;
  color: #1A1A2E;
  text-align: center;
}

.rp-pin-subtitle {
  font-size: 13px;
  color: #6b7280;
  text-align: center;
  margin-bottom: 4px;
}

.rp-pin-prompt {
  font-size: 12px;
  color: #9ca3af;
  text-align: center;
  margin-bottom: 6px;
}

.rp-pin-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 8px 0;
}

.rp-pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2.5px solid #d1d5db;
  background: transparent;
  transition: background 0.15s, border-color 0.15s;
}

.rp-pin-dot-filled {
  background: #FF6B00;
  border-color: #FF6B00;
}

.rp-pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  margin-top: 6px;
}

.rp-pin-key {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 52px;
  border-radius: 10px;
  background: #f5f6fa;
  border: 1.5px solid #e8eaf0;
  font-size: 20px;
  font-weight: 600;
  color: #1A1A2E;
  cursor: pointer;
  transition: background 0.12s, transform 0.08s;
  user-select: none;
}
.rp-pin-key:hover {
  background: #fff3e8;
  border-color: #FF6B00;
  color: #FF6B00;
}
.rp-pin-key:active {
  transform: scale(0.93);
}

.rp-pin-key-del {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
  font-size: 15px;
}
.rp-pin-key-del:hover {
  background: #fecaca;
  border-color: #dc2626;
}

.rp-pin-key-empty {
  background: transparent;
  border: none;
  cursor: default;
  pointer-events: none;
}

.rp-pin-lock-msg {
  font-size: 13px;
  color: #dc2626;
  text-align: center;
  font-weight: 500;
  margin-top: 4px;
}

/* ── Print mode ───────────────────────────────────────────────────────────── */
@media print {
  .rp-filter-bar,
  .rp-tab-bar,
  .rp-header,
  .rp-btn,
  .rp-lily-banner,
  .rp-pin-overlay {
    display: none !important;
  }

  .rp-module {
    background: #fff;
    overflow: visible;
  }

  .rp-section {
    overflow: visible;
    padding: 0;
  }

  .rp-table-wrap,
  .rp-chart-wrap {
    border: 1px solid #ccc;
    border-radius: 0;
    page-break-inside: avoid;
  }

  .rp-burden-label {
    border-left: 3px solid #000;
  }
}

/* ── Responsive — sidebar hidden below 768px (desktop-only rule) ─────────── */
@media (max-width: 767px) {
  .rp-filter-bar {
    padding: 10px 14px;
    gap: 8px;
  }

  .rp-section {
    padding: 14px 14px 24px;
  }

  .rp-header {
    padding: 12px 14px 10px;
  }

  .rp-tab {
    padding: 10px 12px 8px;
    font-size: 12px;
  }

  .rp-overview-tiles {
    grid-template-columns: repeat(2, 1fr);
  }

  .rp-tile-value {
    font-size: 22px;
  }

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

  .rp-pin-modal {
    padding: 22px 20px 24px;
    width: 290px;
  }

  .rp-pin-key {
    height: 46px;
    font-size: 18px;
  }
}

/* ── Job health grid ──────────────────────────────────────────────────────── */
.rp-health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.rp-health-card {
  background: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  border-left: 4px solid #16a34a;
  transition: box-shadow 0.15s;
}
.rp-health-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.rp-health-job {
  font-size: 13px;
  font-weight: 700;
  color: #1A1A2E;
  margin-bottom: 3px;
}

.rp-health-customer {
  font-size: 11px;
  color: #6b7280;
  margin-bottom: 6px;
}

.rp-health-status {
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex-wrap: wrap;
}

.rp-health-detail {
  font-size: 11px;
  font-weight: 400;
  color: #6b7280;
  display: block;
  width: 100%;
  margin-top: 2px;
}

/* ── Job search ───────────────────────────────────────────────────────────── */
.rp-job-search-wrap {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

.rp-job-search {
  width: 100%;
  min-width: 0;
}

/* ── Small button variant ─────────────────────────────────────────────────── */
.rp-btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* ── Needs Attention button ───────────────────────────────────────────────── */
.rp-btn-attn {
  background: #fef9c3;
  color: #854d0e;
  border-color: #fde047;
}
.rp-btn-attn:hover {
  background: #fef08a;
  border-color: #facc15;
}

/* ── Compare picker ───────────────────────────────────────────────────────── */
.rp-compare-picker {
  margin-bottom: 16px;
}
.rp-compare-picker select[multiple] {
  width: 100%;
  max-width: 480px;
  border: 1.5px solid #d1d5db;
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 13px;
  color: #1A1A2E;
  background: #fff;
  outline: none;
}
.rp-compare-picker select[multiple]:focus {
  border-color: #FF6B00;
}
.rp-compare-picker select[multiple] option:checked {
  background: #fff3e8;
  color: #FF6B00;
}

/* ── Responsive additions ─────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .rp-health-grid {
    grid-template-columns: 1fr;
  }

  .rp-job-search-wrap {
    max-width: 100%;
    width: 100%;
  }

  .rp-compare-picker select[multiple] {
    max-width: 100%;
  }
}
