/* Invotaxa — Option A "split editor". System fonts: fast and private (no font downloads). */
:root {
  --bg: #F7F6F2; --card: #FFFFFF; --ink: #1A1C1E; --muted: #4A4D52; --faint: #6B6E73;
  --line: #E2E0D8; --line-2: #EFEDE6; --field: #C9C6BC;
  --accent: #1F6F4A; --accent-dark: #16533A; --accent-tint: #E6F1EA; --accent-line: #B9D8C5;
  --radius: 12px; --shadow: 0 1px 2px rgba(26, 28, 30, .05);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--sans); }
img { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-dark); }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.015em; }
:focus-visible { outline: 3px solid #2F6FEB; outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 6px; z-index: 10; }
.skip:focus { left: 8px; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.i { flex: none; vertical-align: -3px; }

/* ---------- header / footer */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 28px; min-height: 64px; padding-top: 8px; padding-bottom: 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; color: var(--ink); text-decoration: none; letter-spacing: -.02em; }
.brand:hover { color: var(--ink); }
.main-nav { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.main-nav a { color: var(--muted); text-decoration: none; padding: 10px 0; border-bottom: 2px solid transparent; }
.main-nav a:hover { color: var(--ink); }
.main-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.site-footer { margin-top: 64px; background: var(--card); border-top: 1px solid var(--line); padding: 40px 0 24px; font-size: 15px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; }
.footer-grid h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin: 4px 0 12px; }
.footer-grid a:not(.brand) { display: block; color: var(--muted); text-decoration: none; padding: 4px 0; }
.footer-grid a:not(.brand):hover { color: var(--ink); text-decoration: underline; }
.footer-grid p { color: var(--muted); margin: 10px 0; }
.social { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.social a { display: inline !important; }
.copy { color: var(--faint); font-size: 13px; margin-top: 32px; }

/* ---------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; border-radius: 8px; border: 1px solid var(--field); background: var(--card); color: var(--ink); font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-small { min-height: 40px; padding: 8px 12px; font-size: 14px; }
.btn-ghost { border-color: transparent; background: none; color: var(--accent); font-weight: 600; padding-left: 4px; padding-right: 4px; }
.btn-ghost:hover { border-color: transparent; color: var(--accent-dark); }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 8px; background: none; color: var(--faint); cursor: pointer; }
.icon-btn:hover { background: var(--line-2); color: var(--ink); }

/* ---------- tool head */
.tool-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; padding-top: 32px; padding-bottom: 24px; }
.tool-head h1 { font-size: 32px; margin: 0 0 6px; }
.lead { margin: 0; color: var(--muted); font-size: 17px; max-width: 640px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.charset-note { display: flex; gap: 8px; align-items: flex-start; color: #7A4A00; background: #FFF6E5; border: 1px solid #F1D9A8; border-radius: 8px; padding: 10px 14px; font-size: 14px; margin-bottom: 16px; }
.charset-note[hidden] { display: none; }

/* ---------- editor layout */
.editor { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.editor > .form { flex: 1 1 400px; min-width: 0; }
.editor > .side { flex: 1 1 480px; min-width: 0; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.form { padding: 8px 24px 24px; }
fieldset { border: 0; border-bottom: 1px solid var(--line-2); margin: 0; padding: 20px 0; min-width: 0; }
fieldset:last-of-type { border-bottom: 0; }
legend { float: left; width: 100%; font-weight: 700; font-size: 16px; margin-bottom: 12px; padding: 0; }
legend + * { clear: both; }
.opt { font-weight: 400; color: var(--faint); font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field label, .field .label { font-size: 14px; font-weight: 600; color: var(--muted); }
.hint { margin: 0; font-size: 13px; color: var(--faint); }
input[type=text], input[type=date], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: #fff; border: 1px solid var(--field); border-radius: 8px; padding: 10px 12px; min-height: 44px; }
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31, 111, 74, .18); }
::placeholder { color: #8C8F94; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.combo { display: flex; }
.combo input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.combo select { width: auto; border-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; background: var(--bg); }
.combo .unit { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--field); border-left: 0; border-radius: 0 8px 8px 0; background: var(--bg); color: var(--muted); }
.money { position: relative; }
.money span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.money input { padding-left: 26px; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -2px 0 16px; font-size: 14px; color: var(--faint); }
.chip { font: inherit; font-size: 14px; border: 1px solid var(--field); background: #fff; border-radius: 999px; padding: 6px 12px; min-height: 36px; cursor: pointer; color: var(--ink); }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.logo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 14px; }
.logo-box { width: 120px; height: 56px; border: 1px solid var(--line); border-radius: 8px; display: grid; place-items: center; overflow: hidden; background: #fff; }
.logo-box[hidden] { display: none; }
.logo-box img { max-width: 100%; max-height: 100%; }
.swatches { display: flex; gap: 10px; padding: 6px 0; }
.swatch { position: relative; width: 32px; height: 32px; border-radius: 50%; background: var(--c); cursor: pointer; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .5); }
.swatch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.swatch:has(input:checked) { outline: 3px solid var(--c); outline-offset: 3px; }
.swatch:has(input:focus-visible) { outline: 3px solid #2F6FEB; outline-offset: 3px; }
.form-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding-top: 16px; }
.saved { margin: 0; font-size: 13px; color: var(--faint); display: flex; gap: 6px; align-items: center; }
.saved.off { visibility: hidden; }
details.more { margin-top: 4px; }
details.more summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14px; padding: 8px 0; margin-bottom: 8px; }

/* line items */
.items-head, .item { display: grid; grid-template-columns: minmax(0, 1fr) 64px 92px 96px 40px; gap: 8px; align-items: start; }
.items-head { font-size: 13px; font-weight: 600; color: var(--faint); padding-bottom: 6px; }
.items-head span:nth-child(n+2) { text-align: right; }
.item { margin-bottom: 8px; }
.item textarea { overflow: hidden; min-height: 44px; }
.item input { text-align: right; padding-left: 8px; padding-right: 8px; }
.i-amt { padding: 11px 0; text-align: right; font-family: var(--mono); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.add-line { margin-top: 2px; }
.ml { display: none; }

/* ---------- invoice preview (mirrors the PDF) */
.preview { padding: 40px; font-size: 13px; color: var(--ink); --accent: #1F6F4A; }
.pv-top { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.pv-logo { max-width: 160px; max-height: 64px; }
.pv-from-big { font-size: 20px; font-weight: 700; }
.pv-meta { text-align: right; display: grid; gap: 2px; }
.pv-meta div { display: flex; justify-content: flex-end; gap: 12px; }
.pv-meta span { color: var(--faint); }
.pv-title { font-size: 28px; font-weight: 800; color: var(--accent); letter-spacing: -.01em; margin-bottom: 6px; display: block !important; }
.pv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 28px 0 20px; }
.pv-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--faint); margin-bottom: 4px; }
.pv-muted { color: var(--muted); }
.pv-items { width: 100%; border-collapse: collapse; }
.pv-items th { background: #F3F2EE; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); text-align: right; padding: 8px; }
.pv-items th:first-child, .pv-items td:first-child { text-align: left; }
.pv-items td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
.pv-items td:not(:first-child) { white-space: nowrap; font-family: var(--mono); font-size: 12.5px; }
.pv-totals { margin: 12px 0 0 auto; max-width: 280px; }
.pv-totals > div { display: flex; justify-content: space-between; gap: 16px; padding: 4px 0; }
.pv-totals > div span:last-child { font-family: var(--mono); }
.pv-total { border-top: 1.5px solid var(--ink); margin-top: 6px; padding-top: 8px !important; font-weight: 700; font-size: 15px; }
.pv-due { background: var(--accent); color: #fff; font-weight: 700; padding: 8px 10px !important; margin-top: 8px; }
.pv-note { margin-top: 18px; }
.ph { color: #A3A6AA; font-weight: 400; }
.setaside { background: var(--accent-tint); border: 1px solid var(--accent-line); border-radius: var(--radius); padding: 16px 20px; display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.setaside[hidden] { display: none; }
.setaside h2 { font-size: 16px; margin: 0 0 4px; }
.setaside p { margin: 0; font-size: 14px; color: #2E3B33; max-width: 420px; }
.dl-bar { display: none; }

/* ---------- tax results */
.results { padding: 28px; }
.results h2 { font-size: 15px; margin: 24px 0 8px; }
.results .empty { color: var(--faint); margin: 24px 0; }
.big .k { margin: 0; font-weight: 600; color: var(--muted); }
.big .v { margin: 4px 0; font-size: 40px; font-weight: 800; letter-spacing: -.02em; font-family: var(--sans); }
.big .sub { margin: 0; color: var(--muted); }
.split { display: flex; height: 12px; border-radius: 6px; background: #1A1C1E; overflow: hidden; margin: 20px 0 8px; }
.split span { background: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 20px; font-size: 14px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }
.legend .l1::before { background: var(--accent); }
.legend .l2::before { background: #1A1C1E; }
.r { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 15px; }
.r > span:last-child { font-family: var(--mono); font-size: 14px; white-space: nowrap; }
.r.sm { color: var(--faint); font-size: 14px; padding: 4px 0; }
.r.tot { font-weight: 700; border-bottom-color: var(--line); }
.ind { padding-left: 14px; }
details.how { margin-top: 12px; }
details.how summary { cursor: pointer; color: var(--accent); font-weight: 600; padding: 8px 0; }
.fine { font-size: 13px; color: var(--faint); margin: 12px 0 0; }
.next { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 20px; padding: 14px 16px; border-radius: 10px; background: var(--accent-tint); border: 1px solid var(--accent-line); color: var(--ink); text-decoration: none; font-weight: 500; }
.next:hover { border-color: var(--accent); color: var(--ink); }
.dates { list-style: none; margin: 0 0 12px; padding: 0; }
.dates li { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
.dates .q { font-weight: 800; color: var(--faint); }
.dates .d small { display: block; color: var(--faint); font-size: 13px; }
.dates .a { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.dates li.next { border-color: var(--accent); background: var(--accent-tint); }
.dates li.next .q, .dates li.next .a { color: var(--accent); }
.dates li.past { opacity: .6; }

.mbar { display: none; }
/* ---------- prose */
.prose { max-width: 760px; margin-top: 56px; }
.prose h1 { font-size: 34px; margin: 40px 0 16px; }
.prose h2 { font-size: 24px; margin: 40px 0 12px; }
.prose h3 { font-size: 18px; margin: 28px 0 6px; }
.prose p, .prose li { color: #2B2E31; }
.prose li { margin: 6px 0; }
.table-wrap { overflow-x: auto; margin: 16px 0; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.prose table { border-collapse: collapse; width: 100%; font-size: 15px; }
.prose th, .prose td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.prose th { background: #F3F2EE; font-size: 13px; color: var(--muted); }
.prose tr:last-child td { border-bottom: 0; }

/* ---------- small screens */
@media (max-width: 900px) {
  .editor > .side { position: static; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .tool-head { padding-top: 24px; }
  .tool-head h1 { font-size: 26px; }
  .form { padding: 4px 16px 16px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .items-head { display: none; }
  .item { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px; grid-template-areas: "d d x" "mq mr x" "q r x" "a a a"; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
  .item textarea { grid-area: d; } .item .i-qty { grid-area: q; } .item .i-rate { grid-area: r; } .item .i-amt { grid-area: a; padding: 0; } .item .i-del { grid-area: x; }
  .item .ml { display: block; font-size: 12px; font-weight: 600; color: var(--faint); margin-bottom: -4px; } .item .mq { grid-area: mq; } .item .mr { grid-area: mr; }
  .item .i-qty::placeholder { color: transparent; }
  .preview { padding: 20px; font-size: 12px; }
  .pv-parties { grid-template-columns: 1fr; gap: 14px; }
  .pv-title { font-size: 22px; }
  .page-invoice .dl-bar { display: flex; position: sticky; bottom: 0; z-index: 5; padding: 10px 16px; background: rgba(247, 246, 242, .96); border-top: 1px solid var(--line); }
  .dl-bar .btn { flex: 1; }
  .big .v { font-size: 34px; }
  .mbar { display: flex; position: sticky; bottom: 0; z-index: 5; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; background: var(--ink); color: #fff; text-decoration: none; }
  .mbar:hover { color: #fff; }
  .mbar b { font-size: 20px; }
  .mbar small { display: block; color: #C9CCD1; font-size: 13px; }
  .results { padding: 20px; }
  .footer-grid { grid-template-columns: 1fr; gap: 20px; }
  .prose th, .prose td { white-space: normal; }
}
@media print {
  .site-header, .site-footer, .form, .tool-head, .setaside, .prose, .dl-bar, .charset-note { display: none !important; }
  body { background: #fff; }
  .editor > .side { position: static; }
  .card { border: 0; box-shadow: none; }
}
