@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@500;600;700;800&family=Mulish:wght@400;500;600;700;800&display=swap");

* { box-sizing: border-box; }

:root {
  --ink: #16273F;
  --body: #33404F;
  --body2: #2B3644;
  --muted: #8791A0;
  --muted2: #5B6675;
  --muted3: #98A2B0;
  --axis: #A2ABBA;
  --card-border: #EAEDF3;
  --panel-border: #E7EBF1;
  --row-border: #F1F4F8;
  --track: #EEF1F6;
  --red: #E8402A;
  --red-hover: #D5361F;
  --red-disabled: #F0B7AD;
  --blue: #3C7CE0;
  --violet: #7A5AF0;
  --violet2: #6A45C9;
  --green: #1FA97A;
  --green2: #1F8A5B;
  --amber: #E0862A;
  --link: #2F6FE0;
  --link-hover: #1E56C0;
}

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  font-family: "Mulish", system-ui, sans-serif;
  color: var(--body);
  background: linear-gradient(180deg, #F5F3FB 0%, #F1F6F6 100%);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; cursor: pointer; }
body.modal-open { overflow: hidden; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
body.auth-pending .app-shell { display: none; }

/* 90% width to match the sibling redesigned apps. */
.app-shell .rm-header-inner,
.app-shell .rm-footer-inner { max-width: 90%; }

@keyframes rpFadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes rpDrawBar { from { width: 0; } }
@keyframes rpModalIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ------------------------------- Main ------------------------------- */
.rp-main {
  flex: 1;
  max-width: 90%;
  width: 100%;
  margin: 0 auto;
  padding: 32px 32px 56px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.rp-view { display: flex; flex-direction: column; gap: 24px; animation: rpFadeUp 0.3s ease both; }
/* Individual report detail view is capped narrower than the full-width list/builder. */
.rp-view--report { max-width: 1080px; width: 100%; margin: 0 auto; }

/* ------------------------------- Shared card ------------------------------- */
.rp-card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(18, 38, 63, 0.05);
}
.rp-card-head { padding: 22px 26px 18px; }
.rp-card-title { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 18px; color: var(--ink); margin: 0; }
.rp-card-sub { font-size: 13px; color: var(--muted3); margin: 3px 0 0; }

/* ------------------------------- Title row (list) ------------------------------- */
.rp-titlerow { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.rp-title {
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  font-size: 38px;
  line-height: 1.05;
  letter-spacing: -0.5px;
  color: var(--ink);
  margin: 0 0 6px;
}
.rp-subtitle { font-size: 15.5px; color: var(--muted); margin: 0; }

/* ------------------------------- Buttons ------------------------------- */
.rp-create-btn,
.rp-export-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--red);
  border: none;
  color: #fff;
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  font-size: 15px;
  padding: 14px 24px;
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(232, 64, 42, 0.28);
}
.rp-export-btn { padding: 13px 22px; }
.rp-create-btn:hover,
.rp-export-btn:hover { background: var(--red-hover); }
.rp-create-btn svg, .rp-export-btn svg { stroke: #fff; }

/* ------------------------------- Reports table ------------------------------- */
.rp-table-wrap { overflow-x: auto; }
.rp-table { width: 100%; border-collapse: collapse; min-width: 960px; }
.rp-table thead tr { background: #F8FAFD; border-top: 1px solid var(--card-border); border-bottom: 1px solid var(--card-border); }
.rp-table th {
  text-align: left;
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 14px 18px;
}
.rp-table th:first-child { padding-left: 26px; }
.rp-table th.rp-th-actions, .rp-table td.rp-td-actions { text-align: right; padding-right: 26px; }
.rp-table td { padding: 16px 18px; vertical-align: top; }
.rp-table td:first-child { padding-left: 26px; }
.rp-table tbody tr { border-bottom: 1px solid var(--row-border); }
.rp-table tbody tr:last-child { border-bottom: none; }

.rp-name-cell { display: flex; align-items: center; gap: 12px; }
.rp-name-icon { width: 36px; height: 36px; border-radius: 10px; background: #FBEAE7; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.rp-name-text { font-family: "Poppins", sans-serif; font-weight: 600; font-size: 15px; color: var(--ink); }
.rp-chips { display: flex; flex-wrap: wrap; gap: 6px; max-width: 230px; }
.rp-chip {
  display: inline-block;
  font-family: "Mulish", sans-serif;
  font-weight: 700;
  font-size: 11.5px;
  border-radius: 7px;
  padding: 3px 9px;
  white-space: nowrap;
}
.rp-chip--domain { background: #EAF1FC; color: var(--link); }
.rp-chip--product { background: #F1EEFC; color: var(--violet2); }
.rp-chip--more { background: var(--track); color: var(--muted2); }
.rp-span-cell { font-family: "Mulish", sans-serif; font-weight: 600; font-size: 14px; color: var(--muted2); white-space: nowrap; }
.rp-created-cell { font-size: 13.5px; color: var(--muted); white-space: nowrap; }

.rp-row-actions { display: flex; gap: 8px; justify-content: flex-end; }
.rp-view-btn {
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #E4E8EF;
  border-radius: 9px;
  padding: 8px 18px;
}
.rp-view-btn:hover { border-color: var(--blue); color: var(--blue); }
.rp-delete-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: #fff;
  border: 1px solid #E4E8EF;
  border-radius: 9px;
  color: var(--muted3);
}
.rp-delete-btn:hover { border-color: var(--red); color: var(--red); background: #FEF4F2; }

.rp-empty {
  padding: 56px 26px;
  text-align: center;
}
.rp-empty-title { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 17px; color: var(--ink); }
.rp-empty-sub { font-size: 14px; color: var(--muted); margin-top: 6px; }

/* ------------------------------- Detail: back + header ------------------------------- */
.rp-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: none;
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  padding: 0;
  margin-bottom: 14px;
}
.rp-back:hover { color: var(--ink); }
.rp-detail-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.rp-detail-title {
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: -0.5px;
  color: var(--ink);
  margin: 0 0 10px;
}
.rp-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rp-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  color: var(--muted2);
  background: #fff;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 6px 13px;
}

.rp-meta-chip--tpl { color: var(--violet2); }
.rp-meta-chip--tpl svg { flex: 0 0 auto; }

/* Templated report detail: stacked widget cards (reuses .rp-wcard) */
.rp-report-widgets { display: flex; flex-direction: column; gap: 16px; }

/* ------------------------------- Detail: KPI row ------------------------------- */
.rp-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.rp-kpi {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 18px;
  box-shadow: 0 4px 16px rgba(18, 38, 63, 0.05);
  padding: 22px;
}
.rp-kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rp-kpi-icon { flex: 0 0 auto; width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.rp-kpi-delta { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 12px; border-radius: 7px; padding: 3px 9px; white-space: nowrap; }
.rp-kpi-delta.up { color: var(--green); background: #E7F7F1; border: 1px solid #CDEDE1; }
.rp-kpi-delta.neutral { color: var(--muted2); background: var(--track); border: 1px solid #E0E5EE; }
.rp-kpi-value { font-family: "Poppins", sans-serif; font-weight: 800; font-size: 30px; color: var(--ink); line-height: 1; margin-top: 16px; }
.rp-kpi-label { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 7px; }

/* ------------------------------- Detail: trend chart ------------------------------- */
.rp-chart-card { padding: 26px; }
.rp-chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.rp-legend { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted2); font-weight: 600; }
.rp-swatch { width: 11px; height: 11px; border-radius: 3px; background: var(--blue); }
.rp-chart-wrap { position: relative; margin-top: 16px; height: 300px; }
.rp-chart-wrap canvas { width: 100% !important; height: 100% !important; }
.rp-chart-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; margin: 0; }

/* ------------------------------- Detail: per-product ------------------------------- */
.rp-product { padding: 26px; }
.rp-product-head { display: flex; align-items: center; gap: 13px; margin-bottom: 20px; }
.rp-product-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.rp-product-name { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 19px; color: var(--ink); margin: 0; }
.rp-product-sub { font-size: 13px; color: var(--muted3); margin-top: 2px; }
.rp-product-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 26px; align-items: start; }

.rp-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.rp-stat { background: #F8FAFC; border: 1px solid var(--track); border-radius: 14px; padding: 16px 18px; }
.rp-stat-value { font-family: "Poppins", sans-serif; font-weight: 800; font-size: 26px; color: var(--ink); line-height: 1; }
.rp-stat-label { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-top: 6px; }

.rp-bars-title { font-family: "Poppins", sans-serif; font-weight: 600; font-size: 13.5px; color: var(--muted2); margin-bottom: 14px; }
.rp-bars { display: flex; flex-direction: column; gap: 13px; }
.rp-bar-row { display: flex; align-items: center; gap: 12px; }
.rp-bar-name { width: 150px; flex: 0 0 auto; font-family: "Mulish", sans-serif; font-weight: 600; font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-bar-track { flex: 1; height: 12px; border-radius: 999px; background: var(--track); overflow: hidden; }
.rp-bar-fill { height: 100%; border-radius: 999px; animation: rpDrawBar 0.6s ease; }
.rp-bar-value { width: 52px; flex: 0 0 auto; text-align: right; font-family: "Poppins", sans-serif; font-weight: 700; font-size: 13.5px; color: var(--ink); }

/* ------------------------------- Create modal ------------------------------- */
.rp-modal { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-start; justify-content: center; padding: 48px 20px; overflow-y: auto; }
.rp-modal-backdrop { position: fixed; inset: 0; background: rgba(16, 26, 40, 0.5); }
.rp-modal-panel {
  position: relative;
  width: 100%;
  max-width: 640px;
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 30px 80px -18px rgba(16, 26, 40, 0.5);
  animation: rpModalIn 0.28s cubic-bezier(.22,.61,.36,1) both;
  overflow: hidden;
}
.rp-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 24px 28px; border-bottom: 1px solid var(--track); }
.rp-modal-title { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 22px; color: var(--ink); margin: 0; letter-spacing: -0.3px; }
.rp-modal-sub { font-size: 13.5px; color: var(--muted); margin: 3px 0 0; }
.rp-modal-close { width: 40px; height: 40px; border-radius: 12px; background: #F4F6FA; border: 1px solid #E4E8EF; color: var(--muted2); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.rp-modal-close:hover { background: #EBEFF5; }
.rp-modal-body { padding: 24px 28px; display: flex; flex-direction: column; gap: 26px; }

.rp-field { display: block; }
.rp-field-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 11px; }
.rp-label { display: block; font-family: "Poppins", sans-serif; font-weight: 600; font-size: 13.5px; color: var(--ink); margin-bottom: 9px; }
.rp-field-head .rp-label { margin-bottom: 0; }
.rp-hint { color: #B0B8C4; font-weight: 500; }
.rp-count { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 12.5px; }
.rp-count--blue { color: var(--link); }
.rp-count--violet { color: var(--violet); }

.rp-input {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  font-family: "Mulish", sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: #F6F8FC;
  border: 1.6px solid #E4E9F1;
  border-radius: 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.rp-input:focus { border-color: var(--link); box-shadow: 0 0 0 4px rgba(47, 111, 224, 0.12); background: #fff; }

.rp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rp-opt {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1.6px solid #E4E9F1;
  border-radius: 12px;
  padding: 12px 14px;
  transition: all .13s ease;
}
.rp-opt-box {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  flex: 0 0 auto;
  border: 1.8px solid #C7D0DE;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .13s ease;
}
.rp-opt-box svg { display: none; }
.rp-opt-label { font-family: "Mulish", sans-serif; font-weight: 600; font-size: 14px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-opt.is-checked svg { display: block; }
/* domain accent */
.rp-grid--domain .rp-opt.is-checked { background: #EFF5FE; border-color: var(--link); }
.rp-grid--domain .rp-opt.is-checked .rp-opt-box { background: var(--link); border-color: var(--link); }
/* product accent */
.rp-grid--product .rp-opt.is-checked { background: #F4F1FE; border-color: var(--violet); }
.rp-grid--product .rp-opt.is-checked .rp-opt-box { background: var(--violet); border-color: var(--violet); }

.rp-spans { display: flex; flex-wrap: wrap; gap: 9px; }
.rp-span {
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--muted2);
  background: #fff;
  border: 1.6px solid #E4E9F1;
  border-radius: 999px;
  padding: 9px 16px;
}
.rp-span.is-selected { color: #fff; background: var(--ink); border-color: var(--ink); }

.rp-empty-note { font-size: 13.5px; color: var(--muted); margin: 4px 0 0; }

.rp-modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 20px 28px; border-top: 1px solid var(--track); background: #FBFCFE; }
.rp-btn-ghost {
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  font-size: 14.5px;
  color: var(--muted2);
  background: #fff;
  border: 1px solid #E4E8EF;
  border-radius: 11px;
  padding: 12px 22px;
}
.rp-btn-ghost:hover { border-color: #C7D0DE; }
.rp-btn-primary {
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  font-size: 14.5px;
  color: #fff;
  background: var(--red);
  border: none;
  border-radius: 11px;
  padding: 12px 24px;
  box-shadow: 0 6px 16px rgba(232, 64, 42, 0.28);
}
.rp-btn-primary:hover:not(:disabled) { background: var(--red-hover); }
.rp-btn-primary:disabled { background: var(--red-disabled); box-shadow: none; cursor: not-allowed; }

/* ------------------------------- Tab band ------------------------------- */
.rp-tabband {
  position: relative;
  left: 50%;
  margin-left: -50vw;
  width: 100vw;
  background: #fff;
  border-top: 1px solid var(--panel-border);
  border-bottom: 1px solid var(--panel-border);
  box-shadow: 0 1px 2px rgba(18, 38, 63, 0.04);
}
.rp-tabband-inner { max-width: 90%; margin: 0 auto; padding: 0 32px; display: flex; align-items: center; gap: 6px; }
.rp-tab {
  background: none;
  border: none;
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--muted);
  padding: 16px 14px;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}
.rp-tab:hover { color: var(--ink); }
.rp-tab.is-active { font-weight: 700; color: var(--ink); border-bottom-color: var(--red); }
.rp-tab:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 6px; }

/* ------------------------------- Templates table ------------------------------- */
.rp-name-icon--tpl { background: #EDEBFB; }
.rp-type-pill {
  display: inline-block;
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  font-size: 11.5px;
  border-radius: 7px;
  padding: 4px 11px;
  white-space: nowrap;
}
.rp-type-pill--default { color: #2F6FE0; background: #EAF1FC; }
.rp-type-pill--custom { color: var(--violet2); background: #F1EEFC; }

/* "Template" column tag in the Saved reports table */
.rp-tpl-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 200px;
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--violet2);
  background: #F1EEFC;
  border-radius: 8px;
  padding: 5px 10px;
}
.rp-tpl-tag svg { flex: 0 0 auto; }
.rp-tpl-tag-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-tpl-none { color: var(--muted3); font-weight: 600; }
.rp-delete-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.rp-delete-btn:disabled:hover { border-color: #E4E8EF; color: var(--muted3); background: #fff; }

/* ------------------------------- Modal: template picker ------------------------------- */
.rp-select-wrap { position: relative; }
.rp-select {
  width: 100%;
  height: 50px;
  padding: 0 42px 0 16px;
  font-family: "Mulish", sans-serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  background: #F6F8FC;
  border: 1.6px solid #E4E9F1;
  border-radius: 12px;
  outline: none;
  appearance: none;
  cursor: pointer;
}
.rp-select:focus { border-color: var(--link); box-shadow: 0 0 0 4px rgba(47, 111, 224, 0.12); background: #fff; }
.rp-select-caret { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); pointer-events: none; display: flex; }
.rp-field-divider { height: 1px; background: var(--row-border); margin-top: 26px; }

/* ------------------------------- Template Builder ------------------------------- */
.rp-builder { display: flex; flex-direction: column; gap: 22px; animation: rpFadeUp 0.3s ease both; width: 100%; max-width: 1500px; margin: 0 auto; }
.rp-builder-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.rp-builder-headtext { min-width: 0; }
.rp-builder-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  font-size: 11.5px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--violet);
  background: #F1EEFC;
  border-radius: 999px;
  padding: 5px 12px;
  margin-bottom: 10px;
}
.rp-builder-title { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 32px; line-height: 1.05; letter-spacing: -0.5px; color: var(--ink); margin: 0 0 8px; }
.rp-builder-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rp-builder-metachip { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted2); background: #fff; border: 1px solid var(--panel-border); border-radius: 999px; padding: 5px 12px; }
.rp-builder-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.rp-btn-outline {
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  font-size: 14.5px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #E4E8EF;
  border-radius: 12px;
  padding: 12px 20px;
  box-shadow: 0 1px 2px rgba(18, 38, 63, 0.05);
}
.rp-btn-outline:hover { border-color: var(--blue); color: var(--blue); }
.rp-builder-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 26px; align-items: start; }

/* Canvas */
.rp-canvas { display: flex; flex-direction: column; gap: 16px; }
.rp-canvas-empty { background: #fff; border: 1px dashed #D5DDE8; border-radius: 18px; padding: 70px 26px; text-align: center; }
.rp-canvas-empty-icon { width: 52px; height: 52px; margin: 0 auto 16px; border-radius: 14px; background: #F1EEFC; display: flex; align-items: center; justify-content: center; }
.rp-canvas-empty-title { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 17px; color: var(--ink); }
.rp-canvas-empty-sub { font-size: 14px; color: var(--muted); margin-top: 6px; }

/* Placed widget card */
.rp-wcard { background: #fff; border: 1px solid var(--card-border); border-radius: 18px; box-shadow: 0 4px 16px rgba(18, 38, 63, 0.05); overflow: hidden; animation: rpFadeUp 0.25s ease both; }
.rp-wcard-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--row-border); background: #FBFCFE; }
.rp-wcard-cat { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rp-wcard-cat span { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 10.5px; letter-spacing: 0.5px; text-transform: uppercase; color: var(--muted3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-wcard-tools { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.rp-wbtn { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; background: #fff; border: 1px solid #E4E8EF; border-radius: 8px; color: var(--muted2); }
.rp-wbtn:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.rp-wbtn--del:hover:not(:disabled) { border-color: var(--red); color: var(--red); background: #FEF4F2; }
.rp-wbtn:disabled { background: #F6F8FC; border-color: var(--row-border); color: #C6CDD8; cursor: not-allowed; }
.rp-wcard-body { padding: 22px 24px; }
.rp-wcard-head { margin-bottom: 16px; }
.rp-wcard-title { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 17px; color: var(--ink); }
.rp-wcard-sub { font-size: 13px; color: var(--muted3); margin-top: 2px; }

/* Library panel */
.rp-library { position: sticky; top: 24px; background: #fff; border: 1px solid var(--card-border); border-radius: 18px; box-shadow: 0 4px 16px rgba(18, 38, 63, 0.05); display: flex; flex-direction: column; max-height: calc(100vh - 48px); overflow: hidden; }
.rp-library-head { padding: 18px 20px 14px; border-bottom: 1px solid var(--row-border); }
.rp-library-title { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 16px; color: var(--ink); }
.rp-library-sub { font-size: 12.5px; color: var(--muted3); margin-top: 2px; }
.rp-library-scroll { overflow-y: auto; padding: 8px; }
.rp-libsec { padding: 10px 10px 4px; }
.rp-libsec-title { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 11px; letter-spacing: 0.5px; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.rp-libsec-items { display: flex; flex-direction: column; gap: 6px; }
.rp-libentry { display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; background: #fff; border: 1px solid #EDEFF4; border-radius: 11px; padding: 11px 12px; transition: border-color 0.13s, background 0.13s; }
.rp-libentry:hover { border-color: var(--violet); background: #FAF9FE; }
.rp-libentry:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }
.rp-libentry-icon { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; }
.rp-libentry-text { flex: 1; min-width: 0; }
.rp-libentry-name { display: block; font-family: "Poppins", sans-serif; font-weight: 600; font-size: 13.5px; color: var(--ink); }
.rp-libentry-desc { display: block; font-size: 11.5px; color: var(--muted3); line-height: 1.4; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-libentry-add { flex: 0 0 auto; width: 24px; height: 24px; border-radius: 7px; background: #F1EEFC; display: flex; align-items: center; justify-content: center; }

/* Widget kinds */
.rp-w-cover { background: linear-gradient(150deg, #0E2036, #16273F 55%, #1E4363); border-radius: 14px; padding: 36px 34px; color: #fff; }
.rp-w-cover-logo { height: 34px; width: auto; display: block; margin-bottom: 26px; }
.rp-w-cover-name { font-family: "Poppins", sans-serif; font-weight: 800; font-size: 30px; letter-spacing: -0.6px; }
.rp-w-cover-meta { font-size: 14px; color: #B9C6D8; margin-top: 14px; }
.rp-w-cover-date { font-size: 12.5px; color: #7E8EA4; margin-top: 20px; }

.rp-w-text { display: flex; flex-direction: column; gap: 11px; }
.rp-w-para { font-size: 14.5px; line-height: 1.7; color: #4A5563; }

.rp-w-divider { display: flex; align-items: center; gap: 14px; }
.rp-w-divider-bar { width: 5px; height: 26px; border-radius: 3px; background: var(--red); }
.rp-w-divider-text { font-family: "Poppins", sans-serif; font-weight: 800; font-size: 20px; color: var(--ink); letter-spacing: -0.3px; }
.rp-w-pagebreak { display: flex; align-items: center; gap: 12px; color: var(--muted3); }
.rp-w-pb-line { flex: 1; height: 0; border-top: 2px dashed #D5DDE8; }
.rp-w-pb-text { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 12px; letter-spacing: 0.5px; text-transform: uppercase; }

.rp-w-signoff { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.rp-w-sign-line { height: 44px; border-bottom: 1.5px solid #C7D0DE; }
.rp-w-sign-role { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 13.5px; color: var(--ink); margin-top: 8px; }
.rp-w-sign-hint { font-size: 12.5px; color: var(--muted3); }

.rp-w-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.rp-w-kpitile { background: #F8FAFC; border: 1px solid var(--row-border); border-radius: 14px; padding: 16px 18px; }
.rp-w-kpival { font-family: "Poppins", sans-serif; font-weight: 800; font-size: 24px; color: var(--ink); line-height: 1; }
.rp-w-kpilabel { font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 6px; }
.rp-w-kpidelta { display: inline-block; margin-top: 9px; font-family: "Poppins", sans-serif; font-weight: 700; font-size: 11px; color: var(--green); background: #E7F7F1; border-radius: 999px; padding: 2px 9px; }

.rp-w-ring { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.rp-w-ring-dial { flex: 0 0 auto; width: 110px; height: 110px; border-radius: 50%; position: relative; }
.rp-w-ring-hole { position: absolute; inset: 14px; border-radius: 50%; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.rp-w-ring-pct { font-family: "Poppins", sans-serif; font-weight: 800; font-size: 24px; color: var(--ink); line-height: 1; }
.rp-w-ring-cap { font-size: 9px; font-weight: 700; letter-spacing: 0.4px; color: var(--muted3); margin-top: 3px; }
.rp-w-ring-stats { flex: 1; min-width: 150px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rp-w-ring-statval { font-family: "Poppins", sans-serif; font-weight: 800; font-size: 19px; color: var(--ink); }
.rp-w-ring-statlabel { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.rp-w-line-svg { width: 100%; height: auto; display: block; }
.rp-w-line-labels { display: flex; justify-content: space-between; margin-top: 9px; }
.rp-w-line-labels span { font-size: 11px; color: var(--muted3); font-weight: 600; }
.rp-w-line-legend { display: flex; gap: 16px; margin-top: 12px; }
.rp-w-legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted2); font-weight: 600; }
.rp-w-swatch { width: 10px; height: 10px; border-radius: 3px; }

.rp-w-sev-bar { display: flex; height: 15px; border-radius: 999px; overflow: hidden; gap: 3px; }
.rp-w-sev-legend { display: flex; flex-wrap: wrap; gap: 12px 20px; margin-top: 16px; }
.rp-w-sev-item { display: flex; align-items: center; gap: 8px; }
.rp-w-dot { width: 9px; height: 9px; border-radius: 50%; }
.rp-w-sev-label { font-family: "Poppins", sans-serif; font-weight: 600; font-size: 13px; color: var(--body); }

.rp-w-barlist { display: flex; flex-direction: column; gap: 13px; }
.rp-w-bar-row { display: flex; align-items: center; gap: 14px; }
.rp-w-bar-name { width: 150px; flex: 0 0 auto; font-family: "Mulish", sans-serif; font-weight: 600; font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-w-bar-track { flex: 1; height: 11px; border-radius: 999px; background: var(--track); overflow: hidden; }
.rp-w-bar-fill { height: 100%; border-radius: 999px; }
.rp-w-bar-val { width: 52px; flex: 0 0 auto; text-align: right; font-family: "Poppins", sans-serif; font-weight: 700; font-size: 13px; color: var(--ink); }

.rp-w-donut { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.rp-w-donut-dial { flex: 0 0 auto; width: 104px; height: 104px; border-radius: 50%; position: relative; }
.rp-w-donut-hole { position: absolute; inset: 19px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; font-family: "Poppins", sans-serif; font-weight: 700; font-size: 13px; color: var(--ink); text-align: center; }
.rp-w-donut-legend { flex: 1; min-width: 150px; display: flex; flex-direction: column; gap: 9px; }
.rp-w-donut-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rp-w-donut-label { display: inline-flex; align-items: center; gap: 9px; font-family: "Mulish", sans-serif; font-weight: 600; font-size: 13.5px; color: var(--body); }
.rp-w-donut-val { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 13px; color: var(--ink); }

.rp-w-prog { display: flex; align-items: center; gap: 26px; flex-wrap: wrap; }
.rp-w-prog-dial { flex: 0 0 auto; width: 120px; height: 120px; border-radius: 50%; position: relative; }
.rp-w-prog-hole { position: absolute; inset: 22px; border-radius: 50%; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.rp-w-prog-center { font-family: "Poppins", sans-serif; font-weight: 800; font-size: 22px; color: var(--ink); line-height: 1; }
.rp-w-prog-sub { font-size: 10px; color: var(--muted3); font-weight: 700; margin-top: 2px; }
.rp-w-prog-legend { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 14px; }
.rp-w-prog-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rp-w-prog-label { display: inline-flex; align-items: center; gap: 9px; font-family: "Poppins", sans-serif; font-weight: 700; font-size: 13.5px; color: var(--ink); }
.rp-w-sq { width: 10px; height: 10px; border-radius: 3px; }
.rp-w-prog-pct { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 13px; color: var(--muted2); }
.rp-w-prog-detail { font-size: 12px; color: var(--muted3); margin-top: 3px; margin-left: 19px; }

.rp-w-table-wrap { overflow-x: auto; }
.rp-w-table { width: 100%; border-collapse: collapse; min-width: 440px; }
.rp-w-table th { text-align: left; font-family: "Poppins", sans-serif; font-weight: 700; font-size: 11px; letter-spacing: 0.4px; text-transform: uppercase; color: var(--muted); padding: 0 14px 11px 0; border-bottom: 1px solid var(--track); }
.rp-w-table td { font-family: "Mulish", sans-serif; font-weight: 600; font-size: 13.5px; color: var(--body); padding: 12px 14px 12px 0; white-space: nowrap; border-bottom: 1px solid #F5F7FA; }

.rp-w-badges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.rp-w-badge { display: flex; flex-direction: column; align-items: center; padding: 16px 10px; border-radius: 12px; border: 1.5px solid #E4E8EF; background: #F6F8FB; }
.rp-w-badge.is-earned { border-color: #B7E7D5; background: #EAF9F3; }
.rp-w-badge-name { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 13px; color: var(--ink); margin-top: 11px; text-align: center; }
.rp-w-badge-status { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 10px; letter-spacing: 0.4px; margin-top: 5px; }

.rp-w-ph { display: flex; align-items: center; gap: 14px; background: #F8FAFC; border: 1px solid var(--row-border); border-radius: 12px; padding: 18px 20px; }
.rp-w-ph-icon { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; }
.rp-w-ph-desc { font-size: 13.5px; line-height: 1.55; color: var(--muted2); }

/* ------------------------------- Responsive ------------------------------- */
@media (max-width: 1100px) {
  .rp-builder-grid { grid-template-columns: 1fr; }
  .rp-library { position: static; max-height: none; }
}
@media (max-width: 1000px) {
  .rp-kpis { grid-template-columns: repeat(2, 1fr); }
  .rp-product-body { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .rp-main { padding-left: 20px; padding-right: 20px; }
  .rp-kpis { grid-template-columns: 1fr; }
  .rp-grid { grid-template-columns: 1fr; }
  .rp-stats { grid-template-columns: 1fr 1fr; }
  .rp-w-badges { grid-template-columns: repeat(2, 1fr); }
  .rp-w-signoff { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .rp-builder, .rp-wcard { animation: none; }
}

@media (prefers-reduced-motion: reduce) {
  .rp-view, .rp-bar-fill, .rp-modal-panel { animation: none; }
}

/* ============================================================
   Report preview / print — show only the report content as an
   end user would see it (front-end facing), hiding all CMS
   chrome. Applied both to the on-screen preview (body.rp-preview,
   toggled by enterPreview() in app.js) and to the browser
   print / PDF output (@media print, e.g. detail "Export PDF").
   Scoped to fe-reports: styles.css is loaded only here and after
   app-chrome.css, so hiding the shared .rm-header/.rm-footer
   never affects the other apps.
   ============================================================ */

/* --- Chrome hidden on-screen while previewing --- */
body.rp-preview .rm-header,
body.rp-preview .rm-footer,
body.rp-preview .menu-wrap,
body.rp-preview .ai-assistant,
body.rp-preview .ai-launcher,
body.rp-preview .rp-tabband,
body.rp-preview .rp-back,
body.rp-preview .rp-export-btn,
body.rp-preview #exportBtn,
body.rp-preview .rp-builder-chip,
body.rp-preview .rp-builder-actions,
body.rp-preview .rp-library,
body.rp-preview .rp-wcard-bar {
  display: none !important;
}

/* --- Same chrome hidden in the printed / PDF output. Export PDF
       prints directly (no rp-preview class), so this list is
       independent of the preview scope. The floating preview bar
       is also dropped so it never lands in the PDF. --- */
@media print {
  .rm-header,
  .rm-footer,
  .menu-wrap,
  .ai-assistant,
  .ai-launcher,
  .rp-tabband,
  .rp-back,
  .rp-export-btn,
  #exportBtn,
  .rp-builder-chip,
  .rp-builder-actions,
  .rp-library,
  .rp-wcard-bar,
  .rp-preview-bar {
    display: none !important;
  }
}

/* --- Layout reset (both contexts): with the palette column gone,
       let the report content fill the width; keep backgrounds. --- */
body.rp-preview .rp-builder-grid { display: block; }
body.rp-preview .rp-canvas { width: 100%; }
@media print {
  .rp-builder-grid { display: block; }
  .rp-canvas { width: 100%; }
}

/* --- On-screen preview: present the content like a document --- */
body.rp-preview { background: #fff; }
body.rp-preview .rp-main {
  max-width: 1040px;
  padding: 92px 24px 48px; /* top clears the fixed preview bar */
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

/* --- Print: full-bleed, colours preserved --- */
@media print {
  body, .app-shell { background: #fff; }
  .rp-main {
    max-width: none;
    margin: 0;
    padding: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* --- Floating preview action bar (screen only) --- */
.rp-preview-bar {
  position: fixed;
  top: 16px;
  right: 24px;
  z-index: 60;
  display: flex;
  gap: 10px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--card-border, #E4E8EF);
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(18, 38, 63, 0.14);
  backdrop-filter: blur(4px);
}
.rp-preview-bar button {
  font-family: "Poppins", system-ui, sans-serif;
  font-weight: 600;
  font-size: 13.5px;
  border-radius: 10px;
  padding: 9px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.rp-preview-print {
  color: #fff;
  background: var(--blue, #3C7CE0);
  border: 1px solid var(--blue, #3C7CE0);
}
.rp-preview-print:hover { filter: brightness(0.96); }
.rp-preview-close {
  color: #16273F;
  background: #fff;
  border: 1px solid var(--card-border, #E4E8EF);
}
.rp-preview-close:hover { border-color: var(--blue, #3C7CE0); color: var(--blue, #3C7CE0); }
