:root {
  color-scheme: light;
  --page: #f4f0e8;
  --page-rgb: 244, 240, 232;
  --text: #20201e;
  --muted: #6d6b65;
  --faint: #aaa69c;
  --line: #d7d1c5;
  --line-strong: #b8b1a5;
  --control: #fbf8f1;
  --overlay: rgba(23, 22, 19, .42);
  --accent: #994d34;
  --danger: #a12f34;
  --success: #35694f;
  --code: #ebe5da;
  --selection: #e2c9b7;
  --shade: .76;
  --content: 1180px;
  --reading: 820px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #171715;
  --page-rgb: 23, 23, 21;
  --text: #e6e2d9;
  --muted: #a5a097;
  --faint: #716d66;
  --line: #35332f;
  --line-strong: #555149;
  --control: #1d1d1a;
  --overlay: rgba(0, 0, 0, .66);
  --accent: #d58a68;
  --danger: #eb8384;
  --success: #88b89b;
  --code: #21211e;
  --selection: #583d32;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: InterVariable, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-optical-sizing: auto;
  font-size: 17px;
  line-height: 1.65;
  transition: background-color .15s ease, color .15s ease;
}
::selection { background: var(--selection); }
button, input, select, textarea { color: inherit; font: inherit; }
button, select { cursor: pointer; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
.hidden { display: none !important; }
.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; }
.quiet { color: var(--muted); }
.error { min-height: 1.65em; color: var(--danger); }

#background {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}
#background-shade {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: rgba(var(--page-rgb), var(--shade));
  transition: background-color .15s ease;
}

.site {
  width: min(calc(100% - 40px), var(--content));
  margin: 0 auto;
  padding: 38px 0 80px;
}
.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 38px;
}
.wordmark {
  color: var(--text);
  font-weight: 700;
  letter-spacing: -.04em;
  text-decoration: none;
}
.site-header nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px 20px; }
.link-button {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.link-button:hover { text-decoration-thickness: 2px; }
.link-button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin: 8px 0 24px; }
.page-heading h1 { margin: 0; font-size: clamp(25px, 4vw, 34px); line-height: 1.2; letter-spacing: -.05em; }
.page-heading p { margin: 8px 0 0; font-size: 13px; }

.portfolio-summary {
  display: grid;
  grid-template-columns: minmax(145px, .6fr) minmax(130px, .5fr) minmax(360px, 1.8fr);
  margin: 0 0 24px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--control) 82%, transparent);
}
.summary-metric, .severity-summary { min-width: 0; padding: 15px 18px; }
.summary-metric {
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--line);
}
.summary-value { font-size: 25px; line-height: 1.15; letter-spacing: -.045em; }
.summary-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  line-height: 1.4;
  text-transform: uppercase;
}
.summary-metric .summary-label { margin-top: 4px; }
.severity-summary { display: grid; align-content: center; gap: 7px; }
.severity-bar {
  display: flex;
  width: 100%;
  height: 8px;
  overflow: hidden;
  background: var(--code);
}
.severity-segment { min-width: 6px; background: var(--severity-color); }
.severity-empty { width: 100%; background: var(--line); }
.severity-legend { display: flex; flex-wrap: wrap; gap: 2px 14px; min-height: 17px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.severity-key { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.severity-dot { width: 7px; height: 7px; background: var(--severity-color); }
.severity-none { color: var(--faint); }

.filters {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) repeat(5, minmax(115px, auto)) 39px;
  gap: 9px;
  padding: 0 0 26px;
  border-bottom: 1px solid var(--line);
}
.filters label { min-width: 0; }
.filters input, .filters select,
.auth-form input, .dialog input, .dialog select, .dialog textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--control);
  padding: 8px 10px;
  outline: none;
}
.filters input:focus, .filters select:focus,
.auth-form input:focus, .dialog input:focus, .dialog select:focus, .dialog textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.filters select { max-width: 180px; }
.multi-filter { position: relative; width: 180px; min-width: 180px; height: 39px; align-self: start; }
.multi-filter summary {
  position: relative;
  width: 100%;
  height: 39px;
  min-height: 39px;
  padding: 8px 30px 8px 10px;
  line-height: 21px;
  border: 1px solid var(--line-strong);
  background: var(--control);
  list-style: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.multi-filter summary::-webkit-details-marker { display: none; }
.multi-filter summary::after { content: "⌄"; position: absolute; right: 10px; color: var(--muted); }
.multi-filter[open] summary { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.multi-options {
  position: absolute;
  z-index: 30;
  top: calc(100% + 5px);
  left: 0;
  width: max(100%, 210px);
  padding: 8px;
  border: 1px solid var(--line-strong);
  background: var(--page);
  box-shadow: 0 12px 35px rgba(0, 0, 0, .18);
}
.multi-option { display: flex; align-items: center; gap: 9px; padding: 6px 4px; color: var(--text); white-space: nowrap; cursor: pointer; }
.multi-option input { width: 16px; height: 16px; margin: 0; accent-color: var(--option-color, var(--accent)); }
.multi-clear { width: 100%; margin-top: 5px; padding: 7px 4px; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--accent); text-align: left; }
.filters .visibility-filter {
  display: inline-grid;
  width: 39px;
  height: 39px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line-strong);
  background: var(--control);
  color: var(--muted);
  cursor: pointer;
}
.filters .visibility-filter:hover { color: var(--text); border-color: var(--accent); }
.filters .visibility-filter:focus-visible { color: var(--text); border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); outline: none; }
.filters .visibility-filter[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--control)); }
.filters .visibility-filter svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.finding-list { padding-top: 28px; }
.finding-date-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 16px;
  color: var(--faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1;
  letter-spacing: .05em;
  pointer-events: none;
  user-select: none;
}
.finding-date-divider:not(:first-child) { margin-top: 6px; }
.finding-date-divider::before, .finding-date-divider::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--line);
}
.finding-date-label { flex: 0 0 auto; }
.finding-row {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: baseline;
  gap: 0 8px;
  min-width: 0;
  margin: 0 0 18px;
  padding: 0;
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
}
.finding-row::before { content: ""; position: absolute; inset: -6px -8px; z-index: -1; background: transparent; }
.finding-row:hover::before, .finding-row:focus-within::before { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.finding-row.drag-target::before { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.finding-row.dragging { opacity: .35; }
.finding-row.is-hidden { opacity: .68; }
.finding-row a {
  min-width: 0;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  text-overflow: ellipsis;
}
.finding-ref { color: var(--accent); font-weight: 700; }
.finding-title { font-weight: 500; }
.finding-meta { display: inline-flex; align-items: baseline; gap: 8px; color: var(--muted); font-size: 15px; white-space: nowrap; }
.finding-program {
  display: inline-block;
  max-width: 145px;
  padding: 0 5px;
  overflow: hidden;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
  text-overflow: ellipsis;
  vertical-align: -.25em;
  white-space: nowrap;
}
.finding-tag { color: color-mix(in srgb, var(--tag-color, var(--muted)) 76%, var(--text)); font-weight: 550; }
.tag-payout { color: #2e704f; }
:root[data-theme="dark"] .tag-payout { color: #7fcf9a; }
.tag-payout.tag-empty, :root[data-theme="dark"] .tag-payout.tag-empty { color: var(--muted); }
.tag-hidden { color: var(--muted); }
.finding-chain { color: var(--accent); font-size: 14px; white-space: nowrap; }
.finding-indent { flex: 0 0 auto; width: calc(var(--depth, 0) * 24px); }
.finding-indent[style*="--depth: 0"] { width: 0; }
.finding-row[data-depth]:not([data-depth="0"]) .finding-indent { position: relative; }
.finding-row[data-depth]:not([data-depth="0"]) .finding-indent::after { content: "↳"; position: absolute; right: 7px; color: var(--faint); }
.empty { margin: 20px 0; color: var(--muted); }

.status-dropbar {
  position: sticky;
  top: 8px;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 18px 0 -4px;
  padding: 10px;
  border: 1px solid var(--line-strong);
  background: var(--page);
}
.status-drop {
  flex: 1 1 110px;
  padding: 5px 8px;
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--muted);
  text-align: center;
}
.status-drop.over { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent); }

.report-page {
  --report-gutter-width: calc((100vw - var(--reading)) / 2);
  position: relative;
  width: min(100%, var(--reading));
  margin: 0 auto;
}
.report-gutter {
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--report-gutter-width);
  padding: 0;
  border: 0;
  background: transparent;
}
.report-gutter-left { right: 100%; }
.report-gutter-right { left: 100%; }
.report-gutter:focus { outline: none; }
.back-link { display: inline-block; margin-bottom: 34px; }
.report-header { padding-bottom: 25px; border-bottom: 1px solid var(--line); }
.report-ref { margin: 0 0 8px; color: var(--accent); font-size: 13px; font-weight: 700; }
.report-header h1 { margin: 0; font-size: clamp(27px, 5vw, 42px); line-height: 1.2; letter-spacing: -.05em; }
.report-meta { margin: 14px 0 0; color: var(--muted); font-size: 13px; }
.report-actions { display: flex; gap: 20px; margin-top: 18px; }
.markdown { padding: 32px 0 38px; font-family: inherit; font-size: 19px; line-height: 1.78; overflow-wrap: anywhere; }
.markdown > :first-child:not(.md-outline) { margin-top: 0; }
.markdown p { margin: 1.05em 0; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4, .markdown h5, .markdown h6 { position: relative; font-family: inherit; line-height: 1.3; letter-spacing: -.035em; scroll-margin-top: 18px; }
.markdown h1 { margin: 1.7em 0 .65em; font-size: 31px; }
.markdown h2 { margin: 1.8em 0 .6em; padding-bottom: .3em; border-bottom: 1px solid var(--line); font-size: 25px; }
.markdown h3 { margin: 1.6em 0 .5em; font-size: 20px; }
.markdown h4, .markdown h5, .markdown h6 { margin: 1.5em 0 .45em; font-size: 17px; }
.markdown .heading-anchor { position: absolute; right: 100%; padding-right: 10px; opacity: 0; text-decoration: none; }
.markdown :is(h1,h2,h3,h4):hover .heading-anchor { opacity: 1; }
.markdown a { overflow-wrap: anywhere; }
.markdown ul, .markdown ol { padding-left: 1.5em; }
.markdown li { margin: .35em 0; }
.markdown li::marker { color: var(--accent); }
.markdown blockquote { margin: 1.5em 0; padding: .15em 0 .15em 20px; border-left: 3px solid var(--line-strong); color: var(--muted); }
.markdown blockquote > :first-child, .markdown .callout > :first-child { margin-top: 0; }
.markdown blockquote > :last-child, .markdown .callout > :last-child { margin-bottom: 0; }
.markdown code { padding: .12em .34em; background: var(--code); font: .86em ui-monospace, "SFMono-Regular", Consolas, monospace; }
.markdown .code-block { margin: 1.5em 0; border: 1px solid var(--line); background: var(--code); }
.markdown .code-head { display: flex; justify-content: space-between; padding: 7px 11px; border-bottom: 1px solid var(--line); color: var(--muted); font: 12px ui-monospace, monospace; text-transform: uppercase; }
.markdown .code-head button { border: 0; background: transparent; color: var(--accent); font: inherit; text-transform: none; }
.markdown pre { margin: 0; padding: 16px 18px; overflow: auto; line-height: 1.55; }
.markdown pre code { padding: 0; background: transparent; color: inherit; }
.markdown .tok-keyword { color: #b44e84; }
.markdown .tok-string { color: #4c7c55; }
.markdown .tok-number { color: #9e6128; }
.markdown .tok-comment { color: var(--muted); font-style: italic; }
.markdown .tok-attr { color: #39799a; }
:root[data-theme="dark"] .markdown .tok-keyword { color: #e889ba; }
:root[data-theme="dark"] .markdown .tok-string { color: #9bc994; }
:root[data-theme="dark"] .markdown .tok-number { color: #e5ae75; }
:root[data-theme="dark"] .markdown .tok-attr { color: #86bfd8; }
.markdown .table-scroll { margin: 1.5em 0; overflow-x: auto; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }
.markdown table { width: 100%; min-width: 520px; border-collapse: collapse; font-size: 14px; }
.markdown th, .markdown td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.markdown th { color: var(--accent); }
.markdown tr:last-child td { border-bottom: 0; }
.markdown hr { height: 1px; margin: 2em 0; border: 0; background: var(--line); }
.markdown .callout { margin: 1.5em 0; padding: 14px 18px; border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.markdown .callout-title { margin-bottom: 5px; color: var(--accent); font: 700 12px InterVariable, Inter, ui-sans-serif, sans-serif; text-transform: uppercase; }
.markdown .md-image-link { font-family: ui-monospace, monospace; font-size: .85em; }
.markdown .task-item { display: flex; gap: 9px; list-style: none; }
.markdown .task-item input { margin-top: .55em; accent-color: var(--accent); }
.md-outline { margin: 0 0 30px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.md-outline summary { padding: 9px 0; cursor: pointer; font: 14px InterVariable, Inter, ui-sans-serif, sans-serif; color: var(--muted); }
.md-outline summary span { float: right; }
.md-outline nav { display: grid; gap: 4px; padding: 0 0 12px; }
.md-outline nav a { font: 13px InterVariable, Inter, ui-sans-serif, sans-serif; }
.md-outline nav .level-2 { padding-left: 18px; }
.md-outline nav .level-3 { padding-left: 36px; }

.report-links { padding-top: 24px; border-top: 1px solid var(--line); }
.report-links h2 { margin: 0 0 14px; font-size: 16px; }
.report-link { margin: 8px 0; font-size: 13px; }

.auth { width: min(calc(100% - 40px), 440px); margin: 0 auto; padding: 12vh 0 60px; }
.auth-form h1 { margin: 50px 0 5px; font-size: 28px; letter-spacing: -.05em; }
.auth-form > p { margin: 0 0 28px; color: var(--muted); }
.auth-form label { display: block; margin: 17px 0; color: var(--muted); font-size: 13px; }
.auth-form input { margin-top: 6px; color: var(--text); }
.auth-form button, .dialog .primary {
  padding: 8px 13px;
  border: 1px solid var(--text);
  border-radius: 0;
  background: var(--text);
  color: var(--page);
}

.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: var(--overlay); }
.dialog { width: min(760px, 100%); max-height: 92vh; overflow: auto; padding: 26px; border: 1px solid var(--line-strong); background: var(--page); box-shadow: 0 20px 70px rgba(0, 0, 0, .28); }
.dialog.wide { width: min(960px, 100%); }
.dialog-header { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-size: 21px; letter-spacing: -.04em; }
.dialog-close { border: 0; padding: 0; background: transparent; color: var(--accent); text-decoration: underline; }
.dialog form { margin-top: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.dialog label { display: block; color: var(--muted); font-size: 12px; }
.dialog input, .dialog select, .dialog textarea { margin-top: 5px; color: var(--text); }
.dialog textarea { min-height: 340px; resize: vertical; line-height: 1.5; tab-size: 2; }
.dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-top: 20px; }
.dialog-actions > div { display: flex; gap: 16px; }
.danger-link { color: var(--danger); }

.settings-section { padding: 22px 0; border-bottom: 1px solid var(--line); }
.settings-section:last-child { border-bottom: 0; }
.settings-section h3 { margin: 0 0 13px; font-size: 15px; }
.settings-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: end; }
.settings-row + .settings-row { margin-top: 14px; }
.settings-section button:not(.link-button):not(.primary) { padding: 7px 10px; border: 1px solid var(--line-strong); background: transparent; }
.option-kind { display: flex; flex-wrap: wrap; gap: 13px; margin-bottom: 14px; }
.option-list { display: grid; gap: 7px; }
.option-row { display: grid; grid-template-columns: 28px minmax(120px, 1fr) auto auto; gap: 8px; align-items: center; }
.option-row input { margin: 0; }
.option-row input[type="color"] { width: 28px; height: 28px; padding: 0; border: 0; }
.token { padding: 8px 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.program-list { display: grid; gap: 7px; }
.program-row { display: flex; justify-content: space-between; gap: 15px; }
.program-row span { color: var(--muted); }

.context-menu { position: fixed; z-index: 80; min-width: 240px; max-width: min(340px, calc(100vw - 20px)); max-height: 75vh; overflow: auto; padding: 5px 0; border: 1px solid var(--line-strong); background: var(--page); box-shadow: 0 14px 40px rgba(0, 0, 0, .24); font-size: 13px; }
.menu-heading { padding: 7px 12px; border-bottom: 1px solid var(--line); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-heading.back { color: var(--accent); cursor: pointer; }
.menu-item { display: flex; width: 100%; justify-content: space-between; gap: 20px; padding: 7px 12px; border: 0; background: transparent; color: var(--text); text-align: left; }
.menu-item:hover, .menu-item:focus { background: color-mix(in srgb, var(--accent) 10%, transparent); outline: 0; }
.menu-item span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item.danger { color: var(--danger); }
.menu-separator { height: 1px; margin: 5px 0; background: var(--line); }
.menu-search { width: calc(100% - 20px); margin: 8px 10px; padding: 6px 8px; border: 1px solid var(--line-strong); background: var(--control); }

.toast { position: fixed; right: 20px; bottom: 20px; z-index: 100; max-width: min(380px, calc(100vw - 40px)); padding: 9px 13px; border: 1px solid var(--line-strong); background: var(--page); box-shadow: 0 10px 30px rgba(0, 0, 0, .18); }
.toast.bad { border-color: var(--danger); color: var(--danger); }

@media (max-width: 940px) {
  .portfolio-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-metric:nth-child(2) { border-right: 0; }
  .severity-summary { grid-column: 1 / -1; border-top: 1px solid var(--line); }
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filters .search-field { grid-column: 1 / -1; }
  .filters select { max-width: none; }
  .multi-filter { width: 100%; min-width: 0; }
  .filters .visibility-filter { justify-self: start; }
  .report-gutter { display: none; }
}

@media (max-width: 680px) {
  .site { width: min(calc(100% - 28px), var(--content)); padding-top: 24px; }
  .site-header { align-items: flex-start; padding-bottom: 30px; }
  .site-header nav { gap: 5px 13px; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .finding-row { grid-template-columns: auto minmax(0, 1fr); align-items: flex-start; white-space: normal; }
  .finding-row a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .finding-meta { grid-column: 2; display: flex; flex-wrap: wrap; margin-top: 2px; white-space: normal; }
  .finding-program { max-width: min(210px, 100%); }
  .finding-chain { grid-column: 2; display: inline; }
  .form-grid, .settings-row { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .dialog { padding: 20px; }
  .option-row { grid-template-columns: 28px minmax(100px, 1fr) auto; }
  .option-row .set-default { display: none; }
  .markdown { font-size: 18px; }
}

@media (max-width: 440px) {
  .site-header { display: block; }
  .site-header nav { justify-content: flex-start; margin-top: 15px; }
  .filters { grid-template-columns: 1fr; }
  .filters .search-field { grid-column: auto; }
  .report-actions { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
