/* IP COI Review - one small stylesheet, no framework. */
:root {
    --bg: #f5f6f8; --panel: #fff; --text: #1f2933; --muted: #5a6572; --line: #dde1e6;
    --field-line: #7d8792; /* input / control outlines: at least 3:1 against the background (WCAG 1.4.11) */
    --accent: #1f5fa8; --accent-dark: #184c87; --danger: #b42318; --ok-bg: #e7f5ec; --ok: #1e6b3a;
    --warn-bg: #fff6e0; --warn: #8a5a00; --err-bg: #fdecea;
}
* { box-sizing: border-box; }
html { scroll-padding-top: 60px; } /* keep focused / linked-to elements clear of the sticky top bar */
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
/* links in the page are underlined, not told apart by colour alone (WCAG 1.4.1) */
main a:not(.button):not(.stat) { text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }

/* accessibility helpers */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: .5rem; top: -3rem; z-index: 200; background: #fff; color: var(--accent); padding: .5rem .8rem; border: 2px solid var(--accent); border-radius: 4px; }
.skip-link:focus { top: .5rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.topbar :focus-visible { outline-color: #fff; }
main:focus { outline: none; }
.errors:focus { outline: 2px solid var(--danger); outline-offset: 2px; }
.errors a { color: var(--danger); }
[aria-invalid=true] { border-color: var(--danger) !important; }
[role=radiogroup][aria-invalid=true] { border-left: 3px solid var(--danger); padding-left: .5rem; }
.required-note { margin: 0 0 .75rem; }
.session-warning { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 300; max-width: min(36rem, calc(100vw - 2rem));
    background: #fff; border: 2px solid var(--warn); border-radius: 6px; padding: .8rem 1rem; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.session-warning p { margin: 0 0 .6rem; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }

/* top bar */
/* stays at the top of the window while the page scrolls */
.topbar { position: sticky; top: 0; z-index: 100; display: flex; align-items: center; gap: 1.25rem; padding: 0 1.25rem; background: #17324d; color: #fff; min-height: 48px; flex-wrap: wrap; }
.topbar .brand { color: #fff; font-weight: 700; white-space: nowrap; }
.topbar nav { display: flex; flex-wrap: wrap; gap: .1rem; flex: 1; }
.topbar nav a { color: #c9d6e3; padding: .8rem .55rem; }
.topbar nav a:hover, .topbar nav a.on { color: #fff; text-decoration: none; box-shadow: inset 0 -3px 0 #6fa8e8; }
.userbox { display: flex; align-items: center; gap: .5rem; margin: 0; }
.userbox .user { color: #c9d6e3; }
.userbox .link { color: #fff; background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }

main { max-width: 1280px; margin: 0 auto; padding: 1.25rem; }
main.wide { max-width: none; } /* pages that set "wide" (reports with many columns) */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.crumbs { color: var(--muted); margin-bottom: .5rem; font-size: .9rem; display: flex; flex-wrap: wrap; align-items: baseline; }
.crumbs > * + *::before { content: "\203A"; margin: 0 .45rem; color: var(--muted); text-decoration: none; display: inline-block; }
.crumbs [aria-current] { color: var(--text); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 1rem 1.25rem; margin-bottom: 1rem; }
.panel > h2 { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.panel > h2 .count { color: var(--muted); font-weight: normal; font-size: .9rem; }

/* messages */
.flash { background: var(--ok-bg); color: var(--ok); border: 1px solid #b6e0c4; padding: .6rem .9rem; border-radius: 6px; margin-bottom: 1rem; }
/* app.js floats the flash over the page (no layout shift, seen wherever the page is scrolled) */
.flash.toast { position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 150; margin: 0;
    max-width: min(640px, calc(100vw - 2rem)); box-shadow: 0 4px 16px rgba(0, 0, 0, .18); cursor: pointer;
    transition: opacity .35s ease, transform .35s ease; }
.flash.toast.toast-out { opacity: 0; transform: translate(-50%, -.5rem); }
@media (prefers-reduced-motion: reduce) { .flash.toast { transition: none; } }
.errors { background: var(--err-bg); color: var(--danger); border: 1px solid #f5c2bd; padding: .6rem .9rem; border-radius: 6px; margin-bottom: 1rem; }
.warnings { background: var(--warn-bg); color: var(--warn); border: 1px solid #f0d58c; padding: .6rem .9rem; border-radius: 6px; margin-bottom: 1rem; }
.errors ul, .warnings ul { margin: .3rem 0 .3rem 1.2rem; padding: 0; }

/* tables */
table.data { width: 100%; border-collapse: collapse; background: var(--panel); }
table.data th, table.data td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { background: #eef1f4; font-weight: 600; font-size: .85rem; color: #3e4c59; white-space: nowrap; }
table.data tr.inactive td { color: var(--muted); }
table.data tr:hover td { background: #fafbfc; }
table.data td.num { text-align: right; white-space: nowrap; }
table.data td.nowrap, .nowrap { white-space: nowrap; }
/* Wide reports that keep each row on one line scroll sideways inside the page. */
.table-scroll { overflow-x: auto; max-width: 100%; }
.table-scroll:focus-visible { outline-offset: 2px; }
.panel table.data { margin: 0 -.25rem; width: calc(100% + .5rem); }
.empty { color: var(--muted); font-style: italic; padding: .5rem 0; }

/* definition grid on view pages */
dl.props { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .6rem 1.5rem; margin: 0; }
dl.props div { min-width: 0; }
dl.props dt { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
dl.props dd { margin: 0; overflow-wrap: anywhere; }
.text-block { white-space: pre-wrap; background: #fafbfc; border: 1px solid var(--line); border-radius: 4px; padding: .6rem .8rem; margin: 0; }

/* forms */
form.card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 1.25rem; max-width: 980px; }
fieldset { border: 1px solid var(--line); border-radius: 6px; padding: .75rem 1rem 1rem; margin: 0 0 1rem; }
legend { font-weight: 600; padding: 0 .35rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem 1rem; }
.field { margin-bottom: .75rem; }
.grid .field { margin-bottom: 0; }
.field > label, .field > .label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .2rem; }
input[type=text], input:not([type]), input[type=email], input[type=search], input[type=date], input[type=number], input[type=password], select, textarea {
    width: 100%; padding: .42rem .55rem; border: 1px solid var(--field-line); border-radius: 4px; font: inherit; background: #fff; }
textarea { min-height: 7rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
label.check { display: inline-flex; align-items: center; gap: .35rem; font-weight: normal; margin-right: 1rem; }
.hint { color: var(--muted); font-size: .82rem; margin: .2rem 0 0; }
.form-actions { display: flex; gap: .5rem; align-items: center; margin-top: 1rem; }
.audit { color: var(--muted); font-size: .82rem; margin: .5rem 0 0; }

button, .button { display: inline-block; font: inherit; padding: .42rem .9rem; border-radius: 4px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; line-height: 1.3; }
button:hover, .button:hover { background: var(--accent-dark); text-decoration: none; }
.button.secondary, button.secondary { background: #fff; color: var(--accent); }
.button.secondary:hover, button.secondary:hover { background: #eef4fb; }
button.danger, .button.danger { background: #fff; color: var(--danger); border-color: #e3a7a1; }
button.danger:hover { background: var(--err-bg); }
button.small, .button.small { padding: .15rem .5rem; font-size: .82rem; }
button.small.danger { padding: .15rem .5rem; }
form.inline { display: inline; margin: 0; }

/* filter bar */
form.filters { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
form.filters input[type=search] { max-width: 340px; }
form.filters select, form.filters input[type=date] { width: auto; }

/* badges */
.badge { display: inline-block; font-size: .72rem; padding: .05rem .4rem; border-radius: 3px; background: #e3e8ee; color: #3e4c59; vertical-align: middle; margin-left: .25rem; }
.badge.off { background: #f1f1f1; color: #5f5f5f; }
.muted { color: var(--muted); }
.badge.flag { background: var(--err-bg); color: var(--danger); }
.badge.good { background: var(--ok-bg); color: var(--ok); }
.muted { color: var(--muted); }

/* home */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: .8rem 1rem; color: var(--text); }
.stat:hover { border-color: var(--accent); text-decoration: none; }
.stat .n { font-size: 1.7rem; font-weight: 700; display: block; }
.stat .l { color: var(--muted); font-size: .85rem; }

/* type-ahead picker */
.picker { position: relative; }
/* as wide as the suggestions need (one line each where they fit), never narrower than the box */
.picker-list { position: absolute; z-index: 10; left: 0; top: 100%; min-width: 100%; width: max-content; max-width: min(46rem, calc(100vw - 2.5rem));
    margin: 2px 0 0; padding: 0; list-style: none; background: #fff; border: 1px solid var(--field-line); border-radius: 4px; max-height: 280px; overflow: auto; box-shadow: 0 6px 18px rgba(0,0,0,.12); }
.picker-list li { padding: .4rem .6rem; cursor: pointer; }
.picker-list li:hover { background: #eef4fb; }
.picker-list li.sel { background: #eef4fb; box-shadow: inset 3px 0 0 var(--accent); }
.picker-list li.none { color: var(--muted); cursor: default; }
.picker.chosen .picker-text { background: #f2f8ff; }
.picker .picker-text { padding-right: 2rem; }
.picker-btn { position: absolute; top: 1px; right: 1px; height: calc(100% - 2px); width: 1.8rem; padding: 0; border: 0; border-left: 1px solid #e1e5ea; border-radius: 0 4px 4px 0; background: #f6f8fa; color: var(--muted); cursor: pointer; font-size: .9rem; }
.picker-btn:hover { background: #eef4fb; color: inherit; }

/* outcome checkboxes */
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .3rem 1rem; }
.choices.list { grid-template-columns: 1fr; }
.choices .other-choice { grid-column: 1 / -1; }
.choices .other-text { margin: .25rem 0 .5rem 1.6rem; }
.outcome-text { white-space: pre-line; overflow-wrap: anywhere; }
table.data td.wrap { white-space: normal; min-width: 18rem; max-width: 30rem; }
table.data td .cell-item + .cell-item { margin-top: .35rem; }
/* resizable columns on every data table (app.js, table.data) */
table.data th { position: relative; padding-right: 1rem; }
/* sortable headers (app.js): the title is a button that looks like plain header text */
table.data th .th-sort { background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer;
    text-align: left; white-space: inherit; line-height: inherit; }
table.data th .th-sort:hover { background: none; text-decoration: underline; }
table.data th .th-sort::after { content: "\2195"; margin-left: .3em; opacity: 0; font-size: .8em; }  /* faint up-down arrow on hover */
table.data th .th-sort:hover::after, table.data th .th-sort:focus-visible::after { opacity: .5; }
table.data th[aria-sort="ascending"] .th-sort::after { content: "\25B2"; opacity: 1; }
table.data th[aria-sort="descending"] .th-sort::after { content: "\25BC"; opacity: 1; }
.col-resize { position: absolute; top: 0; right: 0; width: 12px; height: 100%; cursor: col-resize; }
/* an always-visible grip (two short lines) on each column edge; the whole edge turns blue on hover / focus */
.col-resize::after { content: ""; position: absolute; right: 1px; top: 25%; width: 2px; height: 50%;
    border-left: 1px solid var(--field-line); border-right: 1px solid var(--field-line); }
.col-resize:hover, .col-resize:focus-visible { outline: none; background: rgba(31, 95, 168, .15); }
.col-resize:hover::after, .col-resize:focus-visible::after { top: 0; height: 100%; border-color: var(--accent); }
/* Review outcomes hold sentences: keep the column readable however wide the other columns get
   (until the user resizes columns by hand, which fixes every width) */
table.data .col-outcomes { min-width: 13rem; }
table.resized { table-layout: fixed; }
table.resized th, table.resized td, table.resized td > div { overflow: hidden; text-overflow: ellipsis; }
table.resized td.wrap { min-width: 0; max-width: none; }
body.col-resizing, body.col-resizing * { cursor: col-resize !important; user-select: none; }

/* history */
.history td.changes table { border-collapse: collapse; width: 100%; }
.history td.changes td { padding: .1rem .4rem; border: 0; font-size: .85rem; vertical-align: top; }
.history td.changes td.f { color: var(--muted); width: 26%; font-family: ui-monospace, monospace; }
.history .old, .history-legend .old { color: var(--danger); text-decoration: line-through; overflow-wrap: anywhere; }
.history .new, .history-legend .new { color: var(--ok); overflow-wrap: anywhere; }

/* login */
.login-wrap { max-width: 360px; margin: 10vh auto; }
.login-wrap h1 { text-align: center; margin-bottom: 1rem; }
[hidden] { display: none !important; }

/* report filter builder */
.filter-builder { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: .75rem; margin-bottom: 1rem; }
.filter-builder .f-row { display: flex; gap: .5rem; align-items: center; margin-bottom: .4rem; flex-wrap: wrap; }
.filter-builder .f-row select, .filter-builder .f-row input { width: auto; }
.filter-builder .f-join, .filter-builder .f-where { width: 4.5rem; }
.filter-builder .f-where { display: inline-block; color: var(--muted); }
.filter-builder .f-col { min-width: 13rem; }
.filter-builder .f-value input[type=text] { min-width: 16rem; }
.filter-builder .f-value { max-width: 100%; }
.filter-builder .f-value select { max-width: 100%; }
.filter-builder .f-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; }
.filter-builder .f-spacer { flex: 1; }
.filter-builder .hint { margin: .5rem 0 0; }
.result-count { color: var(--muted); margin: -.5rem 0 .5rem; }
tr.group-start td { border-top: 2px solid var(--line); }

/* toggle buttons that narrow a picker (ui:partyFilter) */
.picker-filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .35rem; }
.seg { display: inline-flex; border: 1px solid var(--field-line); border-radius: 4px; overflow: hidden; }
.seg button { border: 0; border-left: 1px solid var(--field-line); border-radius: 0; background: #fff; color: inherit; padding: .2rem .6rem; font-size: .85rem; cursor: pointer; }
.seg button:first-child { border-left: 0; }
.seg button:focus-visible { outline-offset: -3px; } /* .seg clips anything outside it */
.seg button:hover { background: #eef4fb; }
.seg button.on { background: var(--accent, #1f5fa8); color: #fff; }

/* chips: several picked records */
.chips .chip-list { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .35rem; }
.chips .chip-list:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: .3rem; background: #eef4fb; border: 1px solid #c9dcf1; border-radius: 999px; padding: .15rem .3rem .15rem .65rem; }
.chip .chip-x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 .25rem; }
.chip .chip-x:hover { color: var(--danger); }

/* IP page: protocol PIs who could be linked as inventors */
.pi-suggest { margin-top: 1rem; padding-top: .75rem; border-top: 1px solid var(--line); }
.pi-suggest h3 { margin-top: 0; font-size: .95rem; }
.pi-suggest ul { list-style: none; margin: 0; padding: 0; }
.pi-suggest li { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .25rem 0; }

/* "Recent" trail under the menu (header.jspf, RecentTrail) */
.recent { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin: -.5rem 0 .9rem; font-size: .85rem; }
.recent .recent-label { color: var(--muted); margin-right: .15rem; }
.recent .recent-item { max-width: 18rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    padding: .1rem .55rem; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); }
main .recent a.recent-item { text-decoration: none; }
main .recent a.recent-item:hover { border-color: var(--accent); }
.recent .recent-item[aria-current] { border-color: var(--field-line); font-weight: 600; }

/* quick search in the top bar */
.quick-search { width: 17rem; max-width: 40vw; }
.quick-search .picker-text { padding: .3rem .55rem; border-color: #8aa1b8; }
.quick-search .picker-list { left: auto; right: 0; color: var(--text); }
.topbar .quick-search :focus-visible { outline-color: #fff; }

/* jump links to the sections of a long page (app.js) */
.section-nav { position: sticky; top: 48px; z-index: 50; display: flex; flex-wrap: wrap; gap: .25rem .9rem; align-items: center;
    background: var(--bg); padding: .45rem 0; margin: -.25rem 0 .75rem; border-bottom: 1px solid var(--line); font-size: .88rem; }
.section-nav .section-nav-label { color: var(--muted); }
html.has-section-nav { scroll-padding-top: 100px; }

/* new IP form started from a protocol: which protocol it will be linked to */
.link-note { background: #eef4fb; border: 1px solid #c9dcf1; border-radius: 6px; padding: .6rem .9rem; }
.link-note p { margin: 0 0 .35rem; }
/* email and phone under a name (ui:contact) */
.contact-line { font-size: .85rem; }
/* IP page "Next step": one New review button per protocol */
.next-reviews { list-style: none; margin: .5rem 0 0; padding: 0; }
.next-reviews li { margin: 0 0 .5rem; }
