/* ==========================================================================
   Sunset Valley Roleplay – Fraktionsverwaltung · Admin-Dashboard
   Alle Farben, Radien, Abstände und Maße zentral als Variablen.
   ========================================================================== */
:root {
  /* Flächen */
  --bg: #12161C;
  --bg-elev: #1B222C;
  --panel: #1E2530;
  --panel-2: #242C38;
  --panel-hover: #262F3C;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.11);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 8px 24px rgba(0, 0, 0, 0.18);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.45);

  /* Text */
  --text: #E4E8EE;
  --text-muted: #9BA6B5;
  --text-faint: #6C7787;

  /* Akzent */
  --accent: #4A9B8E;
  --accent-hover: #55AA9C;
  --accent-soft: rgba(74, 155, 142, 0.14);
  --accent-ink: #0E1A18;

  /* Rückmeldungen */
  --ok: #2ECC71;
  --ok-soft: rgba(46, 204, 113, 0.12);
  --warn: #E67E22;
  --warn-soft: rgba(230, 126, 34, 0.12);
  --danger: #E74C3C;
  --danger-soft: rgba(231, 76, 60, 0.12);

  /* Ticket-Status (identisch zum Discord-Bot) */
  --st-open: #95A5A6;
  --st-in-progress: #F1C40F;
  --st-questions: #3498DB;
  --st-revision: #E67E22;
  --st-accepted: #2ECC71;
  --st-rejected: #E74C3C;
  --st-closed: #2C3E50;

  /* Radien */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-pill: 999px;

  /* Abstände */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 48px;

  /* Maße */
  --sidebar-w: 256px;
  --topbar-h: 64px;
  --drawer-w: 580px;
  --content-max: 1480px;

  /* Schrift */
  --font: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 14.5px;
  --fs-md: 16px;
  --fs-lg: 19px;
  --fs-xl: 24px;
  --fs-kpi: 34px;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ---------- Grundlagen ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
p { text-wrap: pretty; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-xs); }

.icon {
  width: 18px; height: 18px; flex: none;
  stroke: currentColor; fill: none; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
}
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--mono); font-size: 0.92em; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 36px; padding: 0 var(--s-4);
  border-radius: var(--r-sm); border: 1px solid var(--border-strong);
  background: var(--panel-2); color: var(--text);
  font-size: var(--fs-sm); font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: var(--panel-hover); border-color: rgba(255,255,255,0.16); text-decoration: none; color: var(--text); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); border-color: transparent; }
.btn-danger { background: var(--danger-soft); border-color: rgba(231,76,60,0.35); color: #F1897E; }
.btn-danger:hover { background: rgba(231,76,60,0.2); border-color: rgba(231,76,60,0.5); color: #F6A59C; }
.btn-ok { background: var(--ok-soft); border-color: rgba(46,204,113,0.35); color: #6BDC9A; }
.btn-ok:hover { background: rgba(46,204,113,0.2); color: #8AE6B0; }
.btn-sm { height: 30px; padding: 0 var(--s-3); font-size: var(--fs-xs); }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.btn.is-loading { pointer-events: none; opacity: 0.7; }
.btn.is-loading .icon { animation: spin 0.8s linear infinite; }

/* ---------- Formulare ---------- */
.field { display: grid; gap: 6px; }
.field-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.field-hint { font-size: var(--fs-xs); color: var(--text-faint); }
.field-error { font-size: var(--fs-xs); color: #F1897E; }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 var(--s-3);
  background: var(--bg-elev); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); color: var(--text); font-size: var(--fs-base);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { height: auto; min-height: 96px; padding: var(--s-2) var(--s-3); resize: vertical; line-height: 1.45; }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239BA6B5' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.select option { background: var(--panel); }
.input[type="date"] { color-scheme: dark; }
.is-invalid { border-color: var(--danger) !important; }

.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none;
  height: 30px; padding: 0 var(--s-3); border-radius: var(--r-pill);
  background: var(--bg-elev); border: 1px solid var(--border-strong);
  font-size: var(--fs-sm); color: var(--text-muted);
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip .chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--role-color, var(--text-faint)); }
.chip:has(input:checked) { background: var(--accent-soft); border-color: rgba(74,155,142,0.5); color: var(--text); }
.chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- App-Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--bg-elev); border-right: 1px solid var(--border);
  z-index: 40;
}
.sb-brand { display: flex; align-items: center; gap: var(--s-3); height: var(--topbar-h); padding: 0 var(--s-5); border-bottom: 1px solid var(--border); }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: var(--r-sm); background: var(--accent-soft); color: var(--accent);
  border: 1px solid rgba(74,155,142,0.35); font-weight: 700; font-size: var(--fs-sm); letter-spacing: 0.02em;
}
.brand-name { font-weight: 600; font-size: var(--fs-base); line-height: 1.2; }
.brand-sub { font-size: var(--fs-xs); color: var(--text-faint); line-height: 1.3; }

.sb-nav { flex: 1; overflow-y: auto; padding: var(--s-4) var(--s-3); display: flex; flex-direction: column; gap: 2px; }
.sb-label { padding: var(--s-4) var(--s-3) var(--s-2); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.sb-link {
  display: flex; align-items: center; gap: var(--s-3);
  height: 38px; padding: 0 var(--s-3); border-radius: var(--r-sm);
  color: var(--text-muted); font-weight: 500;
}
.sb-link:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.sb-link.is-active { background: var(--accent-soft); color: var(--text); }
.sb-link.is-active .icon { color: var(--accent); }
.sb-count { margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); background: var(--panel-2); color: var(--text-muted); font-size: 11px; font-weight: 600; display: grid; place-items: center; }

.sb-user { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4); border-top: 1px solid var(--border); }
.avatar {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none;
  border-radius: 50%; background: var(--panel-2); border: 1px solid var(--border-strong);
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 26px; height: 26px; font-size: 10px; }
.sb-user-text { min-width: 0; flex: 1; }
.sb-user-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-role { font-size: var(--fs-xs); color: var(--text-faint); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--s-4);
  height: var(--topbar-h); padding: 0 var(--s-7);
  background: rgba(18, 22, 28, 0.88); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: var(--fs-lg); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: var(--s-3); }
.menu-toggle { display: none; }

.live { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-xs); color: var(--text-muted); padding: 0 var(--s-3); height: 28px; border-radius: var(--r-pill); border: 1px solid var(--border); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(46,204,113,0.5); animation: pulse 2.4s infinite; }
.live[data-state="polling"] .live-dot { background: var(--st-in-progress); animation: none; }
.live[data-state="offline"] .live-dot { background: var(--danger); animation: none; }

.demo-banner {
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  margin: var(--s-5) var(--s-7) 0; padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4);
  border: 1px dashed rgba(241,196,15,0.35); border-radius: var(--r-md);
  background: rgba(241,196,15,0.06); color: #E9D27A; font-size: var(--fs-sm);
}
.demo-banner .seg { margin-left: auto; }

.content { width: 100%; max-width: var(--content-max); padding: var(--s-6) var(--s-7) var(--s-8); display: grid; gap: var(--s-5); align-content: start; }
.view { display: grid; gap: var(--s-5); }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }
.view-head p { color: var(--text-muted); max-width: 68ch; }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: var(--r-sm); }
.seg button { height: 28px; padding: 0 var(--s-3); border: 0; border-radius: var(--r-xs); background: transparent; color: var(--text-muted); font-size: var(--fs-xs); font-weight: 600; cursor: pointer; }
.seg button.is-active { background: var(--panel-2); color: var(--text); }

/* ---------- Karten ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: var(--fs-md); }
.card-head .sub { font-size: var(--fs-xs); color: var(--text-faint); }
.card-body { padding: var(--s-5); }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border); font-size: var(--fs-xs); color: var(--text-faint); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-4); }
.kpi { padding: var(--s-5); display: grid; gap: var(--s-2); }
.kpi-head { display: flex; align-items: center; justify-content: space-between; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 500; }
.kpi-head .icon { color: var(--kpi-color, var(--text-faint)); }
.kpi-value { font-size: var(--fs-kpi); font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi-hint { font-size: var(--fs-xs); color: var(--text-faint); min-height: 18px; }
.kpi-value.is-flash { animation: flash 0.9s var(--ease); }

.grid-dash { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: var(--s-4); align-items: start; }
.grid-config { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: var(--s-4); align-items: start; }
.stack { display: grid; gap: var(--s-4); }

/* ---------- Status-Pill ---------- */
.status {
  --c: var(--st-open);
  display: inline-flex; align-items: center; gap: 7px;
  height: 24px; padding: 0 10px 0 8px; border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--c) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
  font-size: var(--fs-xs); font-weight: 600; color: var(--text); white-space: nowrap;
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.status[data-s="open"] { --c: var(--st-open); }
.status[data-s="in_progress"] { --c: var(--st-in-progress); }
.status[data-s="questions"] { --c: var(--st-questions); }
.status[data-s="revision"] { --c: var(--st-revision); }
.status[data-s="accepted"] { --c: var(--st-accepted); }
.status[data-s="rejected"] { --c: var(--st-rejected); }
.status[data-s="closed"] { --c: var(--st-closed); background: rgba(44,62,80,0.45); border-color: rgba(120,145,170,0.28); }
.status[data-s="closed"]::before { box-shadow: 0 0 0 1px rgba(160,180,200,0.45); }
.status[data-s="none"] { --c: var(--text-faint); }

.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: var(--r-xs); background: var(--panel-2); border: 1px solid var(--border); font-size: 11px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.tag-accent { background: var(--accent-soft); border-color: rgba(74,155,142,0.3); color: #8FCFC4; }

/* ---------- Aktivität ---------- */
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s-3); align-items: center; padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--border); cursor: pointer; }
.activity li:last-child { border-bottom: 0; }
.activity li:hover { background: rgba(255,255,255,0.02); }
.activity-main { min-width: 0; display: grid; gap: 4px; }
.activity-line { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.activity-title { font-weight: 600; }
.activity-meta { font-size: var(--fs-xs); color: var(--text-faint); }
.activity-time { font-size: var(--fs-xs); color: var(--text-faint); white-space: nowrap; }
.transition { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.transition .icon { color: var(--text-faint); width: 14px; height: 14px; }

.alert-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-3); align-items: center; padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--border); cursor: pointer; }
.alert-item:last-child { border-bottom: 0; }
.alert-item:hover { background: rgba(255,255,255,0.02); }
.alert-age { font-size: var(--fs-sm); font-weight: 600; color: #F0A560; white-space: nowrap; }
.alert-head-icon { color: var(--warn); }

.empty { display: grid; justify-items: center; gap: var(--s-2); padding: var(--s-7) var(--s-5); text-align: center; color: var(--text-faint); font-size: var(--fs-sm); }
.empty .icon { width: 26px; height: 26px; color: var(--text-faint); }

/* ---------- Toolbar & Tabelle ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s-3); padding: var(--s-4); align-items: center; }
.search { position: relative; flex: 1 1 280px; min-width: 220px; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }
.search .input { padding-left: 36px; }
.toolbar .select { width: auto; min-width: 160px; flex: 0 1 190px; }
.daterange { display: flex; align-items: center; gap: var(--s-2); color: var(--text-faint); font-size: var(--fs-sm); }
.daterange .input { width: 148px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
.table th {
  text-align: left; padding: var(--s-3) var(--s-4); white-space: nowrap;
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint);
  border-bottom: 1px solid var(--border); background: rgba(255,255,255,0.015);
}
.table th:first-child, .table td:first-child { padding-left: var(--s-5); }
.table th:last-child, .table td:last-child { padding-right: var(--s-5); }
.table td { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.is-click { cursor: pointer; }
.table tbody tr.is-click:hover td { background: rgba(255,255,255,0.02); }
.table tbody tr.is-selected td { background: var(--accent-soft); }
.table tbody tr.is-updated td { animation: rowflash 1.4s var(--ease); }
.cell-title { font-weight: 600; }
.cell-sub { font-size: var(--fs-xs); color: var(--text-faint); }
.cell-person { display: flex; align-items: center; gap: var(--s-2); white-space: nowrap; }
.cell-actions { display: flex; gap: var(--s-2); justify-content: flex-end; }
.ticket-id { font-family: var(--mono); font-size: var(--fs-sm); color: var(--text-muted); white-space: nowrap; }
.is-stale { color: #F0A560; }

.load { display: flex; align-items: center; gap: var(--s-3); min-width: 160px; }
.load-bar { flex: 1; height: 6px; border-radius: var(--r-pill); background: var(--bg-elev); overflow: hidden; }
.load-bar span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.load-bar span.is-high { background: var(--st-revision); }
.load-num { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 18px; text-align: right; }

/* ---------- Rollen ---------- */
.roles-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4); }
.role-card { padding: var(--s-5); display: grid; gap: var(--s-4); align-content: start; }
.role-card-head { display: flex; align-items: center; gap: var(--s-3); }
.role-card-head h3 { font-size: var(--fs-md); }
.role-card-head p { font-size: var(--fs-xs); color: var(--text-faint); }
.role-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-md); background: var(--panel-2); color: var(--accent); flex: none; }
.role-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.role-list li { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); background: var(--bg-elev); border: 1px solid var(--border); font-size: var(--fs-sm); }
.role-name { display: flex; align-items: center; gap: var(--s-2); font-weight: 600; }
.role-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--role-color, var(--text-faint)); }

/* ---------- Konfiguration ---------- */
.form-section { padding: var(--s-5); display: grid; gap: var(--s-4); border-bottom: 1px solid var(--border); }
.form-section:last-of-type { border-bottom: 0; }
.form-section h3 { font-size: var(--fs-md); }
.form-section > p { color: var(--text-muted); font-size: var(--fs-sm); margin-top: -8px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.form-bar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border);
  background: var(--panel); border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.form-bar .dirty { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); color: var(--text-muted); margin-right: auto; }
.form-bar .dirty::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.form-bar .dirty.is-dirty { color: #E9D27A; }
.form-bar .dirty.is-dirty::before { background: var(--st-in-progress); }

.check-list { list-style: none; margin: 0; padding: 0; display: grid; }
.check-list li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s-3); padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.check-list li:last-child { border-bottom: 0; }
.check-list .icon { margin-top: 1px; }
.check-list .ok .icon { color: var(--ok); }
.check-list .fail .icon { color: var(--danger); }
.check-list .fail .check-label { color: #F4B0A8; }
.check-detail { color: var(--text-faint); font-size: var(--fs-xs); }
.check-summary { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-3) var(--s-5); font-size: var(--fs-sm); font-weight: 600; border-bottom: 1px solid var(--border); }
.check-summary.ok { color: #6BDC9A; background: var(--ok-soft); }
.check-summary.fail { color: #F1897E; background: var(--danger-soft); }

.diff { display: grid; gap: var(--s-2); }
.diff-row { display: grid; gap: 4px; padding: var(--s-3); border-radius: var(--r-sm); background: var(--bg-elev); border: 1px solid var(--border); font-size: var(--fs-sm); }
.diff-row b { font-weight: 600; }
.diff-vals { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; color: var(--text-muted); }
.diff-vals .old { text-decoration: line-through; color: var(--text-faint); }
.diff-vals .new { color: var(--text); }

/* ---------- Drawer (Ticket-Detail) ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(8, 10, 14, 0.5); z-index: 50; opacity: 0; transition: opacity 0.2s; }
.drawer-backdrop.is-open { opacity: 1; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 51;
  width: min(var(--drawer-w), 100vw);
  display: flex; flex-direction: column;
  background: var(--panel); border-left: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform 0.28s var(--ease);
}
.drawer.is-open { transform: none; }
.drawer-head { padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--border); display: grid; gap: var(--s-3); }
.drawer-top { display: flex; align-items: center; gap: var(--s-3); }
.drawer-top .btn-icon { margin-left: auto; }
.drawer-title { font-size: var(--fs-xl); line-height: 1.2; }
.drawer-sub { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; color: var(--text-muted); font-size: var(--fs-sm); }
.drawer-body { flex: 1; overflow-y: auto; }
.drawer-section { padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--border); display: grid; gap: var(--s-3); }
.drawer-section:last-child { border-bottom: 0; }
.drawer-section h3 { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4) var(--s-5); margin: 0; }
.meta dt { font-size: var(--fs-xs); color: var(--text-faint); margin-bottom: 2px; }
.meta dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.actions-note { font-size: var(--fs-xs); color: var(--text-faint); display: flex; align-items: center; gap: 6px; }

.people { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.people li { display: flex; align-items: center; gap: var(--s-3); padding: 6px 6px 6px var(--s-2); border-radius: var(--r-sm); background: var(--bg-elev); border: 1px solid var(--border); }
.people li .grow { flex: 1; min-width: 0; }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 1px; background: var(--border-strong); }
.timeline li { position: relative; padding: 0 0 var(--s-5) 30px; }
.timeline li:last-child { padding-bottom: 0; }
.tl-dot { position: absolute; left: 2px; top: 5px; width: 11px; height: 11px; border-radius: 50%; background: var(--c, var(--text-faint)); box-shadow: 0 0 0 3px var(--panel); }
.tl-head { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.tl-title { font-weight: 600; }
.tl-meta { font-size: var(--fs-xs); color: var(--text-faint); margin-top: 2px; display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
.tl-reason { margin-top: var(--s-2); padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); background: var(--bg-elev); border: 1px solid var(--border); font-size: var(--fs-sm); color: var(--text-muted); white-space: pre-wrap; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: var(--s-5); background: rgba(8, 10, 14, 0.6); }
.modal {
  width: min(520px, 100%); max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  animation: pop 0.18s var(--ease);
}
.modal.is-lg { width: min(1040px, 100%); height: calc(100vh - 40px); }
.modal-head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: var(--fs-md); }
.modal-head .btn-icon { margin-left: auto; }
.modal-body { padding: var(--s-5); overflow-y: auto; display: grid; gap: var(--s-4); align-content: start; }
.modal.is-lg .modal-body { padding: 0; flex: 1; display: flex; flex-direction: column; }
.modal-body > p { color: var(--text-muted); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border); }
.modal-foot .left { margin-right: auto; display: flex; gap: var(--s-2); }
.modal-error { padding: var(--s-3); border-radius: var(--r-sm); background: var(--danger-soft); border: 1px solid rgba(231,76,60,0.3); color: #F4B0A8; font-size: var(--fs-sm); }
.viewer-frame { flex: 1; width: 100%; border: 0; background: #fff; border-radius: 0 0 var(--r-lg) var(--r-lg); }
.viewer-text { flex: 1; margin: 0; padding: var(--s-5); overflow: auto; font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.6; color: var(--text); background: var(--bg-elev); white-space: pre-wrap; border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: var(--s-5); bottom: var(--s-5); z-index: 70; display: grid; gap: var(--s-2); width: min(380px, calc(100vw - 40px)); }
.toast {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s-3); align-items: start;
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  background: var(--panel-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm); animation: slidein 0.22s var(--ease);
}
.toast b { display: block; font-weight: 600; }
.toast span { color: var(--text-muted); }
.toast.ok .icon { color: var(--ok); }
.toast.error .icon { color: var(--danger); }
.toast.info .icon { color: var(--st-questions); }
.toast.is-out { opacity: 0; transform: translateY(6px); transition: 0.2s; }

/* ---------- Auth-Seiten ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: var(--s-6); background: radial-gradient(1200px 600px at 50% -10%, #1B222C 0%, var(--bg) 60%); }
.auth-card { width: min(420px, 100%); padding: var(--s-7); display: grid; gap: var(--s-5); }
.auth-brand { display: flex; align-items: center; gap: var(--s-3); }
.auth-card h1 { font-size: var(--fs-xl); }
.auth-card p { color: var(--text-muted); }
.auth-card .btn { height: 44px; font-size: var(--fs-base); width: 100%; }
.auth-note { display: flex; gap: var(--s-2); font-size: var(--fs-xs); color: var(--text-faint); padding-top: var(--s-4); border-top: 1px solid var(--border); }
.auth-note .icon { width: 15px; height: 15px; margin-top: 1px; }
.auth-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: var(--r-md); background: var(--danger-soft); color: var(--danger); }
.auth-alert { padding: var(--s-3); border-radius: var(--r-sm); background: var(--danger-soft); border: 1px solid rgba(231,76,60,0.3); color: #F4B0A8; font-size: var(--fs-sm); }

/* ---------- Ladezustände ---------- */
.skeleton { display: block; height: 14px; border-radius: var(--r-xs); background: linear-gradient(90deg, var(--panel-2) 0%, var(--panel-hover) 50%, var(--panel-2) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.boot { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--bg); color: var(--text-faint); font-size: var(--fs-sm); }
.boot .icon { animation: spin 0.8s linear infinite; width: 22px; height: 22px; color: var(--accent); }
.boot-inner { display: grid; justify-items: center; gap: var(--s-3); }

/* ---------- Animationen ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(46,204,113,0.45); } 70% { box-shadow: 0 0 0 6px rgba(46,204,113,0); } 100% { box-shadow: 0 0 0 0 rgba(46,204,113,0); } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.985); } }
@keyframes slidein { from { opacity: 0; transform: translateY(8px); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes flash { 0% { color: var(--accent); } 100% { color: var(--text); } }
@keyframes rowflash { 0% { background: rgba(74,155,142,0.22); } 100% { background: transparent; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .grid-config { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-dash { grid-template-columns: minmax(0, 1fr); }
  .roles-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform 0.25s var(--ease); box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: none; }
  .menu-toggle { display: inline-flex; }
  .topbar, .content { padding-left: var(--s-5); padding-right: var(--s-5); }
  .demo-banner { margin-left: var(--s-5); margin-right: var(--s-5); }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .form-grid, .meta { grid-template-columns: minmax(0, 1fr); }
  .toolbar .select, .daterange, .daterange .input { flex: 1 1 100%; width: 100%; }
  .live-label, #last-sync { display: none; }
  .demo-banner .seg { margin-left: 0; }
}
