:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #dde2e8;
  --text: #1c2530;
  --text-dim: #64707d;
  --accent: #1a5fb4;
  --accent-soft: #e8f0fc;
  --good: #1f8a4c;
  --warn: #b8860b;
  --bad: #c0392b;
  --accent2: #d97530;
  --accent2-soft: #fbeee1;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}

h1, h2, h3 { margin: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--accent); color: white; font-weight: 700; font-size: 13px;
}
.brand h1 { font-size: 16px; }
.brand-sub { font-size: 11px; color: var(--text-dim); }

.app-shell { display: flex; align-items: stretch; min-height: 100vh; }

.sidenav {
  width: 220px;
  flex: 0 0 220px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: width .15s ease, flex-basis .15s ease;
  z-index: 30;
}
.sidenav.collapsed { width: 56px; flex-basis: 56px; }
.sidenav.collapsed .sidenav-title,
.sidenav.collapsed .sidenav-label,
.sidenav.collapsed .sidenav-children { display: none; }
.sidenav.collapsed .sidenav-toggle { transform: rotate(180deg); }

.sidenav-header {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
}
.sidenav-title { font-size: 15px; font-weight: 700; flex: 1; white-space: nowrap; }
.sidenav-toggle {
  border: none; background: transparent; color: var(--text-dim); cursor: pointer;
  font-size: 13px; padding: 4px; border-radius: 6px; flex: 0 0 auto;
}
.sidenav-toggle:hover { background: var(--accent-soft); color: var(--accent); }

.sidenav-groups { padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.sidenav-group { display: flex; flex-direction: column; }
.sidenav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; border: none; background: transparent; color: var(--text);
  padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px; font-weight: 600;
  text-align: left; white-space: nowrap;
}
.sidenav-item:hover { background: var(--accent-soft); }
.sidenav-item.active-route { background: var(--accent-soft); color: var(--accent); }
.sidenav-icon { font-size: 15px; width: 18px; text-align: center; flex: 0 0 auto; }
.sidenav-children {
  display: flex; flex-direction: column; gap: 1px;
  margin: 2px 0 6px 30px;
  border-left: 1px solid var(--border);
  padding-left: 10px;
}
.sidenav-child {
  border: none; background: transparent; color: var(--text-dim);
  padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 12.5px;
  text-align: left; white-space: nowrap;
}
.sidenav-child:hover { background: var(--accent-soft); color: var(--text); }
.sidenav-child.active { background: var(--accent); color: white; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.view-tabs { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.view-tab-btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}
.view-tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.view-tab-btn .count-badge {
  opacity: .75;
  margin-left: 4px;
  font-size: 11px;
}

.topbar-right { display: flex; align-items: center; gap: 10px; }
.load-status { font-size: 12px; color: var(--text-dim); min-width: 140px; text-align: right; }

.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; }

main { padding: 18px 20px 60px; width: 100%; box-sizing: border-box; }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

/* ---------------------------------- home -------------------------------- */
.home-intro { margin-bottom: 18px; }
.home-intro h2 { margin: 0 0 4px; font-size: 21px; }
.home-intro-sub { font-size: 12.5px; color: var(--text-dim); }

.home-currency-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
  margin-bottom: 26px;
}
@media (max-width: 900px) { .home-currency-grid { grid-template-columns: 1fr; } }

.home-currency-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.home-panel-head h3 { margin: 0 0 12px; font-size: 16px; }

.stat-tile-row-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-dim); margin: 12px 0 6px;
}
.stat-tile-row-label:first-of-type { margin-top: 0; }

.stat-tile-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}
.stat-tile {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 0; /* let the value below shrink-wrap instead of forcing the grid track wider */
}
.stat-tile-label { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); margin-bottom: 5px; font-weight: 600; }
.stat-tile-value {
  font-size: 19px; font-weight: 700; line-height: 1.15; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stat-tile-value.tone-good { color: var(--good); }
.stat-tile-value.tone-bad { color: var(--bad); }
.stat-tile-caption { font-size: 10.5px; color: var(--text-dim); margin-top: 3px; }

.home-compare { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.home-compare-title { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); margin-bottom: 10px; }
.home-compare-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.home-compare-row:last-child { margin-bottom: 0; }
.home-compare-key { width: 64px; flex: none; font-size: 12px; font-weight: 600; color: var(--text); }
.home-compare-track { flex: 1; height: 18px; background: var(--bg); border-radius: 999px; overflow: hidden; position: relative; }
.home-compare-fill { height: 100%; border-radius: 999px; }
.home-compare-fill.cartera { background: var(--accent); }
.home-compare-fill.deuda { background: var(--accent2); }
.home-compare-value { width: 128px; flex: none; text-align: right; font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.home-compare-ratio { font-size: 11px; color: var(--text-dim); margin-top: 8px; }

.home-trends { margin-bottom: 10px; }
.home-trends-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; gap: 10px; }
.home-trends-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.home-trends-controls .search-box { min-width: 0; width: auto; }
.home-trends-daterange { display: flex; align-items: center; gap: 6px; }
.home-trends-daterange span { font-size: 12px; color: var(--text-dim); }
.home-trends-daterange input[type="month"] { padding: 7px 9px; font-size: 12.5px; }
.home-trends-head h3 { margin: 0; font-size: 16px; }

.home-charts-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.chart-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.chart-card-title { font-size: 12.5px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.chart-body { position: relative; }
.chart-body svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-legend { display: flex; gap: 14px; margin-top: 8px; flex-wrap: wrap; }
.chart-legend-item { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); }
.chart-legend-swatch { width: 14px; height: 2px; border-radius: 1px; flex: none; }
.chart-totals { display: flex; gap: 16px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.chart-totals-item { font-size: 11px; color: var(--text-dim); }
.chart-totals-item b { font-size: 12.5px; color: var(--text); font-weight: 700; }
.chart-tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--text); color: #fff; border-radius: 6px; padding: 7px 10px;
  font-size: 11.5px; line-height: 1.5; box-shadow: 0 6px 18px rgba(0,0,0,.18);
  transform: translate(-50%, 0); white-space: nowrap; opacity: 0; transition: opacity .1s;
}
.chart-tooltip.visible { opacity: 1; }
.chart-tooltip .ct-title { font-weight: 700; margin-bottom: 3px; }
.chart-tooltip .ct-row { display: flex; align-items: center; gap: 6px; }
.chart-tooltip .ct-key { width: 10px; height: 2px; border-radius: 1px; flex: none; }
.chart-tooltip .ct-val { font-weight: 700; margin-left: auto; padding-left: 10px; }
.chart-empty { font-size: 12px; color: var(--text-dim); padding: 30px 0; text-align: center; }

.rollforward-assumptions {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 18px;
}
.rollforward-assumptions h4 { margin: 0 0 10px; font-size: 13px; }
.rollforward-assumptions h4:not(:first-child) { margin-top: 18px; }
.rollforward-derived {
  margin-top: 16px; padding: 12px 14px; background: var(--bg); border-radius: 8px;
  font-size: 12px; color: var(--text-dim); line-height: 1.6;
}
.rollforward-derived b { color: var(--text); }
.rollforward-derived.error { background: #fbe6e3; color: var(--bad); font-weight: 600; }
#rollforwardRunBtn { margin-top: 16px; }
#rollforwardSaveBtn { margin-top: 16px; margin-left: 8px; }
#rollforwardAssetMixTable input { width: 100%; box-sizing: border-box; border: 1px solid var(--border); border-radius: 4px; padding: 4px 6px; font: inherit; }
.rollforward-horizontal { white-space: nowrap; }
.rollforward-horizontal th:first-child, .rollforward-horizontal td:first-child {
  position: sticky; left: 0; background: var(--panel); z-index: 1; text-align: left; white-space: nowrap;
}
.rollforward-horizontal tr.section-row td { background: var(--text); color: var(--panel); font-weight: 600; }
.rollforward-horizontal tr.section-row td:first-child { background: var(--text); }
.rollforward-horizontal tr.sub-row td:first-child { padding-left: 24px; font-style: italic; }
.rollforward-horizontal tr.total-row td:first-child { font-weight: 700; }
/* Historical (real) columns get a dimmed tint + a divider on their right
   edge, so it's visually obvious where real data ends and the forward
   projection starts - the "hoy" boundary sits right after the last one. */
.rollforward-horizontal th.hist-col, .rollforward-horizontal td.hist-col { background: var(--bg); }
.rollforward-horizontal th.hist-last, .rollforward-horizontal td.hist-last { border-right: 2px solid var(--accent); }
.kpi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); margin-bottom: 6px; }
.kpi-value { font-size: 20px; font-weight: 700; }
.kpi-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.fx-note {
  font-size: 12px;
  color: var(--text-dim);
  background: var(--accent-soft);
  border: 1px solid #cfe0f5;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 14px;
}
.fx-note.fx-error { background: #fbe6e3; border-color: #f2c6c0; color: var(--bad); }

.bar-track {
  display: inline-block;
  width: 110px;
  height: 8px;
  background: #eef1f4;
  border-radius: 999px;
  overflow: hidden;
  vertical-align: middle;
  margin-right: 6px;
}
.bar-fill { height: 100%; border-radius: 999px; }
.bar-good { background: var(--good); }
.bar-warn { background: var(--warn); }
.bar-bad { background: var(--bad); }
.bar-pct { font-size: 11.5px; color: var(--text-dim); vertical-align: middle; }
.morosidad-table tbody tr:not(.total-row) { cursor: pointer; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.mode-switch { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.mode-btn {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
}
.mode-btn.active { background: var(--accent); color: white; }

.toolbar-filters { display: flex; gap: 8px; flex-wrap: wrap; }

.search-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  min-width: 260px;
  background: var(--panel);
  color: var(--text);
}
.asset-filter { min-width: 200px; cursor: pointer; }

.vintage-note { font-size: 12px; color: var(--text-dim); align-self: center; }
.vintage-table td.pivot-cell:hover, .vintage-table td.vintage-cell:hover, .vintage-table td.cobranza-cell:hover { background: var(--accent-soft); cursor: pointer; }
.vintage-table td.cobranza-cell { cursor: pointer; }
.vintage-table th, .vintage-table td { white-space: nowrap; }
.vintage-table thead tr:first-child th { top: 0; }
.vintage-table thead tr:nth-child(2) th { top: 32px; }
.vintage-table td.vintage-cell { text-align: center; }

.mode-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.table-scroll { overflow-x: auto; max-height: 62vh; overflow-y: auto; border-radius: 8px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin-bottom: 4px; }
.form-grid.full { grid-template-columns: 1fr; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field label { font-size: 12px; color: var(--text-dim); }
.form-field input, .form-field select {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  font-size: 13.5px; background: var(--bg); color: var(--text);
}
.cost-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.cost-row label { display: flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--text-dim); white-space: nowrap; }
.tir-preview { background: var(--accent-soft); border: 1px solid #cfe0f5; border-radius: 8px; padding: 12px 14px; margin: 14px 0; }
.tir-preview .tir-value { font-size: 22px; font-weight: 700; color: var(--accent); }
.form-error { background: #fbe6e3; color: var(--bad); border: 1px solid #f2c6c0; border-radius: 8px; padding: 8px 10px; font-size: 12.5px; margin-bottom: 12px; }

.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table thead th {
  position: sticky; top: 0;
  background: #eef2f7;
  border-bottom: 1px solid var(--border);
  text-align: center;
  padding: 8px 10px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.data-table thead th.sorted::after { content: " \25BE"; color: var(--accent); }
.data-table thead th.sorted.asc::after { content: " \25B4"; }
.data-table tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid #eef1f4;
  white-space: nowrap;
  text-align: center;
}
.data-table tbody tr:hover { background: var(--accent-soft); cursor: pointer; }
.data-table tbody tr.total-row { font-weight: 700; background: #f7f9fb; cursor: default; }
.data-table tbody tr.total-row:hover { background: #f7f9fb; }
.data-table tbody tr.current-month { background: #e6f7e9; }
.data-table tbody tr.current-month:hover { background: #d9f2df; }

.num { text-align: center; font-variant-numeric: tabular-nums; }
.pivot-table td.pivot-cell:hover { background: var(--accent-soft); cursor: pointer; }
.pivot-table td.zero { color: #b8c0ca; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-open { background: #e3f3e9; color: var(--good); }
.badge-warn { background: #fbf1dc; color: var(--warn); }
.badge-bad { background: #fbe6e3; color: var(--bad); }
.badge-neutral { background: #eef1f4; color: var(--text-dim); }

.empty-state { padding: 30px; text-align: center; color: var(--text-dim); }

.pivot-controls {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.pivot-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-dim);
}
.pivot-controls select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  min-width: 190px;
  background: var(--panel);
  color: var(--text);
}

.drill-panel { margin-top: 18px; border-top: 2px dashed var(--border); padding-top: 14px; }
.drill-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(20, 26, 33, .55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal {
  background: var(--panel);
  border-radius: 14px;
  width: min(980px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-sub { color: var(--text-dim); font-size: 12.5px; margin-top: 4px; }
.modal-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}
.summary-item .k { font-size: 10.5px; text-transform: uppercase; color: var(--text-dim); letter-spacing: .03em; }
.summary-item .v { font-size: 14px; font-weight: 600; margin-top: 2px; }

.modal-tabs { display: flex; gap: 4px; padding: 10px 22px 0; border-bottom: 1px solid var(--border); }
.modal-tab-btn {
  border: none; background: transparent; padding: 8px 14px; cursor: pointer;
  font-size: 13px; color: var(--text-dim); border-bottom: 2px solid transparent;
}
.modal-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.modal-body { padding: 16px 22px 22px; overflow-y: auto; }

@media (max-width: 680px) {
  .topbar { gap: 10px; }
  .search-box { min-width: 0; width: 100%; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .home-charts-row { grid-template-columns: 1fr; }
  .home-currency-panel { padding: 14px; }
  .home-compare-key { width: 52px; }
  .home-compare-value { width: 96px; font-size: 11.5px; }
}

/* ---------------------------------------------------------------------------
   UI cleanup (overlaps)
   - Numbers in KPI cards / stat tiles never spill out of their card: they
     stay on one line and fitKpiValues() (app.js) shrinks the font until the
     full figure fits - digits are never cut with an ellipsis.
   - Buttons and tab pills don't break their label across lines; their
     containers wrap instead.
   - Small screens: the side menu becomes a drawer (the ≡ button opens it)
     and the top bar drops the secondary text.
--------------------------------------------------------------------------- */
.kpi-card, .stat-tile { min-width: 0; }
.kpi-value, .stat-tile-value {
  white-space: nowrap; overflow: hidden; text-overflow: clip;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.btn, .mode-btn, .view-tab-btn { white-space: nowrap; }
.mode-switch { flex-wrap: wrap; }
.chart-card-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.stat-tile-caption, .kpi-sub { overflow-wrap: anywhere; }
.load-status { min-width: 0; white-space: nowrap; }
.topbar-right { flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }

@media (max-width: 760px) {
  .sidenav {
    position: fixed; left: 0; top: 0; bottom: 0; height: 100vh;
    width: 240px; flex-basis: auto;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 0 10px 30px rgba(20, 26, 33, .25);
    z-index: 60;
  }
  .sidenav.collapsed { width: 240px; flex-basis: auto; }
  .sidenav.collapsed .sidenav-title,
  .sidenav.collapsed .sidenav-label,
  .sidenav.collapsed .sidenav-children { display: revert; }
  body.nav-open .sidenav { transform: none; }
  body.nav-open::after {
    content: ""; position: fixed; inset: 0; background: rgba(20, 26, 33, .35); z-index: 55;
  }
  .topbar { padding: 8px 12px; gap: 8px; }
  .load-status, #userEmail { display: none; }
  main { padding: 12px 12px 48px; }
  .mode-panel { padding: 10px; }
}

/* Usuarios: role checkboxes wrap inside their cell, actions stack when tight */
.usuario-roles { display: flex; flex-wrap: wrap; gap: 6px 12px; justify-content: center; max-width: 340px; margin: 0 auto; }
.usuario-role { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; white-space: nowrap; }
.usuario-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.usuario-actions .btn { padding: 5px 10px; font-size: 12.5px; }

@media (max-width: 760px) {
  .topbar { flex-wrap: nowrap; }
  #topbarBreadcrumb { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-right { flex-wrap: nowrap; gap: 6px; }
  .topbar .btn { padding: 6px 10px; }
  #reloadBtn .btn-label { display: none; }
}

/* ---------------------------------------------------------------------------
   Proyecciones: presupuesto por área, cierres trimestrales, versiones y
   reportes (business-plan.js / business-plan-control.js)
--------------------------------------------------------------------------- */
.bp-explain p { margin: 0 0 8px; font-size: 13.5px; line-height: 1.5; max-width: 980px; }
.bpc-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 8px 0; }
.bpc-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-dim); }
.bpc-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.btn.bpc-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.bpc-primary:hover { color: #fff; filter: brightness(1.06); }
.btn:disabled { opacity: .55; cursor: default; }
.bpc-file { display: inline-flex; align-items: center; gap: 6px; }
.bpc-version-banner {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  padding: 10px 14px; margin-bottom: 14px; border: 1px solid var(--accent); border-radius: var(--radius);
  background: var(--accent-soft); font-size: 13px;
}
.bpc-callout { padding: 10px 12px; margin-bottom: 10px; border-radius: 8px; background: var(--accent-soft); font-size: 13px; }
.bpc-status { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--text-dim); }
.bpc-status-aplicado { background: #e6f4ec; color: var(--good); }
.bpc-status-capturado { background: var(--accent-soft); color: var(--accent); }
.bpc-status-pendiente { background: #fbf3df; color: var(--warn); }
.bpc-status-vencido { background: #fbe9e7; color: var(--bad); }
.bpc-checks { list-style: none; padding: 0; margin: 8px 0 12px; display: grid; gap: 4px; font-size: 13px; }
.bpc-ok { color: var(--good); }
.bpc-bad { color: var(--bad); }
.bpc-info { color: var(--text-dim); }
.bpc-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 16px; }
.bpc-grid2 > div { min-width: 0; }
.bpc-details summary { cursor: pointer; font-size: 13px; color: var(--accent); margin: 12px 0 8px; }
.bpc-fav { font-size: 12px; font-weight: 600; white-space: nowrap; }
.bpc-fav-ok { color: var(--good); }
.bpc-fav-bad { color: var(--bad); }

/* Report (opens in its own tab, prints / saves as PDF) */
.bp-report-body { background: #fff; }
.bp-report { max-width: 1240px; margin: 0 auto; padding: 0 24px 48px; }
.bp-report-toolbar {
  position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  padding: 10px 0; margin-bottom: 16px; background: #fff; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text-dim);
}
.bp-report-cover { min-height: 70vh; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.bp-report-brand { font-weight: 800; letter-spacing: .08em; color: var(--accent); }
.bp-report-cover h1 { font-size: 30px; }
.bp-report-subtitle { font-size: 16px; color: var(--text-dim); }
.bp-report-meta { border-collapse: collapse; margin-top: 10px; }
.bp-report-meta td { padding: 4px 18px 4px 0; font-size: 13px; vertical-align: top; }
.bp-report-meta td:first-child { color: var(--text-dim); white-space: nowrap; }
.bp-report-conf { margin-top: 28px; font-size: 12px; color: var(--text-dim); }
.bp-report-toc { break-before: page; }
.bp-report-toc h2, .bp-report-section > h2 { font-size: 20px; padding-bottom: 6px; margin: 18px 0 12px; border-bottom: 2px solid var(--accent); }
.bp-report-toc ol { columns: 2; font-size: 14px; line-height: 1.9; }
.bp-report-toc a { color: var(--text); text-decoration: none; }
.bp-report-section { break-before: page; }
.bp-report-section h3 { margin: 14px 0 8px; }
.bp-report .table-scroll { max-height: none; overflow: visible; }
.bp-report .data-table { font-size: 11.5px; }
.bp-report [data-bp-csv], .bp-report .mode-switch, .bp-report .btn:not(#bprPrint), .bp-report .bpc-version-banner { display: none !important; }
.bp-report .mode-panel { box-shadow: none; }
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  .bp-report-toolbar { display: none; }
  .bp-report { padding: 0; max-width: none; }
  .bp-report .mode-panel { border: none; padding: 0; }
  .bp-report tr, .bp-report .kpi-card, .bp-report .chart-card { break-inside: avoid; }
  .bp-report thead { display: table-header-group; }
  .bp-report-body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

.bp-report-meta { width: auto; }
.bpc-actions { flex-wrap: nowrap; }
.bpc-actions .btn { padding: 4px 9px; font-size: 12px; white-space: nowrap; }
.bpc-note { white-space: normal; font-weight: 400; margin-top: 2px; max-width: 260px; }
.bpc-row > span, .bpc-callout { min-width: 0; overflow-wrap: anywhere; }
.bpc-inline { max-width: 100%; min-width: 0; flex-wrap: wrap; }
.bpc-inline select, .bpc-inline input { max-width: 100%; min-width: 0; }
