:root {
  --bg: #e8edf5;
  --panel: #ffffff;
  --header: #163e65;
  --header-accent: #00633a;
  --text: #000000;
  --muted-text: #566068;
  --line: #cfdce5;
  --focus: #76a4d7;
  --danger: #c00022;
  --ok: #00aa84;
  --warn: #ffe70e;
  --over: #9bc6de;
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.app-header {
  background: var(--header);
  color: #ffffff;
  padding: 1.2rem 1.4rem;
  border-bottom: 3px solid #002266;
}

.app-header h1 {
  margin: 0;
  font-size: 1.6rem;
}

.app-header p {
  margin: 0.2rem 0 0;
  opacity: 0.9;
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
}

.brand-logo {
  max-width: 28vw;
  height: 3.2rem;
  object-fit: contain;
  background: #ffffff;
  border-radius: 6px;
  padding: 0.25rem 0.45rem;
}

.module-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.module-logo {
  height: 2.6rem;
  max-width: 11rem;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.2rem 0.35rem;
}

.module-title h2 {
  margin: 0;
}

.header-actions {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

#logout {
  margin-left: auto;
}

.current-user {
  font-weight: 600;
  opacity: 0.95;
}

.auth-layout {
  min-height: calc(100vh - 180px);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.auth-panel {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
}

.auth-logo {
  display: block;
  width: min(260px, 72%);
  height: auto;
  margin: 0 auto 0.9rem;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}

.auth-tabs button {
  min-height: 2.4rem;
  padding-inline: 0.45rem;
}

.auth-tabs button.active {
  background: #1144aa;
}

.auth-form {
  display: grid;
  gap: 0.75rem;
}

.layout {
  padding: 1rem;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  flex-wrap: wrap;
  padding: 0.85rem 1rem;
  color: var(--muted-text);
  border-top: 1px solid var(--line);
  background: #ffffff;
  font-size: 0.9rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.9rem;
}

.panel-full {
  width: 100%;
}

.panel h2 {
  margin: 0 0 0.8rem;
  font-size: 1.1rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.filter-panel {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem 0.8rem;
  margin: 0.2rem 0 0.8rem;
  padding: 0.65rem 0.75rem;
  background: #e8edf5;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.filter-panel label {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  min-width: auto;
  white-space: nowrap;
}

.filter-panel input,
.filter-panel select {
  min-width: 0;
  padding: 0.34rem 0.45rem;
}

#jahr-filter,
#filter-kw,
#filter-alarm {
  width: 4.8rem;
}

#filter-datum-von,
#filter-datum-bis {
  width: 7.2rem;
}

#filter-anlass {
  width: 14rem;
}

#filter-dienstbereich {
  width: 15rem;
}

.filter-actions {
  display: flex;
  gap: 0.5rem;
}

.collapsible-section {
  margin: 0 0 0.8rem;
}

.collapsible-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #163e65;
  color: #ffffff;
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font-weight: 700;
}

.collapsible-toggle::after {
  content: "Ausblenden";
  font-weight: 500;
  font-size: 0.85rem;
  opacity: 0.9;
}

.collapsible-section.collapsed .collapsible-toggle::after {
  content: "Einblenden";
}

.collapsible-section.collapsed .collapsible-content {
  display: none;
}

.statistic {
  margin: 0.45rem 0 0;
  padding: 0.75rem;
  background: #e8edf5;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.statistic h2 {
  margin: 0 0 0.65rem;
}

.statistic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.statistic-card {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.statistic-card span {
  color: var(--muted-text);
  font-size: 0.9rem;
}

.statistic-card strong {
  font-size: 1.08rem;
  color: #163e65;
  white-space: nowrap;
}

.statistic-table-wrapper {
  overflow-x: auto;
}

.statistic-table {
  min-width: 720px;
  font-size: 0.92rem;
}

.statistic-table th {
  position: static;
}

.statistic-table td,
.statistic-table th {
  padding: 0.42rem 0.55rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
}

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

input,
textarea,
select {
  border: 1px solid #9bc6de;
  border-radius: 6px;
  padding: 0.45rem 0.55rem;
  background: #ffffff;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--focus);
  border-color: var(--focus);
}

.actions,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

td .inline-actions {
  flex-wrap: nowrap;
}

td .inline-actions button {
  white-space: nowrap;
}

.absage-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  white-space: nowrap;
  background: transparent;
  border: 0;
  padding: 0;
}

.absage-toggle input[type="checkbox"] {
  margin: 0;
}

button {
  border: 1px solid #0c357f;
  border-radius: 6px;
  padding: 0.48rem 0.85rem;
  cursor: pointer;
  background: #1144aa;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.24);
  transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.08s ease;
}

button.secondary {
  background: #174a78;
  border-color: #0f3453;
}

button:hover {
  background: #0d3890;
  border-color: #072d78;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
}

button.secondary:hover {
  background: #1f5f98;
  border-color: #0f3453;
}

button.active {
  background: #00633a;
  border-color: #004f2f;
}

button:active {
  transform: translateY(1px);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0.2);
}

button:focus-visible {
  outline: 3px solid #9bc6de;
  outline-offset: 2px;
}

button.icon-button {
  width: 2.25rem;
  min-width: 2.25rem;
  height: 2.25rem;
  display: inline-grid;
  place-items: center;
  padding-inline: 0;
  line-height: 1;
  margin: .3rem;
}

button.icon-button svg {
  width: 1.1rem;
  height: 1.1rem;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#add-einsatz {
  margin-right: 0.45rem;
  background: #163e65;
  border-color: #0f3453;
}

#add-einsatz:hover {
  background: #245685;
  border-color: #0f3453;
}

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

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

thead th {
  background: #163e65;
  color: #ffffff;
  font-weight: 600;
  text-align: left;
  padding: 0.55rem;
  border-right: 1px solid #002266;
  position: sticky;
  top: 0;
}

.sort-button {
  width: 100%;
  min-height: 2rem;
  padding: 0.1rem 1.1rem 0.1rem 0;
  background: #163e65;
  color: inherit;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  text-align: left;
  position: relative;
}

.sort-button:hover {
  background: #245685;
}

.sort-button:focus-visible {
  outline: 2px solid #9bc6de;
  outline-offset: -2px;
}

.sort-button::after {
  content: "";
  position: absolute;
  right: 0.1rem;
  opacity: 0.55;
}

.sort-button.active[data-direction="asc"]::after {
  content: "▲";
}

.sort-button.active[data-direction="desc"]::after {
  content: "▼";
}

tbody td,
tfoot td {
  border-top: 1px solid #cfdce5;
  border-right: 1px solid #cfdce5;
  padding: 0.42rem 0.5rem;
  vertical-align: top;
  background: #ffffff;
}

tbody tr:nth-child(even) td {
  background: #e8edf5;
}

.eingabe-zeile td {
  background: #cfdce5;
}

.eingabe-zeile input {
  width: 100%;
  min-width: 64px;
  padding: 0.3rem 0.4rem;
}

.display-wert {
  display: inline-block;
  min-width: 44px;
  font-weight: 600;
  color: #163e65;
  padding: 0.28rem 0.1rem;
}

.cell-center {
  text-align: center;
}

.cell-center input[type="checkbox"] {
  width: auto;
  min-width: auto;
  transform: scale(1.1);
}

.empty-row {
  text-align: center;
  color: var(--muted-text);
  font-weight: 600;
  padding: 1rem !important;
}

.wochentag-cell {
  font-weight: 700;
  text-align: center;
}

.tag-mo {
  background: #ffe70e !important;
}

.tag-di {
  background: #00aa84 !important;
  color: #000000;
}

.tag-mi {
  background: #9bc6de !important;
}

.tag-do {
  background: #9185be !important;
  color: #000000;
}

.tag-fr {
  background: #f9b943 !important;
}

.tag-sa {
  background: #c39563 !important;
  color: #000000;
}

.tag-so {
  background: #f5b4cb !important;
}

.row-selected td {
  background: #9bc6de !important;
}

.detail-row td {
  background: #e8edf5 !important;
  padding: 0.75rem;
}

.detail-panel {
  display: grid;
  gap: 0.9rem;
}

.detail-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.7rem;
}

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

.detail-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.7rem;
}

.detail-table-wrapper {
  background: #ffffff;
}

.dienstbereiche-detail-table {
  min-width: 960px;
}

.dienstbereich-name {
  text-align: center;
}

.detail-subhead th {
  background: #002a80;
  color: #ffffff;
  text-align: center;
}

.dienstbereiche-detail-table td input,
.dienstbereiche-detail-table td textarea {
  width: 100%;
}

.dienstbereiche-detail-table .detail-kraft-input {
  width: 3.6rem !important;
  min-width: 3.6rem !important;
  padding: 0.35rem 0.25rem;
  text-align: center;
  display: block;
  margin: 0 auto;
}

.dienstbereich-einsaetze-table {
  min-width: 1100px;
}

.dienstbereich-einsaetze-table .date-cell {
  min-width: 7.5rem;
  white-space: nowrap;
}

.dienstbereich-einsaetze-table .number-cell {
  text-align: center;
}

.dienstbereich-einsaetze-table textarea {
  min-width: 16rem;
  width: 100%;
  min-height: 4rem;
}

textarea.auto-grow-textarea {
  overflow-y: hidden;
  resize: none;
}

.bemerkung-cell {
  white-space: pre-wrap;
}

.dienstbereich-einsaetze-table .kraefte-text-cell textarea {
  background: transparent;
}

.detail-text-row td {
  vertical-align: top;
}

.dienstbereiche-detail-table textarea.freitext-ok {
  background: var(--ok);
  color: #000000;
}

.dienstbereiche-detail-table textarea.freitext-warn {
  background: var(--warn);
}

.dienstbereiche-detail-table textarea.freitext-over {
  background: var(--over);
}

.hinweis {
  margin: 0;
  padding: 0.7rem 0.8rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #e8edf5;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: #002266;
  color: #ffffff;
  padding: 0.75rem 0.95rem;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: 0.2s ease;
  max-width: 320px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: var(--danger);
}

tbody td.mengen-ok {
  background: var(--ok) !important;
  color: #000000;
}

tbody td.mengen-warn {
  background: var(--warn) !important;
}

tbody td.mengen-over {
  background: var(--over) !important;
}

tbody tr.einsatz-abgesagt td:not(:last-child) {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  text-decoration-color: var(--danger);
  color: var(--muted-text);
}

.modal {
  position: fixed;
  inset: 0;
  background: #002266;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 40;
}

.modal.hidden {
  display: none;
}

.modal-content {
  width: min(980px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: #ffffff;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 0.9rem;
}

.einsatz-modal-content {
  width: calc(100vw - 2rem);
  width: calc(100dvw - 2rem);
  max-width: none;
  height: calc(100vh - 2rem);
  height: calc(100dvh - 2rem);
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
}

.users-modal-content {
  width: min(1220px, 100%);
}

.dienstbereich-einsaetze-modal-content {
  width: min(1220px, 100%);
}

.einsatz-dialog-grid {
  margin: 0.8rem 0;
}

.einsatz-detail-container {
  margin: 0.9rem 0;
}

.dienstbereich-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 0.7rem;
  align-items: end;
  margin-bottom: 0.7rem;
}

.user-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr)) auto;
  gap: 0.7rem;
  align-items: end;
  margin-bottom: 0.7rem;
}

@media (max-width: 720px) {
  .filter-panel label,
  .filter-panel input,
  .filter-panel select,
  #filter-anlass,
  #filter-dienstbereich {
    width: 100%;
  }

  .filter-panel label {
    justify-content: space-between;
  }

  .dienstbereich-form {
    grid-template-columns: 1fr;
  }

  .user-form {
    grid-template-columns: 1fr;
  }

  .detail-panel-header {
    align-items: stretch;
  }
}

.app-header .header-actions button {
  min-height: 2.2rem;
}

.app-header .header-actions button.secondary {
  background: #ffffff;
  color: #163e65;
  border-color: #0e375d;
}

.app-header .header-actions button.secondary:hover {
  background: #e8edf5;
  color: #0f3352;
}
