/* =========================================================
   PilotMetrics - Reports page (scripts/reports.js)
   ========================================================= */

.rp-hint {
  font-size: 12px;
  color: var(--muted);
}

.rp-empty {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

/* Allowance */
.rp-allowance {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.rp-allowance-main {
  flex: 1;
  min-width: 240px;
}

.rp-allowance-count {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.rp-allowance-count b {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

.rp-allowance-count span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.rp-meter {
  height: 6px;
  max-width: 420px;
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-top: 8px;
  overflow: hidden;
}

.rp-meter-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  border-radius: 6px;
  transition: width 0.3s ease;
}

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

.rp-addon-soon {
  font-size: 12px;
  color: var(--muted);
  border: 1px dashed var(--line-light);
  border-radius: 6px;
  padding: 7px 10px;
}

/* Ready-made reports */
.rp-catalogue {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.rp-report {
  background: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.rp-report:hover {
  border-color: var(--line-light);
  transform: translateY(-1px);
}

.rp-report.featured {
  border-color: rgba(59, 130, 246, 0.55);
  background: linear-gradient(160deg, rgba(59, 130, 246, 0.12), none 60%);
}

.rp-report.locked {
  opacity: 0.85;
}

.rp-report-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.rp-report-icon,
.rp-modal-icon {
  font-size: 22px;
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--card);
  border: 1px solid var(--line-light);
  border-radius: 10px;
}

.rp-report h3 {
  margin: 0 0 4px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.rp-report p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.rp-featured {
  font-size: 12px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--cyan-light);
  color: var(--cyan);
}

.rp-report button {
  margin-top: auto;
  align-self: flex-start;
}

.rp-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.rp-chip {
  font-size: 12px;
  color: var(--text-soft);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2px 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.rp-chip.locked {
  opacity: 0.55;
}

/* Builder */
.rp-builder {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rp-step {
  display: flex;
  gap: 12px;
}

.rp-step-num {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--blue-light);
  color: #93c5fd;
  font-weight: 800;
  font-size: 12px;
  display: grid;
  place-items: center;
}

.rp-step-body {
  flex: 1;
  min-width: 0;
}

.rp-step-body h3,
.rp-label {
  margin: 2px 0 8px;
  font-size: 12px;
  color: var(--text-soft);
}

.rp-label {
  margin-top: 14px;
}

.rp-section-picks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px;
}

.rp-pick {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 10px;
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.rp-pick:has(input:checked) {
  border-color: rgba(59, 130, 246, 0.6);
  background: rgba(59, 130, 246, 0.08);
}

.rp-pick.locked {
  opacity: 0.55;
  cursor: not-allowed;
}

.rp-pick input {
  margin-top: 2px;
  accent-color: var(--blue);
}

.rp-pick b {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}

.rp-pick small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  margin-top: 2px;
}

.rp-quick {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.rp-builder-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

/* Period and options */
.rp-period-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.rp-period-row .field {
  flex: 1 1 140px;
}

.rp-range {
  margin: 6px 0 0;
}

.rp-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  margin-top: 8px;
  cursor: pointer;
}

.rp-check input {
  accent-color: var(--blue);
}

.rp-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rp-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.rp-seg label {
  cursor: pointer;
}

.rp-seg input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.rp-seg span {
  display: block;
  height: 100%;
  padding: 8px 10px;
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
}

.rp-seg span b {
  display: block;
  font-size: 12px;
  color: #fff;
}

.rp-seg input:checked + span {
  border-color: var(--blue);
  background: rgba(59, 130, 246, 0.1);
}

.rp-seg input:focus-visible + span {
  box-shadow: 0 0 0 2px var(--blue-light);
}

/* CSV exports: a slim strip, exports side by side (stacked on phones) */
.rp-csv-card {
  padding-top: 12px;
  padding-bottom: 12px;
}

.rp-csv-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.rp-csv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 8px;
}

.rp-csv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 8px 7px 10px;
  min-width: 0;
}

.rp-csv-item.locked {
  opacity: 0.8;
}

.rp-csv-icon {
  flex: none;
  font-size: 15px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: var(--card);
  border-radius: 6px;
}

.rp-csv-text {
  flex: 1;
  min-width: 0;
}

.rp-csv-text b {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}

.rp-csv-text small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rp-csv-item button {
  flex: none;
}

@media (max-width: 600px) {
  .rp-csv {
    grid-template-columns: 1fr;
  }

  .rp-csv-text small {
    white-space: normal;
  }
}

/* Past reports */
.rp-history {
  display: flex;
  flex-direction: column;
}

.rp-history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.rp-history-row:last-child {
  border-bottom: 0;
}

.rp-format {
  flex: none;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--danger-light);
  color: var(--alert-urgent);
}

.rp-format.csv {
  background: var(--green-light);
  color: #6ee7b7;
}

.rp-history-main {
  flex: 1;
  min-width: 0;
}

.rp-history-main b {
  display: block;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rp-history-main small {
  color: var(--muted);
  font-size: 12px;
}

.rp-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: #93c5fd;
  text-decoration: none;
  white-space: nowrap;
}

.rp-code:hover {
  text-decoration: underline;
}

@media (max-width: 600px) {
  .rp-history-row {
    flex-wrap: wrap;
  }

  .rp-history-main {
    flex-basis: calc(100% - 60px);
  }

  .rp-code {
    margin-left: 46px;
  }

  .rp-history-row button {
    margin-left: auto;
  }
}

/* Dialogs */
.rp-modal {
  max-width: 620px;
}

.rp-modal-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.rp-modal-head h3 {
  margin: 0;
  font-size: 17px;
}

.rp-modal-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.rp-progress {
  max-width: 420px;
  text-align: center;
}

.rp-progress h3 {
  margin: 10px 0 4px;
  font-size: 16px;
}

.rp-spinner {
  width: 36px;
  height: 36px;
  margin: 8px auto 0;
  border-radius: 50%;
  border: 3px solid var(--line-light);
  border-top-color: var(--blue);
  animation: rp-spin 0.8s linear infinite;
}

@keyframes rp-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .rp-spinner { animation-duration: 2.4s; }
}

.rp-ready-icon {
  font-size: 34px;
}

.rp-ready-code {
  font-size: 12px;
  color: var(--text-soft);
  margin: 8px 0 14px;
}

.rp-ready-code a {
  color: #93c5fd;
}

.rp-ready-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.rp-notice h2 {
  margin: 0;
}
