:root {
  color-scheme: light;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-soft: #f1f1ef;
  --line: #e2e1dc;
  --line-strong: #c9c7c0;
  --text: #20201d;
  --muted: #6f6d66;
  --accent: #0a7a5f;
  --accent-soft: #e8f4ef;
  --danger: #b42318;
  --danger-soft: #fff0ed;
  --shadow: 0 12px 30px rgba(32, 32, 29, 0.06);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  color: var(--text);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  stroke-width: 2;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 24px;
  align-items: center;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 247, 245, 0.94);
}

.brand,
.topbar nav,
.account,
.actions,
.form-actions,
.filter-actions,
.chip-row,
.hero-badges {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  font-weight: 760;
}

.brand:hover,
.case-card:hover {
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--text);
  color: #fff;
  font-size: 12px;
}

.brand-mark .icon {
  width: 18px;
  height: 18px;
}

.topbar nav {
  flex-wrap: wrap;
}

.topbar nav a,
.account a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 14px;
}

.topbar nav a:hover,
.account a:hover {
  background: var(--surface-soft);
  color: var(--text);
  text-decoration: none;
}

.account {
  color: var(--muted);
  font-size: 14px;
}

.account span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.shell {
  width: min(1220px, calc(100vw - 36px));
  margin: 32px auto 64px;
}

.public {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.public-shell {
  width: min(430px, calc(100vw - 28px));
}

.login-card,
.panel,
.workspace,
.case-workspace,
.compact-editor,
.facts-card,
.case-tabs,
.metric {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card,
.panel,
.facts-card {
  padding: 22px;
}

.page-head,
.case-hero {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  align-items: flex-end;
  margin-bottom: 22px;
}

.page-head h1,
.case-hero h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 56px);
  font-weight: 780;
  line-height: 1.02;
  letter-spacing: 0;
}

.case-hero p {
  max-width: 720px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.button,
button.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  white-space: nowrap;
}

.button.primary {
  border-color: var(--text);
  background: var(--text);
  color: #fff;
}

.button.danger {
  border-color: var(--danger);
  color: var(--danger);
}

.button:hover {
  border-color: var(--line-strong);
  text-decoration: none;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  display: grid;
  gap: 9px;
  align-content: start;
  padding: 18px;
}

.metric-icon {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text);
}

.metric-icon .icon {
  width: 17px;
  height: 17px;
}

.metric strong {
  display: block;
  font-size: 30px;
  line-height: 1;
}

.metric > span:not(.metric-icon),
.hint,
.empty,
.notes,
.fact-grid span,
.document-row span,
.case-card-meta,
.case-card-side span {
  color: var(--muted);
}

.case-workspace {
  padding: 16px;
}

.case-controls {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.case-search {
  display: grid;
  gap: 7px;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon .icon {
  position: absolute;
  left: 12px;
  color: var(--muted);
  pointer-events: none;
}

.input-with-icon input {
  padding-left: 38px;
}

.chip-row {
  flex-wrap: wrap;
  align-items: flex-start;
}

.filter-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfbfa;
}

.filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.filter-head strong {
  font-size: 14px;
}

.chip-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.chip-group > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.chip {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

.chip.active {
  border-color: var(--text);
  background: var(--text);
  color: #fff;
}

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

.case-card {
  display: grid;
  grid-template-columns: minmax(230px, 1.2fr) minmax(240px, 1fr) minmax(160px, 0.6fr);
  gap: 18px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.case-due-review {
  border-color: #f3b5ad;
  background: #fff5f3;
}

.case-due-colloquium {
  border-color: #ead38d;
  background: #fff9e8;
}

.case-completed {
  border-color: #b7dccb;
  background: #f0faf4;
}

.case-muted {
  opacity: 0.72;
}

.case-card:hover {
  border-color: var(--line-strong);
}

.case-card-main {
  display: grid;
  gap: 4px;
}

.case-card-main strong {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 17px;
}

.case-card-main span {
  color: var(--muted);
}

.case-card-main .case-kind {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: 12px;
  font-weight: 780;
}

.case-kind .icon {
  width: 14px;
  height: 14px;
}

.case-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.case-card-meta > span,
.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 700;
}

.case-status {
  position: relative;
  cursor: help;
}

.info-tooltip {
  position: relative;
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  cursor: help;
}

.info-tooltip .icon {
  width: 13px;
  height: 13px;
}

.tooltip-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 20;
  display: none;
  width: min(280px, calc(100vw - 48px));
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--text);
  color: #fff;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
  box-shadow: var(--shadow);
}

.info-tooltip:hover,
.info-tooltip:focus {
  border-color: var(--text);
  background: var(--text);
  color: #fff;
}

.info-tooltip:hover .tooltip-panel,
.info-tooltip:focus .tooltip-panel {
  display: block;
}

.badge.role {
  background: var(--accent-soft);
  color: var(--accent);
}

.case-card-side {
  display: grid;
  gap: 4px;
  justify-items: end;
  text-align: right;
}

.case-card-side span,
.case-card-side strong {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.workflow-map {
  position: relative;
  display: flex;
  gap: 0;
  align-items: center;
  margin: -4px 0 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.workflow-step {
  position: relative;
  display: inline-flex;
  min-width: max-content;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
}

.workflow-step:not(:last-child) {
  padding-right: 44px;
}

.workflow-step:not(:last-child)::after {
  position: absolute;
  right: 10px;
  width: 24px;
  height: 2px;
  border-radius: 999px;
  background: var(--line-strong);
  content: "";
}

.workflow-dot {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
}

.workflow-step.is-done {
  color: var(--accent);
}

.workflow-step.is-done .workflow-dot,
.workflow-step.is-done:not(:last-child)::after {
  border-color: var(--accent);
  background: var(--accent);
}

.workflow-step.is-current {
  color: var(--text);
}

.workflow-step.is-current .workflow-dot {
  border-color: var(--text);
  box-shadow: 0 0 0 4px rgba(32, 32, 29, 0.08);
}

.workflow-step.is-locked,
.workflow-step.is-skipped {
  opacity: 0.58;
}

.compact-editor {
  display: grid;
  gap: 0;
  overflow: hidden;
}

.form-card,
.form-more,
.editor-actions {
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.form-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.form-card-head span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--text);
  color: #fff;
  font-size: 13px;
  font-weight: 760;
}

.form-card-head .icon {
  width: 15px;
  height: 15px;
}

.form-card h2,
.facts-card h2,
.case-tabs h2,
.panel h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.nested-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

[hidden] {
  display: none !important;
}

.form-more summary,
.inline-create summary {
  cursor: pointer;
  font-weight: 720;
}

.note-create summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 13px;
  border-radius: var(--radius);
  background: var(--text);
  color: #fff;
  list-style: none;
}

.note-create summary::-webkit-details-marker {
  display: none;
}

.form-more .form-grid,
.inline-create form {
  margin-top: 16px;
}

.editor-actions {
  justify-content: flex-end;
  border-bottom: 0;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.full {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font: inherit;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--text);
  outline: 3px solid rgba(32, 32, 29, 0.08);
}

.case-overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.7fr);
  gap: 16px;
  margin-bottom: 16px;
}

.fact-grid {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 10px 16px;
  margin-top: 16px;
}

.exam-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.exam-submit-button[hidden] {
  display: none;
}

.timeline {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.timeline-item {
  display: grid;
  gap: 4px;
  padding: 8px 8px 8px 16px;
  border-left: 2px solid var(--line);
  border-radius: 0 var(--radius) var(--radius) 0;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.timeline-item:hover {
  border-left-color: var(--line-strong);
  background: var(--surface-soft);
}

.timeline-item > a,
.timeline-item > button {
  font-weight: 720;
}

.timeline-item > button {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 7px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.timeline-item > button:hover {
  text-decoration: underline;
}

.timeline-item small,
.timeline-item span {
  color: var(--muted);
  font-size: 13px;
}

.timeline-item div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.case-tabs {
  overflow: hidden;
}

.case-tabs > nav {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.case-tabs > nav button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

.case-tabs > nav button.active {
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 720;
}

.tab-panel {
  display: none;
  padding: 20px;
}

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

.tab-panel h2 {
  margin: 0 0 12px;
}

.panel-split {
  display: grid;
  grid-template-columns: minmax(280px, 0.65fr) minmax(0, 1fr);
  gap: 20px;
}

.colloquium-block {
  display: grid;
  grid-template-columns: minmax(280px, 0.65fr) minmax(0, 1fr);
  gap: 20px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.upload-form,
.stack {
  display: grid;
  gap: 12px;
}

.upload-complete {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.upload-complete.is-locked {
  color: var(--muted);
}

.upload-complete p {
  margin: 0;
  color: var(--muted);
}

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

.notes-list {
  display: grid;
  gap: 6px;
}

.document-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.document-row a,
.document-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.document-row p,
.note p,
.note-card p {
  margin: 4px 0 0;
  color: var(--muted);
}

.text-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font: inherit;
  font-weight: 650;
}

.icon-only {
  display: inline-grid;
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  place-items: center;
  border-radius: 999px;
}

.icon-only .icon {
  width: 17px;
  height: 17px;
}

.icon-only:hover {
  background: var(--surface-soft);
}

.note {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.note span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.private {
  color: #8a5a00;
}

.danger-zone {
  display: grid;
  gap: 18px;
  max-width: 540px;
}

.danger-zone form:last-child {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid #ffd6d1;
  border-radius: var(--radius);
  background: var(--danger-soft);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(32, 32, 29, 0.35);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(620px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 48px));
  overflow: auto;
  padding: 22px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(32, 32, 29, 0.22);
}

.modal-panel h2 {
  margin: 0 0 16px;
}

.modal-close {
  float: right;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.report-grid {
  display: grid;
  gap: 12px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.report-period {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-bottom: 12px;
}

.program-admin {
  display: grid;
  gap: 18px;
}

.program-table {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.program-header,
.program-row-shell {
  display: grid;
  grid-template-columns: minmax(72px, 0.45fr) minmax(240px, 1.45fr) minmax(106px, 0.55fr) minmax(96px, 0.45fr) minmax(160px, 0.9fr) minmax(220px, 1fr) minmax(116px, 0.55fr) 86px;
  gap: 0;
  align-items: center;
}

.program-header {
  position: sticky;
  top: 0;
  z-index: 1;
  min-width: 1110px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
  text-transform: uppercase;
}

.program-header span,
.program-row > *,
.program-delete {
  padding: 10px;
}

.program-list {
  display: grid;
  min-width: 1110px;
}

.program-row-shell {
  border-bottom: 1px solid var(--line);
}

.program-row-shell:last-child {
  border-bottom: 0;
}

.program-row {
  display: grid;
  grid-column: 1 / 8;
  grid-template-columns: subgrid;
  gap: 0;
  align-items: center;
}

.program-row input,
.program-row select {
  min-height: 36px;
  border-color: transparent;
  background: transparent;
}

.program-row input:focus,
.program-row select:focus {
  background: var(--surface);
}

.program-check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  white-space: nowrap;
}

.program-check input {
  width: auto;
}

.program-delete {
  display: flex;
  grid-column: 8;
  justify-content: flex-end;
}

.autosave-state {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  justify-self: start;
  border-radius: 999px;
  color: var(--muted);
}

.autosave-state .icon {
  width: 15px;
  height: 15px;
}

.autosave-state[data-state="saving"] {
  color: var(--text);
  background: var(--surface-soft);
}

.autosave-state[data-state="saved"] {
  color: var(--accent);
}

.autosave-state[data-state="error"] {
  color: var(--danger);
  background: var(--danger-soft);
}

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

.note-editor-list > .empty {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.note-row-shell {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.note-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.45fr) minmax(150px, 0.65fr) minmax(280px, 1.7fr) auto;
  gap: 8px;
  align-items: start;
  padding: 10px;
}

.note-row > * {
  min-width: 0;
}

.note-time {
  display: flex;
  align-items: center;
  min-height: 38px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
  white-space: nowrap;
}

.note-row input,
.note-row textarea {
  min-height: 38px;
  border-color: transparent;
  background: transparent;
  line-height: 1.35;
  resize: vertical;
}

.note-row input:focus,
.note-row textarea:focus {
  background: var(--surface);
}

.note-row .autosave-state {
  align-self: center;
  justify-self: end;
}

.note-delete {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 10px 12px 10px 0;
  min-height: 58px;
}

.program-add {
  display: grid;
  gap: 12px;
  padding-top: 4px;
}

.program-add h2 {
  margin: 0;
}

.program-add .new-program {
  grid-column: auto;
  grid-template-columns: minmax(72px, 0.45fr) minmax(240px, 1.45fr) minmax(106px, 0.55fr) minmax(96px, 0.45fr) minmax(160px, 0.9fr) minmax(220px, 1fr) minmax(116px, 0.55fr) auto;
  gap: 8px;
  align-items: center;
}

.program-add .new-program input,
.program-add .new-program select {
  border-color: var(--line);
  background: var(--surface);
}

.program-add .new-program .add-program-button {
  justify-self: end;
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
}

.notice {
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
}

@media (max-width: 980px) {
  .topbar,
  .case-card,
  .case-overview,
  .panel-split,
  .form-grid,
  .metrics,
  .report-period {
    grid-template-columns: 1fr;
  }

  .note-row-shell,
  .note-row,
  .program-add .new-program {
    grid-template-columns: 1fr;
  }

  .note-delete {
    justify-content: flex-start;
    padding: 0 10px 10px;
    min-height: auto;
  }

  .report-period {
    align-items: stretch;
    flex-direction: column;
  }

  .case-card-side {
    justify-items: start;
    text-align: left;
  }
}

@media (max-width: 640px) {
  .shell {
    width: calc(100vw - 24px);
    margin-top: 22px;
  }

  .page-head,
  .case-hero,
  .actions,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar nav,
  .account {
    align-items: flex-start;
  }
}
