/* Kostiv Cardinal Forms - base styles (no build step needed). */
:root {
  --ink: #1f2328;
  --quiet: #5c6370;
  --line: #d9dbe0;
  --tint: #f2f3f5;
  --navy: #071f44;
  --gold: #c2a17a;
  --gold-soft: #f3ebe0;
  --accent: #1d3f7a;
  --accent-soft: #e5ebf5;
  --good: #1f8a3b;
  --good-soft: #e3f3e7;
  --warn: #b7791f;
  --warn-soft: #fdf3dc;
  --bad: #c62828;
  --bad-soft: #fbe5e5;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: #fff;
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 15px; line-height: 1.5; }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 24px 0 12px; }
p { margin: 0 0 12px; }

/* Header: menu button, firm logo, who is signed in */
.header { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; height: 68px; padding: 0 20px 0 12px;
  background: #fff; border-bottom: 1px solid var(--line); box-shadow: inset 0 -3px 0 var(--gold-soft); }
.logo { display: flex; align-items: center; }
.logo img { height: 46px; width: auto; display: block; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.header-right form { margin: 0; }
.header-right .btn { white-space: nowrap; }
.menu-toggle { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer;
  display: inline-flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px; padding: 0; flex-shrink: 0; }
.menu-toggle span { display: block; width: 18px; height: 2px; background: var(--navy); border-radius: 2px; }
.menu-toggle:hover { background: var(--tint); }
.menu-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* App layout: sidebar + main (full width) */
.app { display: flex; min-height: calc(100vh - 68px); }
.sidebar { width: 220px; background: var(--tint); border-right: 1px solid var(--line); padding: 16px 12px; flex-shrink: 0;
  position: sticky; top: 68px; align-self: flex-start; height: calc(100vh - 68px); overflow-y: auto; transition: margin-left .2s ease; }
.nav-collapsed .sidebar { margin-left: -221px; }
.brand { font-weight: 700; padding: 0 8px 20px; line-height: 1.3; }
.brand img { width: 100%; height: auto; display: block; }
.nav a { display: block; padding: 7px 12px; border-radius: 6px; color: var(--ink); text-decoration: none; margin-bottom: 2px; border-left: 3px solid transparent; }
.nav a:hover { background: #e6e8ec; }
.nav a.active { background: var(--accent-soft); font-weight: 600; border-left-color: var(--gold); color: var(--navy); }
.nav .group { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--quiet); padding: 16px 12px 4px; }
.sidebar-who { display: none; }
.scrim { display: none; }
.main { flex: 1; min-width: 0; padding: 24px 32px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 12px; }
.topbar form { margin: 0; }
.who { color: var(--quiet); font-size: 14px; }

/* Guest pages (sign-in, invite) */
.guest { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--tint); padding: 16px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; width: 100%; max-width: 420px; }
.card.wide { max-width: 560px; }
.card .brand { padding: 0 0 16px; }

/* Forms */
label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 6px; font-size: 15px; font-family: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; margin: 8px 0; }
.check input { width: 16px; height: 16px; }
.hint { color: var(--quiet); font-size: 13px; margin-top: 4px; }
.error { color: var(--bad); font-size: 14px; margin-top: 6px; }
.code-input { font-size: 22px !important; letter-spacing: .3em; text-align: center; }

/* Buttons */
.btn { display: inline-block; padding: 8px 16px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  font: inherit; font-size: 14px; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--tint); }
.btn.primary { background: var(--accent-soft); border: 2px solid var(--accent); font-weight: 600; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.full { width: 100%; margin-top: 18px; padding: 10px; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions form { margin: 0; }

/* Messages */
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.flash.ok { background: var(--good-soft); border: 1px solid var(--good); }
.flash.err { background: var(--bad-soft); border: 1px solid var(--bad); }
.flash.warn { background: var(--warn-soft); border: 1px solid var(--warn); }

/* Tables and chips */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--quiet); font-weight: 600; background: var(--tint); padding: 8px 10px; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.chip { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 12px; border: 1px solid; }
.chip.active { background: var(--good-soft); border-color: var(--good); }
.chip.invited { background: var(--tint); border-color: var(--line); }
.chip.suspended { background: var(--bad-soft); border-color: var(--bad); }
.muted { color: var(--quiet); }

/* Dashboard tiles */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.tile { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.tile .n { font-size: 24px; font-weight: 700; }
.tile .l { color: var(--quiet); font-size: 13px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }

/* Two-factor setup */
.qr { display: flex; justify-content: center; margin: 12px 0; }
.qr svg { width: 200px; height: 200px; }
.secret { font-family: ui-monospace, Consolas, monospace; background: var(--tint); padding: 8px; border-radius: 6px; text-align: center; word-break: break-all; }
.codes { font-family: ui-monospace, Consolas, monospace; font-size: 18px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 16px 0; }
.codes div { background: var(--tint); padding: 8px; border-radius: 6px; text-align: center; }

.pagination { display: flex; gap: 6px; margin-top: 16px; list-style: none; padding: 0; }

/* Phones and small tablets: the menu slides in over the page from the hamburger button */
@media (max-width: 860px) {
  .header { height: 60px; padding: 0 12px; gap: 10px; }
  .logo { min-width: 0; }
  .logo img { height: auto; max-height: 36px; max-width: 100%; }
  .header .who { display: none; }
  .app { min-height: calc(100vh - 60px); }
  .sidebar { position: fixed; top: 60px; left: 0; bottom: 0; height: calc(100vh - 60px); height: calc(100dvh - 60px); z-index: 25; width: 260px; margin-left: 0;
    transform: translateX(-100%); transition: transform .2s ease; }
  .nav-collapsed .sidebar { margin-left: 0; }
  .nav-open .sidebar { transform: none; box-shadow: 4px 0 16px rgba(0,0,0,.18); }
  .sidebar { background: #fff; }
  .sidebar-who { display: block; color: var(--quiet); font-size: 13px; padding: 16px 12px 0; border-top: 1px solid var(--line); margin-top: 12px; }
  .nav-open .scrim { display: block; position: fixed; inset: 60px 0 0 0; background: rgba(7, 31, 68, .35); z-index: 20; }
  .nav a { padding: 10px 12px; }
}
@media (max-width: 760px) {
  .main { padding: 16px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  table { font-size: 13px; }
}

/* Form grids and detail lists */
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
.spaced { margin-top: 20px; }
.details { display: grid; grid-template-columns: 200px 1fr; gap: 6px 16px; margin: 0; }
.details dt { color: var(--quiet); }
.details dd { margin: 0; }
.search { display: flex; gap: 8px; margin-bottom: 16px; }
.search input { max-width: 360px; }
textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 6px; font: inherit; min-height: 70px; }
.stage { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 12px; background: var(--accent-soft); border: 1px solid var(--accent); }
.stage.closed { background: var(--tint); border-color: var(--line); }
.stage.waiting_on_client { background: var(--warn-soft); border-color: var(--warn); }
@media (max-width: 760px) { .grid3 { grid-template-columns: 1fr; } .details { grid-template-columns: 1fr; } }

/* Forms: people, answers, review */
input[type=date], textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fff; }
textarea { min-height: 90px; resize: vertical; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form label { margin: 0; }
.inline-form select { width: auto; max-width: 100%; flex: 1 1 220px; }
.panel.question { border-left: 4px solid var(--line); }
.panel.question.unanswered { border-left-color: var(--warn); }
.panel.question.answered { border-left-color: var(--good); }
.panel.question h2 { margin-bottom: 4px; }
.row-group { border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 12px 12px; margin: 10px 0; }
.row-group legend { font-size: 13px; color: var(--quiet); padding: 0 4px; }
.field-multi .label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 6px; }
.field-check .check { margin-top: 38px; }
.sticky-actions { position: sticky; bottom: 0; background: #fff; padding: 12px 0; border-top: 1px solid var(--line); }
tr.missing td { background: var(--warn-soft); }
@media (max-width: 700px) { .field-check .check { margin-top: 8px; } }

/* Colored action buttons: "Answer" with questions still needed vs. all answered */
.btn.fill { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; }
.btn.fill:hover { background: #12306a; }
.btn.needs { background: var(--warn); border-color: var(--warn); color: #fff; font-weight: 600; }
.btn.needs:hover { background: #9c6618; }
.btn.done { background: var(--good-soft); border-color: var(--good); color: var(--good); font-weight: 600; }
.btn.done:hover { background: #d2ecd9; }
.count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px; border-radius: 999px; background: rgba(255,255,255,.25); font-size: 12px; text-align: center; }

/* Pop-up window (answers) */
.modal { width: min(960px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: none; border-radius: 12px;
  box-shadow: 0 20px 60px rgba(7, 31, 68, .35); overflow: hidden; }
.modal[open] { display: flex; flex-direction: column; }
.modal::backdrop { background: rgba(7, 31, 68, .45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line);
  box-shadow: inset 0 -3px 0 var(--gold-soft); }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-close { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink); }
.modal-close:hover { background: var(--tint); }
.modal-body { overflow-y: auto; padding: 16px 20px 0; flex: 1; }
.modal-body .sticky-actions { margin: 0 -20px; padding: 12px 20px; }
.modal-loading { color: var(--quiet); padding: 24px 0; }
body.modal-open { overflow: hidden; }
@media (max-width: 760px) {
  .modal { width: 100vw; max-width: 100vw; height: 100%; max-height: 100%; border-radius: 0; margin: 0; }
}

/* "Saved" messages float in the corner so they're seen wherever the page lands */
.flash.toast { position: fixed; right: 20px; bottom: 20px; z-index: 40; max-width: min(420px, calc(100vw - 40px)); margin: 0;
  display: flex; align-items: center; gap: 12px; box-shadow: 0 8px 24px rgba(7, 31, 68, .18); transition: opacity .3s ease; }
.flash.toast.hide { opacity: 0; pointer-events: none; }
.toast-close { margin-left: auto; border: none; background: none; font-size: 20px; line-height: 1; cursor: pointer; color: var(--ink); padding: 0 2px; }
[id] { scroll-margin-top: 84px; }
.panel.question h2 { margin-top: 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Client questionnaire pages (no menu; logo and language switch on top) */
.client-header { position: static; }
.lang { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.lang a { padding: 4px 10px; border-radius: 999px; text-decoration: none; color: var(--ink); font-size: 14px; border: 1px solid transparent; }
.lang a:hover { background: var(--tint); }
.lang a.active { border-color: var(--gold); background: var(--gold-soft); font-weight: 600; }
.client-main { max-width: 860px; margin: 0 auto; padding: 24px 20px 40px; }
.client-card { margin: 24px auto; }
.client-footer { text-align: center; color: var(--quiet); font-size: 13px; padding: 16px 20px 32px; }
.privacy { max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; background: var(--tint); margin-bottom: 12px; font-size: 14px; }
.flash ul { margin: 6px 0 0; padding-left: 20px; }
.steps { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.steps a { font-size: 13px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.steps a.current { background: var(--navy); border-color: var(--navy); color: #fff; }
.progress { height: 8px; background: var(--tint); border-radius: 999px; overflow: hidden; }
.progress .bar { display: block; height: 100%; background: var(--gold); }
@media (max-width: 600px) {
  .client-header { height: auto; flex-wrap: wrap; padding: 10px 12px; }
  .lang { margin-left: 0; width: 100%; justify-content: flex-start; }
  .client-main { padding: 16px 12px 32px; }
}
.progress .bar.w0 { width: 0%; }
.progress .bar.w5 { width: 5%; }
.progress .bar.w10 { width: 10%; }
.progress .bar.w15 { width: 15%; }
.progress .bar.w20 { width: 20%; }
.progress .bar.w25 { width: 25%; }
.progress .bar.w30 { width: 30%; }
.progress .bar.w35 { width: 35%; }
.progress .bar.w40 { width: 40%; }
.progress .bar.w45 { width: 45%; }
.progress .bar.w50 { width: 50%; }
.progress .bar.w55 { width: 55%; }
.progress .bar.w60 { width: 60%; }
.progress .bar.w65 { width: 65%; }
.progress .bar.w70 { width: 70%; }
.progress .bar.w75 { width: 75%; }
.progress .bar.w80 { width: 80%; }
.progress .bar.w85 { width: 85%; }
.progress .bar.w90 { width: 90%; }
.progress .bar.w95 { width: 95%; }
.progress .bar.w100 { width: 100%; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.inline-form .q-email { width: auto; flex: 1 1 200px; min-width: 180px; }
.inline-form .q-lang { flex: 0 1 130px; }
.spaced-sm { margin-top: 6px; }
form.inline { display: inline; margin-left: 8px; }

/* Case lists, workload and reports */
.filters select { width: auto; flex: 0 1 220px; }
.filters input[type=text] { flex: 1 1 200px; }
tr.selected td { background: var(--accent-soft); }
input.short { width: 70px; flex: 0 0 auto; }

/* Help page */
.help-toc { line-height: 2; }
.panel ul, .panel ol { margin: 0; padding-left: 20px; }
.panel li { margin-bottom: 6px; }

/* Add a form: search box above the list */
.add-form .form-search { flex: 1 1 100%; width: 100%; }
.add-form select { flex: 1 1 320px; }

/* Passport photos (2x2): the case page panel, the client step, and the photo guide (public/js/photo-guide.js) */
.photo-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.photo-row:first-of-type { border-top: none; }
.photo-row .actions { align-items: center; }
.photo-person h2 { margin-top: 0; }
body.fp-open { overflow: hidden; }
.fp { width: min(560px, calc(100vw - 16px)); max-height: calc(100vh - 16px); padding: 0; border: none; border-radius: 12px;
  box-shadow: 0 12px 40px rgba(7, 31, 68, .35); color: var(--ink); background: #fff; }
.fp::backdrop { background: rgba(7, 31, 68, .55); }
.fp-in { padding: 14px 16px 22px; }
.fp-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 17px; }
.fp-x { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink); }
.fp-x:hover { background: var(--tint); }
.fp-tips { margin: 0 0 14px; padding-left: 20px; font-size: 14.5px; }
.fp-tips li { margin: 7px 0; }
.fp-cam { position: relative; width: 100%; max-width: 420px; aspect-ratio: 1 / 1; margin: 0 auto; background: #111; border-radius: 10px; overflow: hidden; }
.fp-cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.fp-cam video.fp-mirror { transform: scaleX(-1); }
.fp-cam svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.fp-count { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 76px; color: #fff; font-weight: 700;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .6); pointer-events: none; }
.fp-hint { text-align: center; font-size: 15px; font-weight: 600; margin: 10px 0; min-height: 22px; }
.fp-hint.ok { color: var(--good); }
.fp-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.fp-btns a.btn { text-decoration: none; }
.fp-link { border: none; background: none; color: var(--accent); text-decoration: underline; cursor: pointer; font-size: 14px; padding: 4px; }
.fp-shot { display: block; width: 240px; height: 240px; margin: 0 auto 12px; border: 1px solid var(--line); }
.fp-sheet { display: block; width: 100%; max-width: 360px; margin: 10px auto; border: 1px solid var(--line); }
.fp-check { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-weight: normal; }
.fp-check input { width: auto; margin: 0; }
.fp-warn { background: var(--warn-soft); border: 1px solid var(--warn); border-radius: 8px; padding: 9px 12px; font-size: 13.5px; margin: 8px 0; }
.fp-good { background: var(--good-soft); color: var(--good); border-radius: 8px; padding: 9px 12px; font-size: 13.5px; margin: 8px 0; }
