/* ============================================================
   Ingenieurbüro Bromberger — Admin-Dashboard (Prototyp)
   ============================================================
   Farbtokens und Bausteine aus apps/gbuapp/style.css übernommen
   (Markenfarbe --primary: #235a81), gekürzt auf das, was hier
   gebraucht wird. Kopie, keine Verlinkung: die Apps bleiben unberührt.
   ============================================================ */

:root {
  --primary:      #235a81;
  --primary-dark: #17405d;
  --primary-light:#e2eff8;
  --accent:       #f97316;
  --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-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;
}

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

body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h2 { font-size: 1.15rem; font-weight: 600; color: var(--gray-800); }
h3 { font-size: .95rem; font-weight: 600; color: var(--gray-700); }
.hidden { display: none !important; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: .82rem; }

/* ─── Kopfleiste ─────────────────────────────────────────── */

.app-header {
  position: sticky; top: 0; z-index: 100;
  height: 56px;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0 1rem;
  box-shadow: var(--shadow-md);
}
.app-header .logo { display: flex; align-items: center; gap: .75rem; font-weight: 700; white-space: nowrap; }
.app-header .logo img { height: 38px; width: auto; display: block; }
.app-header .logo .titel { font-size: 1rem; border-left: 1px solid rgba(255,255,255,.35); padding-left: .75rem; }
.prototyp-hinweis {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  background: rgba(255,255,255,.18); padding: .1rem .45rem; border-radius: 99px;
}
.header-right { display: flex; align-items: center; gap: .75rem; font-size: .8rem; }
.header-right a { color: white; opacity: .85; text-decoration: none; }
.header-right a:hover { opacity: 1; text-decoration: underline; }

/* ─── Reiter ─────────────────────────────────────────────── */

.nav-bar {
  background: white; border-bottom: 1px solid var(--gray-200);
  display: flex; overflow-x: auto; padding: 0 1rem;
}
.nav-btn {
  display: flex; align-items: center; gap: .4rem;
  padding: .75rem 1rem; font-size: .85rem; font-weight: 500; font-family: var(--font);
  color: var(--gray-500); background: none; border: none;
  border-bottom: 2px solid transparent; cursor: pointer;
}
.nav-btn:hover { color: var(--primary); }
.nav-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.nav-zaehler {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.15rem; height: 1.15rem; padding: 0 .3rem; border-radius: 99px;
  background: var(--warn); color: white; font-size: .68rem; font-weight: 700;
}

main { max-width: 1280px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.tab { display: none; }
.tab.active { display: block; }

.leiste { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.leiste h2 { margin-right: auto; }
.leiste input[type=search] { width: 260px; }

/* ─── Kacheln ────────────────────────────────────────────── */

/* Alle sieben Kacheln in EINER Zeile; erst auf schmalen Bildschirmen umbrechen. */
.kacheln { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .6rem; margin-bottom: 1.25rem; }
@media (max-width: 1000px) { .kacheln { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); } }
.kachel {
  background: white; border: 1px solid var(--gray-200); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: .75rem .8rem;
}
.kachel .zahl { font-size: 1.55rem; font-weight: 700; color: var(--primary); line-height: 1.1; }
.kachel .bez { font-size: .74rem; color: var(--gray-500); margin-top: .2rem; line-height: 1.3; }

.schnellzugriff { margin-bottom: 1.25rem; }
.schnellzugriff .app-links { margin-top: .25rem; }
.kachel.warn .zahl { color: var(--warn); }

.zwei-spalten { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .zwei-spalten { grid-template-columns: 1fr; } }

.card {
  background: white; border-radius: var(--radius); box-shadow: var(--shadow-md);
  border: 1px solid var(--gray-200); padding: 1rem;
}
.card h3 { margin-bottom: .6rem; }
.leer { color: var(--gray-500); font-size: .85rem; padding: .25rem 0; }

.hinweis-liste { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.hinweis-liste details summary { cursor: pointer; font-size: .88rem; }
.hinweis-liste details ul { margin: .4rem 0 .2rem 1.2rem; font-size: .84rem; }
.hinweis-liste .anzahl { font-weight: 700; color: var(--warn); }
.hinweis-liste .anzahl.null { color: var(--success); }

.anfrage-zeile {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .45rem 0; border-bottom: 1px solid var(--gray-100); font-size: .88rem;
}
.anfrage-zeile:last-child { border-bottom: none; }

/* ─── Knöpfe ─────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem; font-size: .85rem; font-weight: 500; font-family: var(--font);
  border-radius: var(--radius-sm); border: none; cursor: pointer; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #0f6337; }
.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-sm { padding: .3rem .65rem; font-size: .78rem; }
.link-btn {
  background: none; border: none; padding: 0; font: inherit; color: var(--primary);
  cursor: pointer; text-align: left; font-weight: 600;
}
.link-btn:hover { text-decoration: underline; }

/* ─── Formulare ──────────────────────────────────────────── */

label { font-size: .78rem; font-weight: 500; color: var(--gray-600); }
input, select, textarea {
  width: 100%; padding: .5rem .7rem; font-size: .88rem; font-family: var(--font);
  border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
  background: white; color: var(--gray-800); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(35,90,129,.15); }
input[type=checkbox] { width: auto; }
textarea { resize: vertical; min-height: 64px; }
.form-group { display: flex; flex-direction: column; gap: .3rem; }
.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.check { display: flex; align-items: center; gap: .45rem; font-size: .85rem; color: var(--gray-700); }
.feld-hinweis { font-size: .75rem; color: var(--gray-500); }

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

.badge {
  display: inline-flex; align-items: center; padding: .1rem .5rem; border-radius: 99px;
  font-size: .7rem; font-weight: 600; white-space: nowrap;
}
.badge-frei      { background: var(--success-light); color: var(--success); }
.badge-angefragt { background: var(--warn-light);    color: var(--warn); }
.badge-kein      { background: var(--gray-100);      color: var(--gray-400); }
.badge-admin     { background: var(--primary-light); color: var(--primary-dark); }
.badge-inaktiv   { background: var(--error-light);   color: var(--error); }

/* ─── Tabellen ───────────────────────────────────────────── */

.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: .84rem; }
.data-table th {
  text-align: left; padding: .55rem .8rem; font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: #fff;
  background: var(--primary); white-space: nowrap;
}
.data-table th.zahl, .data-table td.zahl { text-align: right; }
/* Firmenübersicht: der Name nahm sonst allen Restplatz; lange Namen brechen um */
.data-table th.spalte-firma { width: 32%; }
/* Ort: volle Anschriften der Betreuungskunden zogen die Spalte sonst breit */
.data-table th.spalte-ort { width: 22%; }
.data-table td { padding: .5rem .8rem; 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 tr.angefragt td { background: var(--warn-light); }
.data-table tr.inaktiv td { color: var(--gray-400); }
.status-zelle { display: flex; gap: .25rem; flex-wrap: wrap; }

/* kleine Tabelle im Detailfenster */
.mini-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.mini-table th { text-align: left; font-size: .7rem; text-transform: uppercase; color: var(--gray-500); padding: .3rem .4rem; border-bottom: 1px solid var(--gray-200); }
.mini-table td { padding: .35rem .4rem; border-bottom: 1px solid var(--gray-100); vertical-align: top; }
.mini-table tr.inaktiv td { color: var(--gray-400); }

/* ─── Detailfenster ──────────────────────────────────────── */

.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 .15s;
}
.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; display: flex; flex-direction: column;
}
.modal.breit { max-width: 900px; }
.modal-head {
  padding: .9rem 1.2rem; border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.modal-body { padding: 1.1rem 1.2rem; display: flex; flex-direction: column; gap: .8rem; overflow-y: auto; }
.modal-foot {
  padding: .8rem 1.2rem; border-top: 1px solid var(--gray-200);
  display: flex; gap: .5rem; justify-content: flex-end; align-items: center;
}
.modal-foot .links { margin-right: auto; }
.schliessen { background: none; border: none; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--gray-500); }

.abschnitt { border-top: 1px solid var(--gray-200); padding-top: .8rem; }
.abschnitt-kopf { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.info-grid { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; font-size: .85rem; }
.info-grid dt { color: var(--gray-500); }
.mini-kacheln { display: flex; gap: .5rem; flex-wrap: wrap; }
.mini-kacheln span { background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: var(--radius-sm); padding: .3rem .6rem; font-size: .8rem; }
.mini-kacheln b { color: var(--primary); }

/* Info-Fenster im Stil des Firmen-Details der Protokollapp
   (apps/protokollapp/admin.html, .info-liste/.info-titel/.info-zeile) */
.info-liste { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; font-size: .9rem; margin: 0; }
.info-liste dt { color: var(--gray-500); font-weight: 500; }
.info-liste dd { margin: 0; color: var(--gray-900); word-break: break-word; }
.info-titel {
  display: flex; align-items: center; gap: .5rem;
  font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--gray-500); margin: .5rem 0 .3rem;
}
.info-titel .badge { text-transform: none; letter-spacing: 0; }
.info-zeile {
  display: flex; align-items: center; gap: .5rem; width: 100%; text-align: left;
  padding: .45rem .7rem; border: 1px solid var(--gray-200); border-radius: var(--radius);
  background: white; font-size: .88rem; color: var(--gray-900); margin-bottom: .3rem;
}
.info-zeile .info-neben { margin-left: auto; font-size: .82rem; color: var(--gray-600); font-weight: 600; }
.info-zeile.zuw-neu { border-color: var(--success); background: var(--success-light); }

.app-bloecke { display: grid; grid-template-columns: 1fr 1fr; gap: .25rem 1rem; }
@media (max-width: 640px) { .app-bloecke { grid-template-columns: 1fr; } }

.zuw-details { border: 1px solid var(--gray-200); border-radius: var(--radius); padding: .5rem .7rem; }
.zuw-details summary { cursor: pointer; font-size: .88rem; font-weight: 600; color: var(--gray-800); }
.zuw-details[open] summary { margin-bottom: .5rem; }
.zuw-suche { margin-top: .5rem; }

/* Projekt-Dropdown neben der zugewiesenen Firma */
.proj-dd { position: relative; margin-left: auto; }
.zuw-details .proj-dd > summary {
  list-style: none; cursor: pointer; margin: 0; font-size: .8rem; font-weight: 500; color: var(--gray-700);
  border: 1px solid var(--gray-300); border-radius: var(--radius-sm); padding: .2rem .55rem; background: white; white-space: nowrap;
}
.proj-dd > summary::-webkit-details-marker { display: none; }
.proj-dd > summary::after { content: ' ▾'; color: var(--gray-500); }
.proj-dd[open] > summary { border-color: var(--primary); }
.proj-menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 6; min-width: 16rem; max-height: 320px; overflow-y: auto;
  background: white; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  padding: .5rem .7rem; display: flex; flex-direction: column; gap: .35rem;
}
.proj-menu .feld-hinweis { margin: 0 0 .15rem; }
/* Unterprojekt-Fenster unter einem Projekt im Dropdown (eingerückt, klappt im Menü auf) */
.up-dd { margin: -.2rem 0 .1rem 1.6rem; }
.zuw-details .up-dd > summary { cursor: pointer; margin: 0; font-size: .76rem; font-weight: 500; color: var(--primary); }
.up-menu {
  margin-top: .3rem; padding: .4rem .55rem; border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
  background: var(--gray-50); display: flex; flex-direction: column; gap: .3rem;
}
.up-menu .feld-hinweis { margin: 0; }
.proj-keine { margin-left: auto; font-size: .8rem; color: var(--gray-500); white-space: nowrap; }
/* Dropdown und „Entfernen" rücken gemeinsam nach rechts */
.info-zeile .proj-dd + .info-neben, .info-zeile .proj-keine + .info-neben { margin-left: 0; }

.verwaltung { background: var(--gray-50); margin: 0 -1.2rem -1.1rem; padding: .9rem 1.2rem 1.1rem; }

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

/* Firmenzuweisung */
.zuw-liste { display: flex; flex-wrap: wrap; gap: .35rem; }
.zuw-chip {
  display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem;
  background: var(--primary-light); color: var(--primary-dark);
  padding: .15rem .3rem .15rem .6rem; border-radius: 99px;
}
.zuw-chip.neu { outline: 2px dashed var(--success); }
.zuw-chip.archiviert { background: var(--gray-100); color: var(--gray-500); }
.zuw-chip button { background: none; border: none; cursor: pointer; font-size: 1rem; line-height: 1; color: inherit; padding: 0 .2rem; }
.zuw-weg { font-size: .78rem; color: var(--error); }
.zuw-suche { position: relative; }
.zuw-treffer {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 5; background: white;
  border: 1px solid var(--gray-300); border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  max-height: 220px; overflow-y: auto;
}
.zuw-treffer button {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: .4rem .7rem; font: inherit; font-size: .85rem; cursor: pointer;
}
.zuw-treffer button:hover, .zuw-treffer button:focus { background: var(--primary-light); outline: none; }

/* ─── 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; padding: .6rem 1rem; border-radius: var(--radius-sm);
  font-size: .85rem; box-shadow: var(--shadow-md); max-width: 30rem;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--error); }

.lade-fehler {
  background: var(--error-light); color: var(--error); border: 1px solid #fecaca;
  border-radius: var(--radius-sm); padding: .7rem 1rem; margin-bottom: 1rem; font-size: .88rem;
}

/* ─── Anmeldung ──────────────────────────────────────────── */

.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}
.auth-card {
  background: white; border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 400px; padding: 1.75rem; display: flex; flex-direction: column; gap: .9rem;
}
.auth-card h1 { font-size: 1.25rem; color: var(--primary); }
.auth-alert { display: none; font-size: .85rem; padding: .6rem .8rem; border-radius: var(--radius-sm); }
.auth-alert.error { display: block; background: var(--error-light); color: var(--error); }
.auth-alert.info  { display: block; background: var(--primary-light); color: var(--primary-dark); }

/* ─── 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; }
}
