/* ============================================================================
   fiduciary-score.css — Reg BI Fiduciary Score widget + methodology drawer.
   All rules scoped under .fid / .fid-drawer. Custom properties are defined on
   the .fid root so the widget is self-contained wherever it mounts.
   ============================================================================ */

/* ----------------------------------------------------------------------------
   Advisor Tools page wrapper (.v2-fid-tool) — follows the same layout pattern
   as .v2-sec-lookup / .v2-corr tool panes in app-shell.css.
---------------------------------------------------------------------------- */

/* Pane override — same unlayered rule every tool uses to beat the
   .v2-tool-pane defaults in v2-overlay.css and make the page scrollable. */
#v2-fiduciary-score.v2-tool-pane.active {
  display: block !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  height: 100%;
}

.v2-fid-tool {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 24px 40px;
}

/* Shell .v2-card__body defaults to flex-stretch (explorer-style cards);
   cards on this page must shrink-wrap their content instead. */
.v2-fid-tool .v2-card,
.v2-fid-tool .v2-card__body {
  min-height: 0;
  flex: none;
}

@media (max-width: 768px) {
  .v2-fid-tool { padding: 12px 12px 32px; }
}

/* ---------------------------------------------------------------------------- */

.fid {
  /* Inherit the v2 shell theme; --muted and --accent cascade from :root
     (tenant accent overrides included). */
  --ink: var(--text, #0f172a);
  --ring: var(--border, #e2e8f0);
  --card-bg: var(--bg-elev, #ffffff);
  /* severity chip palettes */
  --sev-high-bg: #fef2f2;
  --sev-high-bd: #fecaca;
  --sev-high-fg: #b91c1c;
  --sev-med-bg: #fffbeb;
  --sev-med-bd: #fde68a;
  --sev-med-fg: #b45309;
  --sev-low-bg: #f1f5f9;
  --sev-low-bd: #cbd5e1;
  --sev-low-fg: #475569;

  position: relative;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}

/* ----------------------------------------------------------------------------
   Header
---------------------------------------------------------------------------- */

.fid-hdr {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.fid-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

.fid-ticker {
  color: var(--accent);
  font-weight: 700;
}

.fid-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.fid .hdr-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.fid-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  background: var(--card-bg);
  border: 1px solid var(--ring);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.fid-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

/* ----------------------------------------------------------------------------
   Layout grid + cards
---------------------------------------------------------------------------- */

.fid-grid {
  display: grid;
  grid-template-columns: 280px 1fr 1fr;
  gap: 14px;
  align-items: stretch;
}

.fid-card {
  background: var(--card-bg);
  border: 1px solid var(--ring);
  border-radius: 12px;
  padding: 16px;
}

.fid-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.fid-cap-note {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

.fid-info-btn {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}

.fid-info-btn:hover { color: var(--accent); }

/* ----------------------------------------------------------------------------
   Gauge
---------------------------------------------------------------------------- */

.fid-card--gauge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.fid-gauge-wrap {
  position: relative;
  width: 200px;
  height: 200px;
}

#fid-gauge { width: 200px; height: 200px; }

.fid-gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  pointer-events: none;
}

.fid-gauge-num {
  font-size: 40px;
  font-weight: 800;
  line-height: 1;
}

.fid-gauge-foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.fid-formula {
  font-size: 12px;
  color: var(--muted);
}

.fid-formula b { color: var(--ink); }

.fid-delta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
}

.fid-delta--up   { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.fid-delta--down { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* Band pills (shared by gauge, drawer legend) */
.fid .band,
.fid-drawer .band {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid transparent;
}

.fid .band-excellent, .fid-drawer .band-excellent { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.fid .band-good,      .fid-drawer .band-good      { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.fid .band-watchlist, .fid-drawer .band-watchlist { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.fid .band-poor,      .fid-drawer .band-poor      { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }

/* ----------------------------------------------------------------------------
   Pillars
---------------------------------------------------------------------------- */

.fid-pillar { margin-bottom: 14px; }
.fid-pillar:last-child { margin-bottom: 0; }

.fid-pillar-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.fid-pillar-label { font-weight: 600; }

.fid-weight {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  background: #f1f5f9;
  border-radius: 999px;
}

.fid-pillar-score { font-weight: 800; font-size: 14px; }

.fid-bar {
  height: 8px;
  background: #f1f5f9;
  border-radius: 999px;
  overflow: hidden;
}

.fid-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.5s ease-out;
}

.fid-pillar-explainer {
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
}

.fid-pillar--missing .fid-pillar-label,
.fid-pillar--missing .fid-pillar-score { color: #94a3b8; }
.fid-pillar--missing .fid-bar { background: #f8fafc; border: 1px dashed var(--ring); }

/* ----------------------------------------------------------------------------
   Penalty flag chips
---------------------------------------------------------------------------- */

.fid-chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fid-chip {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--ring);
  background: var(--card-bg);
  cursor: pointer;
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.fid-chip:hover { box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08); }

.fid-chip-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fid-chip-label { font-weight: 700; font-size: 12px; }

.fid-chip-pts {
  margin-left: auto;
  font-weight: 800;
  font-size: 12px;
  white-space: nowrap;
}

.fid-chip-details {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
}

.fid-chip.sev-high { background: var(--sev-high-bg); border-color: var(--sev-high-bd); }
.fid-chip.sev-high .fid-chip-pts,
.fid-chip.sev-high .fid-chip-label { color: var(--sev-high-fg); }

.fid-chip.sev-med { background: var(--sev-med-bg); border-color: var(--sev-med-bd); }
.fid-chip.sev-med .fid-chip-pts,
.fid-chip.sev-med .fid-chip-label { color: var(--sev-med-fg); }

.fid-chip.sev-low { background: var(--sev-low-bg); border-color: var(--sev-low-bd); }
.fid-chip.sev-low .fid-chip-pts,
.fid-chip.sev-low .fid-chip-label { color: var(--sev-low-fg); }

.fid-noflags {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px;
  color: #15803d;
  font-weight: 600;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 9px;
}

/* ----------------------------------------------------------------------------
   Empty / loading states
---------------------------------------------------------------------------- */

.fid-loading,
.fid-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 200px;
  color: var(--muted);
  background: var(--card-bg);
  border: 1px dashed var(--ring);
  border-radius: 12px;
}

.fid-empty i { font-size: 30px; color: #cbd5e1; }
.fid-empty-msg { font-weight: 600; }

/* ============================================================================
   Methodology drawer — slide-over (right on desktop, full sheet < 680px)
   ============================================================================ */

.fid-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.fid-drawer-overlay.is-open { opacity: 1; }

.fid-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 10051;
  width: 480px;
  max-width: 96vw;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  box-shadow: -8px 0 28px rgba(15, 23, 42, 0.18);
  transform: translateX(100%);
  transition: transform 0.2s ease;
  color: #0f172a;
  font-size: 13px;
  line-height: 1.5;
}

.fid-drawer.is-open { transform: translateX(0); }

body.fid-drawer-lock { overflow: hidden; }

.fid-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.fid-drawer-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.fid-drawer-close {
  border: none;
  background: none;
  font-size: 24px;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  padding: 0 4px;
}

.fid-drawer-close:hover { color: #0f172a; }

.fid-drawer-body {
  padding: 16px 18px 24px;
  overflow-y: auto;
  flex: 1;
}

.fid-drawer-overview { color: #334155; }

.fid-drawer-formula {
  padding: 9px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  color: #334155;
}

.fid-drawer-bands {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 4px;
}

.fid-drawer-section {
  margin: 20px 0 8px;
  padding-bottom: 4px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
  border-bottom: 1px solid #e2e8f0;
}

.fid-drawer-subhead {
  margin: 14px 0 6px;
  font-size: 12px;
  font-weight: 700;
  color: #0964a0;
}

.fid-drawer-pillar {
  padding: 10px 0;
  border-bottom: 1px dashed #e2e8f0;
}

.fid-drawer-pillar:last-of-type { border-bottom: none; }

.fid-drawer-pillar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.fid-drawer-pillar-label { font-weight: 700; }

.fid-drawer-pillar p { margin: 4px 0 6px; color: #475569; }

.fid-drawer-inputs {
  list-style: none;
  margin: 0;
  padding: 0;
}

.fid-drawer-inputs li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  color: #334155;
  font-size: 12px;
}

.fid-drawer-flag {
  padding: 9px 10px;
  margin-bottom: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  scroll-margin-top: 16px;
}

.fid-drawer-flag-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fid-drawer-flag .fid-chip-label { font-size: 12px; font-weight: 700; }
.fid-drawer-flag .fid-chip-pts { margin-left: auto; font-weight: 800; font-size: 12px; }
.fid-drawer-flag p { margin: 5px 0 0; color: #475569; font-size: 12px; }

.fid-sev {
  padding: 1px 8px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  border-radius: 999px;
  border: 1px solid transparent;
}

.fid-sev.sev-high { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.fid-sev.sev-med  { background: #fffbeb; border-color: #fde68a; color: #b45309; }
.fid-sev.sev-low  { background: #f1f5f9; border-color: #cbd5e1; color: #475569; }

/* Anchor highlight pulse when opened from a penalty chip */
@keyframes fidFlash {
  0%   { background: #fef9c3; border-color: #fde047; }
  100% { background: transparent; border-color: #e2e8f0; }
}

.fid-drawer-flag.fid-flash { animation: fidFlash 1.6s ease-out 1; }

.fid-drawer-notes {
  margin: 0;
  padding-left: 18px;
  color: #475569;
}

.fid-drawer-notes li { margin-bottom: 4px; }

.fid-drawer-foot {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}

.fid-disclaimer {
  margin: 0 0 8px;
  font-size: 11px;
  color: #64748b;
  font-style: italic;
}

.fid-drawer-print {
  font-size: 12px;
  font-weight: 600;
  color: #0964a0;
}

/* ----------------------------------------------------------------------------
   Mobile: full-screen sheet under 680px
---------------------------------------------------------------------------- */

@media (max-width: 680px) {
  .fid-grid { grid-template-columns: 1fr; }

  .fid-drawer {
    width: 100vw;
    max-width: 100vw;
  }
}

@media (max-width: 1100px) and (min-width: 681px) {
  .fid-grid { grid-template-columns: 280px 1fr; }
  .fid-card--flags { grid-column: 1 / -1; }
}

/* ----------------------------------------------------------------------------
   Grid mode (List scoring) — header toggle, loaders, notice, grid renderers
---------------------------------------------------------------------------- */

.fidg-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* Mode toggle — small segmented control */
.fidg-mode-toggle {
  display: inline-flex;
  flex: none;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-elev, #ffffff);
}

.fidg-mode-btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted, #64748b);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.fidg-mode-btn + .fidg-mode-btn {
  border-left: 1px solid var(--border, #e2e8f0);
}

.fidg-mode-btn:hover { color: var(--text, #0f172a); }

.fidg-mode-btn--active {
  background: var(--accent, #0964a0);
  color: #fff !important;
}

/* Universe-type toggle — mirrors the mode segmented control */
.fidg-uni-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted, #64748b);
}

.fidg-uni-toggle {
  display: inline-flex;
  flex: none;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-elev, #ffffff);
}

.fidg-uni-btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted, #64748b);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.fidg-uni-btn + .fidg-uni-btn {
  border-left: 1px solid var(--border, #e2e8f0);
}

.fidg-uni-btn:hover { color: var(--text, #0f172a); }

.fidg-uni-btn--active {
  background: var(--accent, #0964a0);
  color: #fff !important;
}

/* Watchlist / model loaders row */
.fidg-loaders {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.fidg-loader {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted, #64748b);
}

.fidg-loader__select {
  max-width: 260px;
  padding: 6px 8px;
  font-size: 12.5px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 6px;
  background: var(--bg-elev, #ffffff);
  color: var(--text, #0f172a);
}

.fidg-loader-hint {
  font-size: 12px;
  color: var(--muted, #64748b);
  font-style: italic;
}

/* Ticker list upload / paste panel */
.fidg-upload-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  background: var(--surface-2, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
}

/* The author display:flex above otherwise overrides the UA [hidden] rule. */
.fidg-upload-panel[hidden] {
  display: none;
}

.fidg-upload-file {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: var(--v2-primary, #2563eb);
  border: 1px solid var(--v2-primary, #2563eb);
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.fidg-upload-file:hover {
  background: var(--v2-primary-dark, #1d4ed8);
  border-color: var(--v2-primary-dark, #1d4ed8);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.fidg-upload-file i {
  font-size: 12px;
}

.fidg-upload-or {
  font-size: 12px;
  color: var(--muted, #64748b);
}

.fidg-upload-textarea {
  width: 100%;
  resize: vertical;
  padding: 8px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text, #0f172a);
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 6px;
}

.fidg-upload-actions {
  display: flex;
  gap: 8px;
}

/* Unresolved-inputs notice */
.fidg-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid color-mix(in srgb, var(--warning, #d97706) 40%, transparent);
  background: color-mix(in srgb, var(--warning, #d97706) 8%, transparent);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text, #0f172a);
}

.fidg-notice i { color: var(--warning, #d97706); }

.fidg-notice__close {
  appearance: none;
  border: 0;
  background: transparent;
  margin-left: auto;
  font-size: 16px;
  line-height: 1;
  color: var(--muted, #64748b);
  cursor: pointer;
  padding: 2px 6px;
}

.fidg-notice__close:hover { color: var(--text, #0f172a); }

/* Loading / error states inside the grid mount */
.fidg-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px 16px;
  font-size: 13px;
  color: var(--muted, #64748b);
}

.fidg-loading--error { color: #dc2626; }

/* --- Grid rows --- */

.fidg-cat-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  height: 100%;
  padding: 0 12px;
  background: color-mix(in srgb, var(--accent, #0964a0) 9%, var(--bg-elev, #ffffff));
  border-left: 3px solid var(--accent, #0964a0);
}

.fidg-cat-header__name {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text, #0f172a);
  line-height: 34px;
}

.fidg-cat-header__meta {
  font-size: 11px;
  color: var(--muted, #64748b);
}

.ag-theme-balham .fidg-row--peer,
.ag-theme-balham .fidg-row--bench {
  background: color-mix(in srgb, var(--muted, #64748b) 7%, transparent);
  font-style: italic;
}

.ag-theme-balham .fidg-row--bench {
  border-bottom: 2px solid var(--border, #e2e8f0) !important;
}

.fidg-ctx-label {
  font-size: 11.5px;
  color: var(--muted, #64748b);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.fidg-ctx-num {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted, #64748b);
  font-variant-numeric: tabular-nums;
}

/* --- Cells --- */

.fidg-cell-center { text-align: center; }
.fidg-cell-right { text-align: right; }

/* Vertically center only the taller chip cells (Score pill, Flags), which
   otherwise sit on the text baseline in the tall fund rows. Number/text cells
   center via line-height and bar/two-line cells via height:100%, so leaving
   those as plain cells avoids collapsing the flex-based bar renderer. */
.ag-theme-balham .ag-cell.fidg-cell-chip,
.ag-theme-balham .ag-cell.fidg-cell-flags {
  display: flex;
  align-items: center;
}
.ag-theme-balham .ag-cell.fidg-cell-chip  { justify-content: center; }
.ag-theme-balham .ag-cell.fidg-cell-flags { justify-content: flex-start; }

.fidg-ticker {
  font-weight: 700;
  color: var(--accent, #0964a0);
  cursor: pointer;
  text-decoration: underline dotted transparent;
  text-underline-offset: 3px;
}

.fidg-ticker:hover { text-decoration-color: currentColor; }

.fidg-bench-ticker {
  font-weight: 600;
  font-size: 11.5px;
  color: var(--muted, #64748b);
}

.fidg-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fidg-num {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.fidg-muted { color: var(--muted, #94a3b8); }

.fidg-rank {
  font-size: 10.5px;
  color: var(--muted, #64748b);
  font-variant-numeric: tabular-nums;
}

.fidg-penalty {
  font-weight: 700;
  color: #dc2626;
  font-variant-numeric: tabular-nums;
}

/* Score pill (band-colored) */
.fidg-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.fidg-pill--outline {
  background: transparent;
  border: 1.5px solid currentColor;
  height: 22px;
  font-size: 11.5px;
}

/* Two-line cell (cost score + raw ER) */
.fidg-two-line {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.25;
  height: 100%;
}

.fidg-two-line__main {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.fidg-two-line__sub {
  font-size: 10px;
  color: var(--muted, #64748b);
  font-variant-numeric: tabular-nums;
}

/* Mini horizontal pillar bar */
.fidg-bar-cell {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 100%;
}

.fidg-bar {
  flex: 1;
  height: 7px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--muted, #64748b) 18%, transparent);
  overflow: hidden;
}

.fidg-bar__fill {
  height: 100%;
  border-radius: 99px;
}

.fidg-bar-num {
  font-size: 11.5px;
  font-weight: 600;
  min-width: 20px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Flag chips — severity colored, clickable (opens methodology drawer) */
.fidg-flag {
  display: inline-flex;
  align-items: center;
  margin: 0 4px 0 0;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid transparent;
}

.fidg-flag--high {
  background: rgba(220, 38, 38, 0.12);
  border-color: rgba(220, 38, 38, 0.45);
  color: #dc2626;
}

.fidg-flag--med {
  background: rgba(217, 119, 6, 0.12);
  border-color: rgba(217, 119, 6, 0.45);
  color: #d97706;
}

.fidg-flag--low {
  background: rgba(100, 116, 139, 0.12);
  border-color: rgba(100, 116, 139, 0.45);
  color: var(--muted, #64748b);
}

.fidg-flag:hover { filter: brightness(1.1); }

/* KPI band-distribution value */
.fidg-kpi-bands { font-variant-numeric: tabular-nums; }

@media (max-width: 680px) {
  .fidg-page-header { flex-direction: column; }
  .fidg-loader__select { max-width: 100%; }
}

/* ----------------------------------------------------------------------------
   Print: when the drawer is open, print the methodology content only
---------------------------------------------------------------------------- */

@media print {
  /* Drawer open: print ONLY the methodology. The drawer is portaled to be a
     direct child of <body>, so hide every other body child (app shell,
     overlay, everything) and let the drawer flow as a normal document. */
  body.fid-drawer-lock { overflow: visible !important; }
  body.fid-drawer-lock > *:not(.fid-drawer) { display: none !important; }

  body.fid-drawer-lock .fid-drawer {
    position: static !important;
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    height: auto !important;
    transform: none !important;
    box-shadow: none !important;
  }

  body.fid-drawer-lock .fid-drawer-body {
    overflow: visible !important;
  }

  body.fid-drawer-lock .fid-drawer-close,
  body.fid-drawer-lock .fid-drawer-print { display: none !important; }

  /* Scorecard print (drawer closed): hide interactive-only affordances */
  .fid .hdr-actions,
  .fid-info-btn { display: none !important; }
}

/* ----------------------------------------------------------------------------
   Report options modal
---------------------------------------------------------------------------- */

.fidg-modal[hidden] { display: none; }

.fidg-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.fidg-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.fidg-modal__dialog {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--ring, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  overflow: hidden;
}

.fidg-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--ring, #e2e8f0);
}

.fidg-modal__header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink, #0f172a);
}

.fidg-modal__header h3 i { color: var(--accent, #2563eb); margin-right: 6px; }

.fidg-modal__close {
  border: none;
  background: transparent;
  color: var(--muted, #64748b);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.fidg-modal__close:hover { color: var(--ink, #0f172a); }

.fidg-modal__body {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.fidg-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fidg-field__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted, #64748b);
}

.fidg-field__input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--ink, #0f172a);
  background: var(--card-bg, #fff);
  border: 1px solid var(--ring, #e2e8f0);
  border-radius: 8px;
}

.fidg-field__input:focus {
  outline: none;
  border-color: var(--accent, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.fidg-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink, #0f172a);
  cursor: pointer;
}

.fidg-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--ring, #e2e8f0);
  background: var(--bg, #f8fafc);
}
