/* KommunalOS · ITSM-Modul — Arbeitsoberfläche für Agenten & Admins.
   Helle, dichte Oberfläche. Keine externen Abhängigkeiten. */

:root {
  --primary: #2273B9;
  --primary-dunkel: #185a92;
  --primary-hell: #e8f1f9;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --rot: #dc2626;
  --rot-hell: #fee2e2;
  --orange: #ea580c;
  --orange-hell: #ffedd5;
  --amber: #d97706;
  --amber-hell: #fef3c7;
  --gruen: #16a34a;
  --gruen-hell: #dcfce7;
  --violett: #7c3aed;
  --violett-hell: #ede9fe;
  --blau: #2273B9;
  --blau-hell: #dbeafe;
  --grau: #64748b;
  --grau-hell: #f1f5f9;
  --schatten: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --schatten-gross: 0 10px 30px rgba(15, 23, 42, .18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 0 0 8px; }

/* ── Formulare ─────────────────────────────────────────────────────── */
input, select, textarea, button {
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
}
input[type="text"], input[type="search"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="file"], select, textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 9px;
  background: #fff;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}
textarea { resize: vertical; min-height: 70px; }
label.feld { display: block; margin-bottom: 10px; font-size: 12px; color: var(--muted); font-weight: 600; }
label.feld > input, label.feld > select, label.feld > textarea { margin-top: 3px; font-weight: 400; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; user-select: none; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}
.btn:hover { background: var(--grau-hell); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primaer { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primaer:hover { background: var(--primary-dunkel); }
.btn.gefahr { color: var(--rot); border-color: #fecaca; }
.btn.gefahr:hover { background: var(--rot-hell); }
.btn.klein { padding: 3px 8px; font-size: 12px; }
.btn.geist { border-color: transparent; background: transparent; color: var(--primary); }
.btn.geist:hover { background: var(--primary-hell); }

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

#sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: 220px;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  overflow-y: auto;
  z-index: 20;
}
#sidebar .logo {
  font-weight: 800; font-size: 15px; padding: 4px 10px 14px;
  color: var(--text);
}
#sidebar .logo .modul { color: var(--primary); }
#sidebar nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; margin-bottom: 2px;
  border-radius: 8px; color: var(--text); font-weight: 600;
}
#sidebar nav a:hover { background: var(--grau-hell); text-decoration: none; }
#sidebar nav a.aktiv { background: var(--primary-hell); color: var(--primary-dunkel); }
#sidebar .abschnitt {
  margin: 16px 10px 6px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 700;
}

#hauptbereich { flex: 1; margin-left: 220px; display: flex; flex-direction: column; min-width: 0; }

#topbar {
  position: sticky; top: 0; z-index: 15;
  display: flex; align-items: center; gap: 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 8px 20px;
}
#topbar .suche { flex: 0 1 420px; position: relative; }
#topbar .suche input { padding-left: 30px; }
#topbar .suche .lupe { position: absolute; left: 9px; top: 6px; opacity: .55; pointer-events: none; }
#topbar .spacer { flex: 1; }
.wortmarke { font-weight: 800; font-size: 14px; color: var(--muted); white-space: nowrap; }
.wortmarke .modul { color: var(--primary); }
#topbar .nutzer { font-size: 13px; color: var(--muted); white-space: nowrap; }
#topbar .nutzer b { color: var(--text); }

#view { padding: 20px; max-width: 1500px; width: 100%; }

.seitenkopf { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.seitenkopf .spacer { flex: 1; }

/* ── Karten & Tabellen ─────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 14px 16px;
}
.card.dicht { padding: 0; overflow: hidden; }

table.tabelle { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tabelle th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 700;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  background: var(--grau-hell); white-space: nowrap;
}
table.tabelle td { padding: 6px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tabelle tr:last-child td { border-bottom: none; }
table.tabelle tbody tr.klickbar { cursor: pointer; }
table.tabelle tbody tr.klickbar:hover { background: var(--primary-hell); }
.tabellen-wrap { overflow-x: auto; }
td.num, th.num { text-align: right; }
.leer-hinweis { padding: 26px; text-align: center; color: var(--muted); }

/* ── Pills ─────────────────────────────────────────────────────────── */
.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.pill.st-NEU { background: var(--blau-hell); color: var(--primary-dunkel); }
.pill.st-IN_BEARBEITUNG { background: var(--amber-hell); color: var(--amber); }
.pill.st-WARTET_RUECKMELDUNG, .pill.st-WARTET_GENEHMIGUNG { background: var(--violett-hell); color: var(--violett); }
.pill.st-GELOEST { background: var(--gruen-hell); color: var(--gruen); }
.pill.st-GESCHLOSSEN { background: var(--grau-hell); color: var(--grau); }
.pill.pr-KRITISCH { background: var(--rot-hell); color: var(--rot); }
.pill.pr-HOCH { background: var(--orange-hell); color: var(--orange); }
.pill.pr-NORMAL { background: var(--grau-hell); color: var(--grau); }
.pill.pr-NIEDRIG { background: var(--grau-hell); color: var(--muted); }
.pill.neutral { background: var(--grau-hell); color: var(--grau); }
.pill.gruen { background: var(--gruen-hell); color: var(--gruen); }
.pill.rot { background: var(--rot-hell); color: var(--rot); }
.pill.amber { background: var(--amber-hell); color: var(--amber); }
.pill.blau { background: var(--blau-hell); color: var(--primary-dunkel); }
.pill.violett { background: var(--violett-hell); color: var(--violett); }
.rot-text { color: var(--rot); font-weight: 700; }

/* ── Filterleiste ──────────────────────────────────────────────────── */
.filterleiste {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 12px;
}
.filterleiste select, .filterleiste input { width: auto; min-width: 130px; }
.filterleiste input[type="search"] { min-width: 200px; }

.pagination { display: flex; align-items: center; gap: 10px; padding: 10px 12px; font-size: 12px; color: var(--muted); }

/* ── Umschalter (Liste/Kanban, Tabs) ───────────────────────────────── */
.umschalter { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.umschalter button {
  border: none; background: #fff; padding: 6px 12px; cursor: pointer; font-weight: 600;
}
.umschalter button.aktiv { background: var(--primary); color: #fff; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs button {
  border: none; background: transparent; padding: 8px 14px; cursor: pointer;
  font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.aktiv { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Kanban ────────────────────────────────────────────────────────── */
.kanban { display: flex; gap: 12px; align-items: flex-start; overflow-x: auto; padding-bottom: 10px; }
.kanban-spalte {
  flex: 0 0 250px; background: var(--grau-hell);
  border-radius: var(--radius); padding: 8px;
  min-height: 220px;
}
.kanban-spalte h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 2px 6px 8px; margin: 0;
  display: flex; justify-content: space-between;
}
.kanban-spalte.drop-ziel { outline: 2px dashed var(--primary); outline-offset: -2px; background: var(--primary-hell); }
.kanban-karte {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; margin-bottom: 8px; cursor: grab;
  box-shadow: var(--schatten);
}
.kanban-karte:active { cursor: grabbing; }
.kanban-karte .nr { font-size: 11px; color: var(--muted); font-weight: 700; }
.kanban-karte .titel { font-weight: 600; margin: 2px 0 6px; word-break: break-word; }
.kanban-karte .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 11px; color: var(--muted); }
.kanban-karte.ziehend { opacity: .4; }

/* ── Ticket-Detail ─────────────────────────────────────────────────── */
.detail-3sp { display: grid; grid-template-columns: 290px minmax(0, 1fr) 290px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .detail-3sp { grid-template-columns: 1fr; } }

.timeline { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.blase {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 8px 12px; background: #fff; max-width: 92%;
}
.blase .kopf { font-size: 11px; color: var(--muted); margin-bottom: 3px; font-weight: 600; }
.blase .text { white-space: pre-wrap; word-break: break-word; }
.blase.intern { background: var(--amber-hell); border-color: #fde68a; }
.blase.mail { background: var(--blau-hell); border-color: #bfdbfe; }
.systemzeile {
  font-size: 11px; color: var(--muted); text-align: center;
  padding: 1px 0;
}
.systemzeile .zeit { opacity: .7; }

.editor { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.editor .optionen { display: flex; align-items: center; gap: 14px; margin: 8px 0; flex-wrap: wrap; }

.fortschritt { height: 8px; background: var(--grau-hell); border-radius: 999px; overflow: hidden; margin: 8px 0 12px; }
.fortschritt > div { height: 100%; background: var(--gruen); border-radius: 999px; transition: width .2s; }
.task-zeile { display: flex; align-items: flex-start; gap: 8px; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.task-zeile:last-child { border-bottom: none; }
.task-zeile input[type="checkbox"] { margin-top: 3px; width: auto; }
.task-zeile .erledigt { text-decoration: line-through; color: var(--muted); }
.task-zeile .entfaellt { text-decoration: line-through; color: var(--muted); font-style: italic; }

.status-buttons { display: flex; flex-direction: column; gap: 8px; }

.stammdaten-zeile { margin-bottom: 10px; }
.stammdaten-zeile .lbl { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }

.mini-card {
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px;
  background: var(--grau-hell); font-size: 12px;
}

/* ── Autocomplete ──────────────────────────────────────────────────── */
.ac-wrap { position: relative; }
.ac-liste {
  position: absolute; left: 0; right: 0; top: calc(100% + 3px); z-index: 60;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--schatten-gross); max-height: 260px; overflow-y: auto;
}
.ac-liste .ac-eintrag { padding: 7px 11px; cursor: pointer; }
.ac-liste .ac-eintrag:hover, .ac-liste .ac-eintrag.aktiv { background: var(--primary-hell); }
.ac-liste .ac-eintrag .sub { font-size: 11px; color: var(--muted); }

/* ── Chips ─────────────────────────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--grau-hell); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600;
}
.chip button {
  border: none; background: transparent; cursor: pointer;
  color: var(--muted); font-weight: 700; padding: 0 2px; font-size: 13px;
}
.chip button:hover { color: var(--rot); }

/* ── Modal ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 5vh 16px; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: var(--radius); box-shadow: var(--schatten-gross);
  width: 100%; max-width: 560px; padding: 18px 20px;
}
.modal.breit { max-width: 860px; }
.modal .modal-kopf { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal .modal-kopf h2 { margin: 0; }
.modal .schliessen { border: none; background: transparent; font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal .aktionen { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.formular-2sp { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 640px) { .formular-2sp { grid-template-columns: 1fr; } }

/* ── Toasts ────────────────────────────────────────────────────────── */
#toasts { position: fixed; bottom: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text); color: #fff; border-radius: 10px;
  padding: 10px 16px; box-shadow: var(--schatten-gross);
  max-width: 380px; font-size: 13px; animation: toast-rein .18s ease-out;
}
.toast.fehler { background: var(--rot); }
.toast.erfolg { background: var(--gruen); }
@keyframes toast-rein { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Login / Vollbild-Hinweise ─────────────────────────────────────── */
.vollbild {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 20px;
}
.vollbild .box {
  background: #fff; border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--schatten-gross); padding: 30px 34px; width: 100%; max-width: 400px;
}
.vollbild .box .marke { font-weight: 800; font-size: 18px; margin-bottom: 4px; color: var(--muted); }
.vollbild .box .marke .modul { color: var(--primary); }
.vollbild .box .untertitel { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.login-fehler { color: var(--rot); font-size: 13px; margin-top: 8px; min-height: 18px; }

/* ── KPI-Kacheln & Diagramme (Reports) ─────────────────────────────── */
.kpi-raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--schatten);
}
.kpi .wert { font-size: 26px; font-weight: 800; color: var(--primary-dunkel); line-height: 1.2; }
.kpi .wert.warn { color: var(--rot); }
.kpi .lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.report-raster { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; }
.diagramm-wrap { overflow-x: auto; }
.export-zeile { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.export-url { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.export-url input { font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); }

/* ── Asset-Detail ──────────────────────────────────────────────────── */
.asset-kopf { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.asset-kopf .invnr { font-size: 26px; font-weight: 800; letter-spacing: .02em; }
.asset-kopf .qr { background: #fff; padding: 6px; border: 1px solid var(--border); border-radius: 10px; }
.asset-kopf .qr img, .asset-kopf .qr canvas { display: block; }

/* ── Kategorien-Baum / Wizard / Sonstiges ──────────────────────────── */
.baum-einrueckung { color: var(--muted); }
.wizard-schritte { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.wizard-schritte .schritt {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 12px; border-radius: 999px; background: var(--grau-hell);
  color: var(--muted); font-weight: 600; font-size: 12px;
}
.wizard-schritte .schritt.aktiv { background: var(--primary); color: #fff; }
.wizard-schritte .schritt.fertig { background: var(--gruen-hell); color: var(--gruen); }
.mapping-select { min-width: 150px; }
.hinweis { font-size: 12px; color: var(--muted); }
.fehler-box {
  background: var(--rot-hell); border: 1px solid #fecaca; color: var(--rot);
  border-radius: 10px; padding: 10px 14px; margin: 8px 0;
}
.lade { color: var(--muted); padding: 30px; text-align: center; }
.bestell-karten { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.schema-feld-zeile {
  display: grid; grid-template-columns: 1fr 1fr 110px 1fr 60px 30px; gap: 6px;
  align-items: center; margin-bottom: 6px;
}
@media (max-width: 800px) { .schema-feld-zeile { grid-template-columns: 1fr 1fr; } }
