:root {
  --bg: #f3f1ec;
  --surface: #ffffff;
  --ink: #23211c;
  --ink-soft: #6b675d;
  --line: #e2ded4;
  --accent: #c2410c;
  --accent-soft: #fff1e7;
  --ok: #15803d;
  --warn: #b45309;
  --crit: #b91c1c;
  --info: #1d4ed8;
  --radius: 10px;
  --shadow: 0 6px 24px rgba(35, 33, 28, 0.10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 2px solid var(--ink);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-size: 22px;
  font-weight: 300;
  letter-spacing: 0.5px;
}
.brand span { font-weight: 800; color: var(--accent); }

.topbar-actions { display: flex; align-items: center; gap: 12px; }
.status-info { color: var(--ink-soft); font-size: 13px; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { border-color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: #9a3412; border-color: #9a3412; }
.btn-primary:disabled { opacity: 0.6; cursor: wait; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--accent-soft); border-color: transparent; }
.btn-danger { color: var(--crit); border-color: var(--crit); background: transparent; }
.btn-danger:hover { background: #fef2f2; }
.btn-small { padding: 4px 8px; font-size: 13px; }

/* ---------- Board ---------- */
.board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  padding: 20px 24px 120px;
  align-items: start;
}
@media (max-width: 1300px) { .board { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1100px) { .board { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .board { grid-template-columns: 1fr; } }

.column h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--ink-soft);
  margin: 4px 4px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.count {
  background: var(--ink);
  color: #fff;
  border-radius: 99px;
  font-size: 11px;
  padding: 1px 8px;
}

.cards { display: flex; flex-direction: column; gap: 10px; min-height: 60px; border-radius: var(--radius); }
.cards.drag-over { outline: 2px dashed var(--accent); outline-offset: 4px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--sev, var(--ink-soft));
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
}
.card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.card.dragging { opacity: 0.5; }

.card .card-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 6px;
  font-family: Consolas, monospace;
}
.card .card-title { font-weight: 600; font-size: 14px; line-height: 1.35; }
.card .card-meta { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  background: var(--bg);
}
.badge-tool { background: var(--accent-soft); border-color: #f5c8ab; color: var(--accent); font-weight: 600; }
.badge-critical { background: #fef2f2; border-color: #fca5a5; color: var(--crit); font-weight: 700; }
.badge-high { background: #fff7ed; border-color: #fdba74; color: var(--warn); font-weight: 600; }
.badge-medium { background: #eff6ff; border-color: #bfdbfe; color: var(--info); }
.badge-low { background: #f0fdf4; border-color: #bbf7d0; color: var(--ok); }
.badge-whatsapp { background: #f0fdf4; border-color: #bbf7d0; color: var(--ok); }

.empty-hint { color: var(--ink-soft); font-size: 13px; text-align: center; padding: 14px 6px; border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- Detail ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(35, 33, 28, 0.45);
  z-index: 50;
  display: flex;
  justify-content: flex-end;
}
.hidden { display: none !important; }

.detail-panel {
  width: min(680px, 100%);
  background: var(--surface);
  height: 100%;
  overflow-y: auto;
  padding: 20px 26px 30px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: -10px 0 40px rgba(0,0,0,0.2);
}
.detail-header { display: flex; justify-content: space-between; align-items: center; }
.ticket-id { font-family: Consolas, monospace; color: var(--ink-soft); font-size: 14px; }
.detail-panel h2 { margin: 0; font-size: 20px; line-height: 1.3; }
.badges { display: flex; gap: 8px; flex-wrap: wrap; }

.detail-body { display: flex; flex-direction: column; gap: 12px; }
.field label { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-soft); display: block; margin-bottom: 3px; }
.field p { margin: 0; white-space: pre-wrap; font-size: 14px; line-height: 1.5; }

.fix-prompt-section { border-top: 2px solid var(--ink); padding-top: 14px; }
.fix-prompt-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.fix-prompt-head h3 { margin: 0; font-size: 15px; }
.fix-prompt-text {
  background: #23211c;
  color: #f3f1ec;
  border-radius: var(--radius);
  padding: 14px;
  font-family: Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 340px;
  overflow-y: auto;
  margin: 12px 0 0;
}
.fix-prompt-text.empty { background: var(--bg); color: var(--ink-soft); font-style: italic; }

.section-hint { font-size: 12.5px; color: var(--ink-soft); margin: 8px 0 0; }
.section-hint code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }

.jobs-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.job-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  background: var(--bg);
}
.job-item .job-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.job-item .job-meta { color: var(--ink-soft); font-family: Consolas, monospace; font-size: 12px; }
.job-item details { margin-top: 8px; }
.job-item summary { cursor: pointer; color: var(--ink-soft); font-size: 12px; }
.job-item pre {
  background: #23211c; color: #f3f1ec; border-radius: 8px; padding: 10px;
  font-size: 12px; white-space: pre-wrap; word-break: break-word;
  max-height: 260px; overflow-y: auto; margin: 8px 0 0;
}
.job-summary { margin-top: 8px; white-space: pre-wrap; word-break: break-word; }
.badge-job-queued { background: var(--bg); color: var(--ink-soft); }
.badge-job-running { background: #eff6ff; border-color: #bfdbfe; color: var(--info); font-weight: 700; }
.badge-job-done { background: #f0fdf4; border-color: #bbf7d0; color: var(--ok); font-weight: 700; }
.badge-job-failed { background: #fef2f2; border-color: #fca5a5; color: var(--crit); font-weight: 700; }

.attachments { display: flex; gap: 10px; flex-wrap: wrap; }
.attachments a { display: block; }
.attachment-thumb {
  width: 110px; height: 110px; object-fit: cover;
  border: 1px solid var(--line); border-radius: var(--radius);
  transition: transform 0.15s;
}
.attachment-thumb:hover { transform: scale(1.04); }

.detail-footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  gap: 10px;
}
.detail-footer select { padding: 7px 10px; border-radius: var(--radius); border: 1px solid var(--line); font-size: 14px; }

/* ---------- Chat ---------- */
.chat-toggle {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  box-shadow: var(--shadow);
  z-index: 60;
  transition: transform 0.15s;
}
.chat-toggle:hover { transform: scale(1.07); }

.chat-panel {
  position: fixed;
  right: 24px;
  bottom: 96px;
  width: min(400px, calc(100vw - 48px));
  height: min(560px, calc(100vh - 130px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  z-index: 60;
  overflow: hidden;
}
.chat-header {
  padding: 12px 16px;
  background: var(--ink);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chat-header .btn-ghost { color: #fff; }
.chat-header .btn-ghost:hover { background: rgba(255,255,255,0.15); }
.chat-sub { font-size: 12px; opacity: 0.75; margin-top: 2px; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
}
.msg {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg-bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg-info { align-self: center; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; border-radius: 99px; padding: 4px 12px; }
.msg-error { align-self: center; background: #fef2f2; color: var(--crit); font-size: 12px; border-radius: 99px; padding: 4px 12px; }
.msg-typing { align-self: flex-start; color: var(--ink-soft); font-style: italic; background: transparent; }

.chat-input {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.chat-input textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-family: inherit;
  font-size: 14px;
  max-height: 110px;
}
.chat-input textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* ---------- Tabs (Tickets / Feature-Wünsche) ---------- */
.tabs { display: flex; gap: 6px; }
.tab {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  padding: 7px 14px;
  border-radius: 99px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tab:hover { border-color: var(--ink); }
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.tab.active .count { background: var(--accent); }

/* ---------- Zusatz-Badges ---------- */
.badge-channel { background: #eef2ff; border-color: #c7d2fe; color: #4338ca; }
.badge-risk { background: #fef2f2; border-color: #fca5a5; color: var(--crit); font-weight: 700; }
.badge-job-review { background: #fff7ed; border-color: #fdba74; color: var(--warn); font-weight: 700; }
.badge-wishcount { background: var(--accent-soft); border-color: #f5c8ab; color: var(--accent); font-weight: 700; }

/* ---------- Risiko-Box im Ticket-Detail ---------- */
.risk-box {
  border: 1px solid #fca5a5;
  background: #fef2f2;
  border-left: 4px solid var(--crit);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.risk-title { font-weight: 700; color: var(--crit); font-size: 14px; margin-bottom: 6px; }
.risk-scenario { margin: 0 0 10px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; }
.risk-note { margin: 0; font-size: 12.5px; color: var(--ink-soft); }
.risk-actions { display: flex; gap: 8px; }

/* ---------- Job-Diff / Freigabe ---------- */
.job-diff pre { max-height: 320px; }
.job-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- Feature-Wünsche-Ansicht ---------- */
.wishes-view { padding: 20px 24px 120px; max-width: 900px; margin: 0 auto; }
.wishes-head h2 { margin: 4px 0 4px; }
.wishes-head .section-hint { margin: 0 0 14px; }
.wishes-list { display: flex; flex-direction: column; gap: 10px; }
.wish-card {
  display: flex;
  gap: 14px;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
}
.wish-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.wish-count {
  flex: 0 0 auto;
  min-width: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  padding: 6px;
}
.wish-count span { font-size: 11px; font-weight: 600; opacity: 0.85; margin-top: 2px; }
.wish-main { flex: 1; min-width: 0; }
.wish-title { font-weight: 700; font-size: 15px; }
.wish-desc { margin-top: 6px; font-size: 13px; color: var(--ink-soft); line-height: 1.45; }

.wish-actions { display: flex; flex-direction: column; gap: 4px; }
.wish-actions .section-hint { margin: 0; }

/* ---------- Feature-Wunsch-Detail: Einzelanfragen ---------- */
.examples-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.example-item { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: var(--bg); }
.example-meta { font-size: 12px; color: var(--ink-soft); font-family: Consolas, monospace; margin-bottom: 4px; }
.example-text { font-size: 13.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }

/* ---------- Aufwand & Preis ---------- */
.est-settings {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  margin-bottom: 14px; padding: 12px; background: var(--accent-soft);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.est-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.est-settings label, .est-row label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 0.78rem; font-weight: 600; color: var(--ink-soft);
}
.est-settings input, .est-row input, .est-row select {
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 0.92rem; background: var(--surface); color: var(--ink);
}
.est-settings input { width: 6rem; }
.est-row input { width: 7rem; }
.est-row select { min-width: 12rem; }
.est-row input:disabled { background: var(--bg); color: var(--ink-soft); }
.est-result { margin-top: 14px; font-size: 1rem; color: var(--ink); }
.est-result .price { color: var(--ok); font-size: 1.4rem; font-weight: 700; }
.est-result .muted { color: var(--ink-soft); font-weight: 400; font-size: 0.85rem; }

/* ---------- Kartenpreis + Angebot/Ist-Vergleich ---------- */
.card-price {
  margin-left: auto; font-weight: 700; font-size: 0.82rem;
  color: var(--ok); background: #e9f5ee; border: 1px solid #cde9d6;
  padding: 1px 8px; border-radius: 999px; white-space: nowrap;
}
.est-compare {
  margin-top: 14px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface);
}
.cmp-title {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--ink-soft); margin-bottom: 8px;
}
.cmp-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 0.92rem; }
.cmp-row.muted { color: var(--ink-soft); font-size: 0.85rem; }
.cmp-delta { margin-top: 4px; padding-top: 8px; border-top: 1px dashed var(--line); }
.cmp-delta.pos b { color: var(--ok); }
.cmp-delta.neg b { color: var(--crit); }
