/* ==========================================================================
   Technical Reports: projects, sources and the report editor.
   Builds on app.css; the controls are MudBlazor components.
   ========================================================================== */

.rp-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .rp-grid { grid-template-columns: minmax(0, 1fr); } }

.rp-form { display: grid; gap: 14px; }
.rp-form .mud-input-control { margin: 0; }

/* Source documents */
.rp-sources { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
/* Icon and name, then as many controls as the row has (kind, the project it is about, remove), each as wide as it needs. */
.rp-source {
    display: grid; grid-template-columns: 22px minmax(0, 1fr); grid-auto-flow: column; grid-auto-columns: max-content; gap: 10px; align-items: center;
    padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.rp-source .mud-select { width: 180px; }
.rp-source > .mud-icon-root { color: var(--text-3); }
.rp-source-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-source-meta { font-size: 12px; color: var(--text-3); }
.rp-source .mud-input-control { margin: 0; }
@media (max-width: 640px) {
    .rp-source { grid-template-columns: 22px minmax(0, 1fr) auto; grid-auto-flow: row; }
    .rp-source .mud-select { grid-column: 2 / -1; width: auto; }
}

/* Generation progress */
.rp-stages { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.rp-stage { display: flex; gap: 8px; align-items: center; color: var(--text-3); }
.rp-stage .rp-stage-busy { width: 18px; height: 18px; }
.rp-stage.is-done { color: var(--success-fg); }
.rp-stage.is-current { color: var(--text); font-weight: 500; }

/* Report editor */
.rp-group { margin: 22px 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .06em; color: var(--text-3); }
.rp-src { margin-top: 8px; padding: 8px 10px; border-left: 3px solid var(--info-bd); background: var(--surface-muted); border-radius: var(--radius-sm); }
.rp-src.is-found { border-left-color: var(--success-bd); }
.rp-src-head { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--text-3); }
.rp-src-head strong { color: var(--text-2); font-weight: 600; }
.rp-src-text { margin-top: 4px; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Source file picker: a MudFileUpload whose drop area is this card. */
.dropzone.mud-paper {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 18px 12px; cursor: pointer;
    text-align: center; color: var(--text-2);
    background: var(--surface-muted);
    border: 1px dashed var(--border-strong);
    transition: background-color .12s, border-color .12s;
}
.dropzone .dropzone-icon { color: var(--text-3); margin-bottom: 2px; }
.dropzone:hover { background: var(--primary-soft); border-color: var(--primary); }
.dropzone.is-disabled { opacity: .6; cursor: not-allowed; }
.dropzone-browse { color: var(--primary); font-weight: 500; text-decoration: underline; }
.dropzone-hint { font-size: 12px; color: var(--text-3); }

/* ── Report editor ─────────────────────────────────────────────────────────
   A sticky toolbar, the report as a document of numbered sections (the left border of each row shows its state), and a sticky
   rail with the review counts, the selected section's sources and the contents. */

.re-toolbar {
    position: sticky; top: var(--topbar-height); z-index: 15;
    display: flex; align-items: center; gap: 16px;
    padding: 10px 28px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.re-back { color: var(--text-2); white-space: nowrap; flex: none; }
.re-title { min-width: 0; flex: 1; }
.re-title-top { display: flex; align-items: center; gap: 8px; }
.re-id { font: 600 12.5px/1 var(--font-mono); color: var(--text-2); }
.re-title-main { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 4px; }
.re-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.re-saved { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--success-fg); white-space: nowrap; margin-right: 6px; }
.re-saved.is-dirty { color: var(--warning-fg); }

.re-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; padding: 20px 28px 48px; align-items: start; }
@media (max-width: 1200px) { .re-layout { grid-template-columns: minmax(0, 1fr); } .re-rail { position: static; } }

.re-doc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 28px 28px; box-shadow: var(--shadow-1); }

/* The projects a report covers, as chips over the field that adds them. */
.cpi-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.cpi-chips .mud-chip { margin: 0; }

/* To review: the report's own notes and the Science Test checklist at a glance. Each section's notes sit under its text. */
.re-review { margin-bottom: 16px; padding: 14px 16px; border: 1px solid var(--warning-bd); border-left: 4px solid #d97706; border-radius: var(--radius); background: var(--warning-bg); }
.re-review-title { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--warning-fg); margin-bottom: 8px; }

.sts { margin-top: 10px; overflow-x: auto; }
.sts-table { border-collapse: collapse; width: 100%; font-size: 13px; background: var(--surface); border: 1px solid var(--warning-bd); border-radius: var(--radius); }
.sts-table th, .sts-table td { padding: 5px 10px; border-bottom: 1px solid var(--divider); text-align: left; vertical-align: middle; }
.sts-table thead th { font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-muted); }
.sts-table tbody th { font-weight: 400; }
.sts-table td { text-align: center; width: 1%; white-space: nowrap; }
.sts-ws { text-align: center !important; white-space: nowrap; }
.sts-count { display: block; font-weight: 400; color: var(--text-3); font-size: 11.5px; }
.sts-item { display: block; }
.sts-where { display: block; font-size: 11.5px; color: var(--text-3); }
.sts-cell {
    display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 12px;
    font: 700 13px/1 var(--font-ui); border: 1px solid currentColor; background: var(--surface); cursor: pointer;
}
button.sts-cell:hover { filter: brightness(.92); background: currentColor; }
button.sts-cell:hover { color: #fff; }
.sts-cell.is-missing { color: var(--danger-fg); background: var(--danger-bg); }
.sts-cell.is-weak { color: #b45309; background: #fef3c7; }
.sts-legend { margin-top: 6px; font-size: 12px; color: var(--text-3); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sts-legend .sts-cell { width: 18px; height: 18px; font-size: 11px; cursor: default; }

/* A section's notes, under its text. */
.rn { display: grid; gap: 6px; margin: 6px 0 0 8px; font-size: 12.5px; line-height: 1.45; }
.rn-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rn-chip {
    display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 6px; border-radius: 12px; border: 1px solid currentColor;
    font: 500 12px/1.5 var(--font-ui); cursor: pointer; background: var(--surface);
}
.rn-chip.is-missing { color: var(--danger-fg); background: var(--danger-bg); }
.rn-chip.is-weak { color: #b45309; background: #fef3c7; }
.rn-chip.is-open { box-shadow: 0 0 0 2px currentColor; }
.rn-chip-mark { font-weight: 700; }
.rn-detail { padding: 6px 10px; border-radius: var(--radius); border-left: 3px solid; color: var(--text); }
.rn-detail.is-missing { border-color: var(--danger-fg); background: var(--danger-bg); }
.rn-detail.is-weak { border-color: #d97706; background: #fef3c7; }
.rn-wording { color: var(--text-2); padding-left: 10px; border-left: 3px solid #dc2626; }
.rn-quote { color: var(--text); text-decoration: underline wavy #dc2626; text-decoration-skip-ink: none; text-underline-offset: 3px; }
.rn-more { justify-self: start; border: 0; background: none; padding: 0; color: var(--primary); font: 500 12px/1.4 var(--font-ui); cursor: pointer; }
.rn-other { color: var(--warning-fg); padding-left: 10px; border-left: 3px solid var(--warning-bd); }
.re-review > .rn-other { font-size: 13px; margin-bottom: 4px; }

/* A section's text: a transparent textarea over a backdrop holding the same text in the same place, with the marks drawn behind it. */
.rte { display: grid; border: 1px solid transparent; border-radius: var(--radius); }
.re-row:hover .rte:not(.is-readonly) { border-color: var(--border); background: var(--surface); }
.rte:focus-within { border-color: var(--focus); background: var(--surface); box-shadow: 0 0 0 3px rgba(0, 30, 255, .12); }
.rte-backdrop, .rte-text {
    grid-area: 1 / 1; box-sizing: border-box; width: 100%; margin: 0; padding: 2px 8px; border: 0;
    font: 14px/1.6 var(--font-doc); letter-spacing: normal; white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; tab-size: 4;
}
.rte-backdrop { color: transparent; pointer-events: none; min-height: calc(3.2em + 4px); }
.rte-text { height: 100%; resize: none; overflow: hidden; background: transparent; color: var(--text); outline: none; caret-color: var(--text); }
.rte.is-readonly .rte-text { color: var(--text-2); }
.rte-text::placeholder { color: #8a94a3; font-style: italic; opacity: 1; }
.rte mark { color: transparent; border-radius: 3px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.rte-input { background: #fde68a; box-shadow: 0 0 0 1px #d97706; }
.rte-flag { background: rgba(220, 38, 38, .08); text-decoration: underline wavy #dc2626; text-decoration-skip-ink: none; text-underline-offset: 3px; }

/* Legend */
.re-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 4px 0 14px; font-size: 12.5px; color: var(--text-2); border-bottom: 2px solid var(--text); margin-bottom: 8px; }
.re-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.re-legend-mark { width: 0; height: 14px; border-left: 3px solid; }

/* Field states: the left border of a row, and the legend mark */
.st-system { border-left-color: #2e8b57 !important; }
.st-gold { border-left-color: #c9a227 !important; }
.st-generated { border-left-color: var(--primary) !important; }
.st-edited { border-left-color: #d0453b !important; }
.st-edited-nosource { border-left-color: #d0453b !important; border-left-style: dotted !important; }
.st-missing { border-left-color: #9aa3ad !important; border-left-style: dotted !important; }

/* Sections and rows */
.re-section { padding-top: 18px; scroll-margin-top: 130px; }
.re-section-head { display: flex; align-items: baseline; gap: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.re-section-num { color: var(--text-3); font-size: 15px; min-width: 14px; }
.re-section-title { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.re-section.is-hidden { display: none; }

.re-row {
    display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 14px;
    padding: 12px 10px 12px 16px; border-left: 3px solid transparent; border-bottom: 1px solid var(--divider);
    cursor: pointer;
}
.re-row.has-label { grid-template-columns: 170px minmax(0, 1fr) 190px; }
.re-row:hover { background: #fafbfc; }
.re-row.is-selected { background: var(--primary-soft); }
.re-row.is-hidden { display: none; }
.re-label { font-weight: 500; padding-top: 6px; display: flex; gap: 6px; align-items: flex-start; }
.re-value { min-width: 0; }
.re-input.mud-input-control { margin: 0; }
.re-input .mud-input { padding: 2px 8px; border: 1px solid transparent; border-radius: var(--radius); font: 14px/1.6 var(--font-doc); color: var(--text); }
.re-row:hover .re-input .mud-input:not(.mud-input-readonly) { border-color: var(--border); background: var(--surface); }
.re-input .mud-input:focus-within { border-color: var(--focus); background: var(--surface); box-shadow: 0 0 0 3px rgba(0, 30, 255, .12); }
.re-input .mud-input.mud-input-readonly { color: var(--text-2); }
.re-input textarea::placeholder { color: #8a94a3; font-style: italic; opacity: 1; }
.re-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; padding-top: 6px; text-align: right; min-width: 0; }
.re-state { font-size: 12px; color: var(--text-3); }
.re-chip.mud-chip { margin: 0; max-width: 100%; }
.re-chip .mud-chip-content { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.re-chip.is-none { color: var(--text-3); }
.re-gold-btn { font-size: 12px; }

/* Details table and Personnel Involved: filled in by a person, never generated. */
.re-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; padding: 14px 0 14px 19px; border-bottom: 1px solid var(--divider); }
.re-details .mud-input-control { margin: 0; }

/* Hiding a field from the printed report: the eye beside it, and the field dimmed while it is hidden. */
.re-detail { display: flex; align-items: flex-start; gap: 4px; min-width: 0; }
.re-detail > .mud-input-control, .re-detail > .mud-picker, .re-detail > .mud-select, .re-detail > .mud-autocomplete { flex: 1; min-width: 0; }
.re-detail > .hide-toggle { margin-top: 6px; }
.re-detail-field { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

/* What the sources suggest for a field a person fills in: shown under it until the field holds it. */
.re-suggestion { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 12.5px; color: var(--text-2); }
.re-suggestion-icon { color: var(--text-3); flex: none; }
.re-suggestion-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.re-suggestion-use.mud-button-root { min-width: 0; padding: 0 6px; font-size: 12.5px; flex: none; }
.re-people-suggested { margin: 4px 0 0 19px; max-width: calc(100% - 19px); }
.re-chip.is-input { color: var(--warning-fg); border-color: currentColor; }
.re-detail.is-off > :not(.hide-toggle), .re-row.is-off .re-value, .re-row.is-off .re-label { opacity: .45; }
.re-row.is-off .re-state { color: var(--warning-fg); }
.re-state { display: inline-flex; align-items: center; gap: 2px; }
.re-state .hide-toggle-text { font-size: 12px; font-weight: 400; padding: 2px 4px 2px 6px; min-width: 0; color: var(--text-3); }
.re-state .hide-toggle-text.mud-warning-text { color: var(--warning-fg); }
.re-section-head .hide-toggle { margin-left: auto; }
.re-people-hint { margin: 10px 0 8px 19px; }
.re-people.mud-table { width: calc(100% - 19px); margin-left: 19px; background: transparent; }
.re-people th { font-size: 12px; font-weight: 600; color: var(--text-2); padding: 0 6px 4px 0 !important; border: 0 !important; }
.re-people td { padding: 3px 6px 3px 0 !important; vertical-align: middle; border: 0 !important; }
.re-people td:last-child { width: 30px; padding-right: 0; }
.re-people .mud-input-control { margin: 0; }
.re-people-add { margin: 8px 0 0 19px; }
@media (max-width: 640px) {
    .re-details { grid-template-columns: minmax(0, 1fr); }
}

/* Rail */
.re-rail {
    position: sticky; top: calc(var(--topbar-height) + 76px);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1);
    max-height: calc(100vh - var(--topbar-height) - 96px); overflow-y: auto;
}
.re-rail-block { padding: 16px 18px; border-bottom: 1px solid var(--divider); }
.re-rail-block:last-child { border-bottom: 0; }
.re-rail-title { font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); margin-bottom: 10px; }
.re-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.re-stat-num { font-size: 22px; font-weight: 600; line-height: 1.1; }
.re-stat-num.is-edited { color: #a8641a; }
.re-stat-num.is-missing { color: var(--danger-fg); }
.re-stat-label { font-size: 12px; color: var(--text-3); }
.re-filter { width: 100%; }
.re-hint { color: var(--text-2); font-size: 13px; }

.re-src { padding: 10px 0; border-top: 1px solid var(--divider); }
.re-src:first-of-type { border-top: 0; padding-top: 0; }
.re-src-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.re-src-doc { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.re-src-loc { color: var(--text-3); white-space: nowrap; }
.re-src-quote { margin: 6px 0 0; padding: 6px 10px; border-left: 3px solid var(--info-bd); background: var(--surface-muted); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.re-src.is-found .re-src-quote { border-left-color: var(--success-bd); }
.re-src-tag { font-size: 11px; color: var(--success-fg); margin-top: 4px; }

.re-toc.mud-list { padding: 0; }
.re-toc .mud-list-item { padding: 5px 4px; border-radius: var(--radius-sm); }
.re-toc-row { display: flex; align-items: center; gap: 10px; width: 100%; font: 13.5px/1.3 var(--font-ui); }
.re-toc-num { color: var(--text-3); min-width: 16px; }
.re-toc-title { flex: 1; }
.re-flag { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; font: 600 11px/1 var(--font-ui); color: var(--danger-fg); background: var(--danger-bg); }

/* ── Report view ───────────────────────────────────────────────────────────
   The report as printed, in a sandboxed frame filling the page below the toolbar; the report draws its own grey desk and white sheet. */

.rv-frame { display: block; width: 100%; height: calc(100vh - var(--topbar-height) - 63px); border: 0; background: #e9eaee; }

/* ── Gold report editor ────────────────────────────────────────────────────
   One block per written section: its text (growing to fit, like the report editor's), whether it is training data, and its passages. */

.gr-section { padding: 14px 0 16px; border-bottom: 1px solid var(--divider); }
.gr-section:last-child { border-bottom: 0; }
.gr-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.gr-title { font-weight: 600; }
.gr-input.mud-input-control { margin: 0; }
.gr-sources { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 8px; }
.gr-passages { align-self: stretch; }
.gr-passages .mud-expand-panel-header { padding: 4px 0; font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.gr-remove { margin-left: auto; font-size: 12px; }
.gr-stats { grid-template-columns: repeat(3, 1fr); }

/* ── Find source dialog ──────────────────────────────────────────────────── */

.fs-title { font-size: 16px; font-weight: 600; }
.fs-sub { font-size: 13px; color: var(--text-3); margin-top: 2px; }
.fs-search { display: flex; align-items: center; gap: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--divider); }
.fs-search .mud-input-control { flex: 1; margin: 0; }
.fs-body { max-height: 60vh; overflow-y: auto; padding: 4px 0 12px; }
.fs-empty { display: flex; align-items: center; gap: 8px; padding: 28px 0; color: var(--text-2); }
.fs-doc { position: sticky; top: 0; z-index: 1; padding: 10px 0 6px; background: var(--surface); font-weight: 600; border-bottom: 1px solid var(--divider); }
.fs-doc-kind { font-weight: 400; font-size: 12px; color: var(--text-3); margin-left: 6px; }
.fs-para { display: block; padding: 4px 0; border-bottom: 1px solid var(--divider); border-radius: var(--radius-sm); }
.fs-para .mud-checkbox { align-items: flex-start; }
.fs-para:hover { background: var(--surface-muted); }
.fs-para.is-picked { background: var(--success-bg); }
.fs-para-body { min-width: 0; font-size: 13.5px; }
.fs-para-loc { display: block; font-size: 12px; color: var(--text-3); margin-bottom: 2px; }
.fs-para-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.fs-more { padding: 8px 6px; font-size: 12.5px; color: var(--text-3); }
