/* Self-hosted fonts (SIL Open Font License / Apache 2.0). No third-party requests. */
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/poppins-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/poppins-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/poppins-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/inter-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/inter-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/inter-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/inter-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Caveat'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/caveat-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Dancing Script'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/dancing-script-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Sacramento'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/sacramento-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Homemade Apple'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/homemade-apple-latin-400-normal.woff2') format('woff2'); }
/* Lucid Sign design system. Tokens and components follow LucidMD Core: navy and teal, Poppins + Inter,
   liquid glass surfaces. Every token is defined in BOTH palettes. */
:root {
  --bg: #F6F6FA; --surface: #FFFFFF; --card: #FFFFFF; --ink: #1D1240; --ink-2: #6B6590; --line: #E6E4F0; --hover: #F4F3FA;
  --primary: #1FA39B; --primary-ink: #FFFFFF; --primary-text: #146F6A; --accent: #56C6C0; --accent-soft: #E2F5F4;
  --topbar-ink: #C9C4E0; --danger: #C0392B; --danger-bg: #FBECEA; --ok: #1F7A4A; --ok-bg: #E4F4EC;
  --warn: #A0490A; --warn-bg: #FBF1E2; --violet: #5A4FCF; --violet-bg: #EDEBFB; --blue: #2563EB; --blue-bg: #EAF1FE;
  --glass: color-mix(in srgb, #fff 72%, transparent); --glow: rgba(86,198,192,.16); --shadow: 0 18px 44px -22px rgba(29,18,64,.28);
  --display: 'Poppins', sans-serif; --body: 'Inter', sans-serif;
  --r1: #1FA39B; --r2: #5A4FCF; --r3: #D9631E; --r4: #2563EB; --r5: #C2378A; --r6: #6B8E23; --r0: #6B6590;
}
[data-theme="dark"] {
  --bg: #120E24; --surface: #1B1536; --card: #201A3E; --ink: #EFEDFA; --ink-2: #A29BC6; --line: #2C2550; --hover: #221B44;
  --primary: #2FB3AB; --primary-ink: #FFFFFF; --primary-text: #3FBFB7; --accent: #56C6C0; --accent-soft: #16393D;
  --topbar-ink: #B7B1D6; --danger: #F08A80; --danger-bg: #3B1D1D; --ok: #5ED596; --ok-bg: #16382A;
  --warn: #F0B36A; --warn-bg: #3A2B14; --violet: #A79EF5; --violet-bg: #2A2358; --blue: #8AB4F8; --blue-bg: #1E2A4E;
  --glass: color-mix(in srgb, #201A3E 70%, transparent); --glow: rgba(86,198,192,.10); --shadow: 0 18px 44px -18px rgba(0,0,0,.7);
  --r1: #3FBFB7; --r2: #A79EF5; --r3: #F0A268; --r4: #8AB4F8; --r5: #F08CC4; --r6: #B5D46A; --r0: #A29BC6;
}
* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body { font-family: var(--body); background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; transition: background .25s ease, color .25s ease; min-height: 100vh; }
h1, h2, h3, .display { font-family: var(--display); letter-spacing: -0.015em; font-weight: 600; }
a { color: var(--primary-text); text-decoration: none; cursor: pointer; }
button { font: inherit; color: inherit; cursor: pointer; }
::-webkit-scrollbar { width: 9px; height: 9px; } ::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; } ::-webkit-scrollbar-thumb:hover { background: var(--ink-2); }
[hidden] { display: none !important; }
.muted { color: var(--ink-2); } .small { font-size: 12px; } .tnum { font-feature-settings: 'tnum'; }
.row { display: flex; align-items: center; gap: 10px; } .row.wrap { flex-wrap: wrap; } .grow { flex: 1 1 auto; min-width: 0; } .right { margin-left: auto; }
.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* soft brand glow behind everything */
.brand-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(1000px 520px at 88% -6%, var(--glow), transparent 70%), radial-gradient(760px 460px at -8% 24%, color-mix(in srgb, var(--primary) 7%, transparent), transparent 70%); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 8px 16px; font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s, background .12s, filter .12s; }
.btn:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: 0 3px 10px rgba(29,18,64,.10); }
.btn:active { transform: none; } .btn:disabled { opacity: .5; pointer-events: none; }
.btn.primary { background: linear-gradient(135deg, #2FB3AB, #1FA39B); border-color: transparent; color: #fff; font-weight: 600; box-shadow: 0 2px 8px rgba(31,163,155,.35), inset 0 1px 0 rgba(255,255,255,.25); }
.btn.primary:hover { box-shadow: 0 6px 18px rgba(31,163,155,.45), inset 0 1px 0 rgba(255,255,255,.25); filter: brightness(1.04); }
.btn.dark { background: var(--ink); color: var(--surface); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; } .btn.ghost:hover { background: var(--hover); box-shadow: none; border-color: transparent; }
.btn.danger { color: var(--danger); } .btn.danger:hover { border-color: var(--danger); background: var(--danger-bg); box-shadow: none; }
.btn.sm { padding: 5px 12px; font-size: 12px; } .btn.lg { padding: 13px 26px; font-size: 15px; }
.btn.icon { padding: 0; width: 34px; height: 34px; } .btn.icon.sm { width: 28px; height: 28px; }
.btn svg, .ico { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* inputs: glass, like Core */
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=tel], input[type=search], input[type=url], select, textarea {
  font: inherit; color: var(--ink); width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 13px;
  background-color: color-mix(in srgb, var(--card) 70%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 18%, transparent); transition: border-color .13s, box-shadow .13s; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--ink-2) 70%, transparent); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
select { appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer; background-repeat: no-repeat; background-position: right 12px center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7' viewBox='0 0 11 7'%3E%3Cpath d='M1 1l4.5 4.5L10 1' stroke='%236B6590' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 17px; height: 17px; cursor: pointer; }
.field { display: grid; gap: 6px; } .field > label, .lbl { font-size: 10.5px; letter-spacing: .9px; text-transform: uppercase; font-weight: 650; color: var(--ink-2); }
.switch { position: relative; width: 38px; height: 22px; flex: none; } .switch input { opacity: 0; position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .15s; } .switch i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s cubic-bezier(.16,1,.3,1); }
.switch input:checked + i { background: var(--primary); } .switch input:checked + i::after { transform: translateX(16px); }

/* surfaces */
.card { background: color-mix(in srgb, var(--surface) 90%, transparent); border: 1px solid color-mix(in srgb, var(--line) 85%, transparent); border-radius: 18px;
  box-shadow: 0 1px 3px rgba(29,18,64,.05), inset 0 1px 0 color-mix(in srgb, #fff 22%, transparent); }
[data-theme="dark"] .card { box-shadow: 0 1px 3px rgba(0,0,0,.2), inset 0 1px 0 color-mix(in srgb, #fff 5%, transparent); }
.glass { background: var(--glass); -webkit-backdrop-filter: blur(18px) saturate(1.3); backdrop-filter: blur(18px) saturate(1.3);
  border: 1px solid color-mix(in srgb, var(--line) 75%, transparent); box-shadow: var(--shadow), inset 0 1px 0 color-mix(in srgb, #fff 25%, transparent); }
[data-theme="dark"] .glass { box-shadow: var(--shadow), inset 0 1px 0 color-mix(in srgb, #fff 7%, transparent); }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--hover); color: var(--ink-2); }
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; } .chip.plain::before { display: none; }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.wait { background: var(--warn-bg); color: var(--warn); } .chip.bad { background: var(--danger-bg); color: var(--danger); }
.chip.info { background: var(--blue-bg); color: var(--blue); } .chip.teal { background: var(--accent-soft); color: var(--primary-text); } .chip.violet { background: var(--violet-bg); color: var(--violet); }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 7px; font-size: 11px; font-weight: 600; background: var(--violet-bg); color: var(--violet); white-space: nowrap; }

/* overlay + modal */
.overlay { position: fixed; inset: 0; z-index: 80; background: rgba(18,12,42,.5); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow: auto; animation: fade .16s ease both; }
.modal { background: color-mix(in srgb, var(--surface) 92%, transparent); -webkit-backdrop-filter: blur(22px) saturate(1.25); backdrop-filter: blur(22px) saturate(1.25); border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 22px; width: 540px; max-width: 100%; padding: 26px 28px; box-shadow: 0 30px 80px rgba(13,10,29,.4), inset 0 1px 0 color-mix(in srgb, #fff 22%, transparent); animation: pop .22s cubic-bezier(.16,1,.3,1) both; position: relative; }
.modal.wide { width: 860px; } .modal.xl { width: 1080px; }
.modal h2 { font-size: 19px; margin-bottom: 4px; } .modal .sub { color: var(--ink-2); font-size: 13px; margin-bottom: 18px; }
.modal .x { position: absolute; top: 16px; right: 16px; }
.mact { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.stack { display: grid; gap: 14px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--primary) 25%, transparent); border-top-color: var(--primary); animation: spin .7s linear infinite; flex: none; }
.loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 70px 20px; color: var(--ink-2); }

/* toast */
#toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { pointer-events: auto; padding: 11px 18px; border-radius: 14px; font-size: 13.5px; font-weight: 500; color: #fff; background: rgba(29,18,64,.94); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: 0 14px 40px rgba(13,10,29,.35); animation: pop .25s cubic-bezier(.16,1,.3,1) both; max-width: min(520px, 92vw); display: flex; gap: 9px; align-items: center; }
.toast.err { background: #A92F23; } .toast.good::before { content: '✓'; color: #7BEDE4; font-weight: 800; }

/* dropdown menu */
.menu { position: fixed; z-index: 120; min-width: 190px; padding: 6px; border-radius: 14px; animation: pop .14s ease both; }
.menu button { display: flex; width: 100%; align-items: center; gap: 9px; text-align: left; border: 0; background: none; padding: 9px 12px; border-radius: 9px; font-size: 13.5px; }
.menu button:hover { background: var(--hover); } .menu button.danger { color: var(--danger); } .menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }

/* signature pad */
.sigpad-tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
.sigpad-tabs button { border: 0; background: none; padding: 8px 20px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.sigpad-tabs button.on { background: linear-gradient(135deg, #2FB3AB, #1FA39B); color: #fff; }
.sigpad-area { position: relative; border: 1.5px dashed color-mix(in srgb, var(--primary) 50%, var(--line)); border-radius: 16px; background: #fff; height: 190px; overflow: hidden; touch-action: none; }
.sigpad-area canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
.sigpad-area .base { position: absolute; left: 7%; right: 7%; bottom: 44px; border-bottom: 1.5px solid #D9D6E8; pointer-events: none; }
.sigpad-area .hint { position: absolute; left: 0; right: 0; bottom: 16px; text-align: center; font-size: 11.5px; color: #9A94B8; pointer-events: none; letter-spacing: .4px; }
.sig-fonts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.sig-font { border: 1.5px solid var(--line); border-radius: 14px; background: #fff; color: #1D1240; height: 74px; font-size: 30px; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 0 12px; white-space: nowrap; transition: border-color .12s, box-shadow .12s; }
.sig-font[data-f="Homemade Apple"] { font-size: 19px; } .sig-font[data-f="Sacramento"] { font-size: 32px; }
.sig-font.on { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }

/* pdf pages */
.pdf-page { position: relative; margin: 0 auto 18px; background: #fff; border-radius: 6px; box-shadow: 0 2px 6px rgba(29,18,64,.10), 0 18px 44px -20px rgba(29,18,64,.35); }
.pdf-page canvas { display: block; width: 100%; height: 100%; border-radius: 6px; }
.pdf-page .layer { position: absolute; inset: 0; }
.pdf-page .pno { position: absolute; right: -8px; top: 10px; transform: translateX(100%); font-size: 11px; color: var(--ink-2); }
