/* ============================================================================
   XMB Ticketing — Enterprise-ITSM-Oberfläche (ServiceNow-inspiriert)
   Markenfarben: Dark Purple #921BB2 · Blue #362FCC · Neon Pink #CD20B2
   ========================================================================== */

:root {
  --purple: #921BB2;
  --blue: #362FCC;
  --pink: #CD20B2;
  --white: #FFFFFF;

  --ink: #181b29;
  --ink-soft: #5f6577;
  --ink-faint: #8b90a3;
  --line: #e6e8f0;
  --line-soft: #eef0f6;
  --canvas: #f3f4f9;
  --card: #ffffff;

  /* Sidebar (dunkel, mit Marken-Tönung) */
  --side-bg-1: #17122b;
  --side-bg-2: #221a40;
  --side-text: #c7c3dc;
  --side-text-dim: #8b86a8;
  --side-active: #ffffff;

  --ok: #0c8a52;
  --warn: #b7791f;
  --danger: #d4313b;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(20, 22, 40, .05);
  --shadow: 0 4px 16px rgba(20, 22, 40, .08);
  --shadow-lg: 0 12px 40px rgba(20, 22, 40, .14);

  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --sidebar-w: 256px;
  --topbar-h: 62px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--canvas);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================================
   Shell-Layout: Sidebar + Hauptbereich
   ========================================================================== */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: linear-gradient(180deg, var(--side-bg-1) 0%, var(--side-bg-2) 100%);
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 30;
  display: flex; flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, .04);
}

.brand {
  display: flex; align-items: center; justify-content: center;
  padding: 22px 18px 18px;
}
.brand:hover { text-decoration: none; }
.brand-plate {
  background: #fff; border-radius: 12px; padding: 14px 18px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .22); width: 100%;
}
.brand-plate img { height: 58px; max-width: 100%; display: block; }

.side-nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.side-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 13px; border-radius: 9px;
  color: var(--side-text); font-weight: 500; font-size: 14px;
  position: relative; transition: background .14s ease, color .14s ease;
}
.side-link svg { width: 19px; height: 19px; flex-shrink: 0; opacity: .85; }
.side-link:hover {
  background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none;
}
.side-link.active {
  background: rgba(205, 32, 178, .16); color: var(--side-active); font-weight: 600;
}
.side-link.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  background: var(--pink); border-radius: 0 3px 3px 0;
}
.side-link.active svg { opacity: 1; color: var(--pink); }

.side-foot {
  padding: 14px 14px 18px; border-top: 1px solid rgba(255, 255, 255, .06);
  display: flex; align-items: center; gap: 10px;
}
.side-user { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.avatar {
  width: 36px; height: 36px; flex-shrink: 0; border-radius: 9px;
  background: linear-gradient(135deg, var(--blue), var(--pink));
  color: #fff; font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.su-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.su-meta strong { color: #fff; font-size: 13.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.su-meta span { color: var(--side-text-dim); font-size: 11.5px; }
.side-logout {
  background: rgba(255, 255, 255, .06); border: 0; cursor: pointer;
  width: 36px; height: 36px; border-radius: 9px; color: var(--side-text);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background .14s, color .14s;
}
.side-logout svg { width: 18px; height: 18px; }
.side-logout:hover { background: rgba(212, 49, 59, .22); color: #ff9aa0; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h); background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px; padding: 0 32px;
}
.crumbs { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--ink-faint); }
.crumbs .here { color: var(--ink); font-weight: 600; }
.crumbs .sep { color: var(--line); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.content { padding: 26px 32px 64px; flex: 1; }
@media (max-width: 1000px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; }
  .content { padding: 20px; }
}

/* ============================================================================
   Seitenkopf
   ========================================================================== */
.page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.page-head h1 { font-size: 22px; margin: 0; letter-spacing: -.3px; font-weight: 700; }
.page-head .sub { color: var(--ink-soft); font-size: 13.5px; margin-top: 3px; }
.page-head .spacer { flex: 1; }

/* ============================================================================
   Karten
   ========================================================================== */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 18px; }
.card .card-head {
  padding: 14px 18px; border-bottom: 1px solid var(--line-soft);
  font-weight: 600; font-size: 13px; color: var(--ink);
  text-transform: uppercase; letter-spacing: .05em;
  display: flex; align-items: center; gap: 10px;
}
.card .card-body { padding: 18px; }

.grid-2 { display: grid; grid-template-columns: 1fr 360px; gap: 18px; align-items: start; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }

/* ============================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 9px 15px; border-radius: var(--radius-sm); font-weight: 600;
  font-size: 13.5px; font-family: var(--font); transition: .13s ease;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: #f7f8fc; border-color: #d8dbe6; text-decoration: none; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: #2a24ab; border-color: #2a24ab; }
.btn-accent { background: var(--pink); border-color: var(--pink); color: #fff; }
.btn-accent:hover { background: #b3199b; border-color: #b3199b; }
.btn-danger { background: #fff; border-color: #eccacb; color: var(--danger); }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: #f0f1f6; }
.btn-accent[disabled], .btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-accent[disabled]:hover, .btn[disabled]:hover { background: var(--pink); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ============================================================================
   Badges / Status-Pills (mit Punkt)
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 9px;
  border-radius: 6px; font-size: 12px; font-weight: 600; line-height: 1.5;
  white-space: nowrap; border: 1px solid transparent;
}
.badge.dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex-shrink: 0;
}
.badge-status-offen { background: #eef0f5; color: #565d72; }
.badge-status-bearbeitung { background: rgba(54, 47, 204, .10); color: var(--blue); }
.badge-status-review { background: rgba(146, 27, 178, .11); color: var(--purple); }
.badge-status-geloest { background: rgba(12, 138, 82, .13); color: var(--ok); }

.badge-prio-1 { background: #eef0f5; color: #5b6072; }
.badge-prio-2 { background: rgba(54, 47, 204, .09); color: var(--blue); }
.badge-prio-3 { background: rgba(205, 32, 178, .11); color: var(--pink); }
.badge-prio-4 { background: rgba(212, 49, 59, .12); color: var(--danger); }

.badge-type { background: #f1f2f7; color: #555b6e; border-color: var(--line); }

/* ============================================================================
   Tabellen
   ========================================================================== */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px; vertical-align: middle;
}
.table th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-faint); font-weight: 600; background: #fafbfd;
  border-bottom: 1px solid var(--line);
}
.table tbody tr { transition: background .1s ease; }
.table tbody tr:hover { background: #f8f9fd; }
.table tbody tr:last-child td { border-bottom: 0; }
.table td .nr, .nr { font-family: var(--mono); font-weight: 600; font-size: 12.5px;
  color: var(--purple); letter-spacing: -.2px; }
.table a { color: var(--ink); font-weight: 600; }
.table a:hover { color: var(--blue); }
.muted { color: var(--ink-soft); }
.empty { padding: 48px 20px; text-align: center; color: var(--ink-faint); }

/* Sortierbare Spaltenköpfe */
.th-sort {
  display: inline-flex; align-items: center; gap: 5px; color: var(--ink-faint);
  font: inherit; text-transform: inherit; letter-spacing: inherit;
}
.th-sort:hover { color: var(--ink); text-decoration: none; }
.th-sort.active { color: var(--blue); }
.th-arrow { font-size: 10px; opacity: .5; }
.th-sort:hover .th-arrow, .th-sort.active .th-arrow { opacity: 1; }

/* Pagination */
.pagination {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-top: 1px solid var(--line); font-size: 13px;
}

/* ============================================================================
   Filterleiste
   ========================================================================== */
.filterbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px;
}
.filterbar select, .filterbar input[type="search"], .field input,
.field select, .field textarea {
  font-family: var(--font); font-size: 13.5px; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 11px; background: #fff; outline: none; transition: .13s;
}
.filterbar input[type="search"] { min-width: 240px; }
.filterbar select:focus, .filterbar input:focus, .field input:focus,
.field select:focus, .field textarea:focus {
  border-color: var(--blue); box-shadow: 0 0 0 3px rgba(54, 47, 204, .12);
}

/* ============================================================================
   Formulare
   ========================================================================== */
.field { margin-bottom: 15px; display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: 12.5px; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .03em; }
.field input, .field select, .field textarea { width: 100%; }
.field textarea { resize: vertical; line-height: 1.55; }
.field .errorlist { color: var(--danger); font-size: 13px; margin: 2px 0 0; padding-left: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
.checkbox-row { flex-direction: row; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }
.checkbox-row label, .checkbox-row span { text-transform: none; letter-spacing: 0; font-weight: 500; }

/* ============================================================================
   Meta-Liste (Ticket-Details)
   ========================================================================== */
.meta-list { display: grid; grid-template-columns: 1fr; gap: 0; }
.meta-list .row {
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid var(--line-soft);
}
.meta-list .row:last-child { border-bottom: 0; }
.meta-list .k { color: var(--ink-faint); font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; font-weight: 600; }
.meta-list .v { font-weight: 600; text-align: right; font-size: 13.5px; }

/* ============================================================================
   Verlauf (Timeline)
   ========================================================================== */
.verlauf-item {
  padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  margin-bottom: 11px; background: #fff; position: relative;
  border-left: 3px solid var(--ok);
}
.verlauf-item.intern { background: #fffaf0; border-color: #f1e2bf; border-left-color: var(--warn); }
.verlauf-item .meta { font-size: 12px; color: var(--ink-soft); margin-bottom: 6px;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.verlauf-item .meta strong { color: var(--ink); font-weight: 600; }
.tag-intern { background: rgba(183, 121, 31, .15); color: var(--warn); padding: 1px 8px;
  border-radius: 5px; font-weight: 600; font-size: 11px; }
.tag-public { background: rgba(12, 138, 82, .14); color: var(--ok); padding: 1px 8px;
  border-radius: 5px; font-weight: 600; font-size: 11px; }

/* Systemeintrag (Änderungsprotokoll) */
.verlauf-sys {
  display: flex; align-items: center; gap: 9px; padding: 7px 4px;
  margin-bottom: 5px; font-size: 12.5px; color: var(--ink-soft);
}
.verlauf-sys svg { width: 15px; height: 15px; color: var(--ink-faint); flex-shrink: 0; }
.verlauf-sys .sys-text { font-weight: 600; color: var(--ink); }
.verlauf-sys .sys-meta { color: var(--ink-faint); font-size: 11.5px; margin-left: auto;
  white-space: nowrap; }

/* ============================================================================
   Aufwand
   ========================================================================== */
.aufwand-row td .nv { color: var(--ink-soft); }
.aufwand-row td .abger { font-size: 11px; }

/* ============================================================================
   Meldungen
   ========================================================================== */
.messages { margin-bottom: 18px; display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13.5px;
  border: 1px solid var(--line); font-weight: 500; }
.msg.success { background: rgba(12, 138, 82, .09); border-color: rgba(12, 138, 82, .28); color: #0a6e42; }
.msg.error { background: rgba(212, 49, 59, .07); border-color: rgba(212, 49, 59, .28); color: #a01b24; }
.msg.info { background: rgba(54, 47, 204, .06); border-color: rgba(54, 47, 204, .22); color: var(--blue); }

.hint { font-size: 12.5px; color: var(--ink-soft); }
.divider { height: 1px; background: var(--line-soft); margin: 14px 0; border: 0; }

/* ============================================================================
   Ticket-Detailkopf
   ========================================================================== */
.kopf-grid { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.kopf-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Schnellverwaltung (Status/Zuweisung) */
.verwalten { display: flex; flex-direction: column; gap: 12px; }
.verwalten .field { margin-bottom: 0; }

.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator { opacity: 1; }

/* ============================================================================
   Dashboard
   ========================================================================== */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px; margin-bottom: 18px;
}
.kpi {
  position: relative; overflow: hidden; display: block; text-decoration: none;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm);
  transition: transform .13s ease, box-shadow .13s ease, border-color .13s ease;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; border-color: #dadde8; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.kpi-wert { font-size: 36px; font-weight: 700; line-height: 1; color: var(--ink);
  letter-spacing: -1.5px; font-family: var(--mono); }
.kpi-label { margin-top: 9px; font-size: 12px; font-weight: 600; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .05em; }
.kpi-offen::before { background: #aab0c2; }
.kpi-bearbeitung::before { background: var(--blue); }
.kpi-bearbeitung .kpi-wert { color: var(--blue); }
.kpi-review::before { background: var(--purple); }
.kpi-review .kpi-wert { color: var(--purple); }
.kpi-geloest::before { background: var(--ok); }
.kpi-geloest .kpi-wert { color: var(--ok); }

.dash-cols { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
@media (max-width: 980px) { .dash-cols { grid-template-columns: 1fr; } }
.dash-cols .card-head { display: flex; align-items: center; gap: 8px; }
.dash-cols .card-head a { font-weight: 600; text-transform: none; letter-spacing: 0; }

.attn-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 0; border-bottom: 1px solid var(--line-soft); font-size: 13.5px;
}
.attn-row:last-child { border-bottom: 0; }
.prio-zahl { font-weight: 700; font-size: 16px; color: var(--ink); font-family: var(--mono); }

/* Diagramm-Zeile */
.chart-row {
  display: grid; grid-template-columns: 1fr 1.4fr; gap: 18px; margin-bottom: 18px;
}
@media (max-width: 980px) { .chart-row { grid-template-columns: 1fr; } }
.chart-box { position: relative; height: 240px; }

/* Prioritätsbalken */
.pbar-row { display: block; text-decoration: none; padding: 9px 0; }
.pbar-row:hover { text-decoration: none; }
.pbar-row + .pbar-row { border-top: 1px solid var(--line-soft); }
.pbar-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.pbar { height: 7px; background: #eef0f5; border-radius: 99px; overflow: hidden; }
.pbar-fill { display: block; height: 100%; border-radius: 99px; transition: width .5s ease; }
.prio-1 .pbar-fill { background: #aab0c2; }
.prio-2 .pbar-fill { background: var(--blue); }
.prio-3 .pbar-fill { background: var(--pink); }
.prio-4 .pbar-fill { background: var(--danger); }
.pbar-row:hover .pbar-fill { filter: brightness(1.08); }

/* ============================================================================
   Login (unverändert beibehalten)
   ========================================================================== */
.login-wrap { min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(135deg, #2a247f 0%, #921BB2 60%, #CD20B2 120%); padding: 24px; }
.login-card { width: 100%; max-width: 460px; background: #fff;
  border-radius: 16px; box-shadow: 0 20px 60px rgba(20,15,60,.35); padding: 36px 40px; }
.login-card .logo { text-align: center; margin-bottom: 8px; }
.login-card .logo img { height: 240px; max-width: 100%; }
.login-card h1 { font-size: 18px; text-align: center; margin: 0 0 22px; }
.login-card .btn-primary { width: 100%; justify-content: center; }
.login-foot { text-align: center; color: var(--ink-soft); font-size: 12px; margin-top: 16px; }
