:root {
  --ink: #17312b;
  --muted: #6e7c78;
  --paper: #fff;
  --canvas: #eef1ed;
  --line: #dbe2de;
  --accent: #ef8c58;
  --accent-dark: #d66f3a;
  --soft: #f6f8f5;
  --shadow: 0 20px 60px rgba(18, 48, 40, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.topbar { height: 72px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; gap: 18px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; background: var(--accent); border-radius: 10px; font: 800 20px/1 Georgia, serif; }
.brand div { display: flex; flex-direction: column; line-height: 1.1; }
.brand strong { font-size: 16px; letter-spacing: .01em; }
.brand div span { margin-top: 4px; font-size: 12px; color: #b9cac5; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.save-status { font-size: 12px; color: #b9cac5; margin-right: 5px; }
.button { min-height: 40px; padding: 0 16px; border-radius: 9px; border: 1px solid transparent; font-weight: 700; font-size: 14px; }
.button-ghost { background: transparent; color: #fff; border-color: #60746f; }
.button-primary { background: var(--accent); color: #1c2f2a; }
.button:hover { transform: translateY(-1px); }
.button-primary:hover { background: #f39a6b; }
.workspace { max-width: 1500px; margin: 0 auto; display: grid; grid-template-columns: minmax(410px, .82fr) minmax(540px, 1.18fr); min-height: calc(100vh - 72px); }
.editor { padding: 38px 36px 80px; background: #fff; border-right: 1px solid var(--line); }
.editor-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 34px; }
.eyebrow { margin: 0 0 7px; color: var(--accent-dark); font-size: 11px; font-weight: 800; letter-spacing: .16em; }
h1 { margin: 0; font: 700 30px/1.15 Georgia, "Times New Roman", serif; letter-spacing: -.02em; }
.privacy-pill { white-space: nowrap; background: #edf5f1; color: #336257; padding: 7px 10px; border-radius: 999px; font-size: 12px; font-weight: 650; }
form { display: grid; gap: 30px; }
fieldset { margin: 0; padding: 0; border: 0; }
legend { width: 100%; display: flex; align-items: center; gap: 9px; padding: 0 0 14px; border-bottom: 1px solid var(--line); font-size: 15px; font-weight: 800; }
legend span { color: var(--accent-dark); font: 700 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.legend-row { display: flex; align-items: flex-start; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.legend-row legend { border: 0; }
.text-button { flex: 0 0 auto; border: 0; color: var(--accent-dark); background: transparent; padding: 2px 0 12px 12px; font-size: 14px; font-weight: 800; }
.grid { display: grid; gap: 14px; }
.two { grid-template-columns: 1fr 1fr; }
.span-two { grid-column: 1 / -1; }
label { display: grid; gap: 7px; color: #40544f; font-size: 13px; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid #cdd7d2; border-radius: 8px; background: #fff; color: var(--ink); padding: 10px 11px; font-size: 15px; line-height: 1.35; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: #4b766c; box-shadow: 0 0 0 3px rgba(58, 105, 94, .12); }
.items { display: grid; gap: 12px; }
.item-card { background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.item-topline { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 12px; margin-bottom: 12px; }
.remove-item { border: 0; background: transparent; color: #a94b3e; padding: 10px 2px; font-size: 12px; font-weight: 800; }
.item-numbers { grid-template-columns: .75fr 1fr 1fr; align-items: end; margin-top: 12px; }
.line-total { min-height: 64px; display: flex; flex-direction: column; justify-content: center; align-items: flex-end; padding-right: 4px; }
.line-total span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
.line-total strong { margin-top: 4px; font-size: 17px; }
.preview-panel { padding: 30px clamp(24px, 4vw, 64px) 70px; min-width: 0; }
.preview-toolbar { max-width: 760px; margin: 0 auto 14px; display: flex; justify-content: space-between; color: #5d6f6a; font-size: 12px; font-weight: 750; }
.preview-toolbar i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #45a177; margin-right: 5px; }
.receipt { position: relative; width: 100%; max-width: 760px; min-height: 980px; margin: 0 auto; padding: clamp(38px, 6vw, 72px); background: var(--paper); color: #17201e; box-shadow: var(--shadow); overflow: hidden; }
.receipt-accent { position: absolute; inset: 0 auto 0 0; width: 8px; background: var(--ink); }
.receipt-header { display: grid; grid-template-columns: 1.35fr 1fr; gap: 40px; padding-bottom: 34px; border-bottom: 2px solid var(--ink); }
.receipt-title p { margin: 0 0 20px; color: var(--accent-dark); font-size: 12px; font-weight: 850; letter-spacing: .16em; }
.receipt-title h2 { margin: 0; font: 700 clamp(24px, 3vw, 38px)/1.05 Georgia, "Times New Roman", serif; letter-spacing: -.03em; overflow-wrap: anywhere; }
.receipt-meta { display: grid; gap: 12px; align-content: start; }
.receipt-meta div { display: flex; justify-content: space-between; gap: 14px; border-bottom: 1px solid #dde2df; padding-bottom: 6px; }
.receipt-meta span, .receipt-label { color: #73807c; font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.receipt-meta strong { text-align: right; font-size: 12px; }
.receipt-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 38px; padding: 30px 0; }
.receipt-parties > div { display: flex; flex-direction: column; gap: 8px; }
.receipt-parties strong { font-size: 17px; }
.company-details { align-items: flex-end; text-align: right; white-space: pre-line; font-size: 12px; line-height: 1.55; color: #52605c; }
.service-note { background: #f3f5f2; border-left: 3px solid var(--accent); padding: 16px 18px; margin-bottom: 28px; }
.service-note p { margin: 7px 0 0; font-size: 13px; line-height: 1.55; white-space: pre-line; }
.receipt-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.receipt-table th { padding: 0 7px 10px; color: #66736f; border-bottom: 1px solid #96a09d; font-size: 10px; text-align: right; text-transform: uppercase; letter-spacing: .08em; }
.receipt-table th:first-child, .receipt-table td:first-child { text-align: left; padding-left: 0; }
.receipt-table th:last-child, .receipt-table td:last-child { padding-right: 0; }
.receipt-table td { padding: 13px 7px; border-bottom: 1px solid #e1e5e2; text-align: right; vertical-align: top; }
.receipt-table .item-name { font-weight: 750; }
.receipt-table .item-kind { display: block; color: #7c8884; font-size: 10px; margin-top: 3px; }
.totals { width: min(310px, 68%); margin: 26px 0 34px auto; display: grid; gap: 9px; }
.totals div { display: flex; justify-content: space-between; gap: 20px; font-size: 12px; }
.totals .grand-total { margin-top: 4px; padding: 13px 0; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); font-size: 16px; }
.totals .balance { color: var(--accent-dark); font-weight: 850; }
.receipt-footer { margin-top: 44px; padding-top: 22px; border-top: 1px solid #aeb7b3; display: grid; grid-template-columns: .7fr 1.3fr; gap: 30px; }
.receipt-footer div { display: flex; flex-direction: column; gap: 7px; }
.receipt-footer p { margin: 0; color: #54615d; font-size: 11px; line-height: 1.55; white-space: pre-line; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; border-radius: 9px; padding: 11px 15px; font-size: 13px; opacity: 0; pointer-events: none; transition: .2s ease; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .editor { border-right: 0; border-bottom: 1px solid var(--line); }
  .preview-panel { padding-top: 36px; }
}
@media (max-width: 620px) {
  .topbar { height: auto; min-height: 68px; padding: 12px 16px; }
  .brand div span, .save-status, .button-ghost { display: none; }
  .button { padding: 0 13px; }
  .editor { padding: 28px 18px 50px; }
  .editor-heading { align-items: flex-end; }
  .privacy-pill { white-space: normal; text-align: right; }
  .two { grid-template-columns: 1fr; }
  .span-two { grid-column: auto; }
  .item-numbers { grid-template-columns: 1fr 1fr; }
  .line-total { grid-column: 1 / -1; align-items: flex-start; min-height: 42px; }
  .preview-panel { padding: 24px 10px 50px; }
  .receipt { min-height: 720px; padding: 32px 25px 42px; }
  .receipt-header { grid-template-columns: 1fr; gap: 24px; }
  .receipt-parties { gap: 18px; }
  .receipt-table th:nth-child(2), .receipt-table td:nth-child(2) { display: none; }
  .totals { width: 80%; }
  .receipt-footer { grid-template-columns: 1fr; }
}
@media print {
  body { background: #fff; }
  .topbar, .editor, .preview-toolbar, .toast { display: none !important; }
  .workspace { display: block; }
  .preview-panel { padding: 0; }
  .receipt { width: 210mm; min-height: 297mm; max-width: none; box-shadow: none; }
}
