/* Ilapur Document Desk
   Registry green on survey paper. One bold element: the dashed plot tag (a plot as drawn on a layout plan).
   Motion: none on high-frequency actions (typing, results, tabs); press feedback, toasts, menu only. */

:root {
  --paper: #f2f5f2;
  --surface: #ffffff;
  --surface-2: #f7f9f7;
  --ink: #14231f;
  --ink-2: #33433c;
  --muted: #64736b;
  --line: #dde4df;
  --line-strong: #c4cfc8;
  --accent: #1d5c45;
  --accent-hover: #174d39;
  --accent-ink: #ffffff;
  --accent-soft: #e3eee8;
  --ok: #1d6b45;
  --ok-soft: #e2f1e7;
  --warn: #8d5d0c;
  --warn-soft: #fbf1dc;
  --warn-line: #e7cf9c;
  --bad: #ae3429;
  --bad-soft: #fbe8e4;
  --focus: #2b8a66;

  --font-ui: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-num: "Bahnschrift", "DIN Alternate", "Roboto Condensed", "Arial Narrow", var(--font-ui);
  --font-doc: "Book Antiqua", Palatino, "Palatino Linotype", Georgia, serif;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --shadow-1: 0 1px 0 rgba(20, 35, 31, .04), 0 1px 2px rgba(20, 35, 31, .06);
  --shadow-2: 0 8px 24px -8px rgba(20, 35, 31, .18), 0 2px 6px rgba(20, 35, 31, .06);

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1513; --surface: #161e1b; --surface-2: #1b2521; --ink: #e6eee9; --ink-2: #c2cec7; --muted: #8c9b93;
    --line: #26322d; --line-strong: #35443d; --accent: #4fb88f; --accent-hover: #63c79f; --accent-ink: #08130f;
    --accent-soft: #1a2d25; --ok: #59c492; --ok-soft: #15281f; --warn: #e0b260; --warn-soft: #2a2213; --warn-line: #5a4825;
    --bad: #f08a7e; --bad-soft: #33191a; --focus: #63c79f;
    --shadow-1: none; --shadow-2: 0 10px 30px -10px rgba(0, 0, 0, .6); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f1513; --surface: #161e1b; --surface-2: #1b2521; --ink: #e6eee9; --ink-2: #c2cec7; --muted: #8c9b93;
  --line: #26322d; --line-strong: #35443d; --accent: #4fb88f; --accent-hover: #63c79f; --accent-ink: #08130f;
  --accent-soft: #1a2d25; --ok: #59c492; --ok-soft: #15281f; --warn: #e0b260; --warn-soft: #2a2213; --warn-line: #5a4825;
  --bad: #f08a7e; --bad-soft: #33191a; --focus: #63c79f;
  --shadow-1: none; --shadow-2: 0 10px 30px -10px rgba(0, 0, 0, .6); color-scheme: dark;
}

/* ---------------------------------------------------------------- base */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 400 14.5px/1.5 var(--font-ui); -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); text-decoration: none; }
@media (hover: hover) and (pointer: fine) { a:hover { text-decoration: underline; text-underline-offset: 2px; } }
h1 { font-size: 24px; line-height: 1.2; font-weight: 650; letter-spacing: -.015em; margin: 0 0 4px; }
h2 { font-size: 16px; line-height: 1.3; font-weight: 650; letter-spacing: -.005em; margin: 0; }
h3 { font-size: 14px; font-weight: 650; margin: 0; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.ok { color: var(--ok); }
.mt { margin-top: 28px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-soft); }

/* ---------------------------------------------------------------- top bar */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 28px; padding: 0 24px; height: 56px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 650; white-space: nowrap; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; color: var(--accent);
  border: 1.5px dashed var(--accent); font: 600 12px/1 var(--font-num); letter-spacing: .04em; }
.brand-lg .brand-mark { width: 40px; height: 40px; font-size: 15px; border-radius: 9px; }
.brand-lg { font-size: 19px; }
.mainnav { display: flex; gap: 2px; flex: 1; }
.mainnav a { padding: 7px 12px; border-radius: 8px; color: var(--ink-2); white-space: nowrap; font-weight: 500; }
.mainnav a:hover { text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .mainnav a:hover { background: var(--surface-2); color: var(--ink); } }
.mainnav a.active { color: var(--accent); background: var(--accent-soft); }
.usermenu { display: flex; align-items: center; gap: 8px; }
.usermenu form { margin: 0; }
.who { color: var(--ink-2); white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.menubtn { display: none; }

/* ---------------------------------------------------------------- layout */
.container { max-width: 1160px; margin: 0 auto; padding: 28px 24px 72px; }
.container-wide { max-width: 1480px; margin: 0 auto; padding: 0 24px 72px; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.pagehead p { margin: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-1); }
.twocol { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.form-card { padding: 20px 22px; }
.form-card.narrow { max-width: 460px; }
.form-card h2 { margin-bottom: 14px; }
.form-actions { margin-top: 18px; display: flex; justify-content: flex-end; gap: 8px; }

/* ---------------------------------------------------------------- buttons (press feedback, never transition: all) */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: 550 14px/1 var(--font-ui);
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: transform 160ms var(--ease-out), background-color 150ms ease, border-color 150ms ease; }
.btn:hover { text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .btn:hover { background: var(--surface-2); border-color: var(--muted); } }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
@media (hover: hover) and (pointer: fine) { .btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); } }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.danger { color: var(--bad); }

/* ---------------------------------------------------------------- inputs */
input, select, textarea { font: inherit; font-size: 14.5px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 8px 11px; width: 100%; min-height: 38px; transition: border-color 150ms ease, box-shadow 150ms ease; }
textarea { resize: vertical; min-height: 64px; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent); }
input.upper { text-transform: uppercase; }
input[type=file] { padding: 6px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-weight: 600; font-size: 13px; color: var(--ink-2); }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 16px; }
.fld { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fld.w1 { grid-column: span 1; } .fld.w2 { grid-column: span 2; } .fld.w3 { grid-column: span 3; } .fld.w4 { grid-column: span 4; }
.lbl { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.req { color: var(--bad); font-weight: 700; }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.msg { font-size: 12.5px; color: var(--bad); font-weight: 550; }
.msg:empty { display: none; }
.fld.has-err input, .fld.has-err select, .fld.has-err textarea { border-color: var(--bad); background: var(--bad-soft); }
.fld.has-err .multi { border-color: var(--bad); }
.check { display: flex; align-items: center; gap: 9px; cursor: pointer; min-height: 38px; font-weight: 550; }
.check input { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--accent); flex: none; }
.multi { display: flex; flex-wrap: wrap; gap: 0 20px; border: 1px solid transparent; border-radius: 8px; padding: 0 2px; }
.multi .check { font-weight: 450; }

/* ---------------------------------------------------------------- alerts, chips */
.alert { padding: 11px 14px; border-radius: var(--r-sm); margin-bottom: 10px; border: 1px solid transparent; line-height: 1.45; }
.alert-error { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 22%, transparent); }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.chip { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; line-height: 1.5; }
.chip-case { background: transparent; color: var(--ink-2); border-color: var(--line-strong); font-weight: 550; }
.chip-draft { background: var(--surface-2); }
.chip-completed { background: var(--ok); color: #fff; border-color: transparent; }
.chip-verified { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip-generated { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip-signed { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip-closed { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip-hold { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.warntext { color: var(--warn); }

/* ---------------------------------------------------------------- toasts (Sonner principles) */
.toaster { position: fixed; z-index: 60; right: 20px; bottom: 20px; display: flex; flex-direction: column-reverse; gap: 8px;
  width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 10px; align-items: start;
  padding: 13px 14px; border-radius: 12px; background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  box-shadow: var(--shadow-2); font-size: 14px; line-height: 1.4;
  opacity: 0; transform: translateY(100%); transition: transform 400ms ease, opacity 400ms ease; }
.toast[data-mounted="true"] { opacity: 1; transform: translateY(0); }
.toast[data-removed="true"] { opacity: 0; transform: translateY(8px) scale(0.98); transition: transform 200ms var(--ease-out), opacity 200ms var(--ease-out); }
.toast-icon { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; }
.toast.ok .toast-icon { background: var(--ok-soft); color: var(--ok); }
.toast.error .toast-icon { background: var(--bad-soft); color: var(--bad); }
.toast.info .toast-icon { background: var(--accent-soft); color: var(--accent); }
.toast-close { border: 0; background: none; color: var(--muted); cursor: pointer; font: inherit; font-size: 16px; line-height: 1; padding: 0 2px; }
@media (max-width: 600px) { .toaster { right: 16px; left: 16px; width: auto; bottom: 16px; } }

/* ---------------------------------------------------------------- plot tag: the one bold element */
.plottag, .res-plot > span:first-child, #hdr-plot { font-family: var(--font-num); font-weight: 600; letter-spacing: .02em;
  font-variant-numeric: tabular-nums; }
.res-plot > span:first-child, #hdr-plot { display: inline-block; padding: 1px 9px 2px; border: 1.5px dashed color-mix(in srgb, var(--accent) 60%, transparent);
  border-radius: 4px; color: var(--ink); background: var(--surface); }

/* ---------------------------------------------------------------- records finder */
.finder { max-width: 1080px; margin: 0 auto; }
.finder-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.finder-head h1 { margin: 0; }
.searchbox { position: relative; margin-bottom: 14px; }
.searchbox input { height: 56px; font-size: 18px; padding: 0 18px 0 50px; border-radius: var(--r-lg); border: 1.5px solid var(--line-strong);
  box-shadow: var(--shadow-1); }
.searchbox input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); }
.searchicon { position: absolute; left: 18px; top: 18px; width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2.2;
  stroke-linecap: round; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; align-items: center; }
.chip-btn { font: 500 13px/1 var(--font-ui); display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); cursor: pointer;
  user-select: none; transition: transform 160ms var(--ease-out), background-color 150ms ease, border-color 150ms ease, color 150ms ease; }
@media (hover: hover) and (pointer: fine) { .chip-btn:hover { border-color: var(--accent); color: var(--ink); } }
.chip-btn:active { transform: scale(0.96); }
.chip-btn .n { font: 600 12.5px/1 var(--font-num); color: var(--muted); font-variant-numeric: tabular-nums; }
.chip-btn.on { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chip-btn.on .n { color: var(--surface); opacity: .75; }
.chip-btn.good:not(.on) .n { color: var(--ok); }
.chipsep { width: 1px; height: 18px; background: var(--line-strong); margin: 0 4px; }
.resultbar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; min-height: 22px; margin: 10px 2px 8px; }
.results { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; box-shadow: var(--shadow-1); }
.results:empty { display: none; }
.res { display: grid; grid-template-columns: 140px minmax(0, 1fr) 160px 150px; gap: 16px; align-items: center; padding: 11px 18px;
  border-bottom: 1px solid var(--line); color: var(--ink); position: relative; }
.res:last-child { border-bottom: 0; }
.res:hover { text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .res:hover { background: var(--surface-2); } }
.res.active { background: var(--accent-soft); }
.res.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.res:active { background: var(--accent-soft); }
.res-plot { font-size: 16px; display: grid; gap: 3px; justify-items: start; min-width: 0; }
/* long or messy plot text wraps inside its tag instead of running into the name column */
.res-plot > span:first-child { max-width: 100%; white-space: normal; overflow-wrap: anywhere; line-height: 1.25; }
.res-plot[class*="flag-"] > span:first-child { border-color: var(--warn); background: var(--warn-soft); }
.plottag-empty { font: 600 13px/1.25 var(--font-ui) !important; letter-spacing: 0 !important; color: var(--warn) !important;
  border-style: dashed; }
.plotflag { font-size: 12px; font-weight: 600; color: var(--warn); line-height: 1.2; }
.chip-btn.warn:not(.on) .n { color: var(--warn); }
.res-people { min-width: 0; font-weight: 500; }
.res-people > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-people .muted { font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-state { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.rd { font: 600 12.5px/1 var(--font-ui); padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.rd-ok { background: var(--ok-soft); color: var(--ok); }
.rd-need { color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.rd-pending { background: var(--warn-soft); color: var(--warn); }
mark { background: color-mix(in srgb, #f2c94c 45%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
.noresults { padding: 32px; display: grid; gap: 8px; justify-items: center; text-align: center; }
.morewrap { display: flex; justify-content: center; margin: 16px 0; }

/* ---------------------------------------------------------------- tables */
.tablewrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; background: var(--surface); }
.card > table.list, .card .tablewrap > table.list { border: 0; }
table.list th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: var(--surface-2); white-space: nowrap; }
table.list td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr[data-href] { cursor: pointer; }
@media (hover: hover) and (pointer: fine) { table.list tbody tr[data-href]:hover td { background: var(--surface-2); } }
table.compact td, table.compact th { padding: 7px 12px; }
td.actions { display: flex; gap: 6px; flex-wrap: wrap; }
form.inline { display: inline-flex; gap: 6px; margin: 0; }
form.inline input { width: 160px; min-height: 32px; padding: 4px 9px; }
.empty { padding: 44px; text-align: center; }
.empty h2 { margin-bottom: 6px; }
.statstrip { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; padding: 10px 16px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line);
  color: var(--ink-2); min-width: 110px; }
.stat b { font: 600 22px/1.15 var(--font-num); color: var(--ink); font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; }
.stat-closed b { color: var(--ok); }
.stat-hold b { color: var(--bad); }

/* ---------------------------------------------------------------- new record */
.casegrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; }
.casecard { padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.casecard h2 { font-size: 19px; }
.casecard p { margin: 0; }
.casecard .btn { margin-top: auto; }
.casecard-head { display: flex; justify-content: space-between; align-items: center; }
.rate { font: 600 13px/1 var(--font-num); color: var(--muted); letter-spacing: .02em; }
.doclist { margin: 2px 0 4px; padding-left: 18px; }
.doclist li { margin: 4px 0; }

/* ---------------------------------------------------------------- record page */
.recordbar { position: sticky; top: 56px; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 14px;
  flex-wrap: wrap; padding: 12px 0; background: var(--paper); border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.recordbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.recordbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.back { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line-strong);
  color: var(--ink); background: var(--surface); font-size: 16px; transition: transform 160ms var(--ease-out); }
.back:hover { text-decoration: none; }
.back:active { transform: scale(0.95); }
.rec-title { display: flex; align-items: center; gap: 10px; font-size: 19px; flex-wrap: wrap; }
#hdr-sub { margin-top: 3px; max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.statuspick { display: flex; align-items: center; gap: 6px; }
.statuspick select { width: auto; min-height: 36px; padding: 5px 30px 5px 10px; }
.savestate { font-size: 13px; min-width: 120px; text-align: right; font-weight: 550; }
.savestate.ok { color: var(--muted); } .savestate.warn { color: var(--warn); } .savestate.bad { color: var(--bad); }
.tabs { display: flex; gap: 2px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tab { font: 600 14px/1 var(--font-ui); background: none; border: 0; padding: 11px 14px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { text-decoration: none; color: var(--ink); }
.tab.on { color: var(--ink); border-bottom-color: var(--accent); }
.recordgrid { display: grid; grid-template-columns: 236px minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.recordgrid:has(#sectionnav[hidden]) { grid-template-columns: minmax(0, 1fr) 300px; }
.sectionnav { position: sticky; top: 140px; display: flex; flex-direction: column; gap: 1px; max-height: calc(100vh - 160px); overflow-y: auto;
  padding-right: 4px; }
.sectionnav a { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 7px 10px; border-radius: 7px;
  color: var(--ink-2); font-size: 13.5px; line-height: 1.35; }
.sectionnav a:hover { text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .sectionnav a:hover { background: var(--surface); } }
.sectionnav a.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: inset 2px 0 0 var(--accent); }
.nav-b { font: 600 12px/1.35 var(--font-num); white-space: nowrap; font-variant-numeric: tabular-nums; }
.nav-b.good, .sect-badge.good { color: var(--ok); }
.nav-b.bad, .sect-badge.bad { color: var(--bad); }
.nav-b.warn, .sect-badge.warn { color: var(--warn); }
.formcol { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
#recform { display: flex; flex-direction: column; gap: 14px; }
.sect { padding: 18px 20px 20px; scroll-margin-top: 150px; }
.sect-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.sect-badge { font: 600 12.5px/1 var(--font-num); }
.sect-help { margin: -8px 0 14px; }
.item { border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px 16px; margin-bottom: 12px; background: var(--surface-2); }
.item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.addrow { display: flex; align-items: center; gap: 12px; margin: 4px 0 12px; flex-wrap: wrap; }
table.edit { width: 100%; border-collapse: collapse; min-width: 640px; }
table.edit th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 6px; border-bottom: 1px solid var(--line); }
table.edit td { padding: 4px; }
table.edit input { min-height: 34px; padding: 5px 9px; }
table.edit .sl { width: 36px; text-align: center; color: var(--muted); font-family: var(--font-num); }
table.edit .act { width: 36px; }
table.edit th.w2 { width: 24%; }
.emptyrow { padding: 14px !important; }
.sidecol { position: sticky; top: 140px; display: flex; flex-direction: column; gap: 12px; }
.side { padding: 16px 18px; }
.side h3 { margin-bottom: 10px; }
.calc { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; display: grid; gap: 7px; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.kv b { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.gen { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; margin-bottom: 10px; display: grid; gap: 7px; }
.gen.latest { border-color: color-mix(in srgb, var(--accent) 50%, transparent); background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.gen.old { opacity: .7; }
.gen-head { display: flex; justify-content: space-between; align-items: center; }
ul.files { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
ul.files li { display: grid; gap: 7px; padding: 9px 0; font-size: 13px; border-top: 1px solid var(--line); }
ul.files li:first-child { border-top: 0; padding-top: 2px; }
.fname { min-width: 0; font-weight: 600; line-height: 1.35; }
.flinks { display: flex; align-items: center; gap: 16px; white-space: nowrap; font-weight: 600; }
.review { display: flex; flex-direction: column; gap: 14px; }
.review .sect h2 { margin-bottom: 12px; }
.review h3 { margin: 12px 0 6px; }
table.kvtable { width: 100%; border-collapse: collapse; }
table.kvtable th { text-align: left; font-weight: 500; color: var(--muted); width: 40%; padding: 7px 12px 7px 0; vertical-align: top; font-size: 13.5px; }
table.kvtable td { padding: 7px 0; border-bottom: 1px dashed var(--line); font-weight: 550; overflow-wrap: anywhere; }
table.kvtable tr.bad th { color: var(--bad); }
.missing { color: var(--bad); font-weight: 600; }

/* read-only "info" fields */
.infobox { white-space: pre-wrap; background: var(--warn-soft); color: var(--ink); border: 1px solid var(--warn-line); border-radius: 8px;
  padding: 11px 14px; font-size: 13.5px; line-height: 1.6; }

/* live "how it prints" preview */
.preview { margin-top: 16px; padding: 13px 15px; border: 1px dashed var(--line-strong); border-radius: var(--r-sm); background: var(--surface-2); }
.pv-title { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.pv-title + .pv-text { margin: 4px 0 10px; }
.pv-text { font-family: var(--font-doc); font-size: 15px; line-height: 1.6; }
.pv-text:last-child { margin-bottom: 0; }
mark.pv-val { background: var(--accent-soft); color: var(--accent); font-weight: 700; padding: 0 2px; border-radius: 3px; }
mark.pv-missing { background: var(--bad-soft); color: var(--bad); font-family: var(--font-ui); font-size: 12.5px; font-weight: 600; padding: 0 4px; border-radius: 3px; }

/* ---------------------------------------------------------------- bulk import */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 14px; }
.step { padding: 20px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.step p { margin: 0; }
.stepno { width: 30px; height: 30px; border-radius: 7px; border: 1.5px dashed var(--accent); color: var(--accent); display: grid;
  place-items: center; font: 600 14px/1 var(--font-num); }
.uploadform { display: flex; gap: 8px; flex-wrap: wrap; width: 100%; }
.uploadform input[type=file] { flex: 1 1 200px; }
.commitbox, .genbox { margin-bottom: 12px; display: grid; gap: 6px; }
.commitbox .check, .genbox .check { font-weight: 450; align-items: flex-start; }
.commitbox .check input, .genbox .check input { margin-top: 3px; }
.inlineform { margin: 0 0 14px; }
.form-actions.gap { gap: 8px; }
a.tab:hover { text-decoration: none; }
.job { margin-bottom: 14px; display: grid; gap: 9px; }
.job-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.job-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.job-actions form { margin: 0; }
.job-failures { display: grid; gap: 3px; max-height: 260px; overflow-y: auto; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.progress .bar { height: 100%; width: 100%; transform-origin: left; transform: scaleX(0); background: var(--accent); transition: transform 600ms var(--ease-out); }

/* ---------------------------------------------------------------- login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(400px, 100%); padding: 32px 30px 28px; box-shadow: var(--shadow-2); }
.login-card .brand { margin-bottom: 6px; }
.login-card p { margin: 0 0 22px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1200px) {
  .recordgrid { grid-template-columns: 210px minmax(0, 1fr); }
  .recordgrid:has(#sectionnav[hidden]) { grid-template-columns: minmax(0, 1fr); }
  /* Below the form, in the form's own column: the sticky section menu keeps its column and never slides over it. */
  .sidecol { grid-column: -2 / -1; position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: start; }
}
@media (max-width: 860px) {
  .topbar { gap: 12px; padding: 0 16px; flex-wrap: wrap; height: auto; min-height: 56px; }
  .brand-name { display: none; }
  .menubtn { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; font: 550 14px/1 var(--font-ui); background: none;
    border: 1px solid var(--line-strong); border-radius: 8px; height: 36px; padding: 0 12px; color: var(--ink); cursor: pointer;
    transition: transform 160ms var(--ease-out); }
  .menubtn:active { transform: scale(0.97); }
  .usermenu { order: 2; }
  .who { display: none; }
  .mainnav { display: none; order: 3; flex-basis: 100%; flex-direction: column; padding: 4px 0 12px; }
  .topbar.open .mainnav { display: flex; opacity: 1; transform: translateY(0); transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out); }
  @starting-style { .topbar.open .mainnav { opacity: 0; transform: translateY(-4px); } }
  .mainnav a { padding: 11px 12px; }
  .recordgrid, .recordgrid:has(#sectionnav[hidden]) { grid-template-columns: minmax(0, 1fr); }
  .sectionnav { position: static; flex-direction: row; overflow-x: auto; max-height: none; padding-bottom: 6px; scrollbar-width: none; }
  .sectionnav a { flex: none; background: var(--surface); border: 1px solid var(--line); }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fld.w3, .fld.w4 { grid-column: span 2; }
  .twocol { grid-template-columns: 1fr; }
  .recordbar { position: static; }
  .res { grid-template-columns: 104px minmax(0, 1fr); gap: 6px 12px; padding: 12px 14px; }
  .res-case, .res-state { grid-column: 2; justify-content: flex-start; }
  .res-plot { grid-row: span 3; align-self: start; }
  .searchbox input { font-size: 16px; height: 52px; }
  .searchhint { display: none; }
  input, select, textarea { font-size: 16px; }
}
@media (max-width: 520px) {
  .container, .container-wide { padding-left: 16px; padding-right: 16px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .fld.w1, .fld.w2, .fld.w3, .fld.w4 { grid-column: span 1; }
  .recordbar-right { width: 100%; }
  .recordbar-right .btn { flex: 1; }
  .savestate { min-width: 0; text-align: left; }
  .finder-head h1 { font-size: 21px; }
}

/* ---------------------------------------------------------------- reduced motion: keep fades, drop movement */
@media (prefers-reduced-motion: reduce) {
  .btn:active, .chip-btn:active, .back:active, .menubtn:active { transform: none; }
  .toast, .toast[data-mounted="true"], .toast[data-removed="true"] { transform: none; transition: opacity 200ms ease; }
  .topbar.open .mainnav { transform: none; }
  .progress .bar { transition: none; }
}

/* ---------- print preview ---------- */
.printwrap { max-width: 1100px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; min-height: calc(100dvh - 60px); }
.printbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.printbar-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.printbar-title { display: flex; flex-direction: column; min-width: 0; }
.printbar-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.printbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.printbar-actions select { max-width: 260px; }
.btn-print { font-size: 1.05rem; padding: 10px 26px; }
.printhint { margin: 0; }
.pdfframe { flex: 1; width: 100%; min-height: 70vh; border: 1px solid var(--line, #d0d7d2); border-radius: 10px; background: #525659; }
@media (max-width: 640px) {
  .printbar-actions { width: 100%; }
  .btn-print { flex: 1; }
}
.printframe { position: fixed; right: 0; bottom: 0; width: 1px; height: 1px; border: 0; opacity: 0; pointer-events: none; }
.printbtn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 14px; border: 1px solid var(--accent);
  border-radius: 8px; background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; line-height: 1; cursor: pointer;
  transition: transform 160ms cubic-bezier(0.23, 1, 0.32, 1), background-color 160ms ease-out; }
.printbtn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) and (pointer: fine) { .printbtn:hover { background: var(--accent-hover); border-color: var(--accent-hover); } }
.printbtn:active { transform: scale(0.97); }
.printbtn:disabled { opacity: 0.7; cursor: progress; transform: none; }
@media (prefers-reduced-motion: reduce) { .printbtn { transition: background-color 160ms ease-out; } .printbtn:active { transform: none; } }
.alert-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.alert-row .btn { flex: none; }
.datebox { position: relative; }
.datebox input[type=text] { width: 100%; padding-right: 36px; font-variant-numeric: tabular-nums; }
.datepick-btn { position: absolute; top: 50%; right: 4px; transform: translateY(-50%); width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: 6px; background: transparent; cursor: pointer; font-size: 15px; line-height: 1; }
@media (hover: hover) and (pointer: fine) { .datepick-btn:hover { background: var(--line); } }
.datepick-btn:active { transform: translateY(-50%) scale(0.97); }
.datepick-native { position: absolute; right: 0; bottom: 0; width: 36px; height: 100%; opacity: 0; pointer-events: none; border: 0; padding: 0; }
.verifybar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-top: 14px; padding: 16px 18px; }
.verify-text { display: grid; gap: 2px; min-width: 0; }
.verify-ok { color: var(--ok); }
.verify-warn { color: var(--warn); }
.btn-verify { min-width: 140px; }
.verify-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sect.locked .sect-head h2::after, section.locked > h2::after { content: "  🔒"; font-size: 0.8em; }
.sect.locked input:disabled, .sect.locked select:disabled, .sect.locked textarea:disabled { background: transparent; border-style: dashed; border-color: var(--line-strong); color: var(--ink); -webkit-text-fill-color: var(--ink); opacity: 1; cursor: not-allowed; box-shadow: none; }
.sect.locked select:disabled { appearance: none; -webkit-appearance: none; }
.sect.locked .fld label, .sect.locked .fld .lbl { color: var(--muted); }
.sect.locked .btn:disabled { display: none; }
.sect.locked .datepick-native, .sect.locked .datepick-btn { display: none; }

/* ---------- confirmation dialog ---------- */
dialog.ask { width: min(440px, calc(100vw - 32px)); padding: 22px 22px 18px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface, #fff); color: var(--ink); box-shadow: 0 18px 50px rgba(10, 30, 20, 0.22);
  animation: ask-in 200ms cubic-bezier(0.23, 1, 0.32, 1); }
dialog.ask::backdrop { background: rgba(12, 24, 19, 0.38); animation: ask-fade 200ms ease-out; }
dialog.ask.closing { animation: ask-out 120ms ease-in forwards; }
dialog.ask.closing::backdrop { animation: ask-fade 120ms ease-in reverse forwards; }
.ask-title { margin: 0 0 8px; font-size: 17px; line-height: 1.35; }
.ask-body { margin: 0 0 8px; color: var(--muted); line-height: 1.5; font-size: 14px; }
.ask-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.ask-actions .btn { min-width: 96px; }
dialog.ask-warn { border-top: 4px solid var(--warn); }
dialog.ask-danger { border-top: 4px solid var(--bad); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
@media (hover: hover) and (pointer: fine) { .btn-danger:hover { filter: brightness(1.08); } }
@keyframes ask-in { from { opacity: 0; transform: scale(0.96) translateY(4px); } }
@keyframes ask-out { to { opacity: 0; transform: scale(0.98); } }
@keyframes ask-fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { dialog.ask, dialog.ask::backdrop, dialog.ask.closing { animation: none; } }
@media (max-width: 480px) { .ask-actions { flex-direction: column-reverse; } .ask-actions .btn { width: 100%; } }

/* ---------------------------------------------------------------- Forms & checklist card (desk.js) */
.desk { margin-top: 14px; }
.desk h2 .chip { margin-left: 6px; vertical-align: middle; }
.desk-group { border-top: 1px solid var(--line); padding: 16px 0 6px; }
.desk-group h3 { margin-bottom: 10px; }
.desk-group > .fld { margin-top: 10px; }
.desk-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 16px; }
.desk-ticks { display: grid; gap: 2px; }
/* One line per item: tick + label | its box (stamp paper No. / pages) | who and when */
.desk-tick { display: grid; grid-template-columns: minmax(0, 1fr) auto 168px; align-items: center; gap: 4px 14px; padding: 3px 0; }
.desk-tick .check { font-weight: 500; min-height: 34px; }
.desk-tick .check span { line-height: 1.35; }
.desk-tick > .fld { grid-column: 2; grid-row: 1; flex-direction: row; align-items: center; gap: 8px; }
.desk-tick > .fld .lbl { font-weight: 500; white-space: nowrap; }
.desk-tick > .fld input { width: 170px; min-height: 34px; }
.desk-tick > .fld.desk-short input { width: 64px; }
.desk-tick > .desk-meta { grid-column: 3; grid-row: 1; }
.desk-note { margin-left: 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
.desk-meta { text-align: right; line-height: 1.3; }
.desk-ok { color: var(--ok); font-weight: 600; }
.desk-warn { color: var(--warn); }
.desk-bad { color: var(--bad); font-weight: 600; }
.desk-bad-date { border-color: var(--bad) !important; }
.desk-addrow { margin-top: 8px; }
.desk.locked .desk-addrow { display: none; }
.desk-group.desk-attn { outline: 2px solid var(--bad); outline-offset: 4px; border-radius: 6px; }
.desk.locked .datepick-btn { display: none; }
.desk-forms { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 16px; display: grid; gap: 8px; }
.desk-forms-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.desk-forms ul.files { max-width: 560px; }
.desk.locked h2::after { content: "  🔒"; font-size: 0.8em; }
.desk.locked input:disabled, .desk.locked textarea:disabled { background: transparent; border-style: dashed; border-color: var(--line-strong);
  color: var(--ink); -webkit-text-fill-color: var(--ink); opacity: 1; cursor: not-allowed; box-shadow: none; }
@media (max-width: 860px) {
  .desk-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .desk-tick { grid-template-columns: minmax(0, 1fr); }
  .desk-tick > .fld, .desk-tick > .desk-meta { grid-column: 1; grid-row: auto; padding-left: 27px; }
  .desk-meta { text-align: left; }
}

/* Plot group: "add a plot by its number" (record.js groupAddRow) */
.group-plot-input { max-width: 200px; }
