/* WICHTIG: verhindert Überlappungen bei width:100% + padding/border */
*, *::before, *::after { box-sizing: border-box; }

:root { color-scheme: light; }
body { margin:0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; background:#f6f7fb; color:#111; }
.wrap { max-width: 980px; margin: 0 auto; padding: 16px; }
header { background:#111827; color:#fff; padding: 14px 16px; }
.brand { font-weight:700; letter-spacing:.2px; }
main { padding: 16px 0; }
.panel { background:#fff; border-radius: 16px; padding: 16px; box-shadow: 0 6px 18px rgba(0,0,0,.06); }
code { background: #f1f5f9; padding: 2px 6px; border-radius: 8px; }
.card { margin-top: 12px; padding: 12px; border-radius: 14px; background:#f8fafc; border:1px solid #e5e7eb; }
.grid { display:grid; gap:12px; }
.grid-2 { grid-template-columns: 1fr; }
@media (min-width: 820px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

label { display:block; font-weight:600; margin: 10px 0 6px; }
input, button { font: inherit; }
input { width:100%; padding: 12px 12px; border-radius: 12px; border:1px solid #d1d5db; outline:none; }
input:focus { border-color:#111827; box-shadow: 0 0 0 3px rgba(17,24,39,.12); }

.btn { display:inline-block; padding: 10px 12px; border-radius: 10px; border: 0; background:#111827; color:#fff; font-weight:700; font-size:.95rem; cursor:pointer; }
.btn:active { transform: translateY(1px); }

.muted { color:#475569; font-size:.95rem; }
.err { background:#fef2f2; border:1px solid #fecaca; padding:12px; border-radius:12px; }
.ok  { background:#ecfdf5; border:1px solid #a7f3d0; padding:12px; border-radius:12px; }
.small { font-size:.92rem; }

@media (min-width: 768px) { .wrap { padding: 20px; } .panel { padding: 20px; } }

/* Header Layout */
.headrow { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.headright { display:flex; align-items:center; gap:12px; flex-wrap:wrap; justify-content:flex-end; }
.pagetitle { opacity:.85; font-size:.95rem; }

/* Navigation (legacy - bleibt, wird unten überschrieben/ergänzt) */
.nav { display:flex; gap:10px; flex-wrap:wrap; align-items:center; justify-content:flex-end; }
.navlink {
  display:inline-block;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,.08);
  color:#fff;
  text-decoration:none;
  font-weight:700;
  font-size: .95rem;
}
.navlink:hover { background: rgba(255,255,255,.14); }

.navform { margin:0; }
.navbtn {
  padding: 10px 12px;
  border-radius: 12px;
  border: 0;
  background: rgba(255,255,255,.16);
  color:#fff;
  font-weight:800;
  cursor:pointer;
}
.navbtn:hover { background: rgba(255,255,255,.22); }

/* Mobile */
@media (max-width: 640px) {
  .headrow { align-items:flex-start; }
  .headright { width:100%; justify-content:flex-start; }
  .pagetitle { width:100%; }
  .nav { width:100%; justify-content:flex-start; }
}

/* ---------- UI Utilities ---------- */
.btn { display:inline-flex; align-items:center; justify-content:center; gap:7px; padding: 10px 12px; border-radius: 10px; border: 0; background:#111827; color:#fff; font-weight:800; font-size:.95rem; line-height:1.2; cursor:pointer; }
.btn:active { transform: translateY(1px); }
/* Ghost-Button für helle Flächen (Cards/Panel) */
.btn--ghost{
  background:#f1f5f9;
  color:#111827;
  border:1px solid #e5e7eb;
}
.btn--ghost:hover{
  background:#e2e8f0;
}
.btn--ghost:active{
  transform: translateY(1px);
}
.btn--danger { background:#b91c1c; }

.badge { display:inline-flex; align-items:center; padding: 4px 10px; border-radius: 999px; font-weight:800; font-size:.85rem; border:1px solid #e5e7eb; background:#f8fafc; }
.badge--ok { background:#ecfdf5; border-color:#a7f3d0; }
.badge--warn { background:#fff7ed; border-color:#fed7aa; }
.badge--off { background:#fef2f2; border-color:#fecaca; }

/* ---------- NEW: Badge-Farben für Status / Prio / Source ---------- */
/* Status */
.badge--st-open      { background:#ecfdf5; border-color:#4effac; } /* grünlich */
.badge--st-progress  { background:#fff7ed; border-color:#ffa845; } /* amber */
.badge--st-wait      { background:#eff6ff; border-color:#5ea7ff; } /* blau */
.badge--st-closed    { background:#f1f5f9; border-color:#a3a3a3; } /* grau */
.badge--st-default   { background:#f8fafc; border-color:#e5e7eb; }

/* Priorität */
.badge--prio-low     { background:#f1f5f9; border-color:#cbd5e1; }
.badge--prio-normal  { background:#eff6ff; border-color:#bfdbfe; }
.badge--prio-high    { background:#ffdeb6; border-color:#ffb867; }
.badge--prio-urgent  { background:#ffc5c5; border-color:#ff5e5e; }

/* Source (web/telegram) */
.badge--src-web      { background:#eff4fa; border-color:#cbd5e1; }
.badge--src-telegram { background:#c7fcff; border-color:#78eefc; }

.hr { height:1px; background:#e5e7eb; border:0; margin:12px 0; }

/* ---------- Desktop Nav (kompakt) ---------- */
.nav--desktop { display:none; gap:10px; flex-wrap:wrap; align-items:center; justify-content:flex-end; }
@media (min-width: 860px) { .nav--desktop { display:flex; } }

.navlink, .navbtn {
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,.08);
  color:#fff;
  text-decoration:none;
  font-weight:800;
  font-size: .92rem;
  border:0;
  cursor:pointer;
}
.navlink:hover, .navbtn:hover { background: rgba(255,255,255,.14); }
.navlink--ghost { background: rgba(255,255,255,.08); }
.navform { margin:0; }

/* ---------- Dropdown "Administration" (Desktop) ---------- */
.dropdown { position:relative; }

/* Hover-Bridge: verhindert "Hover-Abbruch" zwischen Button und Menü */
.dropdown::after{
  content:"";
  position:absolute;
  left:0;
  right:0;
  top:100%;
  height:12px;             /* Brücke = Spalt überbrücken */
  background:transparent;
  opacity:0;               /* unsichtbar */
  pointer-events:auto;     /* WICHTIG: muss hoverbar sein! */
  display:block;           /* immer vorhanden */
}


/* WICHTIG: display:none muss vorhanden sein, sonst "komisches" Overlay */
.dropdown__menu {
  position:absolute;
  right:0;
  top: calc(100% + 8px);
  min-width: 300px;
  padding: 12px;
  background:#0b1220;                /* bewusst ohne Gradient -> sauberer */
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 20px 50px rgba(0,0,0,.34);
  display:none;
  z-index: 70;
}

/* Pfeil passend zum Menü-Hintergrund */
.dropdown__menu::before {
  content:"";
  position:absolute;
  top:-7px;
  right: 20px;
  width: 14px;
  height: 14px;
  background:#0b1220;
  transform: rotate(45deg);
  border-left: 1px solid rgba(255,255,255,.14);
  border-top: 1px solid rgba(255,255,255,.14);
}

/* Items wieder vollständig definieren -> nicht gequetscht */
.dropdown__item {
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:10px;

  padding: 12px 14px;
  border-radius: 14px;

  color:#fff;
  text-decoration:none;
  font-weight:900;
  font-size:.95rem;

  background: rgba(255,255,255,.06);
  margin-bottom: 8px;
}

.dropdown__item:last-child { margin-bottom: 0; }

.dropdown__item:hover { background: rgba(255,255,255,.12); }

/* Hover-only => kein Sticky-Klick */
.dropdown:hover .dropdown__menu { display:block; }

/* ---------- Mobile Offcanvas ---------- */
.navburger{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:42px;
  height:42px;
  border-radius: 12px;
  border: 0;
  cursor:pointer;
  background: rgba(255,255,255,.10);
  color:#fff;
  font-weight:900;
}
@media (min-width: 860px) { .navburger { display:none; } }

.navsheet { display:none; }
.navsheet.is-open { display:block; }
.navsheet__overlay {
  position:fixed; inset:0;
  background: rgba(0,0,0,.45);
  z-index: 60;
}
.navsheet__panel{
  position:fixed;
  top:0; right:0;
  height:100vh;
  width:min(92vw, 360px);
  background:#ffffff;
  z-index: 61;
  box-shadow: -18px 0 40px rgba(0,0,0,.20);
  display:flex;
  flex-direction:column;
}
.navsheet__head{
  padding:14px 16px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  border-bottom:1px solid #e5e7eb;
}
.navsheet__title{ font-weight:900; }
.navsheet__close{
  border:0; background:#f1f5f9;
  width:40px; height:40px;
  border-radius:12px;
  font-weight:900;
  cursor:pointer;
}
.navsheet__body{
  padding:14px 16px;
  overflow:auto;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.navitem{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 12px 12px;
  border-radius: 14px;
  text-decoration:none;
  color:#111;
  font-weight:900;
  border:1px solid #e5e7eb;
  background:#f8fafc;
}
.navitem--sub{
  margin-left: 10px;
  font-weight:800;
}
.navitem--toggle{
  width:100%;
  border:1px solid #e5e7eb;
  background:#f8fafc;
  cursor:pointer;
}
.navsub{ flex-direction:column; gap:10px; display:flex; }
.navsub[hidden]{ display:none !important; }
.chev{ opacity:.7; }

.navsheet__logout{ margin-top: 6px; }

.no-scroll { overflow:hidden; }

/* ---------- Admin pages layout helpers ---------- */
.kv { display:flex; flex-wrap:wrap; gap:10px; align-items:center; }
.kv .badge { margin-left:0; }
.grid3 { display:grid; gap:12px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid3 { grid-template-columns: 1.2fr .9fr .9fr; } }

.fieldrow { display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.fieldrow > * { flex: 1; min-width: 220px; }
.select { width:100%; padding:12px; border-radius:12px; border:1px solid #d1d5db; background:#fff; }

/* Burger rechts im Header */
.navburger { margin-left: auto; }

/* Mobile Header: Titel + Burger sauber auf einer Zeile */
@media (max-width: 859px) {
  .headright { width:100%; }
  .pagetitle { flex: 1; }
}

/* ---------- Active state (Desktop + Mobile) ---------- */
.navlink.is-active {
  background: rgba(255,255,255,.18);
  outline: 2px solid rgba(255,255,255,.28);
}

.dropdown__item.is-active {
  background: rgba(59,130,246,.22);
  border: 1px solid rgba(59,130,246,.35);
}

.navitem.is-active {
  background:#eef2ff;
  border-color:#c7d2fe;
  outline: 2px solid rgba(17,24,39,.14);
}

/* Desktop: Dropdown immer über Header-Inhalt rendern */
@media (min-width: 860px) {
  header { position: relative; z-index: 10; }
  .dropdown { z-index: 50; }
  .dropdown__menu { z-index: 999; }
}

/* Falls irgendwo noch "alte" .nav angezeigt wird: auf Desktop verstecken */
@media (min-width: 860px) {
  .nav:not(.nav--desktop) { display: none !important; }
}

/* Interne Notizen als eigener, klar sichtbarer Block */
.ticket-internal-note{
  margin-top:12px;
  padding:14px 16px;
  border-radius:16px;
  border:1px dashed #f59e0b;
  background:#fffbeb;
  box-shadow:0 8px 24px rgba(245,158,11,.10);
}
.ticket-internal-note__head{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
}
.ticket-internal-note__title{
  font-weight:900;
  color:#92400e;
}
.ticket-internal-note__meta{
  color:#92400e;
  font-size:.84rem;
  font-weight:700;
}
.ticket-internal-note__body{margin-top:10px}

.dashboard {
    display: grid;
    gap: 20px;
}

.dash-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.dashboard .card {
    padding: 20px;
    border-radius: 16px;
    font-size: 28px;
    font-weight: bold;
    color: #fff;
}

.dashboard .card span {
    display: block;
    font-size: 14px;
    margin-top: 5px;
}

.dashboard .blue { background: #3b82f6; }
.dashboard .green { background: #10b981; }
.dashboard .yellow { background: #f59e0b; }
.dashboard .red { background: #ef4444; }

.dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.dashboard .panel ul {
    list-style: none;
    padding: 0;
}

.dashboard .panel li {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
}

/* ---------- Dashboard layout overrides ---------- */
.page-main{width:100%;}
.wrap--dashboard{max-width:1480px;}
.panel--dashboard{
  padding:0;
  border:0;
  background:transparent;
  box-shadow:none;
}

/* Header auf kleinen Geräten kompakter und stabiler */
@media (max-width: 640px) {
  .headrow{
    display:grid;
    grid-template-columns:minmax(0,1fr) auto;
    align-items:center;
  }
  .headright{
    width:auto;
    justify-content:flex-end;
    gap:10px;
    flex-wrap:nowrap;
  }
  .pagetitle{
    width:auto;
    font-size:.9rem;
    white-space:nowrap;
  }
  .nav{
    width:auto;
    justify-content:flex-end;
  }
  .brand{
    min-width:0;
    line-height:1.15;
  }
}

@media (max-width: 859px) {
  .headright{ width:auto; }
  .pagetitle{ flex:0 1 auto; }
}
