:root {
  --bg-a: #ffe5ec;
  --bg-b: #e0f7fa;
  --bg-c: #fff9e0;
  --card: #ffffff;
  --text: #3d3d4e;
  --muted: #8a8aa3;
  --primary: #ff9ac1;
  --primary-dark: #ff7fb0;
  --accent: #a0c4ff;
  --accent-2: #b9fbc0;
  --error-bg: #ffd6d6;
  --error-text: #b3261e;
  --success-bg: #d8f5d0;
  --success-text: #2e6b1f;
  --radius: 16px;
}

* { box-sizing: border-box; }

h1, h2, h3, p { margin: 0 0 1rem; }
main.page > h1:first-child { margin-top: 0; }

/* Scrollbalken ueberall unsichtbar machen - scrollen bleibt moeglich, nur ohne sichtbare Leiste. */
html {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
html::-webkit-scrollbar { display: none; width: 0; height: 0; }

body {
  font-family: -apple-system, "Segoe UI", system-ui, sans-serif;
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg-a) 0%, var(--bg-b) 55%, var(--bg-c) 100%);
  background-attachment: fixed;
}

.center-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(160, 120, 160, 0.18);
  padding: 2.25rem 2.5rem;
  width: 100%;
  max-width: 380px;
}

.card h1 {
  margin: 0 0 .3rem;
  font-size: 1.5rem;
}

.card .subtitle {
  color: var(--muted);
  font-size: .9rem;
  margin: 0 0 1.5rem;
}

label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: .3rem;
  margin-top: 1rem;
}
label:first-of-type { margin-top: 0; }

input {
  width: 100%;
  padding: .7rem .9rem;
  border-radius: 10px;
  border: 2px solid #f0f0f5;
  background: #fbfbfd;
  color: var(--text);
  font-size: .95rem;
}
input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

select {
  width: 100%;
  padding: .7rem .9rem;
  border-radius: 10px;
  border: 2px solid #f0f0f5;
  background: #fbfbfd;
  color: var(--text);
  font-size: .95rem;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8aa3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .8rem center;
  background-size: 18px;
  padding-right: 2.4rem;
}
select:focus {
  outline: none;
  border-color: var(--accent);
  background-color: #fff;
}

.password-field { position: relative; }
.password-field input { padding-right: 2.6rem; margin: 0; }
.password-field .password-toggle {
  position: absolute;
  right: .4rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: .3rem;
  width: auto;
  margin: 0;
  display: inline-flex;
  box-shadow: none;
}
.password-toggle svg { width: 18px; height: 18px; display: block; }
.password-toggle:hover { color: var(--text); }

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-switch .toggle-track {
  position: absolute;
  inset: 0;
  background: #e2e2ea;
  border-radius: 999px;
  transition: background .2s;
}
.toggle-switch .toggle-track::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.toggle-switch input:checked + .toggle-track {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}
.toggle-switch input:checked + .toggle-track::before {
  transform: translateX(20px);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: .4rem;
}
.row-actions form { display: inline-flex; align-items: center; margin: 0; }

button, .btn {
  display: inline-block;
  width: 100%;
  margin-top: 1.5rem;
  padding: .8rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-weight: 700;
  font-size: .95rem;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 6px 16px rgba(255, 122, 170, 0.35);
}
button:hover, .btn:hover { filter: brightness(1.05); }

.btn-secondary {
  background: linear-gradient(135deg, var(--accent), #8fb8ff);
  box-shadow: 0 6px 16px rgba(120, 160, 255, 0.3);
}

.alert {
  padding: .7rem .9rem;
  border-radius: 10px;
  font-size: .85rem;
  margin-top: 1rem;
}
.alert-error { background: var(--error-bg); color: var(--error-text); }
.alert-success { background: var(--success-bg); color: var(--success-text); }

header.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.75rem;
  background: #fffbfd;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(160, 120, 160, 0.1);
}

/* AUI = Arbeits- und Informationsleiste: sticky direkt unter dem Header.
   Links Suche/Filter, rechts Aktionen (Neu, Export, ...). Immer volle Breite. */
.aui-bar {
  position: sticky;
  top: 62px;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  padding: .75rem 1.75rem;
  background: #fffbfd;
  box-shadow: 0 2px 10px rgba(160, 120, 160, 0.08);
}

.aui-bar .aui-left,
.aui-bar .aui-right {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
}

.aui-search {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: #fbfbfd;
  border: 2px solid #f0f0f5;
  border-radius: 10px;
  padding: 0 .7rem;
  min-width: 220px;
}
.aui-search svg { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }
.aui-search input {
  border: none;
  background: transparent;
  padding: .55rem 0;
  margin: 0;
}
.aui-search input:focus { outline: none; }

.icon-btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 12px rgba(255, 122, 170, .35);
}
.icon-btn-primary:hover { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); filter: brightness(1.06); color: #fff; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin: 0;
  padding: 0;
  border-radius: 10px;
  border: none;
  background: #fff;
  color: #6b7fd7;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
  text-decoration: none;
  flex-shrink: 0;
  vertical-align: middle;
}
.icon-btn:hover { background: var(--accent-2); color: #1f6b3a; }
.icon-btn svg { width: 18px; height: 18px; }

[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: 120%;
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  background: #3d3d4e;
  color: #fff;
  font-size: .72rem;
  padding: .3rem .6rem;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
  z-index: 200;
}
[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

header.topbar .brand {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--primary-dark);
}

header.topbar .user-info {
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}

header.topbar a {
  color: #6b7fd7;
  text-decoration: none;
  font-weight: 600;
}
header.topbar a:hover { text-decoration: underline; }

.badge {
  display: inline-block;
  padding: .15rem .6rem;
  border-radius: 999px;
  background: var(--accent-2);
  color: #1f6b3a;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.badge-vorschlag { background: #fff3b0; color: #8a6d00; }
.badge-offen     { background: var(--accent-2); color: #1f6b3a; }
.badge-erledigt  { background: #dbe4ff; color: #38508f; }
.badge-abgelehnt { background: #f1f0f4; color: #8a8aa3; }

.aui-tabs {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
}

.dir-filter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .2rem;
  border-radius: 8px;
  cursor: pointer;
  opacity: .55;
}
.dir-filter-btn svg { width: 34px; height: 34px; display: block; }
.dir-filter-btn:hover { opacity: .8; }
.dir-filter-btn.active {
  opacity: 1;
  background: #ffe3ef;
}

.dir-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}
.aui-tabs a {
  padding: .45rem .9rem;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  background: #fff;
}
.aui-tabs a.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
}

main.page {
  width: 100%;
  margin: 0;
  padding: 1.75rem 1.75rem 3rem;
  box-sizing: border-box;
}

/* Formulare als volle Breite, Felder fliessen in mehrere Spalten statt in eine schmale Saeule gequetscht zu werden. */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0 1.75rem;
}
.form-grid .full-row { grid-column: 1 / -1; }
.form-grid button[type="submit"] { max-width: 260px; }

.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(160, 120, 160, .12);
  padding: 1.75rem 2rem;
  margin-bottom: 2rem;
  width: 100%;
  box-sizing: border-box;
}

.table-wrap {
  width: 100%;
}

.table-wrap table {
  width: 100%;
  max-width: 100%;
  table-layout: auto;
  border-collapse: collapse;
}

.table-wrap tbody tr:nth-child(odd) {
  background: #ffffff80;
}

/* Tasks-Tabelle hat eine sehr lange Titel-Spalte (Zitat-Text) - feste
   Spaltenbreiten verhindern, dass sie die anderen Spalten zusammenquetscht. */
#task-table {
  table-layout: fixed;
}

.table-wrap td, .table-wrap th {
  overflow-wrap: anywhere;
}

.table-subhead {
  background: #fff3f8;
  text-align: left;
}

.aui-title {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text);
  margin-right: .5rem;
}

.emoji-lg { font-size: 2.2rem; margin-bottom: .25rem; display: block; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  main.page, .aui-bar {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
  .panel {
    padding: 1.25rem 1.5rem;
  }
}

/* Tabellen auf schmalen Bildschirmen (Handys UND schmalere Tablet-/Fenstergroessen):
   statt Spalten zusammenzuquetschen (winzige, zeichenweise umbrechende Zellen) lieber
   per Wisch-Geste horizontal scrollen lassen. Bewusst ein groesserer Schwellwert als
   nur "Handy schmal" (640px), weil genau der Bereich dazwischen (~640-900px, z.B.
   Tablet-Hochformat oder ein schmaleres Browserfenster) sonst mit der festen
   Spaltenbreite von table-layout:fixed genauso kaputt aussieht. Kein
   Tooltip-Clipping-Problem in diesem Bereich, da Hover dort ohnehin kaum genutzt wird. */
@media (max-width: 900px) {
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-wrap table {
    min-width: 620px;
  }
  #task-table {
    table-layout: auto;
  }
  #task-table th, #task-table td {
    white-space: normal;
  }
}

@media (max-width: 640px) {
  header.topbar {
    flex-wrap: wrap;
    row-gap: .6rem;
    padding: .85rem 1rem;
  }
  header.topbar .user-info {
    flex-wrap: wrap;
    gap: .4rem;
  }
  .aui-search { min-width: 0; flex: 1 1 100%; }
  .card {
    padding: 1.5rem 1.25rem;
    max-width: 100% !important;
  }
}
