/* ============================================================================
   platform.css — ONE unified premium light design system + global shell.

   Loaded by every surface (Jinja pages + all SPAs). Provides:
     1. Design tokens (single source of visual truth) — light theme.
     2. The global platform bar (identity + breadcrumbs + journey launcher).
     3. Premium primitives (buttons, cards, panels, badges, KPIs, tables) and
        UI states (loading / empty / error / success / skeleton).

   Everything is namespaced `pf-` so it never collides with a page's own CSS.
   The bar is injected + controlled by platform.js.
   ========================================================================== */
:root {
  /* Brand — aligned to the existing light SPAs (RM console, UC1-3, portal). */
  --pf-brand:        #2f5fd8;
  --pf-brand-2:      #5b8bff;
  --pf-brand-ink:    #1e40b0;
  --pf-brand-soft:   #eaf0fe;
  --pf-accent:       #8a4fd8;

  /* Business-unit accents */
  --pf-sec:          #2f5fd8;   /* Securities */
  --pf-sec-soft:     #eaf0fe;
  --pf-amc:          #0e9f6e;   /* Asset Management */
  --pf-amc-soft:     #e6f7ef;

  /* Surfaces */
  --pf-bg:           #eef2f8;
  --pf-bg-2:         #f4f7fb;
  --pf-surface:      #ffffff;
  --pf-surface-2:    #f8fafd;
  --pf-surface-3:    #f1f5fb;

  /* Ink */
  --pf-ink:          #16202e;
  --pf-ink-2:        #48566a;
  --pf-muted:        #7a8699;
  --pf-line:         #e2e7f0;
  --pf-line-2:       #eef1f7;

  /* Semantic */
  --pf-good:         #14a06b;
  --pf-good-soft:    #e6f7ef;
  --pf-warn:         #d78200;
  --pf-warn-soft:    #fdf3e2;
  --pf-bad:          #d8443a;
  --pf-bad-soft:     #fdecea;
  --pf-info:         #2f5fd8;
  --pf-info-soft:    #eaf0fe;

  /* Typography */
  --pf-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --pf-mono: "SF Mono", "Cascadia Code", "JetBrains Mono", Consolas, monospace;

  /* Radii + shadow + motion */
  --pf-radius:       14px;
  --pf-radius-sm:    9px;
  --pf-radius-lg:    20px;
  --pf-shadow:       0 6px 20px rgba(20, 32, 46, .08);
  --pf-shadow-lg:    0 18px 48px rgba(20, 32, 46, .16);
  --pf-shadow-sm:    0 2px 6px rgba(20, 32, 46, .06);
  --pf-ease:         cubic-bezier(.4, 0, .2, 1);
  --pf-dur:          .22s;

  /* Layout */
  --pf-maxw:         1320px;
  --pf-bar-h:        52px;
}

/* =====================  GLOBAL PLATFORM BAR  ============================= */
.pf-bar {
  --pf-shell-accent: var(--pf-brand);
  --pf-shell-soft: var(--pf-brand-soft);
  position: sticky; top: 0; z-index: 900;
  height: var(--pf-bar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--pf-shell-soft) 38%, transparent), rgba(255,255,255,0) 42%),
    rgba(255, 255, 255, .86);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--pf-shell-accent) 18%, var(--pf-line));
  font-family: var(--pf-font);
  color: var(--pf-ink);
}
.pf-bar * { box-sizing: border-box; }

/* Embed mode: on SPA surfaces that already own a sticky/fixed header, the bar
   sits as a static top strip so the page's own header keeps the viewport top. */
.pf-embed .pf-bar { position: static; }
.pf-embed #synthetic-badge { top: calc(var(--pf-bar-h) + 10px); }

.pf-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; flex-shrink: 0; }
.pf-brand__mark {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--pf-brand), var(--pf-brand-2));
  color: #fff; font-weight: 800; font-size: 14px;
  display: grid; place-items: center;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--pf-brand) 40%, transparent);
}
.pf-brand__name { font-weight: 750; font-size: 14px; letter-spacing: -.01em; line-height: 1; }
.pf-brand__sub  { font-size: 10.5px; color: var(--pf-muted); font-weight: 600; margin-top: 2px; letter-spacing: .02em; }
@media (max-width: 720px) { .pf-brand__text { display: none; } }

/* breadcrumb */
.pf-crumbs { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--pf-ink-2); min-width: 0; overflow: hidden; }
.pf-crumbs__sep { color: var(--pf-muted); opacity: .6; }
.pf-crumbs a { color: var(--pf-ink-2); text-decoration: none; white-space: nowrap; border-radius: 6px; padding: 2px 6px; transition: background var(--pf-dur), color var(--pf-dur), opacity var(--pf-dur); }
.pf-crumbs a:hover { background: var(--pf-surface-3); color: var(--pf-brand); opacity: 1; }
.pf-crumbs__trail { opacity: .58; }
.pf-crumbs__here { font-weight: 700; color: var(--pf-ink); white-space: nowrap; padding: 2px 2px; overflow: hidden; text-overflow: ellipsis; }
.pf-crumbs__new { display: inline-block; animation: pf-crumb-new .28s var(--pf-ease); }
@keyframes pf-crumb-new { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: translateX(0); } }

.pf-spacer { flex: 1 1 auto; }

.pf-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* generic small pill button used in the bar */
.pf-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 20px;
  background: var(--pf-surface); border: 1px solid var(--pf-line);
  color: var(--pf-ink-2); font-size: 12.5px; font-weight: 650; cursor: pointer;
  text-decoration: none; transition: all var(--pf-dur) var(--pf-ease); white-space: nowrap;
}
.pf-chip:hover { border-color: var(--pf-brand); color: var(--pf-brand); box-shadow: var(--pf-shadow-sm); transform: translateY(-1px); }
.pf-chip svg { width: 15px; height: 15px; }
.pf-chip--primary { background: var(--pf-brand); border-color: var(--pf-brand); color: #fff; }
.pf-chip--primary:hover { background: var(--pf-brand-ink); color: #fff; }

/* journey launcher dropdown */
.pf-launcher { position: relative; }
.pf-menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: 340px; max-width: 86vw;
  background: var(--pf-surface); border: 1px solid var(--pf-line);
  border-radius: var(--pf-radius); box-shadow: var(--pf-shadow-lg);
  padding: 10px; opacity: 0; visibility: hidden; transform: translateY(-6px) scale(.98);
  transform-origin: top right; transition: all var(--pf-dur) var(--pf-ease); z-index: 950;
  max-height: 78vh; overflow-y: auto;
}
.pf-launcher.is-open .pf-menu { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.pf-command { position: sticky; top: -10px; z-index: 1; display: flex; align-items: center; gap: 8px;
  margin: -2px -2px 6px; padding: 2px; background: var(--pf-surface); }
.pf-command__input { width: 100%; height: 36px; border: 1px solid var(--pf-line); border-radius: 11px;
  padding: 0 58px 0 12px; font: 650 13px var(--pf-font); color: var(--pf-ink); outline: none;
  background: var(--pf-surface-2); transition: border-color var(--pf-dur), box-shadow var(--pf-dur); }
.pf-command__input:focus { border-color: var(--pf-shell-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pf-shell-accent) 16%, transparent); }
.pf-command__hint { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--pf-muted);
  border: 1px solid var(--pf-line); border-radius: 7px; padding: 2px 6px; font-size: 10px; font-weight: 800; background: var(--pf-surface); }
.pf-command__empty { padding: 16px 10px 18px; color: var(--pf-muted); font-size: 12.5px; }
.pf-menu__group { font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--pf-muted); padding: 10px 10px 5px; }
.pf-menu__item {
  display: flex; align-items: flex-start; gap: 11px; padding: 9px 10px; border-radius: 10px;
  text-decoration: none; color: var(--pf-ink); transition: background var(--pf-dur);
}
.pf-menu__item:hover, .pf-menu__item.is-active { background: var(--pf-surface-3); }
.pf-menu__item.is-active { box-shadow: inset 3px 0 0 var(--pf-shell-accent); }
.pf-menu__ic { width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; display: grid; place-items: center;
  font-size: 15px; background: var(--pf-brand-soft); }
.pf-menu__ic--amc { background: var(--pf-amc-soft); }
.pf-menu__tt { font-size: 13px; font-weight: 700; line-height: 1.2; }
.pf-menu__ds { font-size: 11.5px; color: var(--pf-muted); margin-top: 2px; line-height: 1.35; }

.pf-bar--securities { --pf-shell-accent: var(--pf-sec); --pf-shell-soft: var(--pf-sec-soft); }
.pf-bar--amc { --pf-shell-accent: var(--pf-amc); --pf-shell-soft: var(--pf-amc-soft); }
.pf-bar--amc .pf-brand__mark { background: linear-gradient(135deg, var(--pf-amc), #34c58e); box-shadow: 0 2px 8px color-mix(in srgb, var(--pf-amc) 40%, transparent); }
.pf-bar--securities .pf-crumbs a:hover, .pf-bar--securities .pf-chip:hover { color: var(--pf-sec); border-color: var(--pf-sec); }
.pf-bar--amc .pf-crumbs a:hover, .pf-bar--amc .pf-chip:hover { color: var(--pf-amc); border-color: var(--pf-amc); }

/* =====================  PREMIUM PRIMITIVES  ============================= */
.pf-container { max-width: var(--pf-maxw); margin: 0 auto; padding: 0 22px; }

.pf-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 11px; border: 1px solid transparent;
  font-family: var(--pf-font); font-size: 13.5px; font-weight: 700; cursor: pointer;
  text-decoration: none; transition: all var(--pf-dur) var(--pf-ease); white-space: nowrap;
}
.pf-btn--primary { background: var(--pf-brand); color: #fff; box-shadow: 0 6px 18px color-mix(in srgb, var(--pf-brand) 30%, transparent); }
.pf-btn--primary:hover { background: var(--pf-brand-ink); transform: translateY(-2px); box-shadow: 0 10px 26px color-mix(in srgb, var(--pf-brand) 38%, transparent); }
.pf-btn--ghost { background: var(--pf-surface); color: var(--pf-ink); border-color: var(--pf-line); }
.pf-btn--ghost:hover { border-color: var(--pf-brand); color: var(--pf-brand); transform: translateY(-2px); box-shadow: var(--pf-shadow-sm); }
.pf-btn--lg { padding: 14px 26px; font-size: 15px; border-radius: 13px; }

.pf-card {
  background: var(--pf-surface); border: 1px solid var(--pf-line);
  border-radius: var(--pf-radius); box-shadow: var(--pf-shadow);
  padding: 18px; transition: transform var(--pf-dur) var(--pf-ease), box-shadow var(--pf-dur) var(--pf-ease), border-color var(--pf-dur);
}
.pf-card--hover:hover { transform: translateY(-4px); box-shadow: var(--pf-shadow-lg); border-color: color-mix(in srgb, var(--pf-brand) 35%, var(--pf-line)); }

.pf-panel { background: var(--pf-surface); border: 1px solid var(--pf-line); border-radius: var(--pf-radius); box-shadow: var(--pf-shadow); }
.pf-panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--pf-line-2); }
.pf-panel__title { font-size: 14.5px; font-weight: 750; }
.pf-panel__body { padding: 18px; }

.pf-badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 800; letter-spacing: .02em; background: var(--pf-surface-3); color: var(--pf-ink-2); }
.pf-badge--good { background: var(--pf-good-soft); color: var(--pf-good); }
.pf-badge--warn { background: var(--pf-warn-soft); color: var(--pf-warn); }
.pf-badge--bad  { background: var(--pf-bad-soft);  color: var(--pf-bad); }
.pf-badge--info { background: var(--pf-info-soft); color: var(--pf-info); }
.pf-badge--brand { background: var(--pf-brand-soft); color: var(--pf-brand-ink); }
.pf-badge--amc  { background: var(--pf-amc-soft); color: var(--pf-amc); }

.pf-kpi { display: flex; flex-direction: column; gap: 3px; }
.pf-kpi__val { font-size: 26px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.pf-kpi__lbl { font-size: 11.5px; color: var(--pf-muted); font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }

/* small utilities */
.pf-muted { color: var(--pf-muted); }

/* data tables */
.pf-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pf-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--pf-muted);
  font-weight: 800; padding: 9px 12px; border-bottom: 1px solid var(--pf-line); background: var(--pf-surface-2); position: sticky; top: 0; }
.pf-table td { padding: 10px 12px; border-bottom: 1px solid var(--pf-line-2); color: var(--pf-ink); }
.pf-table tbody tr { cursor: pointer; transition: background var(--pf-dur); }
.pf-table tbody tr:hover { background: var(--pf-surface-3); }
.pf-table--flat tbody tr { cursor: default; }

/* =====================  UI STATES  ===================================== */
.pf-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  text-align: center; padding: 46px 24px; color: var(--pf-muted); }
.pf-state__ic { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 24px; background: var(--pf-surface-3); }
.pf-state__tt { font-size: 15px; font-weight: 750; color: var(--pf-ink); }
.pf-state__ds { font-size: 13px; max-width: 420px; line-height: 1.5; }
.pf-state--error .pf-state__ic { background: var(--pf-bad-soft); color: var(--pf-bad); }
.pf-state--success .pf-state__ic { background: var(--pf-good-soft); color: var(--pf-good); }

.pf-spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--pf-line);
  border-top-color: var(--pf-brand); animation: pf-spin .8s linear infinite; }
@keyframes pf-spin { to { transform: rotate(360deg); } }

/* skeleton loaders */
.pf-skel, .sk { position: relative; overflow: hidden; background: var(--pf-surface-3); border-radius: 8px; }
.pf-skel::after, .sk::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.65), transparent);
  transform: translateX(-100%); animation: pf-shimmer 1.4s infinite; }
@keyframes pf-shimmer { 100% { transform: translateX(100%); } }
.pf-skel--line, .sk-line { height: 12px; margin: 8px 0; }
.pf-skel--kpi  { height: 46px; }
.pf-skel--card { height: 120px; }
.sk-block { min-height: 96px; }

/* toast */
.pf-toast-host { position: fixed; right: 18px; bottom: 18px; z-index: 1000; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.pf-toast { position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px; background: var(--pf-ink); color: #fff;
  padding: 11px 14px 12px 16px; border-radius: 11px; font-size: 13px; font-weight: 600;
  box-shadow: var(--pf-shadow-lg); animation: pf-toast-in .28s var(--pf-ease); max-width: 360px; transition: opacity .3s var(--pf-ease), transform .3s var(--pf-ease); }
.pf-toast.is-leaving { opacity: 0; transform: translateY(8px); }
.pf-toast__msg { min-width: 0; }
.pf-toast__action { border: 1px solid rgba(255,255,255,.55); border-radius: 999px; background: rgba(255,255,255,.14); color: #fff;
  cursor: pointer; font: 800 11.5px var(--pf-font); padding: 4px 9px; white-space: nowrap; }
.pf-toast__action:hover { background: rgba(255,255,255,.24); }
.pf-toast__edge { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.7);
  transform-origin: left center; animation: pf-toast-drain var(--pf-toast-dur, 3200ms) linear forwards; }
.pf-toast--good, .pf-toast--success { background: var(--pf-good); } .pf-toast--bad { background: var(--pf-bad); }
.pf-toast--warn { background: var(--pf-warn); } .pf-toast--info { background: var(--pf-info); }
@keyframes pf-toast-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes pf-toast-drain { to { transform: scaleX(0); } }

/* view-transition routing */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .18s; animation-timing-function: var(--pf-ease); }
::view-transition-old(root) { animation-name: pf-vt-fade-out; }
::view-transition-new(root) { animation-name: pf-vt-fade-in; }
@keyframes pf-vt-fade-out { to { opacity: .78; } }
@keyframes pf-vt-fade-in { from { opacity: .92; } }

/* motion-reduction respect */
@media (prefers-reduced-motion: reduce) {
  .pf-bar, .pf-btn, .pf-card, .pf-chip, .pf-menu, .pf-command__input,
  .pf-skel::after, .sk::after, .pf-spinner, .pf-toast, .pf-toast__edge, .pf-crumbs__new,
  ::view-transition-old(root), ::view-transition-new(root) {
    transition-duration: .001ms !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
  }
  .pf-chip:hover, .pf-btn:hover, .pf-card--hover:hover { transform: none !important; }
}
