:root {
  --rb-bg: #f8fafc;
  --rb-panel: #ffffff;
  --rb-panel-border: #e2e8f0;
  --rb-text: #0f172a;
  --rb-muted: #64748b;
  --rb-accent: #2563eb;
  --rb-green: #059669;
  --rb-page: #f1f5f9;
}

body.rebuy-page {
  margin: 0;
  min-height: 100vh;
  font: 14px/1.45 var(--font, Inter, system-ui, sans-serif);
  color: var(--text);
  background: linear-gradient(165deg, #f8fafc 0%, var(--rb-page) 45%, #eef2ff 100%);
}

.rebuy-wrap {
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 18px 48px;
}

.rebuy-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--rb-panel);
  border: 1px solid var(--rb-panel-border);
  color: var(--rb-text);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.rebuy-topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
}

.rebuy-topbar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rebuy-topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.rebuy-global-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 220px;
  min-width: 180px;
  max-width: 420px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid var(--rb-panel-border);
}

.rebuy-global-search i {
  width: 15px;
  height: 15px;
  color: var(--rb-muted);
  flex-shrink: 0;
}

.rebuy-global-search input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--rb-text);
  font: inherit;
  font-size: 12px;
  padding: 4px 0;
}

.rebuy-global-search input:focus {
  outline: none;
}

.rebuy-global-search input::placeholder {
  color: var(--rb-muted);
}

.rebuy-search-count {
  font-size: 10px;
  color: var(--rb-muted);
  white-space: nowrap;
  font-family: var(--mono, ui-monospace, monospace);
}

.kpmg-detail-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fff;
}

.kpmg-detail-search i {
  width: 16px;
  height: 16px;
  color: #6b7280;
}

.kpmg-detail-search input {
  flex: 1;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 13px;
}

.kpmg-detail-search input:focus {
  outline: none;
}

@media (max-width: 900px) {
  .rebuy-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .rebuy-topbar-meta,
  .rebuy-topbar-actions {
    margin-left: 0;
  }
}

@media (max-width: 640px) {
  .rebuy-wrap {
    padding: 10px 12px 28px;
  }

  .rebuy-controls input,
  .rebuy-controls select,
  .rebuy-sidebar textarea {
    font-size: 16px;
    width: 100%;
  }

  .rebuy-controls label {
    flex: 1 1 100%;
    min-width: 0;
  }

  .rebuy-table-wrap {
    -webkit-overflow-scrolling: touch;
  }

  .rebuy-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .rebuy-kpi-grid {
    grid-template-columns: 1fr;
  }
}

.rebuy-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  border: 1px solid var(--rb-panel-border);
  font-size: 12px;
  color: var(--rb-muted);
}

.rebuy-chip b {
  color: var(--rb-text);
  font-family: var(--mono, ui-monospace, monospace);
}

.rebuy-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 14px;
  align-items: start;
}

@media (max-width: 1100px) {
  .rebuy-layout {
    grid-template-columns: 1fr;
  }
}

.rebuy-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius, 14px);
  padding: 14px;
  box-shadow: var(--shadow);
}

.rebuy-card h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.rebuy-drop {
  border: 1px dashed #c7cdd8;
  border-radius: 14px;
  padding: 22px 16px;
  text-align: center;
  background: #fafafa;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.rebuy-drop.dragover {
  border-color: var(--rb-accent);
  background: rgba(87, 148, 242, 0.08);
}

.rebuy-drop p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.upload-section.compact .rebuy-drop {
  padding: 12px;
}

.mapping-section.collapsed .map-body {
  display: none;
}

.map-grid {
  display: grid;
  gap: 10px;
}

.map-field label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.map-field select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background: #fafafa;
  font: inherit;
}

.filters {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.filters label {
  font-size: 11px;
  color: var(--muted);
}

.filters input[type='date'] {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.pill {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
}

.pill.ok {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.pill.warn {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.grafana-stat-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

@media (max-width: 1200px) {
  .grafana-stat-row {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 760px) {
  .grafana-stat-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

.grafana-stat {
  background: var(--rb-panel);
  border: 1px solid var(--rb-panel-border);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 120px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.grafana-stat-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--rb-muted);
  margin-bottom: 6px;
  font-weight: 600;
}

.grafana-stat-label i {
  width: 14px;
  height: 14px;
  color: var(--rb-accent);
}

.grafana-stat-bullets {
  margin: 8px 0 0;
  padding-left: 16px;
  font-size: 10px;
  line-height: 1.45;
  color: var(--rb-muted);
}

.grafana-stat-bullets li {
  margin-bottom: 2px;
}

.grafana-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--rb-text);
  font-family: var(--mono, ui-monospace, monospace);
  letter-spacing: -0.02em;
}

.grafana-stat-hint {
  margin-top: 6px;
  font-size: 11px;
  color: var(--rb-muted);
}

.grafana-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (max-width: 900px) {
  .grafana-grid {
    grid-template-columns: 1fr;
  }
}

.grafana-panel {
  background: var(--rb-panel);
  border: 1px solid var(--rb-panel-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.grafana-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--rb-panel-border);
  font-size: 12px;
  font-weight: 600;
  color: var(--rb-text);
  background: #f8fafc;
}

.grafana-panel-head i {
  width: 15px;
  height: 15px;
  color: var(--rb-accent);
  margin-right: 4px;
  vertical-align: -2px;
}

.grafana-panel-body {
  padding: 10px 12px 14px;
  height: 260px;
  position: relative;
  background: #fff;
}

.grafana-panel-body.chart-sm {
  height: 180px;
}

.grafana-panel-body.flat {
  height: auto;
  min-height: 80px;
  max-height: none;
}

.grafana-panel-footer {
  padding: 0 12px 12px;
  background: #fff;
  border-top: 1px solid #f1f5f9;
}

.rebuy-panel-wide {
  margin-bottom: 12px;
  grid-column: 1 / -1;
}

.rebuy-insights-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.rebuy-insight-chip {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  font-size: 12px;
  line-height: 1.4;
  flex: 1 1 280px;
}

.rebuy-insight-chip i {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}

.rebuy-mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.rebuy-mini-table th,
.rebuy-mini-table td {
  padding: 5px 8px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
  color: var(--rb-text);
}

.rebuy-mini-table th {
  background: #f8fafc;
  color: var(--rb-muted);
  font-weight: 600;
}

.rebuy-mini-table td:last-child,
.rebuy-mini-table th:last-child {
  text-align: right;
}

.rebuy-panel-empty {
  margin: 0;
  font-size: 12px;
  color: var(--rb-muted);
  padding: 8px 0;
}

.rebuy-panel-note {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--rb-muted);
}

.rebuy-seq-revenue {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--rb-muted);
}

.rebuy-seq-revenue b {
  color: var(--rb-text);
  font-family: var(--mono, ui-monospace, monospace);
}

.rebuy-summary-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rebuy-summary-card h3 i {
  width: 15px;
  height: 15px;
  color: var(--rb-accent);
}

.grafana-panel-body.tall {
  height: 320px;
}

.grafana-panel-note {
  padding: 0 12px 10px;
  font-size: 11px;
  color: var(--rb-muted);
}

.grafana-table-wrap {
  overflow: auto;
  max-height: 360px;
}

.grafana-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.grafana-table th,
.grafana-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--rb-panel-border);
  text-align: left;
  color: var(--rb-text);
}

.grafana-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: var(--rb-muted);
  font-weight: 600;
}

.grafana-table td.num {
  text-align: right;
  font-family: var(--mono, ui-monospace, monospace);
}

.mono {
  font-family: var(--mono, ui-monospace, monospace);
}

.small {
  font-size: 12px;
  color: var(--muted);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

.footer-note {
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
}

.rebuy-logs {
  margin-top: 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius, 14px);
  padding: 14px;
}

.rebuy-log-list {
  margin-top: 10px;
  max-height: 280px;
  overflow: auto;
  display: grid;
  gap: 8px;
}

.rebuy-log-entry {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 11px;
  line-height: 1.35;
  white-space: pre-wrap;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #374151;
}

.rebuy-log-warn {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.rebuy-log-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.rebuy-log-info {
  background: #f8fafc;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.toggle-row input {
  accent-color: var(--rb-accent);
}

/* Summary row */
.rebuy-summary-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

@media (max-width: 1100px) {
  .rebuy-summary-row {
    grid-template-columns: 1fr;
  }
}

.rebuy-summary-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.rebuy-summary-card h3 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #00338d;
}

.rebuy-summary-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.rebuy-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f4f6fb;
}

.rebuy-metric span {
  font-size: 11px;
  color: var(--muted);
}

.rebuy-metric strong {
  font-size: 16px;
  font-family: var(--mono, ui-monospace, monospace);
  color: #111827;
}

.rebuy-status-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.rebuy-status-list li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #f9fafb;
}

.rebuy-status-list em {
  font-style: normal;
  font-size: 10px;
  color: var(--muted);
  font-family: var(--mono, ui-monospace, monospace);
}

.rebuy-hint-list {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: #92400e;
}

.rebuy-summary-note {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.rebuy-summary-note.ok {
  color: #065f46;
}

/* Clickable KPI / panels */
.grafana-stat-clickable {
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.grafana-stat-clickable:hover {
  border-color: var(--rb-accent);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.12);
  transform: translateY(-1px);
}

.grafana-stat-action {
  margin-top: 8px;
  font-size: 10px;
  color: var(--rb-accent);
  display: flex;
  align-items: center;
  gap: 4px;
}

.grafana-panel-clickable {
  cursor: pointer;
  transition: border-color 0.15s;
}

.grafana-panel-clickable:hover {
  border-color: var(--rb-accent);
}

.grafana-panel-head-meta {
  font-size: 11px;
  color: var(--rb-muted);
  font-weight: 500;
}

/* Product search */
.rebuy-product-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--rb-panel-border);
  background: #f8fafc;
}

.rebuy-product-search i {
  width: 16px;
  height: 16px;
  color: var(--rb-muted);
}

.rebuy-product-search input {
  flex: 1;
  border: 1px solid var(--rb-panel-border);
  border-radius: 8px;
  background: #fff;
  color: var(--rb-text);
  padding: 8px 10px;
  font: inherit;
}

.rebuy-product-search input:focus {
  outline: none;
  border-color: var(--rb-accent);
}

.product-row-clickable {
  cursor: pointer;
}

.product-row-clickable:hover td {
  background: rgba(37, 99, 235, 0.06);
}

.muted {
  color: var(--rb-muted);
  font-size: 11px;
}

.rebuy-empty-row {
  text-align: center;
  color: var(--rb-muted);
  padding: 20px !important;
}

/* KPMG-style detail modal */
body.rebuy-modal-open {
  overflow: hidden;
}

.kpmg-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.kpmg-modal[hidden] {
  display: none !important;
}

.kpmg-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 20, 60, 0.55);
  backdrop-filter: blur(4px);
}

.kpmg-modal-dialog {
  position: relative;
  width: min(920px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  background: #fff;
}

.kpmg-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.kpmg-detail-head {
  background: linear-gradient(135deg, #00338d 0%, #005eb8 100%);
  color: #fff;
  padding: 28px 24px 22px;
}

.kpmg-detail-kicker {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.85;
}

.kpmg-detail-head h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.kpmg-detail-sub {
  margin: 8px 0 0;
  opacity: 0.9;
  font-size: 14px;
}

.kpmg-detail-hero {
  margin-top: 16px;
  font-size: 36px;
  font-weight: 700;
  font-family: var(--mono, ui-monospace, monospace);
}

.kpmg-detail-body {
  padding: 18px 24px 24px;
  background: #f4f6fb;
}

.kpmg-section {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
}

.kpmg-section h4 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #00338d;
}

.kpmg-section p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: #374151;
}

.kpmg-insight {
  border-left: 4px solid #00338d;
}

.kpmg-formula {
  font-family: var(--mono, ui-monospace, monospace);
  background: #f9fafb;
  padding: 8px 10px;
  border-radius: 8px;
}

.kpmg-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.kpmg-table th,
.kpmg-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
}

.kpmg-table th {
  background: #f9fafb;
  color: #6b7280;
  font-weight: 600;
}

.kpmg-table td:last-child,
.kpmg-table th:last-child {
  text-align: right;
}

.kpmg-empty {
  margin: 0;
  color: #6b7280;
  font-size: 13px;
}

.kpmg-note {
  margin: 10px 0 0;
  font-size: 12px;
  color: #6b7280;
}

.kpmg-modal-wide {
  width: min(980px, 100%);
}

.kpmg-sub {
  margin: 0 0 14px;
  color: #6b7280;
  font-size: 13px;
}

.rebuy-filter-chip {
  background: #eef4ff;
  border: 1px solid #c7d7f5;
  color: #00338d;
}

.rebuy-chip-link {
  border: none;
  background: none;
  color: #005eb8;
  cursor: pointer;
  text-decoration: underline;
  font: inherit;
  padding: 0;
  margin-left: 4px;
}

.rebuy-customer-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #e5e7eb;
  background: #fafbfc;
}

.rebuy-segment-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.rebuy-seg-tab {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}

.rebuy-seg-tab.active {
  background: #00338d;
  border-color: #00338d;
  color: #fff;
}

.rebuy-type-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.rebuy-type-pill.ok {
  background: #dcfce7;
  color: #166534;
}

.rebuy-type-pill.warn {
  background: #fef3c7;
  color: #92400e;
}

.rebuy-row-repeater td:first-child {
  font-weight: 500;
}

.rebuy-panel-highlight {
  box-shadow: 0 0 0 3px rgba(0, 51, 141, 0.25);
  transition: box-shadow 0.3s ease;
}

.rebuy-pa-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.rebuy-pa-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rebuy-pa-count {
  font-size: 12px;
  color: #6b7280;
  font-weight: 600;
}

.rebuy-pa-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  max-height: min(52vh, 520px);
  overflow: auto;
  padding: 4px;
  margin-bottom: 16px;
}

.rebuy-pa-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.rebuy-pa-tile:hover {
  border-color: #93c5fd;
}

.rebuy-pa-tile.selected {
  border-color: #00338d;
  background: #eef4ff;
}

.rebuy-pa-tile input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.rebuy-pa-tile-name {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  line-height: 1.35;
}

.rebuy-pa-tile-sku {
  font-size: 11px;
  color: #6b7280;
}

.rebuy-pa-tile-meta {
  font-size: 11px;
  color: #9ca3af;
}

.rebuy-pa-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid #e5e7eb;
}

#productAnalysisModal .kpmg-modal-content {
  padding: 22px 24px 24px;
}

#productAnalysisModal h2 {
  margin: 0 0 8px;
  font-size: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #00338d;
}

#productAnalysisModal .kpmg-modal-close {
  background: #f3f4f6;
  color: #374151;
}

/* --- Grafana Chart Gallery --- */
.rebuy-charts-section {
  margin: 16px 0;
}

.rebuy-charts-section-head {
  margin-bottom: 12px;
}

.rebuy-charts-section-head h2 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--rb-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.rebuy-charts-section-head h2 i {
  width: 18px;
  height: 18px;
  color: var(--rb-accent);
}

.rebuy-charts-section-head p {
  margin: 0;
  font-size: 12px;
  color: var(--rb-muted);
}

.rebuy-charts-section-ext {
  margin-top: 20px;
}

.grafana-charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.grafana-charts-grid-dense {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 1200px) {
  .grafana-charts-grid-dense {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 760px) {
  .grafana-charts-grid,
  .grafana-charts-grid-dense {
    grid-template-columns: 1fr;
  }
}

.grafana-chart-panel {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(87, 148, 255, 0.18);
  background: linear-gradient(165deg, #0f172a 0%, #111827 45%, #0b1220 100%);
  box-shadow:
    0 4px 24px rgba(15, 23, 42, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.grafana-chart-panel:hover {
  transform: translateY(-2px);
  box-shadow:
    0 12px 32px rgba(37, 99, 235, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.grafana-chart-panel.grafana-panel-clickable {
  cursor: pointer;
}

.rebuy-chart-wide {
  grid-column: 1 / -1;
}

.grafana-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  background: linear-gradient(90deg, rgba(87, 148, 255, 0.12), rgba(124, 58, 237, 0.08));
}

.grafana-chart-head span {
  font-size: 12px;
  font-weight: 600;
  color: #f1f5f9;
  display: flex;
  align-items: center;
  gap: 6px;
}

.grafana-chart-head span i {
  width: 14px;
  height: 14px;
  color: #5794ff;
}

.grafana-chart-head em {
  font-style: normal;
  font-size: 10px;
  color: #94a3b8;
  text-align: right;
}

.grafana-chart-stage {
  position: relative;
  height: 210px;
  padding: 8px 10px 4px;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(87, 148, 255, 0.08), transparent 55%),
    radial-gradient(ellipse at 80% 100%, rgba(115, 191, 105, 0.06), transparent 50%),
    #0b1220;
}

.rebuy-chart-wide .grafana-chart-stage {
  height: 260px;
}

.grafana-chart-stage canvas {
  width: 100% !important;
  height: 100% !important;
}

.grafana-chart-footer {
  padding: 8px 12px 12px;
  background: rgba(15, 23, 42, 0.65);
  border-top: 1px solid rgba(148, 163, 184, 0.1);
}

.grafana-chart-footer .rebuy-mini-table {
  color: #cbd5e1;
}

.grafana-chart-footer .rebuy-mini-table th {
  color: #94a3b8;
}

.grafana-grid-tables {
  margin-top: 14px;
}

.rebuy-cohort-note {
  margin: 8px 0 0;
  padding: 0 4px;
}

.rebuy-heatmap {
  padding: 12px;
  min-height: 180px;
}

.rebuy-heat-row {
  display: grid;
  grid-template-columns: 120px repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 6px;
  align-items: stretch;
}

.rebuy-heat-head {
  margin-bottom: 8px;
}

.rebuy-heat-label {
  font-size: 11px;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-right: 6px;
}

.rebuy-heat-label em {
  font-style: normal;
  font-size: 10px;
  color: #64748b;
}

.rebuy-heat-col {
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.rebuy-heat-cell {
  border-radius: 8px;
  min-height: 42px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #f8fafc;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: transform 0.15s ease;
}

.rebuy-heat-cell:hover {
  transform: scale(1.04);
  z-index: 1;
}

.rebuy-chart-empty {
  margin: 0;
  padding: 24px;
  text-align: center;
  color: #64748b;
  font-size: 13px;
}

/* --- Manager Report --- */
.kpmg-modal-report {
  width: min(960px, 100%);
  max-height: min(92vh, 980px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mgr-modal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid #e5e7eb;
  background: linear-gradient(135deg, #00338d 0%, #005eb8 100%);
  color: #fff;
}

.mgr-modal-toolbar h2 {
  margin: 0;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mgr-modal-toolbar h2 i {
  width: 20px;
  height: 20px;
}

.mgr-modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mgr-modal-actions .kpmg-modal-close {
  position: static;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.mgr-modal-body {
  overflow: auto;
  padding: 0 !important;
  background: #f4f6fb;
}

.mgr-report {
  padding: 24px 28px 32px;
  max-width: 900px;
  margin: 0 auto;
}

.mgr-header {
  margin-bottom: 20px;
}

.mgr-kicker {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #005eb8;
  font-weight: 700;
}

.mgr-header h1 {
  margin: 0;
  font-size: 28px;
  color: #0f172a;
  font-weight: 700;
}

.mgr-sub {
  margin: 6px 0 12px;
  color: #64748b;
  font-size: 14px;
}

.mgr-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  font-size: 12px;
  color: #475569;
}

.mgr-meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mgr-meta i {
  width: 14px;
  height: 14px;
  color: #005eb8;
}

.mgr-filter-note {
  margin: 10px 0 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mgr-verdict {
  display: flex;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 12px;
  margin-bottom: 20px;
  border: 1px solid transparent;
}

.mgr-verdict i {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  margin-top: 2px;
}

.mgr-verdict h2 {
  margin: 0 0 6px;
  font-size: 16px;
}

.mgr-verdict p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.mgr-verdict-good {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.mgr-verdict-good i {
  color: #059669;
}

.mgr-verdict-neutral {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e3a8a;
}

.mgr-verdict-neutral i {
  color: #2563eb;
}

.mgr-verdict-warn {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.mgr-verdict-warn i {
  color: #d97706;
}

.mgr-verdict-critical {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.mgr-verdict-critical i {
  color: #dc2626;
}

.mgr-section {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 14px;
}

.mgr-section h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #00338d;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mgr-section h3 i {
  width: 16px;
  height: 16px;
}

.mgr-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 760px) {
  .mgr-two-col {
    grid-template-columns: 1fr;
  }
}

.mgr-list {
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.55;
  color: #374151;
}

.mgr-list li {
  margin-bottom: 6px;
}

.mgr-summary-list li {
  font-weight: 500;
}

.mgr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.mgr-table th,
.mgr-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
}

.mgr-table th {
  background: #f8fafc;
  color: #64748b;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mgr-table td:last-child,
.mgr-table th:last-child {
  text-align: right;
}

.mgr-rec-grid {
  display: grid;
  gap: 10px;
}

.mgr-rec {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fafbfc;
}

.mgr-rec-priority {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.mgr-rec-hoch .mgr-rec-priority {
  background: #fee2e2;
  color: #991b1b;
}

.mgr-rec-mittel .mgr-rec-priority {
  background: #fef3c7;
  color: #92400e;
}

.mgr-rec-niedrig .mgr-rec-priority {
  background: #dbeafe;
  color: #1e40af;
}

.mgr-rec h4 {
  margin: 0 0 6px;
  font-size: 14px;
  color: #0f172a;
}

.mgr-rec p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #4b5563;
}

.mgr-rec-detailed .mgr-rec-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.mgr-rec-cat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cat-color, #00338d);
}

.mgr-rec-cat i {
  width: 12px;
  height: 12px;
}

.mgr-rec-block {
  margin: 10px 0;
}

.mgr-rec-block strong {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin-bottom: 4px;
}

.mgr-rec-action {
  padding: 10px 12px;
  background: #f0fdf4;
  border-radius: 8px;
  border-left: 3px solid #059669;
}

.mgr-rec-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e5e7eb;
  font-size: 11px;
  color: #64748b;
}

.mgr-rec-foot span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.mgr-rec-foot i {
  width: 12px;
  height: 12px;
}

.mgr-benchmark-note {
  margin: 10px 0 0;
  font-size: 11px;
  color: #9ca3af;
}

.mgr-section-risk .mgr-list li {
  color: #991b1b;
}

.mgr-section-opp .mgr-list li {
  color: #065f46;
}

.mgr-empty {
  margin: 0;
  color: #9ca3af;
  font-size: 13px;
}

.mgr-footer {
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid #e5e7eb;
  font-size: 11px;
  color: #9ca3af;
  text-align: center;
}

@media print {
  body.rebuy-modal-open {
    overflow: visible !important;
  }

  body * {
    visibility: hidden;
  }

  #managerReportPrint,
  #managerReportPrint *,
  #recommendationsPrint,
  #recommendationsPrint * {
    visibility: visible;
  }

  body.rebuy-print-mgr #managerReportPrint,
  body.rebuy-print-recs #recommendationsPrint {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    padding: 0;
  }

  .no-print,
  .kpmg-modal-backdrop,
  .mgr-modal-toolbar,
  .tool-app-top,
  .rebuy-topbar,
  .rebuy-layout {
    display: none !important;
  }

  .kpmg-modal,
  .kpmg-modal-dialog {
    position: static !important;
    overflow: visible !important;
    max-height: none !important;
    box-shadow: none !important;
    width: 100% !important;
  }

  .mgr-modal-body {
    overflow: visible !important;
    background: #fff !important;
  }

  .mgr-section {
    break-inside: avoid;
  }
}
