/* Revenue assurance v3 shell: app rail, inset content panel, page header, side drawer, Ask Fina overlay, live runner, shared pieces.
   Pattern: the live revenue product (research/LIVE-PRODUCT.md). Kit tokens only. Spacing on the 4 px scale (L-07). */
.nowrap { white-space: nowrap; }
body { background: var(--sidebar); overflow: hidden; }

/* ---------- Frame: rail + white panel inset from it ---------- */
.rx { --rail: 56px; --rail-open: 240px; display: flex; height: 100%; padding-left: var(--rail); transition: padding-left var(--motion-standard) var(--ease-move); }
.rx.pinned { padding-left: var(--rail-open); }
.rx-main { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; margin: 8px 8px 8px 0; background: var(--background); border: 1px solid var(--border); border-radius: var(--radius-xl); overflow: hidden; box-shadow: var(--shadow-sm); }
.rx-main > .page { flex: 1 1 0; min-height: 0; overflow: auto; }
.page-inner.rx-page { padding: 32px 40px 112px; max-width: 1360px; margin: 0 auto; }
/* V3: the floating Ask Fina pill (40 px, 24 px from the bottom) never covers the last rows; inner scrollers keep the same clearance. */
.rx-main > .page { scroll-padding-bottom: 96px; }

/* ---------- App rail (collapsed 56, hover or pin 240, overlays content) ---------- */
.rx-rail { position: fixed; z-index: 70; left: 0; top: 0; bottom: 0; width: var(--rail, 56px); display: flex; flex-direction: column; padding: 12px 8px; background: var(--sidebar); overflow: hidden; transition: width var(--motion-standard) var(--ease-move), box-shadow var(--motion-standard); }
.rx-rail:is(:hover, :focus-within, .pinned, .menu-open) { width: 240px; }
.rx-rail:is(:hover, :focus-within, .menu-open):not(.pinned) { background: var(--background); border-right: 1px solid var(--sidebar-border); border-radius: 0 var(--radius-2xl) var(--radius-2xl) 0; box-shadow: var(--shadow-filter-popover); }
.rx-label { opacity: 0; transition: opacity var(--motion-quick); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.rx-rail:is(:hover, :focus-within, .pinned, .menu-open) .rx-label { opacity: 1; }

.rx-brand { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 0 0 0; margin-bottom: 24px; white-space: nowrap; }
.rx-brand-mark { flex: none; width: 40px; height: 40px; border-radius: var(--radius-lg); display: grid; place-items: center; background: linear-gradient(160deg, var(--finrep-500), var(--primary)); color: var(--primary-foreground); box-shadow: var(--shadow-sm); }
.rx-brand-mark svg { width: 28px; height: 28px; }
.rx-brand-text strong { display: block; font-size: 14px; line-height: 20px; font-weight: 600; }
.rx-brand-text small { display: block; font-size: 12px; line-height: 16px; color: var(--muted-foreground); }

.rx-nav { display: flex; flex-direction: column; gap: 16px; flex: 1 1 auto; min-height: 0; overflow: hidden auto; scrollbar-width: none; }
.rx-group { display: flex; flex-direction: column; gap: 4px; }
.rx-group-label { height: 16px; padding: 0 12px; font-size: 11px; line-height: 16px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-foreground); }
.rx-item { display: flex; align-items: center; gap: 12px; height: 40px; width: 40px; padding: 0 12px; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--sidebar-foreground); font-weight: 400; font-size: 14px; cursor: pointer; text-align: left; white-space: nowrap; overflow: hidden; transition: background var(--motion-quick), width var(--motion-standard) var(--ease-move); }
.rx-rail:is(:hover, :focus-within, .pinned, .menu-open) .rx-item { width: 100%; }
.rx-item svg.lucide { width: 16px; height: 16px; flex: none; color: var(--muted-foreground); }
.rx-item:hover { background: var(--accent); }
.rx-item[aria-current="page"] { background: var(--background); color: var(--foreground); font-weight: 500; box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border); }
.rx-item[aria-current="page"] svg.lucide { color: var(--primary); }
.rx-item[aria-pressed="true"] svg.lucide { color: var(--primary); }
.rx-count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-full); background: var(--muted-brand); color: var(--primary); font-size: 12px; line-height: 20px; font-weight: 500; text-align: center; flex: none; }

.rx-rail-foot { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; }
.rx-profile { display: flex; align-items: center; gap: 12px; height: 48px; width: 40px; padding: 4px; border: 0; border-radius: var(--radius-lg); background: transparent; cursor: pointer; text-align: left; overflow: hidden; transition: background var(--motion-quick), width var(--motion-standard) var(--ease-move); }
.rx-rail:is(:hover, :focus-within, .pinned, .menu-open) .rx-profile { width: 100%; background: var(--muted); }
.rx-profile:hover { background: var(--accent); }
.rx-profile-text { flex: 1; }
.rx-profile-text strong { display: block; font-size: 14px; line-height: 20px; font-weight: 600; }
.rx-profile-text small { display: block; font-size: 12px; line-height: 16px; color: var(--muted-foreground); }
.rx-caret { flex: none; color: var(--muted-foreground); }
.avatar { flex: none; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-full); background: var(--muted-brand); color: var(--primary); font-size: 12px; font-weight: 600; }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }

/* ---------- Popovers: avatar menu, period menu ---------- */
.rx-pop { position: fixed; z-index: 90; width: 280px; padding: 4px; background: var(--popover); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-filter-popover); }
.rx-period-menu { width: 240px; }
.rx-menu-who { display: flex; align-items: center; gap: 12px; padding: 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.rx-pop-group { display: flex; flex-direction: column; padding: 4px 0; }
.rx-pop-group + .rx-pop-group { border-top: 1px solid var(--border); }
.rx-pop-label { padding: 4px 12px; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--muted-foreground); }
.rx-pop-item { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border: 0; border-radius: var(--radius-md); background: transparent; cursor: pointer; text-align: left; width: 100%; }
.rx-pop-item:hover, .rx-pop-item:focus-visible { background: var(--accent); outline: none; }
.rx-pop-item svg.lucide { color: var(--muted-foreground); }
.rx-pop-item[aria-checked="true"] svg.lucide:last-child { color: var(--primary); }

/* ---------- Page header (no top bar) ---------- */
.rx-head { margin-bottom: 32px; }
.rx-head-row { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.rx-head-row > .grow { flex: 1 1 320px; }
.rx-title { font-family: var(--font-serif); font-size: 32px; line-height: 40px; font-weight: 500; letter-spacing: -0.4px; color: var(--foreground); }
.rx-head-sub { margin-top: 4px; font-size: 14px; line-height: 20px; color: var(--muted-foreground); }
.rx-head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; padding-top: 4px; }
.rx-back { margin-top: 4px; }
.rx-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.rx-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: var(--radius-md); background: var(--muted); border: 1px solid var(--border); font-size: 12px; font-weight: 500; color: var(--foreground); white-space: nowrap; }
.rx-chip svg.lucide { width: 14px; height: 14px; color: var(--muted-foreground); }

.rx-period { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-full); background: var(--background); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-2xs); }
.rx-period:hover { background: var(--accent); }
.rx-period-status { color: var(--muted-foreground); font-weight: 400; }
.rx-period svg.lucide { width: 14px; height: 14px; color: var(--muted-foreground); }
.rx-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted-foreground); }
.rx-dot.open { background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 18%, transparent); }
.rx-dot.closed { background: var(--muted-foreground); }

/* ---------- Toolbar (search + filters + actions right) ---------- */
.rx-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.rx-search { position: relative; flex: 1 1 280px; min-width: 200px; }
.rx-search svg.lucide { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted-foreground); pointer-events: none; }
.rx-search .input { padding-left: 36px; }
.rx-toolbar .select { width: auto; min-width: 160px; }
.rx-section-title { display: flex; align-items: center; gap: 8px; margin: 32px 0 12px; font-size: 16px; line-height: 24px; font-weight: 600; }
.rx-section-title:first-child { margin-top: 0; }

/* ---------- KPIs: muted fill, icon top right ---------- */
.rx-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.rx-kpi { display: flex; flex-direction: column; gap: 4px; padding: 20px; border-radius: var(--radius-xl); background: var(--muted); border: 1px solid var(--border); min-width: 0; }
.rx-kpi-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted-foreground); }
.rx-kpi-head svg.lucide { width: 28px; height: 28px; padding: 6px; border-radius: var(--radius-md); background: var(--background); color: var(--muted-foreground); box-shadow: var(--shadow-2xs); }
.rx-kpi-value { margin-top: 8px; font-size: 28px; line-height: 36px; font-weight: 600; letter-spacing: -0.4px; white-space: nowrap; }
.rx-kpi.success .rx-kpi-value { color: var(--success); }
.rx-kpi.warning .rx-kpi-value { color: var(--warning); }
.rx-kpi.destructive .rx-kpi-value { color: var(--destructive); }
.rx-kpi.brand .rx-kpi-value { color: var(--primary); }
.rx-kpi-delta { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--muted-foreground); }
.rx-kpi-delta.up { color: var(--destructive); }
.rx-kpi-delta.down, .rx-kpi-delta.good { color: var(--success); }

/* ---------- Tables ---------- */
.rx-table { border-radius: var(--radius-xl); }
.rx-table table.table { min-width: var(--min-w, 0); }
.rx-table .table th { background: var(--muted); font-size: 12px; height: 40px; }
.rx-table .table td { height: 52px; padding: 12px; }
.rx-table.dense .table td { height: 44px; padding: 8px 12px; }
.table td.num, .table td.nowrap, .table th.nowrap { white-space: nowrap; }
.table .cell-main { display: block; color: var(--foreground); font-weight: 500; }
.table .cell-sub { display: block; font-size: 12px; line-height: 16px; color: var(--muted-foreground); }
.table th.act, .table td.act { text-align: right; width: 48px; }
.table tr.selected td:first-child { box-shadow: inset 2px 0 0 var(--primary); }
.rx-empty-row { color: var(--muted-foreground); text-align: center; height: 96px; }
.badge svg.lucide { width: 12px; height: 12px; }
.badge { flex: none; }
.rx-sim { background: var(--muted-brand); color: var(--primary); }
.rx-sim .fina-spark { width: 12px; height: 12px; }

/* ---------- Empty state, Fina card, citations ---------- */
.rx-emptystate { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 48px 16px; text-align: center; color: var(--muted-foreground); }
.rx-emptystate svg.lucide { width: 28px; height: 28px; color: var(--primary); }
.rx-emptystate p { max-width: 420px; }
.rx-fina-card { display: flex; flex-direction: column; gap: 8px; padding: 16px 20px; border-radius: var(--radius-xl); background: var(--background-brand); border: 1px solid color-mix(in srgb, var(--primary) 18%, transparent); }
.rx-reading { font-family: var(--font-serif); font-size: 16px; line-height: 24px; }
.rx-reading b, .rx-reading strong { font-weight: 600; }
.rx-clause { font-family: var(--font-serif); font-size: 16px; line-height: 26px; }
.rx-clause mark, mark.rx-hl { background: color-mix(in srgb, var(--finrep-300) 45%, transparent); color: inherit; border-radius: 2px; padding: 0 2px; }

/* ---------- Tabs at 32 px (Q-07) ---------- */
.tabs { padding: 2px; max-width: 100%; overflow-x: auto; }
.tab { height: 28px; white-space: nowrap; flex: none; }

/* ---------- Switch ---------- */
.rx-switch { position: relative; display: inline-flex; flex: none; width: 36px; height: 20px; cursor: pointer; }
.rx-switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.rx-switch span { position: absolute; inset: 0; border-radius: var(--radius-full); background: var(--input); transition: background var(--motion-quick); }
.rx-switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--background); box-shadow: var(--shadow-switcher-thumb), 0 0 0 1px var(--border); transition: transform var(--motion-quick) var(--ease-move); }
.rx-switch input:checked + span { background: var(--primary); }
.rx-switch input:checked + span::after { transform: translateX(16px); }
.rx-switch input:focus-visible + span { outline: 2px solid var(--ring); outline-offset: 2px; }

/* ---------- Side drawer (overlay, right) ---------- */
.rx-side { position: fixed; z-index: 75; top: 8px; right: 8px; bottom: 8px; width: min(var(--side-w, 560px), calc(100vw - 96px)); display: flex; flex-direction: column; background: var(--background); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-search-dropdown); transform: translateX(calc(100% + 16px)); transition: transform var(--motion-standard) var(--ease-enter); }
.rx-side.open { transform: none; }
.rx-side-head { display: flex; align-items: flex-start; gap: 8px; padding: 16px 16px 16px 24px; border-bottom: 1px solid var(--border); flex: none; }
.rx-side-head .grow > * + * { margin-top: 2px; }
.rx-side-title { font-size: 16px; line-height: 24px; font-weight: 600; overflow-wrap: anywhere; }
.rx-side-body { flex: 1; min-height: 0; overflow: auto; padding: 24px; }

/* ---------- Dialog ---------- */
.rx-scrim { z-index: 95; animation: rx-fade var(--motion-standard) var(--ease-enter); }
.rx-dialog { padding: 0; display: flex; flex-direction: column; border: 1px solid var(--border); }
.rx-dialog-head { display: flex; align-items: flex-start; gap: 8px; padding: 20px 20px 0 24px; }
.rx-dialog-body { padding: 16px 24px 0; }
.rx-dialog .dialog-foot { padding: 0 24px 24px; }
@keyframes rx-fade { from { opacity: 0; } }

/* ---------- Ask Fina: floating pill bottom centre + overlay panel ---------- */
.rx-ask-pill { position: fixed; z-index: 65; left: calc(50% + 28px); bottom: 24px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 20px 0 16px; border: 1px solid var(--border); border-radius: var(--radius-full); background: var(--background); font-weight: 500; cursor: pointer; box-shadow: var(--shadow-search-bar); transition: box-shadow var(--motion-quick), transform var(--motion-quick); }
.rx-ask-pill:hover { box-shadow: var(--shadow-search-dropdown); transform: translateX(-50%) translateY(-1px); }
.rx.pinned ~ .rx-ask-pill { left: calc(50% + 120px); }
.rx-fina { position: fixed; z-index: 80; right: 8px; top: 8px; bottom: 8px; width: min(420px, calc(100vw - 96px)); display: flex; flex-direction: column; background: var(--background); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-search-dropdown); transform: translateX(calc(100% + 16px)); transition: transform var(--motion-standard) var(--ease-enter); }
.rx-fina.open { transform: none; }
.rx-fina-head { display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 12px 0 16px; border-bottom: 1px solid var(--border); flex: none; }
.rx-fina-body { flex: 1; min-height: 0; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.rx-fina-hello { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px 0 8px; text-align: center; }
.rx-fina-hello .fina-spark { width: 28px; height: 28px; }
.rx-fina-hello .t-page { font-family: var(--font-serif); font-weight: 500; }
.rx-q { align-self: flex-end; max-width: 85%; padding: 8px 12px; border-radius: var(--radius-lg); background: var(--muted); }
.rx-a .rx-reading { font-size: 15px; line-height: 24px; }
.rx-fina-link { display: inline-flex; align-items: center; gap: 4px; margin-top: 8px; }
.rx-try { display: flex; flex-direction: column; gap: 4px; }
.rx-try-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); text-align: left; cursor: pointer; transition: background var(--motion-quick); }
.rx-try-row + .rx-try-row { margin-top: 4px; }
.rx-try-row:hover { background: var(--accent); }
.rx-try-row svg.lucide { color: var(--primary); }
.rx-fina-foot { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); flex: none; }

/* ---------- Live runner (floating or inline) ---------- */
.rx-live.floating { position: fixed; z-index: 85; right: 24px; bottom: 80px; width: 380px; max-width: calc(100vw - 48px); animation: rx-rise var(--motion-deliberate) var(--ease-enter); }
@keyframes rx-rise { from { opacity: 0; transform: translateY(8px); } }
.rx-live-card { border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--background); box-shadow: var(--shadow-search-dropdown); overflow: hidden; }
.rx-live-card.inline { box-shadow: none; }
.rx-live-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px 16px; }
.rx-live-head strong { font-size: 15px; line-height: 22px; font-weight: 600; }
.rx-live-steps { list-style: none; margin: 0; padding: 0 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.rx-live-steps li { display: flex; align-items: flex-start; gap: 12px; padding: 8px 12px; border-radius: var(--radius-lg); background: var(--muted); transition: background var(--motion-quick), opacity var(--motion-quick); }
.rx-live-steps li.todo { opacity: .55; }
.rx-live-steps li.active { background: var(--background-brand); }
.rx-live-ic { width: 20px; height: 20px; display: grid; place-items: center; flex: none; color: var(--muted-foreground); }
.rx-live-steps li.done .rx-live-ic { color: var(--success); }
.rx-live-label { display: block; font-size: 14px; line-height: 20px; }
.rx-live-steps li.done .rx-live-label { color: var(--muted-foreground); }
.rx-live-detail { display: block; font-size: 12px; line-height: 16px; color: var(--muted-foreground); }
.rx-live-count { flex: none; font-size: 12px; line-height: 20px; font-weight: 600; color: var(--primary); padding: 0 8px; border-radius: var(--radius-full); background: var(--muted-brand); animation: rx-fade var(--motion-standard); }
.rx-live-bar { height: 4px; background: var(--muted); }
.rx-live-bar i { display: block; height: 100%; background: var(--primary); transition: width var(--motion-deliberate) var(--ease-move); }
.rx-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--primary); border-right-color: transparent; animation: rx-spin .8s linear infinite; }
@keyframes rx-spin { to { transform: rotate(360deg); } }

/* Kit tags and toasts clear the Ask Fina pill and rail */
.proto-tag { left: auto; right: 16px; bottom: 16px; }
.toast { bottom: 80px; z-index: 99; }

@media (max-width: 1100px) {
  .page-inner.rx-page { padding: 24px 24px 112px; }
  .rx-title { font-size: 28px; line-height: 36px; }
}
@media (prefers-reduced-motion: reduce) { .rx-rail, .rx-side, .rx-fina, .rx-label, .rx-item { transition: none; } }

/* Round 2: exported file card (A1) */
.rx-export { display: flex; flex-direction: column; gap: 12px; }
.rx-export-file { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--muted); }
.rx-export-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-md); background: var(--muted-brand); color: var(--primary); flex: none; }
.rx-export-ic svg { width: 20px; height: 20px; }
.rx-export-name { word-break: normal; overflow-wrap: anywhere; hyphens: none; }
.rx-export-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; color: var(--muted-foreground); font-size: 13px; }

/* V16: Ask Fina suggested questions as cards (pattern: the live product's Try cards) */
.rx-try-card { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); text-align: left; cursor: pointer; transition: background var(--motion-quick), border-color var(--motion-quick), box-shadow var(--motion-quick); }
.rx-try-card + .rx-try-card { margin-top: 8px; }
.rx-try-card:hover { background: var(--background-brand); border-color: color-mix(in srgb, var(--primary) 24%, transparent); box-shadow: var(--shadow-2xs); }
.rx-try-card:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.rx-try-ic { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-md); background: var(--muted-brand); color: var(--primary); }
.rx-try-ic svg.lucide { width: 16px; height: 16px; }
.rx-try-q { display: block; font-size: 14px; line-height: 20px; font-weight: 500; color: var(--foreground); }
.rx-try-sub { display: block; font-size: 12px; line-height: 16px; color: var(--muted-foreground); }
.rx-try-go { flex: none; width: 14px; height: 14px; color: var(--muted-foreground); }
#fina-more:empty { display: none; }
