:root {
  --navy: #1f2a44; --navy-2: #2c3a5c; --gold: #b08d57; --gold-soft: #f4ecdf; --ink: #1d2230; --muted: #5a6275;
  --line: #dfe2e8; --bg: #f7f6f3; --card: #ffffff; --ok: #2e6b3f; --warn-bg: #fff6e5; --warn-line: #e7c98f; --bad: #9b2c2c;
  --radius: 10px; --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 16px; line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--navy-2); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; color: var(--navy); }
h2 { font-size: 1.2rem; color: var(--navy); margin: .5rem 0; }
h3 { font-size: 1.02rem; margin: .5rem 0; }
.muted { color: var(--muted); } .small { font-size: .87rem; } .pad { padding: 1.25rem; } .mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.pre { white-space: pre-wrap; } .nowrap { white-space: nowrap; } .ok { color: var(--ok); }

.test-banner { background: var(--gold); color: #1b1b1b; text-align: center; font-weight: 600; padding: .4rem .75rem; font-size: .92rem; }
.topbar { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 1rem; padding: .6rem 1.25rem; flex-wrap: wrap; }
.brand { color: #fff; text-decoration: none; font-weight: 600; font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; }
.brand-mark { background: var(--gold); color: var(--navy); border-radius: 6px; padding: .1rem .4rem; font-size: .85rem; font-weight: 700; }
.nav { display: flex; gap: .25rem; align-items: center; flex-wrap: wrap; margin-left: auto; }
.nav a, .linklike { color: #e8ebf2; text-decoration: none; padding: .35rem .7rem; border-radius: 6px; background: none; border: 0; font: inherit; cursor: pointer; }
.nav a:hover, .linklike:hover { background: var(--navy-2); }
.nav a.active { background: var(--navy-2); color: #fff; box-shadow: inset 0 -2px 0 var(--gold); }
.version { color: #c9cfdc; font-size: .8rem; }
.nav[hidden] + .version { margin-left: auto; }

main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 1.25rem; outline: none; }
.disclaimer { background: #eceae4; color: #3d4352; font-size: .85rem; text-align: center; padding: .9rem 1.25rem 4.5rem; border-top: 1px solid var(--line); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; box-shadow: 0 1px 2px rgba(20, 30, 50, .04); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.head-actions, .toolbar, .row-btns { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.toolbar { margin-bottom: .5rem; }
.crumb { margin: 0; font-size: .88rem; color: var(--muted); }
.empty { text-align: center; padding: 2rem 1.25rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; font: inherit; font-size: .95rem; padding: .5rem .95rem; min-height: 40px;
  border-radius: 8px; border: 1px solid #c4c9d4; background: #fff; color: var(--navy); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--navy-2); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.primary:hover { background: var(--navy-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--navy-2); text-decoration: underline; }
.btn.small { font-size: .85rem; padding: .3rem .65rem; min-height: 34px; }
.btn.big { font-size: 1.05rem; padding: .7rem 1.4rem; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

label { display: block; font-weight: 500; font-size: .93rem; }
input, select, textarea { font: inherit; font-size: 1rem; width: 100%; padding: .5rem .6rem; border: 1px solid #c4c9d4; border-radius: 7px; background: #fff; color: var(--ink); margin-top: .2rem; }
input[type=checkbox], input[type=radio] { width: 1.1rem; height: 1.1rem; margin: 0 .5rem 0 0; vertical-align: -2px; accent-color: var(--navy); }
textarea { resize: vertical; }
.form-error { color: var(--bad); min-height: 1.2em; margin: .25rem 0; }
.form-error:empty { display: none; }

.auth-wrap { display: flex; justify-content: center; padding-top: 2rem; }
.auth-card { width: 100%; max-width: 420px; padding: 1.75rem; display: flex; flex-direction: column; gap: .9rem; }

.new-matter { display: grid; grid-template-columns: 2fr 1fr auto; gap: .75rem; align-items: end; }
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: .65rem .9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafaf8; }
table.list td.actions { text-align: right; white-space: nowrap; }
table.list tr:last-child td { border-bottom: 0; }

.chip { display: inline-block; font-size: .78rem; font-weight: 600; padding: .12rem .55rem; border-radius: 999px; background: #e9ecf3; color: var(--navy); vertical-align: middle; }
.chip-generated, .chip-fixed, .chip-shipped { background: #e1f0e5; color: var(--ok); }
.chip-signed { background: var(--navy); color: #fff; }
.chip-received, .chip-needs_info { background: var(--gold-soft); color: #6d5226; }
.chip-in_progress, .chip-acknowledged { background: #e3ebf9; color: #23407a; }
.chip-wontfix { background: #eee; color: #555; }

/* interview */
.interview-grid { display: grid; grid-template-columns: 260px 1fr; gap: 1rem; align-items: start; }
.outline { position: sticky; top: 1rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem; }
.outline ol { list-style: none; margin: 0; padding: 0; }
.outline a { display: flex; gap: .55rem; align-items: center; padding: .42rem .5rem; border-radius: 7px; text-decoration: none; color: var(--ink); font-size: .94rem; }
.outline a:hover { background: #f2f3f6; }
.outline li.current a { background: var(--navy); color: #fff; }
.marker { flex: 0 0 1.6rem; height: 1.6rem; border-radius: 50%; border: 1.5px solid #b9bfcc; display: inline-flex; align-items: center; justify-content: center; font-size: .78rem; font-weight: 600; color: var(--muted); background: #fff; }
.outline li.done .marker { background: var(--ok); border-color: var(--ok); color: #fff; }
.outline li.current .marker { border-color: var(--gold); }
.outline-select { display: none; }
.intro { color: var(--muted); margin-top: 0; }
.section-body { display: flex; flex-direction: column; gap: .9rem; }
.field { min-width: 0; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; }
.row > .field { flex: 1 1 180px; }
.row > .field.small { flex: 0 1 110px; }
.row.wrap > .field.wide { flex-basis: 100%; }
.field.check { display: flex; flex-direction: column; justify-content: flex-end; }
.checkbox, .radio { display: flex; align-items: center; font-weight: 400; padding: .25rem 0; cursor: pointer; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.radio-group legend, .list-item legend, .contact legend { font-weight: 600; font-size: .93rem; padding: 0; margin-bottom: .2rem; }
.list-field { border-top: 1px solid var(--line); padding-top: .6rem; }
.list-head { display: flex; align-items: center; gap: .75rem; }
.list-item, fieldset.contact { border: 1px solid var(--line); border-radius: 8px; padding: .75rem; margin: .5rem 0; background: #fcfcfb; }
.sub-heading { border-bottom: 2px solid var(--gold); padding-bottom: .2rem; margin-top: 1rem; }
.help-toggle { background: none; border: 0; padding: .15rem 0; color: var(--navy-2); font-size: .84rem; text-decoration: underline; cursor: pointer; }
.help { background: var(--gold-soft); border-left: 3px solid var(--gold); padding: .5rem .75rem; margin: .3rem 0 0; font-size: .9rem; border-radius: 0 6px 6px 0; }
.info { background: #eef2f9; border-left: 3px solid var(--navy-2); padding: .6rem .8rem; border-radius: 0 6px 6px 0; margin: 0; }
.total.ok { color: var(--ok); } .total.off { color: #7a5a1f; }
.warn-box { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 8px; padding: .75rem 1rem; margin-top: 1rem; }
.warn-title { font-weight: 600; margin: 0 0 .25rem; }
.warn-list { margin: 0; padding-left: 1.1rem; font-size: .9rem; }
.pager { display: flex; gap: .5rem; flex-wrap: wrap; border-top: 1px solid var(--line); margin-top: 1.25rem; padding-top: 1rem; }
.save-status { font-size: .85rem; color: var(--muted); }
.save-status.bad { color: #7a5a1f; }

/* documents */
.docs-grid { display: grid; grid-template-columns: 340px 1fr; gap: 1rem; align-items: start; }
.doc-list { list-style: none; margin: 0; padding: .4rem; }
.doc-list li { padding: .55rem .6rem; border-radius: 8px; border-bottom: 1px solid var(--line); }
.doc-list li:last-child { border-bottom: 0; }
.doc-list li.current { background: var(--gold-soft); }
.doc-link { background: none; border: 0; font: inherit; font-weight: 600; color: var(--navy); text-align: left; padding: 0; cursor: pointer; }
.doc-actions { display: flex; gap: .35rem; margin-top: .35rem; flex-wrap: wrap; }
.preview { background: #e9e7e1; border-radius: var(--radius); padding: 1rem; height: calc(100vh - 2rem); overflow: auto; position: sticky; top: 1rem; }
.paper { position: relative; background: #fff; max-width: 8.5in; margin: 0 auto; padding: .9in .85in; box-shadow: 0 2px 8px rgba(0,0,0,.12);
  font-family: Georgia, "Times New Roman", serif; font-size: 12pt; line-height: 1.55; color: #111; overflow: hidden; }
.paper { background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20width%3D%27640%27%20height%3D%27640%27%3E%3Ctext%20x%3D%27320%27%20y%3D%27320%27%20text-anchor%3D%27middle%27%20transform%3D%27rotate%28-30%20320%20320%29%27%20font-family%3D%27Arial%2Csans-serif%27%20font-size%3D%2740%27%20font-weight%3D%27700%27%20fill%3D%27rgba%28176%2C141%2C87%2C0.16%29%27%3EDRAFT%20%E2%80%94%20FOR%20ATTORNEY%20REVIEW%3C/text%3E%3C/svg%3E"); background-repeat: repeat-y; background-position: center top; }
.paper h1, .paper .doc-title { text-align: center; font-size: 16pt; color: #111; }
.paper h2 { font-size: 13pt; color: #111; }
.paper .blank { display: inline-block; min-width: 6em; border-bottom: 1px solid #333; color: transparent; }
.paper .draft-banner { border: 1px solid #b08d57; background: #fbf6ee; padding: .4rem .6rem; font-family: var(--font); font-size: 9pt; text-align: center; font-weight: 600; }
.paper .sig-block, .paper .notary { margin-top: 1.5rem; page-break-inside: avoid; }
.paper table { border-collapse: collapse; width: 100%; } .paper td, .paper th { border: 1px solid #999; padding: .25rem .4rem; }
.print-root { display: none; }

/* reports / admin */
.report-head { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.history { list-style: none; padding: 0; margin: .4rem 0; border-left: 2px solid var(--line); }
.history li { padding: .3rem 0 .3rem .75rem; }
.shot { max-width: 100%; border: 1px solid var(--line); border-radius: 6px; margin: .5rem 0; }
.invite-out { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .75rem 0; }
.invite-out input { flex: 1 1 300px; }
details summary { cursor: pointer; color: var(--navy-2); margin: .5rem 0; }

/* feedback */
.fb-button { position: fixed; right: 1rem; bottom: 1rem; z-index: 40; background: var(--gold); color: #1b1b1b; border: 0; border-radius: 999px; padding: .75rem 1.1rem;
  font: inherit; font-weight: 600; box-shadow: 0 4px 14px rgba(0,0,0,.2); cursor: pointer; }
.fb-button:hover { filter: brightness(1.05); }
.backdrop { position: fixed; inset: 0; background: rgba(20, 26, 40, .5); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: #fff; border-radius: 12px; padding: 1.4rem; width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; display: flex; flex-direction: column; gap: .75rem; }
.seg { display: flex; gap: .5rem; flex-wrap: wrap; }
.seg label { border: 1px solid #c4c9d4; border-radius: 8px; padding: .45rem .7rem; font-weight: 500; display: flex; align-items: center; cursor: pointer; }
.seg label:has(input:checked) { border-color: var(--navy); background: #eef2f9; }
.fb-id { font-size: 1.15rem; font-weight: 700; color: var(--navy); }
.toast-stack { position: fixed; left: 50%; bottom: 5rem; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; }
.toast { background: var(--navy); color: #fff; padding: .6rem 1rem; border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.25); max-width: 90vw; }
.toast.warn { background: #6d5226; }

@media (max-width: 800px) {
  main { padding: .75rem; }
  .interview-grid, .docs-grid { grid-template-columns: 1fr; }
  .outline { display: none; }
  .outline-select { display: block; margin-bottom: .5rem; }
  .new-matter { grid-template-columns: 1fr; }
  .paper { padding: .5in .4in; font-size: 11pt; }
  .preview { padding: .4rem; height: auto; max-height: none; position: static; }
  table.list thead { display: none; }
  table.list tr { display: block; border-bottom: 1px solid var(--line); padding: .5rem 0; }
  table.list td { display: block; border: 0; padding: .2rem .9rem; }
  table.list td.actions { text-align: left; }
  .pager .btn { flex: 1 1 30%; }
  .fb-button { padding: .65rem .9rem; font-size: .9rem; }
  .topbar { padding: .5rem .75rem; }
}

@media print {
  body.printing > *:not(.print-root) { display: none !important; }
  body.printing .print-root { display: block; }
  .fb-button, #modal-root { display: none !important; }
  .print-root .paper { box-shadow: none; padding: 0; max-width: none; page-break-after: always; overflow: visible; }
  .print-root .paper { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-root::before { content: "DRAFT — FOR ATTORNEY REVIEW"; position: fixed; top: 45%; left: 50%; transform: translate(-50%, -50%) rotate(-30deg);
    font: 700 40px Arial, sans-serif; color: rgba(176, 141, 87, .18); white-space: nowrap; z-index: 0; }
  @page { margin: 0.9in 0.85in; }
}
