:root { --brand: #2563eb; --ink: #0f172a; --muted: #475569; --line: #e2e8f0; --bg: #f1f5f9; --ok: #047857; --warn: #b45309; --bad: #b91c1c; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
.wrap { max-width: 760px; margin: 0 auto; padding: 24px 16px 8px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 24px; margin-bottom: 16px; box-shadow: 0 4px 18px rgba(15,23,42,.04); }
.brandbar { height: 6px; background: var(--brand); border-radius: 18px 18px 0 0; margin: -24px -24px 20px; }
.loading { text-align: center; color: var(--muted); padding: 60px 24px; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; margin: 0 auto 12px; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.biz { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.biz img.logo { max-height: 64px; max-width: 200px; object-fit: contain; }
.biz h1 { margin: 0; font-size: 22px; }
.biz .contact { color: var(--muted); font-size: 14px; margin: 2px 0 0; }
.doctitle { text-align: right; }
.doctitle h2 { margin: 0; font-size: 20px; }
.doctitle p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.badge { display: inline-block; font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; margin-top: 6px; }
.badge.ok { background: #d1fae5; color: var(--ok); }
.badge.due { background: #dbeafe; color: #1d4ed8; }
.badge.late { background: #fee2e2; color: var(--bad); }
.badge.muted { background: #e2e8f0; color: var(--muted); }
.amount { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.amount .label { color: var(--muted); font-size: 14px; margin: 0; }
.amount .big { font-size: 34px; font-weight: 800; margin: 0; letter-spacing: -0.01em; }
.amount .sub { color: var(--muted); font-size: 14px; margin: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 12px 22px; border-radius: 12px; border: 0; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(0.95); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.link { background: none; color: var(--muted); text-decoration: underline; min-height: 44px; padding: 8px; font-weight: 600; }
.btn[disabled] { opacity: .6; cursor: default; }
.alt { margin-top: 14px; font-size: 14px; color: var(--muted); }
.alt a { color: var(--ink); margin-right: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.k { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; margin: 0 0 4px; font-weight: 600; }
.v { margin: 0; white-space: pre-line; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 0 0 8px; border-bottom: 1px solid var(--line); }
td { padding: 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; white-space: nowrap; padding-left: 12px; }
td .detail { color: var(--muted); font-size: 14px; white-space: pre-line; }
.totals { margin-left: auto; max-width: 300px; margin-top: 12px; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals .grand { font-weight: 800; font-size: 18px; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
.notice { border-radius: 14px; padding: 14px 16px; margin-bottom: 16px; font-weight: 600; }
.notice.ok { background: #d1fae5; color: var(--ok); }
.notice.warn { background: #fef3c7; color: var(--warn); }
.notice.bad { background: #fee2e2; color: var(--bad); }
label { display: block; font-weight: 600; margin: 14px 0 6px; }
input[type=text], textarea { width: 100%; font: inherit; padding: 12px 14px; border: 1px solid #cbd5e1; border-radius: 10px; }
input[type=text]:focus, textarea:focus, canvas:focus { outline: 3px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
.sigbox { position: relative; border: 1px dashed #94a3b8; border-radius: 12px; background: #f8fafc; }
.sigbox canvas { display: block; width: 100%; height: 160px; touch-action: none; border-radius: 12px; }
.sigbox .hint { position: absolute; left: 14px; bottom: 10px; color: #94a3b8; font-size: 13px; pointer-events: none; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.check input { width: 20px; height: 20px; margin-top: 2px; }
.foot { text-align: center; padding: 8px 16px 32px; }
.foot a { color: #64748b; font-size: 13px; text-decoration: none; display: inline-flex; gap: 6px; align-items: center; }
@media (max-width: 600px) {
  .doctitle { text-align: left; }
  .grid2 { grid-template-columns: 1fr; }
  .amount .btn { width: 100%; }
  .card { padding: 18px; }
  .brandbar { margin: -18px -18px 16px; }
}
@media print {
  body { background: #fff; }
  .card { box-shadow: none; border: 0; }
  .btn, .foot, .noprint { display: none !important; }
}
