:root {
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #dbe3ee;
  --ink: #111b35;
  --muted: #526174;
  --accent: #0f60df;
  --accent-ink: #0847ad;
  --accent-soft: #eaf2ff;
  --warn: #9a5b08;
  --warn-soft: #fff4dc;
  --bad: #c2382b;
  --bad-soft: #fff0ed;
  --good: #148052;
  --good-soft: #e9f8f0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent-ink); }

header.topbar {
  background: var(--surface);
  color: var(--ink);
  padding: 15px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

header.topbar a.brand {
  color: var(--ink);
  font-weight: 700;
  font-size: 17px;
  text-decoration: none;
}

nav.mainnav { display: flex; gap: 18px; flex-wrap: wrap; }
nav.mainnav a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; }
nav.mainnav a:hover { color: var(--accent); }

main.container {
  max-width: 1480px;
  margin: 0 auto;
  padding: 26px 24px 80px;
}

h1 { font-size: 26px; margin: 0 0 6px; }
h2 { font-size: 19px; margin: 30px 0 10px; border-bottom: 2px solid var(--accent); padding-bottom: 6px; }
h3 { font-size: 15.5px; margin: 18px 0 8px; }
.subtitle { color: var(--muted); margin: 0 0 22px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 24px;
  margin-bottom: 20px;
}

.flash {
  background: var(--good-soft);
  color: var(--good);
  border: 1px solid var(--good);
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 18px;
  font-size: 14px;
}
.flash.error { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }

table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.pill.draft { background: var(--warn-soft); color: var(--warn); }
.pill.published { background: var(--good-soft); color: var(--good); }
.pill.retired { background: var(--surface-2); color: var(--muted); }
.pill.status { background: var(--accent-soft); color: var(--accent-ink); }

form.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); font-weight: 400; }
input[type=text], input[type=number], input[type=date], input[type=email], input[type=tel],
input[type=password], select, textarea {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
  min-width: 200px;
}
input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(15, 96, 223, .16);
  border-color: var(--accent);
}
input[type=file] {
  width: 100%;
  max-width: 420px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
}
input[type=file]::file-selector-button {
  margin-right: 10px;
  padding: 6px 10px;
  border: 0;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
  cursor: pointer;
}
textarea { min-height: 80px; font-family: inherit; }
label.checkbox { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 500; color: var(--ink); }

button, input[type=submit] {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 9px 17px;
  border-radius: 7px;
  font-size: 14px;
  cursor: pointer;
}
button:hover, input[type=submit]:hover { background: var(--accent-ink); }
button.secondary { background: var(--surface-2); color: var(--ink); }
button.secondary:hover { background: var(--border); }
button:disabled, button:disabled:hover { opacity: .42; cursor: not-allowed; background: var(--surface-2); }
button.danger { background: var(--bad); }
button.small { padding: 4px 10px; font-size: 12.5px; }
.icon-button { min-width: 30px; padding: 4px 8px; font-size: 15px; line-height: 1; }
.step-order { display: flex; align-items: center; gap: 10px; }
.step-order > span { min-width: 18px; font-weight: 600; }
.step-order-controls { display: flex; gap: 4px; }
.step-order-controls form { margin: 0; }

.step-library {
  margin: 0 0 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.step-library summary {
  padding: 12px 16px;
  color: var(--accent-ink);
  font-weight: 600;
  cursor: pointer;
}
.step-library[open] summary { border-bottom: 1px solid var(--border); }
.step-library .table-wrap { padding: 4px 8px 8px; }

.steps-nav {
  display: flex;
  gap: 0;
  margin: 18px 0 24px;
  padding: 10px 14px;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.steps-nav a {
  display: flex;
  flex: 1 0 150px;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: 8px;
  background: transparent;
  border: 0;
  text-decoration: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.steps-nav a:hover { background: var(--accent-soft); color: var(--accent-ink); }
.steps-nav a.active { background: var(--accent-soft); color: var(--accent-ink); }
.steps-nav a .progress { display: block; margin-top: 1px; font-size: 11px; color: inherit; opacity: .72; font-weight: 500; }
.step-number {
  display: grid;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: #a9b2bf;
  color: #fff;
  font-size: 12px;
}
.steps-nav a.active .step-number { background: var(--accent); }
.step-nav-copy { min-width: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

.muted { color: var(--muted); }
.section-hint { color: var(--muted); font-size: 13.5px; margin: -4px 0 14px; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 8px 0; border-bottom: 1px solid var(--border); }
ul.plain li:last-child { border-bottom: none; }

hr.rule { border: none; border-top: 1px dashed var(--border); margin: 24px 0; }

.case-heading,
.step-title-row,
.section-heading,
.document-heading,
.case-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.overall-progress { text-align: right; white-space: nowrap; }
.overall-progress strong { display: block; color: var(--accent-ink); font-size: 24px; line-height: 1.1; }
.overall-progress span { color: var(--muted); font-size: 12px; }

.progress-track {
  height: 7px;
  overflow: hidden;
  margin: 2px 0 22px;
  border-radius: 99px;
  background: var(--surface-2);
}
.progress-track span { display: block; height: 100%; background: var(--accent); transition: width 180ms ease-out; }

.step-title-row { align-items: flex-end; margin: 26px 0 14px; }
.step-title-row h2 { margin: 0; border: 0; padding: 0; }
.step-percent { color: var(--accent-ink); white-space: nowrap; }

.information-block,
.completion-summary {
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.information-block h3,
.completion-summary p { margin: 0 0 4px; }
.completion-summary { display: grid; grid-template-columns: minmax(220px, .7fr) 1fr; gap: 24px; }
.completion-summary ul { margin: 0; padding-left: 20px; }
.preserve-lines { max-width: 72ch; white-space: pre-wrap; }

.section-heading h3,
.document-heading p { margin: 0; }
.section-heading p { margin: 2px 0 16px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 2px 18px; }
.field-grow { flex: 1; }
.required-marker { color: var(--bad); }
.document-requirement { padding: 16px 0; border-bottom: 1px solid var(--border); }
.document-requirement:first-of-type { padding-top: 4px; }
.document-requirement:last-child { border-bottom: 0; padding-bottom: 0; }
.document-heading { align-items: center; }
.extraction-plan { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.extraction-plan span { padding: 3px 8px; border-radius: 4px; background: var(--accent-soft); color: var(--accent-ink); font-size: 12px; }
.uploaded-file { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.upload-form { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.file-field { flex: 1 1 300px; }
.compact-field input,
.compact-field select { min-width: 150px; }
.note-meta { font-size: 12px; }
.note-text { margin: 0 0 4px; white-space: pre-wrap; }
.note-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.note-id {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.document-config-list {
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.document-config { padding: 18px 20px; border-bottom: 1px solid var(--border); }
.document-config:last-child { border-bottom: 0; }
.document-config h3 { margin: 0; }
.document-config .document-heading p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.mapping-list { margin: 14px 0 8px; }
.mapping-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.4fr) auto;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--surface-2);
  font-size: 13px;
}
.mapping-row:last-child { border-bottom: 0; }
.mapping-form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.config-warning { margin: 12px 0 0; }

.verification-check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 22px; }
.verification-check-card { padding: 18px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.verification-check-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.verification-check-heading h3 { margin: 0; }
.verification-check-heading p { max-width: 58ch; margin: 3px 0 15px; color: var(--muted); font-size: 13px; }
.verification-toggle { margin-bottom: 14px; }
.verification-check-card select { width: 100%; }
.verification-config-summary { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; margin: 0; font-size: 13px; }
.verification-config-summary dt { color: var(--muted); }
.verification-config-summary dd { margin: 0; overflow-wrap: anywhere; }

.extracted-information {
  margin: 16px 0 6px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.extracted-information h4 { margin: 0; font-size: 14px; }
.extracted-information .section-heading p { margin-bottom: 12px; }

.case-actions { align-items: center; margin-top: 22px; }
.case-actions form { margin-left: auto; }
.case-actions a:last-child { margin-left: 0; }
.case-actions-top {
  justify-content: flex-end;
  margin: -2px 0 16px;
  padding: 0 2px;
}
.case-actions-top form { margin: 0; }
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 16px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.button-link:hover { background: var(--accent-ink); color: #fff; }
.button-link.secondary { background: var(--surface-2); color: var(--ink); }
.button-link.secondary:hover { background: var(--border); }
.button-link.disabled { opacity: .42; cursor: not-allowed; pointer-events: none; }

/* Safety Manager case workspace */
.back-link { margin: 0 0 14px; }
.back-link a { color: var(--accent); font-size: 13.5px; font-weight: 600; text-decoration: none; }
.back-link a:hover { text-decoration: underline; }

.case-summary-bar {
  align-items: center;
  padding: 18px 22px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.case-label { margin: 0; color: var(--muted); font-size: 12px; font-weight: 600; }
.case-summary-bar h1 { font-size: 20px; margin: 1px 0 6px; }
.case-summary-bar .subtitle {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px 10px;
  margin: 0;
  font-size: 13.5px;
}
.case-separator { color: #9ba6b5; }

.case-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  align-items: start;
  gap: 22px;
}
.case-main { min-width: 0; }
.workflow-panel-heading {
  margin: 0 0 16px;
  padding: 20px 24px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.workflow-panel-heading h2 { font-size: 21px; }
.step-percent {
  padding: 5px 10px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12px;
}
.information-block {
  border-color: #bed5fb;
  background: #f1f6ff;
}

.field-category { padding: 18px 0 8px; border-top: 1px solid var(--border); }
.field-category:first-of-type { padding-top: 4px; border-top: 0; }
.field-category-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 13px;
}
.field-category-heading h4 { margin: 0; color: var(--ink); font-size: 15px; }
.field-category-heading span { color: var(--muted); font-size: 12px; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 8px; }

.documents-workspace > .section-heading { margin-bottom: 14px; }
.upload-guidance {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  min-height: 112px;
  margin: 4px 0 18px;
  padding: 20px;
  border: 1px dashed #9eb9df;
  border-radius: 10px;
  background: #fbfdff;
  text-align: left;
}
.upload-guidance strong,
.upload-guidance span { display: block; }
.upload-guidance span { color: var(--muted); font-size: 12.5px; }
.upload-guidance .upload-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 25px;
  line-height: 1;
}
.documents-workspace .document-requirement {
  margin-top: 10px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.documents-workspace .document-requirement:first-of-type { padding-top: 16px; }
.documents-workspace .document-requirement:last-child { padding-bottom: 16px; }
.document-state { display: block; margin-top: 2px; color: var(--good); font-size: 12px; }
.document-state.missing { color: var(--bad); }
.upload-picker { min-width: min(100%, 300px); }
.uploaded-file {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-2);
}
.extracted-information { background: #f8fbff; }

.case-sidebar {
  position: sticky;
  top: 20px;
  display: grid;
  gap: 16px;
}
.sidebar-panel {
  padding: 19px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.sidebar-panel h3 { margin: 0 0 16px; color: var(--ink); font-size: 14px; }
.completion-score { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.completion-score > div:last-child { display: grid; gap: 2px; }
.completion-score strong { font-size: 13px; }
.completion-score > div:last-child span { color: var(--muted); font-size: 11.5px; }
.progress-ring {
  --progress: 0%;
  position: relative;
  display: grid;
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--progress), #dbe7f6 0);
}
.progress-ring::before {
  content: "";
  position: absolute;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--surface);
}
.progress-ring span { position: relative; color: var(--accent-ink); font-size: 17px; font-weight: 700; }
.sidebar-step-progress { margin-top: 11px; }
.sidebar-step-progress > div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
}
.sidebar-step-progress > div:first-child span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-step-progress > div:first-child strong { color: var(--accent-ink); }
.sidebar-step-progress .progress-track { height: 5px; margin: 5px 0 0; }
.validation-result { padding: 11px 0; border-bottom: 1px solid var(--border); }
.validation-result:last-child { padding-bottom: 0; border-bottom: 0; }
.validation-result > div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.validation-result strong { font-size: 12.5px; }
.validation-result span { font-size: 10.5px; font-weight: 700; }
.validation-result p { margin: 4px 0 0; color: var(--muted); font-size: 11.5px; }
.validation-result.passed span { color: var(--good); }
.validation-result.failed span { color: var(--bad); }
.validation-result.pending span { color: var(--warn); }
.sidebar-panel-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.sidebar-panel-heading span { color: var(--bad); font-size: 11.5px; font-weight: 700; }
.missing-panel ul { max-height: 360px; margin: 0; padding-left: 18px; overflow-y: auto; color: var(--ink); font-size: 12.5px; }
.missing-panel li { margin: 7px 0; }
.complete-message { margin: 0; color: var(--good); font-size: 13px; }

.activity-page { max-width: 1180px; }
.activity-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
  align-items: start;
  gap: 22px;
  margin-top: 22px;
}
.activity-layout .section-heading h2 {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 19px;
}
.status-management form,
.case-notes form {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.status-management textarea,
.case-notes textarea { width: 100%; min-height: 96px; }
.activity-section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 20px 0 10px;
}
.activity-section-heading h3 { margin: 0; }
.activity-section-heading span { color: var(--muted); font-size: 12px; }
.status-timeline { margin: 0; padding: 0; list-style: none; }
.status-timeline li {
  position: relative;
  padding: 12px 0 12px 22px;
  border-bottom: 1px solid var(--border);
}
.status-timeline li:last-child { border-bottom: 0; }
.status-timeline li::before {
  content: "";
  position: absolute;
  top: 19px;
  left: 2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.status-timeline li > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.status-timeline time { color: var(--muted); font-size: 12px; }
.status-timeline p { margin: 7px 0 2px; font-size: 13.5px; }
.status-timeline .muted { font-size: 12px; }

@media (max-width: 720px) {
  .case-heading,
  .step-title-row,
  .completion-summary { display: block; }
  .overall-progress { margin-top: 12px; text-align: left; }
  .step-percent { display: block; margin-top: 8px; }
  .completion-summary ul { margin-top: 10px; }
  .mapping-row { grid-template-columns: 1fr; gap: 4px; }
  .mapping-row .pill { grid-column: 1 / -1; justify-self: start; }
}

@media (max-width: 1050px) {
  .case-workspace { grid-template-columns: 1fr; }
  .case-sidebar { position: static; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
  .activity-layout { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  header.topbar { padding: 14px 18px; }
  main.container { padding: 20px 16px 60px; }
  .case-summary-bar { padding: 16px; }
  .case-summary-bar .subtitle { display: grid; gap: 4px; }
  .case-separator { display: none; }
  .workflow-panel-heading { padding: 17px; }
  .steps-nav { margin-right: -16px; border-radius: 10px 0 0 10px; }
  .card { padding: 18px 16px; }
  .upload-form { display: grid; }
  .upload-form .field, .upload-form input, .upload-form select { width: 100%; min-width: 0; }
  .case-actions { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  .progress-track span { transition: none; }
}
