/* CardDex premium polish layer
 *
 * View Transitions API, command palette overlay, top progress bar,
 * tabular numerals on numeric content, hero parallax + light shaft,
 * and empty-state illustration container. Loaded from every public
 * page after ux.css and freshness-tour.css.
 */

/* Prevent horizontal overflow */
body { overflow-x: hidden; }

/* Suppress iOS rubber-band overscroll on the page itself. Without this,
   `position: fixed` elements (notably the bottom nav) visually detach from
   the viewport bottom when momentum scrolling past the page edges. */
html, body { overscroll-behavior-y: none; }

/* Ensure the page is at least the *large* viewport tall on mobile (lvh =
   layout viewport with toolbars collapsed). This guarantees the page is
   always slightly scrollable while the Chrome iOS toolbar is visible —
   which Chrome uses as a cue to keep the toolbar on screen instead of
   hiding it after the user crosses to a short page. */
@media (max-width: 768px) {
  body { min-height: 100lvh; }
}

/* ── Inter variable font (self-hosted) ─────────────────────────
   Provides consistent typography with built-in tabular figures,
   optical sizing, and variable weight. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/Inter-Variable.woff2') format('woff2');
  unicode-range: U+0000-024F, U+0300-036F, U+2000-218F, U+2C60-2C7F, U+A720-A7FF;
}

/* ── Tabular numerals everywhere numbers matter ─────────────────── */
.kpi-card__value,
.kpi-card__sub,
.tcg-card-metric .val,
.cdx-freshness__label,
table td,
.product-name + .price,
.num,
[data-numeric],
.stat strong {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum", "ss01";
}

/* ── Delta magnitude color scaling ─────────────────────────────
   Stronger changes get more vivid color; small changes are muted.
   Applied via inline style or data-mag attribute in JS. */
.delta-pos { color: var(--green); }
.delta-neg { color: var(--red); }
.delta-zero { color: var(--muted); }

.delta-pos[data-mag="low"]  { opacity: .55; }
.delta-neg[data-mag="low"]  { opacity: .55; }
.delta-pos[data-mag="high"] { filter: brightness(1.2); text-shadow: 0 0 8px color-mix(in srgb, var(--green) 30%, transparent); }
.delta-neg[data-mag="high"] { filter: brightness(1.2); text-shadow: 0 0 8px color-mix(in srgb, var(--red) 30%, transparent); }

/* ── View Transitions API ───────────────────────────────────────── */
@view-transition { navigation: auto; }

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 280ms;
  animation-timing-function: cubic-bezier(.4, 0, .2, 1);
}

/* Persist the chrome across navigations so only the body crossfades. */
header { view-transition-name: cdx-header; }
.cdx-hero { view-transition-name: cdx-hero; }
.kpi-row { view-transition-name: cdx-kpi; }
.app-beta { view-transition-name: cdx-beta; }
#cdxFreshness { view-transition-name: cdx-freshness; }
#cdxTourLauncher { view-transition-name: cdx-tour-launcher; }

::view-transition-old(cdx-header),
::view-transition-new(cdx-header),
::view-transition-old(cdx-beta),
::view-transition-new(cdx-beta),
::view-transition-old(cdx-freshness),
::view-transition-new(cdx-freshness),
::view-transition-old(cdx-tour-launcher),
::view-transition-new(cdx-tour-launcher) {
  animation: none;
  mix-blend-mode: normal;
}

::view-transition-old(cdx-hero),
::view-transition-new(cdx-hero) {
  animation-duration: 360ms;
  animation-timing-function: cubic-bezier(.32, .72, 0, 1);
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}

/* ── Top navigation progress bar ────────────────────────────────── */
.cdx-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--accent), #f0b90b 60%, #fff7d6);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 60%, transparent);
  z-index: 10002;
  opacity: 0;
  pointer-events: none;
  transition: width .25s cubic-bezier(.4, 0, .2, 1), opacity .25s;
  border-radius: 0 2px 2px 0;
}
.cdx-progress--visible { opacity: 1; }
.cdx-progress--done { opacity: 0; transition: width .15s, opacity .25s .15s; }
@media (prefers-reduced-motion: reduce) {
  .cdx-progress { transition: opacity .2s; }
}

/* ── Command palette ────────────────────────────────────────────── */
.cdx-cmdk {
  position: fixed;
  inset: 0;
  z-index: 10003;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 16px;
}
.cdx-cmdk--open { display: flex; }
.cdx-cmdk__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px) saturate(120%);
  -webkit-backdrop-filter: blur(6px) saturate(120%);
  animation: cdxCmdkFadeIn .18s ease-out;
}
.cdx-cmdk__panel {
  position: relative;
  width: 100%;
  max-width: 580px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(201, 160, 48, 0.18);
  overflow: hidden;
  animation: cdxCmdkPanelIn .22s cubic-bezier(.32, .72, 0, 1);
}
.cdx-cmdk__inputwrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.cdx-cmdk__searchicon {
  width: 16px;
  height: 16px;
  color: var(--muted);
  flex-shrink: 0;
}
.cdx-cmdk__input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  padding: 0;
}
.cdx-cmdk__input::placeholder { color: var(--muted); }
.cdx-cmdk__hint {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 5px;
  background: var(--hover);
  border: 1px solid var(--border);
  color: var(--muted);
}
.cdx-cmdk__list {
  list-style: none;
  margin: 0;
  padding: 6px 6px 8px;
  overflow-y: auto;
  flex: 1;
}
.cdx-cmdk__section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
  padding: 12px 14px 6px;
}
.cdx-cmdk__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  transition: background .12s;
}
.cdx-cmdk__item--active {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--text);
}
.cdx-cmdk__item--active::after {
  content: '↵';
  margin-left: auto;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}
.cdx-cmdk__label { font-weight: 500; }
.cdx-cmdk__empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.cdx-cmdk__footer {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}
.cdx-cmdk__footer kbd {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 10px;
  padding: 1px 5px;
  margin-right: 4px;
  border-radius: 3px;
  background: var(--hover);
  border: 1px solid var(--border);
  color: var(--text);
}

@keyframes cdxCmdkFadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes cdxCmdkPanelIn { from { opacity: 0; transform: translateY(-12px) scale(.97); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .cdx-cmdk__backdrop,
  .cdx-cmdk__panel { animation: none; }
}

@media (max-width: 640px) {
  .cdx-cmdk { padding: 6vh 10px 10px; }
  .cdx-cmdk__panel { max-height: 88vh; border-radius: 12px; }
  .cdx-cmdk__footer { display: none; }
}

/* ── Hero parallax + light shaft ────────────────────────────────── */
.cdx-hero__bg {
  will-change: transform;
  transition: transform .25s cubic-bezier(.2, .7, 0, 1);
}
.cdx-hero {
  --cdx-parallax-x: 0px;
  --cdx-parallax-y: 0px;
}
@media (hover: hover) and (pointer: fine) {
  .cdx-hero:hover .cdx-hero__bg {
    transform: scale(1.06) translate(var(--cdx-parallax-x), var(--cdx-parallax-y));
  }
}
.cdx-hero::after {
  content: '';
  position: absolute;
  top: 0;
  left: -40%;
  width: 30%;
  height: 100%;
  background: linear-gradient(115deg,
    transparent 30%,
    rgba(255, 245, 200, 0.06) 48%,
    rgba(255, 245, 200, 0.16) 50%,
    rgba(255, 245, 200, 0.06) 52%,
    transparent 70%);
  pointer-events: none;
  animation: cdxHeroLightShaft 14s linear infinite;
  mix-blend-mode: screen;
  z-index: 0;
}
@keyframes cdxHeroLightShaft {
  0%   { transform: translateX(0); }
  100% { transform: translateX(450%); }
}
@media (prefers-reduced-motion: reduce) {
  .cdx-hero::after { animation: none; opacity: 0; }
  .cdx-hero:hover .cdx-hero__bg { transform: none; }
}

/* ── Theme presets beyond dark/light ─────────────────────────────
 * Override the same CSS variable names every page already declares
 * inline. The bootstrap script in each page sets data-theme on
 * <html> from localStorage, so any preset here just needs to be
 * picked from the user dropdown. */
html[data-theme="oled"] {
  --bg:        #000000;
  --surface:   #0a0a12;
  --border:    #1a1a25;
  --text:      #f5f5fa;
  --muted:     #5a5a72;
  --green:     #00d27a;
  --red:       #ff3b5c;
  --yellow:    #f5b800;
  --accent:    #c9a030;
  --accent-blue: #3d7ec7;
  --accent-cyan: #5ec7e0;
  --hover:     #14141e;
}
html[data-theme="amber"] {
  --bg:        #15110a;
  --surface:   #1d180e;
  --border:    #2d2616;
  --text:      #ffd580;
  --muted:     #b08850;
  --green:     #ffb84d;
  --red:       #ff5a3c;
  --yellow:    #ffd966;
  --accent:    #ffa94d;
  --accent-blue: #ff9933;
  --accent-cyan: #ffcb70;
  --hover:     #261d10;
}
html[data-theme="amber"] body { color: var(--text); }
html[data-theme="amber"] .kpi-card__value,
html[data-theme="amber"] .kpi-card__label,
html[data-theme="amber"] table td,
html[data-theme="amber"] .num,
html[data-theme="amber"] [data-numeric] {
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", monospace;
}
html[data-theme="tokyo"] {
  --bg:        #1a1b26;
  --surface:   #24283b;
  --border:    #2f3550;
  --text:      #c0caf5;
  --muted:     #7a86b3;
  --green:     #9ece6a;
  --red:       #f7768e;
  --yellow:    #e0af68;
  --accent:    #bb9af7;
  --accent-blue: #7aa2f7;
  --accent-cyan: #7dcfff;
  --hover:     #2a2f44;
}

/* ── Lighter themes ─────────────────────────────────────────────
 * Four high-key palettes for users who prefer brighter chrome,
 * plus one mid-dark Forest variant for contrast. The cosmic body
 * backdrop is suppressed on the light variants since the texture
 * was designed for navy backgrounds. */

html[data-theme="paper"] {
  --bg:        #faf6ee;
  --surface:   #fffbf0;
  --border:    #e8dfc6;
  --text:      #2a261d;
  --muted:     #8a8273;
  --green:     #1f9d55;
  --red:       #c0392b;
  --yellow:    #b8860b;
  --accent:    #b08a1e;
  --accent-blue: #2c5e8e;
  --accent-cyan: #2e8a9c;
  --hover:     #f4eddc;
}

html[data-theme="mint"] {
  --bg:        #f2fbf6;
  --surface:   #ffffff;
  --border:    #d4e9dd;
  --text:      #1f2e26;
  --muted:     #6b8076;
  --green:     #16a574;
  --red:       #d44e3a;
  --yellow:    #c98a16;
  --accent:    #19a17a;
  --accent-blue: #2c7eb8;
  --accent-cyan: #2e9aaa;
  --hover:     #e6f5ec;
}

html[data-theme="rose"] {
  --bg:        #fdf6f6;
  --surface:   #ffffff;
  --border:    #f2dede;
  --text:      #2e1f24;
  --muted:     #836670;
  --green:     #2f9d6e;
  --red:       #c2386b;
  --yellow:    #c79110;
  --accent:    #c43c6e;
  --accent-blue: #5e7eb8;
  --accent-cyan: #4d9ea7;
  --hover:     #f7eaea;
}

html[data-theme="slate"] {
  --bg:        #eef1f5;
  --surface:   #ffffff;
  --border:    #d8dee8;
  --text:      #1e2733;
  --muted:     #687485;
  --green:     #1f9d6e;
  --red:       #d34256;
  --yellow:    #c08818;
  --accent:    #2e6db8;
  --accent-blue: #2e6db8;
  --accent-cyan: #2e8aa8;
  --hover:     #e2e7ef;
}

html[data-theme="forest"] {
  --bg:        #0f1d18;
  --surface:   #15281f;
  --border:    #1f3a2c;
  --text:      #e8efe8;
  --muted:     #7a8e83;
  --green:     #4ade80;
  --red:       #f87171;
  --yellow:    #facc15;
  --accent:    #4ade80;
  --accent-blue: #38bdf8;
  --accent-cyan: #67e8f9;
  --hover:     #1c322a;
}

html[data-theme="contrast"] {
  --bg:        #000000;
  --surface:   #111111;
  --border:    #444444;
  --text:      #ffffff;
  --muted:     #bbbbbb;
  --green:     #00ff88;
  --red:       #ff4444;
  --yellow:    #ffdd00;
  --accent:    #ffdd00;
  --accent-blue: #66aaff;
  --accent-cyan: #66ffff;
  --hover:     #222222;
}

/* Suppress the navy cosmic backdrop on the high-key light themes */
html[data-theme="paper"] body::before,
html[data-theme="mint"]  body::before,
html[data-theme="rose"]  body::before,
html[data-theme="slate"] body::before { opacity: 0; }
/* Suppress cosmic backdrop on contrast theme */
html[data-theme="contrast"] body::before { opacity: 0; }

/* Theme picker chip row inside the user dropdown */
.cdx-theme-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px 12px;
}
.cdx-theme-picker__label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
}
.cdx-theme-picker__chips {
  display: flex;
  gap: 6px;
}
.cdx-theme-chip {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: transform .15s, border-color .15s;
}
.cdx-theme-chip:hover { transform: scale(1.1); border-color: var(--text); }
.cdx-theme-chip[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent);
}
.cdx-theme-chip--dark   { background: linear-gradient(135deg, #0b1525 50%, #c9a030 50%); }
.cdx-theme-chip--light  { background: linear-gradient(135deg, #f5f6fa 50%, #b08a1e 50%); }
.cdx-theme-chip--oled   { background: linear-gradient(135deg, #000 50%, #c9a030 50%); }
.cdx-theme-chip--amber  { background: linear-gradient(135deg, #15110a 50%, #ffa94d 50%); }
.cdx-theme-chip--tokyo  { background: linear-gradient(135deg, #1a1b26 50%, #bb9af7 50%); }
.cdx-theme-chip--paper  { background: linear-gradient(135deg, #faf6ee 50%, #b08a1e 50%); }
.cdx-theme-chip--mint   { background: linear-gradient(135deg, #f2fbf6 50%, #19a17a 50%); }
.cdx-theme-chip--rose   { background: linear-gradient(135deg, #fdf6f6 50%, #c43c6e 50%); }
.cdx-theme-chip--slate  { background: linear-gradient(135deg, #eef1f5 50%, #2e6db8 50%); }
.cdx-theme-chip--forest { background: linear-gradient(135deg, #0f1d18 50%, #4ade80 50%); }
.cdx-theme-chip--contrast { background: linear-gradient(135deg, #000 50%, #ffdd00 50%); }
/* The picker holds 11 chips now — wrap onto two rows on the narrower
   user dropdown so they don't get cut off. */
.cdx-theme-picker__chips { flex-wrap: wrap; max-width: 168px; row-gap: 6px; }

/* ── Logo shimmer ──────────────────────────────────────────────
 * Slow gold-accent shimmer that sweeps across the CardDex wordmark
 * on hover. Pure CSS via background-clip: text + a gradient that
 * animates its background-position. The logo image itself gets a
 * subtle scale pop and a soft drop-shadow on the same hover. */
header .logo {
  background-image: linear-gradient(110deg,
    var(--accent) 0%,
    var(--accent) 35%,
    #fff7d6 50%,
    var(--accent) 65%,
    var(--accent) 100%);
  background-size: 220% 100%;
  background-position: 100% 0;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  transition: background-position 1.1s cubic-bezier(.4,0,.2,1);
}
header .logo:hover {
  background-position: 0 0;
}
header .logo img {
  transition: transform .35s cubic-bezier(.4,0,.2,1), filter .35s ease;
}
header .logo:hover img {
  transform: scale(1.06) rotate(-2deg);
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--accent) 60%, transparent));
}
@media (prefers-reduced-motion: reduce) {
  header .logo,
  header .logo img { transition: none; }
}

/* ── TCG nav tabs: animated underline that grows from center ────
 * Replaces the old binary "border-bottom" hover with a soft inner
 * highlight + a gold underline that scales out from the centre. The
 * active tab keeps its full underline; hover tabs get a 50% width
 * underline that grows on enter and shrinks on leave. */
.tcg-tab {
  position: relative;
  transition: color .2s ease, background-color .2s ease;
}
.tcg-tab::after {
  content: '';
  position: absolute;
  left: 50%;
  right: 50%;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
  transition: left .25s cubic-bezier(.4,0,.2,1),
              right .25s cubic-bezier(.4,0,.2,1),
              opacity .2s ease;
  opacity: 0;
  pointer-events: none;
}
.tcg-tab:hover {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}
.tcg-tab:hover::after {
  left: 18%;
  right: 18%;
  opacity: 0.55;
}
.tcg-tab.active {
  /* keep the existing border-bottom rule too — defensive */
  border-bottom-color: transparent;
}
.tcg-tab.active::after {
  left: 0;
  right: 0;
  opacity: 1;
}
.tcg-tab .icon,
.tcg-tab svg {
  transition: transform .25s cubic-bezier(.4,0,.2,1), filter .25s ease;
}
.tcg-tab:hover .icon,
.tcg-tab:hover svg {
  transform: scale(1.12);
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 50%, transparent));
}

/* ── Header right-side nav links ───────────────────────────────
 * Portfolio / Alerts / Reports get a soft pill background on hover,
 * a gold underline that grows from centre, and an icon-style scale
 * micro-interaction. The active page (matched by data-active) gets
 * the same treatment as the active TCG tab. */
.header-right .nav-link {
  position: relative;
  border-radius: 8px;
  padding: 7px 14px !important;
  transition: color .2s ease, background-color .2s ease;
}
.header-right .nav-link::after {
  content: '';
  position: absolute;
  left: 50%;
  right: 50%;
  bottom: 3px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
  opacity: 0;
  transition: left .25s cubic-bezier(.4,0,.2,1),
              right .25s cubic-bezier(.4,0,.2,1),
              opacity .2s ease;
  pointer-events: none;
}
.header-right .nav-link:hover {
  color: var(--text) !important;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.header-right .nav-link:hover::after {
  left: 18%;
  right: 18%;
  opacity: 0.65;
}
.header-right .nav-link[aria-current="page"] {
  color: var(--text) !important;
}
.header-right .nav-link[aria-current="page"]::after {
  left: 14%;
  right: 14%;
  opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
  .tcg-tab::after,
  .header-right .nav-link::after,
  .tcg-tab .icon,
  .tcg-tab svg { transition: none; }
}

/* ── Header search trigger (command palette discovery) ─────────── */
.cdx-search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px 7px 12px;
  margin-right: 4px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
  font-family: inherit;
}
.cdx-search-trigger:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--hover);
}
.cdx-search-trigger__icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.cdx-search-trigger__label {
  font-weight: 500;
  min-width: 70px;
  text-align: left;
}
.cdx-search-trigger__kbd {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
@media (max-width: 768px) {
  .cdx-search-trigger { padding: 7px; gap: 0; }
  .cdx-search-trigger__label,
  .cdx-search-trigger__kbd { display: none; }
}

/* ── Skeleton screens shaped like real content ───────────────────
 * The shimmer uses a moving background gradient over a neutral base
 * tinted with the surface color, so it adapts automatically to all
 * three theme presets without per-theme overrides. */
@keyframes cdxSkeletonShimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.cdx-skeleton-line,
.cdx-skeleton-cell {
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--border) 70%, transparent) 0%,
    color-mix(in srgb, var(--border) 30%, transparent) 50%,
    color-mix(in srgb, var(--border) 70%, transparent) 100%);
  background-size: 200% 100%;
  animation: cdxSkeletonShimmer 1.6s linear infinite;
  border-radius: 6px;
  display: block;
}
@media (prefers-reduced-motion: reduce) {
  .cdx-skeleton-line,
  .cdx-skeleton-cell { animation: none; }
}

.cdx-skeleton-kpi {
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
  min-height: 84px;
}
.cdx-skeleton-line--label {
  width: 50%;
  height: 10px;
}
.cdx-skeleton-line--value {
  width: 70%;
  height: 22px;
}

/* ── Inline-edit cells (portfolio table) ─────────────────────────
 * Click on a quantity or paid-price cell to edit in place. The cell
 * itself becomes the input — no row state, no modal — and saves on
 * Enter/blur with optimistic UI + Undo toast. */
.cdx-inline-edit {
  cursor: text;
  position: relative;
  border-radius: 4px;
  transition: background-color .15s, box-shadow .15s;
}
.cdx-inline-edit:hover {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}
.cdx-inline-edit::after {
  content: '';
  position: absolute;
  right: 6px;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  background:
    linear-gradient(currentColor, currentColor) no-repeat 50% 50% / 8px 1.5px,
    linear-gradient(currentColor, currentColor) no-repeat 50% 50% / 1.5px 8px;
  color: var(--accent);
  opacity: 0;
  transition: opacity .15s;
  pointer-events: none;
}
.cdx-inline-edit:hover::after { opacity: 0.55; }
.cdx-inline-edit--editing {
  background: var(--surface) !important;
  box-shadow: inset 0 0 0 2px var(--accent);
  cursor: text;
  padding: 0;
}
.cdx-inline-edit--editing::after { display: none; }
.cdx-inline-edit__input {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: inherit;
  font-family: inherit;
  font-weight: inherit;
  font-variant-numeric: tabular-nums;
  padding: 6px 8px;
  text-align: inherit;
  -moz-appearance: textfield;
}
.cdx-inline-edit__input::-webkit-outer-spin-button,
.cdx-inline-edit__input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ── Empty state illustration ───────────────────────────────────── */
.cdx-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  gap: 14px;
  color: var(--muted);
}
.cdx-empty__art {
  width: 100%;
  max-width: 320px;
  aspect-ratio: 16 / 10;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 80%, transparent), var(--surface));
  border: 1px solid var(--border);
  border-radius: 16px;
  background-size: cover;
  background-position: center;
  box-shadow: 0 18px 45px rgba(0, 0, 0, .28);
  margin-bottom: 6px;
}
.cdx-empty__title {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
}
.cdx-empty__body {
  font-size: 13px;
  max-width: 360px;
  line-height: 1.55;
}
.cdx-empty__cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
}
.cdx-empty__cta:hover { opacity: .9; }

/* ── Button press feedback ─────────────────────────────────────
   Subtle scale-down on :active for tactile button feel. */
.btn-portfolio:active,
.btn-alert:active,
.view-toggle button:active,
.cdx-empty__cta:active,
button[type="submit"]:active {
  transform: scale(.97);
}
@media (prefers-reduced-motion: reduce) {
  .btn-portfolio:active,
  .btn-alert:active,
  .view-toggle button:active,
  .cdx-empty__cta:active,
  button[type="submit"]:active { transform: none; }
}

/* ── KPI card hover lift ───────────────────────────────────────
   Subtle lift on stat cards to invite interaction. */
.kpi-card,
.metric-card {
  transition: transform .2s ease, box-shadow .2s ease;
}
.kpi-card:hover,
.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .15);
}
@media (prefers-reduced-motion: reduce) {
  .kpi-card:hover,
  .metric-card:hover { transform: none; box-shadow: none; }
}

/* ── Breadcrumbs ───────────────────────────────────────────────
   Inline navigation trail below the product title in the header. */
.cdx-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.cdx-breadcrumb a {
  color: var(--muted);
  text-decoration: none;
  transition: color .15s;
}
.cdx-breadcrumb a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.cdx-breadcrumb__sep {
  color: var(--border);
  font-size: 9px;
  user-select: none;
}
.cdx-breadcrumb__current {
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 240px;
  display: none; /* don't repeat the name already in h1 */
}
@media (max-width: 768px) {
  .cdx-breadcrumb { font-size: 10px; }
}

/* ── Staggered row entrance ────────────────────────────────────
   Rows fade+slide in with a 20ms stagger for a premium waterfall
   effect when the table first loads. Applied via JS after render. */
@keyframes cdxRowIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.cdx-row-enter {
  animation: cdxRowIn .25s ease-out both;
}
@media (prefers-reduced-motion: reduce) {
  .cdx-row-enter { animation: none; }
}
/* Touch devices: skip the staggered row entrance entirely. The animation
   can run for ~1s with translateY, during which taps on still-animating
   rows fail to navigate on Chrome Android — going back and returning (via
   bfcache) shows the rows already settled and taps work first try. */
@media (hover: none) {
  .cdx-row-enter { animation: none; }
}

/* ── Column group dividers ─────────────────────────────────────
   Subtle vertical separator between price and supply groups. */
.cdx-sticky-header th:nth-child(7),
.cdx-sticky-header td:nth-child(7) {
  border-left: 1px solid var(--border);
  padding-left: 14px;
}
.cdx-sticky-header th:nth-child(11),
.cdx-sticky-header td:nth-child(11) {
  border-left: 1px solid var(--border);
  padding-left: 10px;
}

/* ── Mobile bottom navigation bar ──────────────────────────────
   Fixed bottom bar with primary nav links on mobile. Hidden on
   desktop. Sits above the Beta badge (z-index 95). */
.cdx-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
}
.cdx-bottom-nav__list {
  display: flex;
  justify-content: space-around;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
}
.cdx-bottom-nav__list li { display: contents; }
.cdx-bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 0;
  color: var(--muted);
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  min-width: 48px;
  transition: color .15s;
}
.cdx-bottom-nav__item:hover,
.cdx-bottom-nav__item[aria-current="page"] {
  color: var(--accent);
}
.cdx-bottom-nav__item svg { width: 20px; height: 20px; }
/* Live status dot inside bottom nav — hidden on desktop */
.cdx-bottom-nav__live {
  display: none;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  color: var(--muted);
  padding: 2px 0;
}
.cdx-bottom-nav__live-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
}
@media (max-width: 768px) {
  .cdx-bottom-nav { display: block !important; }
  body { padding-bottom: 64px; }
  /* Reposition fixed bottom-left/right elements above the nav bar.
     Use translateZ(0) to force own compositing layer on iOS Safari. */
  .app-beta { bottom: 70px !important; z-index: 10000; }
  .cdx-freshness { display: none !important; }
  .cdx-tour-launcher { bottom: 110px !important; z-index: 10000; }
}

/* ── Table cell hover highlight ────────────────────────────────
   Faint highlight on the hovered cell for better data scanning.
   Scoped to real hover devices: on touch (iOS), :hover sticks after
   the first tap and swallows that tap, so the user has to tap twice
   to navigate. Excluding touch restores single-tap activation. */
@media (hover: hover) and (pointer: fine) {
  table td:hover {
    background: color-mix(in srgb, var(--accent) 6%, transparent);
  }
}
