:root {
  color-scheme: dark;
  --background: #0a0d14;
  --surface: #111925;
  --surface-raised: #172234;
  --border: #33435c;
  --text: #f2f5f9;
  --muted: #bac7d8;
  --gold: #e5bd76;
  --blue: #a6ccff;
  --danger: #ffc0b9;
  font-family: system-ui, sans-serif;
  line-height: 1.55;
  background: var(--background);
  color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: radial-gradient(ellipse at 90% 5%, #142440, transparent 36rem), var(--background); }
a { color: var(--blue); }
a:hover { color: var(--gold); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .7; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3 { line-height: 1.2; }
h1 { font-size: clamp(1.9rem, 4vw, 3rem); letter-spacing: -.043em; }
h2 { font-size: 1.32rem; }
h3 { font-size: 1.1rem; }
.portal-shell { width: min(72rem, calc(100% - 3rem)); margin-inline: auto; }
.portal-header { background: #0b0e15; border-bottom: 1px solid var(--border); }
.header-inner, .header-tools, .header-actions, .actions, .heading-row, .item-heading { display: flex; align-items: center; gap: .7rem 1rem; }
.header-inner { position: relative; justify-content: space-between; min-height: 4.5rem; padding-block: .6rem; }
.header-tools { gap: .6rem; min-width: 0; }
.header-actions { justify-content: end; flex-wrap: wrap; }
.header-actions a { font-weight: 650; text-decoration: none; }
.review-notifications { flex: 0 0 auto; }
.button.notification-toggle { position: relative; min-width: 2.55rem; padding: .5rem; }
.notification-toggle[data-new='true'] { color: var(--gold); border-color: var(--gold); }
.notification-count { position: absolute; inset-block-start: -.36rem; inset-inline-end: -.38rem; min-width: 1.25rem; height: 1.25rem; padding-inline: .23rem; border-radius: 2rem; background: var(--gold); color: #21190d; font-size: .7rem; line-height: 1.25rem; text-align: center; }
.notification-panel { position: absolute; z-index: 3; inset-block-start: calc(100% - .2rem); inset-inline-end: 0; width: min(25rem, 100%); max-height: min(28rem, 72dvh); overflow: auto; padding: 1rem; background: var(--surface-raised); border: 1px solid var(--border); box-shadow: 0 .65rem 2rem #080b11b3; }
.notification-panel h2 { margin-bottom: .55rem; font-size: 1.1rem; }
.notification-retry { margin-block: .5rem; }
.notification-list { list-style: none; margin: 0; padding: 0; }
.notification-list li + li { border-top: 1px solid var(--border); }
.notification-list a { display: block; padding: .62rem .3rem; text-decoration: none; overflow-wrap: anywhere; }
.notification-list a span { display: block; }
.notification-list a:hover strong { text-decoration: underline; }
.brand { display: inline-flex; flex: 0 0 auto; align-items: center; gap: .7rem; color: var(--text); font-weight: 800; font-size: 1.25rem; line-height: 1; letter-spacing: .075em; text-decoration: none; }
.brand small { display: block; margin-top: .34rem; color: var(--gold); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; }
.brand-mark { width: 2.45rem; height: 2.45rem; display: grid; place-items: center; border: 1px solid #8b7048; color: var(--gold); font-family: Georgia, serif; font-size: 1.45rem; }
.skip-link { position: absolute; z-index: 1; left: .7rem; top: .7rem; padding: .7rem; background: var(--gold); color: #171108; transform: translateY(-160%); }
.skip-link:focus { transform: none; }
main { flex: 1; padding-block: clamp(1.5rem, 4.2vw, 3.5rem); }
.portal-footer { margin-top: 1.5rem; border-top: 1px solid var(--border); color: var(--muted); padding-block: 1.5rem; font-size: .875rem; }
.muted, small { color: var(--muted); }
.eyebrow { color: var(--gold); text-transform: uppercase; font-size: .875rem; font-weight: 750; letter-spacing: .095em; }
.identity { color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.loading, .empty { padding: 1rem; border: 1px dashed var(--border); color: var(--muted); }
.live-message { padding: .8rem 1rem; background: #142a29; border: 1px solid #3c7770; margin-bottom: 1.1rem; overflow-wrap: anywhere; }
.live-message.error { background: #371e24; border-color: #985c61; color: #ffdad6; }
.auth-layout { display: grid; grid-template-columns: .95fr 1.05fr; align-items: start; gap: clamp(2rem, 7vw, 6rem); margin: clamp(.75rem, 4vw, 3rem) auto 1.5rem; max-width: 62rem; }
.auth-intro { padding-top: clamp(1rem, 4vw, 2.8rem); }
.auth-intro h1 { margin-block: .5rem .9rem; }
.auth-intro p:not(.eyebrow) { max-width: 30rem; }
.auth-badge { width: min(22rem, 95%); aspect-ratio: 589 / 404; margin-top: 1.6rem; overflow: hidden; mix-blend-mode: screen; }
.auth-badge img { width: 100%; height: auto; display: block; transform: translateY(-34.35%); }
.panel, .stat, .record, details.record { min-width: 0; background: var(--surface); border: 1px solid var(--border); }
.panel { padding: clamp(1rem, 3vw, 1.5rem); }
.panel > h2, .panel > p + form { margin-bottom: .8rem; }
.auth-tabs, .portal-nav { display: flex; gap: .35rem; flex-wrap: wrap; }
.auth-tabs { border-bottom: 1px solid var(--border); margin-bottom: 1.2rem; }
.auth-tabs a, .portal-nav a {
  color: var(--muted); text-decoration: none; font-weight: 700; padding: .55rem .75rem; border: 1px solid transparent;
}
.auth-tabs a[aria-current='page'], .portal-nav a[aria-current='page'] { background: #2b2418; border-color: #785f3a; color: #f9d9a1; }
.auth-tabs a:hover, .portal-nav a:hover { color: var(--gold); }
.page-heading { display: flex; align-items: end; gap: 1.1rem; justify-content: space-between; margin-bottom: 1.3rem; }
.page-heading h1 { margin-block: .38rem; overflow-wrap: anywhere; }
.portal-nav { border-bottom: 1px solid var(--border); padding-bottom: .65rem; margin-bottom: 1.5rem; }
.portal-heading { margin-bottom: 1rem; }
.portal-heading p { color: var(--muted); margin-top: .4rem; }
.layout { display: grid; grid-template-columns: minmax(0, 1.43fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.stack, form { display: grid; gap: .85rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem; margin-bottom: 1rem; }
.stat { display: grid; gap: .18rem; padding: 1rem; }
.stat strong { color: var(--gold); font-size: 1.85rem; line-height: 1; }
.stat span { color: var(--muted); }
.label, form label:not(.inline-label) { display: grid; gap: .35rem; font-weight: 650; min-width: 0; }
input, textarea, select { width: 100%; min-width: 0; padding: .62rem .67rem; border: 1px solid #516682; border-radius: 0; background: #0b121e; color: var(--text); }
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #9eafc7; }
input[type='file'] { color: var(--muted); }
input[type='file']::file-selector-button { border: 0; background: var(--surface-raised); color: var(--text); font: inherit; padding: .3rem .5rem; margin-right: .65rem; }
fieldset { min-width: 0; margin: 0; padding: .75rem; border: 1px solid var(--border); }
legend { font-weight: 700; color: var(--muted); padding-inline: .25rem; }
.actions { flex-wrap: wrap; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 2.55rem; padding: .55rem .85rem; border: 1px solid #647995; border-radius: 0; background: var(--surface-raised); color: var(--text); font-weight: 700; text-decoration: none; }
.button:hover { color: var(--gold); border-color: var(--gold); }
.primary { background: var(--gold); color: #21190d; border-color: var(--gold); }
.primary:hover { background: #f8d8a1; color: #21190d; }
.danger { color: var(--danger); }
.record { padding: .85rem 1rem; }
.record p + p { margin-top: .5rem; }
.record-body { border-top: 1px solid var(--border); margin-top: .8rem; padding-top: .8rem; }
.record > summary { cursor: pointer; }
.record > summary::marker { color: var(--gold); }
.record > summary .status { margin-left: .5rem; margin-bottom: .15rem; }
.item-heading, .heading-row { justify-content: space-between; flex-wrap: wrap; }
.item-heading { align-items: start; }
.status { display: inline-block; padding: .15rem .42rem; color: var(--blue); background: #192943; border: 1px solid #466087; font-size: .82rem; font-weight: 650; }
.status[data-status='returned'] { color: #ffd4bc; background: #34221b; border-color: #86604d; }
.status[data-status='approved'], .status[data-status='signed'], .status[data-status='filed'] { color: #bce6d3; background: #142a29; border-color: #3c7770; }
.record dl, dl.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .48rem .8rem; }
.record dt { color: var(--muted); font-size: .87rem; }
.field-note { color: var(--muted); font-size: .875rem; font-weight: 400; }
.rating-field { display: grid; gap: .25rem; }
.observation-rating-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); align-items: start; gap: .75rem; }
.observation-rating-row + .observation-rating-row { border-top: 1px solid var(--border); padding-top: .75rem; }
.rating-explanation { margin-top: .25rem; }
.rating-note-label { display: block; }
.rating-scale dd { color: var(--muted); }
.text-block { white-space: pre-wrap; overflow-wrap: anywhere; }
.wrap { overflow-wrap: anywhere; }
.ratings-list li + li { margin-top: .2rem; }
.upload-link { color: var(--blue); overflow-wrap: anywhere; }
.invite-output { margin-top: 1rem; }

@media (max-width: 760px) {
  .portal-shell { width: calc(100% - 2rem); }
  .auth-layout, .layout { grid-template-columns: 1fr; }
  .auth-intro { padding-top: 0; }
  .auth-badge { display: none; }
  .page-heading { align-items: start; flex-direction: column; }
}

@media (max-width: 650px) {
  .observation-rating-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stats, .grid-2 { grid-template-columns: 1fr; }
  .record dl, dl.facts { grid-template-columns: 1fr; }
  .identity { display: none; }
  .header-inner { gap: .55rem; }
  .header-tools { gap: .45rem; }
  .header-actions a { font-size: .85rem; }
  .portal-nav a { padding-inline: .52rem; }
}
