:root {
  --bg:      #f4f6f8;
  --card:    #fff;
  --ink:     #1f2a37;
  --muted:   #6b7280;
  --line:    #e5e7eb;
  --brand:   #0e7490;
  --brand2:  #155e75;
  --accent:  #0891b2;
  --ok:      #047857;
  --closed:  #b91c1c;
  --planned: #92400e;
  --chip:    #ecfeff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

/* ── HEADER ── */
header {
  background: linear-gradient(90deg, var(--brand2), var(--accent));
  color: #fff;
  padding: 18px 24px;
  position: relative;
}
header h1 { font-size: 20px; margin: 0; letter-spacing: 0.3px; }
header .sub { opacity: 0.85; font-size: 12px; margin-top: 3px; }
.user-info-wrap {
  position: absolute;
  top: 18px;
  right: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.user-info {
  font-size: 12px;
  opacity: 0.9;
}
#logoutBtn {
  background: transparent;
  border: 1px solid rgba(255,255,255,.4);
  color: #fff;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}
#logoutBtn:hover { background: rgba(255,255,255,.15); }

/* ── NAV ── */
nav {
  display: flex;
  gap: 2px;
  background: var(--brand2);
  padding: 0 16px;
  flex-wrap: wrap;
}
nav button {
  background: transparent;
  border: 0;
  color: #cffafe;
  padding: 11px 16px;
  font-size: 13px;
  border-bottom: 3px solid transparent;
  cursor: pointer;
}
nav button.active {
  color: #fff;
  border-bottom-color: #fff;
  font-weight: 600;
}
nav button:hover:not(:disabled) { color: #fff; }
nav button:disabled { opacity: 0.4; cursor: default; }

.global-search {
  margin-left: auto;
  align-self: center;
}
.global-search input {
  width: 220px;
  padding: 7px 11px;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 8px;
  font-size: 13px;
  background: rgba(255,255,255,.12);
  color: #fff;
}
.global-search input::placeholder { color: #cffafe; }
.global-search input:focus { background: #fff; color: var(--ink); outline: none; }

.type-tag {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--chip);
  color: var(--brand2);
}

/* ── LOGIN ── */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 110px);
}
.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 40px 48px;
  text-align: center;
  max-width: 380px;
  width: 100%;
}
.login-card h2 { margin: 0 0 8px; color: var(--brand2); }
.btn-login {
  display: inline-block;
  margin-top: 20px;
  background: var(--brand);
  color: #fff;
  text-decoration: none;
  padding: 11px 24px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
}
.btn-login:hover { background: var(--brand2); }

/* ── MAIN ── */
main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 16px 60px;
}

/* ── VIEWS ── */
.view { display: none; }
.view.active { display: block; }

h2.vt { font-size: 16px; margin: 0 0 14px; }

/* ── KPIS ── */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
#v-overview .card + .card { margin-top: 16px; }
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}
.kpi .n { font-size: 28px; font-weight: 700; color: var(--brand2); }
.kpi .l { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi-link { cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.kpi-link:hover { border-color: var(--accent); box-shadow: 0 4px 14px rgba(8,145,178,.15); }

/* ── TOOLBAR ── */
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}
input[type=text], input[type=date], select {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: var(--card);
  color: var(--ink);
}
input[type=text] { min-width: 240px; }

/* ── CARD ── */
.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  margin-top: 0;
}

/* ── TABLE ── */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: var(--card);
}
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f0fdff; }
tbody tr:last-child td { border-bottom: 0; }

/* admin "Datentypen" tables: keep Status/action columns aligned across tables with a different number of label columns */
.admin-type-table { table-layout: fixed; }
.admin-type-table th:nth-last-child(2), .admin-type-table td:nth-last-child(2) { width: 90px; }
.admin-type-table th:last-child, .admin-type-table td:last-child { width: 140px; }

/* ── BADGES ── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.b-aktiv { background: #d1fae5; color: var(--ok); }
.b-geschlossen { background: #fee2e2; color: var(--closed); }
.b-geplant { background: #fef3c7; color: var(--planned); }
.b-offen { background: #fef3c7; color: var(--planned); }
.b-in_bearbeitung { background: #dbeafe; color: var(--brand2); }
.b-erledigt { background: #d1fae5; color: var(--ok); }
.b-abgelehnt { background: #fee2e2; color: var(--closed); }

/* ── CHIPS ── */
.chip {
  display: inline-block;
  background: var(--chip);
  color: var(--brand2);
  border: 1px solid #a5f3fc;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  margin: 2px 3px 2px 0;
}

.chip-link {
  cursor: pointer;
}

.chip-link:hover {
  background: var(--brand2);
  color: #fff;
}

/* ── MULTISELECT ── */
.ms { position: relative; display: inline-block; }
.ms-btn {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
}
.ms-btn.active { border-color: var(--accent); color: var(--brand2); font-weight: 600; }
.ms-panel {
  display: none;
  position: absolute;
  z-index: 1000;
  top: calc(100% + 4px);
  left: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.14);
  padding: 6px;
  min-width: 230px;
  max-height: 300px;
  overflow: auto;
}
.ms-panel.open { display: block; }
#admin-us-standort-panel { min-width: 380px; }
.ms-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.ms-item:hover { background: #f0fdff; }

/* ── DETAIL VIEW ── */
.back {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  margin-bottom: 10px;
}
.section-h {
  font-size: 13px;
  font-weight: 700;
  color: var(--brand2);
  margin: 18px 0 8px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.kv {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 6px 14px;
  margin: 4px 0;
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.muted { color: var(--muted); }
.empty { color: var(--muted); font-style: italic; padding: 8px 0; }

/* ── DETAIL TABLE ── */
.detail-name { font-size: 18px; font-weight: 700; margin: 0 0 4px; }

/* ── DETAIL TABS ── */
.detail-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin: 18px 0 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding-top: 10px;
}
.detail-tabs button {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 8px 12px;
  font-size: 13px;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
}
.detail-tabs button.active {
  color: var(--brand2);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.detail-tabs button:hover { color: var(--brand2); }
.detail-tab-content { padding-top: 16px; }

.admin-tab-panel { display: none; padding-top: 16px; }
.admin-tab-panel.active { display: block; }

/* ── EDIT FORM ── */
.ed-input {
  width: 100%;
  max-width: 440px;
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
  background: #fffef8;
  color: var(--ink);
}
textarea.ed-input { resize: vertical; font-family: inherit; }
.ed-actions { margin-top: 16px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ed-actions select { margin-right: 4px; }
.hint { margin-top: 6px; font-size: 12px; color: var(--muted); }
.upload-progress { margin-top: 8px; display: flex; align-items: center; gap: 8px; }
.upload-progress-bar { flex: 1; height: 8px; border-radius: 4px; background: #e2e8f0; overflow: hidden; }
.upload-progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.15s ease; }
.upload-progress-label { font-size: 12px; color: var(--muted); min-width: 32px; text-align: right; }
.ed-actions select { height: 36px; }
.ed-actions input[type=file] {
  height: 36px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  padding: 0 11px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: var(--card);
  color: var(--muted);
  max-width: 340px;
}
.ed-actions input[type=file]::file-selector-button {
  height: 36px;
  margin-right: 10px;
  padding: 0 14px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 8px 0 0 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.ed-actions input[type=file]::file-selector-button:hover { background: var(--brand2); }
.btn-save {
  height: 36px;
  box-sizing: border-box;
  background: var(--brand);
  color: #fff;
  border: 0;
  padding: 0 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.btn-save:hover { background: var(--brand2); }
.btn-save:disabled { background: var(--muted); cursor: not-allowed; }

.detail-actions {
  position: absolute;
  top: 16px;
  right: 18px;
  display: flex;
  gap: 8px;
}
.edit-btn {
  background: var(--brand);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.edit-btn:hover { background: var(--brand2); }
.ticket-btn {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.ticket-btn:hover { background: #067188; }

/* ── MODAL ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  z-index: 1100;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-card {
  background: var(--card);
  border-radius: 12px;
  padding: 22px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.modal-sub { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.modal-label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 12px 0 4px; }
.modal-actions { margin-top: 20px; display: flex; justify-content: flex-end; gap: 8px; }

/* ── ICON BUTTONS ── */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--line);
  margin-left: 6px;
  text-decoration: none;
  vertical-align: middle;
  background: #fff;
}
.icon-btn:hover { border-color: var(--accent); background: #f0fdff; }
.icon-btn svg { width: 15px; height: 15px; }

/* ── TOAST NOTIFICATIONS ── */
#toast-container {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}
.toast {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
  padding: 12px 36px 12px 14px;
  font-size: 13px;
  color: var(--ink);
  position: relative;
  animation: toast-in .2s ease-out;
}
.toast.success { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--closed); }
.toast-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}
.toast-close:hover { color: var(--ink); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}
