[hidden] { display: none !important; }
:root {
  --ink: #1d1d1b; --muted: #6b6b66; --line: #e3e2dc; --bg: #f6f5f1; --card: #fff;
  --accent: #1f5f3a; --accent-ink: #fff; --warn: #a15c00; --bad: #a3261d; --good: #1f6f3a;
  --radius: 8px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; }
a { color: inherit; }
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 6px; padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: #bdbcb5; }
button.primary, .btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
button.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--bad); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.small { padding: 4px 9px; font-size: 13px; }
input, select, textarea { font: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; background: #fff; color: var(--ink); width: 100%; }
textarea { min-height: 70px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
label.inline { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
label.inline input { width: auto; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 17px; margin: 0 0 10px; } h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }
.error { color: var(--bad); } .ok { color: var(--good); }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eceae4; white-space: nowrap; }
.badge.entity { color: #fff; }
.st-draft, .st-prepared { background: #eceae4; } .st-sent, .st-partially_signed { background: #fff1d6; color: #7a4d00; }
.st-completed { background: #dcefe2; color: #17532c; } .st-declined, .st-voided, .st-expired, .st-seal_failed { background: #f6dcd9; color: #7d1f17; }
.st-sealing { background: #e2e8f5; }

/* PDF pages */
.pages { display: flex; flex-direction: column; gap: 16px; align-items: center; }
.page { container-type: inline-size; position: relative; width: 100%; max-width: 860px; background: #fff; box-shadow: var(--shadow); border: 1px solid var(--line); }
.page canvas { width: 100%; height: 100%; display: block; }
.page .layer { position: absolute; inset: 0; }
.page .page-no { position: absolute; right: 6px; bottom: -20px; font-size: 11px; color: var(--muted); }

/* Toast */
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 6px; font-size: 14px; display: none; z-index: 100; max-width: calc(100% - 32px); }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 560px; padding: 20px; max-height: calc(100vh - 32px); overflow: auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; }
.tabs button.on { border-bottom-color: var(--ink); font-weight: 600; }
