/* ─── Variablen ─────────────────────────────────────────────────────────── */
:root {
  --blue-900: #1e3a8a;
  --blue-800: #1e40af;
  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-400: #60a5fa;
  --blue-100: #dbeafe;
  --blue-50:  #eff6ff;
  --white:    #ffffff;
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --red-500:  #ef4444;
  --red-100:  #fee2e2;
  --green-500:#22c55e;
  --green-100:#dcfce7;
  --yellow-500:#f59e0b;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow:    0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1);
  --radius:    8px;
  --sidebar-w: 240px;
}

/* ─── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-700);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; font-size: 14px; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ─── Login ──────────────────────────────────────────────────────────────── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--blue-900) 0%, var(--blue-600) 100%);
}

.login-card {
  background: var(--white);
  border-radius: 12px;
  padding: 40px;
  width: 380px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo h1 {
  color: var(--blue-700);
  font-size: 26px;
  font-weight: 700;
}

.login-logo p { color: var(--gray-400); font-size: 13px; margin-top: 4px; }

/* ─── App Layout ─────────────────────────────────────────────────────────── */
#app {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--blue-900);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-logo h2 {
  color: var(--white);
  font-size: 17px;
  font-weight: 700;
}

.sidebar-logo p {
  color: var(--blue-400);
  font-size: 11px;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-section {
  padding: 8px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--blue-400);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: rgba(255,255,255,.75);
  cursor: pointer;
  transition: background .15s, color .15s;
  border-radius: 0;
  margin: 1px 8px;
  border-radius: 6px;
}

.nav-item:hover { background: rgba(255,255,255,.08); color: var(--white); }
.nav-item.active { background: var(--blue-600); color: var(--white); }

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.1);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.user-avatar {
  width: 34px; height: 34px;
  background: var(--blue-600);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 600; font-size: 13px;
}

.user-name { color: var(--white); font-size: 13px; font-weight: 500; }
.user-role { color: var(--blue-400); font-size: 11px; }

.btn-logout {
  width: 100%;
  padding: 7px 12px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px;
  color: rgba(255,255,255,.75);
  font-size: 13px;
  transition: background .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.15); color: white; }

/* ─── Main Content ───────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-bar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.top-bar h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-900);
}

.page-content { padding: 24px; flex: 1; }

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-header h2 { font-size: 15px; font-weight: 600; color: var(--gray-900); }
.card-body { padding: 20px; }

/* ─── Stats / Dashboard ──────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.stat-card .stat-icon {
  width: 40px; height: 40px;
  background: var(--blue-100);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
  color: var(--blue-600);
}

.stat-card .stat-icon svg { width: 22px; height: 22px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--gray-900); }
.stat-label { font-size: 12px; color: var(--gray-400); margin-top: 2px; }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 500;
  border: none;
  transition: background .15s, box-shadow .15s;
  white-space: nowrap;
}

.btn-primary { background: var(--blue-600); color: white; }
.btn-primary:hover { background: var(--blue-700); }

.btn-secondary {
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}
.btn-secondary:hover { background: var(--gray-50); }

.btn-danger { background: var(--red-500); color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-success { background: var(--green-500); color: white; }
.btn-success:hover { background: #16a34a; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn svg { width: 16px; height: 16px; }

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-600);
  white-space: nowrap;
}

td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

/* ─── Tags / Badges ──────────────────────────────────────────────────────── */
.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  color: white;
  margin: 2px;
}

.tag-badge .tag-remove {
  background: none;
  border: none;
  color: rgba(255,255,255,.7);
  cursor: pointer;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  margin-left: 2px;
}
.tag-badge .tag-remove:hover { color: white; }

.tag-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}

/* Auto-Tag bekommt andere Darstellung */
.tag-auto { opacity: .85; }
.tag-manual { box-shadow: 0 0 0 2px rgba(255,255,255,.3) inset; }

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 5px;
}
.form-label.required::after { content: " *"; color: var(--red-500); }

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  background: var(--white);
  color: var(--gray-900);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-control::placeholder { color: var(--gray-400); }

textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn .15s ease;
}

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

.modal {
  background: var(--white);
  border-radius: 10px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}

.modal-lg { max-width: 780px; }

.modal-header {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--gray-400);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-700); }

.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ─── Toast ──────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 16px;
  border-radius: 8px;
  color: white;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-success { background: var(--green-500); }
.toast-error { background: var(--red-500); }
.toast-info { background: var(--blue-600); }

/* ─── Search / Filter ────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  width: 16px; height: 16px;
}

.search-input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  background: white;
}
.search-input:focus { outline: none; border-color: var(--blue-500); }

/* ─── Positions Tabelle ──────────────────────────────────────────────────── */
.pos-type-title {
  background: var(--blue-50);
  font-weight: 600;
}
.pos-type-title td { color: var(--blue-800); }

.pos-number { color: var(--gray-400); font-size: 12px; font-family: monospace; }

/* ─── Keyword-Tags ───────────────────────────────────────────────────────── */
.keyword-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  min-height: 42px;
  background: white;
}

.keyword-chip {
  background: var(--blue-100);
  color: var(--blue-800);
  border-radius: 20px;
  padding: 2px 8px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.keyword-chip button {
  background: none;
  border: none;
  color: var(--blue-600);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0;
}

.keyword-chip button:hover { color: var(--red-500); }

/* ─── Tag Select Checkboxes ──────────────────────────────────────────────── */
.tag-check-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  padding: 4px;
}

.tag-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  cursor: pointer;
}

.tag-check-item:hover { background: var(--gray-50); }
.tag-check-item input { cursor: pointer; }

/* ─── Upload Area ────────────────────────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--gray-300);
  border-radius: 8px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.upload-area:hover, .upload-area.drag-over {
  border-color: var(--blue-500);
  background: var(--blue-50);
}

.upload-area input { display: none; }
.upload-area svg { color: var(--gray-400); width: 40px; height: 40px; margin-bottom: 8px; }
.upload-area p { color: var(--gray-600); }
.upload-area span { color: var(--blue-600); font-weight: 500; }

/* ─── Email Preview ──────────────────────────────────────────────────────── */
.email-match-card {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
}

.email-match-header {
  background: var(--gray-50);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--gray-200);
}

.email-match-body { padding: 12px 16px; }

/* ─── Color Picker ───────────────────────────────────────────────────────── */
.color-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.color-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform .1s;
}
.color-dot:hover { transform: scale(1.15); }
.color-dot.selected { border-color: var(--gray-900); }

/* ─── Empty State ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; color: var(--gray-600); margin-bottom: 4px; }
.empty-state p { font-size: 13px; }

/* ─── Loading ────────────────────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--gray-400);
}

.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--blue-600);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Utility ────────────────────────────────────────────────────────────── */
.text-sm { font-size: 12px; }
.text-muted { color: var(--gray-400); }
.text-danger { color: var(--red-500); }
.text-success { color: var(--green-500); }
.fw-600 { font-weight: 600; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8 { gap: 8px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
