/* Tickets Analysis tool — HIL feedback KPI dashboard. ta- prefix. */

body:has(.ta-page) {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: #f5f5f5;
}

/* ── Page layout ───────────────────────────────────────────────────────── */

.ta-page { max-width: 1200px; margin: 0 auto; padding: 2rem 1rem; }

.ta-header { margin-bottom: 1.5rem; }
.ta-header h1 { margin: 0; font-size: 1.5rem; color: #111827; }
.ta-header__sub { color: #6b7280; font-size: 0.875rem; margin-top: 0.25rem; }

.ta-card {
  background: #fff;
  border-radius: 0.5rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
  margin-bottom: 1.5rem;
  overflow-x: auto; /* wide tables scroll inside the card on narrow viewports */
}

.ta-card h2 { margin: 0 0 1rem; font-size: 1.125rem; color: #111827; }
.ta-card__hint { color: #6b7280; font-size: 0.75rem; margin: -0.75rem 0 1rem; }

.ta-muted { color: #9ca3af; font-size: 0.875rem; }

/* ── Tabs ──────────────────────────────────────────────────────────────── */

.ta-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }

.ta-tabs__tab {
  padding: 0.375rem 1rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #6b7280;
  text-decoration: none;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

.ta-tabs__tab--active { background: #111827; color: #fff; }

/* ── Filter bar ────────────────────────────────────────────────────────── */

.ta-filter { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; margin-bottom: 1.25rem; }

.ta-filter__field label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.ta-filter__field select,
.ta-filter__field input {
  font-size: 0.875rem;
  padding: 0.375rem 0.5rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.375rem;
  background: #fff;
  color: #374151;
}

.ta-filter__reset { font-size: 0.8125rem; color: #6b7280; }

/* ── Pagination ────────────────────────────────────────────────────────── */

.ta-pagination { display: flex; gap: 1rem; align-items: center; justify-content: center; margin-top: 1.25rem; }
.ta-pagination__link { font-size: 0.875rem; font-weight: 600; color: #374151; text-decoration: none; }
.ta-pagination__link:hover { text-decoration: underline; }

/* ── KPI cards ─────────────────────────────────────────────────────────── */

.ta-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.ta-kpi {
  background: #fff;
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

.ta-kpi__value { font-size: 1.75rem; font-weight: 700; color: #111827; line-height: 1.2; }
.ta-kpi__label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

/* ── Tables ────────────────────────────────────────────────────────────── */

.ta-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

.ta-table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #e5e7eb;
}

.ta-table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
  vertical-align: top;
}

.ta-table__bar-col { min-width: 220px; }
.ta-engine { font-weight: 600; color: #111827; }

.ta-feed__title { max-width: 240px; }
.ta-feed__line { display: flex; align-items: center; gap: 6px; max-width: 240px; }
.ta-feed__line a:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ta-feed__compare { flex: none; text-decoration: none; color: #9ca3af; font-size: 13px; }
.ta-feed__compare:hover { color: #2563eb; }
.ta-feed__customer { font-size: 12px; margin-top: 2px; }
.ta-feed__reason { max-width: 360px; }

/* ── Rating colors (good/ok/bad) ───────────────────────────────────────── */

.ta-stack {
  display: flex;
  height: 0.875rem;
  border-radius: 0.25rem;
  overflow: hidden;
  background: #f3f4f6;
}

.ta-stack__seg { display: block; }
.ta-stack__seg--good { background: #16a34a; }
.ta-stack__seg--ok   { background: #f59e0b; }
.ta-stack__seg--bad  { background: #dc2626; }

.ta-stack-legend { margin-top: 0.375rem; display: flex; gap: 0.75rem; font-size: 0.75rem; color: #6b7280; }
.ta-stack-legend__item { display: inline-flex; align-items: center; gap: 0.25rem; }

.ta-dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; display: inline-block; }
.ta-dot--good { background: #16a34a; }
.ta-dot--ok   { background: #f59e0b; }
.ta-dot--bad  { background: #dc2626; }

.ta-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.ta-badge--good { background: #dcfce7; color: #15803d; }
.ta-badge--ok   { background: #fef3c7; color: #b45309; }
.ta-badge--bad  { background: #fee2e2; color: #b91c1c; }

/* ── Judge matrix + routing badges ─────────────────────────────────────── */

.ta-matrix-wrap { max-width: 480px; }

.ta-matrix__cell {
  position: relative;
  font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, #93c5fd var(--heat, 0%), #fff);
}

.ta-matrix__cell--agree {
  background: color-mix(in srgb, #86efac var(--heat, 0%), #fff);
  font-weight: 600;
}

.ta-routing {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.ta-routing--autonomous   { background: #dcfce7; color: #15803d; }
.ta-routing--draft_assist { background: #dbeafe; color: #1d4ed8; }
.ta-routing--draft_only   { background: #fef3c7; color: #b45309; }
.ta-routing--no_answer    { background: #fee2e2; color: #b91c1c; }

/* ── Weekly trend chart (CSS-only stacked bars) ────────────────────────── */

.ta-trend {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 180px;
  padding-top: 0.5rem;
}

/* One continuous baseline across the whole chart, sitting exactly at the bottom
   of the bar area (= top of the fixed-height label row). Independent of the
   per-week gaps so it never breaks or wobbles. */
.ta-trend::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(1rem + 0.375rem);
  border-top: 1px solid #d1d5db;
  pointer-events: none;
}

.ta-trend__week {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
}

.ta-trend__bars {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
}

.ta-trend__bar {
  flex: 1;
  min-width: 0;
  max-width: 22px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  border-radius: 2px 2px 0 0;
  overflow: hidden;
}

/* Older engine (Lucas / classic) muted; new engine (LEA) in full colour. */
.ta-trend__bar--lucas .ta-trend__seg { opacity: 0.55; }

.ta-trend__seg { display: block; width: 100%; }

.ta-trend__label {
  text-align: center;
  font-size: 0.6875rem;
  color: #9ca3af;
  margin-top: 0.375rem;
  white-space: nowrap;
  /* Fixed height so empty (thinned) labels reserve the same space as visible
     ones — otherwise the bar area height varies per week and the baseline wobbles. */
  height: 1rem;
  line-height: 1rem;
}

/* ── help "?" affordance (section header + per box) ── */
.ta-help-dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; margin-left: 8px; vertical-align: middle;
  border-radius: 50%; background: #e5e7eb; color: #6b7280;
  font-size: 11px; font-weight: 700; line-height: 1; text-decoration: none;
  transition: background .15s, color .15s;
}
.ta-help-dot:hover { background: #0891b2; color: #fff; }
.ta-cards__head { display: flex; align-items: center; gap: 2px; margin-bottom: 10px; font-size: 13px; font-weight: 700; color: #374151; text-transform: uppercase; letter-spacing: .04em; }
.ta-header { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 10px; }

/* ── "Zu bewerten" queue ── */
.ta-note { background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 8px; padding: 14px 18px; margin-bottom: 22px; font-size: 13px; color: #0c4a6e; }
.ta-note__steps { margin: 8px 0 8px 18px; line-height: 1.7; }
.ta-note .ta-muted { margin-top: 6px; font-size: 12px; }
.ta-to-rate__actions { white-space: nowrap; }
.ta-to-rate__actions a { margin-right: 10px; }
.ta-cbl__cat { font-weight: 600; color: #111827; }
.ta-cbl__meta { font-size: 12px; line-height: 1.5; }
