:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-muted: #eef1f4;
  --table-row-hover: #e2eef0;
  --text: #17202a;
  --muted: #65717f;
  --line: #d9dee5;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --warning: #8a5a00;
  --warning-bg: #fff7df;
  --ok-bg: #e9f8f3;
  --shadow: 0 12px 36px rgba(20, 28, 38, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  min-height: 100vh;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  background: #101820;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #20a39e;
  color: #061214;
  font-weight: 800;
}

.brand-title {
  font-weight: 800;
  line-height: 1.2;
}

.brand-subtitle {
  margin-top: 2px;
  color: #a8b3bd;
  font-size: 13px;
}

.nav {
  margin-top: 36px;
  display: grid;
  gap: 8px;
}

.nav-link {
  display: block;
  padding: 11px 12px;
  border-radius: 8px;
  color: #d7dee5;
  text-decoration: none;
  font-weight: 650;
}

.nav-link:hover,
.nav-link.is-active {
  background: #22303c;
  color: #fff;
}

.nav-link.is-disabled {
  color: #74808a;
  cursor: default;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 28px;
}

.page-kicker {
  color: var(--accent);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 4px;
  font-size: 32px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

.user-menu {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid #2c3945;
  border-radius: 8px;
}

.user-chip {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.user-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 750;
  line-height: 1;
  color: #fff;
}

.user-role {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 8px;
  background: #22303c;
  color: #d7dee5;
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
}

.logout-form {
  display: flex;
}

.logout-form .button {
  width: 100%;
}

.user-menu .button-secondary {
  background: #22303c;
  color: #fff;
}

.user-menu .button-secondary:hover {
  background: #2c3945;
}

.content {
  max-width: 1040px;
}

.page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 20px;
}

.ticket-detail-stack {
  display: grid;
  gap: 18px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.section-heading p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.5;
}

.collapsible-heading {
  align-items: center;
  margin: -6px -6px 20px;
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
  transition:
    background-color 140ms ease,
    box-shadow 140ms ease,
    transform 80ms ease;
}

.collapsible-heading:hover {
  background: var(--surface-muted);
}

.collapsible-heading:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.collapsible-heading:active {
  transform: translateY(1px);
}

.collapsible-heading[aria-expanded="false"] {
  margin-bottom: -6px;
}

.collapsible-title {
  display: flex;
  align-items: flex-start;
  min-width: 0;
}

.collapsible-section-body.is-collapsed {
  display: none;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.section-actions form {
  display: contents;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 8px;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 12px;
}

.status-pill.internal {
  background: var(--ok-bg);
  color: var(--accent-strong);
}

.status-pill.public {
  background: var(--danger-bg);
  color: var(--danger);
}

.status-pill.classification-customer {
  background: var(--ok-bg);
  color: var(--accent-strong);
}

.status-pill.classification-service {
  background: var(--warning-bg);
  color: var(--warning);
}

.status-pill.classification-unknown {
  background: var(--surface-muted);
  color: var(--muted);
}

.status-pill.classification-failed {
  background: var(--danger-bg);
  color: var(--danger);
}

.classification-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.classification-current,
.classification-form {
  min-width: 0;
}

.definition-list {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
}

.definition-list div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
}

.definition-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.definition-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.classification-audit-table {
  min-width: 980px;
}

.mode-readout {
  display: grid;
  gap: 6px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.mode-readout strong {
  font-size: 18px;
}

.mode-readout span {
  color: var(--muted);
  line-height: 1.5;
}

.llm-settings-panel {
  display: flex;
  flex-direction: column;
}

.form.llm-settings-form {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-submit {
  align-self: flex-end;
  margin-top: auto;
}

.form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  font-weight: 700;
}

.label-with-help {
  display: inline-flex;
  position: relative;
  align-items: center;
  gap: 6px;
  width: fit-content;
}

.info-tooltip {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border: 1px solid #b6c1cb;
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  cursor: help;
}

.info-tooltip:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.tooltip-content {
  position: absolute;
  z-index: 20;
  right: 0;
  bottom: calc(100% + 8px);
  width: min(320px, calc(100vw - 48px));
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101820;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition:
    opacity 140ms ease,
    transform 140ms ease;
}

.tooltip-content::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 100%;
  border: 6px solid transparent;
  border-top-color: #101820;
}

.info-tooltip:hover .tooltip-content,
.info-tooltip:focus .tooltip-content,
.info-tooltip:focus-within .tooltip-content {
  opacity: 1;
  transform: translateY(0);
}

.field-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.field-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

input[type="text"],
input[type="number"],
input[type="password"],
input:not([type]),
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

select {
  appearance: none;
  padding-right: 36px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 18px,
    calc(100% - 12px) 18px;
  background-size:
    5px 5px,
    5px 5px;
  background-repeat: no-repeat;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
input:not([type]):focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

textarea {
  min-height: 440px;
  resize: vertical;
  line-height: 1.45;
}

.modal-panel textarea {
  min-height: 120px;
}

.modal-panel textarea[name="sample_text"] {
  min-height: 180px;
}

.choice-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
}

.choice-row input {
  width: auto;
  min-height: 0;
}

textarea[readonly],
input[readonly] {
  color: var(--muted);
  background: var(--surface-muted);
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

.radio-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.radio-row input {
  margin-top: 3px;
}

.radio-row span {
  display: grid;
  gap: 4px;
}

.radio-row small {
  color: var(--muted);
  line-height: 1.4;
}

.radio-row.danger {
  border-color: #f0b8b2;
  background: var(--danger-bg);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  min-height: 40px;
  padding: 9px 14px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
}

.button-primary {
  background: var(--accent);
  color: #fff;
}

.button-primary:hover {
  background: var(--accent-strong);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.button-secondary {
  background: transparent;
  color: var(--text);
  border: 0;
}

.button-secondary:hover {
  background: var(--surface-muted);
}

.notice {
  max-width: 1040px;
  margin-bottom: 18px;
  border-radius: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.notice.success {
  border-color: #a8decf;
  background: var(--ok-bg);
  color: var(--accent-strong);
}

.notice.error {
  border-color: #f0b8b2;
  background: var(--danger-bg);
  color: var(--danger);
}

.error-panel {
  display: grid;
  gap: 14px;
}

.error-panel p {
  color: var(--muted);
  line-height: 1.5;
}

.error-panel .button {
  width: fit-content;
}

.form-note {
  color: var(--muted);
  line-height: 1.5;
}

.section-heading.compact {
  margin-bottom: 14px;
}

.prompt-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 20px;
}

.prompt-list {
  align-self: start;
}

.prompt-items {
  display: grid;
  gap: 8px;
}

.prompt-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.prompt-item:hover,
.prompt-item.is-active {
  border-color: #9ed8cf;
  background: var(--ok-bg);
}

.prompt-item span:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.prompt-item strong {
  line-height: 1.2;
}

.prompt-item small,
.prompt-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.prompt-meta {
  flex: 0 0 auto;
  white-space: nowrap;
}

.prompt-editor {
  min-width: 0;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

.data-table th,
.data-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.data-table td {
  line-height: 1.35;
}

.data-table tbody tr {
  transition: background-color 140ms ease;
}

.data-table tbody tr:hover {
  background-color: var(--table-row-hover);
}

.data-table td strong,
.data-table td small {
  display: block;
}

.data-table td small {
  margin-top: 3px;
  color: var(--muted);
}

.data-table .col-user {
  width: 26%;
}

.data-table .col-role {
  width: 150px;
}

.data-table .col-status {
  width: 140px;
}

.data-table .col-created,
.data-table .col-login {
  width: 190px;
  white-space: nowrap;
}

.data-table .col-actions {
  width: 136px;
}

.table-role {
  width: fit-content;
}

.role-cell {
  min-width: 120px;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.role-form.inline-form {
  display: none;
}

.role-form.inline-form.is-editing {
  display: flex;
}

.inline-form select {
  min-width: 130px;
}

.role-downgrade {
  margin-top: 8px;
}

.table-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  width: max-content;
}

.prompt-form {
  gap: 14px;
}

.prompt-preview {
  min-height: 440px;
  max-height: 68vh;
  margin: 0;
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--text);
  font: inherit;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.prompt-textarea,
.prompt-comment {
  display: none;
}

.prompt-form.is-editing .prompt-textarea,
.prompt-form.is-editing .prompt-comment {
  display: grid;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease,
    transform 80ms ease;
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button:hover {
  background: var(--surface-muted);
  border-color: #b6c1cb;
}

.icon-button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.icon-button:active {
  transform: translateY(1px);
  box-shadow: inset 0 2px 5px rgba(20, 28, 38, 0.16);
}

.icon-button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.icon-button-primary:hover {
  background: var(--accent-strong);
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
  box-shadow: none;
}

.icon-button:disabled:hover {
  background: var(--surface);
}

.icon-button-primary:disabled:hover {
  background: var(--accent);
}

.modal {
  width: min(100% - 32px, 460px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
}

.modal::backdrop {
  background: rgba(16, 24, 32, 0.42);
}

.modal-panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.modal-heading p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.5;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef1f4;
}

.login-layout {
  width: min(100%, 440px);
}

.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
}

.login-brand h1 {
  font-size: 26px;
}

.login-brand p {
  margin-top: 5px;
  color: var(--muted);
}

@media (max-width: 820px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .page-grid {
    grid-template-columns: 1fr;
  }

  .prompt-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 640px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.filters-form {
  grid-template-columns: minmax(130px, 1fr) minmax(130px, 1fr) minmax(150px, 1fr) minmax(130px, 1fr) minmax(150px, 1fr) auto;
  align-items: end;
}

.tickets-filters-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.replies-filters-form {
  grid-template-columns: minmax(140px, 1fr) minmax(130px, 1fr) minmax(150px, 1fr) minmax(130px, 1fr) minmax(130px, 1fr) minmax(100px, 0.7fr) auto;
}

.tickets-filters-form .filter-reset-button {
  justify-self: end;
  min-width: 112px;
}

.filter-rules-form {
  grid-template-columns: minmax(150px, 1fr) minmax(120px, 0.8fr) minmax(110px, 0.7fr) minmax(170px, 1.3fr) minmax(100px, 0.6fr) auto;
}

.playground-filters-form {
  grid-template-columns: minmax(160px, 1.4fr) minmax(130px, 1fr) minmax(150px, 1fr) minmax(100px, 0.7fr) auto;
}

.filter-reset-button {
  display: inline-flex;
  gap: 8px;
  justify-content: center;
  min-height: 44px;
  text-decoration: none;
}

.filter-reset-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentcolor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.filter-reset-button:active {
  transform: translateY(1px) scale(0.98);
}

.quick-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 18px;
}

.quick-filter-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.quick-filter-link:hover {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
  background: var(--surface-muted);
}

.quick-filter-link:active {
  transform: translateY(1px) scale(0.98);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 14px;
}

.pagination-actions {
  display: flex;
  gap: 10px;
}

.replies-table td small {
  display: block;
  margin-top: 4px;
}

.tickets-table {
  min-width: 1220px;
}

.tickets-table td small {
  display: block;
  margin-top: 4px;
}

.ticket-attempts-table {
  min-width: 980px;
}

.playground-table {
  min-width: 980px;
}

.playground-runs-table {
  min-width: 1040px;
}

.filter-rules-table {
  min-width: 980px;
  table-layout: fixed;
}

.filter-rules-table .col-filter-rule {
  width: 32%;
}

.filter-rules-table .col-filter-scope {
  width: 17%;
}

.filter-rules-table .col-filter-status {
  width: 95px;
}

.filter-rules-table .col-filter-audit {
  width: 160px;
  white-space: nowrap;
}

.filter-rules-table .col-filter-actions {
  width: 150px;
}

.filter-rules-table .table-actions {
  width: auto;
}

.rule-value {
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.table-button {
  min-height: 34px;
  padding: 7px 12px;
}

@media (max-width: 820px) {
  .filters-form,
  .tickets-filters-form,
  .replies-filters-form,
  .filter-rules-form,
  .playground-filters-form {
    grid-template-columns: 1fr;
  }

  .pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .pagination-actions {
    flex-wrap: wrap;
  }

  .tickets-filters-form .filter-reset-button {
    justify-self: stretch;
  }
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.summary-grid > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
}

.summary-grid small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.35;
}

.meta-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
}

.metric-card strong {
  display: block;
  font-size: 24px;
  line-height: 1.2;
}

.summary-breakdown {
  margin: -4px 0 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.breakdown-table {
  min-width: 760px;
}

.breakdown-table th,
.breakdown-table td {
  padding: 10px 12px;
}

.breakdown-table td:not(:first-child),
.breakdown-table th:not(:first-child) {
  text-align: right;
}

.timeline {
  display: grid;
  gap: 14px;
}

.timeline-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.timeline-filter-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease,
    transform 80ms ease;
}

.timeline-filter-button {
  min-height: 36px;
  padding: 8px 12px;
}

.timeline-filter-button:hover {
  background: var(--surface-muted);
  border-color: #b6c1cb;
}

.timeline-filter-button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.timeline-filter-button:active {
  transform: translateY(1px);
  box-shadow: inset 0 2px 5px rgba(20, 28, 38, 0.14);
}

.timeline-filter-button.is-active {
  border-color: var(--accent);
  background: #e6f5f2;
  color: #0f766e;
}

.timeline-item {
  border: 1px solid var(--line);
  border-left: 5px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.timeline-actor-customer {
  border-left-color: #2563eb;
  background: #f8fbff;
}

.timeline-actor-agent {
  border-left-color: #2f7d52;
  background: #f7fbf8;
}

.timeline-actor-bot {
  border-left-color: #0f766e;
  background: #f6fbfa;
}

.timeline-actor-system,
.timeline-actor-unknown {
  border-left-color: #667085;
}

.timeline-comment.public,
.timeline-event.comment_public {
  border-left-color: #2f7d52;
}

.timeline-comment.internal,
.timeline-event.comment_private,
.timeline-event.status_change {
  border-left-color: #667085;
}

.timeline-attempt.failed {
  border-left-color: #b42318;
}

.timeline-attempt.skipped_duplicate {
  border-left-color: #a15c07;
}

.timeline-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.timeline-heading[data-collapse-toggle] {
  margin: -6px -6px 10px;
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
  transition:
    background-color 140ms ease,
    box-shadow 140ms ease,
    transform 80ms ease;
}

.timeline-heading[data-collapse-toggle]:hover {
  background: rgba(255, 255, 255, 0.64);
}

.timeline-heading[data-collapse-toggle]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.timeline-heading[data-collapse-toggle]:active {
  transform: translateY(1px);
}

.timeline-actor {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.timeline-actor-customer .timeline-actor {
  border-color: #bfdbfe;
  background: #dbeafe;
  color: #1d4ed8;
}

.timeline-actor-agent .timeline-actor {
  border-color: #bbf7d0;
  background: #dcfce7;
  color: #166534;
}

.timeline-actor-bot .timeline-actor {
  border-color: #99f6e4;
  background: #ccfbf1;
  color: #0f766e;
}

.timeline-header-content {
  flex: 1 1 auto;
  min-width: 0;
}

.timeline-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.timeline-title-row strong {
  color: var(--text);
}

.timeline-actor-label {
  border-radius: 8px;
  padding: 3px 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
}

.timeline-actor-label.customer {
  background: #dbeafe;
  color: #1d4ed8;
}

.timeline-actor-label.agent {
  background: #dcfce7;
  color: #166534;
}

.timeline-actor-label.bot {
  background: #ccfbf1;
  color: #0f766e;
}

.timeline-collapse-icon {
  flex: 0 0 auto;
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin: 12px 4px 0 auto;
  border-right: 2px solid currentcolor;
  border-bottom: 2px solid currentcolor;
  color: var(--muted);
  transform: translateY(-2px) rotate(45deg);
  transition: transform 140ms ease;
}

.timeline-heading[aria-expanded="false"] .timeline-collapse-icon {
  transform: translateY(1px) rotate(-45deg);
}

.timeline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 13px;
}

.timeline-meta span:not(.status-pill) {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px 8px;
  background: var(--surface-soft);
}

.timeline-body {
  margin-left: 46px;
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.5;
}

.timeline-body a {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.timeline-attachments {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.attachment-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  white-space: normal;
}

.attachment-link:hover {
  background: var(--surface-muted);
}

.attachment-link img,
.attachment-icon {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.attachment-link img {
  object-fit: cover;
}

.attachment-icon {
  position: relative;
}

.attachment-icon::before,
.attachment-icon::after {
  position: absolute;
  content: "";
  border: 2px solid var(--muted);
}

.attachment-icon::before {
  inset: 9px 11px 8px;
  border-radius: 3px;
}

.attachment-icon::after {
  top: 9px;
  right: 11px;
  width: 8px;
  height: 8px;
  border-left: 0;
  border-bottom: 0;
}

.attachment-link span:last-child {
  min-width: 0;
}

.attachment-link strong,
.attachment-link small {
  display: block;
  overflow-wrap: anywhere;
}

.attachment-link small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.timeline-body.is-collapsed {
  max-height: 86px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, #000 58%, transparent);
  mask-image: linear-gradient(180deg, #000 58%, transparent);
}

.timeline-item .notice {
  margin-left: 46px;
}

.empty-state {
  color: var(--muted);
}

.playground-chat {
  display: grid;
  gap: 14px;
}

.playground-message {
  width: min(100%, 860px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
}

.playground-message.user {
  justify-self: start;
  border-left: 5px solid #2563eb;
  background: #f8fbff;
}

.playground-message.assistant {
  justify-self: end;
  border-left: 5px solid #0f766e;
  background: #f6fbfa;
}

.playground-message-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.playground-message-meta strong {
  color: var(--text);
}

.playground-message-meta span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px 8px;
  background: var(--surface-soft);
}

.playground-message-body {
  white-space: pre-wrap;
  line-height: 1.5;
}

.playground-reply-form {
  margin-top: 18px;
}

.table-link {
  color: inherit;
  text-decoration: none;
}

.table-link:hover {
  text-decoration: underline;
}

@media (max-width: 820px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .classification-layout,
  .definition-list div {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .timeline-body,
  .timeline-item .notice {
    margin-left: 0;
  }
}
