/* ============================================================
   LBOS — Refined layer (v2 exploration)
   Layered ON TOP of lbos.css. Everything is scoped under `.rf`
   so the "Current" baseline artboard renders with stock styles.
   Brand kept: Navy #0B1F3A · Gold #C9A84C — palette & type refined.
   ============================================================ */

.rf {
  /* --- refined brand --- */
  --navy:        #0B1F3A;
  --navy-700:    #11294b;
  --navy-600:    #16335c;
  --navy-900:    #07152a;
  --gold:        #C9A84C;
  --gold-bright: #E4C26A;   /* for use on dark surfaces */
  --gold-soft:   #f3e9cd;
  --gold-tint:   #fbf7ec;

  /* warm-tinted neutrals (subtle vs. the cool stock grays) */
  --paper:   #faf9f7;
  --surface: #ffffff;
  --ink-900: #14213a;
  --ink-700: #3a4256;
  --ink-600: #4b5563;
  --ink-500: #6b7280;
  --ink-400: #9aa1ad;
  --line:    #ece9e3;
  --line-2:  #e3e0d8;

  /* data-viz — matched lightness/chroma, varied hue (oklch) */
  --dv-good:  oklch(0.62 0.09 155);
  --dv-good-bg: oklch(0.95 0.03 155);
  --dv-info:  oklch(0.60 0.10 245);
  --dv-info-bg: oklch(0.95 0.03 245);
  --dv-warn:  oklch(0.70 0.10 75);
  --dv-warn-bg: oklch(0.95 0.04 80);
  --dv-risk:  oklch(0.60 0.14 28);
  --dv-risk-bg: oklch(0.95 0.04 30);

  --rf-shadow-sm: 0 1px 2px rgba(15,28,54,0.05);
  --rf-shadow:    0 2px 4px rgba(15,28,54,0.04), 0 6px 16px rgba(15,28,54,0.06);
  --rf-shadow-lg: 0 12px 32px rgba(15,28,54,0.12);

  font-family: var(--font-ui);
  font-feature-settings: "cv05" 1, "cv08" 1, "ss01" 1;
  color: var(--ink-900);
  -webkit-font-smoothing: antialiased;
}
.rf .tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ============================================================
   SHELL
   ============================================================ */
.rf-shell { display: flex; min-height: 100%; background: var(--paper); }

.rf-sidebar {
  width: 218px; flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy-700) 0%, var(--navy) 42%, var(--navy-900) 100%);
  display: flex; flex-direction: column;
  color: #fff;
  position: relative;
}
.rf-sidebar::after {
  content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 1px;
  background: linear-gradient(180deg, transparent, rgba(201,168,76,0.25), transparent);
}

.rf-logo { padding: 1.25rem 1.1rem 1rem; display: flex; align-items: center; gap: 0.7rem; }
.rf-logo-mark {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  display: flex; align-items: center; justify-content: center;
  color: var(--navy-900); font-weight: 800; font-size: 0.95rem; letter-spacing: -0.04em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 2px 8px rgba(201,168,76,0.3);
}
.rf-logo-text .wm { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.rf-logo-text .wm span { color: var(--gold-bright); }
.rf-logo-text .tag { font-size: 0.69rem; color: rgba(255,255,255,0.5); letter-spacing: 0.06em; text-transform: uppercase; margin-top: 0.3rem; }

.rf-nav { flex: 1; overflow: hidden; padding: 0.5rem 0.7rem 1rem; }
.rf-nav-label {
  font-size: 0.69rem; font-weight: 700; color: rgba(255,255,255,0.4);
  text-transform: uppercase; letter-spacing: 0.14em; padding: 1rem 0.75rem 0.4rem;
}
.rf-nav-item {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.55rem 0.75rem; border-radius: 8px; margin-bottom: 1px;
  font-size: 0.9rem; font-weight: 600; color: rgba(255,255,255,0.92);
  text-decoration: none; cursor: pointer; position: relative;
  transition: background 0.13s, color 0.13s;
}
.rf-nav-item .rf-ico { color: rgba(255,255,255,0.78); transition: color 0.13s; }
.rf-nav .rf-ico .a { fill-opacity: 0.55; }
/* Detail layers on nav icons: dark cutout so they're visible against the white/light icon body */
.rf-nav .rf-ico [stroke="#fff"] { stroke: #0B1F3A !important; }
.rf-nav .rf-ico [fill="#fff"]   { fill:   #0B1F3A !important; }
.rf-nav-item.active .rf-ico .a { fill-opacity: 0.75; }
.rf-nav-item:hover .rf-ico .a { fill-opacity: 0.75; }
.rf-nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; }
.rf-nav-item:hover .rf-ico { color: var(--gold-bright); }
.rf-nav-item.active { background: rgba(201,168,76,0.18); color: var(--gold-bright); font-weight: 700; }
.rf-nav-item.active .rf-ico { color: var(--gold-bright); }
.rf-nav-item.active::before {
  content: ""; position: absolute; left: -0.7rem; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--gold-bright);
}
.rf-nav-item.sub { padding-left: 2.3rem; font-size: 0.84rem; font-weight: 500; color: rgba(255,255,255,0.6); }
.rf-nav-badge {
  margin-left: auto; background: var(--gold); color: var(--navy-900);
  font-size: 0.64rem; font-weight: 800; padding: 0.05rem 0.4rem; border-radius: 999px;
}

.rf-userbox {
  margin: 0 0.7rem; padding: 0.7rem; border-top: 1px solid rgba(255,255,255,0.09);
  display: flex; align-items: center; gap: 0.6rem;
}
.rf-userbox .av {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: rgba(201,168,76,0.18); color: var(--gold-bright);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.8rem;
}
.rf-userbox .nm { font-size: 0.875rem; font-weight: 700; color: #fff; line-height: 1.2; }
.rf-userbox .rl { font-size: 0.72rem; color: var(--gold-bright); text-transform: uppercase; letter-spacing: 0.05em; }

/* active-company switcher */
.rf-company-switcher { position: relative; margin: 0 0.7rem 0.3rem; }
.rf-company-switcher__trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.5rem 0.6rem; border-radius: 8px; border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04); color: rgba(255,255,255,0.85); cursor: pointer;
  font-family: var(--font-ui); text-align: left;
}
.rf-company-switcher__trigger:hover { background: rgba(255,255,255,0.08); }
.rf-company-switcher__label { min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.rf-company-switcher__label .nm {
  font-size: 0.8rem; font-weight: 700; color: #fff; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rf-company-switcher__label .rl {
  font-size: 0.66rem; color: var(--gold-bright); text-transform: uppercase; letter-spacing: 0.05em;
}
.rf-company-switcher__menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 0.35rem); z-index: 40;
  background: var(--navy-900, #0B1F3A); border: 1px solid rgba(255,255,255,0.14);
  border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,0.35); padding: 0.35rem;
  max-height: 260px; overflow-y: auto;
}
.rf-company-switcher__menu-label {
  font-size: 0.64rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  color: rgba(255,255,255,0.4); padding: 0.35rem 0.5rem 0.25rem;
}
.rf-company-switcher__item-form { margin: 0; }
.rf-company-switcher__item {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.5rem 0.6rem; border-radius: 7px; border: none; background: transparent;
  color: rgba(255,255,255,0.85); cursor: pointer; font-family: var(--font-ui); text-align: left;
}
.rf-company-switcher__item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.rf-company-switcher__item.is-active { background: rgba(201,168,76,0.18); color: var(--gold-bright); }
.rf-company-switcher__item-text { min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.rf-company-switcher__item-text .nm {
  font-size: 0.8rem; font-weight: 700; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rf-company-switcher__item-text .rl {
  font-size: 0.66rem; color: var(--gold-bright); text-transform: uppercase; letter-spacing: 0.05em;
}
.rf-company-switcher__item.is-active .rl { color: var(--navy, #0B1F3A); opacity: 0.65; }

/* main */
.rf-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.rf-topbar {
  height: 60px; background: rgba(255,255,255,0.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.6rem; flex-shrink: 0;
  /* Stick to viewport top and float above page content + dropdowns */
  position: sticky; top: 0; z-index: 200; overflow: visible;
}
/* Shift shell + sticky topbar down when the fixed impersonation banner (36px) is showing */
.rf-shell.is-impersonating { padding-top: 36px; }
.rf-shell.is-impersonating .rf-topbar { top: 36px; }
@media (max-width: 1024px) {
  .rf-shell.is-impersonating .rf-sidebar { top: 36px; }
}
.rf-crumb { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; color: var(--ink-400); }
.rf-crumb b { color: var(--navy); font-weight: 700; font-size: 0.95rem; }
.rf-topbar-actions { display: flex; align-items: center; gap: 0.6rem; flex: 1; min-width: 0; justify-content: flex-end; }
.rf-search {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--paper); border: 1px solid var(--line-2); border-radius: 999px;
  padding: 0.4rem 0.9rem; color: var(--ink-400); font-size: 0.8rem; width: 200px;
}

.rf-content { padding: 1.6rem 2rem; }
.rf-content > * { max-width: none; }

/* ============================================================
   BUTTONS / PILLS
   ============================================================ */
.rf-btn {
  display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer;
  border-radius: 8px; font-weight: 700; font-size: 0.82rem; padding: 0.5rem 0.95rem;
  border: 1px solid transparent; transition: all 0.13s; white-space: nowrap; font-family: var(--font-ui);
}
.rf-btn-primary { background: var(--gold); color: var(--navy-900); box-shadow: 0 1px 2px rgba(168,135,46,0.3); }
.rf-btn-primary:hover { background: var(--gold-bright); transform: translateY(-1px); box-shadow: var(--rf-shadow); }
.rf-btn-dark { background: var(--navy); color: #fff; }
.rf-btn-dark:hover { background: var(--navy-600); }
.rf-btn-ghost { background: var(--surface); color: var(--ink-700); border-color: var(--line-2); }
.rf-btn-ghost:hover { border-color: var(--ink-400); color: var(--navy); }
.rf-btn-sm { padding: 0.35rem 0.7rem; font-size: 0.75rem; }

.rf-pill {
  display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.7rem; font-weight: 700;
  padding: 0.15rem 0.55rem; border-radius: 999px; letter-spacing: 0.01em;
}
.rf-pill.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.rf-pill-gold { background: var(--gold-tint); color: #8a6d1f; }
.rf-pill-good { background: var(--dv-good-bg); color: var(--dv-good); }
.rf-pill-info { background: var(--dv-info-bg); color: var(--dv-info); }
.rf-pill-warn { background: var(--dv-warn-bg); color: oklch(0.5 0.1 70); }
.rf-pill-risk { background: var(--dv-risk-bg); color: var(--dv-risk); }
.rf-pill-navy { background: var(--navy); color: var(--gold-bright); }

/* ============================================================
   CARDS / SECTIONS
   ============================================================ */
.rf-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--rf-shadow-sm);
}
.rf-card-pad { padding: 1.25rem 1.35rem; }
.rf-sec-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.9rem; }
.rf-sec-title { font-size: 0.95rem; font-weight: 800; color: var(--navy); letter-spacing: -0.01em; }
.rf-sec-sub { font-size: 0.76rem; color: var(--ink-500); margin-top: 0.1rem; font-weight: 500; }
.rf-eyebrow { font-size: 0.66rem; font-weight: 800; letter-spacing: 0.13em; text-transform: uppercase; color: var(--gold); }

/* greeting */
.rf-greet-name { font-size: 1.5rem; font-weight: 800; color: var(--navy); letter-spacing: -0.025em; }
.rf-greet-sub { font-size: 0.84rem; color: var(--ink-500); margin-top: 0.15rem; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.rf-stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 1.05rem 1.2rem; position: relative; overflow: hidden; box-shadow: var(--rf-shadow-sm);
}
.rf-stat-top { display: flex; align-items: center; justify-content: space-between; }
.rf-stat-ico {
  width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: var(--gold-tint); color: var(--gold);
}
.rf-stat-label { font-size: 0.7rem; font-weight: 700; color: var(--ink-500); text-transform: uppercase; letter-spacing: 0.07em; }
.rf-stat-value { font-size: 2rem; font-weight: 800; color: var(--navy); line-height: 1; letter-spacing: -0.03em; margin-top: 0.55rem; }
.rf-stat-meta { font-size: 0.72rem; color: var(--ink-400); margin-top: 0.5rem; display: flex; align-items: center; gap: 0.35rem; }
.rf-delta { font-weight: 800; display: inline-flex; align-items: center; gap: 0.15rem; }
.rf-delta.up { color: var(--dv-good); }
.rf-delta.down { color: var(--dv-risk); }

/* ============================================================
   AT-RISK ROW CARDS
   ============================================================ */
.rf-risk-row {
  display: flex; align-items: center; gap: 0.9rem; padding: 0.8rem 0;
  border-top: 1px solid var(--line);
}
.rf-risk-row:first-child { border-top: none; }
.rf-risk-av {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.82rem;
}

/* health meter */
.rf-meter { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; width: 100%; }
.rf-meter > span { display: block; height: 100%; border-radius: 999px; }

/* ============================================================
   SCORE RING (conic)
   ============================================================ */
.rf-ring { position: relative; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.rf-ring::before { content: ""; position: absolute; inset: 8px; background: var(--surface); border-radius: 50%; }
.rf-ring-val { position: relative; font-weight: 800; color: var(--navy); letter-spacing: -0.02em; }

/* maturity distribution bar */
.rf-mat { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--line); }
.rf-mat > span { display: block; height: 100%; }
.rf-mat-legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1.1rem; margin-top: 0.8rem; }
.rf-mat-key { display: flex; align-items: center; gap: 0.4rem; font-size: 0.74rem; color: var(--ink-700); font-weight: 600; }
.rf-mat-key i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

/* sparkline wrap */
.rf-spark { width: 100%; height: 38px; display: block; }

/* table refinements */
.rf-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
.rf-table th {
  text-align: left; padding: 0.55rem 0.4rem; color: var(--ink-400);
  font-size: 0.66rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em;
  border-bottom: 1px solid var(--line);
}
.rf-table td { padding: 0.7rem 0.4rem; border-bottom: 1px solid var(--line); color: var(--ink-700); vertical-align: middle; }
.rf-table tr:last-child td { border-bottom: none; }
.rf-table tbody tr { transition: background 0.1s; }
.rf-table .co { font-weight: 700; color: var(--navy); }

/* quick action tile */
.rf-qa {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.75rem 0.85rem;
  border: 1px solid var(--line); border-radius: 11px; background: var(--surface);
  cursor: pointer; transition: all 0.13s; text-decoration: none;
}
.rf-qa:hover { border-color: var(--gold); box-shadow: var(--rf-shadow); transform: translateY(-1px); text-decoration: none; }
.rf-qa .qa-ico { width: 34px; height: 34px; border-radius: 9px; background: var(--gold-tint); color: var(--gold); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rf-qa .qa-t { font-size: 0.82rem; font-weight: 700; color: var(--navy); }
.rf-qa .qa-s { font-size: 0.7rem; color: var(--ink-400); }

/* timeline (upcoming) */
.rf-tl-item { display: flex; gap: 0.75rem; padding: 0.55rem 0; }
.rf-tl-time { font-size: 0.72rem; font-weight: 800; color: var(--gold); width: 52px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.rf-tl-dot { position: relative; }
.rf-tl-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); display: block; margin-top: 4px; }
.rf-tl-body { font-size: 0.8rem; }
.rf-tl-body .t { font-weight: 700; color: var(--navy); }
.rf-tl-body .s { color: var(--ink-400); font-size: 0.74rem; }

/* ============================================================
   COMMAND CENTER (variant C) — navy hero band
   ============================================================ */
.rf-hero {
  background: linear-gradient(135deg, var(--navy-700), var(--navy) 55%, var(--navy-900));
  border-radius: 18px; padding: 1.5rem 1.7rem; color: #fff; position: relative; overflow: hidden;
  box-shadow: var(--rf-shadow-lg);
}
.rf-hero::before {
  content: ""; position: absolute; right: -60px; top: -60px; width: 240px; height: 240px;
  background: radial-gradient(circle, rgba(201,168,76,0.22), transparent 70%);
}
.rf-hero-stat .v { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.03em; }
.rf-hero-stat .l { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(255,255,255,0.6); font-weight: 700; }
.rf-hero-divider { width: 1px; align-self: stretch; background: rgba(255,255,255,0.12); }

.rf-cc-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--rf-shadow-sm); }

/* focus-overlay: let artboards breathe */
.dc-focus .rf-shell { min-height: 100vh; }

/* ============================================================
   MOBILE RESPONSIVE — rf-sidebar
   ============================================================ */
@media (max-width: 1024px) {
  .rf-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 1000;
    transform: translateX(-100%); transition: transform 0.25s ease;
    width: 248px;
  }
  .rf-sidebar.is-open { transform: translateX(0); }
  .rf-shell { position: relative; }
}
/* Allow rf-nav to scroll if content overflows */
.rf-nav { overflow-y: auto !important; }

/* Desktop sidebar collapse (toggled by hamburger on >=1025px) */
.rf-sidebar { transition: width 0.22s ease; }
.rf-shell.sidebar-collapsed .rf-sidebar { width: 0; overflow: hidden; }
.rf-nav::-webkit-scrollbar { width: 4px; }
.rf-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 999px; }

/* chevronRight rotation for breadcrumb */
.rf-crumb .rf-ico { transform: rotate(-90deg); opacity: 0.5; flex-shrink: 0; }

/* topbar search — hide on narrow screens */
@media (max-width: 768px) {
  .rf-search { display: none; }
}

/* ============================================================
   MOBILE POLISH — phones (max 480px)
   ============================================================ */

/* 1. Topbar: truncate section title, reduce action button padding */
@media (max-width: 480px) {
  .rf-topbar { padding: 0 0.75rem; }
  .rf-crumb span.rf-topbar-title,
  .rf-crumb > span:first-of-type {
    max-width: 120px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .rf-topbar-actions > button,
  .rf-topbar-actions > a,
  .rf-topbar-actions .btn {
    padding: 0.5rem !important;
  }
}

/* 3. Main content: tighter horizontal padding on small phones */
@media (max-width: 480px) {
  .rf-content { padding: 0.75rem 0.75rem; }
}

/* 3b. Main content: reserve room for the fixed mobile Help bubble
   (#help-bubble-btn, client_portal/base.html - bottom:1.5rem, ~40px tall,
   z-index 9101, shown only below 768px) so the last card/text on a page
   always scrolls clear of it instead of sitting underneath. Placed after
   the 480px horizontal-padding rule above so this bottom value wins at
   every width <= 768px, including <= 480px. Desktop (>768px) hides the
   bubble, so no extra padding is added there. */
@media (max-width: 768px) {
  .rf-content { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px)); }
}

/* 4. Card grids: force single column below 480px */
@media (max-width: 480px) {
  .card-grid { grid-template-columns: 1fr !important; }
}

/* 5. Table scroll containers */
@media (max-width: 768px) {
  .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* 6. Modal inner padding reduced on small phones */
@media (max-width: 480px) {
  .permissions-modal-body { padding: 1rem !important; }
}

/* 8. Sidebar nav items: smaller on phones */
@media (max-width: 480px) {
  .rf-nav-item { font-size: 0.8125rem; padding: 0.45rem 0.75rem; }
}
