:root {
  --ink: #123a73;
  --paper: #f5f8f3;
  --accent: #d8ff58;
  --alert: #b92f1f;
  --muted: #56708f;
  --line: #c6d1cf;
  --white: #fff;
  --soft: #eaf0ed;
  --tool-purple: #5b21b6;
  --tool-lavender: #ddd6fe;
  --shadow: 0 18px 45px rgba(18, 58, 115, .12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 Inter, ui-sans-serif, system-ui, sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button:disabled {
  cursor: wait;
  opacity: .55;
}

a {
  color: inherit;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: 10px;
  transform: translateY(-160%);
  z-index: 10;
  background: var(--accent);
  padding: 9px;
}

.skip-link:focus {
  transform: none;
}

:focus-visible {
  outline: 3px solid var(--alert);
  outline-offset: 3px;
}

.topbar {
  min-height: 72px;
  padding: 12px max(20px, calc((100vw - 1180px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: var(--white);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  line-height: 1.05;
  text-decoration: none;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: block;
  flex: 0 0 auto;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 18px;
}

.brand small {
  margin-top: 4px;
  color: var(--tool-purple);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
}

.session {
  font-size: 13px;
  color: var(--muted);
}

.session-panel {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  min-width: 0;
}

.session-panel > div {
  display: grid;
  min-width: 0;
  text-align: right;
}

.session-panel strong,
.session-panel span {
  overflow-wrap: anywhere;
}

.session-panel span {
  color: var(--muted);
  font-size: 12px;
}

main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 56px 0 80px;
}

.signin {
  max-width: 620px;
  margin: 8vh auto;
}

.signin h1,
.intro h1 {
  font-size: clamp(42px, 6vw, 76px);
  line-height: .95;
  letter-spacing: -.055em;
  margin: 0 0 25px;
}

.signin > p:not(.eyebrow) {
  font-size: 19px;
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 13px;
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: 11px;
  font-weight: 900;
  color: var(--alert);
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 16px;
  border: 2px solid var(--ink);
  font-weight: 850;
  text-decoration: none;
  cursor: pointer;
}

.button.compact {
  min-height: 36px;
  padding: 6px 11px;
  font-size: 13px;
}

.primary,
.primary-action {
  background: var(--accent) !important;
}

.secondary {
  background: var(--white);
}

.intro {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 60px;
  align-items: end;
  margin-bottom: 45px;
}

.intro > p {
  color: var(--muted);
  font-size: 18px;
}

.tabs {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  border-bottom: 2px solid var(--ink);
  margin-bottom: 22px;
}

.tabs button {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  padding: 12px 16px;
  font-weight: 800;
  cursor: pointer;
}

.tabs button.active {
  background: var(--ink);
  color: var(--paper);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.notice {
  min-height: 26px;
  margin: 0 0 12px;
  font-weight: 750;
}

.notice.error {
  color: var(--alert);
}

.panel {
  padding: 26px;
  border: 1px solid var(--line);
  background: var(--white);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.panel h2 {
  margin: 0 0 20px;
  font-size: 26px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric-grid article {
  min-height: 145px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--line);
  background: var(--white);
}

.metric-grid span {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: -.04em;
}

.metric-grid strong {
  color: var(--muted);
}

.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.identity-card {
  box-shadow: none;
}

.identity-card dl {
  margin: 0;
}

.identity-card dl div {
  display: grid;
  grid-template-columns: 115px minmax(0, 1fr);
  gap: 14px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.identity-card dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.identity-card dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.method {
  box-shadow: none;
}

.method ol {
  margin: 0;
  padding-left: 24px;
}

.method li + li {
  margin-top: 9px;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.wide-form {
  max-width: 900px;
}

.form-heading,
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.form-heading > div,
.section-heading > div {
  min-width: 0;
}

label {
  display: block;
  font-weight: 750;
  margin: 0 0 16px;
}

input,
textarea,
select {
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border: 1px solid #879bad;
  border-radius: 0;
  background: #fff;
}

input[readonly],
textarea[readonly] {
  background: var(--soft);
  color: var(--muted);
}

textarea {
  min-height: 85px;
  resize: vertical;
}

.body-field {
  min-height: 220px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field-note,
.section-intro {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.field-note {
  margin-top: 6px;
}

.section-intro {
  margin: -12px 0 20px;
}

.checkbox-field {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
}

.checkbox-field input {
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
}

.story-picker {
  margin: 22px 0;
  padding: 16px;
  border: 1px solid var(--line);
  background: #fbfcfa;
}

.story-picker legend {
  padding: 0 7px;
  font-weight: 850;
}

.story-picker-empty {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.issue-event-row { border: 1px solid var(--line); background: var(--white); padding-bottom: 12px; }
.issue-event-row .story-picker-item { border: 0; }
.issue-event-position { display: grid; gap: 5px; margin: 0 12px; font-size: 13px; }
.issue-event-position select { width: 100%; min-width: 0; }
.issue-event-invalid { border-color: #9d320e; }
.issue-event-warning { margin: 10px 12px 0; color: #9d320e; font-size: 13px; }

.story-picker-list {
  display: grid;
  gap: 8px;
}

.story-picker-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 11px;
  align-items: start;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--white);
  cursor: pointer;
}

.story-picker-item:has(input:checked) {
  border-color: var(--ink);
  box-shadow: inset 4px 0 var(--accent);
}

.story-picker-item input {
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
}

.story-picker-copy {
  min-width: 0;
}

.story-picker-copy strong,
.story-picker-copy small {
  display: block;
}

.story-picker-copy strong {
  overflow-wrap: anywhere;
}

.story-picker-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.permission-note {
  border-left: 6px solid var(--accent);
  box-shadow: none;
  font-weight: 700;
}

.correction-panel {
  border-top: 7px solid var(--accent);
}

.record-list {
  display: grid;
  gap: 10px;
}

.record-group-heading {
  margin: 28px 0 4px;
  padding-bottom: 9px;
  border-bottom: 3px solid var(--tool-purple);
  font-size: 18px;
}

.record-group-heading:first-child {
  margin-top: 0;
}

.record {
  padding: 16px;
  border: 1px solid var(--line);
  background: #fbfcfa;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.record h3 {
  margin: 0 0 4px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.record p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.record .record-detail {
  margin-top: 6px;
}

.record-warning {
  margin: 8px 0 0;
  color: #9d320e;
  font-weight: 700;
}

.record-title-preview {
  margin: 0 0 5px;
}

.record-title-preview > summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  list-style: none;
  cursor: pointer;
}

.record-title-preview > summary::-webkit-details-marker {
  display: none;
}

.record-title-heading {
  font-size: 18px;
  font-weight: 850;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.record-title-line {
  display: flex;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}

.record-preview-cue {
  flex: 0 0 auto;
  padding: 4px 7px;
  border: 1px solid var(--ink);
  background: var(--white);
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.record-title-preview[open] .record-preview-cue {
  background: var(--ink);
  color: var(--paper);
}

.record-title-preview > summary:hover .record-title-heading {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.story-preview {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.story-preview summary {
  display: inline-block;
  padding: 6px 9px;
  border: 1px solid var(--ink);
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
}

.story-preview-content {
  margin-top: 12px;
  padding: 14px;
  border-left: 4px solid var(--accent);
  background: var(--soft);
}

.story-preview-content h4 {
  margin: 14px 0 5px;
  color: var(--ink);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.story-preview-content h4:first-child {
  margin-top: 0;
}

.story-preview-content p,
.story-preview-content li {
  white-space: pre-wrap;
}

.story-preview-deck {
  color: var(--ink) !important;
  font-weight: 750;
}

.story-preview-content ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

.story-preview-content a {
  color: var(--ink);
  font-weight: 750;
}

.record-preview-content {
  margin-bottom: 10px;
}

.record-preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 22px;
  margin: 0;
}

.record-preview-grid > div {
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.record-preview-grid dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.record-preview-grid dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}

.record-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.record-preview-sources {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.record-preview-sources li {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.record-preview-sources small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.badge {
  display: inline-block;
  margin-right: 8px;
  padding: 3px 7px;
  background: var(--soft);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.record-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
}

.record-actions:empty {
  display: none;
}

.record-actions button {
  border: 1px solid var(--ink);
  background: var(--white);
  padding: 7px 9px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

details {
  margin-top: 10px;
}

details summary {
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

details p {
  margin-top: 8px !important;
  white-space: pre-wrap;
}

.audit-record {
  align-items: start;
}

.audit-record pre {
  max-width: 100%;
  overflow-x: auto;
  padding: 12px;
  background: #edf2ef;
  color: #21344b;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

footer {
  padding: 25px max(20px, calc((100vw - 1180px) / 2));
  display: flex;
  justify-content: space-between;
  gap: 20px;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .session-panel {
    width: 100%;
    justify-content: space-between;
    border-top: 1px solid var(--line);
    padding-top: 10px;
  }

  .session-panel > div {
    text-align: left;
  }

  main {
    width: min(100% - 26px, 1180px);
    padding-top: 38px;
  }

  .intro,
  .two-column,
  .form-grid,
  .overview-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }

  .record {
    grid-template-columns: 1fr;
  }

  .record-actions {
    justify-content: flex-start;
  }

  .record-preview-grid {
    grid-template-columns: 1fr;
  }

  .record-title-preview > summary {
    display: grid;
  }

  .record-preview-cue {
    justify-self: start;
  }
}

@media (max-width: 430px) {
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .signin h1,
  .intro h1 {
    font-size: 44px;
  }

  .tabs button {
    padding-inline: 11px;
  }

  .form-heading,
  .section-heading {
    display: grid;
  }

  footer {
    flex-direction: column;
  }
}
