/* ==========================================================================
   Flash Finance — shared "market pages" design system
   Used by: /multibagger-ai and /live-market-tracking.
   Light pro-dashboard language (same family as corporate_actions_hub):
   Inter, soft-tint badges, tokenized colors. All classes are ff-* scoped so
   this file can be added to more pages without clashing with base_news css.
   ========================================================================== */

:root {
  --ff-primary: #1a365d;
  --ff-primary-2: #2c5282;
  --ff-accent: #2c7be5;
  --ff-accent-soft: #e7f0fc;
  --ff-success: #16a34a;
  --ff-success-deep: #166534;
  --ff-success-soft: #dcfce7;
  --ff-warning: #d97706;
  --ff-warning-deep: #854d0e;
  --ff-warning-soft: #fef3c7;
  --ff-danger: #dc2626;
  --ff-danger-deep: #991b1b;
  --ff-danger-soft: #fee2e2;
  --ff-watch: #7c3aed;
  --ff-watch-deep: #5b21b6;
  --ff-watch-soft: #ede9fe;
  --ff-neutral: #64748b;
  --ff-neutral-deep: #475569;
  --ff-neutral-soft: #f1f5f9;
  --ff-text: #1f2937;
  --ff-text-soft: #6b7280;
  --ff-text-faint: #9ca3af;
  --ff-border: #e5e7eb;
  --ff-border-soft: #eef1f6;
  --ff-bg: #f7f9fc;
  --ff-card: #ffffff;
  --ff-radius: 12px;
  --ff-radius-sm: 8px;
  --ff-shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --ff-shadow-hover: 0 4px 12px rgba(16, 24, 40, .08), 0 2px 4px rgba(16, 24, 40, .05);
  --ff-font: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;

  /* Height of base_news' sticky header (--ff-header-h), and of the header
     plus any sticky sub-nav sitting under it (--ff-stick-h). Anything that
     sticks below the header, and any anchor target that has to clear it,
     must offset by these instead of a literal number — the header is NOT a
     fixed height: it is ~56px on desktop but ~108px under 900px, where the
     search bar wraps onto its own row. A hardcoded 56px is therefore wrong
     on exactly the viewports most of our traffic comes from.
     market.js measures the live values and overrides these; the defaults
     below mirror the header's own 900px breakpoint so the page is still
     right with JS disabled or before it runs. */
  --ff-header-h: 56px;
  --ff-stick-h: 105px;
}
@media (max-width: 900px) {
  :root { --ff-header-h: 108px; --ff-stick-h: 157px; }
}

/* ---- page shell: widen base_news' 1000px column for dashboard density ----
   1400px is not arbitrary: it matches base_news' .header-content, so the nav
   bar's outer edges line up with the card edges below it instead of
   overhanging them by 80px a side. Prose does NOT get this width — the
   narrative/FAQ/report blocks keep their own reading caps below. */
.ff-page { font-family: var(--ff-font); color: var(--ff-text); }
.content:has(.ff-page) { max-width: 1400px; }
/* fallback for browsers without :has() — the page sets this class on .content via JS */
.content.ff-wide { max-width: 1400px; }

/* ---------------------------------- hero --------------------------------- */
.ff-hero {
  background: linear-gradient(135deg, var(--ff-primary) 0%, var(--ff-primary-2) 100%);
  color: #fff; border-radius: var(--ff-radius); padding: 22px 24px 18px;
  margin-bottom: 16px; box-shadow: var(--ff-shadow);
}
.ff-hero h1 { margin: 0 0 4px; font-size: 1.65rem; font-weight: 700; letter-spacing: -.4px; display: flex; align-items: center; gap: 10px; }
.ff-hero p { margin: 0; opacity: .88; font-size: .93rem; line-height: 1.5; max-width: 860px; }
.ff-hero-status { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ff-hero-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 20px; padding: 4px 12px; font-size: .76rem; font-weight: 500; color: #fff;
}
.ff-pulse {
  width: 8px; height: 8px; border-radius: 50%; background: #4ade80; flex: none;
  box-shadow: 0 0 0 0 rgba(74, 222, 128, .6); animation: ffpulse 2s infinite;
}
@keyframes ffpulse {
  0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, .55); }
  70% { box-shadow: 0 0 0 7px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

/* ------------------------------ notes / boxes ---------------------------- */
.ff-note {
  border-radius: 10px; padding: 11px 15px; margin-bottom: 14px;
  font-size: .84rem; line-height: 1.55;
}
.ff-note-warn { background: #fff8e1; border: 1px solid #ffe082; color: #5d4037; }
.ff-note-warn strong { color: #bf360c; }
.ff-note-info { background: var(--ff-accent-soft); border: 1px solid #cfe3fb; color: #1e3a5f; }

/* -------------------------------- stat band ------------------------------ */
.ff-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 10px; margin-bottom: 14px;
}
.ff-stat {
  background: var(--ff-card); border: 1px solid var(--ff-border);
  border-radius: var(--ff-radius); padding: 13px 14px 11px; text-align: center;
  box-shadow: var(--ff-shadow);
}
.ff-stat .v { font-size: 1.45rem; font-weight: 700; color: var(--ff-primary); line-height: 1.15; }
.ff-stat .l { font-size: .7rem; color: var(--ff-text-soft); text-transform: uppercase; letter-spacing: .45px; margin-top: 3px; font-weight: 600; }
.ff-stat .s { font-size: .7rem; color: var(--ff-text-faint); margin-top: 2px; }
.ff-stat.t-pos .v { color: var(--ff-success); }
.ff-stat.t-neg .v { color: var(--ff-danger); }
.ff-stat.t-warn .v { color: var(--ff-warning); }
.ff-stat.t-watch .v { color: var(--ff-watch); }
.ff-stat.t-accent .v { color: var(--ff-accent); }

/* --------------------------------- badges -------------------------------- */
.ff-badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: .72rem; font-weight: 600; white-space: nowrap; line-height: 1.7;
}
/* impact */
.ff-badge.i-positive { background: var(--ff-success-soft); color: var(--ff-success-deep); }
.ff-badge.i-negative { background: var(--ff-danger-soft); color: var(--ff-danger-deep); }
.ff-badge.i-neutral  { background: var(--ff-warning-soft); color: var(--ff-warning-deep); }
.ff-badge.i-watch    { background: var(--ff-watch-soft); color: var(--ff-watch-deep); }
/* verdict */
.ff-badge.v-STRONG_CANDIDATE { background: var(--ff-success-soft); color: var(--ff-success-deep); }
.ff-badge.v-POSSIBLE { background: var(--ff-warning-soft); color: var(--ff-warning-deep); }
.ff-badge.v-UNLIKELY { background: var(--ff-neutral-soft); color: var(--ff-neutral-deep); }
.ff-badge.v-NO { background: var(--ff-danger-soft); color: var(--ff-danger-deep); }
/* source */
.ff-badge.b-EXPANSION { background: #e0f2fe; color: #075985; }
.ff-badge.b-ORDER { background: var(--ff-watch-soft); color: var(--ff-watch-deep); }
/* styled hover card, driven by [data-tip]. A native title= can only carry one flat string
   and takes ~1s to appear; these carry a labelled block of stats. Keyboard-reachable. */
.ff-tip {
  position: fixed; z-index: 9999; max-width: 320px; pointer-events: none;
  opacity: 0; visibility: hidden; transform: translateY(2px);
  transition: opacity .12s ease, transform .12s ease;
  background: #111827; color: #f3f4f6; border-radius: 8px;
  padding: 9px 11px; font-size: .76rem; line-height: 1.55; white-space: pre-line;
  box-shadow: 0 6px 22px rgba(0,0,0,.28); font-variant-numeric: tabular-nums;
}
.ff-tip.on { opacity: 1; visibility: visible; transform: translateY(0); }
.ff-tip b { color: #fff; font-weight: 650; }
[data-tip] { cursor: help; }
[data-tip]:focus-visible { outline: 2px solid var(--ff-accent); outline-offset: 2px; }

/* oversized-deal risk flag (multibagger) — an outline pill, deliberately NOT a filled
   verdict-style badge: it warns about the blow-up tail, it does not re-rate the pick */
.ff-badge.ff-oversized {
  background: transparent; color: var(--ff-danger-deep);
  border: 1px solid currentColor; font-size: .66rem; padding: 1px 7px;
  margin-left: 4px; letter-spacing: .01em;
}
/* sector cell (multibagger) — a long industry label must not shove the numeric
   columns off screen, so it clips with the full name kept in the title tooltip */
.ff-sector { max-width: 140px; font-size: .78rem; color: var(--ff-text-soft); }
.ff-sector > span {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ff-oversized-note { color: var(--ff-danger-deep); font-weight: 600; }
/* status / misc */
.ff-badge.st-pending { background: var(--ff-warning-soft); color: #92400e; }
.ff-badge.new {
  background: var(--ff-accent); color: #fff; font-size: .62rem; padding: 1px 7px;
  vertical-align: 2px; letter-spacing: .5px;
}
/* score pill */
.ff-badge.score { background: var(--ff-accent-soft); color: #1e40af; }
/* per-category tints (live market) */
.ff-badge.c-EARNINGS { background: #e0f2fe; color: #075985; }
.ff-badge.c-DIVIDEND { background: var(--ff-success-soft); color: var(--ff-success-deep); }
.ff-badge.c-MA, .ff-badge.c-M\&A { background: #fce7f3; color: #9d174d; }
.ff-badge.c-BOARD_MEETING { background: var(--ff-neutral-soft); color: var(--ff-neutral-deep); }
.ff-badge.c-REGULATORY { background: var(--ff-warning-soft); color: var(--ff-warning-deep); }
.ff-badge.c-FUNDRAISE { background: #ecfeff; color: #155e75; }
.ff-badge.c-EXPANSION { background: #e0f2fe; color: #075985; }
.ff-badge.c-MANAGEMENT { background: var(--ff-watch-soft); color: var(--ff-watch-deep); }
.ff-badge.c-LEGAL { background: var(--ff-danger-soft); color: var(--ff-danger-deep); }
.ff-badge.c-ROUTINE, .ff-badge.c-OTHER { background: var(--ff-neutral-soft); color: var(--ff-neutral-deep); }

/* --------------------------------- cards --------------------------------- */
.ff-card {
  background: var(--ff-card); border: 1px solid var(--ff-border);
  border-radius: var(--ff-radius); box-shadow: var(--ff-shadow);
  margin-bottom: 14px; overflow: hidden;
}
.ff-card-header {
  padding: 12px 16px; border-bottom: 1px solid var(--ff-border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: linear-gradient(180deg, #fafbfc 0%, #ffffff 100%);
}
.ff-card-header h2 { font-size: .98rem; font-weight: 600; color: var(--ff-primary); margin: 0; display: flex; align-items: center; gap: 7px; }
.ff-card-header .meta { color: var(--ff-text-soft); font-size: .78rem; }
.ff-card-body { padding: 14px 16px; }

/* chart cards */
.ff-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
/* Uneven split for a wide table beside a narrow chart. A class, not an inline
   style: inline grid-template-columns outranks the breakpoint below, so pairs
   written that way stayed side by side on phones. */
.ff-charts.wide-left { grid-template-columns: 1.15fr .85fr; }
.ff-chart-wrap { position: relative; height: 230px; }
.ff-chart-foot { font-size: .72rem; color: var(--ff-text-faint); padding: 8px 16px 12px; line-height: 1.45; }
@media (max-width: 860px) {
  .ff-charts,
  .ff-charts.wide-left { grid-template-columns: 1fr; }
}

/* -------------------------------- filters -------------------------------- */
.ff-filterbar {
  background: var(--ff-card); border: 1px solid var(--ff-border); border-radius: var(--ff-radius);
  box-shadow: var(--ff-shadow); padding: 12px 14px; margin-bottom: 14px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
}
.ff-filterbar select, .ff-filterbar input[type="text"] {
  padding: 8px 12px; border: 1px solid var(--ff-border); border-radius: var(--ff-radius-sm);
  font-size: .88rem; font-family: var(--ff-font); color: var(--ff-text); background: #fff;
  min-width: 140px;
}
.ff-filterbar select:focus, .ff-filterbar input:focus { outline: none; border-color: var(--ff-accent); box-shadow: 0 0 0 3px var(--ff-accent-soft); }
.ff-btn {
  /* inline-block, not the inline default: as an <a> the button was a plain
     inline box, so a label too long for one line (the /predictors CTA on a
     phone) broke across lines with the background painting only the first —
     the trailing words and the arrow sat outside the blue entirely. */
  display: inline-block;
  text-align: center;
  text-decoration: none;
  max-width: 100%;
  background: var(--ff-accent); color: #fff; border: none; padding: 9px 20px;
  border-radius: var(--ff-radius-sm); cursor: pointer; font-size: .88rem; font-weight: 600;
  font-family: var(--ff-font); transition: background .15s;
}
.ff-btn:hover { background: #1a5fc4; }
.ff-btn-ghost {
  color: var(--ff-text-soft); text-decoration: none; font-size: .85rem; padding: 9px 10px;
}
.ff-btn-ghost:hover { color: var(--ff-danger); }
.ff-result-count { font-size: .82rem; color: var(--ff-text-soft); margin: -6px 2px 12px; }

/* chip filters (server-side) */
.ff-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ff-chip {
  padding: 6px 13px; border-radius: 20px; border: 1px solid var(--ff-border);
  color: var(--ff-text); text-decoration: none; font-size: .82rem; background: #fff;
  transition: all .15s; font-weight: 500;
}
.ff-chip:hover { border-color: var(--ff-accent); color: var(--ff-accent); }
.ff-chip.active { background: var(--ff-primary); color: #fff; border-color: var(--ff-primary); }
.ff-chip-sep { color: var(--ff-border); margin: 0 2px; }

/* symbol autocomplete dropdown */
.ff-ac-wrap { position: relative; }
.ff-ac {
  position: absolute; top: calc(100% + 4px); left: 0; min-width: 260px; z-index: 60;
  background: #fff; border: 1px solid var(--ff-border); border-radius: var(--ff-radius-sm);
  box-shadow: var(--ff-shadow-hover); max-height: 280px; overflow: auto;
}
.ff-ac a { display: block; padding: 8px 12px; font-size: .84rem; color: var(--ff-text); text-decoration: none; }
.ff-ac a:hover, .ff-ac a.sel { background: var(--ff-accent-soft); }
.ff-ac .sym { font-weight: 700; color: var(--ff-primary); margin-right: 6px; }
.ff-ac .ind { color: var(--ff-text-faint); font-size: .74rem; float: right; }

/* ---------------------- wide-table breakout (desktop) ---------------------
   Dense financial tables — 15 quarters, 13-column peer grids — are the one
   thing on these pages that genuinely wants more room than the reading
   shell. .ff-bleed lets a card grow past .ff-page and stay centred on it;
   since the shell is itself centred, the card stays centred on screen.

   Apply it only to tables that are actually wide. A 6-column table stretched
   to 1700px reads worse than one at shell width, not better.

   No media query is needed and none should be added: max(100%, …) makes this
   a provable no-op whenever the shell is already the full viewport, which is
   every phone and most tablets. 100vw counts the scrollbar, so the 80px
   subtraction is what keeps a desktop breakout from scrolling the whole page
   sideways — the same failure base_news' .content min-width:0 guards against.
   Do not lower it. */
.ff-bleed {
  --ff-bleed-w: max(100%, min(1700px, 100vw - 80px));
  width: var(--ff-bleed-w);
  margin-left: calc((100% - var(--ff-bleed-w)) / 2);
  margin-right: calc((100% - var(--ff-bleed-w)) / 2);
}

/* --------------------------------- table --------------------------------- */
.ff-tablewrap { overflow-x: auto; border: 1px solid var(--ff-border); border-radius: var(--ff-radius); background: var(--ff-card); box-shadow: var(--ff-shadow); }
table.ff-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.ff-table th {
  background: #f4f6fa; text-align: left; padding: 10px 12px; font-size: .72rem;
  text-transform: uppercase; letter-spacing: .45px; color: #56607a;
  border-bottom: 1px solid var(--ff-border); white-space: nowrap;
  position: sticky; top: 0; z-index: 5;
}
table.ff-table td { padding: 10px 12px; border-bottom: 1px solid var(--ff-border-soft); vertical-align: middle; }
table.ff-table tbody:last-child tr:last-child td { border-bottom: none; }
table.ff-table tr.ff-row:hover { background: #f8fafc; }
th.ff-sort { cursor: pointer; user-select: none; }
th.ff-sort:hover { color: var(--ff-accent); }
th.ff-sort::after { content: ' ↕'; opacity: .35; font-size: .8em; }
th.ff-sort.asc::after { content: ' ↑'; opacity: 1; color: var(--ff-accent); }
th.ff-sort.desc::after { content: ' ↓'; opacity: 1; color: var(--ff-accent); }
th.ff-sort:focus-visible { outline: 2px solid var(--ff-accent); outline-offset: -2px; }

/* Mobile sort bar (market.js builds it for table[data-sortbar]).
   Hidden on desktop, where the clickable header row IS the control; shown
   only under the ff-cardable breakpoint, which hides <thead> and would
   otherwise leave a sortable table with nothing to sort it by. */
.ff-sortbar { display: none; }
@media (max-width: 768px) {
  .ff-sortbar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 10px 14px 2px; font-family: var(--ff-font);
  }
  .ff-sortbar label {
    font-size: .68rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .5px; color: var(--ff-text-faint);
  }
  .ff-sortbar select {
    flex: 1 1 150px; min-width: 0; font-family: inherit; font-size: .82rem;
    padding: 7px 9px; border: 1px solid var(--ff-border);
    border-radius: var(--ff-radius-sm); background: #fff; color: var(--ff-text);
  }
  .ff-sortdir {
    flex: none; font-family: inherit; font-size: .78rem; font-weight: 600;
    padding: 7px 11px; border: 1px solid var(--ff-border);
    border-radius: var(--ff-radius-sm); background: #fff;
    color: var(--ff-text-soft); cursor: pointer;
  }
  .ff-sortdir:disabled { opacity: .45; cursor: default; }
  .ff-sortdir:not(:disabled) { color: var(--ff-accent); border-color: var(--ff-accent); }
}

.ff-sym { font-weight: 700; color: #1d4ed8; text-decoration: none; }
.ff-sym:hover { text-decoration: underline; }
.ff-live { margin-left: 6px; font-size: .8rem; text-decoration: none; }
.ff-subtle { font-size: .74rem; color: var(--ff-text-faint); }
.ff-co { display: block; font-size: .72rem; color: var(--ff-text-faint); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ret-pos, .alpha-pos { color: var(--ff-success); font-weight: 700; }
.ret-neg, .alpha-neg { color: var(--ff-danger); font-weight: 700; }
.ret-na, .alpha-na { color: var(--ff-text-faint); }

/* score mini-bar */
.ff-score { min-width: 76px; }
.ff-score b { font-size: .86rem; }
.ff-score-bar { height: 4px; border-radius: 3px; background: var(--ff-neutral-soft); margin-top: 4px; overflow: hidden; }
.ff-score-bar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--ff-accent), #7c3aed); }

/* expand button */
.ff-expand {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 12px;
  border-radius: var(--ff-radius-sm); border: 1px solid var(--ff-primary);
  background: var(--ff-primary); color: #fff; font-size: .76rem; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: all .15s; font-family: var(--ff-font);
}
.ff-expand:hover { background: var(--ff-primary-2); }
.ff-expand.open { background: #fff; color: var(--ff-primary); }
.ff-expand .chev { transition: transform .18s; display: inline-block; }
.ff-expand.open .chev { transform: rotate(180deg); }

/* detail (expanded) row — toggled via the .open class (works in both table
   and mobile stacked-card layouts, unlike an inline display style) */
tr.ff-detail { background: #fbfcfe; display: none; }
tr.ff-detail.open { display: table-row; }
tr.ff-detail > td { padding: 0; }
.ff-detail-inner { padding: 16px 20px; }
.ff-detail-title { font-size: .86rem; color: #374151; margin-bottom: 12px; }
.ff-kv-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--ff-text-soft); margin: 12px 0 7px; }
.ff-kv-title:first-child { margin-top: 0; }
.ff-kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 9px; }
.ff-kv > div { background: #fff; border: 1px solid var(--ff-border-soft); border-radius: var(--ff-radius-sm); padding: 8px 10px; font-size: .8rem; }
.ff-kv b { display: block; color: var(--ff-text-soft); font-size: .66rem; text-transform: uppercase; letter-spacing: .35px; margin-bottom: 2px; font-weight: 600; }
.ff-flag-warn { color: var(--ff-warning-deep); font-weight: 600; }
.ff-flag-ok { color: var(--ff-success-deep); font-weight: 600; }

.ff-list { margin: 4px 0 6px; padding-left: 18px; font-size: .84rem; }
.ff-list li { margin: 3px 0; }
.ff-list.pos li { color: #15803d; }
.ff-list.risk li { color: #b91c1c; }
.ff-list.gov li { color: #9a3412; }
.ff-list.gaps li { color: var(--ff-text-soft); }

/* --------------------------------- pager --------------------------------- */
.ff-pager { display: flex; align-items: center; gap: 12px; justify-content: center; margin: 16px 0; font-size: .85rem; color: var(--ff-text-soft); flex-wrap: wrap; }
.ff-pager .current { background: var(--ff-primary); color: #fff; border-color: var(--ff-primary); padding: 6px 13px; border-radius: 20px; }

/* ------------------------------- accordion ------------------------------- */
details.ff-acc { background: var(--ff-card); border: 1px solid var(--ff-border); border-radius: var(--ff-radius); box-shadow: var(--ff-shadow); margin-bottom: 14px; }
details.ff-acc > summary {
  cursor: pointer; padding: 13px 16px; font-size: .92rem; font-weight: 600; color: var(--ff-primary);
  list-style: none; display: flex; align-items: center; gap: 8px;
}
details.ff-acc > summary::-webkit-details-marker { display: none; }
details.ff-acc > summary::after { content: '▾'; margin-left: auto; color: var(--ff-text-faint); transition: transform .18s; }
details.ff-acc[open] > summary::after { transform: rotate(180deg); }
details.ff-acc .ff-acc-body { border-top: 1px solid var(--ff-border); }

/* --------------------------------- toast --------------------------------- */
.ff-toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(90px);
  background: var(--ff-primary); color: #fff; border-radius: 30px; padding: 11px 22px;
  font-size: .88rem; font-weight: 600; font-family: var(--ff-font); box-shadow: 0 8px 24px rgba(16, 24, 40, .28);
  z-index: 1200; display: flex; align-items: center; gap: 9px; cursor: pointer;
  opacity: 0; transition: transform .3s ease, opacity .3s ease; border: 1px solid rgba(255,255,255,.15);
}
.ff-toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.ff-toast:hover { background: var(--ff-primary-2); }

/* ------------------------------- skeleton -------------------------------- */
.ff-skeleton { position: relative; overflow: hidden; background: var(--ff-neutral-soft); border-radius: 6px; min-height: 14px; }
.ff-skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .75), transparent);
  animation: ffshimmer 1.4s infinite; transform: translateX(-100%);
}
@keyframes ffshimmer { 100% { transform: translateX(100%); } }

/* ------------------------- lazy-loaded AI report -------------------------- */
.ff-report { background: #fff; border: 1px solid var(--ff-border-soft); border-radius: var(--ff-radius-sm); padding: 14px 18px; font-size: .85rem; line-height: 1.6; max-height: 560px; overflow: auto; color: #26303f; }
.ff-report h1, .ff-report h2, .ff-report h3, .ff-report h4 { margin: 14px 0 6px; line-height: 1.3; color: #15233b; }
.ff-report h1 { font-size: 1.1rem; } .ff-report h2 { font-size: 1.02rem; }
.ff-report h3 { font-size: .95rem; } .ff-report h4 { font-size: .88rem; }
.ff-report h1:first-child, .ff-report h2:first-child, .ff-report h3:first-child, .ff-report h4:first-child { margin-top: 0; }
/* Cap the running text, not the block: at the 1400px shell an uncapped
   paragraph runs ~180 characters a line. Tables inside the report keep the
   full width — they want it, prose does not. */
.ff-report p { margin: 6px 0; max-width: 78ch; }
.ff-report ul, .ff-report ol { margin: 6px 0 10px; padding-left: 22px; }
.ff-report li { margin: 3px 0; max-width: 78ch; }
.ff-report strong { color: #0f2740; }
.ff-report code { background: var(--ff-neutral-soft); padding: 1px 5px; border-radius: 4px; font-size: .82em; }
.ff-report table { border-collapse: collapse; margin: 8px 0; font-size: .82rem; width: 100%; }
.ff-report th, .ff-report td { border: 1px solid #e2e8f0; padding: 5px 9px; text-align: left; }
.ff-report th { background: #f4f6fa; }
.ff-report hr { border: 0; border-top: 1px solid var(--ff-border-soft); margin: 12px 0; }

/* -------------------------------- footnote ------------------------------- */
.ff-footnote { font-size: .76rem; color: var(--ff-text-faint); margin-top: 18px; line-height: 1.55; max-width: 95ch; }
.ff-section-title { font-size: 1.02rem; font-weight: 700; color: var(--ff-primary); margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }

/* ------------- corp-action type + date-label badges (hub page) ------------ */
.ff-badge.a-DIVIDEND { background: var(--ff-accent-soft); color: #1e40af; }
.ff-badge.a-RESULTS { background: var(--ff-success-soft); color: var(--ff-success-deep); }
.ff-badge.a-SPLIT, .ff-badge.a-BONUS { background: var(--ff-watch-soft); color: var(--ff-watch-deep); }
.ff-badge.a-BUYBACK { background: var(--ff-warning-soft); color: var(--ff-warning-deep); }
.ff-badge.a-RIGHTS { background: #fce7f3; color: #9d174d; }
.ff-badge.a-MERGER, .ff-badge.a-DEMERGER { background: #dbeafe; color: #1d4ed8; }
.ff-badge.a-OTHER { background: var(--ff-neutral-soft); color: var(--ff-neutral-deep); }
.ff-badge.dl { font-size: .66rem; }
.ff-badge.dl-ex { background: var(--ff-warning-soft); color: var(--ff-warning-deep); }
.ff-badge.dl-record { background: var(--ff-accent-soft); color: #1e40af; }
.ff-badge.dl-meeting { background: var(--ff-success-soft); color: var(--ff-success-deep); }
.ff-badge.dl-event { background: var(--ff-neutral-soft); color: var(--ff-neutral-deep); }

/* ----------------------- tab bar (corp-actions hub) ----------------------- */
.ff-tabs {
  display: flex; flex-wrap: wrap; gap: 5px;
  background: var(--ff-card); border: 1px solid var(--ff-border);
  border-radius: var(--ff-radius); box-shadow: var(--ff-shadow);
  padding: 6px; margin-bottom: 14px;
}
.ff-tabs a {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px; border-radius: var(--ff-radius-sm);
  color: var(--ff-text-soft); text-decoration: none;
  font-size: .85rem; font-weight: 500; white-space: nowrap; transition: all .15s;
}
.ff-tabs a:hover { background: var(--ff-accent-soft); color: var(--ff-accent); }
.ff-tabs a.active { background: var(--ff-primary); color: #fff; }
.ff-tabs .n {
  background: rgba(0, 0, 0, .06); border-radius: 12px; padding: 0 8px;
  font-size: .7rem; font-weight: 600; line-height: 1.7;
}
.ff-tabs a.active .n { background: rgba(255, 255, 255, .22); color: #fff; }

/* row action cell: AI expand + PDF chip */
td.ff-actcell { white-space: nowrap; text-align: right; }
.ff-pdf {
  display: inline-block; margin-left: 6px; padding: 4px 10px;
  border: 1px solid var(--ff-border); border-radius: var(--ff-radius-sm);
  color: var(--ff-text-soft); text-decoration: none; font-size: .74rem; font-weight: 600;
  transition: all .15s;
}
.ff-pdf:hover { color: var(--ff-accent); border-color: var(--ff-accent); background: var(--ff-accent-soft); }

/* today banner */
.ff-banner {
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(90deg, var(--ff-success-soft) 0%, #f2fdf7 100%);
  border-left: 4px solid var(--ff-success); padding: 11px 16px;
  font-weight: 600; color: var(--ff-success-deep); font-size: .9rem;
}

/* table section-divider row */
tr.ff-divider td {
  background: var(--ff-bg) !important; padding: 9px 12px !important;
  font-weight: 700; color: var(--ff-primary); font-size: .72rem;
  text-transform: uppercase; letter-spacing: .5px;
}

/* ------------- lazy-loaded per-row AI analysis (corp-actions) ------------- */
.ff-ai .ai-top { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin-bottom: 9px; }
.ff-ai .ai-h { font-weight: 700; font-size: .92rem; color: var(--ff-primary); margin-bottom: 6px; line-height: 1.4; }
.ff-ai .ai-s { font-size: .85rem; line-height: 1.6; color: #374151; margin-bottom: 10px; }
.ff-ai .ai-row { display: flex; gap: 8px; font-size: .82rem; line-height: 1.5; margin: 5px 0; }
.ff-ai .ai-row .lbl {
  flex: none; font-size: .66rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; color: var(--ff-text-soft); padding-top: 3px; width: 92px;
}
.ff-ai .figs { display: flex; flex-wrap: wrap; gap: 7px; margin: 9px 0; }
.ff-ai .fig {
  background: #fff; border: 1px solid var(--ff-border-soft); border-radius: var(--ff-radius-sm);
  padding: 5px 10px; font-size: .78rem;
}
.ff-ai .fig b { color: var(--ff-text-soft); font-weight: 600; }
.ff-ai .ai-watch {
  background: var(--ff-accent-soft); border-left: 3px solid var(--ff-accent);
  border-radius: 6px; padding: 9px 12px; font-size: .82rem; line-height: 1.55; margin-top: 10px;
}
.ff-ai .ai-risks { margin-top: 9px; font-size: .82rem; }
.ff-ai .ai-risks .lbl { color: var(--ff-warning-deep); font-weight: 700; font-size: .74rem; text-transform: uppercase; letter-spacing: .4px; }
.ff-ai .ai-risks ul { margin: 4px 0 0; padding-left: 18px; }
.ff-ai .ai-risks li { color: #92400e; margin: 2px 0; }
.ff-ai .ai-foot { margin-top: 10px; font-size: .76rem; color: var(--ff-text-faint); display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.ff-ai .ai-foot a { color: var(--ff-accent); text-decoration: none; font-weight: 600; }
.ff-ai .ai-foot a:hover { text-decoration: underline; }
.ff-ai .conf { font-size: .7rem; font-weight: 700; padding: 2px 9px; border-radius: 20px; }
.ff-ai .conf-high { background: var(--ff-success-soft); color: var(--ff-success-deep); }
.ff-ai .conf-medium { background: var(--ff-warning-soft); color: var(--ff-warning-deep); }
.ff-ai .conf-low { background: var(--ff-neutral-soft); color: var(--ff-neutral-deep); }

/* --------------------------- responsive: tables -------------------------- */
@media (max-width: 768px) {
  .ff-hero h1 { font-size: 1.3rem; }
  .ff-tabs a { font-size: .78rem; padding: 7px 10px; }

  /* filter bar: two controls a row, then the date picker (which renders far
     wider than a text input on mobile) on its own, then the two buttons
     sharing the last row rather than Reset dangling under a full-width Apply */
  .ff-filterbar { gap: 8px; }
  /* border-box or the 45% basis is content-only and the two controls, once
     their padding and border are added, no longer fit a 360px row */
  .ff-filterbar select, .ff-filterbar input { box-sizing: border-box; }
  .ff-filterbar select, .ff-filterbar input[type="text"] { flex: 1 1 45%; min-width: 0; }
  .ff-filterbar input[type="date"] { flex: 1 1 100%; min-width: 0; }
  .ff-filterbar .ff-btn { flex: 1 1 0; }
  .ff-filterbar .ff-btn-ghost {
    flex: 0 0 auto; border: 1px solid var(--ff-border);
    border-radius: var(--ff-radius-sm); padding: 9px 18px; text-align: center;
  }

  /* Stacked-card table: each main row becomes a card and every cell prints
     its own header from data-label.

     The label sits ABOVE its value, in a grid column. Beside it — the
     obvious layout — the label is only as wide as its own text, so "Date",
     "Details" and "Amount" each started their value at a different x and the
     card read as a ragged left edge with no column to scan down. Worse, a
     flex cell turns "<strong>Final</strong> · FY2025-26 · Ex: 20 Aug" into
     two flex items, so the long run of text wrapped in a narrow gutter
     beside the bold word instead of flowing under it. A block cell in a
     fixed grid column fixes both: one shared start position, and free text
     that wraps the whole width it was given. */
  table.ff-cardable { min-width: 0 !important; }
  table.ff-cardable thead { display: none; }
  table.ff-cardable tbody { display: block; }
  /* Card separator per ROW, not per tbody. Tables that group each row with
     its AI panel have one tbody a card, but /highs and friends put every row
     in a single tbody — those got no divider at all and their cards ran
     together. A rule on the row itself covers both shapes. */
  table.ff-cardable tr.ff-row { border-top: 1px solid var(--ff-border-soft); }
  table.ff-cardable tbody:first-of-type tr.ff-row:first-of-type { border-top: none; }
  /* auto-fit, not a fixed 2: a 360px phone still gets two columns, while a
     large phone or small tablet fills the width instead of stretching two
     half-empty ones across it */
  table.ff-cardable tr.ff-row {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
    gap: 9px 14px; padding: 13px 14px; align-items: start;
  }
  table.ff-cardable tr.ff-row td {
    display: block; min-width: 0; padding: 0; border: none;
    font-size: .84rem; line-height: 1.5; text-align: left;
  }
  table.ff-cardable tr.ff-row td[data-label]::before {
    content: attr(data-label); display: block; margin-bottom: 1px;
    font-size: .62rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .5px; color: var(--ff-text-faint);
  }
  /* identity, free text and the button row want the full card width */
  table.ff-cardable tr.ff-row td.ff-cell-main,
  table.ff-cardable tr.ff-row td.ff-actcell,
  table.ff-cardable tr.ff-row td[data-label="Details"],
  table.ff-cardable tr.ff-row td[data-label="Notes"] { grid-column: 1 / -1; }
  table.ff-cardable tr.ff-row td[data-label="Notes"] { max-width: none !important; }
  table.ff-cardable tr.ff-row .ff-sym { font-size: .95rem; line-height: 1.35; }
  /* the desktop 180px ellipsis truncates company names that have room to
     wrap once the cell spans the whole card */
  table.ff-cardable tr.ff-row .ff-co { max-width: none; white-space: normal; overflow: visible; }
  table.ff-cardable tr.ff-row td.ff-actcell {
    display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px;
  }
  /* two labelled buttons need no third label over them */
  table.ff-cardable tr.ff-row td.ff-actcell::before { content: none; }
  table.ff-cardable tr.ff-row td.ff-actcell .ff-pdf { margin-left: 0; }
  table.ff-cardable tr.ff-row td.ff-actcell .ff-expand,
  table.ff-cardable tr.ff-row td.ff-actcell .ff-pdf {
    padding: 8px 16px; font-size: .79rem; line-height: 1.5;
  }
  /* the panel's near-white tint alone does not read as a separate layer on a
     phone, where it has no table row above it to contrast against */
  table.ff-cardable tr.ff-detail.open { display: block; border-top: 1px solid var(--ff-border-soft); }
  table.ff-cardable tr.ff-detail > td { display: block; }

  /* Corporate-actions today/upcoming rows. These six columns describe
     themselves — a date, a company, a type badge, a details line, an amount
     and two buttons — so the generic label column is noise. Lead with the
     deadline badge and the company name instead, and pair the action badge
     with the amount on one line. */
  table.ff-ca-cards tr.ff-row {
    grid-template-columns: minmax(0, 1fr) auto; gap: 7px 12px; padding: 14px;
  }
  table.ff-ca-cards tr.ff-row td[data-label]::before { content: none; }
  table.ff-ca-cards tr.ff-row td[data-label="Date"] {
    grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center;
    gap: 7px; font-size: .8rem; color: var(--ff-text-soft);
  }
  table.ff-ca-cards tr.ff-row td[data-label="Date"] br { display: none; }
  table.ff-ca-cards tr.ff-row td[data-label="Date"] b { color: var(--ff-text); font-weight: 600; }
  table.ff-ca-cards tr.ff-row td[data-label="Date"] .ff-badge.dl { margin-left: auto; }
  table.ff-ca-cards tr.ff-row td[data-label="Action"] { grid-column: 1; align-self: center; }
  table.ff-ca-cards tr.ff-row td[data-label="Amount"] {
    grid-column: 2; align-self: center; text-align: right;
    font-size: .95rem; font-weight: 700; color: var(--ff-text);
  }
  /* Details is before Amount in source order but belongs under it. It spans
     both columns, so auto-placement cannot leave it beside the action badge;
     ordering it after Amount is what lets badge and amount share one line. */
  table.ff-ca-cards tr.ff-row td[data-label="Details"] {
    order: 1; font-size: .83rem; line-height: 1.55; color: var(--ff-text-soft);
  }
  table.ff-ca-cards tr.ff-row td[data-label="Details"] strong { color: var(--ff-text); font-weight: 600; }
  table.ff-ca-cards tr.ff-row td.ff-actcell { order: 2; margin-top: 3px; }
  /* a lone right-aligned em dash reads as a stray mark once the column
     header is gone — an action with no amount just shows none */
  table.ff-ca-cards tr.ff-row td.ff-empty { display: none; }

  /* expanded AI panel: the 92px label gutter leaves ~7 words a line here */
  .ff-detail-inner { padding: 13px 14px; }
  .ff-ai .ai-row { flex-direction: column; gap: 1px; margin: 8px 0; }
  .ff-ai .ai-row .lbl { width: auto; padding-top: 0; }
}
