/* Reporting tab: a bright, light page inside the dark portal */
#panel-reporting, #panel-customers { background: #f4f5f3; }
.rp {
  --rp-bg: #f4f5f3; --rp-card: #ffffff; --rp-ink: #17201e; --rp-muted: #66706c; --rp-line: #e2e5e1; --rp-line2: #eef0ed;
  --rp-accent: #1d8a82; --rp-accent-soft: #e6f4f2; --rp-up: #23784a; --rp-down: #c2412d; --rp-amber: #a86a12; --rp-amber-soft: #fbf1df; --rp-red-soft: #fbe9e5;
  flex: 1; overflow-y: auto; background: var(--rp-bg); color: var(--rp-ink); font-family: "DM Sans", sans-serif; font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
.rp *, .rp h3 { margin: 0; }
.rp a.rp-go { color: inherit; text-decoration: none; border-bottom: 1px dotted #b9c2be; }
.rp a.rp-go:hover { color: var(--rp-accent); border-bottom-color: var(--rp-accent); }
.rp-wrap { max-width: 1180px; margin: 0 auto; padding: 24px 24px 64px; }
.rp-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.rp-title { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.1; }
.rp-sub { font-size: 13px; color: var(--rp-muted); margin-top: 4px; }
.rp-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rp-btn { font: 500 13px "DM Sans", sans-serif; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--rp-line); background: #fff; color: var(--rp-ink); cursor: pointer; }
.rp-btn:hover { border-color: var(--rp-accent); color: var(--rp-accent); }
.rp-btn.primary { background: var(--rp-accent); border-color: var(--rp-accent); color: #fff; }
.rp-btn.primary:hover { background: #17736c; color: #fff; }
.rp-btn:disabled { opacity: .5; cursor: default; }

.rp-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--rp-line); margin-bottom: 20px; overflow-x: auto; }
.rp-tab { font: 500 14px "DM Sans", sans-serif; padding: 10px 16px; background: none; border: none; border-bottom: 2px solid transparent; color: var(--rp-muted); cursor: pointer; white-space: nowrap; margin-bottom: -1px; }
.rp-tab:hover { color: var(--rp-ink); }
.rp-tab.on { color: var(--rp-accent); border-bottom-color: var(--rp-accent); }
.rp-count { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 6px; border-radius: 9px; background: var(--rp-line2); color: var(--rp-muted); font-size: 11px; line-height: 18px; text-align: center; }
.rp-tab.on .rp-count { background: var(--rp-accent-soft); color: var(--rp-accent); }

.rp-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.rp-tile { background: var(--rp-card); border: 1px solid var(--rp-line); border-radius: 10px; padding: 14px 16px; }
.rp-tile-label { font-size: 13px; color: var(--rp-muted); font-weight: 500; }
.rp-tile-value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.rp-tile-foot { font-size: 13px; color: var(--rp-muted); line-height: 1.45; }
.rp-tile-foot b { color: var(--rp-ink); }
.rp-up { color: var(--rp-up); font-weight: 600; }
.rp-down { color: var(--rp-down); font-weight: 600; }

.rp-grid2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 16px; }
.rp-card { background: var(--rp-card); border: 1px solid var(--rp-line); border-radius: 10px; padding: 16px; margin-bottom: 16px; min-width: 0; }
.rp-grid2 .rp-card { margin-bottom: 0; }
.rp-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.rp-card .rp-note { font-size: 13px; margin-top: 2px; color: var(--rp-muted); margin-bottom: 12px; line-height: 1.5; }
.rp-grid2 .rp-card { display: flex; flex-direction: column; }
.rp-chart { flex: 1; position: relative; min-height: 260px; margin-top: 4px; }
.rp-chart svg { position: absolute; left: 0; top: 0; display: block; }

.rp-tablewrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table.rp-t { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.rp-t th { text-align: left; font-weight: 600; font-size: 12px; color: var(--rp-muted); padding: 8px 10px; border-bottom: 1px solid var(--rp-line); white-space: nowrap; background: #fafbfa; position: sticky; top: 0; }
.rp-t th.sort { cursor: pointer; user-select: none; }
.rp-t th.sort:hover { color: var(--rp-ink); }
.rp-t td { padding: 8px 10px; border-bottom: 1px solid var(--rp-line2); vertical-align: top; }
.rp-t tr:last-child td { border-bottom: none; }
.rp-t tbody tr:hover td { background: #f8faf9; }
.rp-t .num { text-align: right; white-space: nowrap; }
.rp-t tfoot td { font-weight: 600; border-top: 1px solid var(--rp-line); border-bottom: none; }
.rp-detail { font-size: 12px; color: var(--rp-muted); margin-top: 2px; line-height: 1.4; }

.rp-badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.rp-badge.action { background: var(--rp-red-soft); color: var(--rp-down); }
.rp-badge.check { background: var(--rp-amber-soft); color: var(--rp-amber); }
.rp-badge.new { background: var(--rp-accent-soft); color: var(--rp-accent); }
.rp-badge.ok { background: #e5f3ea; color: var(--rp-up); }

.rp-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.rp-in, .rp-sel, .rp-ta { font: 13px "DM Sans", sans-serif; color: var(--rp-ink); background: #fff; border: 1px solid var(--rp-line); border-radius: 7px; padding: 6px 9px; outline: none; }
.rp-in:focus, .rp-sel:focus, .rp-ta:focus { border-color: var(--rp-accent); box-shadow: 0 0 0 3px var(--rp-accent-soft); }
.rp-ta { width: 100%; min-width: 180px; resize: vertical; height: 34px; min-height: 34px; line-height: 1.4; }
.rp-check { font-size: 13px; color: var(--rp-muted); display: inline-flex; gap: 6px; align-items: center; }
.rp-saved { font-size: 11px; color: var(--rp-up); }
.rp-err { font-size: 11px; color: var(--rp-down); }
.rp-who { font-size: 11px; color: var(--rp-muted); margin-top: 3px; }

.rp-form { display: grid; grid-template-columns: 2fr 1.2fr .8fr 1fr; gap: 8px; margin-bottom: 8px; }
.rp-form .rp-ta { grid-column: 1 / -1; }
.rp-empty { padding: 28px; text-align: center; color: var(--rp-muted); }
.rp-banner { background: var(--rp-red-soft); color: var(--rp-down); border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; font-size: 13px; }
.rp-more { text-align: center; padding: 12px 0 0; }

@media (max-width: 900px) {
  .rp-tiles { grid-template-columns: 1fr 1fr; }
  .rp-grid2 { grid-template-columns: 1fr; }
  .rp-grid2 .rp-card { margin-bottom: 0; }
  .rp-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .rp-wrap { padding: 16px 16px 48px; }
  .rp-title { font-size: 22px; }
  .rp-tile-value { font-size: 22px; }
  .rp-chart { min-height: 220px; }
  .rp-tile { padding: 12px; }
}

/* ---------- franchisee page ---------- */
.rp-crumb { margin: -4px 0 10px; font-size: 13px; }
.rp-crumb a { color: var(--rp-accent); text-decoration: none; }
.rp-crumb a:hover { text-decoration: underline; }
.rp-frhead { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.rp-frname { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.rp-cardhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.rp-btn.rp-small { padding: 4px 10px; font-size: 12px; }
.rp-points { margin: 4px 0 0 18px; padding: 0; }
.rp-points li { margin: 0 0 10px; line-height: 1.5; font-size: 14px; }
.rp-pat { border-left: 3px solid var(--rp-amber); background: var(--rp-amber-soft); border-radius: 0 8px 8px 0; padding: 8px 12px; margin-bottom: 8px; }
.rp-pat.good { border-left-color: var(--rp-up); background: #e5f3ea; }
.rp-pat-t { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.rp-pat.good .rp-pat-t { color: var(--rp-up); }
.rp-pat.watch .rp-pat-t { color: var(--rp-amber); }
/* Worth a look: one line per pattern, opens to show the franchisees */
.rp-patgroup summary { cursor: pointer; margin-bottom: 0; list-style: none; }
.rp-patgroup summary::-webkit-details-marker { display: none; }
.rp-patgroup summary::after { content: ' ▸'; color: var(--rp-muted); font-weight: 400; }
.rp-patgroup[open] summary::after { content: ' ▾'; }
.rp-patn { font-weight: 400; color: var(--rp-muted); }
.rp-patgroup ul { margin: 6px 0 2px; padding: 0 0 0 16px; }
.rp-patgroup li { font-size: 13px; margin: 0 0 4px; line-height: 1.45; }
.rp-patgroup li .rp-detail { margin-left: 4px; }
/* Franchisees table: one chip per flagged pattern */
.rp-chips { display: flex; flex-wrap: wrap; gap: 4px; min-width: 120px; }
.rp-chip { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; cursor: pointer; background: var(--rp-amber-soft); color: var(--rp-amber); }
.rp-chip.good { background: #e5f3ea; color: var(--rp-up); }
.rp-tip { position: fixed; z-index: 50; display: none; max-width: 280px; background: #17201e; color: #fff; font-family: "DM Sans", sans-serif; font-size: 12px; line-height: 1.45; padding: 7px 10px; border-radius: 6px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18); }
/* Territory tab and franchisee panel */
.rp-tchart { width: 100%; height: auto; display: block; }
.rp-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--rp-muted); margin-bottom: 6px; }
.rp-legend-i i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.rp-rowlink { cursor: pointer; }
.rp-t tr.rp-grpfirst td { border-top: 1px solid var(--rp-line); }
.rp-t tr.rp-subtot td { font-weight: 600; color: var(--rp-muted); background: #fafbfa; }
.rp-tbar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--rp-line2); margin: 2px 0 10px; }
.rp-tbar i { display: block; height: 100%; }
.rp-tsplit { display: flex; gap: 6px 16px; flex-wrap: wrap; font-size: 13px; }
.rp-grid2.rp-even { grid-template-columns: 1fr 1fr; align-items: start; }
.rp-grid2.rp-even .rp-card { display: block; }
.rp-a.rp-go { cursor: pointer; }

/* ---------- one-page PDF (printed from the browser) ---------- */
#rp-print { display: none; }
@media print {
  @page { size: A4 portrait; margin: 9mm; }
  html, body { background: #fff !important; height: auto !important; overflow: visible !important; }
  body > *:not(#rp-print) { display: none !important; }
  #rp-print { display: block !important; }
  .rp-paper { display: block; overflow: visible; background: #fff; font-size: 10px; color: #17201e; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rp-paper .rp-pp-head { display: flex; align-items: center; gap: 14px; border-bottom: 2px solid #1d8a82; padding-bottom: 6px; margin-bottom: 8px; }
  .rp-paper .rp-pp-head img { height: 30px; }
  .rp-paper .rp-frname { font-size: 17px; }
  .rp-paper .rp-sub { font-size: 9px; margin-top: 1px; }
  .rp-paper .rp-tiles { grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 6px; }
  .rp-paper .rp-tile { padding: 6px 8px; border-radius: 6px; }
  .rp-paper .rp-tile-label, .rp-paper .rp-tile-foot { font-size: 8.5px; }
  .rp-paper .rp-tile-value { font-size: 16px; margin: 1px 0; }
  .rp-paper .rp-pp-cols { display: grid; grid-template-columns: 1.1fr 1fr; gap: 8px; }
  .rp-paper .rp-card { padding: 7px 9px; margin-bottom: 6px; border-radius: 6px; break-inside: avoid; }
  .rp-paper .rp-card h3 { font-size: 11px; }
  .rp-paper .rp-note { font-size: 8.5px; margin-bottom: 4px; }
  .rp-paper .rp-t { font-size: 9px; }
  .rp-paper .rp-t th, .rp-paper .rp-t td { padding: 2px 5px; position: static; white-space: nowrap; }
  .rp-paper .rp-t th { font-size: 8.5px; }
  .rp-paper .rp-t td:nth-child(2) { white-space: normal; }
  .rp-paper .rp-tablewrap { overflow: visible; margin: 0; padding: 0; }
  .rp-paper .rp-points li { font-size: 9.5px; margin-bottom: 4px; line-height: 1.35; }
  .rp-paper .rp-pat { padding: 3px 7px; margin-bottom: 4px; }
  .rp-paper .rp-pat-t { font-size: 9.5px; }
  .rp-paper .rp-detail { font-size: 8.5px; }
  .rp-paper .rp-badge { font-size: 8px; padding: 1px 5px; }
  .rp-paper .rp-printchart svg { width: 100%; height: auto; display: block; }
  .rp-paper .rp-pp-foot { margin-top: 4px; font-size: 8px; color: #66706c; border-top: 1px solid #e2e5e1; padding-top: 4px; }
}
@media (max-width: 900px) { .rp-grid2.rp-even { grid-template-columns: 1fr; } }

/* ---------- two-step sign-in ---------- */
.rp-mfa { max-width: 560px; }
.rp-mfa h3 { margin-bottom: 4px; }
.rp-steps { margin: 6px 0 12px 20px; padding: 0; font-size: 14px; line-height: 1.55; }
.rp-steps li { margin-bottom: 6px; }
.rp-key { font-family: ui-monospace, Menlo, monospace; background: var(--rp-line2); padding: 2px 6px; border-radius: 5px; word-break: break-all; }
.rp-qr { margin: 4px 0 14px; }
.rp-qr img { width: 180px; height: 180px; border: 1px solid var(--rp-line); border-radius: 10px; padding: 6px; background: #fff; }
.rp-mfa-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rp-mfa-in { font-size: 20px; letter-spacing: .3em; width: 150px; text-align: center; padding: 8px 10px; }

/* ---------- settings ---------- */
.rp-setrow { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--rp-line2); flex-wrap: wrap; }
.rp-setrow:last-child { border-bottom: none; }
.rp-setrow label { flex: 1; min-width: 200px; font-size: 13px; }
.rp-setrow .rp-who { width: 100%; margin: 0; }
.rp-bigrate { font-size: 24px; font-weight: 600; margin-top: 4px; }
.rp-rateform { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-top: 14px; }
.rp-rateform label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--rp-muted); }
.rp-rateform input[type=number] { width: 90px; }
.rp-t input[type=checkbox], .rp-card input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--rp-accent); }

/* ---------- marketing fund ---------- */
.rp-upload-preview { margin-top: 10px; padding: 10px 12px; background: var(--rp-accent-soft); border-radius: 8px; font-size: 13px; }

/* ---------- franchisee pack (printed) ---------- */
@media print {
  .rp-paper .rp-pk-intro { font-size: 10.5px; margin: 0 0 8px; }
  .rp-paper .rp-pk-group { margin-bottom: 6px; }
  .rp-paper .rp-pk-group .rp-pat-t { color: #17201e; }
}
@media (max-width: 900px) { .rp-tiles[style*="repeat(3"] { grid-template-columns: 1fr !important; } }

/* ---------- period picker, Key and accessories ---------- */
.rp-period { background: var(--rp-card); border: 1px solid var(--rp-line); border-radius: 10px; padding: 10px 12px; margin: -6px 0 16px; }
.rp-i { display: inline-block; margin-left: 4px; font-size: 12px; font-weight: 400; line-height: 1; color: var(--rp-muted); cursor: help; vertical-align: 1px; text-transform: none; }
.rp-i:hover, .rp-i:focus { color: var(--rp-accent); outline: none; }
.rp-keylist { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; line-height: 1.45; }
.rp-keylist dt { font-weight: 600; white-space: nowrap; }
.rp-keylist dd { color: var(--rp-ink); }
.rp-notice { background: var(--rp-amber-soft); color: var(--rp-amber); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-size: 13px; }
.rp-top3 { margin: 8px 0 0 18px; padding: 0; font-size: 13px; line-height: 1.5; }
@media (max-width: 520px) { .rp-keylist { grid-template-columns: 1fr; } .rp-keylist dd { margin-bottom: 6px; } }
