/* ── Reset / Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

/* Submit-guard fallback. Subsystems with their own button CSS
   (.av2-btn, .dgp-btn) define richer disabled / aria-busy states;
   this catches any bare <button> so the user gets a visible cue
   that the first click was accepted and they shouldn't click again. */
button:disabled,
button[disabled],
input[type="submit"]:disabled,
input[type="submit"][disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ── Impersonation banner ───────────────────────────────── */
/* Sits above .portal-nav. High-contrast warning stripe so an admin can
   never miss that they're acting as someone else. */
.impersonation-banner {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1rem;
  background: #b8860b;            /* dark goldenrod — readable in both themes */
  color: #0d1117;
  border-bottom: 2px solid #6b4f00;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.impersonation-banner-label {
  background: #0d1117;
  color: #ffd75a;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}
.impersonation-banner-target { font-weight: 700; }
.impersonation-banner-sep { opacity: 0.6; }
.impersonation-banner-real strong { font-weight: 700; }
.impersonation-banner-hint {
  margin-left: auto;
  opacity: 0.85;
  font-style: italic;
  font-size: 0.8rem;
}

/* ── Login Page ─────────────────────────────────────────── */
.login-body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  background:
    radial-gradient(circle, rgba(212, 175, 55, 0.07) 1px, transparent 1.5px) 0 0 / 32px 32px,
    var(--color-bg-page);
}

[data-theme="light"] .login-body {
  background:
    radial-gradient(circle, rgba(184, 134, 11, 0.10) 1px, transparent 1.5px) 0 0 / 32px 32px,
    linear-gradient(180deg, #f7f3ea 0%, #efece4 100%);
}

/* Paper-grain overlay — adds editorial texture without color. */
.login-body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.04;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

[data-theme="dark"] .login-body::before {
  opacity: 0.07;
  mix-blend-mode: overlay;
}

.login-bg-glow {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 70% 60% at 50% 45%,
              var(--color-accent-glow) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

[data-theme="light"] .login-bg-glow {
  background: radial-gradient(ellipse 45% 45% at 50% 50%,
              rgba(184, 134, 11, 0.12) 0%,
              rgba(184, 134, 11, 0.04) 40%,
              transparent 75%);
}

.login-theme-toggle {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 20;
}

.login-wrapper {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  width: 100%;
  padding: 1rem;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 460px;
  padding: 2.5rem 2.25rem 2.1rem;
  background: var(--color-bg-elevated);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow:
    0 8px 48px rgba(0, 0, 0, 0.55),
    0 0 0 1px var(--color-accent-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  text-align: center;
  animation: loginFadeIn 0.5s ease-out both;
}

[data-theme="light"] .login-card {
  background: var(--color-bg-surface);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow:
    0 20px 60px rgba(31, 41, 55, 0.12),
    0 4px 16px rgba(31, 41, 55, 0.06),
    0 0 0 1px rgba(184, 134, 11, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* Vault corner brackets — top-left + bottom-right */
.login-card::before,
.login-card::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: var(--color-accent);
  pointer-events: none;
}
.login-card::before {
  top: 10px;
  left: 10px;
  border-top: 1.5px solid;
  border-left: 1.5px solid;
}
.login-card::after {
  bottom: 10px;
  right: 10px;
  border-bottom: 1.5px solid;
  border-right: 1.5px solid;
}

/* Brand lockup: logo plate │ wordmark + kicker */
.login-lockup {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  margin-bottom: 1.85rem;
}

.login-lockup-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  background: #f5f5f5;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 2px 12px var(--color-accent-glow);
  animation: loginRiseIn 0.55s ease-out 80ms both;
}

.login-logo-img {
  display: block;
  height: 44px;
  width: auto;
}

.login-lockup-divider {
  flex: 0 0 1px;
  align-self: stretch;
  min-height: 56px;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    var(--color-accent-dim) 25%,
    var(--color-accent-dim) 75%,
    transparent 100%
  );
  opacity: 0.7;
}

.login-lockup-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  text-align: left;
}

.login-wordmark {
  font-family: 'Fraunces', 'Times New Roman', Georgia, serif;
  font-optical-sizing: auto;
  font-weight: 700;
  font-size: 1.7rem;
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin: 0;
  animation: loginRiseIn 0.55s ease-out 160ms both;
}

[data-theme="light"] .login-wordmark {
  /* Deeper bronze keeps AA contrast on cream background. */
  color: #8a6508;
}

.login-kicker {
  font-family: var(--font-num);
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 0;
  animation: loginRiseIn 0.55s ease-out 220ms both;
}

@media (max-width: 480px) {
  .login-lockup {
    flex-direction: column;
    gap: 0.85rem;
  }
  .login-lockup-divider {
    min-height: 1px;
    width: 56px;
    align-self: center;
    background: linear-gradient(
      to right,
      transparent 0%,
      var(--color-accent-dim) 25%,
      var(--color-accent-dim) 75%,
      transparent 100%
    );
  }
  .login-lockup-text {
    align-items: center;
    text-align: center;
  }
}

@keyframes loginFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes loginRiseIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .login-card,
  .login-lockup-logo,
  .login-wordmark,
  .login-kicker,
  .btn-google-signin,
  .login-restriction {
    animation: none;
  }
}

/* Error message */
.login-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  color: #fca5a5;
  font-size: 0.85rem;
  text-align: left;
}

[data-theme="light"] .login-error {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(220, 38, 38, 0.3);
  color: #b91c1c;
}

/* Google Sign-In button — follows Google brand guidelines */
.btn-google-signin {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 0.78rem 1.25rem;
  background: #ffffff;
  color: #3c4043;
  font-family: 'Google Sans', 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  transition: box-shadow 0.2s ease, transform 0.1s ease;
  letter-spacing: 0.01em;
  animation: loginRiseIn 0.55s ease-out 320ms both;
}

.btn-google-signin:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  transform: translateY(-1px);
}

.btn-google-signin:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.btn-google-signin:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

[data-theme="light"] .btn-google-signin {
  box-shadow: 0 2px 8px rgba(31, 41, 55, 0.10);
}

[data-theme="light"] .btn-google-signin:hover {
  box-shadow: 0 4px 16px rgba(31, 41, 55, 0.15);
}

[data-theme="light"] .btn-google-signin:active {
  box-shadow: 0 1px 4px rgba(31, 41, 55, 0.10);
}

.login-restriction {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 1.1rem;
  font-size: 0.74rem;
  color: var(--color-text-muted);
  animation: loginRiseIn 0.55s ease-out 380ms both;
}

.login-footer {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  opacity: 0.5;
}

/* ── Portal / Dashboard Layout ──────────────────────────── */
.portal-body {
  background: var(--bg-base);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Top navigation */
.portal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem 0 1rem;
  height: 64px;
  background: var(--color-bg-surface);
  border-bottom: 1px solid var(--color-border);
  z-index: 200;
  flex-shrink: 0;
}

.portal-nav-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Hamburger toggle (mobile) */
.sidebar-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}
.sidebar-toggle-btn:hover {
  background: var(--color-interactive-hover);
  color: var(--color-accent);
}

.portal-nav-brand {
  display: flex;
  align-items: center;
  border-radius: 6px;
  padding: 3px 10px;
  text-decoration: none;
  transition: background 0.2s ease, opacity 0.15s;
}
.portal-nav-brand:hover { opacity: 0.85; }

.nav-logo {
  height: 36px;
  width: auto;
  display: block;
}

[data-theme="dark"] .portal-nav-brand {
  background: rgba(255, 255, 255, 0.92);
}

.portal-nav-user {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.user-avatar-img {
  object-fit: cover;
  background: transparent;
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.user-name  { font-weight: 600; font-size: 0.88rem; line-height: 1.2; }
.user-email { font-size: 0.74rem; color: var(--text-muted); line-height: 1.2; }

.btn-logout {
  padding: 0.38rem 1rem;
  font-size: 0.82rem;
  font-family: var(--font);
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold-border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease;
  white-space: nowrap;
}

.btn-logout:hover { background: var(--gold-glow); }

/* ── Body wrap: sidebar + page ───────────────────────────── */
.portal-body-wrap {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* ── Global sidebar ──────────────────────────────────────── */

/* Fixed overlay — takes zero flex space; 8px hover strip triggers the fly-out */
.portal-sidebar {
  position: fixed;
  top: 64px;
  left: 0;
  bottom: 0;
  width: 8px;
  overflow: visible;
  z-index: 150;
}

/* Discoverability ribbon — hints at the hidden menu on the collapsed strip */
.portal-sidebar::before {
  content: "MENU";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%) rotate(180deg);
  writing-mode: vertical-rl;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--color-accent);
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 101;
}

.portal-sidebar:hover::before,
[data-sidebar="pinned"] .portal-sidebar::before { opacity: 0; }

/* In light mode the goldenrod ribbon reads stronger against the pale page
   than against the dark page. Tone it down so it stays a hint, not a label. */
[data-theme="light"] .portal-sidebar::before { opacity: 0.22; }

/* Page area */
.portal-page {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
  transition: margin-left 0.22s ease;
}

[data-sidebar="pinned"] .portal-page {
  margin-left: 230px;
}

.portal-page.page-fill { overflow: hidden; }

/* Inner fly-out panel — hidden by default, slides in on hover or pin */
.sidebar-inner {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0;
  background: var(--color-bg-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
  /* Delayed close so mouse can reach submenu items */
  transition: width 0.2s ease 0.28s, box-shadow 0.2s ease 0.28s;
}

/* Fast open, no delay */
.portal-sidebar:hover .sidebar-inner,
.sidebar-inner:hover,
.sidebar-inner:focus-within,
[data-sidebar="pinned"] .sidebar-inner {
  width: 230px;
  transition: width 0.18s ease 0s, box-shadow 0.15s ease 0s;
}

.sidebar-inner:hover,
.sidebar-inner:focus-within {
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.22);
}

[data-sidebar="pinned"] .sidebar-inner { box-shadow: none; }

/* ── Pin button ───────────────────────────────────────────── */
.sidebar-pin-area {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0.28rem 0.4rem;
  min-height: 32px;
  border-bottom: 1px solid var(--color-divider);
  flex-shrink: 0;
}

.sidebar-pin-btn {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, background 0.15s ease, color 0.15s ease;
}

.portal-sidebar:hover .sidebar-pin-btn,
.sidebar-inner:hover .sidebar-pin-btn,
.sidebar-inner:focus-within .sidebar-pin-btn,
[data-sidebar="pinned"] .sidebar-inner .sidebar-pin-btn {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-pin-btn:hover { background: var(--color-interactive-hover); color: var(--color-accent); }
[data-sidebar="pinned"] .sidebar-pin-btn { color: var(--color-accent); }

.pin-icon-pin   { display: flex; }
.pin-icon-unpin { display: none; }
[data-sidebar="pinned"] .pin-icon-pin   { display: none; }
[data-sidebar="pinned"] .pin-icon-unpin { display: flex; }

/* ── Sidebar nav ─────────────────────────────────────────── */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.3rem 0;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.48rem 0.75rem;
  padding-left: calc(0.75rem + var(--depth, 0) * 0.65rem);
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 0.76rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.15s, color 0.15s;
  border-left: 2px solid transparent;
}

.sidebar-nav-item:hover { background: var(--color-interactive-hover); color: var(--color-text-primary); }

.sidebar-nav-item.active {
  background: var(--color-interactive-hover);
  color: var(--color-accent);
  border-left-color: var(--color-accent);
  font-weight: 600;
}

/* Nested leaf items (depth > 0). Indentation is driven by the --depth
   custom property set inline by the recursive _MenuItem partial, so any
   nesting level renders correctly. */
.sidebar-nav-item--nested { font-size: 0.68rem; }

/* Group header */
.sidebar-group-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.42rem 0.75rem;
  padding-left: calc(0.75rem + var(--depth, 0) * 0.65rem);
  background: transparent;
  border: none;
  border-left: 2px solid transparent;
  color: var(--color-text-muted);
  font-family: var(--font);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.15s, color 0.15s;
}

.sidebar-group-btn:hover { background: var(--color-interactive-hover); color: var(--color-text-primary); }
.sidebar-group.open > .sidebar-group-btn { color: var(--color-accent); }

.sidebar-group-items { display: none; }
.sidebar-group.open > .sidebar-group-items { display: block; }

/* Nested group headers (depth > 0). Padding-left comes from the
   --depth driven calc on .sidebar-group-btn; only the visual style
   (case/weight/color) differs from the root group header. */
.sidebar-group-btn--sub {
  font-size: 0.68rem;
  text-transform: none;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--color-text-secondary);
}

/* Icons */
.sidebar-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.sidebar-nav-item:hover .sidebar-icon,
.sidebar-nav-item.active .sidebar-icon,
.sidebar-group-btn:hover .sidebar-icon,
.sidebar-group.open > .sidebar-group-btn .sidebar-icon { opacity: 1; }

/* Labels — invisible in rail, fade in when expanded */
.sidebar-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  opacity: 0;
  transition: opacity 0.1s ease;
}

.portal-sidebar:hover .sidebar-label,
.sidebar-inner:hover .sidebar-label,
.sidebar-inner:focus-within .sidebar-label,
[data-sidebar="pinned"] .sidebar-inner .sidebar-label { opacity: 1; }

/* Chevron — invisible in rail */
.sidebar-chevron {
  margin-left: auto;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.1s ease;
}

.portal-sidebar:hover .sidebar-chevron,
.sidebar-inner:hover .sidebar-chevron,
.sidebar-inner:focus-within .sidebar-chevron,
[data-sidebar="pinned"] .sidebar-inner .sidebar-chevron { opacity: 1; }

.sidebar-group.open > .sidebar-group-btn .sidebar-chevron { transform: rotate(180deg); }

/* Main content */
.portal-main {
  padding: 2rem;
  padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  overflow-y: auto;
}

.portal-container {
  max-width: 1200px;
  margin: 0 auto;
}

.welcome-section {
  margin-bottom: 2rem;
}

.welcome-heading {
  font-size: 1.9rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  letter-spacing: -0.01em;
}

.welcome-sub {
  font-size: 0.88rem;
  color: var(--gold-dim);
}

.welcome-lastlogin {
  color: var(--text-muted);
}

/* Metric cards */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.metric-card {
  padding: 1.6rem 1.5rem;
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--gold-border);
  border-radius: 12px;
  text-align: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
  border-color: rgba(212, 175, 55, 0.4);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.metric-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 0.35rem;
}

.metric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Under construction notice */
.placeholder-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1.75rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  border: 1px dashed rgba(212, 175, 55, 0.15);
  border-radius: 12px;
}

/* ── Homepage: My Work + Dashboard Launcher ─────────────── */
.home-section {
  margin-bottom: 2.25rem;
}

.home-section-heading {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--color-accent);
  margin-bottom: 0.85rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--color-border);
}

.home-empty {
  padding: 1.25rem 1rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-divider);
  border-radius: 10px;
}

/* My Work — action inbox list */
.home-task-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.home-task {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  color: var(--color-text-primary);
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.home-task:hover {
  border-color: var(--color-accent-dim);
  background: var(--color-interactive-hover);
  transform: translateX(2px);
}

.home-task-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--color-accent-glow);
  color: var(--color-accent);
}

.home-task-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.home-task-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--color-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-task-meta {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.home-task-chev {
  flex-shrink: 0;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--color-text-muted);
  transition: color 0.15s ease, transform 0.15s ease;
}

.home-task:hover .home-task-chev {
  color: var(--color-accent);
  transform: translateX(3px);
}

.home-task-more {
  list-style: none;
  text-align: right;
  padding: 0.25rem 0.25rem 0;
  font-size: 0.85rem;
}

.home-task-more a {
  color: var(--color-accent);
  text-decoration: none;
}

.home-task-more a:hover {
  text-decoration: underline;
}

/* Source tag + priority pill inside .home-task — lets My Work disambiguate
   items from multiple subsystems (Appraisal vs PIP, etc.) and flag overdue
   work. Uses --ap-* tokens for dual-theme consistency with the rest of the
   portal. */
.home-task-source-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.08rem 0.42rem;
  margin-right: 0.5rem;
  border-radius: 4px;
  background: color-mix(in srgb, var(--color-accent) 16%, transparent);
  color: var(--color-accent);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  vertical-align: middle;
}
.home-task-source-tag.is-pip {
  background: color-mix(in srgb, #b45309 16%, transparent);
  color: #b45309;
}
[data-theme="dark"] .home-task-source-tag.is-pip {
  background: color-mix(in srgb, #f59e0b 18%, transparent);
  color: #f59e0b;
}
.home-task-source-tag.is-app-v2 {
  background: color-mix(in srgb, #0891b2 16%, transparent);
  color: #0891b2;
}
[data-theme="dark"] .home-task-source-tag.is-app-v2 {
  background: color-mix(in srgb, #22d3ee 18%, transparent);
  color: #22d3ee;
}
.home-task-priority {
  display: inline-flex;
  align-items: center;
  padding: 0.08rem 0.42rem;
  margin-left: 0.5rem;
  border-radius: 4px;
  background: color-mix(in srgb, var(--ap-danger, #dc2626) 18%, transparent);
  color: var(--ap-danger, #dc2626);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  vertical-align: middle;
}

/* Dashboard launcher grid */
.home-launcher-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.home-launcher-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 1.25rem 1.1rem;
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  color: var(--color-text-primary);
  text-decoration: none;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

[data-theme="light"] .home-launcher-tile {
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.home-launcher-tile:hover {
  border-color: var(--color-accent);
  background: var(--color-interactive-hover);
  transform: translateY(-2px);
  box-shadow: var(--color-shadow-md);
}

.home-launcher-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: var(--color-accent-glow);
  color: var(--color-accent);
}

[data-theme="light"] .home-launcher-icon {
  background: rgba(184, 134, 11, 0.14);
}

.home-launcher-icon svg {
  width: 20px;
  height: 20px;
}

.home-launcher-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Footer */
.portal-footer {
  padding: 1rem 2rem;
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  opacity: 0.4;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

/* ── Responsive ─────────────────────────────────────────── */
/* Also fires on any touch device (iPad, tablets) regardless of viewport
   width, since those have no :hover to trigger the edge fly-out. */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
  .sidebar-toggle-btn { display: flex; }

  /* On mobile: sidebar is fixed overlay, hidden by default */
  .portal-sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    width: 0 !important;
    min-width: 0 !important;
    z-index: 150;
    overflow: visible;
  }

  /* Hamburger is the mobile affordance — hide the edge ribbon */
  .portal-sidebar::before { display: none; }

  .sidebar-inner {
    width: 0;
    transition: width 0.22s ease 0s, box-shadow 0.2s ease 0s;
    box-shadow: none;
  }

  .portal-sidebar.mobile-open .sidebar-inner {
    width: 190px;
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
  }

  /* Always show labels on mobile */
  .portal-sidebar.mobile-open .sidebar-label { opacity: 1; }
  .portal-sidebar.mobile-open .sidebar-chevron { opacity: 1; }

  /* Overlay behind mobile sidebar */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 64px 0 0 0;
    background: rgba(0,0,0,0.45);
    z-index: 140;
  }
  .sidebar-overlay.visible { display: block; }

  /* Override desktop pinned-state on touch devices — the hamburger is the
     only affordance here, so a leftover pinned flag from desktop must not
     force the panel open or shift the page. */
  [data-sidebar="pinned"] .sidebar-inner { width: 0; }
  [data-sidebar="pinned"] .portal-page   { margin-left: 0; }
}

@media (max-width: 600px) {
  .portal-nav { padding: 0 1rem; }
  .user-info   { display: none; }
  .portal-main { padding: 1.25rem; }
  .welcome-heading { font-size: 1.4rem; }
  .nav-logo    { height: 26px; }
}

/* ── FinDash ──────────────────────────────────────────────────────────────── */

/* Layout shell */
.findash-shell {
  display: flex;
  height: 100%;
  overflow: hidden;
}

/* Sidebar */
.findash-sidebar {
  width: 224px;
  min-width: 224px;
  overflow-y: auto;
  background: var(--bg-surface);
  border-right: 1px solid var(--gold-border);
  padding: 0.85rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

/* Main content area */
.findash-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  min-width: 0;
}

/* Sidebar pieces */
.fd-filter-block { display: flex; flex-direction: column; gap: 0.3rem; }

.fd-section-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-dim);
}
.fd-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.fd-clear-btn {
  font-size: 0.65rem;
  color: var(--color-text-dim);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.fd-clear-btn:hover { color: var(--gold, #d4af37); }

.fd-year-group, .fd-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.fd-month-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
}

.fd-btn {
  padding: 3px 7px;
  font-size: 0.7rem;
  font-family: var(--font);
  background: transparent;
  color: var(--text-muted);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.fd-btn:hover  { border-color: var(--gold-border); color: var(--text-primary); }
.fd-btn.active { background: var(--gold); color: var(--bg-base); border-color: var(--gold); font-weight: 600; }

.fd-check-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
}

.fd-scrollable-list {
  max-height: 140px;
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 5px;
  padding: 0.3rem;
}

.fd-search {
  width: 100%;
  padding: 4px 8px;
  font-size: 0.72rem;
  font-family: var(--font);
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
  border: 1px solid var(--gold-border);
  border-radius: 4px;
  outline: none;
}
.fd-search::placeholder { color: var(--text-muted); }

.fd-check-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--text-primary);
  padding: 3px 4px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  min-height: 20px;
  flex-shrink: 0;
}
.fd-check-item > span {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.fd-check-item:hover { background: var(--gold-glow); }
.fd-check-item input { accent-color: var(--gold); flex-shrink: 0; }

/* Loading bar */
.fd-loading-bar {
  display: none;
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--gold) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: fd-shimmer 1s linear infinite;
  z-index: 50;
  margin: -1rem -1.25rem 0.5rem;
}
@keyframes fd-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* KPI row */
.fd-kpi-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.fd-kpi-card {
  background: var(--fd-card-bg);
  border: 1px solid var(--fd-card-border);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  min-width: 0;
  text-align: center;
  color: var(--fd-card-text);
}

.fd-kpi-label {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fd-card-text);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fd-kpi-value {
  font-family: var(--font-num);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--fd-card-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.15rem;
}

.fd-kpi-py {
  font-family: var(--font-num);
  font-size: 0.68rem;
  color: var(--fd-card-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-wrap: wrap;
}

/* Page-level header bar (rounded solid-color banner). Sits above the first
   section title and holds the page title + "Last Data Update" timestamp.
   Solid brand-green background with white text — matches the design sample. */
.fd-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  background: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 0.55rem 0.85rem;
  margin-bottom: 0.85rem;
  box-shadow: 0 6px 18px var(--gold-glow);
}
.fd-header-title {
  text-align: center;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.fd-last-update {
  font-size: 0.72rem;
  font-style: italic;
  color: rgba(255, 255, 255, 0.82);
  white-space: nowrap;
  text-align: right;
}
@media (max-width: 1200px) {
  .fd-header        { grid-template-columns: 1fr; }
  .fd-header-spacer { display: none; }
  .fd-last-update   { text-align: center; }
}

/* Section title */
.fd-section-title {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  text-align: center;
  border-bottom: 1px solid var(--gold-border);
  padding-bottom: 0.5rem;
  margin: 1.4rem 0 0.8rem;
  text-shadow: 0 0 24px var(--gold-glow);
}

.findash-content > .fd-section-title:first-of-type {
  margin-top: 0.2rem;
}

/* Table grids */
.fd-table-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  margin-bottom: 0.65rem;
}

.fd-launch-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 0.65rem;
}

/* Table panels */
.fd-table-panel {
  background: var(--bg-card);
  border: 1px solid var(--gold-border);
  border-radius: 9px;
  overflow: hidden;
  min-width: 0;
}

.fd-table-header {
  padding: 0.4rem 0.6rem;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  background: var(--gold-glow);
  border-bottom: 1px solid var(--gold-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  white-space: nowrap;
}

.fd-toggle-group { display: flex; gap: 3px; flex-shrink: 0; }

.fd-toggle-btn {
  padding: 2px 7px;
  font-size: 0.62rem;
  font-family: var(--font);
  font-weight: 600;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
}
.fd-toggle-btn.active { background: var(--gold); color: var(--bg-base); border-color: var(--gold); }

/* Data table */
.fd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.67rem;
}

.fd-table th {
  padding: 3px 5px;
  text-align: right;
  font-weight: 600;
  font-size: 0.58rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--gold-glow);
  border-bottom: 1px solid var(--gold-border);
}
.fd-table th:first-child,
.fd-table th:nth-child(2) { text-align: left; }

.fd-table td {
  padding: 3px 5px;
  text-align: right;
  border-bottom: 1px solid rgba(255,255,255,0.025);
  color: var(--text-primary);
}
.fd-table td:first-child  { text-align: center; color: var(--text-muted); width: 20px; font-size: 0.6rem; }
.fd-table td:nth-child(2) { text-align: left; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fd-table td:nth-child(3),
.fd-table td:nth-child(4),
.fd-table td:nth-child(5),
.fd-table td:nth-child(6) { font-family: var(--font-num); font-size: 0.62rem; }
.fd-table tr:last-child td { border-bottom: none; }
.fd-table tr:hover td { background: rgba(255,255,255,0.02); }

.fd-launch-date { font-size: 0.66rem; color: var(--text-muted); }
.fd-empty-cell  { text-align: center !important; color: var(--text-muted); padding: 0.75rem !important; font-size: 0.72rem; }

/* Change badges — plain-text style mirroring vCIS (.vcis-badge-*).
   With KPI/Owner cards now solid blue, bright #22c55e / #ef4444 read at high
   contrast on the navy surface. On the neutral table-panel surface they remain
   legible too. */
.badge-up      { font-family: var(--font-num); color: #22c55e; font-size: 0.62rem; font-weight: 700; white-space: nowrap; }
.badge-down    { font-family: var(--font-num); color: #ef4444; font-size: 0.62rem; font-weight: 700; white-space: nowrap; }
.badge-neutral { font-family: var(--font-num); color: var(--text-muted); font-size: 0.62rem; }

/* Owner KPI row */
.fd-owner-grid {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}

.fd-owner-card {
  flex: 1;
  min-width: 130px;
  background: var(--fd-card-bg);
  border: 1px solid var(--fd-card-border);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  text-align: center;
  color: var(--fd-card-text);
}
.fd-owner-name {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fd-card-text);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fd-owner-value {
  font-family: var(--font-num);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--fd-card-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.15rem;
}
.fd-owner-py {
  font-family: var(--font-num);
  font-size: 0.68rem;
  color: var(--fd-card-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-wrap: wrap;
}

/* Chart panels */
.fd-chart-full {
  background: var(--bg-card);
  border: 1px solid var(--gold-border);
  border-radius: 9px;
  padding: 0.7rem 0.85rem;
  margin-bottom: 0.65rem;
}

.fd-chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 0.65rem;
}

.fd-chart-panel {
  background: var(--bg-card);
  border: 1px solid var(--gold-border);
  border-radius: 9px;
  padding: 0.7rem 0.85rem;
  min-width: 0;
  overflow: hidden;
}

.fd-chart-title {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}

/* Responsive tweaks */
@media (max-width: 1400px) {
  .fd-kpi-row { grid-template-columns: repeat(3, 1fr); }
  .fd-owner-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 1200px) {
  .fd-table-grid  { grid-template-columns: 1fr; }
  .fd-launch-grid { grid-template-columns: 1fr; }
  .fd-chart-grid  { grid-template-columns: 1fr; }
}

/* Mid-page banner: same .fd-header banner styling, but separated from the
   section above. Used for "Yearly Performance Dashboard" between the launch
   tables and the owner KPI grid. */
.fd-header--mid { margin-top: 1.4rem; }

/* ── FinDash + SalesDash blue theme overrides ────────────────────────────────
   Scoped via body.findash-body so Homepage / DGPulse / Admin keep their
   existing gold tokens. We override `--gold*` rather than renaming everything
   — every .fd-* rule already reads var(--gold*), so the cascade does the work.
   Blue values mirror SalesDash_vCIS so the three dashboards feel related:
     • Light mode brand = #0f3a8a (deep navy, same as vCIS cards)
     • Dark mode brand  = #3b82f6 (vivid blue, same as vCIS dark accent) */
body.findash-body {
  --gold:        #3b82f6;
  --gold-dim:    rgba(59, 130, 246, 0.65);
  --gold-glow:   rgba(59, 130, 246, 0.18);
  --gold-border: rgba(59, 130, 246, 0.28);
  /* Solid-blue KPI/Owner cards — values mirror vCIS exactly so the dashboards
     read as one family. White text on blue, plain-text badges (see below). */
  --fd-card-bg:         #1e40af;
  --fd-card-border:     rgba(59, 130, 246, 0.45);
  --fd-card-text:       #ffffff;
  --fd-card-text-muted: rgba(255, 255, 255, 0.72);
}
[data-theme="light"] body.findash-body {
  --gold:        #0f3a8a;
  --gold-dim:    rgba(15, 58, 138, 0.70);
  --gold-glow:   rgba(15, 58, 138, 0.10);
  --gold-border: rgba(15, 58, 138, 0.30);
  --bg-card:     #ffffff;
  --fd-card-bg:         #0f3a8a;
  --fd-card-border:     #1546aa;
  --fd-card-text:       #ffffff;
  --fd-card-text-muted: rgba(255, 255, 255, 0.72);
}

/* ── SalesDash additions ──────────────────────────────────────────────────── */

/* Sub-label under KPI value (used for date/year context on DAU cards) */
.fd-kpi-sub {
  font-family: var(--font-num);
  font-size: 0.66rem;
  color: var(--text-muted);
  margin-bottom: 0.1rem;
}

/* ══ SalesDash polish pass ═══════════════════════════════════════════════════
   Layered blue scale + hero/chip KPI cards + variance pills + lean header.
   Scoped to body.findash-body so other dashboards are untouched. */

body.findash-body {
  --sd-blue-980: #0a1530;
  --sd-blue-900: #0f1e3e;
  --sd-blue-800: #1a3066;
  --sd-blue-700: #1e40af;
  --sd-blue-600: #2563eb;
  --sd-blue-500: #3b82f6;
  --sd-blue-400: #60a5fa;
  --sd-blue-300: #93c5fd;

  --sd-chip-bg:     #0f1e3e;
  --sd-chip-border: rgba(59, 130, 246, 0.22);
  --sd-chip-label:  rgba(147, 197, 253, 0.85);
  --sd-chip-value:  #e0ecff;
  --sd-chip-muted:  rgba(186, 206, 244, 0.62);

  --sd-hero-bg:     linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
  --sd-hero-border: rgba(96, 165, 250, 0.5);
  --sd-hero-glow:   0 10px 32px rgba(37, 99, 235, 0.32);

  --sd-positive:    #4ade80;
  --sd-positive-bg: rgba(34, 197, 94, 0.14);
  --sd-negative:    #fca5a5;
  --sd-negative-bg: rgba(239, 68, 68, 0.14);
}

[data-theme="light"] body.findash-body {
  --sd-chip-bg:     #eff6ff;
  --sd-chip-border: #bfdbfe;
  --sd-chip-label:  #1d4ed8;
  --sd-chip-value:  #0f1e3e;
  --sd-chip-muted:  #475569;

  --sd-hero-bg:     linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
  --sd-hero-border: #1e40af;
  --sd-hero-glow:   0 10px 30px rgba(15, 58, 138, 0.22);

  --sd-positive:    #15803d;
  --sd-positive-bg: rgba(34, 197, 94, 0.16);
  --sd-negative:    #b91c1c;
  --sd-negative-bg: rgba(239, 68, 68, 0.12);
}

/* ── Lean command-bar header (replaces solid blue slab) ───────────────────── */
body.findash-body .fd-header {
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
  padding: 0.4rem 0 0.7rem;
  margin-bottom: 0.85rem;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  position: relative;
}
body.findash-body .fd-header::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: linear-gradient(90deg,
    var(--sd-blue-500) 0%,
    var(--sd-blue-500) 14%,
    rgba(59,130,246,0.25) 30%,
    transparent 70%);
}
body.findash-body .fd-header-spacer { display: none; }
body.findash-body .fd-header-title {
  text-align: left;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.34em;
  color: var(--color-text-primary);
  text-shadow: none;
}
body.findash-body .fd-last-update {
  font-style: normal;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
body.findash-body .fd-header--mid {
  margin-top: 1.6rem;
}

/* Freshness chip with pulsing live dot */
.fd-freshness-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.10);
  border: 1px solid rgba(59, 130, 246, 0.24);
  font-family: 'Geist Mono', 'Roboto Mono', ui-monospace, monospace;
  font-size: 0.68rem;
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.fd-freshness-chip::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--sd-blue-500);
  box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.6);
  animation: fd-pulse 2.2s ease-out infinite;
  flex-shrink: 0;
}
@keyframes fd-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(59,130,246,0.6); }
  70%  { box-shadow: 0 0 0 9px rgba(59,130,246,0); }
  100% { box-shadow: 0 0 0 0 rgba(59,130,246,0); }
}

/* ── KPI row: 1 hero + 6 chips (4-col, 2-row, hero spans rows) ─────────────── */
.fd-kpi-row--lead {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}

.fd-kpi-hero {
  grid-row: span 2;
  background: var(--sd-hero-bg);
  border: 1px solid var(--sd-hero-border);
  border-radius: 14px;
  padding: 1.1rem 1.35rem;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.6rem;
  box-shadow: var(--sd-hero-glow);
  position: relative;
  overflow: hidden;
  min-height: 168px;
}
.fd-kpi-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 88% -10%, rgba(255,255,255,0.22), transparent 55%);
  pointer-events: none;
}
.fd-kpi-hero::after {
  content: '';
  position: absolute;
  right: -40px; bottom: -40px;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(147,197,253,0.18), transparent 70%);
  pointer-events: none;
}
.fd-hero-label {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: rgba(219, 234, 254, 0.92);
  position: relative;
}
.fd-hero-value {
  font-family: 'Geist Mono', 'Roboto Mono', ui-monospace, monospace;
  font-size: 2.15rem;
  font-weight: 600;
  line-height: 1.0;
  letter-spacing: -0.015em;
  color: #ffffff;
  position: relative;
  font-variant-numeric: tabular-nums;
}
.fd-hero-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  position: relative;
  font-family: 'Geist Mono', 'Roboto Mono', ui-monospace, monospace;
  font-size: 0.72rem;
  color: rgba(219, 234, 254, 0.88);
  font-variant-numeric: tabular-nums;
  flex-wrap: wrap;
}
.fd-hero-py-label { color: rgba(219, 234, 254, 0.65); margin-right: 4px; }
.fd-hero-period {
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(219, 234, 254, 0.7);
  position: relative;
}

/* Chip card — secondary metrics + DAU row */
.fd-kpi-chip {
  background: var(--sd-chip-bg);
  border: 1px solid var(--sd-chip-border);
  border-radius: 10px;
  padding: 0.6rem 0.78rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  color: var(--sd-chip-value);
  justify-content: center;
}
.fd-kpi-chip .fd-kpi-label,
.fd-kpi-chip-label {
  font-size: 0.56rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--sd-chip-label);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fd-kpi-chip .fd-kpi-value,
.fd-kpi-chip-value {
  font-family: 'Geist Mono', 'Roboto Mono', ui-monospace, monospace;
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--sd-chip-value);
  margin: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fd-kpi-chip .fd-kpi-py,
.fd-kpi-chip-py {
  font-family: 'Geist Mono', 'Roboto Mono', ui-monospace, monospace;
  font-size: 0.6rem;
  color: var(--sd-chip-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: nowrap;
  margin: 0;
}

/* Freshness chip variant lives in the KPI grid, no metric value */
.fd-kpi-freshness {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
}
.fd-kpi-freshness .fd-kpi-chip-label {
  color: var(--sd-chip-label);
}
.fd-kpi-freshness .fd-freshness-line {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: 'Geist Mono', 'Roboto Mono', ui-monospace, monospace;
  font-size: 0.78rem;
  color: var(--sd-chip-value);
  font-variant-numeric: tabular-nums;
}
.fd-kpi-freshness .fd-freshness-line::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--sd-blue-400);
  box-shadow: 0 0 0 0 rgba(96, 165, 250, 0.6);
  animation: fd-pulse 2.2s ease-out infinite;
}
.fd-kpi-freshness .fd-freshness-sub {
  font-family: 'Geist Mono', 'Roboto Mono', ui-monospace, monospace;
  font-size: 0.6rem;
  color: var(--sd-chip-muted);
}

/* Variance pill — replaces tiny coloured microcopy */
.fd-variance {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  font-family: 'Geist Mono', 'Roboto Mono', ui-monospace, monospace;
  font-size: 0.62rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.fd-variance--up   { background: var(--sd-positive-bg); color: var(--sd-positive); }
.fd-variance--down { background: var(--sd-negative-bg); color: var(--sd-negative); }
.fd-variance--flat { background: rgba(148, 163, 184, 0.14); color: rgba(148, 163, 184, 0.95); }
.fd-variance--hero {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  padding: 3px 10px;
  font-size: 0.72rem;
  backdrop-filter: blur(4px);
}
.fd-variance--hero.is-down { background: rgba(254, 202, 202, 0.22); color: #fee2e2; }
.fd-variance--hero.is-up   { background: rgba(187, 247, 208, 0.24); color: #f0fdf4; }

/* DAU row + non-lead KPI rows: reskin .fd-kpi-card to chip style.
   (Excludes .fd-kpi-row--solid which is used by FinDash for the hero-blue treatment.) */
body.findash-body .findash-content > .fd-kpi-row:not(.fd-kpi-row--lead):not(.fd-kpi-row--solid) .fd-kpi-card {
  background: var(--sd-chip-bg);
  border: 1px solid var(--sd-chip-border);
  border-radius: 10px;
  color: var(--sd-chip-value);
  text-align: left;
}
body.findash-body .findash-content > .fd-kpi-row:not(.fd-kpi-row--lead):not(.fd-kpi-row--solid) .fd-kpi-card .fd-kpi-label {
  color: var(--sd-chip-label);
  font-size: 0.56rem;
  letter-spacing: 0.16em;
}
body.findash-body .findash-content > .fd-kpi-row:not(.fd-kpi-row--lead):not(.fd-kpi-row--solid) .fd-kpi-card .fd-kpi-value {
  color: var(--sd-chip-value);
  font-family: 'Geist Mono', 'Roboto Mono', ui-monospace, monospace;
}
body.findash-body .findash-content > .fd-kpi-row:not(.fd-kpi-row--lead):not(.fd-kpi-row--solid) .fd-kpi-card .fd-kpi-py {
  color: var(--sd-chip-muted);
  justify-content: flex-start;
  font-family: 'Geist Mono', 'Roboto Mono', ui-monospace, monospace;
}
body.findash-body .findash-content > .fd-kpi-row:not(.fd-kpi-row--lead):not(.fd-kpi-row--solid) .fd-kpi-card .fd-kpi-sub {
  color: var(--sd-chip-muted);
}

/* ── FinDash hero-blue KPI row (all 6 cards get the hero treatment) ────────── */
.fd-kpi-row--solid .fd-kpi-card {
  background: var(--sd-hero-bg);
  border: 1px solid var(--sd-hero-border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  color: #ffffff;
  text-align: left;
  position: relative;
  overflow: hidden;
  box-shadow: var(--sd-hero-glow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.35rem;
  min-height: 110px;
}
.fd-kpi-row--solid .fd-kpi-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 88% -20%, rgba(255,255,255,0.18), transparent 60%);
  pointer-events: none;
}
.fd-kpi-row--solid .fd-kpi-card > * { position: relative; }
.fd-kpi-row--solid .fd-kpi-card .fd-kpi-label {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(219, 234, 254, 0.88);
  margin: 0;
}
.fd-kpi-row--solid .fd-kpi-card .fd-kpi-value {
  font-family: 'Geist Mono', 'Roboto Mono', ui-monospace, monospace;
  font-size: 1.4rem;
  font-weight: 600;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fd-kpi-row--solid .fd-kpi-card .fd-kpi-py {
  font-family: 'Geist Mono', 'Roboto Mono', ui-monospace, monospace;
  font-size: 0.62rem;
  color: rgba(219, 234, 254, 0.78);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
}
/* Hero-card variance pill — frosted-glass on the blue gradient */
.fd-kpi-row--solid .fd-kpi-card .badge-up,
.fd-kpi-row--solid .fd-kpi-card .badge-down,
.fd-kpi-row--solid .fd-kpi-card .badge-neutral,
.fd-kpi-row--solid .fd-kpi-card .fd-variance {
  padding: 3px 9px;
  font-size: 0.66rem;
}
.fd-kpi-row--solid .fd-kpi-card .badge-up,
.fd-kpi-row--solid .fd-kpi-card .fd-variance--up {
  background: rgba(187, 247, 208, 0.24);
  color: #f0fdf4;
}
.fd-kpi-row--solid .fd-kpi-card .badge-down,
.fd-kpi-row--solid .fd-kpi-card .fd-variance--down {
  background: rgba(254, 202, 202, 0.22);
  color: #fee2e2;
}
.fd-kpi-row--solid .fd-kpi-card .badge-neutral,
.fd-kpi-row--solid .fd-kpi-card .fd-variance--flat {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

/* ── FinDash yearly owner cards: apply same hero-blue treatment ──────────── */
body.findash-body .fd-owner-card {
  background: var(--sd-hero-bg);
  border: 1px solid var(--sd-hero-border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  color: #ffffff;
  text-align: left;
  position: relative;
  overflow: hidden;
  box-shadow: var(--sd-hero-glow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.35rem;
  min-height: 110px;
}
body.findash-body .fd-owner-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 88% -20%, rgba(255,255,255,0.18), transparent 60%);
  pointer-events: none;
}
body.findash-body .fd-owner-card > * { position: relative; }
body.findash-body .fd-owner-name {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(219, 234, 254, 0.88);
  margin: 0;
  text-align: left;
}
body.findash-body .fd-owner-value {
  font-family: 'Geist Mono', 'Roboto Mono', ui-monospace, monospace;
  font-size: 1.4rem;
  font-weight: 600;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
  margin: 0;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.findash-body .fd-owner-py {
  font-family: 'Geist Mono', 'Roboto Mono', ui-monospace, monospace;
  font-size: 0.62rem;
  color: rgba(219, 234, 254, 0.78);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
}
/* Frosted-glass variance pills inside the hero-blue owner cards */
body.findash-body .fd-owner-card .badge-up,
body.findash-body .fd-owner-card .badge-down,
body.findash-body .fd-owner-card .badge-neutral {
  padding: 3px 9px;
  font-size: 0.66rem;
}
body.findash-body .fd-owner-card .badge-up {
  background: rgba(187, 247, 208, 0.24);
  color: #f0fdf4;
}
body.findash-body .fd-owner-card .badge-down {
  background: rgba(254, 202, 202, 0.22);
  color: #fee2e2;
}
body.findash-body .fd-owner-card .badge-neutral {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

/* ── FinDash product name (kicker above page title) ───────────────────────── */
.fd-product-name {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: 'Geist', 'Geist Sans', system-ui, -apple-system, sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--sd-blue-600);
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
  font-feature-settings: "ss01" 1, "cv11" 1;
}
.fd-product-name::before {
  content: 'F';
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: 'Geist', 'Geist Sans', system-ui, sans-serif;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
  padding-bottom: 1px;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
[data-theme="light"] body.findash-body .fd-product-name::before {
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
[data-theme="light"] body.findash-body .fd-product-name {
  color: var(--sd-blue-700);
}
[data-theme="light"] body.findash-body .fd-product-name::before {
  background: var(--sd-blue-600);
  box-shadow: 0 0 8px rgba(37, 99, 235, 0.35);
}
/* Stack product name above the title on the left half of the header */
body.findash-body .findash-content > .fd-header {
  align-items: flex-end;
}

/* ── Donut legend (replaces overlapping in-chart labels) ──────────────────── */
.fd-donut-legend {
  margin-top: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: 'Geist Mono', 'Roboto Mono', ui-monospace, monospace;
}
.fd-donut-legend-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 9px;
  padding: 4px 8px;
  border-radius: 5px;
  transition: background 0.15s;
}
.fd-donut-legend-row:hover { background: rgba(59, 130, 246, 0.06); }
.fd-donut-legend-dot {
  width: 9px; height: 9px;
  border-radius: 2px;
  flex-shrink: 0;
}
.fd-donut-legend-name {
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fd-donut-legend-value {
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.7rem;
}
.fd-donut-legend-pct {
  color: var(--color-text-secondary);
  font-size: 0.65rem;
  font-variant-numeric: tabular-nums;
  min-width: 48px;
  text-align: right;
}

/* ── Chart title bar + scale toggle ───────────────────────────────────────── */
.fd-chart-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
  gap: 0.6rem;
}
.fd-chart-titlebar .fd-chart-title { margin: 0; }
.fd-scale-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.20);
  border-radius: 999px;
}
.fd-scale-toggle button {
  padding: 3px 11px;
  font-size: 0.6rem;
  font-family: 'Geist Mono', 'Roboto Mono', ui-monospace, monospace;
  letter-spacing: 0.1em;
  background: transparent;
  color: var(--color-text-secondary);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  font-weight: 600;
}
.fd-scale-toggle button.active {
  background: var(--sd-blue-600);
  color: #ffffff;
}
.fd-scale-toggle button:hover:not(.active) {
  color: var(--color-text-primary);
}

/* ── Legacy .badge-* classes (used by FinDash) restyled as pills inside the
   findash family — keeps FinDash variance display visually consistent with
   SalesDash's .fd-variance pills without touching FinDash's JS/markup. vCIS
   is unaffected: it scopes under body.vcis-body. */
body.findash-body .badge-up,
body.findash-body .badge-down,
body.findash-body .badge-neutral {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  font-family: 'Geist Mono', 'Roboto Mono', ui-monospace, monospace;
  font-size: 0.62rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
body.findash-body .badge-up      { background: var(--sd-positive-bg); color: var(--sd-positive); }
body.findash-body .badge-down    { background: var(--sd-negative-bg); color: var(--sd-negative); }
body.findash-body .badge-neutral { background: rgba(148, 163, 184, 0.14); color: rgba(148, 163, 184, 0.95); }

/* Period chip — sits inline with the page title showing the active time window */
.fd-period-chip {
  display: inline-flex;
  align-items: center;
  margin-left: 0.85rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.10);
  border: 1px solid rgba(59, 130, 246, 0.22);
  font-family: 'Geist Mono', 'Roboto Mono', ui-monospace, monospace;
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--sd-blue-300);
  vertical-align: middle;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.fd-period-chip:empty { display: none; }
[data-theme="light"] body.findash-body .fd-period-chip {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.25);
  color: var(--sd-blue-700);
}

/* ── Light-mode fixes ─────────────────────────────────────────────────────── */
[data-theme="light"] body.findash-body .fd-section-label {
  color: var(--sd-blue-700);
}
[data-theme="light"] body.findash-body .fd-check-item {
  color: #0f1e3e;
}
/* Custom checkbox so the box is always visible regardless of theme. Browser
   default chrome renders almost-invisible thin borders on light backgrounds
   and gets clipped by the scrollbar in tight columns — fix by drawing our own. */
body.findash-body .fd-check-item input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 13px; height: 13px;
  margin: 0;
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s;
  border: 1.5px solid var(--sd-blue-500);
  background: rgba(15, 30, 62, 0.4);
}
body.findash-body .fd-check-item input[type="checkbox"]:hover {
  border-color: var(--sd-blue-400);
}
body.findash-body .fd-check-item input[type="checkbox"]:checked {
  background: var(--sd-blue-600);
  border-color: var(--sd-blue-600);
}
body.findash-body .fd-check-item input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 3px; top: 0px;
  width: 4px; height: 8px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
[data-theme="light"] body.findash-body .fd-check-item input[type="checkbox"] {
  border-color: var(--sd-blue-700);
  background: #ffffff;
}
[data-theme="light"] body.findash-body .fd-check-item input[type="checkbox"]:hover {
  border-color: var(--sd-blue-600);
}
[data-theme="light"] body.findash-body .fd-check-item:hover {
  background: rgba(37, 99, 235, 0.08);
}
[data-theme="light"] body.findash-body .fd-btn {
  border-color: rgba(15, 58, 138, 0.25);
  color: #1e3a8a;
}
[data-theme="light"] body.findash-body .fd-btn:hover {
  border-color: var(--sd-blue-600);
  color: var(--sd-blue-700);
}
[data-theme="light"] body.findash-body .fd-btn.active {
  background: var(--sd-blue-600);
  color: #ffffff;
  border-color: var(--sd-blue-600);
}
[data-theme="light"] body.findash-body .fd-clear-btn:hover { color: var(--sd-blue-600); }
[data-theme="light"] body.findash-body .fd-search {
  border-color: rgba(15, 58, 138, 0.25);
  background: #ffffff;
  color: #0f1e3e;
}
[data-theme="light"] body.findash-body .fd-scrollable-list {
  border-color: rgba(15, 58, 138, 0.15);
}
[data-theme="light"] body.findash-body .findash-sidebar {
  border-right-color: rgba(15, 58, 138, 0.18);
}

/* ── Page-load reveal animation ───────────────────────────────────────────── */
@keyframes fd-fadeup {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
body.findash-body .findash-content > .fd-header {
  animation: fd-fadeup 0.4s ease-out both;
}
body.findash-body .fd-kpi-row--lead > * {
  animation: fd-fadeup 0.45s ease-out both;
}
body.findash-body .fd-kpi-row--lead > *:nth-child(1) { animation-delay: 0.05s; }
body.findash-body .fd-kpi-row--lead > *:nth-child(2) { animation-delay: 0.11s; }
body.findash-body .fd-kpi-row--lead > *:nth-child(3) { animation-delay: 0.17s; }
body.findash-body .fd-kpi-row--lead > *:nth-child(4) { animation-delay: 0.23s; }
body.findash-body .fd-kpi-row--lead > *:nth-child(5) { animation-delay: 0.29s; }
body.findash-body .fd-kpi-row--lead > *:nth-child(6) { animation-delay: 0.35s; }
body.findash-body .fd-kpi-row--lead > *:nth-child(7) { animation-delay: 0.41s; }
body.findash-body .findash-content > .fd-chart-full,
body.findash-body .findash-content > .fd-chart-grid {
  animation: fd-fadeup 0.5s ease-out 0.34s both;
}
@media (prefers-reduced-motion: reduce) {
  body.findash-body .findash-content > .fd-header,
  body.findash-body .fd-kpi-row--lead > *,
  body.findash-body .findash-content > .fd-chart-full,
  body.findash-body .findash-content > .fd-chart-grid {
    animation: none;
  }
}

/* ── Responsive: collapse hero+chips into vertical stack on narrow screens ── */
@media (max-width: 1100px) {
  .fd-kpi-row--lead {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: auto auto auto;
  }
  .fd-kpi-hero {
    grid-column: 1 / -1;
    grid-row: span 1;
    min-height: 140px;
  }
  .fd-hero-value { font-size: 2.2rem; }
}
@media (max-width: 720px) {
  .fd-kpi-row--lead { grid-template-columns: 1fr 1fr; }
}

/* ╔════════════════════════════════════════════════════════════════════════╗
   ║  FinDash — Trend Detail modal (row-click drill-down)                   ║
   ║  All selectors scoped via the .fd-trend-* prefix so nothing collides   ║
   ║  with the .vcis-trend-* classes used by SalesDash. Fully independent.  ║
   ║  Color tokens (--tm-*) declared on .fd-trend-card and overridden under ║
   ║  [data-theme="light"] so light mode is readable. Don't lean on global  ║
   ║  --bg-page / --input-* tokens — those aren't defined here.             ║
   ╚════════════════════════════════════════════════════════════════════════╝ */

/* Source-table clickable row — subtle affordance, doesn't fill the dense
   table. Same selector lives only here; vCIS uses .vcis-clickable-row. */
body.findash-body .fd-clickable-row { cursor: pointer; transition: background 0.12s; }
body.findash-body .fd-clickable-row:hover td {
  background: var(--color-row-hover, rgba(59,130,246,0.07));
}
/* 3px FinDash-blue accent on the leftmost cell — clearer than the previous
   1px full inset border on this dense table. */
body.findash-body .fd-clickable-row:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--fd-card-bg, #1e40af);
}

/* Backdrop. */
.fd-trend-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(6, 11, 24, 0.72);
  backdrop-filter: blur(6px) saturate(120%);
  -webkit-backdrop-filter: blur(6px) saturate(120%);
}
.fd-trend-backdrop[hidden] { display: none; }

/* Card — defaults are dark-mode values; overridden under [data-theme="light"]. */
.fd-trend-card {
  /* Modal-local color tokens (dark theme defaults). */
  --tm-card-bg:    #161b22;
  --tm-bg-soft:    #0f1e3e;
  --tm-bg-page:    #0d1117;
  --tm-text:       #f0f0f0;
  --tm-text-muted: #8b949e;
  --tm-divider:    rgba(255,255,255,0.06);
  --tm-input-bg:   rgba(255,255,255,0.06);
  --tm-input-bd:   rgba(255,255,255,0.18);
  --trend-accent:      #3b82f6;
  --trend-accent-soft: rgba(59, 130, 246, 0.18);
  --trend-accent-fade: rgba(59, 130, 246, 0.06);
  --trend-warn:        #f59e0b;

  width: min(1180px, 100%);
  max-height: 90vh;
  background: var(--tm-card-bg);
  border: 1px solid var(--fd-card-border, rgba(59,130,246,0.45));
  border-radius: 10px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.02) inset;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
[data-theme="light"] .fd-trend-card {
  --tm-card-bg:    #ffffff;
  --tm-bg-soft:    #eff6ff;
  --tm-bg-page:    #f1f5f9;
  --tm-text:       #0f1e3e;
  --tm-text-muted: #475569;
  --tm-divider:    #e2e8f0;
  --tm-input-bg:   #ffffff;
  --tm-input-bd:   #cbd5e1;
  --trend-accent:      #0f3a8a;
  --trend-accent-soft: rgba(15, 58, 138, 0.12);
  --trend-accent-fade: rgba(15, 58, 138, 0.04);
  --trend-warn:        #d4a82a;
}

/* Header — always blue (FinDash convention). Same in both themes. */
.fd-trend-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  padding: 0.7rem 1rem 0.85rem;
  background: var(--fd-card-bg, #1e40af);
  color: #fff;
}
.fd-trend-header::after {
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: 1px;
  background: linear-gradient(90deg,
              transparent 0%,
              var(--trend-accent) 12%,
              var(--trend-accent) 88%,
              transparent 100%);
  opacity: 0.7;
}
.fd-trend-titlewrap {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}
.fd-trend-back {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.fd-trend-back[hidden] { display: none; }
.fd-trend-back:hover   { background: rgba(255,255,255,0.28); }

.fd-trend-pill {
  flex: 0 0 auto;
  padding: 3px 8px;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  background: rgba(255,255,255,0.18);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.30);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.fd-trend-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
}

.fd-trend-close {
  width: 28px;
  height: 28px;
  font-size: 0.95rem;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.fd-trend-close:hover { background: rgba(255,255,255,0.28); }

/* Body — scrollable; flex children below opt out of shrinking. */
.fd-trend-body {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0.9rem 1rem 1rem;
  overflow-y: auto;
  max-height: calc(90vh - 60px);
}
.fd-trend-chips,
.fd-trend-chart-panel,
.fd-trend-breakdown { flex-shrink: 0; }

/* Chips. */
.fd-trend-chips {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.55rem;
}
.fd-trend-chip {
  background: var(--tm-bg-soft);
  border: 1px solid var(--tm-divider);
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-variant-numeric: tabular-nums;
}
.fd-trend-chip-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tm-text-muted);
}
.fd-trend-chip-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--trend-accent);
  flex: 0 0 auto;
}
.fd-trend-chip-dot--accent {
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34,197,94,0.18);
}
.fd-trend-chip-value {
  font-family: var(--font-num, monospace), 'Inter', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--tm-text);
  line-height: 1.1;
}
.fd-trend-chip-sub {
  margin-top: 0.18rem;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--tm-text-muted);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  min-height: 0.7rem;
}

/* Chart panel. */
.fd-trend-chart-panel {
  background: var(--tm-card-bg);
  border: 1px solid var(--tm-divider);
  border-radius: 6px;
  overflow: hidden;
}
.fd-trend-section-cap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0.5rem 0.85rem 0.45rem;
  background: var(--tm-bg-page);
  border-bottom: 1px solid var(--tm-divider);
}
.fd-trend-section-cap-label {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--trend-accent);
}
.fd-trend-section-cap-sub {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--tm-text-muted);
  font-variant-numeric: tabular-nums;
}
.fd-trend-chart-wrap {
  height: 280px;
  padding: 0.55rem 0.75rem 0.4rem;
}

/* Two-column breakdown. */
.fd-trend-breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.fd-trend-list-panel {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--tm-divider);
  border-radius: 6px;
  background: var(--tm-card-bg);
  overflow: hidden;
}
.fd-trend-list-header {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.7rem;
  background: var(--tm-bg-page);
  border-bottom: 1px solid var(--tm-divider);
}
.fd-trend-list-title {
  flex: 0 0 auto;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--trend-accent);
}
.fd-trend-search-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
.fd-trend-search-glyph {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  color: var(--tm-text-muted);
  pointer-events: none;
  line-height: 1;
}
.fd-trend-search {
  width: 100%;
  height: 24px;
  padding: 0 0.6rem 0 1.5rem;
  font-size: 0.72rem;
  font-family: inherit;
  background: var(--tm-input-bg);
  color: var(--tm-text);
  border: 1px solid var(--tm-input-bd);
  border-radius: 999px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.fd-trend-search::placeholder { color: var(--tm-text-muted); }
.fd-trend-search:focus {
  outline: none;
  border-color: var(--trend-accent);
  box-shadow: 0 0 0 2px var(--trend-accent-soft);
}

/* Insight strip — "Top 3 customers drive 84% of total". Hidden when empty
   (renderBreakdownList wipes the inner HTML for small populations). */
.fd-trend-insight {
  padding: 5px 0.75rem;
  background: var(--tm-bg-page);
  border-bottom: 1px solid var(--tm-divider);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--tm-text-muted);
  font-variant-numeric: tabular-nums;
}
.fd-trend-insight strong {
  color: var(--tm-text);
  font-weight: 800;
}
.fd-trend-insight-warn        { color: var(--trend-warn); }
.fd-trend-insight-warn strong { color: var(--trend-warn); }
.fd-trend-insight:empty       { display: none; }

/* List rows. */
.fd-trend-list {
  max-height: 320px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--tm-text-muted) transparent;
}
.fd-trend-list::-webkit-scrollbar       { width: 6px; }
.fd-trend-list::-webkit-scrollbar-thumb { background: var(--tm-text-muted); border-radius: 3px; }

.fd-trend-list-row {
  position: relative;
  display: grid;
  /* rank | name | revenue | YoY badge | share% */
  grid-template-columns: 26px 1fr auto 56px 52px;
  align-items: center;
  gap: 0.6rem;
  padding: 4px 0.7rem;
  min-height: 30px;
  border-bottom: 1px solid var(--tm-divider);
  font-size: 0.74rem;
  color: var(--tm-text);
  cursor: pointer;       /* rows drill into the clicked entity's modal */
  transition: background 0.12s;
}
.fd-trend-list-row:last-child { border-bottom: none; }
.fd-trend-list-row:hover { background: var(--tm-bg-page); }
/* Phase 3 — game rows in customer/currency modals get a 36px pill slot
   between rank and name. */
.fd-trend-list-row--with-gt {
  grid-template-columns: 26px 36px 1fr auto 56px 52px;
}

/* Share fill — blue-tinted (no gold per the portal-shell rule). */
.fd-trend-list-bar {
  position: absolute;
  inset: 3px auto 3px 0;
  background: linear-gradient(90deg, var(--trend-accent-soft) 0%, var(--trend-accent-fade) 100%);
  border-left: 2px solid var(--trend-accent);
  border-radius: 2px;
  pointer-events: none;
  z-index: 0;
}

.fd-trend-list-rank,
.fd-trend-list-name,
.fd-trend-list-rev,
.fd-trend-list-yoy,
.fd-trend-list-share { position: relative; z-index: 1; }

.fd-trend-list-rank {
  color: var(--tm-text-muted);
  font-family: var(--font-num, monospace), 'Inter', sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 0.7rem;
  text-align: center;
}
.fd-trend-list-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 600;
  letter-spacing: 0.005em;
}
.fd-trend-list-rev {
  font-family: var(--font-num, monospace), 'Inter', sans-serif;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
}
.fd-trend-list-yoy {
  font-family: var(--font-num, monospace), 'Inter', sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 0.66rem;
  text-align: right;
  white-space: nowrap;
}
.fd-trend-list-share {
  font-family: var(--font-num, monospace), 'Inter', sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--trend-accent);
  text-align: right;
  letter-spacing: 0.02em;
}
.fd-trend-list-empty {
  padding: 1.4rem 0.7rem;
  text-align: center;
  color: var(--tm-text-muted);
  font-size: 0.78rem;
  font-style: italic;
}
.fd-trend-list-footer {
  padding: 5px 0.75rem;
  border-top: 1px solid var(--tm-divider);
  background: var(--tm-bg-page);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--tm-text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Phase 3 — GameType pill (on game rows) ──────────────────────────────── */
.fd-trend-gt-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 16px;
  border-radius: 3px;
  font-family: var(--font-num, monospace), 'Inter', sans-serif;
  font-size: 0.54rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #0a1429;            /* dark text reads on pastel backgrounds */
  z-index: 1;                /* sit above the share-bar */
}

/* ── Phase 3 — GameType mix bar ──────────────────────────────────────────── */
.fd-trend-gtmix-wrap {
  background: var(--tm-card-bg);
  border: 1px solid var(--tm-divider);
  border-radius: 6px;
  padding: 0.5rem 0.7rem 0.55rem;
  flex-shrink: 0;
}
.fd-trend-gtmix-wrap[hidden] { display: none; }
.fd-trend-gtmix-cap {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tm-text-muted);
  margin-bottom: 0.35rem;
}
.fd-trend-gtmix {
  display: flex;
  width: 100%;
  height: 22px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--tm-bg-page);
}
.fd-trend-gtmix-slice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #0a1429;
  white-space: nowrap;
  overflow: hidden;
}
.fd-trend-gtmix-slice-name { text-transform: uppercase; opacity: 0.85; }
.fd-trend-gtmix-slice-pct  { font-variant-numeric: tabular-nums; font-weight: 800; }

/* ── Phase 4 — "What Changed?" diagnostic panel ──────────────────────────── */
.fd-trend-changes {
  background: var(--tm-card-bg);
  border: 1px solid var(--tm-divider);
  border-radius: 6px;
  padding: 0.65rem 0.85rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
}
.fd-trend-changes[hidden] { display: none; }
.fd-trend-changes-cap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px dashed var(--tm-divider);
}
.fd-trend-changes-title {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--trend-accent);
}
.fd-trend-changes-headline {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--tm-text);
  font-variant-numeric: tabular-nums;
  text-align: right;
  letter-spacing: 0.01em;
}
.fd-trend-changes-focus,
.fd-trend-changes-prev { font-weight: 800; }
.fd-trend-changes-focus-val,
.fd-trend-changes-prev-val {
  font-family: var(--font-num, monospace), 'Inter', sans-serif;
  margin: 0 0.3rem;
  color: var(--tm-text);
}
.fd-trend-changes-vs { color: var(--tm-text-muted); }
.fd-trend-changes-delta {
  margin-left: 0.5rem;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: var(--font-num, monospace), 'Inter', sans-serif;
  font-size: 0.72rem;
  font-weight: 800;
}

.fd-trend-changes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.fd-trend-changes-col-title {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}
.fd-trend-changes-col--drops .fd-trend-changes-col-title { color: #ef4444; }
.fd-trend-changes-col--gains .fd-trend-changes-col-title { color: #22c55e; }

.fd-trend-changes-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.55rem;
  padding: 3px 0.1rem;
  font-size: 0.74rem;
  color: var(--tm-text);
  border-bottom: 1px solid var(--tm-divider);
}
.fd-trend-changes-row:last-child { border-bottom: none; }
.fd-trend-changes-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 600;
}
.fd-trend-changes-amt {
  font-family: var(--font-num, monospace), 'Inter', sans-serif;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.72rem;
}
.fd-trend-changes-row--drop .fd-trend-changes-amt { color: #ef4444; }
.fd-trend-changes-row--gain .fd-trend-changes-amt { color: #22c55e; }
.fd-trend-changes-pct {
  font-family: var(--font-num, monospace), 'Inter', sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--tm-text-muted);
  min-width: 44px;
  text-align: right;
}
.fd-trend-changes-tag {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--tm-bg-page);
  color: var(--tm-text-muted);
  min-width: 44px;
  text-align: center;
}
.fd-trend-changes-tag--off { background: rgba(239,68,68,0.15); color: #ef4444; }
.fd-trend-changes-tag--new { background: rgba(34,197,94,0.15); color: #22c55e; }
.fd-trend-changes-empty {
  padding: 6px 0;
  font-size: 0.74rem;
  font-style: italic;
  color: var(--tm-text-muted);
}

.fd-trend-changes-explain {
  padding: 0.1rem 0 0.05rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--tm-text-muted);
  font-variant-numeric: tabular-nums;
}
.fd-trend-changes-explain strong {
  color: var(--tm-text);
  font-weight: 800;
}
.fd-trend-changes-explain:empty { display: none; }

.fd-trend-changes-context {
  padding-top: 0.4rem;
  border-top: 1px dashed var(--tm-divider);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.7rem;
  color: var(--tm-text-muted);
  font-variant-numeric: tabular-nums;
}
.fd-trend-changes-context strong {
  color: var(--tm-text);
  font-weight: 700;
}
.fd-trend-changes-context-sep {
  color: var(--tm-divider);
  opacity: 0.6;
}

/* Responsive — collapse to single column under 900px, full-screen under 600px. */
@media (max-width: 900px) {
  .fd-trend-chips         { grid-template-columns: repeat(2, 1fr); }
  .fd-trend-breakdown     { grid-template-columns: 1fr; }
  .fd-trend-chart-wrap    { height: 240px; }
  .fd-trend-changes-grid  { grid-template-columns: 1fr; }
  .fd-trend-changes-cap   { flex-direction: column; align-items: flex-start; }
  .fd-trend-changes-headline { text-align: left; }
}
@media (max-width: 600px) {
  .fd-trend-card     { width: 100%; max-height: 100vh; border-radius: 0; }
  .fd-trend-backdrop { padding: 0; }
  .fd-trend-body     { max-height: calc(100vh - 56px); }
}
