        :root {
            --bg: #F5F7F6;
            --surface: #FFFFFF;
            --ink: #16212B;
            --muted: #5B6672;
            --line: #DCE3E1;
            --navy: #173254;
            --navy-dark: #0E2038;
            --teal: #0E7C6B;
            --teal-dark: #0B6355;
            --amber: #C98A2C;
            --red: #B23B3B;
            --green-bg: #E8F4EE;
            --amber-bg: #FBF1E1;
            --indigo: #5C6BC0;
            --indigo-bg: #ECEEFA;
            /* Colores de marca (logo): rojo/verde/azul/oro, usados como acento por
               oferta (tarjetas, desglose, recomendación) y en las gráficas
               comparativas, para que se lean como colores propios de la marca. */
            --accent-red: #D6473E;
            --accent-red-bg: #FBEAE8;
            --accent-green: #3E9142;
            --accent-green-bg: #E9F5EA;
            --accent-blue: #4472C4;
            --accent-blue-bg: #EAF0FB;
            --accent-gold: #C79323;
            --accent-gold-bg: #FBF2E0;
            --radius: 10px;
            --font-display: 'Fraunces', Georgia, serif;
            --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
            --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Menlo, monospace;
        }

        * {
            box-sizing: border-box;
        }

        html,
        body {
            margin: 0;
            padding: 0;
        }

        body {
            background: var(--bg);
            color: var(--ink);
            font-family: var(--font-body);
            font-size: 14px;
            line-height: 1.5;
            -webkit-font-smoothing: antialiased;
        }

        #app {
            display: flex;
            min-height: 100vh;
        }

        /* ---------- sidebar ---------- */
        .sidebar {
            width: 230px;
            flex: 0 0 230px;
            background: var(--navy-dark);
            color: #DCE6EF;
            padding: 26px 20px;
            display: flex;
            flex-direction: column;
            gap: 28px;
        }

        .brand {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .brand-mark {
            width: 34px;
            height: 34px;
            border-radius: 8px;
            background: linear-gradient(135deg, var(--teal), var(--teal-dark));
            display: flex;
            align-items: center;
            justify-content: center;
            color: #fff;
            font-family: var(--font-display);
            font-weight: 700;
            font-size: 16px;
            flex: 0 0 auto;
        }

        .brand-text {
            font-family: var(--font-display);
            font-weight: 600;
            font-size: 15.5px;
            color: #F3F6F8;
            line-height: 1.2;
        }

        .brand-sub {
            font-size: 11px;
            color: #8EA3B8;
            margin-top: 2px;
        }

        nav.tabs {
            display: flex;
            flex-direction: column;
            gap: 4px;
        }

        .nav-btn {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 10px 12px;
            border-radius: 8px;
            border: none;
            background: transparent;
            color: #B9C8D6;
            font-family: var(--font-body);
            font-size: 13.5px;
            font-weight: 500;
            cursor: pointer;
            text-align: left;
        }

        .nav-btn:hover {
            background: rgba(255, 255, 255, 0.06);
            color: #fff;
        }

        .nav-btn.active {
            background: rgba(14, 124, 107, 0.22);
            color: #fff;
        }

        .count-badge {
            font-family: var(--font-mono);
            font-size: 11px;
            background: rgba(255, 255, 255, 0.1);
            padding: 1px 7px;
            border-radius: 20px;
            color: #CFE0EA;
        }

        .sidebar-hint {
            font-size: 11.5px;
            color: #75899C;
            line-height: 1.5;
            margin-top: auto;
        }

        /* ---------- main ---------- */
        .main {
            flex: 1;
            padding: 38px 44px 60px;
            max-width: 920px;
        }

        .eyebrow {
            font-family: var(--font-mono);
            font-size: 11px;
            letter-spacing: 0.08em;
            font-weight: 600;
            color: var(--teal-dark);
            text-transform: uppercase;
            margin: 0 0 8px;
        }

        h1.page-title {
            font-family: var(--font-display);
            font-weight: 600;
            font-size: 28px;
            margin: 0 0 6px;
            color: var(--navy-dark);
        }

        p.page-sub {
            color: var(--muted);
            font-size: 14px;
            margin: 0 0 28px;
            max-width: 560px;
        }

        /* ---------- upload screen ---------- */
        .dropzone {
            border: 1.5px dashed #B6C4CB;
            border-radius: 14px;
            background: var(--surface);
            padding: 52px 30px;
            text-align: center;
            cursor: pointer;
            transition: border-color .15s, background .15s;
        }

        .dropzone.drag {
            border-color: var(--teal);
            background: #F0F8F6;
        }

        .dropzone svg {
            margin-bottom: 14px;
        }

        .dropzone-title {
            font-family: var(--font-display);
            font-size: 18px;
            font-weight: 600;
            color: var(--navy-dark);
            margin: 0 0 6px;
        }

        .dropzone-sub {
            color: var(--muted);
            font-size: 13px;
            margin: 0;
        }

        .dropzone-meta {
            margin-top: 18px;
            font-family: var(--font-mono);
            font-size: 10.5px;
            color: #93A0AA;
            text-transform: uppercase;
            letter-spacing: .04em;
        }

        .dropzone-sm {
            padding: 22px 20px;
            max-width: 520px;
        }

        .dropzone-sm svg {
            margin-bottom: 8px;
        }

        .offer-chip-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
            margin-bottom: 18px;
            max-width: 520px;
        }

        .offer-chip {
            display: flex;
            align-items: center;
            justify-content: space-between;
            background: var(--surface);
            border: 1px solid var(--line);
            border-radius: 10px;
            padding: 10px 14px;
        }

        .offer-chip-info {
            display: flex;
            flex-direction: column;
            gap: 2px;
        }

        .offer-chip-name {
            font-family: var(--font-display);
            font-weight: 600;
            font-size: 13.5px;
            color: var(--navy-dark);
        }

        .offer-chip-meta {
            font-size: 11.5px;
            color: var(--muted);
            font-family: var(--font-mono);
        }

        .btn-chip-remove {
            background: transparent;
            border: none;
            color: #93A0AA;
            cursor: pointer;
            font-size: 14px;
            padding: 4px 8px;
            border-radius: 6px;
        }

        .btn-chip-remove:hover {
            background: #FBEEEE;
            color: var(--red);
        }

        /* ---------- loading / error ---------- */
        .center-screen {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 80px 20px;
            text-align: center;
        }

        .spinner {
            width: 38px;
            height: 38px;
            border-radius: 50%;
            border: 3px solid #DCE6E4;
            border-top-color: var(--teal);
            animation: spin 0.8s linear infinite;
            margin-bottom: 18px;
        }

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

        .loading-text {
            font-family: var(--font-display);
            font-size: 16px;
            color: var(--navy-dark);
            margin: 0 0 4px;
        }

        .loading-sub {
            color: var(--muted);
            font-size: 13px;
        }

        .error-box {
            max-width: 440px;
            background: #FBEEEE;
            border: 1px solid #EBC6C6;
            border-radius: 12px;
            padding: 26px 28px;
            text-align: left;
        }

        .error-title {
            font-weight: 600;
            color: var(--red);
            margin: 0 0 6px;
            font-size: 14.5px;
        }

        .error-msg {
            color: #7A3E3E;
            font-size: 13px;
            margin: 0 0 16px;
            line-height: 1.5;
        }

        /* ---------- buttons ---------- */
        .btn {
            font-family: var(--font-body);
            font-weight: 600;
            font-size: 13px;
            border-radius: 8px;
            padding: 9px 16px;
            cursor: pointer;
            border: 1px solid transparent;
            display: inline-flex;
            align-items: center;
            gap: 7px;
        }

        .btn-primary {
            background: var(--teal);
            color: #fff;
        }

        .btn-primary:hover {
            background: var(--teal-dark);
        }

        .btn-ghost {
            background: transparent;
            border-color: var(--line);
            color: var(--navy-dark);
        }

        .btn-ghost:hover {
            background: #EFF2F1;
        }

        .btn-danger {
            background: transparent;
            border-color: #E7C9C9;
            color: var(--red);
        }

        .btn-danger:hover {
            background: #FBEEEE;
        }

        .btn-sm {
            padding: 6px 11px;
            font-size: 12px;
        }

        /* ---------- report toolbar ---------- */
        .report-toolbar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 18px;
            gap: 10px;
            flex-wrap: wrap;
        }

        .toolbar-left {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .autosave-note {
            font-size: 11.5px;
            color: #8B98A3;
            font-style: italic;
        }

        /* ---------- report card ---------- */
        .report-printable {
            background: var(--surface);
            border: 1px solid var(--line);
            border-radius: 14px;
            padding: 36px 40px;
            max-width: 820px;
        }

        .report-brand-header {
            display: flex;
            align-items: center;
            gap: 10px;
            margin: 0 0 16px;
        }

        .report-brand-logo {
            max-height: 40px;
            max-width: 160px;
            width: auto;
            object-fit: contain;
        }

        .report-brand-name {
            font-family: var(--font-display);
            font-weight: 600;
            font-size: 15px;
            color: var(--navy-dark);
        }

        .report-kicker {
            font-family: var(--font-mono);
            font-size: 10.5px;
            letter-spacing: .08em;
            color: var(--teal-dark);
            text-transform: uppercase;
            font-weight: 600;
            margin: 0 0 8px;
        }

        .report-title {
            font-family: var(--font-display);
            font-size: 24px;
            font-weight: 600;
            color: var(--navy-dark);
            margin: 0 0 6px;
        }

        .report-subtitle {
            color: var(--muted);
            font-size: 13px;
            margin: 0 0 22px;
        }

        .advisor-summary {
            border: 1px solid #BFD8D3;
            border-left: 6px solid var(--teal-dark);
            border-radius: 12px;
            background: linear-gradient(180deg, #F7FBF9 0%, #FFFFFF 100%);
            padding: 20px 22px;
            margin: 18px 0 24px;
            page-break-inside: avoid;
            break-inside: avoid;
        }

        .advisor-verdict {
            margin-bottom: 16px;
        }

        .advisor-eyebrow {
            font-family: var(--font-mono);
            font-size: 10px;
            text-transform: uppercase;
            letter-spacing: .08em;
            color: var(--teal-dark);
            font-weight: 700;
            margin: 0 0 5px;
        }

        .advisor-verdict h2 {
            font-family: var(--font-display);
            font-size: 22px;
            line-height: 1.18;
            color: var(--navy-dark);
            margin: 0 0 6px;
        }

        .advisor-verdict p,
        .advisor-rationale p {
            font-size: 13px;
            line-height: 1.58;
            color: #2E3B45;
            margin: 0;
        }

        .advisor-metrics {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            gap: 10px;
            margin: 0 0 14px;
        }

        .advisor-metric {
            background: #FFFFFF;
            border: 1px solid var(--line);
            border-radius: 8px;
            padding: 11px 12px;
        }

        .advisor-metric span {
            display: block;
            font-family: var(--font-mono);
            font-size: 9.5px;
            text-transform: uppercase;
            letter-spacing: .04em;
            color: var(--muted);
            margin-bottom: 4px;
        }

        .advisor-metric strong {
            display: block;
            font-family: var(--font-display);
            font-size: 16px;
            line-height: 1.2;
            color: var(--teal-dark);
        }

        .advisor-rationale {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 14px;
            border-top: 1px solid var(--line);
            padding-top: 14px;
        }

        .ficha {
            border: 1px solid var(--line);
            border-radius: 10px;
            overflow: hidden;
            margin-bottom: 8px;
        }

        .ficha-row {
            display: flex;
            align-items: center;
            padding: 9px 14px;
            font-size: 13px;
            border-bottom: 1px solid var(--line);
        }

        .ficha-row:last-child {
            border-bottom: none;
        }

        .ficha-row:nth-child(odd) {
            background: #FAFBFA;
        }

        .ficha-label {
            width: 190px;
            flex: 0 0 190px;
            color: var(--muted);
            font-weight: 600;
            font-size: 12.5px;
        }

        .ficha-value {
            flex: 1;
            font-weight: 600;
            color: var(--navy-dark);
        }

        .ficha-value.missing {
            color: var(--red);
            font-weight: 500;
        }

        .ficha-value.missing-info {
            color: #93A0AA;
            font-weight: 500;
            font-style: italic;
        }

        input.field-edit {
            width: 100%;
            max-width: 420px;
            border: 1px solid transparent;
            background: #F1F5F4;
            border-radius: 6px;
            padding: 5px 8px;
            font-family: var(--font-body);
            font-size: 13px;
            font-weight: 600;
            color: var(--navy-dark);
        }

        input.field-edit:hover {
            border-color: var(--line);
        }

        input.field-edit:focus {
            outline: none;
            border-color: var(--teal);
            background: #fff;
        }

        input.field-edit::placeholder {
            color: #A6B0B8;
            font-weight: 500;
        }

        textarea.field-edit-area {
            width: 100%;
            max-width: 420px;
            min-height: 64px;
            resize: vertical;
            border: 1px solid transparent;
            background: #F1F5F4;
            border-radius: 6px;
            padding: 6px 8px;
            font-family: var(--font-body);
            font-size: 13px;
            font-weight: 500;
            line-height: 1.4;
            color: var(--navy-dark);
        }

        textarea.field-edit-area:hover {
            border-color: var(--line);
        }

        textarea.field-edit-area:focus {
            outline: none;
            border-color: var(--teal);
            background: #fff;
        }

        textarea.field-edit-area::placeholder {
            color: #A6B0B8;
            font-weight: 500;
        }

        .ficha-row-multiline {
            align-items: flex-start;
        }

        .ficha-row-multiline .ficha-label {
            padding-top: 6px;
        }

        .field-print {
            display: none;
        }

        .helper-note {
            font-size: 11px;
            color: #8B98A3;
            font-style: italic;
            margin: 8px 2px 22px;
        }

        h2.section-title {
            font-family: var(--font-display);
            font-size: 17px;
            font-weight: 600;
            color: var(--navy);
            border-bottom: 1px solid var(--line);
            padding-bottom: 8px;
            margin: 30px 0 14px;
            page-break-after: avoid;
            break-after: avoid;
        }

        p.section-intro {
            font-size: 13px;
            color: #3B4650;
            margin: 0 0 14px;
            line-height: 1.6;
        }

        table.data-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 12.5px;
            margin-bottom: 6px;
        }

        table.data-table td {
            padding: 8px 12px;
            border-bottom: 1px solid var(--line);
        }

        table.data-table tr:nth-child(odd) td {
            background: #FAFBFA;
        }

        table.data-table td.num {
            text-align: right;
            font-family: var(--font-mono);
            font-weight: 600;
        }

        table.data-table tr.total td {
            background: var(--navy);
            color: #fff;
            font-weight: 700;
            font-family: var(--font-mono);
        }

        table.data-table tr.total td.label {
            font-family: var(--font-body);
        }

        /* ---------- per-offer accent colors ----------
           Position-based, not semantic: 1st offer uploaded = rojo, 2nd = verde,
           3rd = azul, 4th = oro (colores de marca). Lets a client track the same
           offer across the savings card, the desglose block, the recommendation
           card and the comparison charts at a glance. */
        .offer-accent-1 {
            --offer-color: var(--accent-red);
            --offer-tint: var(--accent-red-bg);
        }

        .offer-accent-2 {
            --offer-color: var(--accent-green);
            --offer-tint: var(--accent-green-bg);
        }

        .offer-accent-3 {
            --offer-color: var(--accent-blue);
            --offer-tint: var(--accent-blue-bg);
        }

        .offer-accent-4 {
            --offer-color: var(--accent-gold);
            --offer-tint: var(--accent-gold-bg);
        }

        .savings-cards-row {
            display: flex;
            flex-wrap: wrap;
            gap: 14px;
            margin: 18px 0 22px;
        }

        .savings-card {
            flex: 1 1 220px;
            display: flex;
            align-items: center;
            gap: 14px;
            background: var(--offer-tint, var(--green-bg));
            border: 1px solid var(--line);
            border-left: 4px solid var(--offer-color, #BFE0CD);
            border-radius: 12px;
            padding: 16px 16px;
            page-break-inside: avoid;
            break-inside: avoid;
        }

        .savings-card-best {
            box-shadow: 0 3px 14px rgba(14, 32, 56, 0.1);
        }

        .charts-row {
            display: flex;
            flex-wrap: wrap;
            gap: 14px;
            margin: 0 0 26px;
        }

        .chart-box {
            flex: 1 1 280px;
            min-width: 0;
            border: 1px solid var(--line);
            border-radius: 10px;
            padding: 14px 16px 10px;
            background: #fff;
            break-inside: avoid;
        }

        .chart-canvas-wrap {
            position: relative;
            height: 220px;
        }

        .chart-title {
            font-size: 12px;
            font-weight: 600;
            color: var(--muted);
            margin: 0 0 10px;
        }

        .savings-crm {
            font-family: var(--font-display);
            font-weight: 600;
            font-size: 13px;
            color: var(--navy-dark);
            margin: 0 0 2px;
        }

        .best-tag {
            display: inline-block;
            font-family: var(--font-mono);
            font-size: 9.5px;
            text-transform: uppercase;
            letter-spacing: .03em;
            background: var(--teal);
            color: #fff;
            padding: 1px 6px;
            border-radius: 20px;
            margin-left: 6px;
            vertical-align: middle;
        }

        .gauge {
            flex: 0 0 auto;
        }

        .gauge text.gauge-text {
            font-family: var(--font-mono);
            font-size: 15px;
            font-weight: 600;
            fill: var(--navy-dark);
        }

        .savings-copy {
            flex: 1;
            min-width: 0;
        }

        .savings-main {
            font-family: var(--font-display);
            font-weight: 600;
            font-size: 16px;
            color: var(--teal-dark);
            margin: 0 0 4px;
        }

        .savings-sub {
            font-size: 12px;
            color: #3B4650;
            margin: 0;
        }

        .subsection-title {
            font-family: var(--font-display);
            font-size: 14px;
            font-weight: 600;
            color: var(--navy);
            margin: 0 0 10px;
        }

        .offer-ref {
            font-family: var(--font-mono);
            font-size: 11.5px;
            color: var(--muted);
            margin: -6px 0 12px;
        }

        .offer-block {
            margin-bottom: 22px;
            page-break-inside: avoid;
            break-inside: avoid;
        }

        .offer-block.offer-accent-1,
        .offer-block.offer-accent-2,
        .offer-block.offer-accent-3,
        .offer-block.offer-accent-4 {
            border-left: 3px solid var(--offer-color);
            padding-left: 14px;
        }

        .offer-recommendation {
            border-left: 4px solid var(--line);
            background: #FAFBFA;
            border-radius: 10px;
            padding: 16px 18px;
            margin-bottom: 14px;
            page-break-inside: avoid;
            break-inside: avoid;
        }

        .offer-recommendation.offer-accent-1,
        .offer-recommendation.offer-accent-2,
        .offer-recommendation.offer-accent-3,
        .offer-recommendation.offer-accent-4 {
            border-left-color: var(--offer-color);
            background: var(--offer-tint);
        }

        .offer-recommendation:last-child {
            margin-bottom: 0;
        }

        .offer-recommendation-name {
            font-family: var(--font-display);
            font-weight: 600;
            font-size: 14px;
            color: var(--navy-dark);
            margin: 0 0 6px;
        }

        ul.key-points {
            margin: 0 0 22px;
            padding: 0;
            list-style: none;
        }

        ul.key-points li {
            display: flex;
            gap: 10px;
            align-items: flex-start;
            font-size: 13px;
            color: #2B3640;
            padding: 6px 0;
        }

        ul.key-points li::before {
            content: '—';
            color: var(--teal-dark);
            font-weight: 700;
            flex: 0 0 auto;
        }

        .cta-box {
            background: linear-gradient(135deg, var(--teal), var(--teal-dark));
            color: #fff;
            border-radius: 12px;
            padding: 22px 26px;
            margin: 20px 0 22px;
            box-shadow: 0 6px 18px rgba(11, 99, 85, 0.28);
            page-break-inside: avoid;
            break-inside: avoid;
        }

        .cta-title {
            font-family: var(--font-display);
            font-size: 18px;
            font-weight: 600;
            color: #fff;
            margin: 0 0 9px;
        }

        .cta-line {
            font-size: 13px;
            color: rgba(255, 255, 255, 0.92);
            margin: 0 0 4px;
            line-height: 1.55;
        }

        .disclaimer {
            border-top: 1px solid var(--line);
            padding-top: 12px;
            margin-top: 22px;
            font-size: 11px;
            color: #93A0AA;
            font-style: italic;
            line-height: 1.6;
        }

        .meta-note {
            font-size: 10.5px;
            color: #B0BAC2;
            margin-top: 8px;
            font-family: var(--font-mono);
        }

        /* ---------- history ---------- */
        .history-grid {
            display: flex;
            flex-direction: column;
            gap: 10px;
            max-width: 760px;
        }

        .history-card {
            display: flex;
            align-items: center;
            gap: 16px;
            background: var(--surface);
            border: 1px solid var(--line);
            border-radius: 12px;
            padding: 14px 18px;
            cursor: pointer;
            transition: border-color .12s, box-shadow .12s;
        }

        .history-card:hover {
            border-color: var(--teal);
            box-shadow: 0 2px 10px rgba(14, 124, 107, 0.08);
        }

        .history-info {
            flex: 1;
            min-width: 0;
        }

        .history-top {
            display: flex;
            align-items: baseline;
            gap: 8px;
            flex-wrap: wrap;
        }

        .history-crm {
            font-family: var(--font-display);
            font-weight: 600;
            font-size: 14.5px;
            color: var(--navy-dark);
        }

        .history-client {
            font-size: 12px;
            color: var(--muted);
        }

        .history-meta {
            font-size: 11px;
            color: #93A0AA;
            margin-top: 3px;
            font-family: var(--font-mono);
        }

        .history-amount {
            font-family: var(--font-mono);
            font-size: 13px;
            font-weight: 600;
            color: var(--navy-dark);
            white-space: nowrap;
        }

        .history-del {
            flex: 0 0 auto;
        }

        .empty-state {
            padding: 60px 20px;
            text-align: center;
            color: var(--muted);
        }

        .empty-state p {
            margin: 0 0 16px;
            font-size: 13.5px;
        }

        @media (max-width: 760px) {
            .report-printable {
                padding: 26px 22px;
            }

            .advisor-metrics,
            .advisor-rationale {
                grid-template-columns: 1fr;
            }

            .advisor-verdict h2 {
                font-size: 19px;
            }

            .ficha-row {
                align-items: flex-start;
                flex-direction: column;
                gap: 4px;
            }

            .ficha-label {
                width: auto;
                flex: 0 0 auto;
            }
        }

        @media print {

            .sidebar,
            .report-toolbar,
            .no-print {
                display: none !important;
            }

            body {
                background: #fff;
            }

            .main {
                padding: 0;
                max-width: none;
            }

            .report-printable {
                border: none;
                padding: 0;
                max-width: none;
            }

            input.field-edit,
            textarea.field-edit-area {
                display: none !important;
            }

            .ficha-row-empty {
                display: none !important;
            }

            .ficha-client:not(:has(.ficha-row:not(.ficha-row-empty))),
            .ficha-notas:not(:has(.ficha-row:not(.ficha-row-empty))) {
                display: none !important;
            }

            .field-print {
                display: inline !important;
            }

            .field-print-multiline {
                display: block !important;
                white-space: pre-wrap;
            }
        }
