/*
  DORA reporting - stylesheet.
  Tokens and base rules follow the Incudo web style guide (shared with
  Incudo Business Manager). Cards and inputs sit on --canvas white.
*/
@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
:root {
  --ink: #1a1a1a;
  --charcoal: #37352f;
  --slate: #5d5b54;
  --steel: #787671;
  --stone: #a4a097;
  --canvas: #ffffff;
  --surface: #f6f5f4;
  --surface-soft: #fafaf9;
  --hairline: #e5e3df;
  --hairline-soft: #ede9e4;
  --hairline-strong: #c8c4be;
  --primary: #5645d4;
  --primary-pressed: #4534b3;
  --primary-deep: #3a2c99;
  --on-primary: #ffffff;
  --link: #0075de;
  --link-pressed: #005bab;
  --success: #1aae39;
  --success-text: #147d2a;
  --warning: #dd5b00;
  --warning-text: #793400;
  --danger: #e03131;
  --danger-text: #b82626;
  --tint-peach: #ffe8d4;
  --tint-rose: #fde0ec;
  --tint-mint: #d9f3e1;
  --tint-lavender: #e6e0f5;
  --tint-sky: #dcecfa;
  --tint-yellow: #fef7d6;
  --tint-cream: #f8f5e8;
  --radius: 12px;
  --radius-control: 8px;
  --shadow-focus: 0 0 0 2px var(--primary);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.55;
  background: var(--canvas);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-weight: 600; color: var(--ink); }
h1 { font-size: 28px; line-height: 1.25; letter-spacing: -0.3px; margin: 0 0 8px 0; }
h2 { font-size: 22px; line-height: 1.3; margin: 0 0 12px 0; }
h3 { font-size: 18px; line-height: 1.4; margin: 0 0 8px 0; }
h4 { font-size: 16px; line-height: 1.4; margin: 16px 0 6px 0; }
p { margin: 0 0 12px 0; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-pressed); text-decoration: underline; }
ul, ol { padding-left: 22px; margin: 0 0 12px 0; }
li { margin-bottom: 4px; }
hr { border: 0; border-top: 1px solid var(--hairline); margin: 24px 0; }
code { font-family: var(--font-mono); font-size: 14px; background: var(--surface); padding: 1px 5px; border-radius: 4px; }
::selection { background: rgba(86, 69, 212, 0.18); }
[hidden] { display: none !important; }

/* ---- Sidebar ---------------------------------------------------------- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--hairline);
  padding: 24px 16px;
  overflow-y: auto;
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--charcoal);
  font-size: 15px;
  font-weight: 600;
  padding: 0 8px 8px 8px;
  line-height: 1.3;
}
.brand:hover { text-decoration: none; color: var(--ink); }
.sidebar__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sidebar .nav-toggle { display: none; flex: 0 0 auto; }
.brand__mark {
  width: 24px; height: 24px; flex: 0 0 24px;
  border-radius: 6px;
  background: var(--primary) url("/favicon.svg") center / cover no-repeat;
}
.sidebar h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--steel);
  margin: 20px 0 6px 0;
  padding: 0 8px;
  font-weight: 600;
}
.sidebar a:not(.brand) {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--charcoal);
  text-decoration: none;
  padding: 8px;
  border-radius: 6px;
  margin-bottom: 2px;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 120ms ease;
}
.sidebar a:not(.brand):hover { background: var(--hairline-soft); color: var(--ink); }
.sidebar a.active {
  background: var(--surface-soft);
  border: 1px solid var(--hairline);
  padding: 7px;
  color: var(--ink);
  font-weight: 600;
}
.nav-item__icon {
  display: inline-flex;
  width: 20px; height: 20px; flex: 0 0 20px;
  align-items: center; justify-content: center;
}
.nav-item__icon svg { width: 20px; height: 20px; }
.inline-icon { display: inline-block; width: 16px; height: 16px; vertical-align: -3px; }
.inline-icon svg { width: 16px; height: 16px; }

/* ---- Content ---------------------------------------------------------- */
.content {
  margin-left: 240px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 32px 48px 32px;
  flex: 1 0 auto;
}
.page-header { margin-bottom: 24px; }
.page-lead { color: var(--slate); font-size: 17px; max-width: 760px; margin: 0; }
.eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--steel);
  font-weight: 600;
  margin: 0 0 6px 0;
}

/* ---- Cards & sections ------------------------------------------------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.card {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}
.card-grid > .card { margin-bottom: 0; }
.card--muted { background: var(--surface-soft); }
.card h2 { font-size: 18px; }
.card h3 { margin-top: 4px; }
.card > :last-child { margin-bottom: 0; }
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.card__head h2, .card__head h3 { margin: 0; }
.section-description { margin: 4px 0 16px 0; color: var(--slate); font-size: 14px; }
.stat { font-size: 28px; font-weight: 600; line-height: 1.2; }

/* ---- Forms ------------------------------------------------------------ */
form { display: block; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 600; font-size: 14px; padding: 0; margin-bottom: 8px; }
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
}
.form-grid .field { margin-bottom: 0; min-width: 0; }
.form-grid .field--wide { grid-column: 1 / -1; }
label, .label {
  display: block;
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--ink);
}
.required-mark { color: var(--danger-text); margin-left: 2px; }
.hint { display: block; color: var(--steel); font-size: 13px; margin-top: 4px; overflow-wrap: anywhere; }
.field-code { color: var(--stone); font-size: 12px; font-family: var(--font-mono); margin-left: 6px; font-weight: 400; overflow-wrap: anywhere; }
input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-control);
  font-family: var(--font);
  font-size: 16px;
  color: var(--ink);
  background: var(--canvas);
  min-height: 44px;
  transition: border-color 160ms ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--stone); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--shadow-focus); }
input:disabled, input[readonly], select:disabled { background: var(--surface); color: var(--steel); cursor: not-allowed; }
input::placeholder, textarea::placeholder { color: var(--stone); }
textarea { min-height: 110px; resize: vertical; }
input[type="checkbox"], input[type="radio"] {
  width: 18px; height: 18px; min-height: 0;
  margin: 0; padding: 0;
  accent-color: var(--primary);
  flex: 0 0 18px;
}
input[type="file"] { padding: 8px; min-height: 0; }
.datetime { display: flex; gap: 8px; }
.datetime .date-field { flex: 1 1 auto; min-width: 0; }
.datetime .datetime__time { flex: 0 0 6.5em; width: 6.5em; font-variant-numeric: tabular-nums; }
.date-field { position: relative; display: block; min-width: 0; }
.date-input { font-variant-numeric: tabular-nums; }
.date-field.has-picker .date-input { padding-right: 44px; }
.date-field__pick {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  min-height: 0;
  padding: 0;
  border-color: transparent;
  color: var(--slate);
}
.date-field__pick:hover { border-color: transparent; background: var(--surface-soft); color: var(--ink); }
.date-field__native {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}
.field.is-invalid input, .field.is-invalid select, .field.is-invalid textarea,
.field.is-invalid .check-list { border-color: var(--danger); }
.field-error { color: var(--danger-text); font-size: 13px; margin-top: 4px; }
.check-list {
  display: grid;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-control);
  padding: 10px 12px;
}
.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-weight: 400;
  font-size: 14px;
  margin: 0;
  cursor: pointer;
}
.check input { margin-top: 2px; }
.radio-row { display: flex; gap: 20px; flex-wrap: wrap; }
.honeypot { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.check-group { border: 0; padding: 0; margin: 0; min-width: 0; }
.check-group legend { font-weight: 500; font-size: 14px; margin-bottom: 4px; padding: 0; }
.check-list--cols { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.check-list--codes { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); max-height: 220px; }
.report-form .card { margin-bottom: 20px; }
.report-form .field-code { margin-left: 6px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.toolbar .grow { flex: 1 1 auto; }
.inline-select { width: auto; min-width: 220px; }

/* ---- Questionnaire --------------------------------------------------- */
.question-list { counter-reset: none; }
.question-group-title { margin: 24px 0 8px 0; font-size: 15px; color: var(--slate); text-transform: none; }
.question__number { display: inline-block; min-width: 2.2em; font-weight: 600; color: var(--primary-deep); }
.question__bullets { margin: 6px 0 10px 1.2em; font-size: 14px; color: var(--slate); }
.question__note { font-size: 13px; color: var(--steel); margin-bottom: 10px; }
.question.is-missing .question__text { color: var(--danger-text); }
.question {
  border-top: 1px solid var(--hairline-soft);
  padding: 16px 0;
}
.question:first-of-type { border-top: 0; padding-top: 0; }
.question__text { font-weight: 500; margin-bottom: 4px; }
.question__help { color: var(--slate); font-size: 14px; margin-bottom: 10px; }
.question details { margin-top: 8px; }
details summary { cursor: pointer; color: var(--link); font-size: 14px; }
details[open] summary { margin-bottom: 8px; }
details .details-body { font-size: 14px; color: var(--slate); }

/* ---- Buttons ---------------------------------------------------------- */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--ink);
  padding: 10px 18px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-control);
  text-decoration: none;
  font-family: var(--font);
  font-weight: 500;
  font-size: 14px;
  line-height: 1.3;
  width: auto;
  cursor: pointer;
  min-height: 40px;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}
button:hover, .btn:hover { border-color: var(--stone); background: var(--surface-soft); text-decoration: none; color: var(--ink); }
button svg, .btn svg { width: 16px; height: 16px; flex: 0 0 16px; }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: none; box-shadow: var(--shadow-focus); border-radius: 6px; }
button:disabled, .btn:disabled, .btn[aria-disabled="true"] { background: var(--hairline); color: var(--stone); border-color: transparent; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.btn.primary:hover { background: var(--primary-pressed); color: var(--on-primary); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--tint-rose); color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: 13px; min-height: 32px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 20px; }
.actions--end { justify-content: flex-end; }
.sticky-actions {
  position: sticky;
  bottom: 0;
  background: var(--canvas);
  border-top: 1px solid var(--hairline);
  padding: 12px 0;
  margin-top: 16px;
  z-index: 5;
}
.sticky-actions .actions { margin-top: 0; }

/* ---- Tables ----------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-control);
  overflow: hidden;
  font-size: 14px;
}
th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--hairline-soft);
  vertical-align: top;
}
th { background: var(--surface); color: var(--steel); font-weight: 500; font-size: 13px; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-soft); }
.empty { color: var(--steel); font-size: 14px; padding: 12px 0; }

/* ---- Badges, notices, flash ------------------------------------------ */
.muted { color: var(--slate); }
.small { color: var(--slate); font-size: 14px; }
.mono { font-family: var(--font-mono); font-size: 0.95em; }
.nowrap { white-space: nowrap; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  border-radius: 6px;
  background: var(--tint-lavender);
  color: var(--primary-deep);
}
.badge--success { background: var(--tint-mint); color: var(--success-text); }
.badge--warning { background: var(--tint-peach); color: var(--warning-text); }
.badge--danger { background: var(--tint-rose); color: var(--danger-text); }
.badge--neutral { background: var(--surface); color: var(--slate); }
.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 9999px;
  background: var(--surface);
  color: var(--steel);
  border: 1px solid var(--hairline);
  font-size: 12px;
  font-weight: 500;
}
.notice {
  padding: 12px 16px;
  border-radius: var(--radius-control);
  background: var(--tint-sky);
  border: 1px solid #9cc6ee;
  margin-bottom: 16px;
  font-size: 14px;
}
.notice > :last-child { margin-bottom: 0; }
.notice--warning { background: var(--tint-yellow); border-color: var(--warning); }
.notice--danger { background: var(--tint-rose); border-color: var(--danger); }
.notice--success { background: var(--tint-mint); border-color: var(--success); }
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-control);
  margin-bottom: 16px;
  font-size: 14px;
  background: var(--tint-mint);
  border: 1px solid var(--success);
}
.flash--error { background: var(--tint-rose); border-color: var(--danger); }

/* ---- Results & output ------------------------------------------------- */
.result {
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 16px 0;
  border: 1px solid var(--hairline);
  background: var(--surface-soft);
}
.result--major { background: var(--tint-rose); border-color: var(--danger); }
.result--minor { background: var(--tint-mint); border-color: var(--success); }
.result h3 { margin-top: 0; }
.result > :last-child { margin-bottom: 0; }
.deadline-list { list-style: none; padding: 0; margin: 0; }
.deadline-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--hairline-soft);
  margin: 0;
}
.deadline-list li:last-child { border-bottom: 0; }
.deadline__label { display: flex; flex-direction: column; gap: 2px; }
.deadline__value { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }
pre.json {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-control);
  padding: 16px;
  overflow: auto;
  max-height: 520px;
  white-space: pre;
  margin: 0;
}
.error-list { margin: 8px 0 0 0; font-size: 14px; }
.kv { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: 6px 16px; font-size: 14px; margin: 0; }
.kv dt { color: var(--steel); }
.kv dd { margin: 0; }
.steps { counter-reset: step; list-style: none; padding: 0; }
.steps li { counter-increment: step; position: relative; padding-left: 36px; margin-bottom: 12px; }
.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 24px; height: 24px;
  border-radius: 9999px;
  background: var(--tint-lavender);
  color: var(--primary-deep);
  font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ---- Help / prose ----------------------------------------------------- */
.prose { max-width: 820px; }
.prose h2 { margin-top: 28px; }
.prose h3 { margin-top: 20px; }
.prose table { margin: 12px 0 16px 0; }
.help-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }

/* ---- Footer ----------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--hairline);
  background: var(--surface-soft);
  color: var(--slate);
  font-size: 13px;
  padding: 16px 32px;
}
.site-footer__row {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 8px 24px;
  flex-wrap: wrap;
  padding: 2px 0;
}
.site-footer__links { display: inline-flex; gap: 16px; flex-wrap: wrap; }
.site-footer a { color: var(--slate); }
.site-footer a:hover { color: var(--ink); }

@media (max-width: 900px) {
  .sidebar { position: static; width: 100%; border-right: none; border-bottom: 1px solid var(--hairline); padding: 12px 16px; }
  .brand { padding-bottom: 0; }
  /* app.js sets .has-toggle, so without script the links stay visible. */
  .sidebar.has-toggle .nav-toggle { display: inline-flex; }
  .sidebar.has-toggle:not(.is-open) .nav-links { display: none; }
  .sidebar.is-open .nav-links { padding-top: 4px; }
  .content { margin-left: 0; min-height: 0; }
  .container { padding: 24px 16px 40px 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .site-footer { padding: 16px; }
}

@media print {
  .sidebar, .site-footer, .actions, .sticky-actions, #flash { display: none !important; }
  .content { margin-left: 0; }
  .card { border: 0; padding: 0; }
}
