/*
  Alarmplan OÖ - Oberfläche nach Corporate Design OÖLFV (7.1.002_AID_Corporate_Design_Bezirke.pdf)
  CD-Farben: Weiß, Schwarz, Rot RGB 207/65/40, Grau RGB 114/115/117 (70 % Schwarz).
  Headline: Bold Condensed / Arial Bold, Großbuchstaben, 70 % Grau. Lauftext: Arial/Helvetica.
  Drei Darstellungen über data-theme auf <html>: light (Standard), dark, access (barrierefrei).
*/

:root {
  color-scheme: light;
  --bg: #f2f3f3;
  --surface: #ffffff;
  --surface-soft: #f7f7f7;
  --line: #d9d9d9;
  --line-strong: #b9babb;
  --text: #111111;
  --muted: #727375;
  --head: #727375;
  --red: #cf4128;
  --red-hover: #a83322;
  --red-text: #a83322;
  --green: #16734d;
  --amber: #94650d;
  --steel: #4a4b4d;
  --black: #000000;
  --tint-red: #fff0ed;
  --tint-red-line: #efc3ba;
  --tint-green: #eef9f3;
  --tint-amber: #fff7e8;
  --tint-neutral: #edf1f5;
  --tint-steel: #f1f1f1;
  --danger-bg: #fff3f0;
  --danger-line: #e3a092;
  --danger-text: #9d1e1e;
  --field-bg: #ffffff;
  --contrast-bg: #000000;
  --contrast-fg: #ffffff;
  --focus: #cf4128;
  --focus-width: 2px;
  --backdrop: rgba(12, 23, 35, 0.45);
  --map-caption-bg: rgba(255, 255, 255, 0.92);
  --logo-plate: transparent;
  --timeline-neutral: #e7edf2;
  --timeline-done: #dff3e9;
  --timeline-pending: #fff1d8;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  --control-height: 36px;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
}

/* Dunkle Darstellung: CD-Farbwelt auf dunklen Flächen, Rot bleibt Akzent- und Aktionsfarbe. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131416;
  --surface: #1d1f22;
  --surface-soft: #26292d;
  --line: #34373b;
  --line-strong: #4b4f54;
  --text: #f0f0f0;
  --muted: #a7a9ac;
  --head: #b9bbbe;
  --red: #cf4128;
  --red-hover: #de5a41;
  --red-text: #f08b74;
  --green: #59c48f;
  --amber: #e3b566;
  --steel: #b6b8bb;
  --tint-red: rgba(207, 65, 40, 0.16);
  --tint-red-line: rgba(207, 65, 40, 0.5);
  --tint-green: rgba(22, 115, 77, 0.24);
  --tint-amber: rgba(148, 101, 13, 0.26);
  --tint-neutral: rgba(150, 160, 170, 0.16);
  --tint-steel: rgba(155, 155, 155, 0.16);
  --danger-bg: rgba(207, 65, 40, 0.14);
  --danger-line: rgba(207, 65, 40, 0.55);
  --danger-text: #f2937e;
  --field-bg: #26292d;
  --contrast-bg: #f0f0f0;
  --contrast-fg: #131416;
  --focus: #f08b74;
  --backdrop: rgba(0, 0, 0, 0.62);
  --map-caption-bg: rgba(29, 31, 34, 0.92);
  --logo-plate: #ffffff;
  --timeline-neutral: rgba(150, 160, 170, 0.18);
  --timeline-done: rgba(22, 115, 77, 0.26);
  --timeline-pending: rgba(148, 101, 13, 0.28);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Barrierefreie Darstellung: hohe Kontraste (WCAG 2.2 / AAA-orientiert), größere Schrift,
   deutliche Fokusrahmen, größere Bedienflächen, keine Farbinformation ohne Textzeichen. */
:root[data-theme="access"] {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #ffffff;
  --line: #000000;
  --line-strong: #000000;
  --text: #000000;
  --muted: #3a3a3a;
  --head: #2f2f2f;
  --red: #9d1e1e;
  --red-hover: #7c1717;
  --red-text: #9d1e1e;
  --green: #0c5132;
  --amber: #6b4a00;
  --steel: #1f1f1f;
  --tint-red: #ffe4de;
  --tint-red-line: #9d1e1e;
  --tint-green: #e4f5ec;
  --tint-amber: #fdf0d5;
  --tint-neutral: #eef0f2;
  --tint-steel: #ececec;
  --danger-bg: #ffffff;
  --danger-line: #9d1e1e;
  --danger-text: #9d1e1e;
  --field-bg: #ffffff;
  --contrast-bg: #000000;
  --contrast-fg: #ffffff;
  --focus: #000000;
  --focus-width: 3px;
  --backdrop: rgba(0, 0, 0, 0.7);
  --map-caption-bg: #ffffff;
  --logo-plate: transparent;
  --timeline-neutral: #eef0f2;
  --timeline-done: #e4f5ec;
  --timeline-pending: #fdf0d5;
  --shadow: none;
  --control-height: 44px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 1040px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

:root[data-theme="access"] body {
  font-size: 17px;
  line-height: 1.6;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a.link-button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  min-height: var(--control-height);
  padding: 0 12px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

button:hover,
a.link-button:hover {
  border-color: var(--red);
}

button.primary {
  background: var(--red);
  border-color: var(--red);
  color: #ffffff;
}

button.primary:hover {
  background: var(--red-hover);
  border-color: var(--red-hover);
}

button.secondary {
  background: var(--surface-soft);
}

button.danger {
  background: var(--danger-bg);
  border-color: var(--danger-line);
  color: var(--danger-text);
}

button:focus-visible,
a.link-button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: var(--focus-width) solid var(--focus);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

:root[data-theme="access"] button,
:root[data-theme="access"] a.link-button,
:root[data-theme="access"] select,
:root[data-theme="access"] input,
:root[data-theme="access"] textarea {
  border-width: 2px;
}

:root[data-theme="access"] a:not(.link-button) {
  text-decoration: underline;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 292px 1fr;
}

.sidebar {
  position: relative;
  background: var(--surface);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  border-right: 1px solid var(--line);
}

/* Rotes Schrägelement in Anlehnung an die dynamischen CD-Stilelemente */
.sidebar::before {
  content: "";
  position: absolute;
  top: 0;
  left: -22px;
  width: 210px;
  height: 7px;
  background: var(--red);
  transform: skewX(-30deg);
  transform-origin: left top;
}

.brand {
  height: 92px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 22px 20px 16px;
  border-bottom: 1px solid var(--line);
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  color: var(--text);
  font-size: 20px;
  line-height: 1.1;
  text-transform: uppercase;
  font-weight: 700;
}

.brand .brand-kicker {
  margin-bottom: 5px;
  color: var(--red-text);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.nav {
  padding: 14px 10px;
  display: grid;
  gap: 4px;
}

.nav button {
  justify-content: flex-start;
  width: 100%;
  border-color: transparent;
  color: var(--text);
  background: transparent;
  border-left: 4px solid transparent;
  min-height: 42px;
}

.nav button.active {
  color: var(--text);
  background: var(--tint-red);
  border-color: var(--red);
  font-weight: 700;
}

:root[data-theme="access"] .nav button {
  min-height: 48px;
}

.nav .nav-icon {
  width: 36px;
  text-align: center;
  color: var(--red-text);
  font-size: 24px;
  line-height: 1;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding: 16px;
  border-top: 1px solid var(--line);
}

.sidebar-footer .link-button {
  color: var(--contrast-fg);
  background: var(--contrast-bg);
  border-color: var(--contrast-bg);
}

.workspace {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: relative;
  min-height: 92px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 28px;
}

.topbar::after {
  content: "";
  position: absolute;
  right: 28px;
  bottom: -1px;
  width: 170px;
  height: 5px;
  background: var(--red);
  transform: skewX(-30deg);
  transform-origin: right bottom;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--red-text);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

/* CD-Headline: Bold (Condensed), Großbuchstaben, 70 % Grau */
h1,
h2,
h3 {
  font-family: "Helvetica Neue Condensed", "Arial Narrow", Arial, sans-serif;
  color: var(--head);
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
  margin-bottom: 12px;
}

h3 {
  font-size: 14px;
  line-height: 1.25;
  margin-bottom: 10px;
}

:root[data-theme="access"] h1 {
  font-size: 32px;
}

:root[data-theme="access"] h2 {
  font-size: 21px;
}

:root[data-theme="access"] h3 {
  font-size: 17px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
  flex-wrap: wrap;
}

.contextbar {
  display: flex;
  align-items: end;
  gap: 10px;
}

/* Logo laut CD rechtsbündig, unverändert, mit Freiraum; Umschalter direkt darunter rechts oben. */
.topbar-brand {
  min-width: 176px;
  display: grid;
  justify-items: end;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.topbar-brand img {
  width: 168px;
  height: 48px;
  object-fit: contain;
  display: block;
  background: var(--logo-plate);
  border-radius: 4px;
  padding: 2px 4px;
  box-shadow: none;
}

/* Umschalter Hell / Dunkel / Barrierefrei */
.theme-switch {
  display: inline-flex;
  align-items: stretch;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-soft);
}

.theme-switch button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
}

.theme-switch button:hover {
  color: var(--text);
  border-color: var(--red);
}

.theme-switch button[aria-pressed="true"] {
  background: var(--red);
  border-color: var(--red);
  color: #ffffff;
}

.theme-switch .lbl {
  display: none;
}

:root[data-theme="access"] .theme-switch {
  border-width: 2px;
  border-radius: 10px;
}

:root[data-theme="access"] .theme-switch button {
  min-height: 40px;
  border-radius: 8px;
  font-size: 15px;
}

:root[data-theme="access"] .theme-switch .lbl {
  display: inline;
}

/* CD-Stilelement "Tag": rote Leiste mit www.ooelfv.at am rechten Rand, von unten lesbar */
.cd-tag {
  position: fixed;
  right: 0;
  bottom: 44px;
  z-index: 30;
  background: var(--red);
  color: #ffffff;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  padding: 16px 7px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  pointer-events: none;
}

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

:root[data-theme="access"] label {
  font-size: 15px;
  color: var(--text);
}

select,
input,
textarea {
  border: 1px solid var(--line-strong);
  background: var(--field-bg);
  color: var(--text);
  min-height: var(--control-height);
  border-radius: 6px;
  padding: 6px 9px;
}

textarea {
  resize: vertical;
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 19px;
}

:root[data-theme="access"] .icon-button {
  width: 44px;
}

.content {
  padding: 24px 28px 34px;
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.layout-grid.equal {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

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

.panel-header {
  min-height: 58px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-header h2,
.panel-header h3 {
  margin: 0;
}

.panel-body {
  padding: 16px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

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

.metric {
  min-height: 94px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  align-content: space-between;
  box-shadow: var(--shadow);
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  font-size: 60px;
  line-height: 1;
  color: #cf4128;
}

/* Kennzahl 0 wird bewusst zurückhaltend grau dargestellt. */
.metric strong.metric-zero {
  color: var(--steel);
}

:root[data-theme="access"] .metric span {
  font-size: 15px;
}

.table-wrap {
  overflow: auto;
  max-height: 520px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

:root[data-theme="access"] table {
  font-size: 16px;
}

:root[data-theme="access"] th {
  font-size: 14px;
  color: var(--text);
  border-bottom: 2px solid var(--line);
}

tbody tr {
  cursor: default;
}

tbody tr.selectable:hover,
tbody tr.selected {
  background: var(--tint-red);
}

:root[data-theme="access"] tbody tr.selected {
  outline: 2px solid var(--red);
  outline-offset: -2px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.status-pill.green {
  color: var(--green);
  background: var(--tint-green);
}

.status-pill.red {
  color: var(--red-text);
  background: var(--tint-red);
}

.status-pill.amber {
  color: var(--amber);
  background: var(--tint-amber);
}

.status-pill.validated {
  color: var(--steel);
  background: var(--tint-steel);
}

.status-pill.neutral {
  color: var(--steel);
  background: var(--tint-neutral);
}

:root[data-theme="access"] .status-pill {
  font-size: 14px;
  font-weight: 700;
  border-width: 2px;
}

/* Barrierefrei: Status zusätzlich als Zeichen, nicht nur über Farbe */
:root[data-theme="access"] .status-pill.green::before {
  content: "✓\00a0";
}

:root[data-theme="access"] .status-pill.red::before {
  content: "✕\00a0";
}

:root[data-theme="access"] .status-pill.amber::before {
  content: "!\00a0";
}

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

.list-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
}

.list-item strong,
.list-item span {
  display: block;
}

.list-item span {
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px;
}

:root[data-theme="access"] .list-item span {
  font-size: 15px;
}

.detail-stack {
  display: grid;
  gap: 14px;
}

.plan-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.timeline {
  display: grid;
  gap: 10px;
  counter-reset: steps;
}

.timeline-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: start;
}

.timeline-item::before {
  counter-increment: steps;
  content: counter(steps);
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--timeline-neutral);
  color: var(--steel);
  font-weight: 700;
}

.timeline-item.done::before {
  background: var(--timeline-done);
  color: var(--green);
}

.timeline-item.pending::before {
  background: var(--timeline-pending);
  color: var(--amber);
}

:root[data-theme="access"] .timeline-item::before {
  border: 2px solid currentColor;
}

.map-box {
  height: 300px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eeeeee;
  overflow: hidden;
  position: relative;
}

/* Nur die statische Fallback-SVG direkt im Kartenrahmen strecken -
   Leaflets Overlay-SVG (.leaflet-pane svg) muss unangetastet bleiben. */
.map-box > svg {
  width: 100%;
  height: 100%;
  display: block;
}

.map-caption {
  position: absolute;
  left: 12px;
  bottom: 12px;
  background: var(--map-caption-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--steel);
  pointer-events: none;
  z-index: 500;
}

/* Echter Kartenausschnitt (Leaflet) mit den fünf Kartenlayern */
.map-box .geo-map {
  width: 100%;
  height: 100%;
  background: #eeeeee;
}

/* Einsatzzonenbestand: volle Breite, links Karte, rechts Tabelle */
.zones-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(440px, 1.15fr);
  gap: 16px;
  align-items: start;
}

.zones-map-box {
  height: 600px;
  min-height: 600px;
}

.zones-table-col .table-wrap {
  max-height: 600px;
}

.zones-table-col th,
.zones-table-col td {
  padding: 8px 8px;
}

@media (max-width: 1100px) {
  .zones-split {
    grid-template-columns: 1fr;
  }
}

.map-note {
  position: absolute;
  top: 12px;
  left: 56px;
  right: 12px;
  max-width: 480px;
  background: var(--map-caption-bg);
  border: 1px solid var(--line);
  border-left: 4px solid #cf4128;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--steel);
  pointer-events: none;
  z-index: 500;
}

:root[data-theme="dark"] .leaflet-control-zoom a,
:root[data-theme="dark"] .leaflet-control-attribution {
  background: #1d1f22;
  color: #e8eaed;
}

:root[data-theme="dark"] .leaflet-control-attribution a {
  color: #9fc3ff;
}

/* --- Alarmplan-Cockpit ------------------------------------------------- */

.cockpit-header .cockpit-title h2 {
  margin: 0;
}

.cockpit-header select {
  max-width: 340px;
}

.cockpit-stepper {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stepper-step {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 180px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.stepper-step .step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--line);
  font-weight: 700;
  flex: 0 0 auto;
}

.stepper-step .step-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.stepper-step .step-text span:last-child {
  font-size: 12px;
  color: var(--steel);
}

.stepper-step.active {
  border-color: #cf4128;
}

.stepper-step.active .step-number {
  border-color: #cf4128;
  background: #cf4128;
  color: #ffffff;
}

.stepper-step.done .step-number {
  border-color: #16734d;
  color: #16734d;
}

.matrix-section h4 {
  margin: 14px 0 6px;
}

.matrix-section h4 .matrix-icon {
  display: inline-block;
  width: 24px;
  margin-right: 6px;
  text-align: center;
  color: var(--red-text);
  font-size: 17px;
  line-height: 1;
}

.content-divider {
  border: none;
  border-top: 1px solid var(--line);
  /* Der detail-stack setzt 14px Gap; die negativen Margins reduzieren den sichtbaren Abstand. */
  margin: -8px 0;
}

.matrix-table {
  table-layout: fixed;
}

.matrix-table th:nth-child(1) {
  width: 10%;
}

.matrix-table th:nth-child(2) {
  width: 54%;
}

.matrix-table th:nth-child(3) {
  width: 18%;
}

.matrix-table th:nth-child(4) {
  width: 18%;
}

.matrix-table td {
  vertical-align: top;
}

.matrix-level {
  white-space: nowrap;
  width: 70px;
}

.matrix-units {
  min-width: 260px;
}

.matrix-ampel {
  white-space: nowrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  margin: 2px 4px 2px 0;
  background: var(--timeline-neutral);
  font-size: 13px;
}

.chip .chip-sub {
  color: var(--steel);
  font-size: 12px;
}

.chip-added {
  border-color: #16734d;
  background: var(--timeline-done);
}

.chip-removed {
  border-color: var(--red-text);
  text-decoration: line-through;
  opacity: 0.75;
}

.chip-remove {
  border: 0;
  background: transparent;
  color: var(--red-text);
  font-weight: 700;
  cursor: pointer;
  padding: 0 2px;
  font-size: 14px;
  line-height: 1;
}

.cell-add {
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--steel);
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
  font-size: 13px;
}

.cell-add:hover {
  border-color: var(--red);
  color: var(--red-text);
}

.cell-add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.cell-add-form select {
  max-width: 220px;
}

.ampel {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  vertical-align: middle;
}

.ampel.ok { background: var(--green); }
.ampel.fail { background: var(--red); }
.ampel.none, .ampel.neutral { background: var(--line); }

.ampel-missing {
  display: inline-block;
  vertical-align: top;
  color: var(--red-text);
  font-size: 12px;
  line-height: 1.5;
}

/* Bei mehrzeiliger Anforderungsliste bleibt die Ampel an der ersten Zeile ausgerichtet. */
.matrix-ampel .ampel {
  vertical-align: top;
  margin-top: 3px;
}

.cap {
  display: inline-block;
  min-width: 44px;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

.cap-low {
  color: #a83322;
  font-weight: 700;
}

.cockpit-assign {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr);
  gap: 16px;
  align-items: start;
}

@media (max-width: 1100px) {
  .cockpit-assign {
    grid-template-columns: 1fr;
  }
}

.cockpit-map-box {
  height: 260px;
}

.suggest-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 12px;
  background: var(--tint-steel);
}

.suggest-panel h4 {
  margin: 0 0 8px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.filter-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  padding: 3px 10px;
  cursor: pointer;
  font-size: 13px;
}

.filter-chip.active {
  border-color: var(--red);
  color: var(--red-text);
  font-weight: 700;
}

.suggest-bucket h5 {
  margin: 10px 0 4px;
  color: var(--red-text);
}

.suggest-table {
  font-size: 12px;
}

.suggest-table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--line);
}

.suggest-name {
  font-weight: 700;
  white-space: nowrap;
}

.suggest-meta {
  color: var(--steel);
}

.suggest-min {
  white-space: nowrap;
  text-align: right;
  color: var(--steel);
}

.suggest-item[data-suggest-unit] {
  cursor: pointer;
}

.suggest-item[data-suggest-unit]:hover td {
  background: var(--tint-red);
  color: var(--red-text);
}

.suggest-item.planned {
  opacity: 0.55;
  cursor: not-allowed;
}

.instance-progress {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.instance-step {
  flex: 1 1 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.instance-step .instance-icon {
  font-weight: 700;
}

.instance-step.done { border-color: #16734d; }
.instance-step.done .instance-icon { color: #16734d; }
.instance-step.current { border-color: #cf4128; box-shadow: 0 0 0 2px rgba(207, 65, 40, 0.15); }
.instance-step.current .instance-icon { color: #cf4128; }
.instance-step.rejected { border-color: #a83322; }
.instance-step.rejected .instance-icon { color: #a83322; }
.instance-step.waiting { opacity: 0.75; }

.frist {
  font-size: 12px;
  font-weight: 700;
}

.frist.warn { color: #94650d; }
.frist.danger { color: #a83322; }
.frist.neutral { color: var(--steel); }

.decision-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border: 1px solid #cf4128;
  border-radius: 8px;
  padding: 10px 14px;
}

.diff-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.diff-only-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--steel);
}

.row-changed {
  background: rgba(207, 65, 40, 0.05);
}

.comment-thread {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.comment-thread h4 {
  margin: 0 0 8px;
}

.comment-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  padding: 6px 0;
}

.comment-item:last-of-type {
  border-bottom: 0;
}

.comment-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: flex-start;
}

.comment-form textarea {
  flex: 1;
}

.cockpit-banner {
  border: 1px solid var(--line);
  border-left: 4px solid #cf4128;
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 12px;
}

.small {
  font-size: 12px;
}

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

.form-grid .wide {
  grid-column: span 2;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 28px;
  display: grid;
  gap: 6px;
  text-align: center;
  color: var(--muted);
  background: var(--surface-soft);
}

.empty-state strong {
  color: var(--text);
}

.toast {
  margin: 14px 28px 0;
  padding: 10px 12px;
  background: var(--tint-red);
  color: var(--red-text);
  border: 1px solid var(--tint-red-line);
  border-radius: 8px;
  font-weight: 600;
}

.toast.error {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: var(--danger-line);
}

:root[data-theme="access"] .toast {
  border-width: 2px;
}

.dialog {
  width: min(520px, calc(100vw - 40px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.wide-dialog {
  width: min(920px, calc(100vw - 40px));
}

.dialog::backdrop {
  background: var(--backdrop);
}

.dialog form {
  display: grid;
  gap: 14px;
}

.dialog-actions {
  display: flex;
  justify-content: end;
  gap: 8px;
}

.mono {
  font-family: Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

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

.nowrap {
  white-space: nowrap;
}

/* Anmeldegate: verdeckt die Anwendung vollständig, bis die Anmeldung erfolgt ist. */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

/* display:flex würde sonst das hidden-Attribut (UA-Stylesheet) übersteuern. */
.login-screen[hidden] {
  display: none;
}

.login-card {
  display: grid;
  gap: 10px;
  width: 340px;
  max-width: 100%;
  padding: 28px 26px;
  border: 1px solid var(--line);
  border-radius: 10px;
  border-top: 5px solid var(--red);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card h2 {
  margin: 0;
}

.login-card p {
  margin: 0 0 6px;
}

.login-logo {
  height: 46px;
  width: auto;
  justify-self: start;
  background: var(--logo-plate);
  border-radius: 4px;
}

.login-card input {
  width: 100%;
}

.login-error {
  color: var(--danger-text);
  font-weight: 700;
}

:root[data-theme="access"] .login-card {
  border-width: 2px;
  border-top-width: 6px;
}

/* Barrierefrei: größere Bedienflächen (WCAG 2.5.8 Zielgröße), Zustände zusätzlich
   über Textzeichen statt nur Farbe (WCAG 1.4.1), lesbare Vorschlagsliste. */
:root[data-theme="access"] .filter-chip {
  font-size: 15px;
  padding: 4px 14px;
}

:root[data-theme="access"] .filter-chip.active::before {
  content: "✓\00a0";
}

:root[data-theme="access"] .chip-remove {
  min-width: 28px;
  font-size: 18px;
}

:root[data-theme="access"] .cell-add {
  font-size: 15px;
}

:root[data-theme="access"] .suggest-table td {
  padding: 9px 10px;
}

:root[data-theme="access"] .ampel {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

:root[data-theme="access"] .ampel.ok::after {
  content: "✓";
}

:root[data-theme="access"] .ampel.fail::after {
  content: "✕";
}

:root[data-theme="access"] .ampel.none::after,
:root[data-theme="access"] .ampel.neutral::after {
  content: "–";
}

/* Bewegung reduzieren: Systemeinstellung respektieren, im Barrierefrei-Modus immer */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

:root[data-theme="access"] *,
:root[data-theme="access"] *::before,
:root[data-theme="access"] *::after {
  transition: none !important;
  animation: none !important;
}

@media (max-width: 1180px) {
  body {
    min-width: 980px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .layout-grid,
  .layout-grid.equal {
    grid-template-columns: 1fr;
  }
}
