/* 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 {
  --font: 'Safiro', 'Manrope', 'Helvetica Neue', Arial, sans-serif;
  --ink: #111;
  --ink-2: #555;
  --ink-3: #8a8a86;
  --line: #e3e3df;
  --line-2: #d2d2cc;
  --bg: #f4f4f1;
  --panel: #fff;
  --accent: #111;
  --blue: #2f5bff;
  --green: #1d8a4e;
  --amber: #b26b00;
  --red: #c4362b;
  --radius: 6px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border: 1px solid var(--line-2); background: #fff; border-radius: var(--radius); cursor: pointer; font-weight: 600; font-size: 13px; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #999; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: #000; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(0,0,0,.05); }
.btn.danger { color: var(--red); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.icon { width: 30px; height: 30px; padding: 0; }
.btn.block { width: 100%; }
.link { background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; font-size: 13px; color: var(--ink-2); }

/* Forms */
label.f { display: block; margin-bottom: 14px; }
label.f > span, .f-label { display: block; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 5px; }
.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: 1px solid var(--line-2); border-radius: var(--radius); background: #fff; padding: 8px 10px; font-size: 14px; line-height: 1.45; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #111; box-shadow: 0 0 0 3px rgba(0,0,0,.06); }
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 */
.brandbar { height: 56px; display: flex; align-items: center; gap: 16px; padding: 0 20px; background: #111; color: #fff; }
.brandbar img.logo { height: 18px; display: block; }
.brandbar .crumb { font-size: 13px; color: #bbb; }
.brandbar .spacer { flex: 1; }
.brandbar .btn { background: transparent; color: #fff; border-color: #444; }
.brandbar .btn:hover { border-color: #888; }
.brandbar .btn.primary { background: #fff; color: #111; border-color: #fff; }

/* Status pills */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 99px; font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; background: #ececea; color: #555; white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.draft { color: #666; }
.pill.sent { background: #e9eeff; color: var(--blue); }
.pill.viewed { background: #fff3e0; color: var(--amber); }
.pill.client_signed { background: #e6f5ec; color: var(--green); }
.pill.signed { background: var(--green); color: #fff; }
.pill.declined { background: #fbe9e7; color: var(--red); }

/* Toast */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #111; color: #fff; padding: 10px 16px; border-radius: 8px; 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(--red); }

/* 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: 10px; 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: 17px; font-weight: 600; }
.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: 1120px; margin: 0 auto; padding: 36px 24px 80px; }
.page-h { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-h h1 { font-size: 30px; font-weight: 400; margin: 0; letter-spacing: -.01em; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; }
.tabs button { border: 0; background: none; padding: 6px 12px; border-radius: 99px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.tabs button.on { background: #111; color: #fff; }
.plist { background: #fff; border: 1px solid var(--line); border-radius: 10px; 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: 400; 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 { border: 1px solid var(--line-2); border-radius: 8px; padding: 12px; cursor: pointer; font-size: 13px; }
.choice label:has(input:checked) { border-color: #111; box-shadow: inset 0 0 0 1px #111; }
.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 - 56px); }
.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: 7px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; user-select: none; }
.olist li:hover { background: #f3f3f0; }
.olist li.on { background: #111; 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: 17px; font-weight: 600; flex: 1; }
.form-b { padding: 18px 22px 120px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 8px; 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); border: 1px solid var(--line); border-radius: 8px; 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; border: 1px solid var(--line); border-radius: 8px; }
.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: 1px solid #f1dca5; color: #6a4a00; border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }
.notice.ok { background: #eaf6ee; border-color: #bfe3cb; color: #145c34; }
.notice.info { background: #eef2ff; border-color: #cdd7ff; color: #22347a; }

/* Signature pad */
.sig-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.sig-tabs button { border: 1px solid var(--line-2); background: #fff; border-radius: 99px; padding: 4px 12px; font-size: 12px; font-weight: 600; cursor: pointer; }
.sig-tabs button.on { background: #111; color: #fff; border-color: #111; }
.sig-box { position: relative; border: 1px solid var(--line-2); border-radius: 8px; 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: 56px; 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: 400; 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: 380px; margin: 14vh auto; background: #fff; padding: 32px; border-radius: 10px; border: 1px solid var(--line); }
.gate h1 { font-weight: 400; font-size: 24px; 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); }
.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: 28px; border-radius: 10px; border: 1px solid var(--line); }
.login h1 { font-size: 22px; font-weight: 400; margin: 0 0 18px; }
.err { color: var(--red); 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; }
}
