:root {
  --rh-red: #8B0000;
  --rh-red-light: rgba(139, 0, 0, 0.08);
  --rh-anthracite: #1a1a1a;
  --rh-gray: #f5f5f4;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 24px rgba(0, 0, 0, 0.08);
  --radius: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

body {
  margin: 0;
  font-family: var(--font);
  background: var(--rh-gray);
  color: var(--rh-anthracite);
  min-height: 100dvh;
  padding-bottom: 6rem;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* Header */
.header {
  background: white;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-text { flex: 1; min-width: 0; }

.header-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.125rem;
  flex-shrink: 0;
}

.header-user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--rh-anthracite);
}

.header-logout {
  font-size: 0.75rem;
  color: var(--rh-red);
  text-decoration: none;
  font-weight: 500;
}

.header-logout:hover { text-decoration: underline; }

.header-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.header-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--rh-red);
  letter-spacing: -0.02em;
}

.header-sub {
  margin: 0.125rem 0 0;
  font-size: 0.8125rem;
  color: #737373;
}

/* Main */
.main {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.error-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: #b91c1c;
  font-size: 0.875rem;
}

.error-close {
  margin-left: auto;
  background: none;
  border: none;
  color: #ef4444;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

/* Dashboard */
.dashboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.stat-card {
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-num {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  display: block;
  margin-top: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #737373;
}

.stat-neu .stat-num { color: var(--rh-red); }
.stat-bearbeitung .stat-num { color: #d97706; }
.stat-erledigt .stat-num { color: #059669; }

/* Section */
.section-head { margin-bottom: 1rem; }

.section-head h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.section-sub {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: #a3a3a3;
}

.back-btn {
  background: none;
  border: none;
  padding: 0;
  margin-bottom: 0.5rem;
  font-size: 0.8125rem;
  color: #a3a3a3;
  cursor: pointer;
}

.back-btn:hover { color: var(--rh-anthracite); }

/* Toolbar */
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  font-size: 0.9375rem;
  background: white;
}

.search-input:focus {
  outline: 2px solid var(--rh-red);
  outline-offset: 0;
}

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

.filter-btn {
  padding: 0.5rem 1rem;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  background: white;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn.active,
.filter-btn:hover {
  background: var(--rh-red);
  color: white;
  border-color: var(--rh-red);
}

.archiv-zugang {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.875rem 1rem;
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.archiv-zugang:hover { box-shadow: var(--shadow-lg); }

.archiv-badge {
  margin-left: auto;
  background: #d1fae5;
  color: #059669;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
}

/* Loading / Empty */
.loading, .empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1rem;
  color: #a3a3a3;
  font-size: 0.875rem;
  gap: 0.75rem;
}

.empty {
  background: white;
  border-radius: var(--radius);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: var(--shadow);
}

.empty-icon { font-size: 2rem; }
.empty-title { margin: 0; font-weight: 500; color: #737373; font-size: 0.9375rem; }
.empty-sub { margin: 0; font-size: 0.8125rem; }

.spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid #e5e5e5;
  border-top-color: var(--rh-red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* Ticket Grid */
.ticket-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .ticket-grid { grid-template-columns: repeat(2, 1fr); }
}

.ticket-card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.15s, transform 0.15s;
}

.ticket-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.ticket-photo-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  cursor: pointer;
  position: relative;
}

.ticket-photo {
  width: 100%;
  height: 14rem;
  object-fit: cover;
  display: block;
}

.ticket-body { padding: 1.25rem; }

.ticket-top {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.ticket-num {
  font-size: 0.75rem;
  font-weight: 600;
  color: #a3a3a3;
  letter-spacing: 0.02em;
}

.ticket-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  justify-content: flex-end;
}

.badge {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  white-space: nowrap;
}

.badge-neu { background: var(--rh-red-light); color: var(--rh-red); }
.badge-bearbeitung { background: rgba(245, 158, 11, 0.1); color: #b45309; }
.badge-erledigt { background: rgba(16, 185, 129, 0.1); color: #047857; }
.badge-prio-niedrig { background: #f5f5f4; color: #525252; }
.badge-prio-normal { background: #eff6ff; color: #1d4ed8; }
.badge-prio-hoch { background: var(--rh-red-light); color: var(--rh-red); }

.ticket-desc {
  margin: 0 0 0.75rem;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  text-align: left;
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  width: 100%;
}

.ticket-meta {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: #737373;
  margin-bottom: 0.75rem;
}

.ticket-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: white;
  cursor: pointer;
}

.btn-sm:hover { background: var(--rh-gray); }
.btn-sm-primary { background: var(--rh-red); color: white; border-color: var(--rh-red); }
.btn-sm-primary:hover { background: #6d0000; }

/* FAB */
.fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: var(--rh-red);
  color: white;
  border: none;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(139, 0, 0, 0.4);
  z-index: 50;
  transition: transform 0.15s;
}

.fab:hover { transform: scale(1.05); }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

@media (min-width: 640px) {
  .modal { align-items: center; padding: 1rem; }
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.modal-panel {
  position: relative;
  background: white;
  width: 100%;
  max-width: 32rem;
  max-height: 92dvh;
  overflow-y: auto;
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow-lg);
}

@media (min-width: 640px) {
  .modal-panel { border-radius: var(--radius); }
}

.modal-panel-lg { max-width: 40rem; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.25rem 0;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: #a3a3a3;
  cursor: pointer;
  padding: 0.25rem;
}

.modal-body { padding: 1.25rem; }

.modal-footer {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  padding-top: 0.5rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-bottom: 1rem;
}

.field > span {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #525252;
}

.field input,
.field select,
.field textarea {
  padding: 0.625rem 0.875rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  font-size: 0.9375rem;
  font-family: inherit;
}

.field textarea { resize: vertical; min-height: 4rem; }

.field-error {
  margin: 0;
  font-size: 0.8125rem;
  color: #dc2626;
}

.btn {
  padding: 0.625rem 1.25rem;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

.btn-primary { background: var(--rh-red); color: white; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary { background: var(--rh-gray); color: var(--rh-anthracite); }
.btn-danger { background: #fef2f2; color: #dc2626; }

/* Photo input */
.photo-input { display: flex; flex-direction: column; gap: 0.5rem; }

.photo-file { display: none; }

.photo-label {
  display: block;
  padding: 1.5rem;
  border: 2px dashed rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  text-align: center;
  font-size: 0.875rem;
  color: #737373;
  cursor: pointer;
}

.photo-label:hover { border-color: var(--rh-red); color: var(--rh-red); }

.photo-preview img {
  width: 100%;
  max-height: 12rem;
  object-fit: cover;
  border-radius: 10px;
}

.photo-clear {
  margin-top: 0.5rem;
  background: none;
  border: none;
  color: #dc2626;
  font-size: 0.8125rem;
  cursor: pointer;
}

/* Detail view */
.detail-photos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.detail-photo-wrap img {
  width: 100%;
  height: 10rem;
  object-fit: cover;
  border-radius: 10px;
}

.detail-photo-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: #a3a3a3;
  margin-bottom: 0.25rem;
}

.detail-info {
  display: grid;
  gap: 0.5rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.detail-row { display: flex; gap: 0.5rem; }
.detail-row strong { min-width: 6rem; color: #525252; }

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* Login */
.login-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--rh-gray);
}

.login-card {
  width: 100%;
  max-width: 24rem;
  background: white;
  border-radius: var(--radius);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: var(--shadow-lg);
  padding: 2rem 1.5rem;
  text-align: center;
}

.login-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  margin: 0 auto 1rem;
}

.login-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--rh-red);
}

.login-sub {
  margin: 0.25rem 0 1.5rem;
  font-size: 0.875rem;
  color: #737373;
}

.login-form { text-align: left; }

.login-submit {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.75rem;
}

.login-error {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  color: #b91c1c;
  font-size: 0.875rem;
  text-align: left;
}

.login-success {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 10px;
  color: #047857;
  font-size: 0.875rem;
}

.login-hint {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  font-size: 0.875rem;
  color: #1d4ed8;
}

.login-hint a { color: var(--rh-red); font-weight: 600; }

.login-note {
  margin-top: 1rem;
  font-size: 0.8125rem;
  color: #737373;
}

.login-note code {
  background: var(--rh-gray);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.75rem;
}
