:root {
  --desk: oklch(0.925 0.007 85); --surface: oklch(0.988 0.004 85); --hover: oklch(0.935 0.008 85);
  --line: oklch(0.885 0.009 85); --line-strong: oklch(0.8 0.012 85);
  --text: oklch(0.25 0.015 266); --text-2: oklch(0.45 0.014 266); --text-3: oklch(0.6 0.012 266);
  --accent: oklch(0.5 0.19 266); --accent-hover: oklch(0.44 0.19 266); --accent-soft: oklch(0.935 0.04 266);
  --on-accent: oklch(0.99 0.006 266); --danger: oklch(0.54 0.2 27); --paper: oklch(1 0 0);
  --shadow: 0 0 0 1px oklch(0.25 0.015 266 / 0.07), 0 4px 14px oklch(0.25 0.015 266 / 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 13px/1.45 var(--font); color: var(--text); background: var(--desk); display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.top { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 14px; background: var(--surface); border-bottom: 1px solid var(--line); flex: none; }
.brand { font-size: 15px; font-weight: 650; }
.fill { flex: 1; }
.btn { height: 32px; padding: 0 12px; border-radius: 7px; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.outline { box-shadow: inset 0 0 0 1px var(--line-strong); }
.seg { display: inline-flex; padding: 3px; border-radius: 9px; background: var(--hover); }
.seg button { height: 26px; padding: 0 14px; border-radius: 6px; font-weight: 500; color: var(--text-2); }
.seg button[aria-selected="true"] { background: var(--paper); color: var(--text); box-shadow: 0 1px 2px oklch(0.25 0.015 266 / 0.15); }
.wrap { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(340px, 440px) 1fr; }
.panel { overflow-y: auto; padding: 16px 18px 40px; background: var(--surface); border-right: 1px solid var(--line); display: grid; gap: 18px; align-content: start; }
.note { margin: 0; color: var(--text-2); font-size: 12px; }
fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 9px; }
legend { padding: 0; margin-bottom: 8px; font-size: 14px; font-weight: 650; }
label { display: grid; gap: 4px; font-size: 12px; font-weight: 500; color: var(--text-2); }
label small { font-weight: 400; color: var(--text-3); }
input, textarea, select { width: 100%; min-height: 32px; padding: 5px 9px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--paper); color: var(--text); font-weight: 400; }
textarea { resize: vertical; line-height: 1.4; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); outline-offset: 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--text); cursor: pointer; }
.check input { width: 15px; height: 15px; min-height: 0; accent-color: var(--accent); }
.inline { display: flex; align-items: center; gap: 8px; }
.inline input { width: 80px; }
.lines { display: grid; gap: 8px; }
.line { display: grid; grid-template-columns: 1fr 58px 76px 62px 26px; gap: 6px; align-items: start; }
.line textarea { min-height: 32px; }
.line .rm { height: 32px; border-radius: 6px; color: var(--text-3); font-size: 16px; }
.line .rm:hover { background: var(--hover); color: var(--danger); }
.line-head { font-size: 11px; color: var(--text-3); font-weight: 600; }
.issues { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; color: var(--danger); font-size: 12px; }
.preview { overflow: auto; padding: 24px; display: grid; justify-items: center; align-content: start; }
.sheet { width: 595px; min-height: 842px; background: var(--paper); box-shadow: var(--shadow); padding: 46px 48px; font: 10px/1.45 Helvetica, Arial, sans-serif; color: #1b1b1f; position: relative; }
.sheet h1 { margin: 0; font-size: 22px; letter-spacing: 0.02em; }
.sheet .head { display: flex; justify-content: space-between; gap: 20px; }
.sheet .muted { color: #5b5f6b; }
.sheet .parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 26px 0 18px; }
.sheet .parties b { display: block; font-size: 11px; margin-bottom: 2px; }
.sheet .cap { font-size: 8px; text-transform: uppercase; letter-spacing: 0.06em; color: #5b5f6b; margin-bottom: 4px; }
.sheet table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.sheet th { text-align: right; font-size: 8px; text-transform: uppercase; letter-spacing: 0.05em; color: #5b5f6b; padding: 6px 4px; border-bottom: 1px solid #1b1b1f; }
.sheet th:first-child, .sheet td:first-child { text-align: left; }
.sheet td { text-align: right; padding: 7px 4px; border-bottom: 1px solid #e3e1dc; vertical-align: top; white-space: nowrap; }
.sheet td:first-child { white-space: pre-wrap; }
.sheet .totals { margin: 14px 0 0 auto; width: 230px; }
.sheet .totals div { display: flex; justify-content: space-between; padding: 3px 4px; }
.sheet .totals .grand { margin-top: 4px; padding: 7px 4px; border-top: 1px solid #1b1b1f; font-size: 12px; font-weight: 700; }
.sheet .foot { margin-top: 26px; display: grid; gap: 8px; white-space: pre-wrap; }
.sheet .sign { margin-top: 22px; width: 240px; margin-left: auto; border: 1px solid #c9c6bf; height: 78px; padding: 6px 8px; color: #5b5f6b; }
@media (max-width: 900px) { .wrap { grid-template-columns: 1fr; } .panel { border-right: 0; } .preview { display: none; } #reset { display: none; } }
