@font-face { font-family: 'DM Sans'; src: url('dm-sans.ttf') format('truetype'); font-weight: 100 1000; font-display: swap; }
@font-face { font-family: 'Manrope'; src: url('manrope.ttf') format('truetype'); font-weight: 200 800; font-display: swap; }

:root { --ink: #202a28; --muted: #74807b; --accent: #a61d24; --line: #e2e7e3; --wash: #f6f8f6; --font: 'DM Sans', 'Bahnschrift', sans-serif; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: #fff; font-family: var(--font); font-size: 13px; letter-spacing: 0; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { opacity: .35; cursor: default; }
button:focus-visible, a:focus-visible { outline: 3px solid #d68b91; outline-offset: 3px; }
svg { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 1.7; }
.topbar { height: 76px; padding: 0 5%; display: flex; align-items: center; gap: 30px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; text-decoration: none; color: var(--ink); font: 800 26px 'Manrope', var(--font); }
.brand-icon { background: var(--accent); color: white; width: 33px; height: 37px; border-radius: 6px; display: grid; place-items: center; margin-right: 10px; }
.brand-icon svg { width: 22px; height: 22px; }
.brand-dot { color: var(--accent); }
.account-controls { margin-left: auto; display: flex; gap: 8px; align-items: center; min-width: 0; }
#account-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.login-screen { max-width: 360px; margin: 72px auto; padding: 0 24px; }
.login-logo { display: block; width: 88px; height: 112px; object-fit: contain; margin-bottom: 30px; }
.login-screen h1 { margin-bottom: 28px; }
.login-screen input { height: 44px; font-size: 16px; }
.login-screen .primary { width: 100%; margin-top: 8px; }
.auth-status { color: var(--accent); line-height: 1.6; overflow-wrap: anywhere; }
.auth-status:not(:empty) { margin: 16px 0; }
dialog { border: 1px solid var(--line); border-radius: 6px; padding: 24px; color: var(--ink); width: min(620px, calc(100% - 32px)); max-height: 85vh; }
dialog::backdrop { background: #202a2860; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.dialog-heading h2 { font-size: 18px; }
.user-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.user-form .primary { grid-column: 1 / -1; justify-self: start; }
.record-list { margin-top: 12px; }
.record-row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.record-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.record-meta { color: var(--muted); font-size: 11px; }
.record-row .record-meta { display: block; margin-top: 4px; }
.user-active { margin: 0; flex-direction: row; align-items: center; gap: 8px; }
.user-active input { width: 16px; height: 16px; accent-color: var(--accent); }
@media (max-width: 700px) { .topbar { height: auto; min-height: 76px; flex-wrap: wrap; gap: 8px; padding-top: 12px; padding-bottom: 12px; } .brand { font-size: 22px; } .top-caption { display: none; } }
@media (max-width: 520px) { .account-controls { width: 100%; } #account-name { max-width: none; flex: 1; } .user-form { grid-template-columns: 1fr; } .login-screen { margin-top: 44px; } }
.top-caption { color: var(--muted); border-left: 1px solid var(--line); padding-left: 30px; font-size: 12px; }
.local-badge { margin-left: auto; display: flex; gap: 7px; align-items: center; color: #805f62; font-size: 12px; }
.local-badge svg { width: 16px; }
main { max-width: 1480px; margin: auto; padding: 36px 5% 0; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 24px; }
.eyebrow { color: var(--muted); font-size: 10px; font-weight: 600; margin-bottom: 8px; }
h1 { font: 700 30px 'Manrope', var(--font); margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
button { border: none; background: none; color: var(--ink); }
.primary, .secondary { display: inline-flex; gap: 9px; align-items: center; justify-content: center; border-radius: 5px; min-height: 42px; padding: 10px 16px; font-weight: 600; }
.primary { background: var(--accent); color: white; }
.primary:hover { background: #86171d; }
.secondary { border: 1px solid var(--line); background: white; }
.secondary:hover, .icon-button:hover { background: var(--wash); }
.icon-button { width: 36px; height: 36px; border-radius: 4px; display: inline-grid; place-items: center; flex-shrink: 0; }
#status { min-height: 0; color: var(--accent); }
#status:not(:empty) { padding: 10px 14px; border-left: 3px solid var(--accent); background: #fff0f0; margin-bottom: 18px; }
#status.error { color: #a32b2b; border-color: #a32b2b; background: #fff3f3; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); border-top: 1px solid var(--line); gap: 34px; }
.form-section { padding: 25px 0; border-bottom: 1px solid var(--line); }
.last-section { border: 0; }
.section-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 21px; }
.step { display: grid; place-items: center; width: 26px; height: 26px; color: var(--accent); background: #f9eeee; border-radius: 4px; font-size: 10px; font-weight: 700; }
h2 { margin: 0; font: 700 14px 'Manrope', var(--font); }
.section-heading > svg { margin-left: auto; color: #9aa59f; }
.section-meta { color: var(--muted); font-size: 10px; margin-left: auto; }
.party-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
fieldset { min-width: 0; border: 0; padding: 0; margin: 0; }
legend { color: var(--accent); font-weight: 600; margin-bottom: 14px; padding: 0; }
label { display: flex; flex-direction: column; gap: 6px; color: #5d6963; font-size: 11px; font-weight: 500; margin-bottom: 12px; min-width: 0; }
input, textarea, select { min-width: 0; width: 100%; border: 1px solid #dce3dd; border-radius: 4px; padding: 10px 11px; color: var(--ink); background: #fff; outline: none; font-size: 12px; line-height: 1.4; }
input, select { height: 38px; }
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #a0aaa4; font-weight: 400; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px #a61d2412; }
.field-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.details-grid { display: grid; grid-template-columns: 1fr 1.1fr 1.1fr; gap: 12px; }
.details-grid label { margin-bottom: 0; }
.bank-grid { margin-bottom: 12px; }
.item-row { display: grid; grid-template-columns: minmax(0, 2.5fr) minmax(0, .8fr) minmax(0, 1.1fr) minmax(0, .85fr) 28px; gap: 8px; align-items: end; }
.item-row input, .item-row select { padding: 8px; }
.item-row .icon-button { width: 28px; height: 38px; margin-bottom: 12px; color: #919c96; }
.item-row .icon-button:hover { color: #b73838; background: #fff1f1; }
.text-button { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); padding: 5px 0; font-size: 12px; font-weight: 600; }
.profile-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.editor-totals { width: 230px; max-width: 100%; margin: 18px 0 0 auto; }
.editor-totals > div { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; color: var(--muted); font-size: 12px; }
.editor-totals strong { color: var(--ink); font-weight: 500; white-space: nowrap; }
.editor-totals .grand-total { border-top: 1px solid var(--line); margin-top: 7px; padding-top: 12px; color: var(--ink); font-weight: 700; }
.grand-total strong { font-weight: 700; color: var(--accent); font-size: 17px; }
.preview-area { padding: 24px 22px 28px; background-color: #f6f2f2; background-image: radial-gradient(#e7dddd 0.5px, transparent 0.5px); background-size: 8px 8px; align-self: start; min-width: 0; }
.preview-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 10px; font-size: 11px; color: var(--muted); }
.preview-heading > span:first-child { display: flex; align-items: center; gap: 7px; color: #70565a; font-weight: 500; }
.invoice-paper { background: white; padding: 32px 28px 24px; min-height: 660px; box-shadow: 0 4px 20px #24382a09, 0 0 0 1px #e5eae5; position: relative; overflow-wrap: anywhere; display: flex; flex-direction: column; }
.invoice-brand { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 24px; }
.invoice-header-parties { display: grid; grid-template-columns: 1fr; gap: 18px; min-width: 0; flex: 1; }
.invoice-seller, .invoice-buyer { min-width: 0; font-size: 10px; line-height: 1.8; color: #737e77; }
.invoice-seller strong, .invoice-buyer strong { display: block; color: var(--ink); font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.invoice-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.document-label { font-size: 9px; color: var(--accent); font-weight: 700; margin-bottom: 9px; }
.invoice-top h2 { font: 600 28px 'Manrope', var(--font); }
.document-mark { width: 86px; height: 110px; flex-shrink: 0; object-fit: contain; }
.invoice-dates { display: flex; gap: 32px; margin: 22px 0; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.invoice-dates > div { display: flex; flex-direction: column; gap: 5px; font-size: 10px; }
.invoice-dates span { color: var(--muted); }
.invoice-dates strong { font-weight: 500; }
.mini-label { display: block; color: #88978d; font-size: 8px; font-weight: 600; margin-bottom: 7px; }
.multiline { white-space: pre-wrap; }
.preview-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 9px; }
.preview-table th { text-align: right; color: #806565; background: #faf0f0; padding: 10px 5px; font-weight: 500; }
.preview-table th:first-child { text-align: left; width: 32%; }
.preview-table th:nth-child(2) { width: 10%; }
.preview-table th:nth-child(3) { width: 20%; }
.preview-table th:nth-child(4) { width: 14%; }
.preview-table th:last-child { width: 24%; }
.preview-table td { padding: 13px 5px; text-align: right; vertical-align: top; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.preview-table td:first-child { text-align: left; }
.paper-totals { margin: 18px 0 26px auto; width: 65%; font-size: 10px; }
.paper-totals > div { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; color: #737e77; }
.paper-totals .paper-grand { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 12px; color: var(--accent); align-items: baseline; }
.paper-grand strong { font-size: 19px; text-align: right; }
.invoice-bottom { margin-top: 36px; margin-bottom: 32px; font-size: 10px; color: #737e77; line-height: 1.8; }
#payment-block { color: var(--ink); }
#payment-block strong { font-weight: 700; }
.payment-reference { margin-top: 14px; }
#notes-block { margin-top: 18px; }
.paper-footer { color: var(--ink); border-top: 1px solid var(--ink); padding-top: 12px; margin-top: auto; font-size: 9px; text-align: center; }
.paper-footer .invoice-seller { font-size: 9px; line-height: 1.5; color: var(--ink); }
.paper-footer .invoice-seller strong { display: inline; font-size: 9px; font-weight: 700; margin: 0; }
.preview-foot { display: flex; align-items: center; gap: 7px; color: #94868a; font-size: 10px; padding-top: 18px; }
.preview-foot > span:last-child { margin-left: auto; }
.preview-dot { width: 5px; height: 5px; border-radius: 50%; background: #b7757d; }
.app-footer { border-top: 1px solid var(--line); margin-top: 22px; padding: 21px 0; display: flex; justify-content: space-between; gap: 12px; color: #929c96; font-size: 10px; }
.app-footer > span:first-child { font-weight: 700; color: #6f7c73; }
@media (max-width: 520px) { .preview-table th { padding: 10px 3px; font-size: 8px; white-space: nowrap; } .invoice-header-parties { grid-template-columns: 1fr; gap: 14px; } }
@media (min-width: 1400px) { .invoice-paper { min-height: 735px; padding: 40px 34px; } }
@media (max-width: 1100px) { main { padding: 28px 3% 0; } .workspace { gap: 22px; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); } .party-columns { gap: 14px; } .field-grid { grid-template-columns: 1fr; gap: 0; } .preview-area { padding: 20px 14px; } .invoice-paper { padding: 25px 18px; } }
@media (max-width: 860px) { .workspace { grid-template-columns: 1fr; gap: 0; } .field-grid { grid-template-columns: 1fr 1.4fr; gap: 10px; } .preview-area { padding: 24px; } .invoice-paper { max-width: 600px; margin: auto; padding: 36px; } .preview-heading, .preview-foot { max-width: 600px; margin-left: auto; margin-right: auto; } .preview-table { font-size: 11px; } .top-caption { display: none; } }
@media (max-width: 520px) { .topbar { height: auto; min-height: 64px; padding: 12px 5%; } main { padding: 24px 5% 0; } .page-heading { flex-wrap: wrap; gap: 20px; } h1 { font-size: 26px; } .actions { width: 100%; } .actions .primary { margin-left: auto; } .primary, .secondary { padding: 10px 12px; font-size: 12px; } .party-columns { grid-template-columns: 1fr; gap: 12px; } .details-grid { grid-template-columns: 1fr 1fr; } .details-grid > label:first-child { grid-column: 1 / -1; } .item-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr) 28px; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 14px; } .description-field { grid-column: 1 / -1; margin-bottom: 0; } .preview-area { margin: 0 -2%; padding: 20px 12px; } .invoice-paper { padding: 24px 16px; min-height: 590px; } .preview-table { font-size: 9px; } .invoice-top h2 { font-size: 24px; } .paper-grand strong { font-size: 16px; } .invoice-parties { gap: 16px; } .app-footer > span:last-child { text-align: right; } }