:root {
  --ink: #173d35;
  --ink-2: #28574d;
  --accent: #e5a850;
  --accent-soft: #fff4df;
  --paper: #f6f4ef;
  --white: #fff;
  --muted: #71817c;
  --line: #dfe5e1;
  --danger: #b84a3d;
  --shadow: 0 14px 40px rgba(26, 61, 53, .08);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-variant-numeric: tabular-nums; }
button, input, select { font: inherit; }
button { color: inherit; }
.topbar { max-width: 1400px; margin: 0 auto; padding: 34px 34px 24px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.eyebrow, .section-number { margin: 0 0 5px; color: var(--accent); font-weight: 800; font-size: 11px; letter-spacing: .15em; }
h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(27px, 4vw, 42px); line-height: 1.1; outline: none; }
h1:focus { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 5px; }
.save-state { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.version-line { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.version-line .save-state { margin: 0; }
.version-badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.version-badge.local { background: #e9edeb; color: var(--muted); }
.version-badge.server { background: #dceee5; color: #286444; }
.header-actions { display: flex; gap: 10px; }
.button { border: 0; border-radius: 10px; padding: 13px 17px; cursor: pointer; font-weight: 750; transition: transform .15s, opacity .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button.primary { background: var(--ink); color: white; box-shadow: 0 7px 18px rgba(23, 61, 53, .22); }
.button.secondary { background: transparent; border: 1px solid var(--line); }
.logout-link { display: inline-flex; align-items: center; text-decoration: none; }
main { max-width: 1400px; margin: 0 auto; padding: 0 34px 70px; }
.hero-grid { position: sticky; top: 0; z-index: 8; display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin: 12px -8px 22px; padding: 8px; border-radius: 14px; background: rgba(246, 244, 239, .93); backdrop-filter: blur(12px); }
.summary-card { min-height: 105px; padding: 15px 17px; background: var(--white); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; box-shadow: 0 7px 24px rgba(26, 61, 53, .07); }
.summary-card span { font-size: 13px; font-weight: 750; color: var(--muted); }
.summary-card strong { margin: auto 0 2px; font-family: Georgia, serif; font-size: clamp(21px, 2vw, 29px); }
.summary-card small { color: var(--muted); }
.summary-card.dark { color: white; background: var(--ink); border-color: var(--ink); }
.summary-card.dark span, .summary-card.dark small { color: #b9cec8; }
.summary-card.accent { background: var(--accent-soft); border-color: #f1d49e; }
.panel { margin-top: 16px; padding: 28px; background: var(--white); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
h2 { margin: 0 0 5px; font-family: Georgia, serif; font-size: 25px; }
h3 { margin: 0 0 4px; font-family: Georgia, serif; font-size: 21px; }
.section-heading p:last-child { margin: 0; color: var(--muted); font-size: 14px; }
.section-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 14px; }
.text-button, .link-button { border: 0; background: none; padding: 5px 0; color: var(--ink-2); cursor: pointer; font-weight: 800; }
.text-button { white-space: nowrap; border-bottom: 2px solid var(--accent); }
.link-button { color: var(--muted); font-size: 12px; text-decoration: underline; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 720px; }
.quotes-table { table-layout: fixed; }
.quotes-table .quote-name-column { width: 28%; }
.quotes-table .quote-money-column { width: 24%; }
.quotes-table .quote-action-column { width: 42px; }
.quotes-table thead th:first-child, .quotes-table tfoot th:first-child { padding-left: 10px; }
.quotes-table th.money-column { padding-right: 10px; text-align: right; }
.quotes-table td:nth-child(2), .quotes-table td:nth-child(3), .quotes-table td:nth-child(4) { text-align: right; }
.quotes-table .money-input { display: block; width: 100%; margin: 0; }
.quotes-table input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
.quotes-table input[type="number"]::-webkit-inner-spin-button,
.quotes-table input[type="number"]::-webkit-outer-spin-button { margin: 0; -webkit-appearance: none; }
.quote-name-field { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 7px; align-items: center; }
.quote-selector { width: 17px; height: 17px; margin: 0; padding: 0; border-color: var(--line); accent-color: var(--ink); cursor: pointer; }
.quotes-table tbody tr { transition: background .15s, box-shadow .15s; cursor: pointer; }
.quotes-table tbody tr.selected { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.quotes-table tbody tr.selected input { color: var(--ink); }
.quote-selection-summary { display: grid; grid-template-columns: .7fr repeat(3, 1fr); gap: 9px; margin-top: 18px; padding-top: 17px; border-top: 1px solid var(--line); }
.quote-selection-summary > div { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfb; }
.quote-selection-summary > div.highlight { background: #f6f4ef; }
.quote-selection-summary.has-selection > div.highlight { border-color: #f1d49e; background: var(--accent-soft); }
.quote-selection-summary span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; font-weight: 750; }
.quote-selection-summary strong { display: block; font-family: Georgia, serif; font-size: 19px; }
th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
th, td { padding: 11px 8px; border-bottom: 1px solid #edf0ee; }
td:first-child, th:first-child { padding-left: 0; }
td:last-child, th:last-child { width: 36px; padding-right: 0; }
tfoot th { padding-top: 18px; border-bottom: 0; color: var(--ink); font-size: 14px; }
input, select { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 9px; padding: 11px 12px; background: #fbfcfb; color: var(--ink); outline: none; transition: border .15s, box-shadow .15s; }
input:focus, select:focus { border-color: var(--ink-2); box-shadow: 0 0 0 3px rgba(40, 87, 77, .1); }
table input { padding: 9px 10px; border-color: transparent; background: transparent; }
table input:hover, table input:focus { border-color: var(--line); background: white; }
.money-input { text-align: right; }
.remove-button { width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; }
.remove-button:hover { background: #fff0ed; color: var(--danger); }
.field-grid.one-line { max-width: 360px; margin-bottom: 18px; }
label > span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 12px; font-weight: 750; }
.input-suffix { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfb; overflow: hidden; }
.input-suffix:focus-within { border-color: var(--ink-2); box-shadow: 0 0 0 3px rgba(40, 87, 77, .1); }
.input-suffix input { border: 0; background: transparent; box-shadow: none; text-align: right; }
.input-suffix span { padding: 0 12px; color: var(--muted); font-size: 13px; }
.lenders-list { display: grid; gap: 9px; }
.lender-row { display: grid; grid-template-columns: minmax(150px, 1.5fr) repeat(3, minmax(110px, 1fr)) 34px; gap: 10px; align-items: end; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.contribution-row { grid-template-columns: minmax(150px, 1.5fr) minmax(130px, 1fr) minmax(135px, .85fr) minmax(190px, 1.2fr) 78px 34px; }
.investor-row { grid-template-columns: minmax(150px, 1.5fr) minmax(120px, 1fr) minmax(82px, .6fr) minmax(90px, .65fr) minmax(130px, .85fr) 78px 34px; }
.lender-row label span { white-space: nowrap; }
.lender-row.paid { border-color: #9fcdb3; background: #f1f8f4; }
.paid-toggle .check-control { display: flex; align-items: center; gap: 7px; min-height: 43px; margin: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--ink); cursor: pointer; font-size: 12px; font-weight: 800; }
.paid-toggle .check-control input { flex: 0 0 auto; width: 17px; height: 17px; margin: 0; padding: 0; accent-color: #286444; cursor: pointer; }
.funding-groups { display: grid; gap: 18px; }
.funding-group { padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: #fbfcfb; }
.contribution-group { border-left: 4px solid #5d86a6; }
.investor-group { border-left: 4px solid var(--accent); }
.funding-group-heading { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 16px; }
.funding-group-heading p:not(.funding-kind) { margin: 0; color: var(--muted); font-size: 13px; }
.funding-kind { margin: 0 0 4px; color: var(--muted); font-size: 9px; font-weight: 850; letter-spacing: .12em; }
.repayment-mode { min-width: 0; padding: 9px 11px; border-radius: 9px; background: #eef4f7; }
.repayment-mode span { display: block; margin-bottom: 3px; color: var(--muted); font-size: 11px; font-weight: 750; }
.repayment-mode strong { display: block; font-size: 12px; }
.group-total { margin-top: 13px; padding-top: 13px; }
.vat-coverage { margin: 10px 0 0; padding: 9px 11px; border-radius: 8px; background: #edf6f0; color: #286444; font-size: 12px; }
.vat-coverage.warning { background: #fff4df; color: #8a5a16; }
.funding-grand-total { display: flex; justify-content: flex-end; align-items: baseline; gap: 28px; margin-top: 18px; padding: 16px 18px; border-radius: 11px; background: var(--ink); color: white; }
.funding-grand-total span { color: #b9cec8; font-size: 13px; font-weight: 750; }
.funding-grand-total strong { font-family: Georgia, serif; font-size: 23px; }
.inline-total { display: flex; justify-content: flex-end; gap: 30px; margin-top: 18px; padding-top: 17px; border-top: 1px solid var(--line); }
.inline-total span { color: var(--muted); }
.inline-total span small { display: block; margin-top: 2px; font-size: 11px; }
.bank-fields { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; max-width: 700px; margin-bottom: 20px; }
.bank-fields label small { display: block; margin-top: 3px; }
.bank-breakdown { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin: 0 0 10px; }
.bank-breakdown > div { padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfb; }
.bank-breakdown > div.highlight { border-color: #f1d49e; background: var(--accent-soft); }
.bank-breakdown span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; font-weight: 750; }
.bank-breakdown strong { display: block; font-family: Georgia, serif; font-size: 19px; }
.funding-note { margin: 0 0 20px; padding: 10px 12px; border-left: 3px solid var(--accent); background: #fffcf5; color: var(--muted); font-size: 12px; }
.scenario-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.scenario { padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: #fbfcfb; transition: border .15s, background .15s; }
.scenario.active { border-color: var(--accent); background: #fffcf5; }
.scenario-title { display: flex; justify-content: space-between; align-items: start; margin-bottom: 20px; }
.scenario-title span { display: block; margin-bottom: 3px; color: var(--accent); font-size: 10px; font-weight: 850; letter-spacing: .12em; }
.scenario-title strong { font-family: Georgia, serif; font-size: 21px; }
.scenario-title input { width: 18px; height: 18px; accent-color: var(--ink); }
.scenario label { display: block; max-width: 230px; }
dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 22px 0 0; padding-top: 18px; border-top: 1px solid var(--line); }
dl div { min-width: 0; }
dt { color: var(--muted); font-size: 11px; min-height: 29px; }
dd { margin: 3px 0 0; font-weight: 800; white-space: nowrap; }
.timeline-legend { display: flex; flex-wrap: wrap; gap: 13px; margin-bottom: 16px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }
.chart-wrap { position: relative; padding-left: 30px; }
.chart-y-label { position: absolute; top: 50%; left: -50px; width: 130px; transform: rotate(-90deg); color: var(--muted); font-size: 10px; text-align: center; }
.chart { min-height: 250px; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); background: repeating-linear-gradient(to bottom, transparent 0, transparent 49px, #edf0ee 50px); overflow: hidden; }
.chart svg { display: block; width: 100%; height: 250px; overflow: visible; }
.timeline-events { display: flex; gap: 8px; overflow-x: auto; padding: 16px 0 3px 30px; }
.event-chip { flex: 0 0 auto; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 11px; color: var(--muted); }
.event-chip strong { display: block; margin-bottom: 2px; color: var(--ink); }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 340px; padding: 13px 17px; background: var(--ink); color: white; border-radius: 10px; box-shadow: var(--shadow); transform: translateY(120px); opacity: 0; transition: .25s; z-index: 10; }
.toast.visible { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--danger); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.login-page { min-height: 100vh; background: var(--ink); }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 430px); padding: 38px; border-radius: 18px; background: var(--white); box-shadow: 0 24px 80px rgba(0, 0, 0, .22); }
.login-card h1 { margin-bottom: 10px; font-size: 34px; }
.login-card > p:not(.eyebrow) { margin: 0 0 28px; color: var(--muted); }
.login-card label { display: block; margin-bottom: 16px; }
.login-card .button { width: 100%; }
.login-card small { display: block; margin-top: 16px; color: var(--muted); text-align: center; }
.login-error { margin-bottom: 16px; padding: 11px 13px; border-radius: 8px; background: #fff0ed; color: var(--danger); font-size: 13px; }
@media (max-width: 950px) {
  .hero-grid { grid-template-columns: repeat(2, 1fr); }
  .lender-row { grid-template-columns: 1fr 1fr; }
  .contribution-row, .investor-row { grid-template-columns: 1fr 1fr; }
  .lender-row .remove-button { grid-column: 2; justify-self: end; }
  dl { grid-template-columns: 1fr; }
  .bank-breakdown { grid-template-columns: repeat(2, 1fr); }
  .quote-selection-summary { grid-template-columns: repeat(2, 1fr); }
  dt { min-height: 0; }
}
@media (max-width: 650px) {
  .topbar { padding: 22px 16px 15px; align-items: flex-start; flex-direction: column; }
  .header-actions { width: 100%; }
  .header-actions .button { flex: 1; padding: 11px 8px; font-size: 12px; }
  .header-actions { flex-wrap: wrap; }
  .logout-link { justify-content: center; }
  main { padding: 0 12px 45px; }
  .hero-grid { display: flex; overflow-x: auto; margin: 8px -12px 16px; padding: 7px 12px; border-radius: 0; scrollbar-width: none; }
  .hero-grid::-webkit-scrollbar { display: none; }
  .summary-card { flex: 0 0 190px; min-height: 96px; padding: 13px; }
  .summary-card strong { font-size: 22px; }
  .panel { padding: 19px 15px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .section-actions { justify-content: flex-start; }
  .lender-row, .bank-fields, .scenario-grid { grid-template-columns: 1fr; }
  .contribution-row, .investor-row { grid-template-columns: 1fr; }
  .funding-group { padding: 15px; }
  .funding-group-heading { align-items: flex-start; flex-direction: column; }
  .funding-grand-total { justify-content: space-between; }
  .bank-breakdown { grid-template-columns: 1fr; }
  .quote-selection-summary { grid-template-columns: 1fr 1fr; }
  .lender-row .remove-button { grid-column: 1; }
  .inline-total { justify-content: space-between; gap: 10px; }
}
