:root { --bg: #fff; --ink: #1f1f1f; --ink2: #5a5a5a; --rule: #e3e3e3; --tile: #f3f6f9; --accent: #1f4e79; --ok: #2f6b3a; --warn: #8a5a00; --bad: #a12a2a; --focus: #f0b429; }
[hidden] { display: none !important; }
@media (prefers-color-scheme: dark) { :root { --bg: #161616; --ink: #ececec; --ink2: #a9a9a9; --rule: #333; --tile: #212528; --accent: #8fb8e0; --ok: #8fce99; --warn: #e6b866; --bad: #f09a9a; } }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 1.5rem; line-height: 1.2; margin: 0 0 .75rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }
p { margin: 0 0 .75rem; }
.pad { padding: 16px; }
.muted { color: var(--ink2); }
.small { font-size: .9rem; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .top { background: #10283e; } }
.brand { color: #fff; text-decoration: none; font-weight: 700; }
.brand span { font-weight: 400; opacity: .85; }
.where { font-size: .9rem; opacity: .85; }
main { max-width: 760px; margin: 0 auto; padding: 16px; outline: none; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--bg); border-top: 1px solid var(--rule); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { display: flex; align-items: center; justify-content: center; min-height: 56px; text-decoration: none; color: var(--ink2); font-size: .9rem; font-weight: 600; }
.tabs a[aria-current="page"] { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 1rem; }
.card { background: var(--tile); border-radius: 10px; padding: 12px 14px; text-decoration: none; color: inherit; display: block; }
.card b { display: block; font-size: 1.35rem; }
.card span { color: var(--ink2); font-size: .9rem; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: .5rem 0 1rem; }
.btn { appearance: none; display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 18px; border-radius: 8px; border: 2px solid var(--accent); background: var(--accent); color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
@media (prefers-color-scheme: dark) { .btn { color: #10283e; } }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn[disabled] { opacity: .5; cursor: default; }
.list { list-style: none; margin: 0 0 1rem; padding: 0; border-top: 1px solid var(--rule); }
.list li { border-bottom: 1px solid var(--rule); }
.list a.row, .list .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 4px; text-decoration: none; color: inherit; min-height: 52px; }
.row .main { min-width: 0; }
.row .main b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.row .main span { color: var(--ink2); font-size: .9rem; }
.row .amt { text-align: right; white-space: nowrap; }
.tag { display: inline-block; font-size: .78rem; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: var(--tile); color: var(--ink2); }
.tag.sent { color: var(--warn); } .tag.paid { color: var(--ok); } .tag.void { text-decoration: line-through; } .tag.draft { color: var(--accent); }
form.f { display: grid; gap: 14px; }
.field { display: grid; gap: 4px; align-content: start; }
label, .lbl { font-weight: 600; }
input, select, textarea { font: inherit; color: inherit; background: var(--bg); border: 1px solid #8a8a8a; border-radius: 8px; padding: 10px 12px; min-height: 46px; width: 100%; }
textarea { min-height: 96px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; border: 0; padding: 0; margin: 0; }
.choices legend { font-weight: 600; margin-bottom: 6px; }
.choices label { display: flex; align-items: center; gap: 8px; border: 1px solid var(--rule); border-radius: 8px; padding: 10px 12px; font-weight: 500; min-height: 46px; }
.choices input { width: auto; min-height: 0; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.check input { width: 22px; height: 22px; min-height: 0; }
.quote { background: var(--tile); border-radius: 10px; padding: 12px 14px; }
.quote b { font-size: 1.3rem; }
.hint { color: var(--ink2); font-size: .9rem; }
.err { color: var(--bad); font-weight: 600; }
.search { margin-bottom: 12px; }
.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; z-index: 10; }
.toast.show { opacity: 1; }
table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; font-size: .95rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--rule); vertical-align: top; }
td.r, th.r { text-align: right; }
.inv { border: 1px solid var(--rule); border-radius: 10px; padding: 18px; margin-bottom: 1rem; }
.inv-meta { text-align: right; }
@media (max-width: 480px) { .inv-meta { text-align: left; } }
.inv header { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 1rem; }
.inv .totals td { border: 0; padding: 4px 6px; }
.back { display: inline-block; margin-bottom: 10px; }
@media (max-width: 560px) { .two:not(.keep) { grid-template-columns: 1fr; } .two:not(.keep) span.lbl { display: none; } }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
@media print {
  .top, .tabs, .actions, .back, .noprint, .toast { display: none !important; }
  body { padding: 0; background: #fff; color: #000; }
  .inv { border: 0; padding: 0; }
}
