/* Brief Forms Portal: design system
   Palette: ink navy + warm brass on paper. Display: Fraunces. UI: Inter. */

:root {
  --ink: #17233a;
  --ink-2: #24344f;
  --ink-soft: #3c4a63;
  --brass: #b88a4a;
  --brass-soft: #e9d9bf;
  --brass-tint: #f7efe2;
  --paper: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --line: #e7e1d7;
  --line-strong: #d6cdbf;
  --text: #1d2433;
  --muted: #697084;
  --success: #2c7a57;
  --success-bg: #e6f4ec;
  --warning: #a2660f;
  --warning-bg: #fdf1dc;
  --danger: #b23c32;
  --danger-bg: #fbe9e7;
  --info: #2c5d9c;
  --info-bg: #e7eef8;
  --focus: #3d6fd8;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(23, 35, 58, .06);
  --shadow: 0 1px 2px rgba(23, 35, 58, .05), 0 6px 20px -8px rgba(23, 35, 58, .12);
  --shadow-lg: 0 20px 50px -20px rgba(23, 35, 58, .35);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-w: 256px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; animation: none !important; } }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--text); background: var(--paper); -webkit-font-smoothing: antialiased; }
a { color: var(--ink-2); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brass); }
img, svg { display: block; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--ink); }
p { margin: 0; }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: .05em .35em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -40px; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: var(--radius-sm); z-index: 100; }
.skip-link:focus { top: 12px; color: #fff; }

.icon { width: 20px; height: 20px; flex-shrink: 0; }
.icon-sm { width: 16px; height: 16px; }
.icon-xs { width: 13px; height: 13px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }
.nowrap { white-space: nowrap; }
.prewrap { white-space: pre-wrap; word-break: break-word; }
.center { text-align: center; }
.ta-right { text-align: right; }
.d-block { display: block; }
.mb { margin-bottom: 16px; }
.error-text { color: var(--danger); }
.stack { display: grid; gap: 14px; }
.stack-sm { display: grid; gap: 8px; margin-top: 14px; }
.stack-xs { display: grid; gap: 4px; justify-items: start; }

.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--brass); margin-bottom: 6px; }
.display { font-family: var(--font-display); font-weight: 600; font-size: clamp(24px, 3vw, 30px); letter-spacing: -.01em; }
.display-xl { font-size: clamp(28px, 4.4vw, 42px); }
.lead { font-size: 17px; color: var(--ink-soft); max-width: 70ch; margin-top: 10px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 14px; line-height: 1; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--ink-2); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: var(--ink-soft); color: var(--ink); background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: rgba(23, 35, 58, .06); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #962f27; color: #fff; }
.danger-card { border-color: #f1c8c2; }
.book-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 18px; padding-bottom: 16px; border-bottom: 1px dashed var(--line); }
.book-tab { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft); text-decoration: none; font-size: 13px; font-weight: 600; transition: all .15s; }
.book-tab:hover { border-color: var(--ink-soft); color: var(--ink); }
.book-tab.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.book-tab-count { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: rgba(23, 35, 58, .08); }
.book-tab.is-active .book-tab-count { background: rgba(255, 255, 255, .18); }
.book-tab-add { border-style: dashed; color: var(--brass); border-color: var(--brass-soft); }
.remove-book { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -14px 0 30px; }
.book-section + .book-section { margin-top: 0; }
.book-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.book-head h2 { font-family: var(--font-display); font-size: 20px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.book-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brass); }
.smtp-diagnostic { margin-top: 16px; padding: 14px; border: 1px solid #f1c8c2; background: var(--danger-bg); border-radius: var(--radius-sm); font-size: 14px; display: grid; gap: 10px; }
.smtp-diagnostic summary { cursor: pointer; font-weight: 600; }
.smtp-diagnostic pre { margin: 8px 0 0; max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 12px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 10px; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { min-height: 48px; padding: 0 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-loading { opacity: .7; cursor: progress; }
.btn.is-loading::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); cursor: pointer; transition: all .15s; }
.icon-btn:hover { border-color: var(--line-strong); color: var(--ink); background: var(--surface-2); }
.icon-btn.is-copied { color: var(--success); border-color: var(--success); }
.icon-btn-danger:hover { color: var(--danger); border-color: var(--danger); }
.link { background: none; border: 0; padding: 0; font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; text-decoration: none; }
.link:hover { color: var(--brass); }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); text-decoration: none; margin-bottom: 10px; }
.back-link:hover { color: var(--ink); }

/* ---------- Badges & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.4; white-space: nowrap; }
.badge-xs { padding: 1px 7px; font-size: 11px; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: #eeebe5; color: var(--muted); }
.cat { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 8px; border-radius: 6px; }
.cat-ebook { background: var(--brass-tint); color: #8a6430; }
.cat-marketing { background: #e9eef7; color: #36558a; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-soft); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); }
.chip-completed .dot { background: var(--success); }

/* ---------- Alerts ---------- */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid; margin-bottom: 18px; font-size: 14px; }
.alert .icon { margin-top: 2px; }
.alert > span { flex: 1; }
.alert-success { background: var(--success-bg); border-color: #bfe0cd; color: #1f5c40; }
.alert-error { background: var(--danger-bg); border-color: #f1c8c2; color: #8a2a22; }
.alert-info { background: var(--info-bg); border-color: #c7d6ee; color: #22497c; }
.alert a { color: inherit; font-weight: 600; }
.alert-close { background: none; border: 0; color: inherit; opacity: .6; cursor: pointer; padding: 2px; }
.alert-close:hover { opacity: 1; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 22px; margin-bottom: 20px; }
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-title { display: inline-flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 650; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 { margin-bottom: 20px; }
.empty { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 36px 20px; color: var(--muted); }
.empty .icon { width: 28px; height: 28px; color: var(--line-strong); }
.empty-sm { padding: 16px; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; margin: 0; min-width: 0; }
fieldset.field { border: 0; padding: 0; }
.field-label { font-weight: 600; font-size: 14px; color: var(--ink); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 0; }
legend.field-label { margin-bottom: 6px; }
.field-help { font-size: 13px; color: var(--muted); }
.field-help .icon { display: inline-block; vertical-align: -2px; margin-right: 4px; }
.req { color: var(--danger); font-weight: 700; }
.input { width: 100%; min-height: 42px; padding: 9px 12px; font: inherit; font-size: 15px; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); transition: border-color .15s, box-shadow .15s; }
.input::placeholder { color: #a3a8b5; }
.input:hover { border-color: #bfb4a3; }
.input:focus { outline: none; border-color: var(--ink-soft); box-shadow: 0 0 0 3px rgba(61, 111, 216, .18); }
.input-sm { min-height: 32px; padding: 5px 10px; font-size: 13px; width: 150px; }
.reset-pass { display: inline-flex; gap: 6px; align-items: center; }
.textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
.select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23697084' stroke-width='2.4'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.field-error { font-size: 13px; font-weight: 500; color: var(--danger); }
.has-error .input, .input[aria-invalid="true"] { border-color: var(--danger); background: #fffafa; }
.has-error .choice-grid { border-radius: var(--radius-sm); box-shadow: 0 0 0 1px var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.field-span { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-bottom: 30px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-top: 18px; padding-top: 18px; border-top: 1px dashed var(--line); }
.inline-form .field { flex: 1 1 200px; }

/* Choice tiles (checkbox & radio) */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.choice { position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 44px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; font-size: 14px; }
.choice:hover { border-color: var(--line-strong); background: var(--surface-2); }
.choice input, .ms-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice-box { width: 18px; height: 18px; flex-shrink: 0; border: 1.5px solid #b9b0a2; border-radius: 5px; background: #fff; display: grid; place-items: center; transition: all .15s; }
.choice input[type="radio"] + .choice-box { border-radius: 50%; }
.choice input:checked + .choice-box, .ms-option input:checked + .choice-box { background: var(--ink); border-color: var(--ink); }
.choice input:checked + .choice-box::after, .ms-option input:checked + .choice-box::after { content: ""; width: 9px; height: 5px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: translateY(-1px) rotate(-45deg); }
.choice input[type="radio"]:checked + .choice-box::after { width: 7px; height: 7px; border: 0; border-radius: 50%; background: #fff; transform: none; }
.choice:has(input:checked) { border-color: var(--ink-soft); background: #f3f5f9; }
.choice input:focus-visible + .choice-box, .ms-option input:focus-visible + .choice-box { outline: 3px solid var(--focus); outline-offset: 2px; }
.other-input { margin-top: 8px; max-width: 520px; }
.js .other-input:not(.is-open) { display: none; }

/* File upload */
.file-drop { border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 16px; background: var(--surface-2); }
.file-input { font: inherit; font-size: 14px; max-width: 100%; }
.file-input::file-selector-button { font: inherit; font-weight: 600; font-size: 13px; padding: 8px 14px; margin-right: 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: #fff; color: var(--ink); cursor: pointer; }
.file-hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.file-list { margin: 8px 0 0; padding: 0; list-style: none; font-size: 13px; display: grid; gap: 4px; }
.file-list li { display: flex; gap: 8px; color: var(--ink-soft); }
.file-list .bad { color: var(--danger); }

/* Repeater */
.repeater-items { display: grid; gap: 14px; }
.repeater-item { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--surface-2); }
.repeater-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.repeater-title { font-size: 14px; font-weight: 700; color: var(--ink); }
.repeater-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.repeater-grid .field-textarea, .repeater-grid .field-radio { grid-column: 1 / -1; }
.repeater-items + .btn { justify-self: start; margin-top: 4px; }
.repeater-item:only-child [data-repeater-remove] { display: none; }

/* Multi-select dropdown */
.ms { position: relative; }
.ms-toggle { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; cursor: pointer; }
.ms-summary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.ms.has-value .ms-summary { color: var(--text); }
.ms-toggle .icon { color: var(--muted); transition: transform .15s; }
.ms.is-open .ms-toggle .icon { transform: rotate(180deg); }
.ms-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ms-chips:empty { display: none; }
.ms-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; background: var(--ink); color: #fff; border-radius: 999px; font-size: 12px; font-weight: 600; }
.ms-chip.is-locked { background: var(--success); padding-right: 10px; }
.ms-chip button { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .18); color: #fff; cursor: pointer; padding: 0; }
.ms-chip button:hover { background: rgba(255, 255, 255, .35); }
.ms-panel { margin-top: 8px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-lg); padding: 8px; }
.js .ms-panel { position: absolute; left: 0; right: 0; top: 46px; z-index: 30; display: none; margin-top: 0; }
.js .ms.is-open .ms-panel { display: block; }
.no-js .ms-toggle, .no-js .ms-search-wrap, .no-js .ms-actions { display: none; }
.ms-search-wrap { display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--muted); }
.ms-search { flex: 1; border: 0; outline: none; font: inherit; font-size: 14px; padding: 9px 0; background: transparent; min-width: 0; }
.ms-actions { display: flex; justify-content: space-between; padding: 8px 6px 4px; }
.ms-options { max-height: 290px; overflow: auto; display: grid; gap: 2px; }
.ms-option { position: relative; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; }
.ms-option:hover { background: var(--surface-2); }
.ms-option-text { flex: 1; }
.ms-option.is-locked { cursor: not-allowed; opacity: .85; }
.ms-empty { padding: 10px; color: var(--muted); font-size: 13px; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #fcfbf8; }
.card:not(.card-flush) .table th:first-child, .card:not(.card-flush) .table td:first-child { padding-left: 4px; }
.client-cell { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.client-cell span:last-child { display: grid; }
.client-cell small { font-size: 12px; }
.client-cell:hover strong { color: var(--brass); }
.row-actions { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.row-actions form { margin: 0; }
.pager { display: flex; gap: 6px; padding: 14px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pager-link { min-width: 34px; height: 34px; display: grid; place-items: center; border-radius: var(--radius-sm); border: 1px solid var(--line); text-decoration: none; font-size: 13px; font-weight: 600; }
.pager-gap { align-self: center; color: var(--muted); padding: 0 2px; }
.pager-info { align-self: center; margin-left: auto; font-size: 13px; color: var(--muted); }
.pager-link.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* Avatars & progress */
.avatar { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--brass-tint); color: #7e5a2a; font-weight: 700; font-size: 13px; flex-shrink: 0; border: 1px solid var(--brass-soft); }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-lg { width: 56px; height: 56px; font-size: 18px; }
.avatar-warn { background: var(--warning-bg); color: var(--warning); border-color: #f2dcb4; }
.progress { height: 8px; background: #ece7df; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--ink-2), var(--brass)); border-radius: inherit; transition: width .3s ease; }
.progress-lg { height: 10px; }
.progress-inline { display: flex; align-items: center; gap: 10px; min-width: 130px; }
.progress-inline .progress { flex: 1; max-width: 140px; }

/* ---------- Admin shell ---------- */
.admin-shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--ink); color: #c9d0dc; display: flex; flex-direction: column; position: fixed; left: 0; top: 0; bottom: 0; z-index: 30; overflow-y: auto; overscroll-behavior: contain; padding: 20px 14px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; color: #fff; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: linear-gradient(135deg, var(--brass), #d9b57f); color: var(--ink); flex-shrink: 0; }
.brand-text { display: grid; line-height: 1.25; min-width: 0; }
.brand-text strong { font-family: var(--font-display); font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-text small { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #9aa6ba; }
.nav { display: grid; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); color: #c9d0dc; text-decoration: none; font-weight: 500; font-size: 14px; background: none; border: 0; font-family: inherit; cursor: pointer; transition: background .15s, color .15s; }
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link.is-active { background: rgba(255, 255, 255, .1); color: #fff; box-shadow: inset 3px 0 0 var(--brass); }
.nav-link .icon { opacity: .85; }
.nav-count { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 14px; display: grid; gap: 6px; }
.me { display: flex; align-items: center; gap: 10px; padding: 4px 8px; }
.me .avatar { background: rgba(255, 255, 255, .1); border-color: transparent; color: #fff; }
.me-text { display: grid; min-width: 0; line-height: 1.3; }
.me-text strong { color: #fff; font-size: 13px; }
.me-text small { font-size: 12px; color: #9aa6ba; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; margin-left: var(--sidebar-w); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 32px; background: rgba(246, 243, 238, .88); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar-title { font-weight: 600; color: var(--ink-soft); font-size: 14px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-btn { display: none; }
.content { padding: 28px 32px 140px; max-width: 1280px; width: 100%; } /* bottom room for dropdown panels */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head .muted { margin-top: 6px; }
.title-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.sidebar-backdrop { display: none; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { position: relative; display: grid; gap: 4px; padding: 18px 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); text-decoration: none; color: inherit; transition: box-shadow .15s, transform .15s, border-color .15s; }
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); border-color: var(--line-strong); color: inherit; }
.stat-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: #eef1f6; color: var(--ink-2); margin-bottom: 8px; }
.stat-icon-sm { width: 32px; height: 32px; margin: 0; flex-shrink: 0; }
.stat-warning .stat-icon { background: var(--warning-bg); color: var(--warning); }
.stat-success .stat-icon { background: var(--success-bg); color: var(--success); }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat-value { font-family: var(--font-display); font-size: 32px; font-weight: 600; color: var(--ink); line-height: 1.1; }

.activity { list-style: none; margin: 0; padding: 0; display: grid; }
.activity li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.activity li:last-child { border-bottom: 0; }
.activity-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.activity-body a { text-decoration: none; color: var(--text); }
.activity-body a:hover { color: var(--brass); }
.activity-body small { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px; }
.toolbar .select { width: auto; min-width: 170px; flex: 0 1 auto; }
.search-input { position: relative; flex: 1 1 260px; display: flex; align-items: center; }
.search-input .icon { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search-input .input { padding-left: 36px; }

.client-hero-row { display: flex; align-items: center; gap: 16px; }
.link-card { background: linear-gradient(180deg, #fff, #fdfbf7); border-color: var(--brass-soft); }
.link-card-head { margin-bottom: 14px; }
.link-card .muted { margin-top: 4px; max-width: 75ch; }
.copy-field { display: flex; gap: 8px; flex-wrap: wrap; }
.copy-field .input { flex: 1 1 320px; background: var(--surface-2); }
.link-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.form-status-list { list-style: none; margin: 0; padding: 0; }
.form-status-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.form-status-list li:last-child { border-bottom: 0; }
.form-status-list li > div:first-child { display: grid; }
.form-status-list small { font-size: 12px; }
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; min-width: 0; word-break: break-word; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab.is-active { color: var(--ink); border-bottom-color: var(--brass); }
.tab-count { display: inline-block; min-width: 22px; text-align: center; font-size: 11px; background: #ece7df; border-radius: 999px; padding: 1px 6px; margin-left: 4px; }

/* Submission view */
.submission-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.submission-side { position: sticky; top: 80px; }
.meta-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 0; }
.meta-grid dt { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.meta-grid dd { margin: 4px 0 0; font-weight: 600; word-break: break-word; }
.answer-section-title { font-family: var(--font-display); font-size: 19px; font-weight: 600; padding-bottom: 12px; margin-bottom: 4px; border-bottom: 2px solid var(--brass-soft); }
.qa { padding: 14px 0; border-bottom: 1px solid var(--line); }
.qa:last-child { border-bottom: 0; padding-bottom: 0; }
.qa-q { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.qa-a { font-size: 15px; color: var(--text); }
.qa-empty { color: #a3a8b5; font-style: italic; }
.qa-list { margin: 0; padding-left: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.qa-list li { background: #f1f3f7; border: 1px solid #e1e5ec; border-radius: 6px; padding: 3px 10px; font-size: 14px; }
.file-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.file-links a { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.notif-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 12px; }
.notif-list li { display: grid; gap: 3px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.notif-row { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; word-break: break-all; }

/* ---------- Login ---------- */
.login-page { background: var(--ink); }
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-aside { padding: 44px; color: #c9d0dc; display: flex; flex-direction: column; justify-content: space-between; background: radial-gradient(1200px 500px at -10% 110%, rgba(184, 138, 74, .35), transparent 60%), var(--ink); }
.login-quote { font-family: var(--font-display); font-size: clamp(28px, 3.4vw, 40px); color: #fff; font-weight: 500; max-width: 18ch; line-height: 1.2; }
.login-sub { margin-top: 16px; max-width: 46ch; color: #aab4c5; }
.login-foot { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #8e9ab0; }
.login-panel { background: var(--paper); display: grid; place-items: center; padding: 32px 20px; }
.login-card { width: 100%; max-width: 400px; display: grid; gap: 16px; }
.login-card .alert { margin: 0; }

/* ---------- Client portal ---------- */
body.client { background: var(--paper); }
.client-top { background: var(--ink); color: #fff; }
.client-top-inner { max-width: 1140px; margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.client-top .brand { padding: 0; }
.secure-note { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #aab4c5; white-space: nowrap; }
.client-main { min-height: calc(100vh - 140px); }
.client-container { max-width: 1140px; margin: 0 auto; padding: 40px 20px 60px; }
.client-container.narrow { max-width: 720px; }
.client-foot { text-align: center; font-size: 12px; color: var(--muted); padding: 24px 20px 32px; border-top: 1px solid var(--line); }
.hero { margin-bottom: 30px; }
.hero-progress { margin-top: 22px; max-width: 420px; display: grid; gap: 8px; font-size: 14px; color: var(--ink-soft); }
.portal-group { margin-bottom: 32px; }
.portal-book-title { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 24px; font-weight: 600; margin: 34px 0 16px; padding-bottom: 10px; border-bottom: 2px solid var(--brass-soft); }
.portal-book-title .icon { color: var(--brass); }
.next-list li small { display: block; width: 100%; font-size: 12px; }
.group-title { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 650; margin-bottom: 14px; }
.form-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.form-card { display: flex; flex-direction: column; gap: 14px; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); transition: box-shadow .2s, transform .2s, border-color .2s; }
.form-card:not(.is-done):hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--line-strong); }
.form-card-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--brass-tint); color: #8a6430; }
.form-card.is-done .form-card-icon { background: var(--success-bg); color: var(--success); }
.form-card-body h3 { font-family: var(--font-display); font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.form-card-body p { font-size: 14px; }
.form-card-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.form-card.is-done { background: #fcfdfc; }
.privacy-note { display: flex; gap: 12px; padding: 16px 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--brass); margin-bottom: 26px; font-size: 14px; color: var(--ink-soft); }
.privacy-note .icon { color: var(--brass); margin-top: 3px; }
.privacy-note p { margin-top: 4px; }

.form-hero { margin-bottom: 24px; }
.form-hero .lead { font-size: 16px; }
.form-hero .small { margin-top: 10px; }
.form-layout-client { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 28px; align-items: start; }
.section-nav { position: sticky; top: 20px; display: grid; gap: 14px; }
.progress-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 10px; }
.progress-head { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.section-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.section-links a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); text-decoration: none; color: var(--ink-soft); font-size: 13px; font-weight: 500; transition: background .15s; }
.section-links a:hover { background: rgba(23, 35, 58, .05); color: var(--ink); }
.section-links a.is-current { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.sl-num { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: #ece7df; color: var(--ink-soft); flex-shrink: 0; transition: all .2s; }
.section-links a.is-complete .sl-num { background: var(--success); color: #fff; }
.sl-text { line-height: 1.35; }
.brief-form { min-width: 0; }
.form-section { padding: 0; overflow: hidden; scroll-margin-top: 20px; }
.form-section-head { padding: 20px 24px 16px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #fff, var(--surface-2)); }
.section-step { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--brass); }
.form-section-title { font-family: var(--font-display); font-size: 21px; font-weight: 600; margin-top: 4px; }
.form-section-desc { margin-top: 6px; color: var(--ink-soft); }
.form-section-body { padding: 22px 24px 26px; display: grid; gap: 24px; }
.form-section-body .field-label { font-size: 15px; line-height: 1.45; }
.submit-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-color: var(--brass-soft); background: linear-gradient(180deg, #fff, #fdfaf4); }
.state-card { text-align: center; display: grid; justify-items: center; gap: 10px; padding: 44px 28px; }
.state-card .lead { margin-left: auto; margin-right: auto; }
.state-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: #eef1f6; color: var(--ink-2); margin-bottom: 8px; }
.state-icon .icon { width: 30px; height: 30px; }
.state-icon-success { background: var(--success-bg); color: var(--success); box-shadow: 0 0 0 8px rgba(44, 122, 87, .08); }
.state-icon-warn { background: var(--warning-bg); color: var(--warning); }
.thank-you .display { font-size: clamp(28px, 4vw, 36px); }
.next-card .card-title { margin-bottom: 12px; }
.next-list { list-style: none; margin: 0; padding: 0; }
.next-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.next-list li:last-child { border-bottom: 0; }
.next-list li > span { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.center-page .state-card { max-width: 520px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .submission-layout { grid-template-columns: 1fr; }
  .submission-side { position: static; }
  .meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .main-wrap { margin-left: 0; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: none; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(15, 22, 36, .45); z-index: 40; }
  .sidebar.is-open + .sidebar-backdrop { display: block; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 10px 16px; }
  .content { padding: 20px 16px 120px; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-layout-client { grid-template-columns: 1fr; }
  .section-nav { position: static; }
  .section-links { display: none; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-aside { display: none; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .form-grid, .repeater-grid { grid-template-columns: 1fr; }
  .stat-grid { gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 26px; }
  .card { padding: 16px; }
  .card-flush { padding: 0; }
  .form-section-head { padding: 16px 16px 14px; }
  .form-section-body { padding: 18px 16px 20px; }
  .choice-grid { grid-template-columns: 1fr; }
  .topbar-cta span { display: none; }
  .table th, .table td { padding: 11px 12px; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dd { margin-bottom: 10px; }
  .meta-grid { grid-template-columns: 1fr; }
  .submit-bar .btn { width: 100%; }
  .client-container { padding: 28px 16px 44px; }
  .secure-note { display: none; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
  .page-head > .btn, .page-head > form { width: 100%; }
  .page-head > form .btn, .page-head > .btn { width: 100%; }
}

/* ---------- Print (admin submission) ---------- */
@media print {
  .sidebar, .topbar, .no-print, .alert-close, .back-link { display: none !important; }
  body { background: #fff; font-size: 12pt; }
  .content { padding: 0; max-width: none; }
  .main-wrap { margin-left: 0; }
  .card { box-shadow: none; border: 0; padding: 0 0 12pt; break-inside: auto; }
  .submission-layout { display: block; }
  .qa { break-inside: avoid; }
  .qa-list li { border: 0; background: none; padding: 0 10pt 0 0; }
}
