.record-editor {
  width: min(680px, calc(100% - 24px)); max-height: calc(100dvh - 24px); margin: auto;
  border: 1px solid var(--line); border-radius: 12px; padding: 28px 20px 20px;
}
.record-editor::backdrop { background: rgb(30 30 42 / 30%); }
.record-form { width: min(544px, calc(100% - 24px)); }
.record-form form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.record-form label { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; font-size: 14px; line-height: 20px; font-weight: 400; color: var(--ink-3, #575766); min-width: 0; }
.record-editor #new-report { background: transparent; }
@scope (.record-editor) {
  :scope {
    color-scheme: light;
    --muted: var(--ink-3, #575766);
    --surface: var(--fill, rgba(112, 115, 147, .10));
    --hover: var(--fill-2, rgba(112, 115, 147, .16));
    --evidence: var(--accent, #4659db);
    --evidence-surface: var(--accent-wash, rgba(70, 89, 219, .09));
    --evidence-hover: rgba(70, 89, 219, .14);
    --column: 40rem;
    font: 400 15px/24px Inter, system-ui, sans-serif;
    color: var(--ink, #1e1e2a);
    background: #fff;
  }
  * { box-sizing: border-box; }
  [hidden] { display: none !important; }
  h1, h2, h3, p { margin: 0; }
  a, button { color: inherit; }
  a, .text-button { text-underline-offset: 2px; }
  h1, h2, h3, strong, summary { font-weight: 500; }
  h1 { font-size: clamp(1.7rem, 4vw, 2.1rem); line-height: 1.16; letter-spacing: -.045em; }
  h2 { font-size: 19px; line-height: 26px; letter-spacing: -.01em; }
  h3 { font-size: 14px; color: var(--muted); font-weight: 500; }
  button, input, select, textarea { font: inherit; }
  button:not(.pill):not(.iconb), .button:not(.pill):not(.iconb) {
    display: inline-flex; align-items: center; justify-content: center; min-height: 36px;
    padding: 6px 14px; border: 0; border-radius: 9999px; background: var(--surface);
    cursor: pointer; font-size: 14px; font-weight: 400; text-decoration: none;
  }
  button:not(.pill):not(.iconb):hover, .button:not(.pill):not(.iconb):hover { background: var(--hover); }
  button:disabled { opacity: .45; cursor: not-allowed; }
  .primary:not(.pill) { color: #fff; background: var(--accent, #4659db); }
  .primary:not(.pill):hover { background: #3849c4; }
  button.text-button {
    min-height: 0; padding: 0; border-radius: 0; background: transparent;
    color: var(--accent, #4659db); text-decoration: none; text-align: left;
  }
  button.text-button:hover { background: transparent; text-decoration: underline; }
  :focus-visible { outline: 2px solid var(--accent, #4659db); outline-offset: 2px; }
  input, textarea, select {
    min-width: 0; width: 100%; font: 400 15px/22px Inter, system-ui, sans-serif;
    border: 1px solid var(--line-2, rgba(87, 90, 118, .28)); border-radius: 8px;
    color: var(--ink, #1e1e2a); background: #fff; outline: 0;
    transition: border-color .12s, box-shadow .12s;
  }
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select {
    height: 38px; padding: 0 12px;
  }
  select {
    -webkit-appearance: none; 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 12 12' fill='none' stroke='%23575766' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5l3 3 3-3'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
  }
  textarea { min-height: 88px; padding: 9px 12px; resize: vertical; }
  input[type="file"] { padding: 7px 10px; font-size: 14px; }
  input:not([type="checkbox"]):not([type="radio"]):focus, select:focus, textarea:focus {
    border-color: var(--accent, #4659db);
    box-shadow: 0 0 0 3px var(--accent-wash, rgba(70, 89, 219, .09));
    outline: 0;
  }
  input::placeholder, textarea::placeholder { color: var(--ink-4, #636374); }
  input:disabled, select:disabled, textarea:disabled { opacity: .55; background: var(--page, #fbfbfd); }
  input[type="search"]::placeholder { color: var(--muted); }
  main { padding-top: 6px; margin-inline: auto; overflow-wrap: anywhere; }
  #export { gap: 6px; font-size: .8125rem; }
  .scope {
    grid-column: 1 / -1; justify-self: start; gap: 6px 10px; flex-wrap: wrap; justify-content: start;
    padding-inline: 0; background: transparent; color: var(--muted); text-align: left;
  }
  #scope:hover { background: transparent; }
  #request-text { white-space: pre-wrap; font: inherit; margin: 0 0 16px; }
  .evidence { margin-top: 18px; }
  search { display: flex; flex: 1; min-width: 0; gap: 10px; align-items: center; }
  search input { flex: 1; width: auto; }
  .muted, small { color: var(--muted); font-size: .875rem; }
  .amount { font-size: clamp(2.6rem, 7vw, 4rem); line-height: 1.12; letter-spacing: -.05em; }
  .amount strong { font-weight: 550; }
  .amount span { font-size: .44em; letter-spacing: -.02em; }
  .source-link { display: inline-flex; align-items: center; min-height: 34px; font-size: .8125rem; }
  .tasks, .entries { padding: 0; list-style: none; margin: 8px 0 0; }
  .task { padding-block: 7px; }
  .panel-heading {
    display: flex; justify-content: space-between; align-items: baseline; gap: 8px 16px;
  }
  .entry .muted { margin-top: 3px; }
  .panel-heading { align-items: center; margin-bottom: 18px; }
  .evidence > section + section { margin-top: 22px; }
  .entry { padding-block: 6px 11px; }
  .reading { font-variant-numeric: tabular-nums; font-weight: 600; }
  .reading > span { color: var(--muted); font-weight: 400; font-size: .8rem; }
  .source-controls { display: flex; align-items: center; gap: 8px; width: fit-content; max-width: 100%; }
  .source-toggle, .open-file {
    display: inline-flex; align-items: center; gap: 6px; min-height: 34px;
    font-size: .8125rem; font-weight: 500; line-height: 1.3;
  }
  .source-toggle { background: transparent; text-align: left; padding: 4px 2px; min-width: 0; overflow-wrap: anywhere; }
  .source-toggle:hover { background: var(--surface); }
  .source-toggle::before {
    content: ""; flex: none; width: 6px; height: 6px; margin-inline: 2px 3px;
    border: solid currentColor; border-width: 1.4px 1.4px 0 0; transform: rotate(45deg);
  }
  .source-toggle[aria-expanded="true"]::before { transform: translateY(-2px) rotate(135deg); }
  .open-file { flex: none; padding: 4px 2px; text-decoration: none; }
  .open-file:hover { text-decoration: underline; }
  .task .open-file { padding-inline: 8px; border-radius: 6px; background: var(--surface); text-decoration: none; }
  .task .open-file:hover { background: var(--hover); }
  .source-content { margin-block: 7px 10px; font-size: .875rem; }
  .source-content img { display: block; max-width: 100%; height: auto; }
  .event { margin-block: 12px; }
  .notice, #dialog-error { font-weight: 550; margin-top: 8px; }
  dialog {
    width: min(calc(100% - 2rem), 34rem); max-height: 88vh; border: 1px solid #ccc; border-radius: 8px;
    padding: 24px; color: var(--ink); overflow-wrap: anywhere;
  }
  dialog::backdrop { background: #0005; }
  dialog .panel-heading button { border: 0; font-size: 1.3rem; }
  dialog form, dialog label { display: grid; gap: 12px; }
  dialog label { gap: 4px; font-weight: 550; }
  @media (max-width: 360px) {
    #export { gap: 4px; padding-inline: 8px; font-size: .75rem; }
    .scope { gap: 4px 8px; font-size: .8125rem; }
  }
  @media (pointer: coarse) {
    button, .button, .source-toggle, .open-file, .source-link { min-height: 44px; }
  }
}

/* Higg FEM entry: label over value, each value copyable; a draft says so first. */
.fem-entry { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr); gap: 10px 16px; margin: 12px 0 0; }
.fem-entry dt { color: var(--ink-3, #70707d); }
.fem-entry dd { margin: 0; overflow-wrap: anywhere; }
.fdm-months { border-collapse: collapse; margin-top: 8px; }
.fdm-months th, .fdm-months td { padding: 4px 16px 4px 0; text-align: left; font-variant-numeric: tabular-nums; }
.fdm-months .r { text-align: right; }

/* Document-backed forms: compact fields + actions on top, full-width viewer cleanly below (never side-by-side). */
.typebill { display: grid; gap: 10px; }
.typebill > div:not(.page-preview) { display: grid; gap: 10px; align-content: start; }
.source-content .viewer { height: 420px; border: 1px solid var(--line, rgba(87, 90, 118, .18)); border-radius: 8px; overflow: hidden; }

.accounts { border: 0; padding: 0; margin: 2px 0 0; display: grid; gap: 8px; }
.accounts legend { padding: 0; margin-bottom: 8px; font-size: 14px; line-height: 20px; font-weight: 400; color: var(--ink-3, #575766); }
.accounts .check { display: flex; gap: 10px; align-items: center; font-variant-numeric: tabular-nums; }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 12px; }
.trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; }
.row-doc { display: grid; grid-template-columns: minmax(0, 1fr) 82px; gap: 10px 12px; }
.row-narrow { display: grid; grid-template-columns: minmax(0, 148px) minmax(0, 1fr); gap: 10px 12px; }
@media (max-width: 520px) { .trio, .pair, .row-narrow { grid-template-columns: 1fr; } }

/* Forms open in the side panel's place, not in a dialog (Long, 22 Nov 2026). The panel keeps its width and position;
   the original it showed comes back when the form closes. */
#editor.form-panel {
  width: auto; max-height: none; margin: 0; border: 0; border-left: 1px solid var(--line); border-radius: 0;
  padding: 20px 24px 32px; position: sticky; top: 52px; height: calc(100dvh - 52px); overflow-y: auto; overflow-x: hidden; min-width: 0;
  background: #fff;
}
#editor.form-panel.has-preview {
  display: flex; flex-direction: column; padding: 0; overflow: hidden;
}
#editor.form-panel.has-preview > .panel-heading {
  padding: 16px 20px 0; margin-bottom: 10px; flex: none;
}
#editor.form-panel.has-preview > #dialog-body {
  padding: 0 20px 14px; flex: 0 1 auto; max-height: 54%; overflow: auto; border-bottom: 1px solid var(--line);
}
#editor.form-panel.has-preview > #dialog-error {
  margin: 0; padding: 8px 20px; border-bottom: 1px solid var(--line); flex: none;
}
#editor.form-panel.has-preview > .page-preview {
  flex: 1 1 auto; min-height: 240px; border: 0; border-radius: 0; overflow: hidden;
}
#editor.form-panel.has-preview form { gap: 10px; }
#editor.form-panel.has-preview label { gap: 4px; font-size: 13px; line-height: 18px; }
#editor.form-panel.has-preview input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
#editor.form-panel.has-preview select { height: 34px; font-size: 14px; padding: 0 10px; }
#editor.form-panel.has-preview select { padding-right: 30px; }
#editor.form-panel[hidden], .work.form #evid { display: none; }
/* Smaller non-document forms stay clearly narrower (460px default, draggable) and yield before crushing the main column. */
.work.ev.form:not(:has(#editor.has-preview)) {
  grid-template-columns: minmax(0, 1fr) clamp(340px, var(--form-w, 460px), calc(100% - var(--col) - 56px));
}
.work.ev.form:not(:has(#editor.has-preview)) .evid-grip {
  left: auto;
  right: calc(clamp(340px, var(--form-w, 460px), calc(100% - var(--col) - 56px)) - 5px);
}
#editor.form-panel .panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 16px; }
#editor.form-panel .panel-heading h2 { margin: 0; font-size: 19px; line-height: 26px; font-weight: 500; letter-spacing: -.01em; color: var(--ink); }
#editor.form-panel .panel-heading .panel-nav { margin-left: auto; display: flex; align-items: center; gap: 4px; flex: none; font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
#editor.form-panel .panel-heading .panel-nav .count { min-width: 32px; text-align: center; }
#editor.form-panel .panel-heading .panel-nav .iconb:disabled { opacity: .35; cursor: default; pointer-events: none; }
#editor.form-panel .panel-heading #close { flex: none; }
#editor.form-panel form > p, #editor.form-panel .typebill p { margin: 0; font-size: 14px; line-height: 21px; color: var(--ink-2); }
#editor.form-panel p.dim, #editor.form-panel p.muted { color: var(--ink-3); }
#editor.form-panel [data-statement-period]:not([hidden]),
#editor.form-panel [data-cert]:not([hidden]) { display: grid; gap: 14px; }
#editor.form-panel .form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
#editor.form-panel .form-actions .form-delete { margin-left: auto; }
#editor.form-panel .form-batch-status { width: 100%; margin: 2px 0 0; font-size: 13.5px; line-height: 19px; color: var(--green); }
#editor.form-panel .upload-panel { display: grid; gap: 16px; }
#editor.form-panel .upload-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: 13px; color: var(--ink-3); }
#editor.form-panel .upload-file-list { list-style: none; margin: 0; padding: 4px 0; border: 1px solid var(--line); border-radius: 10px; max-height: 176px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
#editor.form-panel .upload-file-list li { display: flex; align-items: center; gap: 8px; padding: 6px 12px; font-size: 13.5px; line-height: 19px; color: var(--ink); }
#editor.form-panel .upload-file-list li + li { border-top: 1px solid var(--line); }
#editor.form-panel .upload-file-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#editor.form-panel .upload-file-meta { flex: none; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
#editor.form-panel .upload-rm { min-height: 0; width: 22px; height: 22px; padding: 0; border-radius: 50%; background: none; color: var(--ink-3); font-size: 15px; line-height: 1; }
#editor.form-panel .upload-rm:hover { background: var(--fill); color: var(--ink); }
#editor.form-panel .upload-dropzone { display: grid; justify-items: center; gap: 6px; padding: 26px 18px; border: 1.5px dashed var(--line-2); border-radius: 12px; background: var(--page); text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
#editor.form-panel .upload-dropzone:hover, #editor.form-panel .upload-dropzone.is-dragging { border-color: var(--accent); background: var(--accent-wash); }
#editor.form-panel .upload-dropzone svg { width: 24px; height: 24px; color: var(--ink-3); }
#editor.form-panel .upload-dropzone:hover svg, #editor.form-panel .upload-dropzone.is-dragging svg { color: var(--accent); }
#editor.form-panel .upload-dropzone strong { font-size: 14.5px; font-weight: 500; color: var(--ink); }
#editor.form-panel .upload-dropzone .upload-hint { font-size: 13px; color: var(--ink-3); }
#editor.form-panel .upload-dropzone .upload-folder-link { height: 28px; padding: 0 12px; margin-top: 4px; font-size: 13.5px; }
#editor.form-panel .file-acts { display: flex; flex-wrap: wrap; gap: 6px 14px; }
#editor.form-panel .source-link { min-height: 0; font-size: 14px; color: var(--accent); text-decoration: none; }
#editor.form-panel .source-link:hover { text-decoration: underline; }
#editor.form-panel #request-text {
  white-space: pre-wrap; font: 400 14px/21px Inter, system-ui, sans-serif; color: var(--ink-2);
  background: var(--page); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 0 0 14px;
}
#editor.form-panel #copy-status { font-size: 14px; color: var(--green); }
#editor.form-panel #dialog-error { margin: 12px 0 0; font-size: 14px; line-height: 20px; font-weight: 400; color: #b42318; }
@media (max-width: 720px) {
  .work.form .main { display: none; }
  .work.ev.form:not(:has(#editor.has-preview)) { grid-template-columns: minmax(0, 1fr); }
} /* as the evidence panel does on a narrow screen */
/* A tick box sits before its words, not spread across the panel. */
#editor.form-panel label.check {
  display: flex; justify-content: flex-start; align-items: center; gap: 10px;
  font-size: 15px; line-height: 22px; font-weight: 400; color: var(--ink);
  cursor: pointer; font-variant-numeric: tabular-nums;
}
#editor.form-panel label.check input { width: 16px; height: 16px; min-height: 0; margin: 0; padding: 0; flex: none; accent-color: var(--accent); cursor: pointer; }
#editor.form-panel .utility-account-readonly { display: grid; gap: 14px; }
#editor.form-panel .utility-account-readonly > p { margin: 0; font-size: 14px; line-height: 21px; color: var(--ink-2); }
#editor.form-panel .utility-account-list { display: grid; border-top: 1px solid var(--line); }
#editor.form-panel .utility-account-row { display: flex; align-items: flex-start; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .12s; }
#editor.form-panel .utility-account-row:hover { background: rgba(112, 115, 147, .04); }
#editor.form-panel .utility-account-row input { width: 16px; height: 16px; min-height: 0; margin: 3px 0 0; padding: 0; flex: none; accent-color: var(--accent); cursor: pointer; }
#editor.form-panel .utility-account-row input:disabled { cursor: default; }
#editor.form-panel .utility-account-body { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; }
#editor.form-panel .utility-account-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
#editor.form-panel .utility-account-head strong { font-size: 15px; line-height: 22px; font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
#editor.form-panel .utility-account-state { font-size: 13px; line-height: 18px; color: var(--ink-4); white-space: nowrap; flex: none; }
#editor.form-panel .utility-account-row.is-checked .utility-account-state { color: var(--green); }
#editor.form-panel .utility-account-meta { font-size: 13px; line-height: 19px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* Organization settings windows (account.js) in the panel: notes sit in the form's own 14px rhythm. */
#editor.form-panel .dialog-note { margin: 0; color: var(--ink-3); }
#editor.form-panel .reset-block { margin: 0; }
#editor.form-panel .reset-block .dialog-note { margin-top: 6px; }
#editor.form-panel .link-box { margin: 0; }
