/*
 * TMS Report Panel - interface styles (on top of Bootstrap 5.3).
 * Tokens: cool white paper, deep navy navigation, one action blue,
 * teal for "better", brick for "worse". Borders instead of shadows.
 */
:root {
  --rp-paper: #f6f8fb;
  --rp-surface: #ffffff;
  --rp-ink: #13203a;
  --rp-ink-2: #4a5970;
  --rp-ink-3: #7b889c;
  --rp-rule: #e1e7ef;
  --rp-rule-strong: #cfd8e4;
  --rp-navy: #0f2747;
  --rp-navy-2: #183a66;
  --rp-blue: #1d5ac4;
  --rp-blue-dark: #174aa3;
  --rp-blue-soft: #e8effc;
  --rp-good: #0a8574;
  --rp-good-soft: #e2f4f0;
  --rp-bad: #b4392a;
  --rp-bad-soft: #fbe9e6;
  --rp-warn: #9a6100;
  --rp-warn-soft: #fff3d9;
  --rp-radius: 10px;
  --rp-radius-sm: 7px;
  --rp-sidebar: 244px;

  --bs-body-font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --bs-body-color: var(--rp-ink);
  --bs-body-bg: var(--rp-paper);
  --bs-border-color: var(--rp-rule);
  --bs-primary: var(--rp-blue);
  --bs-primary-rgb: 29, 90, 196;
  --bs-link-color: var(--rp-blue);
  --bs-link-color-rgb: 29, 90, 196;
  --bs-link-hover-color: var(--rp-blue-dark);
  --bs-secondary-color: var(--rp-ink-2);
  --bs-border-radius: var(--rp-radius-sm);
  --bs-focus-ring-color: rgba(29, 90, 196, .28);
}

html { -webkit-text-size-adjust: 100%; }
body {
  font-size: .9375rem;
  line-height: 1.55;
  font-feature-settings: "tnum" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { color: var(--rp-ink); letter-spacing: -0.01em; }
a { text-underline-offset: 2px; }
.text-ink-2 { color: var(--rp-ink-2) !important; }
.text-ink-3 { color: var(--rp-ink-3) !important; }
.figure { font-variant-numeric: tabular-nums; }

/* ---------- Buttons and forms ---------- */
.btn { font-weight: 600; border-radius: var(--rp-radius-sm); padding: .5rem 1rem; }
.btn-sm { padding: .3rem .7rem; }
.btn-primary {
  --bs-btn-bg: var(--rp-blue); --bs-btn-border-color: var(--rp-blue);
  --bs-btn-hover-bg: var(--rp-blue-dark); --bs-btn-hover-border-color: var(--rp-blue-dark);
  --bs-btn-active-bg: var(--rp-blue-dark); --bs-btn-active-border-color: var(--rp-blue-dark);
  --bs-btn-disabled-bg: var(--rp-blue); --bs-btn-disabled-border-color: var(--rp-blue);
}
.btn-outline-secondary {
  --bs-btn-color: var(--rp-ink); --bs-btn-border-color: var(--rp-rule-strong);
  --bs-btn-hover-bg: #eef2f7; --bs-btn-hover-color: var(--rp-ink); --bs-btn-hover-border-color: var(--rp-rule-strong);
  --bs-btn-active-bg: #e5ebf3; --bs-btn-active-color: var(--rp-ink); --bs-btn-active-border-color: var(--rp-rule-strong);
  background: var(--rp-surface);
}
.btn-danger { --bs-btn-bg: var(--rp-bad); --bs-btn-border-color: var(--rp-bad); --bs-btn-hover-bg: #9a2f22; --bs-btn-hover-border-color: #9a2f22; }
.btn-link { font-weight: 600; text-decoration: none; }
.form-label { font-weight: 600; font-size: .875rem; margin-bottom: .35rem; }
.form-control, .form-select { border-color: var(--rp-rule-strong); padding: .55rem .75rem; }
.form-control:focus, .form-select:focus { border-color: var(--rp-blue); }
.form-text { color: var(--rp-ink-3); font-size: .8125rem; }
.form-check-input:checked { background-color: var(--rp-blue); border-color: var(--rp-blue); }
.invalid-feedback { font-size: .8125rem; }
:focus-visible { outline: 2px solid var(--rp-blue); outline-offset: 2px; }

/* ---------- App shell ---------- */
.rp-shell { min-height: 100vh; display: flex; }
.rp-sidebar {
  width: var(--rp-sidebar); flex: 0 0 var(--rp-sidebar);
  background: var(--rp-navy); color: #c9d6ea;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.rp-brand { display: flex; align-items: center; gap: .7rem; padding: 1.25rem 1.25rem 1.1rem; color: #fff; text-decoration: none; }
.rp-brand:hover { color: #fff; }
.rp-brand-mark {
  width: 36px; height: 36px; border-radius: 9px; background: #fff; color: var(--rp-navy);
  display: grid; place-items: center; font-weight: 800; font-size: .8rem; overflow: hidden; flex: 0 0 36px;
}
.rp-brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.rp-brand-name { font-weight: 700; font-size: .95rem; line-height: 1.2; }
.rp-brand-sub { font-size: .75rem; color: #8fa6c7; }
.rp-nav { list-style: none; margin: .25rem 0 0; padding: 0 .75rem; }
.rp-nav-group { margin-top: 1.25rem; padding: 0 .6rem .35rem; font-size: .75rem; color: #7f97ba; font-weight: 600; }
.rp-nav a {
  display: flex; align-items: center; gap: .7rem; padding: .55rem .6rem; margin-bottom: 2px;
  color: #d5e0f0; text-decoration: none; border-radius: 8px; font-weight: 500; position: relative;
}
.rp-nav a .bi { font-size: 1.05rem; opacity: .85; }
.rp-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.rp-nav a.active { background: var(--rp-navy-2); color: #fff; font-weight: 600; }
.rp-nav a.active::before { content: ""; position: absolute; left: -.75rem; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #6ea0ff; }
.rp-soon { margin-left: auto; font-size: .6875rem; font-weight: 600; color: #8fa6c7; border: 1px solid #2b4a75; border-radius: 99px; padding: 0 .45rem; line-height: 1.5; }
.rp-sidebar-foot { margin-top: auto; padding: 1rem 1.25rem; font-size: .75rem; color: #7f97ba; border-top: 1px solid rgba(255, 255, 255, .07); }

.rp-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.rp-topbar {
  height: 60px; display: flex; align-items: center; gap: .75rem; padding: 0 1.75rem;
  background: var(--rp-surface); border-bottom: 1px solid var(--rp-rule); position: sticky; top: 0; z-index: 20;
}
.rp-topbar .rp-menu-toggle { display: none; }
.rp-icon-btn {
  position: relative; width: 38px; height: 38px; border-radius: 9px; border: 1px solid transparent;
  display: grid; place-items: center; color: var(--rp-ink-2); background: none; text-decoration: none;
}
.rp-icon-btn:hover { background: #eef2f7; color: var(--rp-ink); }
.rp-icon-btn .bi { font-size: 1.15rem; }
.rp-badge-dot {
  position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  background: var(--rp-bad); color: #fff; font-size: .6875rem; font-weight: 700; display: grid; place-items: center; border: 2px solid #fff;
}
.rp-user-btn { display: flex; align-items: center; gap: .55rem; background: none; border: 0; padding: .25rem .4rem; border-radius: 9px; color: var(--rp-ink); }
.rp-user-btn:hover { background: #eef2f7; }
.rp-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--rp-blue-soft); color: var(--rp-blue-dark); display: grid; place-items: center; font-size: .75rem; font-weight: 700; }
.rp-content { padding: 1.75rem; max-width: 1240px; width: 100%; }

/* ---------- Page furniture ---------- */
.rp-page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.rp-page-head h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.rp-page-head p { margin: .3rem 0 0; color: var(--rp-ink-2); max-width: 64ch; }
.rp-panel { background: var(--rp-surface); border: 1px solid var(--rp-rule); border-radius: var(--rp-radius); }
.rp-panel-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--rp-rule); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.rp-panel-head h2 { font-size: 1rem; font-weight: 700; margin: 0; }
.rp-panel-body { padding: 1.25rem; }
.rp-section-title { font-size: 1rem; font-weight: 700; margin: 0 0 .25rem; }
.rp-section-sub { color: var(--rp-ink-2); font-size: .875rem; margin: 0 0 1rem; }
.rp-form-section { padding: 1.5rem 1.25rem; border-bottom: 1px solid var(--rp-rule); }
.rp-form-section:last-of-type { border-bottom: 0; }
.rp-form-actions { padding: 1rem 1.25rem; border-top: 1px solid var(--rp-rule); background: #fbfcfe; border-radius: 0 0 var(--rp-radius) var(--rp-radius); display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }

/* Tables */
.rp-table { margin: 0; --bs-table-bg: transparent; }
.rp-table > :not(caption) > * > * { padding: .8rem 1.25rem; border-bottom-color: var(--rp-rule); vertical-align: middle; }
.rp-table thead th { font-size: .8125rem; font-weight: 600; color: var(--rp-ink-3); background: #fbfcfe; white-space: nowrap; }
.rp-table tbody tr:last-child > * { border-bottom: 0; }
.rp-table tbody tr:hover > * { background: #fafbfd; }
.rp-entity { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.rp-entity-logo {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--rp-rule); background: #fff;
  display: grid; place-items: center; overflow: hidden; flex: 0 0 36px; font-size: .75rem; font-weight: 700; color: var(--rp-ink-2);
}
.rp-entity-logo img { width: 100%; height: 100%; object-fit: contain; }
.rp-entity-name { font-weight: 600; color: var(--rp-ink); text-decoration: none; }
.rp-entity-name:hover { color: var(--rp-blue); }
.rp-entity-meta { font-size: .8125rem; color: var(--rp-ink-3); }

/* Status pills: colour carries meaning only (good / bad / waiting / neutral) */
.rp-pill { display: inline-flex; align-items: center; gap: .35rem; font-size: .75rem; font-weight: 600; padding: .15rem .55rem; border-radius: 99px; white-space: nowrap; }
.rp-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.rp-pill-good { background: var(--rp-good-soft); color: var(--rp-good); }
.rp-pill-bad { background: var(--rp-bad-soft); color: var(--rp-bad); }
.rp-pill-warn { background: var(--rp-warn-soft); color: var(--rp-warn); }
.rp-pill-neutral { background: #eef1f6; color: var(--rp-ink-2); }
.rp-pill-blue { background: var(--rp-blue-soft); color: var(--rp-blue-dark); }

/* Flash messages */
.rp-flash { display: flex; gap: .75rem; align-items: flex-start; padding: .85rem 1rem; border-radius: var(--rp-radius-sm); margin-bottom: 1.25rem; border: 1px solid; font-size: .9rem; }
.rp-flash .bi { font-size: 1.1rem; line-height: 1.3; }
.rp-flash-ok { background: var(--rp-good-soft); border-color: #b9e3da; color: #075e52; }
.rp-flash-err { background: var(--rp-bad-soft); border-color: #f1c6bf; color: #8a2b1f; }
.rp-flash-warn { background: var(--rp-warn-soft); border-color: #f2d9a2; color: #6e4600; }

/* Tabs */
.rp-tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--rp-rule); margin-bottom: 1.5rem; overflow-x: auto; }
.rp-tabs a { padding: .65rem .9rem; color: var(--rp-ink-2); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.rp-tabs a:hover { color: var(--rp-ink); }
.rp-tabs a.active { color: var(--rp-blue); border-bottom-color: var(--rp-blue); }

/* Reports home: setup sequence */
.rp-steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.rp-step { display: grid; grid-template-columns: 40px 1fr auto; gap: 1rem; align-items: center; padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--rp-rule); }
.rp-step:last-child { border-bottom: 0; }
.rp-step-num {
  counter-increment: step; width: 32px; height: 32px; border-radius: 50%; border: 1.5px solid var(--rp-rule-strong);
  display: grid; place-items: center; font-weight: 700; font-size: .85rem; color: var(--rp-ink-2);
}
.rp-step-num::before { content: counter(step); }
.rp-step.is-done .rp-step-num { background: var(--rp-good); border-color: var(--rp-good); color: #fff; }
.rp-step.is-done .rp-step-num::before { content: "\2713"; }
.rp-step-title { font-weight: 700; }
.rp-step.is-done .rp-step-title { color: var(--rp-ink-2); }
.rp-step-body { font-size: .875rem; color: var(--rp-ink-2); }

/* The report sentence: the product's signature element */
.rp-sentence { font-size: clamp(1.4rem, 2.6vw, 2.1rem); font-weight: 650; line-height: 1.22; letter-spacing: -0.02em; color: var(--rp-ink); max-width: 24ch; }
.rp-sentence .rp-delta { display: inline-flex; align-items: center; gap: .3rem; font-size: .55em; font-weight: 700; padding: .2em .6em; border-radius: 99px; vertical-align: middle; letter-spacing: 0; }
.rp-delta-good { background: var(--rp-good-soft); color: var(--rp-good); }

/* Empty / coming-soon states */
.rp-empty { text-align: center; padding: 3.5rem 1.5rem; }
.rp-empty .bi { font-size: 2rem; color: var(--rp-ink-3); }
.rp-empty h2 { font-size: 1.15rem; font-weight: 700; margin: .75rem 0 .35rem; }
.rp-empty p { color: var(--rp-ink-2); max-width: 52ch; margin: 0 auto 1.25rem; }

/* Secret / key display */
.rp-key { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; background: #f1f4f9; border: 1px dashed var(--rp-rule-strong); border-radius: var(--rp-radius-sm); padding: .75rem .9rem; word-break: break-all; user-select: all; }

/* Definition-style key/value list */
.rp-dl { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.25rem; margin: 0; font-size: .9rem; }
.rp-dl dt { color: var(--rp-ink-3); font-weight: 500; }
.rp-dl dd { margin: 0; }

/* Connections */
.rp-conn-icon { width: 36px; height: 36px; flex: 0 0 36px; border-radius: var(--rp-radius-sm); display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.rp-conn-google { background: #eef3fe; color: #1a73e8; }
.rp-conn-meta { background: #e9f0ff; color: #0866ff; }
.rp-conn-instagram { background: #fdeef4; color: #c13584; }
.rp-entity-logo.rp-conn-google, .rp-entity-logo.rp-conn-meta, .rp-entity-logo.rp-conn-instagram { font-size: 1rem; border-color: transparent; }
.rp-details { border-top: 1px solid var(--rp-rule); padding-top: .75rem; }
.rp-details > summary { cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--rp-ink-2); }
.rp-details > summary:hover { color: var(--rp-ink); }
.rp-tab-count { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .25rem; border-radius: 99px; background: #eef1f6; color: var(--rp-ink-2); font-size: .75rem; text-align: center; }
.rp-tabs a.active .rp-tab-count { background: var(--rp-blue-soft); color: var(--rp-blue-dark); }
.rp-row-muted td { color: var(--rp-ink-3); }
.rp-sticky-actions { position: sticky; bottom: 0; z-index: 2; }

/* ---------- Sign-in screens ---------- */
.rp-auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--rp-surface); }
.rp-auth-side {
  background: var(--rp-navy); color: #c9d6ea; padding: 2.5rem 3rem; display: flex; flex-direction: column;
  background-image: linear-gradient(var(--rp-navy), var(--rp-navy)), repeating-linear-gradient(0deg, transparent 0 39px, rgba(255,255,255,.035) 39px 40px);
  background-blend-mode: normal;
}
.rp-auth-side .rp-brand { padding: 0; }
.rp-auth-sample { margin: auto 0; max-width: 520px; }
.rp-auth-sample-label { font-size: .8125rem; color: #8fa6c7; margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem; }
.rp-auth-sample-label::before { content: ""; width: 20px; height: 1px; background: #4c6a93; }
.rp-auth-sample .rp-sentence { color: #fff; max-width: 20ch; font-size: clamp(1.75rem, 3.2vw, 2.6rem); }
.rp-auth-sample .rp-delta-good { background: rgba(23, 190, 165, .16); color: #5fe0c9; }
.rp-auth-sample-meta { margin-top: 1.5rem; display: flex; gap: 2rem; flex-wrap: wrap; font-size: .875rem; }
.rp-auth-sample-meta strong { display: block; color: #fff; font-size: 1.15rem; font-weight: 700; }
.rp-auth-foot { font-size: .8125rem; color: #7f97ba; }
.rp-auth-main { display: flex; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; }
.rp-auth-card { width: 100%; max-width: 400px; }
.rp-auth-card h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: .35rem; }
.rp-auth-card .lead-in { color: var(--rp-ink-2); margin-bottom: 1.75rem; }

/* ---------- Small screens ---------- */
@media (max-width: 991.98px) {
  .rp-sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s ease; }
  .rp-shell.nav-open .rp-sidebar { transform: none; }
  .rp-shell.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(9, 20, 38, .45); z-index: 40; }
  .rp-topbar { padding: 0 1rem; }
  .rp-topbar .rp-menu-toggle { display: grid; }
  .rp-content { padding: 1.25rem 1rem; }
  .rp-auth { grid-template-columns: 1fr; }
  .rp-auth-side { padding: 1.5rem; }
  .rp-auth-sample { margin: 2rem 0 .5rem; }
  .rp-auth-sample-meta, .rp-auth-foot { display: none; }
}
@media (max-width: 575.98px) {
  .rp-step { grid-template-columns: 32px 1fr; }
  .rp-step > :last-child { grid-column: 2; }
  .rp-table > :not(caption) > * > * { padding: .7rem .9rem; }
  .rp-hide-sm { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
