/* LOTSE styles: plain CSS without a framework (stage 2a plan).

   Sections:
   1. Colours and sizes
   2. Basics
   3. Page layout: header, navigation, footer
   4. Building blocks: cards, buttons, badges, notices, tables
   5. Form fields
   6. Pages: start, overview, request form, detail

   The colours follow the brand of the Landeshauptstadt Kiel (docs/etappen/
   etappe-2a-mockup.html). config/tests/test_colours.py checks the
   contrast of every colour pair used for text, borders and focus.
   No inline styles anywhere: the Content Security Policy forbids them. */

/* --- 1. Colours and sizes ---------------------------------------------- */

:root {
  /* Every colour has a value for the light and one for the dark mode:
     light-dark(light, dark). Which one applies follows "color-scheme" below,
     set by the switch in the header (static/js/theme.js) or by the setting
     of the operating system. config/tests/test_colours.py checks the
     contrast of both. */
  color-scheme: light dark;

  --header: #00223e;                               /* header: navy in both modes */
  --navy: light-dark(#00223e, #9cd2f2);            /* brand colour: main buttons, headings */
  --navy-light: light-dark(#1d4a6e, #c2e5f9);      /* links, hover */
  --navy-tint: light-dark(#eef3f7, #1f2e3c);       /* hover of rows, selected tiles */
  --on-navy: light-dark(#ffffff, #0b1620);         /* text on --navy and --navy-light */
  --cyan: #1bbbea;                                 /* only the line below the header, never text */
  --sky: #84d0f0;                                  /* focus halo; text in the header */
  --sky-tint: light-dark(#e3f4fc, #152f3f);        /* background of subfields */
  --page: light-dark(#f4f6f7, #0f171f);            /* page background */
  --surface: light-dark(#ffffff, #18222c);         /* cards */
  --grey-light: light-dark(#e9ecee, #2a3642);      /* lines inside cards */
  --grey-line: light-dark(#c2cbd4, #3b4957);       /* card borders (decoration) */
  --grey-border: light-dark(#8796a5, #7f8e9c);     /* borders of input fields, 3:1 */
  --grey-text: light-dark(#5b6b7a, #a7b4c0);       /* secondary text, 4.5:1 */
  --text: light-dark(#1a1f24, #e6ebef);

  /* Meaning colours. Red is reserved for "sofort", alarm, errors and the
     banner of a test instance. */
  --test-banner: #b8003f;                          /* same red in both modes, white text */
  --red-text: light-dark(#b8003f, #ff9ab7);
  --red-tint: light-dark(#fde8ef, #3f1624);
  --red-line: light-dark(#e3004f, #ff4d7d);
  --red-border: light-dark(#f3b6c9, #7a2a44);
  --amber-text: light-dark(#9a4a00, #ffc078);
  --amber-tint: light-dark(#fff1e0, #3a2711);
  --amber-line: light-dark(#e07b00, #e88f1c);
  --amber-border: light-dark(#f2cf9f, #6b4a1f);
  --green-text: light-dark(#1d6b45, #86d9ad);
  --green-tint: light-dark(#e6f4ec, #13311f);
  --green-line: light-dark(#2e9e66, #3cbf7c);
  --green-border: light-dark(#b4dcc6, #2a5a41);
  --blue-text: light-dark(#0b5c85, #95d3f6);
  --blue-tint: light-dark(#e3f4fc, #11293a);
  --blue-border: light-dark(#b5e3f6, #24506b);
  --closed-text: light-dark(#4a5763, #b5c0ca);
  --closed-tint: light-dark(#eceff1, #27313b);
  /* Text inside the coloured notices */
  --red-dark: light-dark(#6e0026, #ffc6d6);
  --amber-dark: light-dark(#5c2c00, #ffdcb0);
  --blue-dark: light-dark(#063a55, #cbe9fb);
  --green-dark: light-dark(#0f3f27, #bdeed3);
  --tick-border: light-dark(#d3dee8, #33495c);

  --radius-small: 4px;
  --radius: 8px;
  --shadow: 0 1px 2px rgb(0 34 62 / 8%);
  --page-width: 1240px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Liberation Sans", Arial, sans-serif;
}

/* The switch in the header (static/js/theme.js) overrides the operating system. */
:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

/* --- 2. Basics ---------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* The attribute "hidden" always wins, also over classes with their own "display". */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--page);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--navy);
  line-height: 1.25;
}

h1 {
  font-size: 1.625rem;
}

h2 {
  font-size: 1.125rem;
}

h3 {
  font-size: 1rem;
}

p {
  margin: 0;
}

a {
  color: var(--navy-light);
  text-underline-offset: 2px;
}

a:hover {
  color: var(--navy);
}

/* Clearly visible keyboard focus (BITV 2.0): navy line with a light blue halo. */
:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--sky);
}

.muted {
  color: var(--grey-text);
}

.small {
  font-size: 0.875rem;
}

.preserve-lines {
  white-space: pre-line;
}

/* Reference numbers with digits of equal width, so they line up in tables. */
.reference-number {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -100px;
  z-index: 10;
  padding: 8px 16px;
  background: var(--surface);
  color: var(--navy);
  font-weight: 600;
}

.skip-link:focus {
  top: 8px;
}

/* Vertical spacing between the children of a block. */
.stack > * + * {
  margin-top: 20px;
}

.stack-small > * + * {
  margin-top: 8px;
}

/* --- 3. Page layout ----------------------------------------------------- */

.site-header {
  background: var(--header);
  color: #ffffff;
  border-bottom: 3px solid var(--cyan);
}

.site-header-inner,
.site-footer-inner,
.page {
  width: 100%;
  max-width: var(--page-width);
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

.site-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 24px;
  min-height: 60px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  color: inherit;
  text-decoration: none;
}

.brand:hover {
  color: inherit;
}

/* Room for a future logo (templates/includes/logo.html, README). */
.logo {
  display: block;
  flex: none;
  width: 40px;
  height: 40px;
}

.logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-name {
  display: block;
  font-size: 1.25rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  line-height: 1;
}

.brand-subtitle {
  display: block;
  margin-top: 3px;
  font-size: 0.75rem;
  color: var(--sky);
}

.main-nav {
  display: flex;
  align-self: stretch;
  gap: 4px;
}

.main-nav a {
  display: flex;
  align-items: center;
  padding: 0 12px;
  margin-bottom: -3px;
  border-bottom: 3px solid transparent;
  color: rgb(255 255 255 / 85%);
  font-weight: 500;
  text-decoration: none;
}

.main-nav a:hover {
  color: #ffffff;
  background: rgb(255 255 255 / 6%);
}

.main-nav a[aria-current="page"] {
  color: #ffffff;
  border-bottom-color: var(--sky);
}

.account {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  padding: 8px 0;
  font-size: 0.875rem;
}

.account-who {
  text-align: right;
  line-height: 1.3;
}

.account-detail {
  display: block;
  color: var(--sky);
  font-size: 0.75rem;
}

.button-header {
  padding: 6px 12px;
  border: 1px solid rgb(255 255 255 / 55%);
  border-radius: var(--radius-small);
  background: transparent;
  color: #ffffff;
  font: inherit;
  cursor: pointer;
}

.button-header:hover {
  background: rgb(255 255 255 / 10%);
}

.page {
  flex: 1;
  padding-top: 24px;
  padding-bottom: 48px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 20px;
}

.lead {
  max-width: 70ch;
  margin-top: 4px;
  color: var(--grey-text);
}

.breadcrumb {
  margin-bottom: 6px;
  font-size: 0.875rem;
}

.site-footer {
  border-top: 1px solid var(--grey-line);
  background: var(--surface);
}

.site-footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  padding-top: 14px;
  padding-bottom: 14px;
  font-size: 0.875rem;
  color: var(--grey-text);
}

.site-footer a {
  color: var(--grey-text);
}

/* --- 4. Building blocks ------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--grey-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--grey-light);
}

.card-body {
  padding: 20px;
}

.empty {
  padding: 24px 20px;
  color: var(--grey-text);
  text-align: center;
}

/* Buttons. One main action per page; small buttons only in tables and lists. */
.button,
.button-secondary,
.button-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: var(--radius-small);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.button {
  border: 1px solid var(--navy);
  background: var(--navy);
  color: var(--on-navy);
}

.button:hover {
  background: var(--navy-light);
  color: var(--on-navy);
}

.button-secondary {
  border: 1px solid var(--navy);
  background: var(--surface);
  color: var(--navy);
}

.button-secondary:hover {
  background: var(--navy-tint);
  color: var(--navy);
}

.button-danger {
  border: 1px solid var(--red-text);
  background: var(--surface);
  color: var(--red-text);
}

.button-danger:hover {
  background: var(--red-tint);
}

.button-small {
  min-height: 32px;
  padding: 4px 12px;
  font-size: 0.875rem;
}

.button-large {
  min-height: 48px;
  padding: 10px 22px;
  font-size: 1.0625rem;
}

.button-wide {
  width: 100%;
}

.link-button {
  padding: 4px 0;
  border: none;
  background: none;
  color: var(--navy-light);
  font: inherit;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

/* Status of a request (concept 4). The colour repeats the text, never replaces it. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 10px;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.badge-draft {
  border: 1px dashed var(--grey-border);
  background: var(--surface);
  color: var(--grey-text);
}

.badge-requested {
  background: var(--amber-tint);
  color: var(--amber-text);
}

.badge-in_progress {
  background: var(--blue-tint);
  color: var(--blue-text);
}

.badge-dispatched {
  background: var(--green-tint);
  color: var(--green-text);
}

.badge-archived,
.badge-forwarded,
.badge-cancelled {
  background: var(--closed-tint);
  color: var(--closed-text);
}

/* Urgency: a short coloured bar in front of the text. */
.urgency {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.urgency::before {
  content: "";
  flex: none;
  width: 4px;
  height: 1.1em;
  border-radius: 2px;
  background: currentColor;
}

.urgency-immediate {
  color: var(--red-text);
}

.urgency-urgent {
  color: var(--amber-text);
}

.urgency-planned {
  color: var(--grey-text);
  font-weight: 500;
}

/* Notices: alert (call the KOLST, errors), warning (please check), info, success.
   notice-error, -warning, -success and -info also match the levels of Django messages. */
.notice {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid;
  border-radius: var(--radius);
  font-size: 0.9375rem;
}

.notice::before {
  content: "!";
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: var(--on-navy);
  font-size: 0.75rem;
  font-weight: 800;
}

.notice-title {
  display: block;
  font-weight: 700;
}

.notice ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.notice a {
  color: inherit;
}

.notice-alert,
.notice-error {
  border-color: var(--red-border);
  background: var(--red-tint);
  color: var(--red-dark);
}

.notice-alert::before,
.notice-error::before {
  background: var(--red-line);
}

.notice-warning {
  border-color: var(--amber-border);
  background: var(--amber-tint);
  color: var(--amber-dark);
}

.notice-warning::before {
  background: var(--amber-line);
}

.notice-info {
  border-color: var(--blue-border);
  background: var(--sky-tint);
  color: var(--blue-dark);
}

.notice-info::before {
  content: "i";
  background: var(--navy-light);
}

.notice-success {
  border-color: var(--green-border);
  background: var(--green-tint);
  color: var(--green-dark);
}

.notice-success::before {
  content: "✓";
  background: var(--green-line);
}

.messages {
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}

.messages > * + * {
  margin-top: 8px;
}

/* Tables scroll inside their card on narrow screens, the page never does. */
.table-wrap {
  overflow-x: auto;
  /* Keeps visually hidden headings (position: absolute) inside the scroll area. */
  position: relative;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.table th {
  padding: 10px 16px;
  border-bottom: 1px solid var(--grey-line);
  background: var(--page);
  color: var(--grey-text);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--grey-light);
  vertical-align: top;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover {
  background: var(--navy-tint);
}

.table .row-link {
  color: var(--navy);
  font-weight: 650;
  text-decoration: none;
}

.table .row-link:hover {
  text-decoration: underline;
}

.table .sub {
  display: block;
  color: var(--grey-text);
  font-size: 0.8125rem;
}

/* Finished requests are shown weaker than active ones. */
.table tr.is-finished td {
  color: var(--grey-text);
}

/* Definition lists on the detail page. */
.details {
  display: grid;
  grid-template-columns: minmax(140px, 220px) 1fr;
  gap: 8px 20px;
  margin: 0;
}

.details dt {
  color: var(--grey-text);
}

.details dd {
  margin: 0;
}

/* --- 5. Form fields ----------------------------------------------------- */

.fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px 20px;
}

.field {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
}

.field-wide {
  grid-column: 1 / -1;
}

/* Groups of radio buttons are fieldsets; they look like any other field. */
fieldset.field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

fieldset.field > legend {
  margin-bottom: 6px;
  padding: 0;
}

.field > label,
.group-label {
  font-weight: 600;
  font-size: 0.9375rem;
}

.field input:not([type="checkbox"], [type="radio"], [type="hidden"]),
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--grey-border);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: var(--navy-light);
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  outline-offset: 0;
  box-shadow: 0 0 0 4px var(--sky);
}

/* Missing or unreadable: red border and a bar on the left. */
.field-error input,
.field-error select,
.field-error textarea {
  border-color: var(--red-text);
  box-shadow: inset 3px 0 0 var(--red-text);
}

/* Implausible value: warns, does not block (concept 5.4). */
.field-warning input {
  border-color: var(--amber-text);
}

.field-message {
  color: var(--red-text);
  font-size: 0.8125rem;
  font-weight: 600;
}

/* Checkboxes and radio buttons with their label. */
.choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 0;
  cursor: pointer;
}

.choice input {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--navy);
}

.choice.field-error {
  color: var(--red-text);
  font-weight: 600;
}

/* Yes/no questions as a switch with two or three parts. */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--grey-border);
  border-radius: var(--radius-small);
  overflow: hidden;
  background: var(--surface);
}

.segmented label {
  padding: 7px 16px;
  border-left: 1px solid var(--grey-border);
  font-weight: 500;
  cursor: pointer;
}

.segmented label:first-child {
  border-left: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented label:hover {
  background: var(--navy-tint);
}

.segmented label:has(input:checked) {
  background: var(--navy);
  color: var(--on-navy);
}

.segmented label:has(input:focus-visible) {
  outline: 2px solid var(--navy);
  outline-offset: -4px;
  box-shadow: inset 0 0 0 4px var(--sky);
}

.segmented.field-error {
  border-color: var(--red-text);
  box-shadow: inset 3px 0 0 var(--red-text);
}

/* Large choice tiles for the urgency. */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.tiles.field-error .tile {
  border-color: var(--red-text);
}

.tile {
  position: relative;
  display: block;
  padding: 12px 14px 12px 42px;
  border: 1px solid var(--grey-border);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 650;
  cursor: pointer;
}

.tile input {
  position: absolute;
  left: 14px;
  top: 15px;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--navy);
}

.tile:hover {
  border-color: var(--navy-light);
  background: var(--navy-tint);
}

.tile:has(input:checked) {
  border-color: var(--navy);
  box-shadow: inset 0 0 0 1px var(--navy);
  background: var(--navy-tint);
}

.tile:has(input[value="immediate"]:checked) {
  border-color: var(--red-text);
  box-shadow: inset 0 0 0 1px var(--red-text);
  background: var(--red-tint);
  color: var(--red-text);
}

/* --- 6. Pages ----------------------------------------------------------- */

/* Start page without login */
.login {
  display: grid;
  place-items: center;
  padding: 48px 0;
}

.login-card {
  width: 100%;
  max-width: 440px;
  padding: 32px;
  text-align: center;
}

.login-card .logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
}

.login-card h1 {
  letter-spacing: 0.08em;
}

.login-subtitle {
  margin: 4px 0 20px;
  color: var(--grey-text);
}

.login-intro {
  margin-bottom: 20px;
}

.login-fallback {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--grey-light);
  color: var(--grey-text);
  font-size: 0.875rem;
  text-align: left;
}

/* Overview: drafts with their progress */
.draft-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.draft-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--grey-light);
}

.draft-list li:last-child {
  border-bottom: 0;
}

.draft-name {
  min-width: 200px;
  font-weight: 600;
}

.draft-meta {
  flex: 1;
  color: var(--grey-text);
  font-size: 0.875rem;
}

.draft-progress {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--grey-text);
  font-size: 0.8125rem;
}

.draft-progress progress {
  width: 90px;
  height: 6px;
  border: 0;
  border-radius: 3px;
  background: var(--grey-light);
  appearance: none;
}

.draft-progress progress::-webkit-progress-bar {
  border-radius: 3px;
  background: var(--grey-light);
}

.draft-progress progress::-webkit-progress-value {
  border-radius: 3px;
  background: var(--navy-light);
}

.draft-progress progress::-moz-progress-bar {
  border-radius: 3px;
  background: var(--navy-light);
}

/* Request form: sections on the left, status of the draft on the right */
.form-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: start;
}

.form-aside {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 16px;
}

.form-section {
  scroll-margin-top: 16px;
}

.form-section h2 {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Number of a section; a tick once nothing required is missing. */
.step {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--navy-tint);
  color: var(--navy);
  font-size: 0.8125rem;
  font-weight: 700;
}

.step-complete {
  background: var(--green-tint);
  color: var(--green-text);
}

.save-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  font-size: 0.875rem;
}

.save-status::before {
  content: "";
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green-line);
  box-shadow: 0 0 0 3px var(--green-tint);
}

.notices:empty {
  display: none;
}

.section-list {
  margin: 0;
  padding: 8px 16px;
  list-style: none;
}

.section-list a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  color: var(--text);
  font-size: 0.9375rem;
  text-decoration: none;
}

.section-list a:hover {
  color: var(--navy-light);
  text-decoration: underline;
}

.section-list .step {
  width: 22px;
  height: 22px;
  font-size: 0.75rem;
}

.open-count {
  margin-left: auto;
  color: var(--amber-text);
  font-size: 0.75rem;
  font-weight: 600;
}

.fixed-value {
  font-weight: 650;
  color: var(--navy);
}

.chosen-destination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 14px 16px;
  border: 1px solid var(--grey-line);
  border-radius: var(--radius);
  background: var(--page);
}

.chosen-destination > div {
  flex: 1;
  min-width: 200px;
}

.destination-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--grey-line);
  border-radius: var(--radius);
  background: var(--surface);
}

.destination-list li + li {
  border-top: 1px solid var(--grey-light);
}

.destination-list .link-button {
  display: block;
  width: 100%;
  padding: 8px 12px;
  text-decoration: none;
}

.destination-list .link-button:hover {
  background: var(--navy-tint);
}

.destination-hint {
  margin-top: 8px;
  color: var(--grey-text);
  font-size: 0.875rem;
}

/* Areas A to F of the medical section */
.areas {
  display: grid;
  gap: 16px;
}

.area {
  margin: 0;
  padding: 0;
  border: 1px solid var(--grey-line);
  border-radius: var(--radius);
}

.area legend {
  float: left;
  width: 100%;
  padding: 10px 16px;
  border-bottom: 1px solid var(--grey-light);
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--page);
  color: var(--navy);
  font-weight: 650;
}

.area-body {
  clear: both;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0 20px;
  padding: 8px 16px 12px;
}

.area-body > .field {
  padding: 6px 0;
}

/* Fields that only appear when their box or option is chosen (concept 5.2).
   Pure CSS, so no script and no change of the Content Security Policy. */
.dependent,
.subfields {
  display: none;
}

.option-with-subfields:has(> .choice input:checked) {
  grid-column: 1 / -1;
}

.option-with-subfields:has(> .choice input:checked) > .subfields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  align-items: end;
  gap: 8px 16px;
  margin: 2px 0 8px 28px;
  padding: 12px 14px;
  border-left: 3px solid var(--sky);
  border-radius: 0 var(--radius-small) var(--radius-small) 0;
  background: var(--sky-tint);
}

.urgency-block:has(input[value="scheduled"]:checked) .scheduled-at,
.urgency-block:has(#id_transport-is_incubator_transport:checked) .incubator-staff,
.admission:has(input[value="true"]:checked) .admission-by,
.infection:has(input[value="true"]:checked) .infection-details {
  display: block;
}

/* With an incubator team of the sending hospital the medical section is left out. */
.request-form:has(#id_transport-is_incubator_transport:checked) .medical-only {
  display: none;
}

.perfusor-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 10px 16px;
}

.perfusor-rows > * + * {
  margin-top: 10px;
}

/* The buttons stay visible at the bottom while scrolling through the form. */
.form-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  padding: 12px 16px;
  border: 1px solid var(--grey-line);
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface);
  box-shadow: 0 -4px 12px rgb(0 34 62 / 6%);
}

.form-footer-spacer {
  flex: 1;
}

.error-summary {
  margin-bottom: 20px;
  padding: 16px 20px;
  border: 2px solid var(--red-text);
  border-radius: var(--radius);
  background: var(--surface);
}

.error-summary h2 {
  margin-bottom: 8px;
  color: var(--red-text);
}

.error-summary ul {
  margin: 0;
  padding-left: 20px;
}

/* Detail page */
.detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
}

.detail-head h1 {
  font-variant-numeric: tabular-nums;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
}

.route {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
}

.route-end {
  padding: 14px 16px;
  border: 1px solid var(--grey-line);
  border-radius: var(--radius);
  background: var(--page);
}

.route-label {
  color: var(--grey-text);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.route-arrow {
  color: var(--grey-border);
  font-size: 1.5rem;
}

.ticks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ticks li {
  padding: 3px 10px;
  border: 1px solid var(--tick-border);
  border-radius: var(--radius-small);
  background: var(--navy-tint);
  color: var(--navy);
  font-size: 0.875rem;
}

.timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  position: relative;
  padding: 0 0 18px 26px;
}

.timeline li::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 6px;
  width: 12px;
  height: 12px;
  border: 2px solid var(--navy-light);
  border-radius: 50%;
  background: var(--surface);
}

.timeline li::after {
  content: "";
  position: absolute;
  left: 10px;
  top: 20px;
  bottom: 0;
  width: 2px;
  background: var(--grey-line);
}

.timeline li:last-child::after {
  display: none;
}

.timeline li.is-current::before {
  border-color: var(--navy);
  background: var(--navy);
  box-shadow: 0 0 0 3px var(--sky);
}

.timeline-when {
  color: var(--grey-text);
  font-size: 0.8125rem;
}

/* KOLST list ("Anforderungen" for dispatchers, stage 3). */
.card-head h2 .count {
  color: var(--grey-text);
  font-weight: 400;
}

.worklist td {
  vertical-align: middle;
}

/* New, not yet taken over: tinted row and a coloured bar at the start.
   The urgency is also written in its own column: colour never stands alone. */
.worklist tr.is-new td {
  background: var(--red-tint);
}

.worklist tr.is-new td:first-child {
  box-shadow: inset 4px 0 0 var(--red-line);
}

.worklist tr.is-new-urgent td {
  background: var(--amber-tint);
}

.worklist tr.is-new-planned td {
  background: var(--navy-tint);
}

.worklist tr.is-new-urgent td:first-child {
  box-shadow: inset 4px 0 0 var(--amber-line);
}

.worklist tr.is-new-planned td:first-child {
  box-shadow: inset 4px 0 0 var(--grey-border);
}

.worklist .age {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.worklist .age-late {
  color: var(--red-text);
}

.worklist-action {
  text-align: right;
  white-space: nowrap;
}

.worklist-action .inline-form {
  display: inline;
}

.worklist-distance {
  font-variant-numeric: tabular-nums;
}

.worklist-finished > summary {
  cursor: pointer;
  list-style-position: inside;
}

.worklist-finished > summary h2 {
  display: inline;
}

.worklist-finished:not([open]) > summary {
  border-bottom: 0;
}

.worklist-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}

.alarm-off,
.alarm-on {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 650;
  font-size: 0.875rem;
}

/* Red: the alarm cannot sound (concept 12: red for alarm). */
.alarm-off {
  border: 1px solid var(--red-line);
  background: var(--red-tint);
  color: var(--red-text);
}

.alarm-on {
  background: var(--green-tint);
  color: var(--green-text);
}

.live-status {
  color: var(--grey-text);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

/* Status box on the detail page and the form for a change of status. */
.status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-change {
  max-width: 720px;
}

/* fieldset.field sets its margin to 0; keep the space between the questions. */
.status-change .stack > * + * {
  margin-top: 20px;
}

/* Manual entry of faxes and calls (stage 4). */
.search-row {
  display: flex;
  gap: 8px;
}

.search-row input {
  flex: 1;
}

.hospital-results {
  margin: 4px 0 0;
  padding: 0;
  border: 0;
}

/* Suggestion and page "Disponieren" (stage 4). */
.details-compact {
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
}

.details-compact .sub {
  display: block;
  color: var(--grey-text);
  font-size: 0.8125rem;
}

.dispatch-route {
  margin: -8px 0 20px;
}

.dispatch-layout {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: 24px;
  align-items: start;
}

/* fieldset.field sets its margin to 0; keep the space between the questions. */
.dispatch-form.stack > * + * {
  margin-top: 20px;
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0 24px;
}

.vehicle-group {
  margin-top: 8px;
  color: var(--grey-text);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.vehicles-out-of-service {
  margin-top: 8px;
  padding: 8px 12px;
  border: 1px solid var(--grey-line);
  border-radius: var(--radius-small);
}

.vehicles-out-of-service > summary {
  cursor: pointer;
  font-weight: 600;
}

.suggestion strong,
.details-compact strong {
  font-weight: 700;
  color: var(--navy);
}

.suggestion .sub {
  display: block;
  color: var(--grey-text);
  font-size: 0.8125rem;
}

.suggestion .suggestion-uncertain {
  color: var(--amber-text);
  font-weight: 600;
}

.suggestion-alternatives {
  margin: 2px 0 0;
  padding-left: 20px;
}

.suggestion-matrix > summary {
  cursor: pointer;
  color: var(--navy-light);
  font-weight: 600;
}

.suggestion-matrix .table-wrap {
  margin-top: 8px;
}

.matrix th[scope="row"] {
  white-space: nowrap;
}

/* The cell that applies: tinted, framed and named, so colour does not stand alone. */
.matrix td.is-chosen {
  background: var(--sky-tint);
  box-shadow: inset 0 0 0 2px var(--navy);
}

.matrix-chosen {
  display: block;
  color: var(--navy);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* --- Narrow screens ----------------------------------------------------- */

@media (max-width: 960px) {
  .form-layout,
  .detail-layout,
  .dispatch-layout {
    grid-template-columns: 1fr;
  }

  .form-aside {
    position: static;
    order: -1;
  }

  .form-aside .section-list-card {
    display: none;
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: 1.375rem;
  }

  /* Who is logged in stays visible: function accounts share computers. */
  .account {
    order: 2;
    width: 100%;
    justify-content: space-between;
    margin-left: 0;
    padding-top: 0;
  }

  .account-who {
    text-align: left;
  }

  .main-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }

  .main-nav a {
    padding: 10px 12px;
  }

  .card-head {
    padding: 12px 16px;
  }

  .card-body {
    padding: 16px;
  }

  .details {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .details dd {
    margin-bottom: 8px;
  }

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

  .route-arrow {
    justify-self: center;
    transform: rotate(90deg);
  }

  .draft-meta {
    flex-basis: 100%;
  }

  .form-footer {
    position: static;
  }

  .form-footer > * {
    flex: 1 1 100%;
  }

  .form-footer-spacer {
    display: none;
  }
}

/* Banner of a test instance (stage 5a). Red on purpose (Jan, 18.11.2026):
   concept 12 allows red for it. The text always says what it means. */
.test-banner {
  margin: 0;
  padding: 0.4rem 1rem;
  background: var(--test-banner);
  color: #ffffff;
  font-weight: 700;
  text-align: center;
}
