/* ============================================================
   Ingenieurbüro Bromberger — Vertriebsapp Design System
   Basiert auf dem Bromberger Design System (Protokollapp)
   ============================================================ */

:root {
  --primary:      #0e7490;
  --primary-dark: #0a5f73;
  --primary-light:#e0f2fe;
  --accent:       #f97316;
  --accent-dark:  #ea6c05;
  --error:        #b3342b;
  --error-light:  #fef2f2;
  --success:      #147a45;
  --success-light:#f0fdf4;
  --warn:         #b45309;
  --warn-light:   #fffbeb;
  --gray-50:      #f8fafc;
  --gray-100:     #f1f5f9;
  --gray-200:     #e2e8f0;
  --gray-300:     #cbd5e1;
  --gray-400:     #94a3b8;
  --gray-500:     #64748b;
  --gray-600:     #475569;
  --gray-700:     #334155;
  --gray-800:     #1e293b;
  --gray-900:     #0f172a;
  --radius:       10px;
  --radius-sm:    6px;
  --shadow:       0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:    0 10px 25px rgba(0,0,0,.1);
  --font:         'Segoe UI', system-ui, -apple-system, sans-serif;
  --header-h:     56px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── Typography ─────────────────────────────────────────── */

h1 { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); }
h2 { font-size: 1.25rem; font-weight: 600; color: var(--gray-800); }
h3 { font-size: 1rem; font-weight: 600; color: var(--gray-700); }
p  { color: var(--gray-600); }

/* ─── Header ─────────────────────────────────────────────── */

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  box-shadow: var(--shadow-md);
}
.app-header .logo {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
}
.app-header .logo svg { width: 22px; height: 22px; flex-shrink: 0; }
.header-right { display: flex; align-items: center; gap: .75rem; }
.header-user { font-size: .8rem; opacity: .85; white-space: nowrap; }

.sync-status {
  font-size: .75rem;
  padding: .2rem .5rem;
  border-radius: 99px;
  white-space: nowrap;
}
.sync-status.saving { background: rgba(255,255,255,.2); color: white; }
.sync-status.saved  { background: rgba(20,122,69,.3);  color: #bbf7d0; }
.sync-status.error  { background: rgba(179,52,43,.3);  color: #fecaca; }

/* ─── Navigation ─────────────────────────────────────────── */

.nav-bar {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: var(--header-h);
  z-index: 90;
}
.nav-bar::-webkit-scrollbar { display: none; }

.nav-btn {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
  padding: .6rem .9rem;
  font-size: .7rem;
  font-weight: 500;
  color: var(--gray-500);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.nav-btn svg { width: 20px; height: 20px; }
.nav-btn:hover { color: var(--primary); }
.nav-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ─── Buttons ─────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  font-size: .875rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background .15s, transform .1s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent  { background: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; color: var(--gray-600); border: 1px solid var(--gray-300); }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-800); }
.btn-danger { background: var(--error); color: white; }
.btn-danger:hover { background: #a12b23; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #0f6337; }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: .45rem; }

/* ─── Cards ───────────────────────────────────────────────── */

.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--gray-200);
  padding: 1rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}

/* ─── Forms ───────────────────────────────────────────────── */

.form-group { display: flex; flex-direction: column; gap: .35rem; }

label { font-size: .8rem; font-weight: 500; color: var(--gray-600); }

input, select, textarea {
  width: 100%;
  padding: .55rem .75rem;
  font-size: .9rem;
  font-family: var(--font);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--gray-800);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(14,116,144,.15);
}
textarea { resize: vertical; min-height: 80px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
}
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 640px) {
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  padding: 1rem;
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
}
.form-section-title {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-400);
  margin-bottom: .25rem;
}

/* ─── Badges ──────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: .15rem .55rem;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Lead-Status-Badges */
.badge-neu              { background: var(--primary-light); color: var(--primary-dark); }
.badge-in-bearbeitung   { background: var(--warn-light);    color: var(--warn); }
.badge-angebot-erstellt { background: #ede9fe;              color: #5b21b6; }
.badge-angebot-versendet{ background: #dbeafe;              color: #1d4ed8; }
.badge-bestellt         { background: var(--success-light); color: var(--success); }
.badge-abgelehnt        { background: var(--error-light);   color: var(--error); }
.badge-kein-angebot     { background: var(--gray-100);      color: var(--gray-500); }
.badge-duplikat         { background: var(--gray-100);      color: var(--gray-400); }

/* Management-Badge */
.badge-mgmt {
  background: var(--error-light);
  color: var(--error);
  font-size: .7rem;
  padding: .1rem .4rem;
}

/* GB-Badge */
.badge-gb {
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: .7rem;
}

/* ─── KPI-Karten ──────────────────────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .6rem;
}

.kpi-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  padding: .75rem 1rem;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.kpi-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.kpi-card.active { border-color: var(--primary); background: var(--primary-light); }
.kpi-card.active .kpi-num { color: var(--primary-dark); }

.kpi-num {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}
.kpi-label {
  font-size: .72rem;
  color: var(--gray-500);
  margin-top: .2rem;
}

/* ─── Lead-Tabelle ────────────────────────────────────────── */

.lead-table-wrap {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.lead-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.lead-table th {
  text-align: left;
  padding: .6rem .9rem;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
.lead-table td {
  padding: .6rem .9rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
  white-space: nowrap;
}
.lead-table tr:last-child td { border-bottom: none; }
.lead-table tr:hover td { background: var(--gray-50); cursor: pointer; }
.lead-table .td-firma { max-width: 180px; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.lead-table .td-notiz { max-width: 200px; overflow: hidden; text-overflow: ellipsis; color: var(--gray-500); font-size: .8rem; }
.lead-table .date-col { font-size: .8rem; color: var(--gray-500); }
.lead-table .overdue  { color: var(--error); font-weight: 600; }

/* Inline-Status-Select */
.status-select {
  padding: .15rem .4rem;
  font-size: .75rem;
  border-radius: 99px;
  border: 1px solid var(--gray-300);
  background: white;
  cursor: pointer;
  outline: none;
}

/* ─── Filter-Zeile ────────────────────────────────────────── */

.filter-bar {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar input, .filter-bar select {
  width: auto;
  min-width: 140px;
  padding: .4rem .65rem;
  font-size: .85rem;
}
.filter-bar .search-input { flex: 1; min-width: 200px; }

/* ─── Drag & Drop Zone ────────────────────────────────────── */

.drop-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  color: var(--gray-400);
  font-size: .85rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}
.drop-zone svg { width: 28px; height: 28px; margin: 0 auto .4rem; display: block; }

/* ─── Modal ───────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-body { padding: 1.25rem; display: flex; flex-direction: column; gap: .75rem; }
.modal-foot {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--gray-200);
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
}

/* ─── Toast ───────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-width: 320px;
}
.toast {
  background: var(--gray-800);
  color: white;
  padding: .6rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  box-shadow: var(--shadow-md);
  animation: slideIn .2s ease;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--error); }
.toast.warn    { background: var(--warn); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ─── Page Layout ─────────────────────────────────────────── */

.page { display: none; padding: 1rem; max-width: 1000px; margin: 0 auto; }
.page.active { display: block; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: .5rem;
  flex-wrap: wrap;
}

.section-title {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-400);
  margin-bottom: .5rem;
}

/* ─── Angebots-Box ────────────────────────────────────────── */

.angebot-box {
  background: var(--primary-light);
  border: 1px solid #a5f3fc;
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.angebot-box .angebot-nr {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-dark);
}

/* ─── Empty State ─────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 3rem 1rem;
  color: var(--gray-400);
  text-align: center;
}
.empty-state svg { width: 48px; height: 48px; opacity: .4; }
.empty-state p { font-size: .9rem; }

/* ─── Admin-Tabelle ───────────────────────────────────────── */

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.admin-table th {
  text-align: left;
  padding: .6rem .75rem;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}
.admin-table td {
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }

/* ─── Login-Seite ─────────────────────────────────────────── */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--gray-100) 100%);
}
.auth-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  text-align: center;
}
.auth-logo h1 { font-size: 1.25rem; }
.auth-logo .sub { font-size: .8rem; color: var(--gray-500); }
.auth-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.auth-tab {
  flex: 1;
  padding: .5rem;
  font-size: .875rem;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-500);
  transition: background .15s, color .15s;
}
.auth-tab.active { background: var(--primary); color: white; }

.auth-alert {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  display: none;
}
.auth-alert.error   { background: var(--error-light); color: var(--error); display: block; }
.auth-alert.success { background: var(--success-light); color: var(--success); display: block; }
.auth-alert.info    { background: var(--warn-light); color: var(--warn); display: block; }

/* ─── Utility ─────────────────────────────────────────────── */

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: .5rem; }
.gap-md { gap: .75rem; }
.gap-lg { gap: 1rem; }
.mt-sm { margin-top: .5rem; }
.mt-md { margin-top: .75rem; }
.mt-lg { margin-top: 1rem; }
.text-sm { font-size: .85rem; }
.text-xs { font-size: .75rem; }
.text-muted { color: var(--gray-500); }
.w-full { width: 100%; }
.hidden { display: none !important; }
.divider { border: none; border-top: 1px solid var(--gray-200); margin: .5rem 0; }
.stack { display: flex; flex-direction: column; gap: .75rem; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

@media print {
  .no-print { display: none !important; }
}
