/* FORTH Proposals — app UI (editor, dashboard, client review). */
@font-face { font-family: 'Safiro'; src: url('/assets/fonts/Safiro-Regular.woff') format('woff'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Safiro'; src: url('/assets/fonts/Safiro-Medium.woff') format('woff'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Safiro'; src: url('/assets/fonts/Safiro-SemiBold.woff') format('woff'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Safiro'; src: url('/assets/fonts/Safiro-Bold.woff') format('woff'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Manrope'; src: url('/assets/fonts/manrope-latin-400-normal.woff2') format('woff2'); font-weight: 400; }
@font-face { font-family: 'Manrope'; src: url('/assets/fonts/manrope-latin-500-normal.woff2') format('woff2'); font-weight: 500; }
@font-face { font-family: 'Manrope'; src: url('/assets/fonts/manrope-latin-600-normal.woff2') format('woff2'); font-weight: 600; }
@font-face { font-family: 'Manrope'; src: url('/assets/fonts/manrope-latin-700-normal.woff2') format('woff2'); font-weight: 700; }
@font-face { font-family: 'Signature'; src: url('/assets/fonts/mrs-saint-delafield-latin-400-normal.woff2') format('woff2'); }

:root {
  /* Shared with FORTH Feedback */
  --font: 'Safiro', 'Manrope', 'Helvetica Neue', Arial, sans-serif;
  --ink: #000;
  --ink-2: #555;
  --ink-3: #8a8a8a;
  --muted: #8a8a8a;
  --g100: #f0f0f0;
  --g200: #e1e1e1;
  --line: #e2e2e2;
  --line-2: #e1e1e1;
  --bg: #f7f7f7;
  --panel: #fff;
  --accent: #000;
  --green: #00cb73;
  --green-h: #00bd6b;
  --mint: #17e3a9;
  --bug: #ff5a4e;
  --blue: #2f5bff;
  --amber: #b26b00;
  --red: #e0453a;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.45 var(--font); letter-spacing: -.01em; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
input[type=checkbox], input[type=radio] { accent-color: #000; }
a { color: inherit; }
button, input, select, textarea { font: inherit; letter-spacing: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Buttons — same system as FORTH Feedback */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 20px; border: 0; border-radius: 999px; background: #fff; box-shadow: inset 0 0 0 1px var(--g200); color: #000; font-size: 14px; font-weight: 500; white-space: nowrap; cursor: pointer; text-decoration: none; transition: background-color .25s, color .25s, box-shadow .25s; }
.btn:hover { background: #000; color: #fff; box-shadow: none; }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn.primary { background: #000; color: #fff; box-shadow: none; }
.btn.primary:hover { background: var(--green-h); }
.btn.good { background: var(--green); color: #fff; box-shadow: none; }
.btn.good:hover { background: var(--green-h); }
.btn.soft { background: var(--g100); box-shadow: none; }
.btn.soft:hover { background: var(--green-h); color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--g100); color: #000; }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--bug); color: #fff; box-shadow: none; }
.btn.primary.danger { background: var(--bug); color: #fff; }
.btn.primary.danger:hover { background: #e8443a; }
.btn.sm { height: 32px; padding: 0 14px; font-size: 13px; }
.btn.icon { width: 32px; height: 32px; padding: 0; }
.btn.block { width: 100%; }
.link { background: none; border: 0; border-bottom: 1px solid currentColor; padding: 0; cursor: pointer; font-size: 13px; color: var(--muted); }
.link:hover { color: #000; }

/* Forms */
label.f { display: block; margin-bottom: 14px; }
label.f > span, .f-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; letter-spacing: 0; }
.f-hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], select, textarea {
  width: 100%; border: 0; border-radius: 10px; background: var(--g100); padding: 11px 13px; font-size: 14.5px; line-height: 1.45; outline: none; transition: box-shadow .2s, background-color .2s;
}
input:focus, select:focus, textarea:focus { background: #fff; box-shadow: inset 0 0 0 1.5px #000; }
.card input[type=text], .card input[type=email], .card input[type=number], .card select, .card textarea, .modal input[type=text], .modal input[type=email], .modal input[type=date], .modal select, .modal textarea { background: var(--g100); }
input[readonly] { color: var(--ink-2); }
textarea { resize: vertical; min-height: 64px; }
textarea.md { font-size: 13.5px; line-height: 1.55; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; cursor: pointer; }
.check input { margin-top: 3px; }

/* Brand bar — matches the FORTH Feedback top bar */
.brandbar { height: 64px; display: flex; align-items: center; gap: 16px; padding: 0 28px; background: #000; color: #fff; position: sticky; top: 0; z-index: 20; }
.brandbar img.logo { height: 18px; display: block; }
.brandbar .brand { display: flex; align-items: center; gap: 14px; font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; text-decoration: none; color: #fff; }
.brandbar .brand .sep { width: 1px; height: 20px; background: rgba(255,255,255,.45); }
.brandbar .crumb { font-size: 13px; color: rgba(255,255,255,.6); text-decoration: none; }
.brandbar a.crumb:hover { color: #fff; }
.brandbar .spacer { flex: 1; }
.brandbar .btn { background: transparent; color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.4); }
.brandbar .btn:hover { background: #fff; color: #000; box-shadow: none; }
.brandbar .btn.primary { background: #fff; color: #000; box-shadow: none; }
.brandbar .btn.primary:hover { background: var(--green-h); color: #fff; }
.brandbar .btn.good { background: var(--green); color: #fff; box-shadow: none; }
.brandbar .btn.good:hover { background: var(--green-h); }
.brandbar .navlink { background: none; border: 0; padding: 0; color: rgba(255,255,255,.85); border-bottom: 1px solid currentColor; font-size: 13px; text-decoration: none; cursor: pointer; }
.brandbar .navlink:hover { color: #fff; }

/* Status pills — FORTH Feedback style */
.pill { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--g100); color: #000; white-space: nowrap; }
.pill.draft { background: var(--g100); color: #000; }
.pill.sent { background: #fff; box-shadow: inset 0 0 0 1px var(--g200); }
.pill.viewed { background: var(--mint); color: #000; }
.pill.client_signed { background: #fff; color: #000; box-shadow: inset 0 0 0 1.5px var(--green); }
.pill.signed { background: var(--green); color: #fff; }
.pill.declined { background: var(--bug); color: #fff; }
.brandbar .pill.draft { background: rgba(255,255,255,.15); color: #fff; }
.brandbar .pill.sent { background: transparent; color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.4); }

/* Toast */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #000; color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 13px; opacity: 0; transition: .2s; pointer-events: none; z-index: 100; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--bug); }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(10,10,10,.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow: auto; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { max-width: 760px; }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-h h3 { margin: 0; font-size: 22px; font-weight: 500; letter-spacing: -.015em; }
.modal-b { padding: 20px 22px; }
.modal-f { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

/* ----------------------------------------------------------- Dashboard */
.page { max-width: 1280px; margin: 0 auto; padding: 36px 28px 80px; }
.page-h { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.page-h h1 { font-size: 40px; line-height: 1.05; font-weight: 500; margin: 0; letter-spacing: -.025em; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.tabs button { border: 0; background: none; padding: 12px 16px; cursor: pointer; font-size: 14.5px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: #000; }
.tabs button.on { color: #000; border-color: #000; }
.plist { background: #fff; border-radius: 16px; overflow: hidden; }
.prow { display: grid; grid-template-columns: 1fr 150px 120px 150px 40px; gap: 16px; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); text-decoration: none; }
.prow:last-child { border-bottom: 0; }
.prow:hover { background: #fafaf8; }
.prow .t { font-weight: 600; font-size: 15px; }
.prow .c { color: var(--ink-2); font-size: 13px; }
.prow .m { font-size: 12px; color: var(--ink-3); }
.prow .amt { font-variant-numeric: tabular-nums; font-size: 14px; }
.empty { text-align: center; padding: 70px 20px; color: var(--ink-2); }
.empty h2 { font-weight: 500; letter-spacing: -.015em; font-size: 22px; color: var(--ink); margin: 0 0 8px; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.choice label { box-shadow: inset 0 0 0 1px var(--g200); border-radius: 12px; padding: 12px; cursor: pointer; font-size: 13px; }
.choice label:has(input:checked) { box-shadow: inset 0 0 0 1.5px #000; }
.choice input { display: none; }
.choice b { display: block; font-size: 14px; margin-bottom: 2px; }

/* ----------------------------------------------------------- Editor */
.editor { display: grid; grid-template-columns: 260px minmax(380px, 520px) 1fr; height: calc(100vh - 64px); }
.outline { background: #fff; border-right: 1px solid var(--line); overflow: auto; display: flex; flex-direction: column; }
.outline-h { padding: 14px 14px 8px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.olist { list-style: none; margin: 0; padding: 0 8px; }
.olist li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 999px; cursor: pointer; font-size: 13px; user-select: none; }
.olist li:hover { background: #f3f3f0; }
.olist li.on { background: #000; color: #fff; }
.olist li.off .o-name { opacity: .4; text-decoration: line-through; }
.olist li .grip { cursor: grab; color: var(--ink-3); font-size: 12px; letter-spacing: -2px; }
.olist li.on .grip { color: #777; }
.olist li .o-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.olist li .o-pg { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.olist li.on .o-pg { color: #aaa; }
.olist li.drag-over { box-shadow: inset 0 2px 0 var(--blue); }
.olist li.meta-item { font-weight: 600; }
.outline-f { margin-top: auto; padding: 12px; border-top: 1px solid var(--line); display: grid; gap: 8px; }

.form { overflow: auto; background: var(--bg); border-right: 1px solid var(--line); }
.form-h { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 16px 22px 12px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.form-h h2 { margin: 0; font-size: 22px; font-weight: 500; letter-spacing: -.015em; flex: 1; }
.form-b { padding: 18px 22px 120px; }
.card { background: #fff; border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.card-h { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.card-h .num { font-weight: 700; font-size: 12px; color: var(--ink-3); width: 28px; }
.card-h .title { flex: 1; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card.collapsed .card-b { display: none; }
.card.collapsed .card-h { margin-bottom: 0; }
.card.is-hidden { opacity: .55; }
.addbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 18px; }
.mdhelp { font-size: 11.5px; color: var(--ink-3); margin: -8px 0 14px; }
.mdhelp code { background: #ebebe7; padding: 0 4px; border-radius: 3px; font-size: 11px; }
.sum { display: flex; justify-content: space-between; padding: 10px 2px; font-weight: 700; border-top: 1px solid var(--line-2); margin-top: 4px; }
.sum.warn { color: var(--red); }
.grid-pay { display: grid; grid-template-columns: 1fr 1fr 70px 30px; gap: 8px; align-items: start; }
.calc { font-size: 12px; color: var(--ink-2); padding-top: 2px; }
.divider { height: 1px; background: var(--line); margin: 20px 0; }

.preview { position: relative; background: #e9e9e6; overflow: hidden; }
.preview iframe { width: 100%; height: 100%; border: 0; display: block; }
.preview-bar { position: absolute; right: 14px; top: 12px; z-index: 3; display: flex; gap: 6px; align-items: center; background: rgba(255,255,255,.92); box-shadow: 0 2px 12px rgba(0,0,0,.08); border-radius: 999px; padding: 4px; backdrop-filter: blur(6px); font-size: 12px; }
.preview-bar span { padding: 0 6px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.savestate { font-size: 12px; color: #aaa; min-width: 70px; text-align: right; }

/* Library picker */
.lib-list { max-height: 55vh; overflow: auto; box-shadow: inset 0 0 0 1px var(--line); border-radius: 14px; }
.lib-cat { padding: 8px 12px; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); background: #fafaf8; border-bottom: 1px solid var(--line); position: sticky; top: 0; }
.lib-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.lib-item:hover { background: #fafaf8; }
.lib-item input { margin-top: 4px; }
.lib-item .n { font-weight: 600; font-size: 13.5px; }
.lib-item .p { font-size: 12px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Share panel */
.share-link { display: flex; gap: 8px; }
.share-link input { font-size: 13px; background: #fafaf8; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.timeline li { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--ink-3); font-size: 12px; width: 140px; flex: none; font-variant-numeric: tabular-nums; }
.notice { background: #fff8e6; border: 0; color: #6a4a00; border-radius: 14px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }
.notice.ok { background: #e3f8ee; color: #00633a; }
.notice.info { background: var(--g100); color: #000; }

/* Signature pad */
.sig-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.sig-tabs button { border: 0; background: var(--g100); border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 500; cursor: pointer; }
.sig-tabs button.on { background: #000; color: #fff; }
.sig-box { position: relative; border: 0; box-shadow: inset 0 0 0 1px var(--g200); border-radius: 14px; background: #fff; height: 130px; overflow: hidden; }
.sig-box canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.sig-box .baseline { position: absolute; left: 20px; right: 20px; bottom: 30px; border-bottom: 1px solid #ccc; pointer-events: none; }
.sig-box .x { position: absolute; left: 22px; bottom: 34px; color: #aaa; font-size: 14px; pointer-events: none; }
.sig-box .typed { position: absolute; left: 40px; right: 20px; bottom: 28px; font-family: 'Signature', cursive; font-size: 42px; line-height: 1; white-space: nowrap; overflow: hidden; pointer-events: none; }
.sig-box .clear { position: absolute; right: 8px; top: 8px; }
.sig-box .hint { position: absolute; left: 0; right: 0; top: 42%; text-align: center; color: #bbb; font-size: 13px; pointer-events: none; }

/* ----------------------------------------------------------- Client page */
.client { display: flex; flex-direction: column; height: 100vh; }
.client .doc-frame { flex: 1; position: relative; }
.client .doc-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.client .brandbar .t { font-size: 14px; color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client .brandbar .c { font-size: 12px; color: #aaa; }
.drawer { position: fixed; top: 64px; right: 0; bottom: 0; width: 420px; max-width: 100vw; background: #fff; box-shadow: -10px 0 40px rgba(0,0,0,.18); transform: translateX(105%); transition: transform .25s ease; z-index: 20; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-h { padding: 20px 22px 6px; display: flex; align-items: flex-start; justify-content: space-between; }
.drawer-h h2 { font-size: 22px; font-weight: 500; letter-spacing: -.015em; margin: 0; }
.drawer-b { padding: 12px 22px 24px; overflow: auto; flex: 1; }
.drawer-f { padding: 14px 22px; border-top: 1px solid var(--line); }
.legal { font-size: 12px; color: var(--ink-2); line-height: 1.5; }
.gate { max-width: 400px; margin: 14vh auto; background: #fff; padding: 32px; border-radius: 16px; }
.gate h1 { font-weight: 500; letter-spacing: -.025em; font-size: 28px; margin: 0 0 6px; }
.banner { background: #111; color: #fff; padding: 10px 20px; font-size: 13px; display: flex; gap: 12px; align-items: center; justify-content: center; }
.banner.ok { background: var(--green); color: #fff; }
.banner.warn { background: #6a4a00; }

/* Password field with show/hide */
.f { margin-bottom: 14px; }
.pw { position: relative; }
.pw input { padding-right: 42px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 34px; height: 30px; border: 0; background: none; border-radius: 4px; color: var(--ink-3); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.pw-toggle:hover { color: var(--ink); background: rgba(0,0,0,.05); }
.pw-toggle svg[hidden] { display: none; }
input::placeholder, textarea::placeholder { color: #a5a5a0; }

/* Login */
.login { max-width: 380px; margin: 12vh auto; }
.login .logo { height: 30px; margin-bottom: 28px; }
.login .box { background: #fff; padding: 32px; border-radius: 16px; }
.login h1 { font-size: 28px; font-weight: 500; letter-spacing: -.025em; margin: 0 0 20px; }
.err { color: var(--bug); font-size: 13px; margin: 0 0 12px; }

@media (max-width: 1100px) {
  .editor { grid-template-columns: 220px 1fr; }
  .editor .preview { display: none; }
  .editor.show-preview .form { display: none; }
  .editor.show-preview .preview { display: block; }
}
@media (max-width: 720px) {
  .prow { grid-template-columns: 1fr auto; }
  .prow .hide-sm { display: none; }
  .client .brandbar .hide-sm { display: none; }
}
