/* =====================================================================
   fin.css — Petrizzio · Command Finance Dashboard
   Bloomberg Terminal meets glassmorphism — premium 2026 edition.
   Deep navy + mint/teal accent. Stripe / Brex / Airbase aesthetic.
   ?v=20260507a
   ===================================================================== */

/* ── CSS Custom Properties ──────────────────────────────────────────── */
:root {
  --bg:              #050c1c;
  --card:            rgba(13, 27, 53, 0.85);
  --card-solid:      #0d1b35;
  --card-hover:      rgba(18, 32, 64, 0.95);
  --accent:          #00c896;
  --accent2:         #3b82f6;
  --warn:            #f59e0b;
  --danger:          #ef4444;
  --t1:              #f0f6ff;
  --t2:              #94afd4;
  --t3:              #4a6a8a;
  --border:          rgba(0, 200, 150, 0.15);
  --border-subtle:   rgba(0, 200, 150, 0.07);
  --glow:            rgba(0, 200, 150, 0.08);
  --glow-strong:     rgba(0, 200, 150, 0.18);
  --glow-blue:       rgba(59, 130, 246, 0.08);
  --gradient-accent: linear-gradient(135deg, #00c896, #3b82f6);
  --gradient-card:   linear-gradient(135deg, rgba(0,200,150,0.2), rgba(59,130,246,0.08));
  --gradient-hero:   linear-gradient(135deg, rgba(0,200,150,0.3), rgba(59,130,246,0.15));
  --sidebar-w:       200px;
  --radius:          1rem;
  --radius-sm:       0.5rem;
  --gap:             1rem;
  --transition:      0.18s cubic-bezier(0.4, 0, 0.2, 1);

  /* color-mix() alpha variants — 2026 CSS */
  --accent-a06:  color-mix(in srgb, #00c896 6%,  transparent);
  --accent-a10:  color-mix(in srgb, #00c896 10%, transparent);
  --accent-a15:  color-mix(in srgb, #00c896 15%, transparent);
  --accent-a20:  color-mix(in srgb, #00c896 20%, transparent);
  --accent-a30:  color-mix(in srgb, #00c896 30%, transparent);
  --warn-a08:    color-mix(in srgb, #f59e0b 8%,  transparent);
  --warn-a15:    color-mix(in srgb, #f59e0b 15%, transparent);
  --danger-a08:  color-mix(in srgb, #ef4444 8%,  transparent);
  --danger-a15:  color-mix(in srgb, #ef4444 15%, transparent);
}

/* ── Keyframes ──────────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(1.4); }
}

@keyframes skeleton {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-4px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Reset & Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--t1);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ── Sidebar ────────────────────────────────────────────────────────── */
.fin-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: linear-gradient(180deg, #04091a 0%, #080f22 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
  /* Subtle inner glow on the right edge */
  box-shadow: 1px 0 0 0 rgba(0, 200, 150, 0.06), 4px 0 24px rgba(0,0,0,0.4);
}

/* Tiny decorative accent line at the top of sidebar */
.fin-sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-accent);
  opacity: 0.6;
}

.fin-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}

.fin-logo-icon {
  font-size: 1.5rem;
  line-height: 1;
  filter: drop-shadow(0 0 6px rgba(0, 200, 150, 0.4));
}

/* CSS-only brand mark — gradient square with a mini trend-line inside */
.fin-logo-mark {
  display: inline-block;
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, #00c896 0%, #3b82f6 100%);
  border-radius: 7px;
  position: relative;
  flex-shrink: 0;
  box-shadow:
    0 0 12px rgba(0, 200, 150, 0.30),
    0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Trend-line bars inside the mark */
.fin-logo-mark::before {
  content: '';
  position: absolute;
  bottom: 5px;
  left: 4px;
  right: 4px;
  height: 2px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 1px;
}

.fin-logo-mark::after {
  content: '';
  position: absolute;
  bottom: 9px;
  left: 4px;
  right: 4px;
  height: 2px;
  /* Ascending step line using clip-path */
  background: rgba(255, 255, 255, 0.85);
  clip-path: polygon(0 100%, 30% 100%, 30% 40%, 65% 40%, 65% 0%, 100% 0%, 100% 30%, 65% 30%, 65% 70%, 30% 70%, 30% 130%, 0 130%);
  border-radius: 1px;
}

.fin-logo-text {
  font-size: 0.75rem;
  color: var(--t2);
  line-height: 1.3;
}

.fin-logo-text strong {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: -0.01em;
}

/* ── Sidebar Nav ────────────────────────────────────────────────────── */
.fin-nav {
  flex: 1;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.fin-nav-link {
  display: flex;
  align-items: center;
  padding: 0.6rem 1rem;
  color: var(--t2);
  text-decoration: none;
  font-size: 0.82rem;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-right: 0.5rem;
  transition: color var(--transition), background var(--transition),
              border-color var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}

.fin-nav-link:hover {
  color: var(--t1);
  background: rgba(0, 200, 150, 0.06);
  border-left-color: rgba(0, 200, 150, 0.3);
}

.fin-nav-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(0, 200, 150, 0.10);
  font-weight: 600;
  animation: slideIn 0.2s ease both;
}

/* Active link glow */
.fin-nav-link.active::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 100%;
  background: radial-gradient(ellipse at right, rgba(0,200,150,0.12) 0%, transparent 70%);
  pointer-events: none;
}

/* ── Sidebar Bottom ─────────────────────────────────────────────────── */
.fin-sidebar-bottom {
  padding: 1rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}

.fin-avatar {
  font-size: 0.78rem;
  color: var(--t3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
  transition: color var(--transition);
}

.fin-avatar:hover { color: var(--t2); }

.fin-logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--t3);
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.78rem;
  transition: color var(--transition), border-color var(--transition),
              background var(--transition);
}

.fin-logout:hover {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.06);
}

/* ── Main Content ───────────────────────────────────────────────────── */
.fin-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ── Header ─────────────────────────────────────────────────────────── */
.fin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(5, 12, 28, 0.85);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 1rem;
  /* Scanline overlay — ultra-subtle horizontal line pattern */
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 3px,
      rgba(0, 200, 150, 0.006) 3px,
      rgba(0, 200, 150, 0.006) 4px
    );
}

/* Bottom accent glow line on header */
.fin-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(0,200,150,0.25) 30%,
    rgba(59,130,246,0.15) 70%,
    transparent 100%
  );
}

.fin-header-left {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.fin-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--t1);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.fin-period {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.fin-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ── Demo Badge ─────────────────────────────────────────────────────── */
.fin-badge-mock {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: var(--warn);
  font-size: 0.73rem;
  font-weight: 600;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  cursor: help;
  white-space: nowrap;
  letter-spacing: 0.03em;
  /* Subtle pulse animation */
  animation: badge-pulse 3s ease-in-out infinite;
  position: relative;
}

@keyframes badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
  50%       { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.08); }
}

/* ── Select / Filter ────────────────────────────────────────────────── */
.fin-select {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--t1);
  padding: 0.32rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  backdrop-filter: blur(8px);
}

.fin-select:hover,
.fin-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 200, 150, 0.08);
}

/* ── Tab Bar ────────────────────────────────────────────────────────── */
.fin-tabs {
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(5, 12, 28, 0.5);
  backdrop-filter: blur(8px);
  position: relative;
  gap: 0;
}

.fin-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--t3);
  padding: 0.75rem 1.2rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
  margin-bottom: -1px;
  position: relative;
  letter-spacing: 0.01em;
}

.fin-tab:hover { color: var(--t2); }

.fin-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 700;
}

/* Active tab glow underline */
.fin-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-accent);
  border-radius: 2px 2px 0 0;
  filter: blur(1px);
  opacity: 0.5;
}

/* ── Content Area ───────────────────────────────────────────────────── */
.fin-content {
  flex: 1;
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
}

/* ── Tab Sections ───────────────────────────────────────────────────── */
.fin-section {
  display: none;
}

.fin-section.active {
  display: block;
  animation: fadeUp 0.25s ease both;
}

/* ── Bento Grid ─────────────────────────────────────────────────────── */
.fin-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap);
}

.span1 { grid-column: span 1; }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
.span4 { grid-column: span 4; }

/* ── Cards — Glassmorphism + gradient border ─────────────────────────── */
.fcard {
  background:
    linear-gradient(var(--card), var(--card)) padding-box,
    linear-gradient(135deg,
      color-mix(in srgb, #00c896 18%, transparent),
      color-mix(in srgb, #3b82f6  7%, transparent)
    ) border-box;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 1.25rem;
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.25),
    0 4px 16px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

/* Subtle radial glow at top-left for depth */
.fcard::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top left,
    color-mix(in srgb, #00c896 4%, transparent) 0%,
    transparent 65%
  );
  pointer-events: none;
  border-radius: inherit;
}

.fcard:hover {
  transform: translateY(-2px);
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.3),
    0 12px 40px rgba(0, 0, 0, 0.35),
    0 0 0 1px color-mix(in srgb, #00c896 14%, transparent),
    0 4px 20px var(--glow);
}

/* ── Card Title ─────────────────────────────────────────────────────── */
.fcard-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--t2);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.25rem;
  text-wrap: balance;
}

/* ── KPI Hero Cards ─────────────────────────────────────────────────── */
.kpi-hero {
  background:
    linear-gradient(var(--card), var(--card)) padding-box,
    linear-gradient(135deg,
      color-mix(in srgb, #00c896 30%, transparent),
      color-mix(in srgb, #3b82f6 15%, transparent)
    ) border-box;
  border: 1px solid transparent;
  position: relative;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.3),
    0 6px 24px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(0, 200, 150, 0.06);
}

/* Top gradient accent bar for hero cards */
.kpi-hero::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-accent);
  border-radius: var(--radius) var(--radius) 0 0;
  opacity: 0.85;
}

/* ── KPI Typography ─────────────────────────────────────────────────── */
.kpi-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--t3);
  text-wrap: balance;
}

/*
 * kpi-value: NO gradient text.
 * Gradient text prevents JS setColor() from showing status-based
 * coloring (green/yellow/red). Color defaults to --accent (mint);
 * JS overrides to status color as needed.
 */
.kpi-value {
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  animation: fadeUp 0.4s ease both;
}

.kpi-value-sm {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--t2);
  font-variant-numeric: tabular-nums;
}

/* ── KPI Delta Badge ─────────────────────────────────────────────────── */
.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.kpi-delta.pos {
  background: rgba(0, 200, 150, 0.12);
  color: #00c896;
  border: 1px solid rgba(0, 200, 150, 0.2);
}

.kpi-delta.neg {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.kpi-delta.warn {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warn);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

/* ── Status Colors ──────────────────────────────────────────────────── */
.status-green  { color: #00c896 !important; }
.status-yellow { color: #f59e0b !important; }
.status-red    { color: #ef4444 !important; }

/* ── Status Dot — pulsing indicator ─────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}

.status-dot::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  animation: pulse-dot 2s ease-in-out infinite;
  opacity: 0.5;
}

.status-dot.green  { background: #00c896; }
.status-dot.green::after  { background: rgba(0, 200, 150, 0.4); }

.status-dot.yellow { background: #f59e0b; }
.status-dot.yellow::after { background: rgba(245, 158, 11, 0.4); }

.status-dot.red    { background: #ef4444; }
.status-dot.red::after    { background: rgba(239, 68, 68, 0.4); }

/* ── Positive / Negative Variance ───────────────────────────────────── */
.var-pos { color: #00c896; font-weight: 600; font-variant-numeric: tabular-nums; }
.var-neg { color: #ef4444; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Section Divider ─────────────────────────────────────────────────── */
.fin-divider {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--border) 20%,
    var(--border) 80%,
    transparent 100%
  );
  margin: 0.5rem 0;
}

/* ── CCC Formula ────────────────────────────────────────────────────── */
.ccc-formula {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  font-weight: 600;
  margin: 0.1rem 0;
}

.ccc-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 0.5rem;
  padding: 0.3rem 0.55rem;
  min-width: 46px;
  transition: background var(--transition), transform var(--transition);
}

.ccc-block:hover {
  background: rgba(255,255,255,0.06);
  transform: translateY(-1px);
}

.ccc-block .ccc-num {
  font-size: 1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.ccc-block .ccc-lbl {
  font-size: 0.58rem;
  color: var(--t3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ccc-op {
  color: var(--t3);
  font-size: 1rem;
  font-weight: 700;
}

.ccc-dso .ccc-num { color: var(--accent2); }
.ccc-dio .ccc-num { color: var(--warn); }
.ccc-dpo .ccc-num { color: var(--accent); }

/* ── Progress Bar with Shimmer ──────────────────────────────────────── */
.fin-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.25rem;
}

.fin-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--accent) 0%,
    rgba(0,200,150,0.6) 40%,
    var(--accent2) 60%,
    var(--accent) 100%
  );
  background-size: 200% 100%;
  transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1);
  animation: shimmer 2.5s linear infinite;
}

/* ── Charts ─────────────────────────────────────────────────────────── */
.fin-chart {
  height: 280px;
  width: 100%;
}

.fin-chart-sm {
  height: 180px;
  width: 100%;
}

/* ── Sparkline ──────────────────────────────────────────────────────── */
.fin-sparkline {
  height: 48px;
  width: 100%;
}

/* ── Loading States ─────────────────────────────────────────────────── */
.fin-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 120px;
  color: var(--t3);
  font-size: 0.85rem;
  gap: 0.5rem;
}

.fin-loading::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.fin-error {
  color: var(--danger);
  font-size: 0.8rem;
  padding: 0.5rem;
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.15);
  border-radius: var(--radius-sm);
}

/* ── Skeleton Loading Card ──────────────────────────────────────────── */
.fcard.loading {
  pointer-events: none;
}

.fcard.loading .skeleton-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.04) 0%,
    rgba(255,255,255,0.10) 50%,
    rgba(255,255,255,0.04) 100%
  );
  background-size: 400px 100%;
  animation: skeleton 1.4s ease-in-out infinite;
  margin-bottom: 0.5rem;
}

.fcard.loading .skeleton-line.wide  { width: 80%; }
.fcard.loading .skeleton-line.medium { width: 55%; }
.fcard.loading .skeleton-line.narrow { width: 35%; }
.fcard.loading .skeleton-value {
  height: 28px;
  width: 60%;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    rgba(0,200,150,0.04) 0%,
    rgba(0,200,150,0.12) 50%,
    rgba(0,200,150,0.04) 100%
  );
  background-size: 400px 100%;
  animation: skeleton 1.4s ease-in-out infinite;
  margin-bottom: 0.5rem;
}

/* ── Scrollbar ──────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(0,200,150,0.2);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(0,200,150,0.4); }

/* ── Utility: Tabular Nums ──────────────────────────────────────────── */
.tabular { font-variant-numeric: tabular-nums; }

/* ── Small Text Helpers ─────────────────────────────────────────────── */
.text-accent  { color: var(--accent); }
.text-accent2 { color: var(--accent2); }
.text-warn    { color: var(--warn); }
.text-danger  { color: var(--danger); }
.text-muted   { color: var(--t3); }
.text-sm      { font-size: 0.78rem; }
.text-xs      { font-size: 0.68rem; }
.fw-700       { font-weight: 700; }
.fw-800       { font-weight: 800; }

/* ── Inline Row Layout ──────────────────────────────────────────────── */
.fin-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.fin-row.between {
  justify-content: space-between;
}

.fin-row.end {
  justify-content: flex-end;
}

/* ── Pill / Tag ─────────────────────────────────────────────────────── */
.fin-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.fin-pill.accent {
  background: rgba(0, 200, 150, 0.12);
  color: var(--accent);
  border: 1px solid rgba(0, 200, 150, 0.2);
}

.fin-pill.blue {
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent2);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.fin-pill.warn {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warn);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.fin-pill.danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ── Table Utility ──────────────────────────────────────────────────── */
.fin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.fin-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--t3);
  border-bottom: 1px solid var(--border-subtle);
}

.fin-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--t2);
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
  transition: color var(--transition);
}

.fin-table tr:last-child td {
  border-bottom: none;
}

.fin-table tr:hover td {
  color: var(--t1);
  background: rgba(0, 200, 150, 0.03);
}

/* ── Tooltip Hint ───────────────────────────────────────────────────── */
[title] { cursor: help; }

/* ── Mobile Responsive ──────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .fin-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .span3, .span4 { grid-column: span 2; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .fin-sidebar {
    width: 0;
    overflow: hidden;
    border-right: none;
  }

  .fin-main {
    margin-left: 0;
  }

  .fin-grid {
    grid-template-columns: 1fr;
  }

  .span1, .span2, .span3, .span4 {
    grid-column: span 1;
  }

  .fin-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
  }

  .fin-tabs {
    padding: 0 0.75rem;
    overflow-x: auto;
  }

  .fin-content {
    padding: 0.75rem;
  }

  .kpi-value {
    font-size: 1.3rem;
  }
}

@media (max-width: 480px) {
  .fin-tab {
    padding: 0.65rem 0.8rem;
    font-size: 0.78rem;
  }

  .fcard {
    padding: 1rem;
  }
}

/* ── Print overrides ────────────────────────────────────────────────── */
@media print {
  .fin-sidebar, .fin-header, .fin-tabs,
  .fin-burger, .insights-panel, .alerts-panel,
  .fin-modal, .kb-hint, .note-btn, .drilldown-badge { display: none !important; }
  .fin-main { margin-left: 0; }
  body { background: #fff !important; color: #000 !important; }
  .fcard {
    break-inside: avoid;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: #fff !important;
    color: #000 !important;
    border: 1px solid #ddd !important;
  }
  .kpi-value, .kpi-value-sm {
    color: #000 !important;
  }
  .fin-content { padding: 0.5rem !important; }
  .fin-grid { gap: 0.5rem !important; }
}

/* ══════════════════════════════════════════════════════════════════════
   LIGHT THEME
══════════════════════════════════════════════════════════════════════ */
[data-theme="light"] {
  --bg:              #f0f4f8;
  --card:            rgba(255, 255, 255, 0.92);
  --card-solid:      #ffffff;
  --card-hover:      rgba(248, 250, 253, 0.98);
  --accent:          #00a87a;
  --accent2:         #2563eb;
  --warn:            #d97706;
  --danger:          #dc2626;
  --t1:              #0f172a;
  --t2:              #334155;
  --t3:              #64748b;
  --border:          rgba(0, 168, 122, 0.22);
  --border-subtle:   rgba(0, 168, 122, 0.10);
  --glow:            rgba(0, 168, 122, 0.06);
  --glow-strong:     rgba(0, 168, 122, 0.14);
  --glow-blue:       rgba(37, 99, 235, 0.06);
  --gradient-accent: linear-gradient(135deg, #00a87a, #2563eb);
  --gradient-card:   linear-gradient(135deg, rgba(0,168,122,0.15), rgba(37,99,235,0.06));
  --gradient-hero:   linear-gradient(135deg, rgba(0,168,122,0.22), rgba(37,99,235,0.10));
}

[data-theme="light"] body { background: var(--bg); }

[data-theme="light"] .fin-sidebar {
  background: linear-gradient(180deg, #e8f0f5 0%, #dce8f0 100%);
  border-right-color: var(--border);
}

[data-theme="light"] .fin-header {
  background: rgba(240, 244, 248, 0.90);
  background-image: none;
}

[data-theme="light"] .fin-tabs {
  background: rgba(240, 244, 248, 0.6);
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(0, 168, 122, 0.25);
}

/* ══════════════════════════════════════════════════════════════════════
   MOBILE OVERLAY + BURGER
══════════════════════════════════════════════════════════════════════ */
.fin-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  backdrop-filter: blur(2px);
}

.fin-overlay.active { display: block; }

.fin-burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.fin-burger:hover { background: rgba(0, 200, 150, 0.08); }

.fin-burger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--t2);
  border-radius: 2px;
  transition: background var(--transition);
}

@media (max-width: 768px) {
  .fin-burger { display: flex; }
  .fin-sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    width: 200px !important;
    overflow: visible !important;
  }
  .fin-sidebar.open { transform: translateX(0); }
}

/* ══════════════════════════════════════════════════════════════════════
   HEADER NEW CONTROLS
══════════════════════════════════════════════════════════════════════ */
.fin-freshness {
  font-size: 0.7rem;
  color: var(--t3);
  white-space: nowrap;
  letter-spacing: 0.01em;
  margin-left: 0.25rem;
}

.fin-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--t2);
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  transition: color var(--transition), border-color var(--transition),
              background var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  position: relative;
  backdrop-filter: blur(8px);
}

.fin-icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--glow);
}

.fin-icon-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(0, 200, 150, 0.1);
}

.fin-theme-btn { font-size: 1rem; padding: 0.28rem 0.5rem; }

/* ══════════════════════════════════════════════════════════════════════
   ALERTS BELL + PANEL
══════════════════════════════════════════════════════════════════════ */
.fin-alerts-wrap {
  position: relative;
}

.alert-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--danger);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 800;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 2px solid var(--bg);
  pointer-events: none;
}

.alerts-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 340px;
  background: var(--card-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(0, 200, 150, 0.06);
  z-index: 200;
  display: none;
  overflow: hidden;
  animation: fadeUp 0.15s ease both;
}

.alerts-panel.open { display: block; }

.alerts-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--t1);
}

.alerts-count {
  font-size: 0.72rem;
  color: var(--t3);
  font-weight: 500;
}

.alerts-list { padding: 0.5rem; max-height: 320px; overflow-y: auto; }

.alert-empty {
  padding: 1rem;
  color: var(--accent);
  font-size: 0.82rem;
  text-align: center;
}

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
}

.alert-item.warn { background: rgba(245, 158, 11, 0.08); border: 1px solid rgba(245, 158, 11, 0.15); }
.alert-item.critical { background: rgba(239, 68, 68, 0.08); border: 1px solid rgba(239, 68, 68, 0.18); }

/* CSS-only status dot — replaces emoji indicators */
.alert-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
  position: relative;
}

.alert-dot.red {
  background: var(--danger);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15);
}

.alert-dot.yellow {
  background: var(--warn);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
}

/* Pulse animation on critical dot */
.alert-item.critical .alert-dot.red::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.25);
  animation: pulse-dot 1.8s ease-in-out infinite;
}

.alert-content { flex: 1; min-width: 0; }
.alert-label { font-weight: 700; color: var(--t1); margin-bottom: 2px; font-size: 0.8rem; }
.alert-msg { color: var(--t2); line-height: 1.4; font-size: 0.78rem; }

/* ══════════════════════════════════════════════════════════════════════
   AI INSIGHTS PANEL
══════════════════════════════════════════════════════════════════════ */
.insights-panel {
  position: fixed;
  top: 0;
  right: -420px;
  width: 400px;
  height: 100vh;
  background: var(--card-solid);
  border-left: 1px solid var(--border);
  z-index: 150;
  overflow-y: auto;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.3);
  padding-bottom: 2rem;
}

.insights-panel.open { right: 0; }

.insights-placeholder {
  padding: 3rem 2rem;
  text-align: center;
  color: var(--t3);
  font-size: 0.9rem;
  line-height: 1.7;
}

.insights-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent);
  position: sticky;
  top: 0;
  background: var(--card-solid);
  z-index: 1;
}

.insights-close {
  background: none;
  border: none;
  color: var(--t3);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: color var(--transition);
}

.insights-close:hover { color: var(--danger); }

.insights-body { padding: 0.75rem 1rem; }

.insights-section { margin-bottom: 1.25rem; }

/* Both class names used — .insights-tab-label (legacy) and .insights-section-title (JS-generated) */
.insights-tab-label,
.insights-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--t3);
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border-subtle);
  text-wrap: balance;
}

/*
 * insight-item — left accent bar via ::before.
 * No icon element needed; status color visible via border-left.
 */
.insight-item {
  padding: 0.6rem 0.75rem 0.6rem 0.85rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--t2);
  position: relative;
  overflow: hidden;
}

.insight-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
}

.insight-item.pos {
  background: rgba(0, 200, 150, 0.07);
  border: 1px solid rgba(0, 200, 150, 0.12);
  border-left: none;
}
.insight-item.pos::before { background: var(--accent); }

.insight-item.warn {
  background: rgba(245, 158, 11, 0.07);
  border: 1px solid rgba(245, 158, 11, 0.12);
  border-left: none;
}
.insight-item.warn::before { background: var(--warn); }

.insight-item.neutral {
  background: rgba(148, 175, 212, 0.05);
  border: 1px solid rgba(148, 175, 212, 0.1);
  border-left: none;
}
.insight-item.neutral::before { background: var(--t3); }

.insight-text { display: block; }
.insight-icon { display: none; } /* deprecated — replaced by ::before bar */

/* Loading state for Bedrock insights */
.insights-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  padding: 2.5rem 1rem;
  color: var(--t3);
  font-size: 0.82rem;
}
.insights-spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid rgba(0, 200, 150, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ══════════════════════════════════════════════════════════════════════
   KEYBOARD HINT TOAST
══════════════════════════════════════════════════════════════════════ */
.kb-hint {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(13, 27, 53, 0.95);
  border: 1px solid var(--border);
  color: var(--t2);
  font-size: 0.78rem;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  white-space: nowrap;
  z-index: 1000;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.kb-hint.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.kb-hint strong { color: var(--accent); }

/* ══════════════════════════════════════════════════════════════════════
   MODALS
══════════════════════════════════════════════════════════════════════ */
.fin-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 300;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  padding: 1rem;
}

.fin-modal.open { display: flex; animation: fadeUp 0.2s ease both; }

.fin-modal-box {
  background: var(--card-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 680px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 200, 150, 0.08);
}

.fin-modal-wide { max-width: 900px; }
.fin-modal-sm   { max-width: 460px; }

.fin-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--t1);
  flex-shrink: 0;
}

.fin-modal-close {
  background: none;
  border: none;
  color: var(--t3);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: color var(--transition), background var(--transition);
}

.fin-modal-close:hover { color: var(--danger); background: rgba(239, 68, 68, 0.08); }

.fin-modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
}

/* ══════════════════════════════════════════════════════════════════════
   DRILL-DOWN INDICATOR
══════════════════════════════════════════════════════════════════════ */
.drilldown-badge {
  position: absolute;
  top: 0.6rem;
  right: 0.65rem;
  font-size: 0.68rem;
  color: var(--accent);
  opacity: 0.5;
  font-weight: 700;
  pointer-events: none;
  transition: opacity var(--transition);
}

.fcard:hover .drilldown-badge { opacity: 1; }

/* ══════════════════════════════════════════════════════════════════════
   SCENARIO MODAL
══════════════════════════════════════════════════════════════════════ */
.scenario-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 700px) { .scenario-layout { grid-template-columns: 1fr; } }

.scenario-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--t3);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.scenario-slider-group { margin-bottom: 1.1rem; }

.scenario-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--t2);
  margin-bottom: 0.4rem;
  font-weight: 500;
}

.slider-val { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }

.slider-track {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.slider-hint { font-size: 0.68rem; color: var(--t3); white-space: nowrap; }

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 0 3px rgba(0, 200, 150, 0.2);
  transition: box-shadow var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 5px rgba(0, 200, 150, 0.3);
}

.scenario-reset {
  background: none;
  border: 1px solid var(--border);
  color: var(--t3);
  padding: 0.4rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  transition: color var(--transition), border-color var(--transition);
  margin-top: 0.5rem;
}

.scenario-reset:hover { color: var(--accent); border-color: var(--accent); }

.scenario-result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.scen-card {
  background: rgba(0, 200, 150, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
}

/* Tarjetas clave del escenario — más prominentes */
.scen-card-highlight {
  background: rgba(0, 200, 150, 0.09);
  border-color: rgba(0, 200, 150, 0.25);
}

.scen-label {
  font-size: 0.68rem;
  color: var(--t3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.3rem;
}

.scen-value {
  font-size: 1.2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--t1);
  transition: color 0.2s;
}

.scen-impact {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 200, 150, 0.04);
  border: 1px solid var(--border-subtle);
  min-height: 2rem;
}

.scen-disclaimer {
  margin-top: 0.75rem;
  font-size: 0.72rem;
  color: var(--t3);
  font-style: italic;
}

/* ══════════════════════════════════════════════════════════════════════
   NOTES
══════════════════════════════════════════════════════════════════════ */
.note-btn {
  position: absolute;
  bottom: 0.5rem;
  right: 0.6rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: system-ui, sans-serif;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition), color var(--transition),
              background var(--transition), border-color var(--transition);
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
  color: var(--t3);
  z-index: 2;
  letter-spacing: 0.02em;
}

.fcard:hover .note-btn {
  opacity: 0.7;
  border-color: var(--border);
}

.fcard.has-note .note-btn {
  opacity: 1;
  color: var(--accent);
  background: rgba(0, 200, 150, 0.08);
  border-color: rgba(0, 200, 150, 0.2);
}

.fcard.has-note::before {
  background: radial-gradient(ellipse at bottom right, rgba(0,200,150,0.10) 0%, transparent 60%);
}

.notes-input {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--t1);
  padding: 0.75rem;
  font-size: 0.85rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  line-height: 1.6;
}

.notes-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--glow);
}

.notes-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.75rem;
  gap: 0.75rem;
}

.notes-save-btn {
  background: var(--accent);
  color: #050c1c;
  border: none;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--transition);
}

.notes-save-btn:hover { opacity: 0.85; }

.notes-hint {
  font-size: 0.72rem;
  color: var(--t3);
  font-style: italic;
}

/* ══════════════════════════════════════════════════════════════════════
   ANOMALY GLOW — KPI cards con valores fuera de rango
   Investigado: CSS pulse + glow animation, dark theme, 60fps hardware accel
   Técnica: box-shadow rgba pulsante + inset border glow, solo opacity/shadow
   (no transform scale — evita layout reflow en grids)
══════════════════════════════════════════════════════════════════════ */
@keyframes anomaly-warn-pulse {
  0%, 100% {
    box-shadow:
      0 0  0px 0px rgba(245,158,11, 0.0),
      inset 0 0 0 1px rgba(245,158,11, 0.25);
  }
  50% {
    box-shadow:
      0 0 22px 4px rgba(245,158,11, 0.12),
      inset 0 0 0 1px rgba(245,158,11, 0.7),
      0 0 8px  2px rgba(245,158,11, 0.08);
  }
}

@keyframes anomaly-crit-pulse {
  0%, 100% {
    box-shadow:
      0 0  0px 0px rgba(239,68,68, 0.0),
      inset 0 0 0 1px rgba(239,68,68, 0.25);
  }
  50% {
    box-shadow:
      0 0 24px 6px rgba(239,68,68, 0.14),
      inset 0 0 0 1px rgba(239,68,68, 0.75),
      0 0 10px 3px rgba(239,68,68, 0.1);
  }
}

.fcard.anomaly-warn {
  animation: anomaly-warn-pulse 2.2s ease-in-out infinite;
  border-color: rgba(245,158,11, 0.35) !important;
}

.fcard.anomaly-crit {
  animation: anomaly-crit-pulse 1.6s ease-in-out infinite;
  border-color: rgba(239,68,68, 0.35) !important;
}

/* ══════════════════════════════════════════════════════════════════════
   NARRATIVE BLOCK — Data storytelling inline por tab
   Standard 2026: "one insight per scroll", sequencing over decoration.
   Fuente: Fuselab/MIT Sloan — narrative antes que ornamentación.
══════════════════════════════════════════════════════════════════════ */
@keyframes narrative-reveal {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.narrative-block {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  background: linear-gradient(135deg,
    color-mix(in srgb, #00c896 4%, transparent),
    color-mix(in srgb, #3b82f6 3%, transparent));
  border: 1px solid color-mix(in srgb, #00c896 14%, transparent);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  animation: narrative-reveal 0.35s ease both;
}

.narrative-tag {
  flex-shrink: 0;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-a10);
  border: 1px solid var(--accent-a30);
  border-radius: 4px;
  padding: 0.18rem 0.45rem;
  margin-top: 0.12rem;
  line-height: 1.4;
}

.narrative-text {
  font-size: 0.815rem;
  color: var(--t2);
  line-height: 1.65;
}

.narrative-text b { color: var(--t1); font-weight: 600; }
.narrative-text .n-ok   { color: var(--accent); font-weight: 600; }
.narrative-text .n-warn { color: var(--warn);   font-weight: 600; }
.narrative-text .n-bad  { color: var(--danger); font-weight: 600; }

/* Light theme */
[data-theme="light"] .narrative-block {
  background: linear-gradient(135deg,
    color-mix(in srgb, #00c896 5%, white),
    color-mix(in srgb, #3b82f6 4%, white));
  border-color: color-mix(in srgb, #00c896 20%, transparent);
}
[data-theme="light"] .narrative-text { color: #374151; }
[data-theme="light"] .narrative-text b { color: #1e293b; }

/* ══════════════════════════════════════════════════════════════════════
   KPI YoY DELTA BADGE
══════════════════════════════════════════════════════════════════════ */
.kpi-yoy {
  display: inline-flex;
  align-items: center;
  gap: 0.18rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.025em;
  padding: 0.14rem 0.38rem;
  border-radius: 4px;
  margin-top: 0.3rem;
  transition: opacity var(--transition);
}
.kpi-yoy.up   { background: var(--accent-a10); color: var(--accent); }
.kpi-yoy.down { background: var(--danger-a08); color: var(--danger); }
.kpi-yoy.flat { background: var(--warn-a08);   color: var(--warn);   }
.kpi-yoy.na   { background: rgba(74,106,138,0.1); color: var(--t3);  }

/* ══════════════════════════════════════════════════════════════════════
   PENDING CHIP — estado null informativo
══════════════════════════════════════════════════════════════════════ */
.pending-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--t3);
  background: rgba(74,106,138, 0.08);
  border: 1px solid rgba(74,106,138, 0.2);
  border-radius: 4px;
  padding: 0.18rem 0.45rem;
  cursor: help;
  vertical-align: middle;
}
.pending-chip::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--t3);
  opacity: 0.6;
}

/* ══════════════════════════════════════════════════════════════════════
   FORECAST BADGE — en títulos de charts con predicción
══════════════════════════════════════════════════════════════════════ */
.forecast-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent2);
  background: rgba(59,130,246, 0.1);
  border: 1px solid rgba(59,130,246, 0.25);
  border-radius: 4px;
  padding: 0.14rem 0.42rem;
  margin-left: 0.5rem;
  vertical-align: middle;
}
.forecast-badge::before {
  content: '';
  display: inline-block;
  width: 16px; height: 2px;
  background: repeating-linear-gradient(
    90deg, var(--accent2) 0, var(--accent2) 4px, transparent 4px, transparent 7px
  );
  opacity: 0.8;
}

/* ══════════════════════════════════════════════════════════════════════
   KEYBOARD FOCUS — ACCESSIBILITY
══════════════════════════════════════════════════════════════════════ */
.fin-tab:focus-visible,
.fin-icon-btn:focus-visible,
.fin-select:focus-visible,
.fin-nav-link:focus-visible,
.fin-burger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ══════════════════════════════════════════════════════════════════════
   RESPONSIVE UPDATES (extended)
══════════════════════════════════════════════════════════════════════ */
@media (max-width: 1200px) {
  .insights-panel { width: 340px; right: -360px; }
}

@media (max-width: 900px) {
  .fin-header-right { gap: 0.4rem; }
  .fin-freshness { display: none; }
  .fin-badge-mock { display: none; }
}

@media (max-width: 640px) {
  .fin-icon-btn { padding: 0.28rem 0.45rem; font-size: 0.75rem; }
  .alerts-panel { width: 300px; }
  .insights-panel { width: 100vw; right: -100vw; }
  .fin-modal-box { max-height: 90vh; }
}

/* ══════════════════════════════════════════════════════════════════════
   PRINT / PDF EXPORT — v20260507a
   Optimizado para window.print() → chrome headless / PDF.
   Fondo blanco, márgenes amplios, ocultar controles, preservar charts.
══════════════════════════════════════════════════════════════════════ */
@media print {
  /* Restablecer colores para impresión */
  :root {
    --bg:       #ffffff;
    --card:     #f8fafc;
    --t1:       #0f172a;
    --t2:       #374151;
    --t3:       #6b7280;
    --border:   rgba(0, 200, 150, 0.35);
    --accent:   #009970;
  }

  body {
    background: #ffffff;
    color: #0f172a;
  }

  /* Ocultar controles de navegación y paneles */
  .fin-sidebar,
  .fin-header,
  .fin-tabs,
  .kb-hint,
  .fin-icon-btn,
  .fin-select,
  .fin-burger,
  .fin-overlay,
  .fin-modal,
  .alerts-panel,
  .insights-panel,
  .fin-nav,
  .fin-sidebar-bottom,
  .narrative-block { display: none !important; }

  /* Full-width main, sin sidebar */
  .fin-main {
    margin-left: 0 !important;
    padding: 12mm 16mm !important;
  }

  /* Mostrar TODAS las secciones (no solo la activa) */
  .fin-section {
    display: block !important;
    page-break-after: always;
  }
  .fin-section:last-child { page-break-after: avoid; }

  /* Cards en grilla imprimible */
  .fin-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8mm;
    break-inside: avoid;
  }

  .fcard {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 4mm 5mm;
    break-inside: avoid;
    box-shadow: none;
  }
  .fcard.span2 { grid-column: span 2; }
  .fcard.span4 { grid-column: span 4; }

  /* KPI values legibles en impresión */
  .kpi-value {
    color: #0f172a !important;
    font-size: 1.4rem !important;
  }
  .kpi-label {
    color: #374151 !important;
    font-size: 0.72rem !important;
  }
  .kpi-sub {
    color: #6b7280 !important;
    font-size: 0.68rem !important;
  }

  /* Charts — dar altura fija para que ECharts los renderice */
  .fin-chart { height: 180px !important; }
  .fcard.span4 .fin-chart { height: 220px !important; }

  /* Cabecera de impresión */
  .fin-content::before {
    content: 'Petrizzio · Dashboard Financiero — ' attr(data-periodo);
    display: block;
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 6mm;
    padding-bottom: 3mm;
    border-bottom: 1px solid #e2e8f0;
  }

  /* Evitar cortes dentro de cards grandes */
  .fin-section { break-inside: avoid-page; }

  /* Tamaño de página */
  @page {
    size: A4 landscape;
    margin: 10mm 12mm;
  }
}

/* ── Aviso de fuente de datos caída (v20260810b) ──────────────────────────
   Se inyecta al tope de una pestaña cuando una tabla origen queda sin datos.
   Ámbar, no rojo: el dato falta, no está equivocado. */
.fuente-alert {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.85rem 1rem;
  margin-bottom: 0.9rem;
  border-radius: 12px;
  background: color-mix(in srgb, var(--warn) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 28%, transparent);
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--txt);
  animation: fadeUp 0.35s ease both;
}
.fuente-alert b { color: var(--warn); font-weight: 650; }
.fuente-alert code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78em;
  padding: 0.08em 0.35em;
  border-radius: 4px;
  background: color-mix(in srgb, var(--warn) 14%, transparent);
}
.fuente-alert-dot {
  flex: 0 0 auto;
  width: 9px; height: 9px;
  margin-top: 0.42rem;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 22%, transparent);
}
