:root {
  --navy: #0b2c51;
  --navy-2: #123a68;
  --green: #1f7a4d;
  --green-dark: #1b662e;
  --red: #e0473d;
  --amber: #f2a91b;
  --gray-border: #e2e6ec;
  --gray-text: #6b7686;
  --bg: #eef1f6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  font-family: "Segoe UI", Roboto, Arial, Helvetica, sans-serif;
  color: var(--navy);
  -webkit-font-smoothing: antialiased;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: var(--navy);
  color: #fff;
  font-size: 13px;
}
.toolbar-actions { display: flex; gap: 8px; flex-shrink: 0; }
.toolbar button {
  background: #fff;
  color: var(--navy);
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.toolbar button:hover { background: #dfe6f0; }
.toolbar button:disabled { opacity: .6; cursor: wait; }
#pdfBtn { background: var(--green); color: #fff; }
#pdfBtn:hover { background: #1a6841; }

.page {
  max-width: 900px;
  margin: 24px auto 60px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(11,44,81,.12);
  overflow: hidden;
  padding-bottom: 8px;
}

/* ---------- editable fields ---------- */
[contenteditable="true"] {
  border-bottom: 1px dashed rgba(11,44,81,.35);
  outline: none;
  cursor: text;
  border-radius: 2px;
  padding: 0 1px;
}
[contenteditable="true"]:hover { background: rgba(31,122,77,.08); }
[contenteditable="true"]:focus { background: rgba(31,122,77,.14); border-bottom-color: var(--green); }

/* ---------- header ---------- */
.header { position: relative; overflow: hidden; min-height: 168px; }
.header-bg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.header-content {
  position: relative; z-index: 1;
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 18px; padding: 26px 30px 20px;
}
.brand { width: 230px; color: #fff; flex-shrink: 0; }
.brand-logo { display: flex; align-items: center; gap: 6px; }
.logo-mark { width: 30px; height: 26px; }
.brand-name { font-size: 22px; font-weight: 800; }
.brand-sub { font-size: 9px; letter-spacing: .3px; line-height: 1.5; margin-top: 8px; opacity: .92; }

.title-block { flex: 1; text-align: center; padding-top: 4px; }
.title-block h1 { margin: 0; font-size: 26px; line-height: 1.15; letter-spacing: .5px; }
.t-navy { color: var(--navy); font-weight: 800; }
.t-green { color: var(--green); font-weight: 800; font-size: 22px; }
.subtitle { margin: 8px 0 0; font-size: 12.5px; color: #33475a; line-height: 1.5; }

.date-card {
  flex-shrink: 0; width: 190px;
  background: #fff; border: 1px solid var(--gray-border); border-radius: 10px;
  padding: 10px 12px; display: flex; gap: 10px; align-items: flex-start;
  box-shadow: 0 2px 6px rgba(11,44,81,.06);
}
.date-label { font-size: 10.5px; color: var(--gray-text); line-height: 1.3; }
.date-value { font-size: 17px; font-weight: 800; color: var(--green); margin: 2px 0; }
.date-sub { font-size: 10.5px; color: var(--gray-text); }

.greeting { padding: 10px 30px 4px; font-size: 14px; }
.greeting b { color: var(--green); }

/* ---------- sections ---------- */
.section { margin: 14px 24px; border: 1px solid var(--gray-border); border-radius: 12px; padding: 18px 22px 20px; }
.section-title { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 14px; margin-bottom: 16px; color: var(--navy); }
.badge { background: var(--navy); color: #fff; font-weight: 800; font-size: 13px; padding: 3px 9px; border-radius: 6px; }

.icon { width: 30px; height: 30px; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-green { stroke: var(--green); color: var(--green); }
.icon-green-dark { stroke: var(--green-dark); fill: var(--green-dark); color: var(--green-dark); }
.icon-lg { width: 40px; height: 40px; }
.icon-white { stroke: #fff; width: 26px; height: 26px; }
.icon-white-sm { fill: #fff; stroke: none; width: 13px; height: 13px; vertical-align: -2px; }

/* KPI row */
.kpi-row { display: flex; }
.kpi { flex: 1; text-align: center; padding: 0 10px; position: relative; }
.kpi + .kpi::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 1px; background: var(--gray-border); }
.kpi .icon { margin-bottom: 6px; }
.kpi-label { font-size: 10.5px; font-weight: 700; color: var(--navy); letter-spacing: .2px; margin-bottom: 4px; }
.kpi-value { font-size: 19px; font-weight: 800; color: var(--green); }
.kpi-sub { font-size: 10px; color: var(--gray-text); margin-top: 3px; line-height: 1.35; }

/* two-col layout */
.two-col { display: flex; gap: 16px; margin-top: 18px; align-items: stretch; }
.two-col > .panel:first-child { flex: 1.7; }
.two-col > .panel:last-child { flex: 1; }
.panel { border: 1px solid var(--gray-border); border-radius: 10px; padding: 14px 16px; background: #fff; }
.panel-title { font-weight: 800; font-size: 12px; text-align: center; color: var(--navy); }

/* gauge */
.gauge-wrap { position: relative; margin-top: 6px; }
.gauge-svg { width: 100%; display: block; }
.gauge-labels { position: absolute; top: 38%; left: 0; right: 0; display: flex; justify-content: space-between; font-size: 10.5px; padding: 0 4px; }
.gauge-zone { text-align: center; width: 32%; line-height: 1.4; }
.gauge-zone-left { text-align: left; }
.gauge-zone-right { text-align: right; }
.gauge-value { position: absolute; bottom: 6%; left: 0; right: 0; text-align: center; font-size: 26px; font-weight: 800; color: var(--red); }
.gauge-note { text-align: center; font-size: 11px; color: #33475a; margin-top: 4px; line-height: 1.4; }

.c-red { color: var(--red); }
.c-amber { color: var(--amber); }
.c-green { color: var(--green); }

/* semaforo */
.semaforo-panel { display: flex; flex-direction: column; justify-content: center; }
.semaforo-head { display: flex; gap: 10px; align-items: flex-start; font-size: 11.5px; margin-bottom: 12px; }
.risk-list { list-style: none; margin: 0; padding: 0; font-size: 11px; display: flex; flex-direction: column; gap: 8px; }
.risk-list li { display: flex; align-items: center; gap: 8px; }
.dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.dot-red { background: var(--red); }
.dot-amber { background: var(--amber); }
.dot-green { background: var(--green); }

/* protection row */
.protection-row { display: flex; gap: 18px; align-items: stretch; }
.protection-item { flex: 1; display: flex; gap: 12px; align-items: flex-start; padding-right: 18px; border-right: 1px solid var(--gray-border); }
.protection-row .protection-item:last-of-type { border-right: none; }
.p-label { font-size: 10.5px; font-weight: 800; color: var(--navy); margin-bottom: 4px; }
.p-value { font-size: 18px; font-weight: 800; color: var(--navy-2); margin-bottom: 3px; }
.p-sub { font-size: 10px; color: var(--gray-text); line-height: 1.4; }
.protection-panel { flex: 1; display: flex; gap: 12px; align-items: center; background: #f4f8f5; border: 1px solid var(--gray-border); border-radius: 10px; padding: 14px 16px; font-size: 12px; }

/* area chart */
.chart-wrap { position: relative; }
.area-svg { width: 100%; display: block; }
.area-note { font-size: 9.5px; color: var(--gray-text); margin-top: 2px; }
.chart-label { position: absolute; font-size: 11px; line-height: 1.35; white-space: nowrap; }
.chart-label-title { font-weight: 800; color: var(--navy); }
.chart-label-value { font-weight: 800; color: var(--green); }
.chart-label-start { transform: translateY(-108%); }
.chart-label-end { transform: translate(-100%, -108%); text-align: right; }

/* origin panel */
.origin-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--gray-border); }
.origin-icon { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.origin-icon svg { width: 15px; height: 15px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.origin-icon-green { background: var(--green); }
.origin-icon-navy { background: var(--navy); }
.origin-text { flex: 1; font-size: 11px; color: var(--navy); line-height: 1.3; }
.origin-val { text-align: right; font-size: 12px; font-weight: 700; color: var(--navy); line-height: 1.3; }
.origin-pct { font-weight: 400; font-size: 10.5px; color: var(--gray-text); }
.origin-total { margin-top: 10px; background: var(--navy); color: #fff; border-radius: 8px; padding: 9px 12px; display: flex; justify-content: space-between; align-items: center; font-size: 10.5px; font-weight: 700; }
.origin-total span:last-child { font-size: 13px; }

/* scenarios */
.scenarios-row { display: flex; gap: 16px; margin-top: 16px; align-items: stretch; }
.scenarios-panel { flex: 3; border: 1px solid var(--gray-border); border-radius: 10px; padding: 16px 18px; }
.scen-grid { display: grid; grid-template-columns: 1.1fr 1fr 1fr 1fr; gap: 14px; }
.scen-legend { border-right: 1px solid var(--gray-border); padding-right: 12px; }
.scen-legend-sub { font-weight: 400; color: var(--gray-text); font-size: 9.5px; }
.legend-line { font-size: 10px; color: #33475a; display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.line-solid { width: 16px; height: 2px; background: var(--green); display: inline-block; }
.line-dashed { width: 16px; height: 0; border-top: 2px dashed var(--navy); display: inline-block; }

.scen-col { text-align: center; display: flex; flex-direction: column; align-items: center; }
.scen-title { font-size: 10.5px; font-weight: 800; min-height: 40px; }
.scen-title-sub { font-weight: 400; font-size: 9px; color: var(--gray-text); }
.scen-value { font-size: 17px; font-weight: 800; margin-top: 6px; }
.scen-sub { font-size: 10.5px; color: var(--gray-text); margin-bottom: 8px; }
.scen-bar-wrap { width: 100%; height: 90px; display: flex; align-items: flex-end; justify-content: center; border-bottom: 2px solid var(--navy); }
.scen-bar { width: 46px; border-radius: 4px 4px 0 0; transition: height .15s; }
.bar-red { background: var(--red); }
.bar-amber { background: var(--amber); }
.bar-green { background: var(--green); }
.scen-delta { font-size: 10.5px; font-weight: 700; margin-top: 8px; line-height: 1.3; }
.scen-footnote { font-size: 9.5px; color: var(--gray-text); margin-top: 14px; }

/* score panel */
.score-panel { flex: 1; border: 1px solid var(--gray-border); border-radius: 10px; padding: 16px 16px; text-align: center; display: flex; flex-direction: column; align-items: center; }
.score-wrap { position: relative; width: 120px; height: 120px; margin: 10px auto; }
.score-svg { width: 100%; height: 100%; }
.score-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score-num { font-size: 26px; font-weight: 800; color: var(--navy); min-width: 1ch; }
.score-den { font-size: 10px; color: var(--gray-text); font-weight: 700; }
.score-note { font-size: 10.5px; color: #33475a; line-height: 1.4; margin-top: 4px; }
.score-link { font-size: 10.5px; color: var(--navy); font-weight: 700; margin-top: 10px; }

/* quote */
.quote { margin: 14px 24px; border: 1px solid var(--gray-border); border-radius: 12px; padding: 14px 20px; display: flex; gap: 14px; align-items: flex-start; background: #fbfdfb; }
.quote-title { font-weight: 800; font-size: 12px; text-align: center; margin-bottom: 6px; color: var(--navy); }
.quote div div { font-size: 11.5px; line-height: 1.5; color: #33475a; }
.quote-strong { color: var(--green); font-weight: 700; margin-top: 2px; }

/* footer */
.footer { margin-top: 6px; background: var(--navy); color: #fff; padding: 16px 30px; display: flex; justify-content: space-between; align-items: center; gap: 20px; font-size: 11px; }
.footer-left { display: flex; gap: 12px; align-items: center; line-height: 1.5; }
.footer-right { text-align: right; line-height: 1.8; }

/* ---------- print ---------- */
@media print {
  @page { size: A4; margin: 8mm; }
  .no-print { display: none !important; }
  body { background: #fff; }
  .page { max-width: none; margin: 0; box-shadow: none; border-radius: 0; }
  [contenteditable="true"] { border-bottom: none; }
  [contenteditable="true"]:hover, [contenteditable="true"]:focus { background: none; }
  .section, .quote { break-inside: avoid; }
}
