/* Estilos de cdn/resumen-financiero.js y cdn/visor-pdf.js (pantallas
   "Resumen" y "Herramientas" de Stitch). Los usan el Dashboard y Copiloto,
   encima de la base /app/crm/app/style.css. */

.panel h2.caps { font-size: 15px; letter-spacing: 0.04em; text-transform: uppercase; }
.panel h2.caps-sm, span.caps-sm { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.title-icon { width: 36px; height: 36px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); background: var(--surface-container); color: var(--accent-system-hover); }

.empty-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 28px 20px;
  border-radius: var(--radius);
  background: var(--surface-low);
  text-align: center;
}
.empty-box .empty-icon, .empty-state .empty-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--surface-container);
  color: var(--accent-system-hover);
  margin-bottom: 4px;
}
.empty-box strong { font-size: 15px; font-weight: 500; color: var(--text); max-width: 440px; }
.empty-box span.empty-sub { font-size: 12.5px; color: var(--muted); max-width: 440px; }
.empty-box .btn { margin-top: 10px; }
.empty-inline { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface-low); font-size: 13.5px; color: var(--text); }
.empty-inline .material-symbols-outlined { color: var(--muted); font-size: 20px; }

/* ---- resumen financiero ---- */

.fin-root { display: flex; flex-direction: column; gap: 16px; }
.fin-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); margin-bottom: 0; }
.fkpi { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px; }
.fkpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fkpi-label { font-size: 11.5px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fkpi-icon { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); background: var(--surface-container); color: var(--accent-system-hover); font-size: 19px; flex-shrink: 0; }
.fkpi .stat-value { font-size: 26px; line-height: 32px; }
.fkpi-foot { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.fkpi-foot span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-badge-ok { background: var(--stage-cerrado-soft) !important; color: var(--stage-cerrado) !important; }
.kpi-badge-danger { background: var(--overdue) !important; color: var(--overdue-text) !important; }

.title-row-sm { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.title-row-sm h2 { margin: 0 !important; }
.panel h2.title-md { font-size: 18px; line-height: 25px; font-weight: 600; margin: 0 0 2px; }
.fin-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.chart-box { min-height: 260px; }
.month-tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-bottom: 18px; }
.month-tile { display: flex; flex-direction: column; gap: 1px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-low); font-size: 12px; color: var(--muted); min-width: 0; }
.month-tile b { font-size: 14px; color: var(--text); }
.month-tile em { font-style: normal; color: var(--accent-system-hover); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.month-tile.is-current { background: var(--surface-container); }
.month-tile.is-current > span:first-child, .month-tile.is-current b { color: var(--accent-system-hover); }
.line-wrap { position: relative; }
.line-svg { width: 100%; height: 240px; display: block; overflow: visible; }
.line-svg .grid { stroke: var(--border); stroke-dasharray: 4 4; }
.line-svg .axis { font-size: 11px; fill: var(--muted); font-family: inherit; }
.line-svg .area { fill: color-mix(in srgb, var(--accent-system) 12%, transparent); }
.line-svg .line { fill: none; stroke: var(--accent-system-hover); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.line-svg .dot { fill: var(--panel); stroke: var(--accent-system-hover); stroke-width: 2; }
.line-svg .dot.is-max { fill: var(--accent-system-hover); }
.max-tip {
  position: absolute;
  z-index: 2;
  transform: translate(-100%, -115%);
  min-width: 210px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: #0f172a;
  color: #fff;
  box-shadow: var(--shadow-modal);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.max-tip-kicker { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; color: #34d399; }
.max-tip-kicker .fu-dot { background: #34d399; width: 6px; height: 6px; }
.max-tip strong { font-size: 14px; }
.max-tip > span:not(.max-tip-kicker) { font-size: 12.5px; color: #cbd5e1; }
.max-tip-row { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, 0.15); font-size: 12px; color: #cbd5e1; }
.max-tip-row b { color: #fff; font-size: 14px; }
.panel-foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 16px; font-size: 12.5px; color: var(--muted); }
.panel-foot > span:first-child { display: inline-flex; align-items: center; gap: 5px; color: var(--accent-system-hover); }
.panel-foot .material-symbols-outlined { font-size: 16px; }
.panel-foot b { color: var(--text); }

.fin-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.fin-side { display: flex; flex-direction: column; gap: 16px; }
.client-chip { width: 34px; height: 34px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); color: #fff; font-size: 12px; font-weight: 700; }
.service-chip { display: inline-block; max-width: 180px; padding: 5px 9px; border-radius: var(--radius-sm); background: var(--surface-container); font-size: 12.5px; line-height: 17px; }
.status-cerrado { background: var(--stage-cerrado-soft); color: var(--stage-cerrado); }
.fin-table td { vertical-align: middle; }
.pipeline-strip { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 16px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface-low); }
.pipeline-strip div { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 200px; }
.pipeline-strip strong { font-size: 14px; font-weight: 600; }
.pipeline-strip span:not(.material-symbols-outlined) { font-size: 13px; color: var(--muted); }

.pdf-promo {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 22px;
  border-radius: var(--radius);
  color: #fff;
  background: linear-gradient(140deg, var(--accent-system-hover), var(--accent-system));
  box-shadow: var(--shadow-pop);
}
.pdf-promo-tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.18); font-size: 12px; font-weight: 600; }
.pdf-promo-tag .material-symbols-outlined { font-size: 15px; }
.pdf-promo strong { font-size: 19px; font-weight: 600; }
.pdf-promo p { margin: 0 0 8px; font-size: 13.5px; line-height: 21px; opacity: 0.95; position: relative; z-index: 1; }
.pdf-promo-btn { position: relative; z-index: 1; width: 100%; justify-content: center; background: #fff !important; color: var(--accent-system-hover) !important; font-weight: 600; }
.pdf-promo-bg { position: absolute; right: -18px; bottom: -22px; font-size: 140px !important; opacity: 0.12; }
.return-row { margin-bottom: 14px; }
.return-row .perf-row { font-size: 14px; margin-bottom: 6px; }
.return-foot { display: flex; justify-content: space-between; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.return-foot b { color: var(--text); }

/* ---- visor de PDFs ---- */

.pdf-root { display: flex; flex-direction: column; gap: 16px; }
.pdf-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; align-items: start; }
.pdf-list-col { display: flex; flex-direction: column; gap: 12px; }
.pdf-list-head { padding: 0 4px; font-size: 12.5px; font-weight: 600; }
.pdf-list { display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 360px); overflow-y: auto; padding: 2px; }
.pdf-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-card);
  font-family: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.pdf-card:hover { box-shadow: var(--shadow-pop); }
.pdf-card.is-active { box-shadow: inset 0 0 0 2px var(--accent-system), var(--shadow-card); }
.pdf-card-top { display: flex; align-items: flex-start; gap: 10px; }
.pdf-card-icon { width: 40px; height: 40px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); background: var(--surface-container); color: var(--accent-system-hover); }
.pdf-card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pdf-card-main strong { font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; }
.pdf-card-main span { font-size: 12.5px; color: var(--muted); }
.pdf-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.pdf-card-foot > span:last-child { display: inline-flex; align-items: center; gap: 4px; }
.pdf-card-foot .material-symbols-outlined { font-size: 15px; }
.pdf-status-borrador { background: var(--today); color: var(--today-text); }
.pdf-status-aprobado { background: var(--surface-container); color: var(--accent-system-hover); }
.pdf-status-enviado { background: var(--stage-cerrado-soft); color: var(--stage-cerrado); }
.voice-card { display: flex; flex-direction: column; gap: 8px; padding: 18px; border-radius: var(--radius); background: var(--surface-container); }
.voice-card strong { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; color: var(--accent-system-hover); }
.voice-card p { margin: 0 0 4px; font-size: 13.5px; line-height: 20px; color: var(--text); }

.pdf-viewer { display: flex; flex-direction: column; border-radius: var(--radius); background: var(--surface-low); border: 1px solid var(--border); overflow: hidden; min-width: 0; }
.pdf-viewer:fullscreen { background: var(--bg); }
.pdf-viewer-empty { padding: 60px 24px; }
.pdf-toolbar, .pdf-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 12px 16px; background: var(--panel); }
.pdf-toolbar { border-bottom: 1px solid var(--border); }
.pdf-actions { border-top: 1px solid var(--border); }
.pdf-tool-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pdf-page-label { min-width: 44px; text-align: center; font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
.pdf-tool-group code { background: none; padding: 0; font-size: 11.5px; color: var(--accent-system-hover); }
.icon-btn[disabled] { opacity: 0.4; cursor: default; }
.pdf-stage { display: flex; justify-content: center; padding: 24px; overflow: auto; max-height: calc(100vh - 300px); min-height: 480px; }
.pdf-sheet-wrap { position: relative; flex-shrink: 0; }
.pdf-scale { transform-origin: top left; width: 794px; }
.pdf-editor { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 820px; }
.pdf-editor textarea { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.55; resize: vertical; }
.pdf-editor-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Hoja A4 (794×1123 px a 96 dpi): mismo tamaño en el visor, la impresión y
   el PDF que se sube al Portal. Colores fijos a propósito: un documento no
   cambia con el modo oscuro. */
.pdf-sheet {
  position: relative;
  width: 794px;
  height: 1123px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  padding: 56px 60px 40px;
  background: #ffffff;
  color: #0f172a;
  font-family: Inter, -apple-system, "Segoe UI", sans-serif;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.18);
  overflow: hidden;
}
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 30px; }
.sheet-brand { display: flex; align-items: center; gap: 14px; }
.sheet-brand img { max-height: 48px; max-width: 120px; object-fit: contain; }
.sheet-mark { width: 46px; height: 46px; display: flex; align-items: center; justify-content: center; border-radius: 6px; background: #163edc; color: #fff; font-size: 22px; font-weight: 700; }
.sheet-brand strong { display: block; font-size: 20px; letter-spacing: 0.02em; }
.sheet-brand span { display: block; margin-top: 2px; font-size: 11px; font-weight: 600; letter-spacing: 0.1em; color: #475569; }
.sheet-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 13px; color: #475569; }
.sheet-id { padding: 3px 9px; border-radius: 4px; background: #e5eeff; color: #163edc; font-size: 11.5px; font-weight: 700; }
.sheet-client { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 28px; padding: 18px 20px; border-radius: 6px; background: #eff4ff; }
.sheet-client span { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #475569; }
.sheet-client strong { display: block; margin-top: 4px; font-size: 17px; }
.sheet-client em { display: block; margin-top: 2px; font-size: 13px; font-style: normal; color: #475569; }
.sheet-running { display: flex; justify-content: space-between; padding-bottom: 12px; margin-bottom: 20px; border-bottom: 1px solid #e2e8f0; font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; color: #64748b; }
.sheet-body { flex: 1; overflow: hidden; font-size: 14px; line-height: 23px; color: #1e293b; }
.sheet-body h3 { margin: 18px 0 8px; font-size: 19px; line-height: 26px; color: #0f172a; }
.sheet-body h4 { margin: 16px 0 6px; font-size: 16px; color: #0f172a; }
.sheet-body h5 { margin: 12px 0 4px; font-size: 14px; color: #0f172a; }
.sheet-body p { margin: 0 0 10px; }
.sheet-body ul { margin: 0 0 12px; padding-left: 20px; }
.sheet-body li { margin-bottom: 4px; }
.sheet-body table { width: 100%; margin: 10px 0 14px; border-collapse: collapse; font-size: 13px; }
.sheet-body th { padding: 9px 12px; background: #e5eeff; text-align: left; font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: #334155; }
.sheet-body td { padding: 10px 12px; border-bottom: 1px solid #e2e8f0; }
.sheet-sign { display: flex; align-items: center; gap: 14px; margin: 16px 0 10px; padding: 16px 18px; border-radius: 6px; background: #f1f5f9; }
.sheet-sign.is-approved { background: #ecfdf5; }
.sheet-sign-icon { width: 42px; height: 42px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: #e2e8f0; color: #475569; }
.sheet-sign.is-approved .sheet-sign-icon { background: #d1fae5; color: #047857; }
.sheet-sign-kicker { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #64748b; }
.sheet-sign.is-approved .sheet-sign-kicker { color: #047857; }
.sheet-sign strong { display: block; margin: 2px 0 4px; font-size: 14px; }
.sheet-sign code { display: block; font-size: 11px; background: none; padding: 0; color: #475569; word-break: break-all; }
.sheet-foot { display: flex; justify-content: space-between; gap: 16px; padding-top: 14px; border-top: 1px solid #e2e8f0; font-size: 11px; color: #64748b; }
.pdf-render-holder { position: fixed; left: -10000px; top: 0; width: 794px; }
.pdf-render-holder .pdf-sheet { box-shadow: none; }

@media (max-width: 1280px) {
  .fin-layout, .pdf-layout { grid-template-columns: 1fr; }
  .pdf-list { max-height: none; }
  .fin-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .month-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .fin-kpis { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 520px) {
  .fin-kpis { grid-template-columns: 1fr; }
}
