/* ============================================================
   Ingenieurbüro Bromberger — GBU-App · Design System
   ============================================================
   Gemeinsame Bausteine. App-spezifisches CSS steht im <style>-Block
   am Kopf von app.html — so macht es auch die Protokollapp.

   Farbtokens und Grundbausteine sind mit apps/protokollapp/style.css
   abgeglichen (Markenfarbe --primary: #235a81). Die Tabellenstile
   stammen aus apps/vertriebsapp/style.css (.lead-table), weil die
   Protokollapp gar keine Tabellenstile hat.
   ============================================================ */

:root {
  --primary:      #235a81;
  --primary-dark: #17405d;
  --primary-light:#e2eff8;
  --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); text-transform: uppercase; }
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;
}

/* Regel wortgleich aus apps/protokollapp/style.css bzw.
   apps/vertriebsapp/style.css — damit das Logo in allen drei Apps
   gleich hoch steht. Die Bilddatei ist dieselbe (gleiche Pruefsumme),
   liegt hier aber im App-Wurzelverzeichnis wie bei der Protokollapp,
   nicht unter reference/ wie bei der Vertriebsapp: der spaetere
   Cloudflare-Job soll das ganze Verzeichnis ausliefern. */
.app-header .logo img.logo-img {
  height: 38px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.header-user {
  font-size: .8rem;
  opacity: .9;
  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;
}
.nav-bar::-webkit-scrollbar { display: none; }

.nav-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .7rem 1rem;
  font-size: .82rem;
  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: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;
  font-family: var(--font);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:disabled:active { transform: none; }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-accent  { background: var(--accent); color: white; }
.btn-accent:hover:not(:disabled) { background: var(--accent-dark); }

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border: 1px solid var(--gray-300);
}
.btn-ghost:hover:not(:disabled) { background: var(--gray-100); color: var(--gray-800); }

.btn-danger { background: var(--error); color: white; }
.btn-danger:hover:not(:disabled) { background: #a12b23; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { 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: .35rem .5rem; }

/* ─── 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(35,90,129,.15);
}
textarea { resize: vertical; min-height: 80px; }

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

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

.badge {
  display: inline-flex;
  align-items: center;
  padding: .15rem .6rem;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
}
.badge-migriert { background: var(--gray-100);      color: var(--gray-600); }
.badge-manuell  { background: var(--primary-light); color: var(--primary-dark); }
.badge-pdf      { background: var(--warn-light);    color: var(--warn); }

/* ─── Tabelle ─────────────────────────────────────────────── */
/* Vorlage: apps/vertriebsapp/style.css, .lead-table */

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.data-table th {
  text-align: left;
  padding: .6rem .9rem;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #fff;
  background: var(--primary);
  border-bottom: 2px solid var(--primary-dark);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--primary-light); }
.data-table th .sort-ind {
  margin-left: 5px;
  font-size: 1rem;
  line-height: 1;
  color: rgba(255, 255, 255, .55);
  font-weight: 900;
  vertical-align: middle;
}
.data-table th .sort-ind.active { color: #fff; }
.data-table td {
  padding: .6rem .9rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--gray-50); }
.data-table tbody tr.klickbar { cursor: pointer; }
.data-table .td-titel { font-weight: 700; }
.data-table .nowrap { white-space: nowrap; }
.data-table .td-gedaempft { color: var(--gray-500); font-size: .8rem; }

/* ─── 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: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal--breit { max-width: 820px; }

.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;
}

.toast {
  background: var(--gray-800);
  color: white;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  box-shadow: var(--shadow-md);
  animation: slideIn .2s ease;
  max-width: 30rem;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--error); }
.toast-close-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0 .1rem;
  opacity: .75;
  flex-shrink: 0;
  margin-left: auto;
}
.toast-close-btn:hover { opacity: 1; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── 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 p { font-size: .9rem; }

/* ─── Seiten-Layout ───────────────────────────────────────── */

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

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

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

/* ─── Drop-Zone ───────────────────────────────────────────── */

.drop-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  color: var(--gray-500);
  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--busy { opacity: .6; pointer-events: none; }

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

/* Uebernommen aus apps/vertriebsapp/style.css. Ohne .auth-tabs/.auth-tab:
   die GBU-App hat keine Registrierung, also auch keinen Umschalter. */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  /* Spalte statt Zeile: der App-Wechsler stuende sonst NEBEN der Karte.
     min-height (nicht height) laesst die Seite bei langen Formularen wachsen. */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 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-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; }

/* Innenabstand der beiden Anmeldeformulare. .auth-card setzt nur den
   Abstand ZWISCHEN Logo, Meldung und Formular. */
.stack { display: flex; flex-direction: column; gap: .75rem; }

/* ─── Scrollbar ───────────────────────────────────────────── */

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

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

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.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;
}

/* ─── App-Wechsler (Verlinkung zwischen den Bromberger-Apps) ─── */

/* Das Markup baut app-links.js, hier steht nur das Aussehen.
   Standard: blaues Symbol auf weisser Kachel. Beide Anmeldebildschirme
   liegen auf dem dunkelblauen Verlauf, die weisse Kachel setzt sich
   davon klar ab. Fuer helle Flaechen (z. B. spaeter im App-Header)
   gibt es .app-links--hell.

   --app-link-label ist bewusst getrennt von --app-link-fg: das Symbol
   sitzt IN der Kachel, die Beschriftung darunter aber auf dem
   Seitenhintergrund. Beide dieselbe Farbe zu geben macht die
   Beschriftung auf dunklem Grund unlesbar. */

.app-links {
  --app-link-fg:       var(--primary);
  --app-link-bg:       #fff;
  --app-link-border:   transparent;
  --app-link-bg-hover: var(--primary-light);
  --app-link-label:    #fff;

  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
}
/* display:flex oben wuerde das hidden-Attribut sonst uebersteuern */
.app-links[hidden] { display: none; }

.app-links--hell {
  --app-link-fg:       var(--primary);
  --app-link-bg:       var(--primary-light);
  --app-link-border:   var(--gray-200);
  --app-link-bg-hover: #cfe6f5;
  --app-link-label:    var(--gray-600);
}

.app-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  width: 5.25rem;
  text-decoration: none;
  color: var(--app-link-label);
}
.app-link-icon {
  color: var(--app-link-fg);
  width: 58px;
  height: 58px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--app-link-bg);
  border: 1px solid var(--app-link-border);
  transition: background .15s ease, transform .15s ease;
}
.app-link-icon svg { width: 30px; height: 30px; }
.app-link-label {
  font-size: .72rem;
  line-height: 1.25;
  text-align: center;
  opacity: .9;
}
.app-link:hover .app-link-icon { background: var(--app-link-bg-hover); transform: translateY(-2px); }
.app-link:hover .app-link-label { opacity: 1; }
.app-link:focus-visible { outline: none; }
.app-link:focus-visible .app-link-icon {
  outline: 2px solid var(--app-link-fg);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .app-link-icon { transition: none; }
  .app-link:hover .app-link-icon { transform: none; }
}
