*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --indigo: #4F46E5;
  --indigo-dark: #4338CA;
  --indigo-light: #EEF2FF;
  --green: #16a34a;
  --green-light: #dcfce7;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.5;
  min-height: 100vh;
}

/* Screens */
.screen { display: none; }
.screen.active { display: flex; }

/* ── LOGIN ── */
#screen-login {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef2ff 0%, #f0f9ff 100%);
}

.login-container {
  background: white;
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(79,70,229,0.12), 0 4px 16px rgba(0,0,0,0.06);
  text-align: center;
}

.login-logo { margin-bottom: 20px; }

.login-container h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 8px;
}

.login-sub {
  color: var(--gray-500);
  font-size: 15px;
  margin-bottom: 32px;
}

.entity-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.entity-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 16px;
  border: 2px solid var(--gray-200);
  border-radius: 14px;
  background: white;
  cursor: pointer;
  transition: all 0.18s ease;
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-700);
}

.entity-btn:hover {
  border-color: var(--indigo);
  background: var(--indigo-light);
  color: var(--indigo);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(79,70,229,0.15);
}

.entity-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--indigo-light);
  color: var(--indigo);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s;
}

.entity-btn:hover .entity-icon {
  background: var(--indigo);
  color: white;
}

/* ── APP ── */
#screen-app {
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 60px;
  background: white;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 12px;
}

.header-left { display: flex; align-items: center; gap: 10px; }
.header-right { display: flex; align-items: center; gap: 10px; }

.app-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
}

.entity-badge {
  background: var(--indigo-light);
  color: var(--indigo);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
}

.app-body {
  max-width: 820px;
  margin: 0 auto;
  padding: 28px 20px 60px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── INPUT CARD ── */
.input-card {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 14px;
}

textarea {
  width: 100%;
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  padding: 14px;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--gray-900);
  resize: vertical;
  transition: border-color 0.15s;
  background: var(--gray-50);
  line-height: 1.6;
}

textarea:focus {
  outline: none;
  border-color: var(--indigo);
  background: white;
}

textarea::placeholder { color: var(--gray-400); }

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  gap: 12px;
}

.input-hint {
  font-size: 12.5px;
  color: var(--gray-500);
  flex: 1;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--indigo);
  color: white;
}
.btn-primary:hover { background: var(--indigo-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--gray-500);
  border: 1px solid var(--gray-200);
}
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-700); }

/* ── ARCHIVE BANNER ── */
.archive-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  color: #92400e;
}

/* ── TICKETS ── */
.tickets-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.ticket-count {
  background: var(--gray-100);
  color: var(--gray-500);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}

.ticket-card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 12px;
  transition: box-shadow 0.15s;
}

.ticket-card:hover { box-shadow: var(--shadow-md); }

.ticket-stripe {
  height: 4px;
  background: var(--indigo);
}

.ticket-body { padding: 18px 20px; }

.ticket-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.ticket-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.4;
}

.ticket-id {
  font-size: 12px;
  color: var(--gray-400);
  font-weight: 500;
  white-space: nowrap;
}

.ticket-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}

.badge-cat {
  background: var(--indigo-light);
  color: var(--indigo);
}

.badge-prio-hoch { background: #fef2f2; color: #dc2626; }
.badge-prio-mittel { background: #fff7ed; color: #d97706; }
.badge-prio-niedrig { background: var(--green-light); color: var(--green); }
.badge-prio-default { background: var(--gray-100); color: var(--gray-500); }

.badge-by {
  background: var(--gray-100);
  color: var(--gray-500);
}

.ticket-desc {
  font-size: 13.5px;
  color: var(--gray-700);
  line-height: 1.6;
  margin-bottom: 10px;
}

.ticket-original {
  font-size: 12px;
  color: var(--gray-400);
  font-style: italic;
  margin-bottom: 14px;
  padding-left: 10px;
  border-left: 2px solid var(--gray-200);
}

/* Interest checkboxes */
.ticket-interests {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.interest-item {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--gray-200);
  transition: all 0.15s;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-500);
  user-select: none;
}

.interest-item:hover {
  border-color: var(--indigo);
  color: var(--indigo);
  background: var(--indigo-light);
}

.interest-item.checked {
  border-color: var(--green);
  background: var(--green-light);
  color: var(--green);
}

.interest-item.own-entity {
  font-weight: 700;
}

.interest-check {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.interest-check svg { display: none; }
.interest-item.checked .interest-check svg { display: block; }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(2px);
}

.modal {
  background: white;
  border-radius: 18px;
  padding: 36px 32px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 25px 60px rgba(0,0,0,0.2);
}

.modal-icon { margin-bottom: 16px; }

.modal h3 {
  font-size: 19px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 10px;
}

.modal p {
  font-size: 14px;
  color: var(--gray-500);
  line-height: 1.6;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ── TICKET FOOTER ── */
.ticket-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--gray-100);
}

.btn-delete {
  background: none;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 5px 7px;
  cursor: pointer;
  color: var(--gray-400);
  display: flex;
  align-items: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.btn-delete:hover {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #dc2626;
}

/* ── UTILS ── */
.hidden { display: none !important; }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--gray-900);
  color: white;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  z-index: 300;
  animation: slideUp 0.25s ease;
}

.toast.success { background: var(--green); }
.toast.error { background: #dc2626; }

@keyframes slideUp {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 600px) {
  .entity-grid { grid-template-columns: 1fr 1fr; }
  .login-container { padding: 32px 24px; }
  .header-right { gap: 6px; }
  .btn { padding: 7px 12px; font-size: 13px; }
  .app-title { display: none; }
}
