/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', system-ui, sans-serif; background-color: #f8fafc; color: #334155; line-height: 1.5; }
h1, h2, h3, h4, p, ul, li, figure { margin: 0; padding: 0; }
ul { list-style: none; }
button { font-family: inherit; }

/* Container */
#app { max-width: 1000px; margin: 0 auto; padding: 2rem 1rem; }

/* Typography */
.eyebrow { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; color: #94a3b8; letter-spacing: 0.05em; display: block; margin-bottom: 0.5rem; }
.page-title { font-size: 2rem; font-weight: 800; color: #0f172a; margin-bottom: 0.5rem; }
.subline { color: #64748b; font-size: 1rem; }
.badge-version { background: #f1f5f9; color: #475569; padding: 0.125rem 0.375rem; border-radius: 4px; font-size: 0.75rem; font-family: monospace; }
.section-title { font-size: 1.5rem; font-weight: 800; color: #0f172a; margin-bottom: 2rem; border-left: 4px solid #0f172a; padding-left: 1rem; }
.section-label { font-size: 0.875rem; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 1rem; }

/* Header */
.budget-header { margin-bottom: 3rem; border-bottom: 1px solid #e2e8f0; padding-bottom: 2rem; }
.header-top { display: flex; flex-direction: column; gap: 1.5rem; justify-content: space-between; margin-bottom: 2rem; }
.status-badge { display: inline-block; padding: 0.25rem 0.75rem; border-radius: 9999px; font-size: 0.875rem; font-weight: 600; }
.status-badge.enviado { background: #fef3c7; color: #b45309; }
.status-badge.aceptado { background: #dcfce7; color: #15803d; }

.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; background: #fff; padding: 1.5rem; border-radius: 8px; border: 1px solid #e2e8f0; }
.kpi-label { font-size: 0.75rem; color: #94a3b8; text-transform: uppercase; margin-bottom: 0.25rem; }
.kpi-value { font-size: 1.25rem; font-weight: 600; color: #334155; }
.kpi-value.discount { color: #16a34a; }
.kpi-value.total { font-size: 1.5rem; font-weight: 800; color: #0f172a; }
.kpi-actions { display: flex; align-items: center; justify-content: center; }

/* Contacts */
.contacts-section { display: grid; gap: 3rem; margin-bottom: 4rem; }
.contact-name { font-size: 1.125rem; font-weight: 600; color: #0f172a; }
.contact-details { color: #475569; }
.contact-email { font-size: 0.875rem; color: #64748b; margin-top: 0.5rem; }
.payment-terms { margin-top: 1rem; padding: 0.75rem; background: #eff6ff; color: #1e40af; border: 1px solid #dbeafe; border-radius: 4px; font-size: 0.875rem; }

/* Scope */
.scope-section { margin-bottom: 4rem; }
.scope-grid { display: grid; gap: 2rem; margin-bottom: 1.5rem; }
.scope-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 1.5rem; box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05); }
.scope-card.excludes { opacity: 0.75; }
.card-title { font-size: 1.125rem; font-weight: 700; color: #1e293b; margin-bottom: 1rem; display: flex; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; margin-right: 0.5rem; }
.dot.green { background: #22c55e; }
.dot.red { background: #f87171; }
.scope-card ul li { margin-bottom: 0.5rem; padding-left: 1rem; position: relative; font-size: 0.95rem; color: #475569; }
.scope-card ul li::before { content: "•"; position: absolute; left: 0; color: #cbd5e1; }
.scope-assumptions { font-size: 0.75rem; color: #94a3b8; font-style: italic; }

/* Items */
.items-section { margin-bottom: 4rem; }
.items-list { display: flex; flex-direction: column; gap: 1.5rem; }
.item-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05); overflow: hidden; page-break-inside: avoid; }
.item-main { padding: 1.5rem; }
.item-header { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.item-category { display: inline-block; background: #f1f5f9; color: #64748b; font-size: 0.75rem; font-weight: 700; padding: 0.125rem 0.5rem; border-radius: 4px; text-transform: uppercase; margin-bottom: 0.5rem; }
.item-title { font-size: 1.25rem; font-weight: 700; color: #0f172a; }
.item-pricing { text-align: left; }
.item-price { font-size: 1.5rem; font-weight: 800; color: #0f172a; }
.item-discount-label { font-size: 0.75rem; color: #16a34a; font-weight: 500; }
.item-description { color: #475569; margin-bottom: 1.5rem; leading-relaxed; }
.item-deliverables { margin-bottom: 1.5rem; }
.deliverables-label { font-size: 0.875rem; font-weight: 700; color: #0f172a; margin-bottom: 0.5rem; }
.tags { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag { background: #f8fafc; border: 1px solid #e2e8f0; color: #475569; padding: 0.25rem 0.75rem; border-radius: 9999px; font-size: 0.75rem; }

/* References */
.item-references { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid #f1f5f9; }
.btn-toggle-refs { background: none; border: none; color: #2563eb; font-size: 0.875rem; font-weight: 500; cursor: pointer; padding: 0; display: flex; align-items: center; }
.btn-toggle-refs:hover { color: #1e40af; text-decoration: underline; }
.btn-toggle-refs .icon { margin-right: 0.25rem; }
.refs-content { margin-top: 1rem; background: #f8fafc; padding: 1rem; border-radius: 4px; border: 1px solid #e2e8f0; display: flex; flex-direction: column; gap: 1rem; }
.hidden { display: none; }
.ref-link a { color: #2563eb; text-decoration: none; font-size: 0.875rem; }
.ref-link a:hover { text-decoration: underline; }
.ref-images { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.ref-img-wrapper { position: relative; cursor: pointer; aspect-ratio: 16/9; }
.ref-img-wrapper img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; border: 1px solid #e2e8f0; }
.ref-img-wrapper .overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); color: #fff; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.2s; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
.ref-img-wrapper:hover .overlay { opacity: 1; }
.snippet-block { }
.snippet-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.25rem; }
.snippet-header span { font-size: 0.75rem; font-weight: 700; color: #64748b; text-transform: uppercase; }
.btn-copy { background: none; border: none; color: #2563eb; font-size: 0.75rem; cursor: pointer; }
.snippet-block pre { background: #0f172a; color: #f8fafc; padding: 0.75rem; border-radius: 4px; font-size: 0.75rem; overflow-x: auto; }

/* Summary */
.summary-section { margin-bottom: 4rem; display: flex; justify-content: flex-end; }
.summary-card { background: #0f172a; color: #fff; border-radius: 8px; padding: 2rem; width: 100%; max-width: 400px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); page-break-inside: avoid; }
.summary-title { font-size: 1.125rem; font-weight: 700; margin-bottom: 1.5rem; border-bottom: 1px solid #334155; padding-bottom: 0.5rem; }
.summary-rows { display: flex; flex-direction: column; gap: 0.75rem; font-size: 0.875rem; }
.summary-row { display: flex; justify-content: space-between; color: #94a3b8; }
.summary-row.discount { color: #4ade80; }
.summary-row.total { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #334155; color: #fff; font-size: 1.25rem; font-weight: 800; align-items: flex-end; }

/* Footer */
.budget-footer { border-top: 1px solid #e2e8f0; padding-top: 3rem; padding-bottom: 6rem; }
.footer-content { display: grid; gap: 2rem; margin-bottom: 2rem; }
.notes-title { font-weight: 700; color: #0f172a; margin-bottom: 0.5rem; }
.notes-list { list-style: disc inside; font-size: 0.875rem; color: #475569; }
.footer-actions { display: flex; flex-direction: column; gap: 1rem; align-items: flex-start; }
.footer-meta { text-align: center; font-size: 0.75rem; color: #94a3b8; margin-top: 3rem; }

/* Buttons */
.btn-primary { display: inline-block; background: #0f172a; color: #fff; padding: 0.5rem 1rem; border-radius: 4px; font-weight: 500; text-decoration: none; transition: background 0.2s; font-size: 0.875rem; border: none; cursor: pointer; text-align: center; }
.btn-primary:hover { background: #1e293b; }
.btn-primary.large { padding: 0.75rem 2rem; font-size: 1rem; }
.btn-secondary { display: inline-block; color: #475569; text-decoration: underline; font-size: 0.875rem; cursor: pointer; }
.btn-secondary:hover { color: #0f172a; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 1rem; cursor: pointer; }
.modal-image { max-width: 100%; max-height: 100%; border-radius: 4px; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); }

/* Responsive Desktop */
@media (min-width: 768px) {
    #app { padding: 4rem 2rem; }
    .header-top { flex-direction: row; align-items: flex-end; }
    .page-title { font-size: 3rem; }
    .kpi-grid { grid-template-columns: repeat(4, 1fr); }
    .contacts-section { grid-template-columns: repeat(2, 1fr); }
    .scope-grid { grid-template-columns: repeat(2, 1fr); }
    .item-header { flex-direction: row; justify-content: space-between; align-items: flex-start; }
    .item-pricing { text-align: right; }
    .ref-images { grid-template-columns: repeat(4, 1fr); }
    .footer-content { grid-template-columns: repeat(2, 1fr); }
    .footer-actions { align-items: flex-end; }
}

/* Print */
@media print {
    body { background: #fff; }
    #app { max-width: none; padding: 0; }
    .budget-header, .contacts-section, .scope-section, .items-section, .summary-section, .budget-footer { margin-bottom: 2rem; }
    .item-card, .scope-card { box-shadow: none; border: 1px solid #cbd5e1; }
    .btn-primary, .btn-secondary, .btn-toggle-refs, .kpi-actions button, #auth-overlay button { display: none !important; }
    .hidden { display: block !important; } /* Show references if hidden? Maybe not refs content. */
    .refs-content.hidden { display: none !important; } /* Keep them hidden unless we want them printed. Usually detailed evidence isn't printed if collapsed. */
    .fixed { display: none !important; } /* Hide logout button */
    .kpi-actions { display: none; }
}
