:root {
  --bg: #0b0f19;
  --bg-elev: #121729;
  --bg-elev-2: #1a2138;
  --accent: #ffb347;
  --accent-2: #4dd9ff;
  --text: #eef2ff;
  --text-dim: #8b93b0;
  --danger: #ff5470;
  --success: #35d19e;
  --violet: #b490ff;
  --border: rgba(255, 255, 255, 0.08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: radial-gradient(1200px 800px at 50% -10%, #1e1608 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(14px + var(--safe-top)) 16px calc(14px + var(--safe-bottom));
  max-width: 1080px;
  margin: 0 auto;
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

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

.brand__mark {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px 2px rgba(255, 179, 71, 0.6);
}

.brand h1 {
  font-size: 17px;
  letter-spacing: 0.3em;
  font-weight: 700;
  margin: 0;
  color: var(--accent);
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  order: 3;
  width: 100%;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -ms-overflow-style: none;
  /* Fade-Rand als Scroll-Hinweis: mehr Tabs liegen außerhalb des sichtbaren Bereichs. */
  mask-image: linear-gradient(to right, transparent 0, black 14px, black calc(100% - 14px), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0, black 14px, black calc(100% - 14px), transparent 100%);
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  padding: 10px 16px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  scroll-snap-align: start;
}

/* Ab Tablet-Breite: alle Tabs sichtbar per Umbruch statt Scrollen. */
@media (min-width: 700px) {
  .tabs {
    flex-wrap: wrap;
    overflow-x: visible;
    scroll-snap-type: none;
    mask-image: none;
    -webkit-mask-image: none;
    row-gap: 8px;
  }
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  background: var(--bg-elev-2);
  color: var(--text);
  border-color: var(--border);
}

/* ---------- Buttons ---------- */

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  min-height: 40px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn--primary {
  background: var(--accent);
  color: #1a1204;
  font-weight: 600;
}

.btn--primary:hover {
  filter: brightness(1.08);
}

.btn--icon {
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 16px;
}

.icon-btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  border-radius: 8px;
  width: 38px;
  height: 38px;
  cursor: pointer;
  font-size: 14px;
  display: grid;
  place-items: center;
  flex: none;
}

.icon-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}

/* ---------- Main / loading / empty ---------- */

.main {
  flex: 1;
}

.loading, .empty-state {
  color: var(--text-dim);
  text-align: center;
  padding: 60px 16px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

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

/* ---------- Cards (Übersicht) ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card--danger {
  border-color: rgba(255, 84, 112, 0.4);
}

.card__value {
  font-size: 26px;
  font-weight: 700;
}

.card--danger .card__value {
  color: var(--danger);
}

.card__label {
  font-size: 12px;
  color: var(--text-dim);
}

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 14px;
}

.panel h2 {
  font-size: 14px;
  margin: 0 0 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.panel-grid .panel {
  margin-bottom: 0;
}

.hint-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}

.goal-row {
  margin-bottom: 12px;
}

.goal-row:last-child {
  margin-bottom: 0;
}

.goal-row__head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
}

.goal-row__pct {
  color: var(--text-dim);
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  border-radius: 999px;
  transition: width 0.2s ease;
}

/* ---------- Forms ---------- */

.quick-add {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.quick-add--wrap {
  flex-wrap: wrap;
}

.quick-add input[type="text"],
.quick-add input[type="email"],
.quick-add input[type="date"],
.quick-add select {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  min-height: 40px;
  /* 16px verhindert das ungewollte Auto-Zoom von iOS Safari beim Fokussieren
     von Eingabefeldern mit kleinerer Schrift. */
  font-size: 16px;
  font-family: inherit;
}

.quick-add input[type="text"] {
  flex: 1;
  min-width: 160px;
}

.quick-add input[type="email"] {
  min-width: 160px;
}

.quick-add .btn {
  flex: none;
}

/* ---------- Suche ---------- */

.search-input {
  display: block;
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  min-height: 40px;
  font-size: 16px;
  font-family: inherit;
  margin-bottom: 14px;
}

.search-input::placeholder {
  color: var(--text-dim);
}

/* ---------- Status-Dropdown in Kanban-Karten ---------- */

.status-select {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 8px;
  min-height: 38px;
  font-size: 13px;
  font-family: inherit;
  flex: 1;
  min-width: 0;
}

/* ---------- Notizen-Liste ---------- */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.list-item__main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.list-item__main p {
  margin: 0;
  font-size: 14px;
}

.list-item__main time {
  font-size: 11px;
  color: var(--text-dim);
}

.list-item__actions {
  display: flex;
  gap: 6px;
  flex: none;
}

.tag {
  display: inline-block;
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tag--hoch {
  background: rgba(255, 84, 112, 0.18);
  color: #ff8ba3;
}

.tag--mittel {
  background: rgba(255, 179, 71, 0.18);
  color: var(--accent);
}

.tag--niedrig {
  background: rgba(77, 217, 255, 0.18);
  color: var(--accent-2);
}

/* ---------- Tags: Findings-Priorität, Rechtsmarker, Dokument-Status ---------- */

.tag--priority-P0 {
  background: rgba(255, 84, 112, 0.18);
  color: #ff8ba3;
}

.tag--priority-P1 {
  background: rgba(255, 179, 71, 0.18);
  color: var(--accent);
}

.tag--priority-P2 {
  background: rgba(77, 217, 255, 0.18);
  color: var(--accent-2);
}

.tag--marker-FAKT {
  background: rgba(77, 217, 255, 0.18);
  color: var(--accent-2);
}

.tag--marker-RISIKO {
  background: rgba(255, 84, 112, 0.18);
  color: #ff8ba3;
}

.tag--marker-PRUEFBEDARF {
  background: rgba(255, 179, 71, 0.18);
  color: var(--accent);
}

.tag--marker-GATE {
  background: rgba(180, 144, 255, 0.2);
  color: var(--violet);
}

.tag--final {
  background: rgba(53, 209, 158, 0.18);
  color: var(--success);
}

.tag--entwurf {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
}

.task-card__notes {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
}

/* ---------- Board (Aufgaben / CRM) ---------- */

.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  align-items: start;
}

.board__col {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  min-height: 80px;
}

.board__col h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.board__col .count {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 10px;
}

.board__items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-card--overdue {
  border-color: rgba(255, 84, 112, 0.5);
}

.task-card__title {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
}

.task-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.task-card__meta time {
  font-size: 11px;
  color: var(--text-dim);
}

.task-card__actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* ---------- Roadmap ---------- */

.goal-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.goal-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.goal-card--overdue {
  border-color: rgba(255, 84, 112, 0.5);
}

.goal-card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.goal-card__head h3 {
  margin: 0;
  font-size: 15px;
}

.goal-card > time {
  font-size: 11px;
  color: var(--text-dim);
}

.milestone-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.milestone-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.milestone-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  min-width: 0;
}

.milestone-list label span {
  overflow-wrap: anywhere;
}

.milestone-list input[type="checkbox"] {
  accent-color: var(--accent);
}

.milestone-list .done {
  text-decoration: line-through;
  color: var(--text-dim);
}

.goal-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.goal-card__actions .btn {
  padding: 6px 12px;
  font-size: 12px;
}

/* ---------- Settings dialog ---------- */

.dialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-elev);
  color: var(--text);
  padding: 0;
  max-width: 420px;
  width: calc(100% - 32px);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.settings-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-form h2 {
  margin: 0;
  font-size: 16px;
}

.dialog__hint {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0;
  line-height: 1.5;
}

.settings-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

.settings-form input,
.settings-form select,
.settings-form textarea {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  min-height: 40px;
  /* 16px verhindert das ungewollte Auto-Zoom von iOS Safari beim Fokussieren. */
  font-size: 16px;
  font-family: inherit;
  resize: vertical;
}

.edit-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 60vh;
  overflow-y: auto;
}

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
  z-index: 20;
}

.toast--error {
  border-color: rgba(255, 84, 112, 0.5);
  color: #ff8ba3;
}

/* ---------- Footer ---------- */

.footer {
  padding-top: 20px;
  text-align: center;
}

.footer a {
  color: var(--text-dim);
  font-size: 12px;
  text-decoration: none;
}

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

/* ---------- Responsive ---------- */
/* Tabs liegen immer auf eigener Zeile (siehe .tabs oben) - hier nur noch
   Anpassungen, die speziell sehr schmale Displays betreffen. */
