html, body {
  height: 100%;
  margin: 0;
}

/* Login view (full-screen when not authenticated) */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111827;
}

.login-view-inner {
  width: 100%;
  max-width: 360px;
  padding: 1.5rem;
}

.login-view-inner .ui.form .field label {
  color: #e5e7eb;
}

.login-view-inner .ui.header {
  color: #f9fafb;
}

.login-view-inner input {
  background: #1f2937;
  color: #f9fafb;
  border-color: #374151;
}

/* Sidebar footer account menu */
.app-sidebar-footer {
  margin-top: auto;
  padding: 0.5rem 0.375rem;
  display: flex;
  justify-content: center;
}

.app-sidebar-footer .account-menu-trigger.ui.basic.button {
  width: 100%;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  background: transparent;
  box-shadow: none;
  padding: 0.7rem !important;
}

.app-sidebar-footer .account-menu-trigger.ui.basic.button:hover,
.app-sidebar-footer .account-menu-trigger.ui.basic.button.active,
.app-sidebar-footer .account-menu-trigger.ui.basic.button.visible {
  color: #f9fafb;
  background: #374151;
}

.app-sidebar-footer .account-menu-trigger > .icon {
  margin: 0 !important;
  font-size: 1.35rem !important;
}

.app-sidebar-footer .account-menu-trigger .menu {
  min-width: 180px;
}

/* Overall layout: sidebar + main content */
.app-layout {
  display: flex;
  height: 100vh;
}

.app-sidebar {
  width: 56px;
  min-width: 56px;
  max-width: 56px;
  color: #e5e7eb;
  padding: 0.5rem 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.app-sidebar .app-menu {
  width: 100%;
  border-radius: 0;
  border: none;
  background: transparent;
}

.app-sidebar .item {
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 0.5rem !important;
  color: #9ca3af !important;
}

.app-sidebar .item .icon {
  margin: 0 !important;
  font-size: 1.25rem !important;
}

.app-sidebar .item.active {
  background: #1f2937 !important;
  color: #f9fafb !important;
}

.app-main {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  display: flex;
}

.view {
  display: none;
  width: 100%;
  height: 100%;
}

.view.active {
  display: flex;
}

.view-profile {
  overflow-y: auto;
}

.view-settings {
  overflow-y: auto;
}

.profile-view-segment {
  width: 100%;
  padding: 1.25rem !important;
}

.view-settings .ui.basic.segment {
  width: 100%;
  padding: 1.25rem !important;
}

.settings-view-segment {
  min-height: 100%;
}

.settings-page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 100%;
}

.settings-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.settings-page-subtitle {
  margin: 0.35rem 0 0;
  color: #6b7280;
  font-size: 0.95rem;
}

.settings-groups {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.settings-group-card {
  border: 1px solid #e5e7eb;
  border-radius: 1.75rem;
  background: #f6f7f9;
  padding: 1.1rem 1.15rem;
  box-shadow: none;
}

.settings-group-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.settings-group-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #111827;
}

.settings-group-description {
  margin: 0.3rem 0 0;
  color: #6b7280;
  font-size: 0.92rem;
}

.settings-group-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  padding: 0.38rem 0.7rem;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  color: #4b5563;
  font-size: 0.82rem;
  font-weight: 600;
}

.settings-group-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.settings-field-card {
  border: 1px solid #e5e7eb;
  border-radius: 1.35rem;
  background: #ffffff;
  padding: 1rem 1rem 0.95rem;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.settings-field-card.dirty {
  border-color: #9dc5f8;
  box-shadow: 0 0 0 3px rgba(33, 133, 208, 0.08);
}

.settings-field-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 340px);
  gap: 1rem 1.25rem;
  align-items: start;
}

.settings-field-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.settings-field-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #111827;
}

.settings-restart-mark {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(242, 113, 28, 0.12);
  color: #b45309;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.settings-field-key {
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: #6b7280;
}

.settings-field-key code {
  background: #f3f4f6;
  padding: 0.18rem 0.42rem;
  border-radius: 999px;
  color: #374151;
}

.settings-field-description {
  margin-top: 0.55rem;
  color: #374151;
  line-height: 1.45;
}

.settings-field-default {
  margin-top: 0.55rem;
  color: #9ca3af;
  font-size: 0.85rem;
}

.settings-field-default strong {
  color: #6b7280;
  font-weight: 600;
}

.settings-field-control {
  min-width: 0;
}

.settings-field-control .ui.input,
.settings-field-control .ui.form,
.settings-field-control .ui.dropdown {
  width: 100%;
}

.settings-field-control .ui.input input,
.settings-field-control textarea,
.settings-field-control select {
  border-radius: 1rem !important;
}

.settings-field-control textarea {
  min-height: 6.5rem;
  resize: vertical;
}

.settings-field-control .ui.toggle.checkbox {
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
}

.settings-field-control .ui.toggle.checkbox label {
  color: #374151 !important;
  font-weight: 600;
}

.settings-save-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 1.1rem;
  margin-top: 0.2rem;
  border: 1px solid rgba(229, 231, 235, 0.96);
  border-radius: 1.45rem;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 35px rgba(17, 24, 39, 0.08);
}

.settings-save-status {
  min-height: 1.4rem;
  color: #6b7280;
  font-size: 0.92rem;
}

.settings-save-status.positive {
  color: #0f766e;
}

.settings-save-status.negative {
  color: #b91c1c;
}

#settingsSaveBtn.ui.button {
  border-radius: 999px !important;
  padding: 0.85rem 1.35rem !important;
  min-width: 10rem;
}

@media (max-width: 980px) {
  .settings-field-layout {
    grid-template-columns: 1fr;
  }

  .settings-save-bar {
    flex-direction: column;
    align-items: stretch;
  }

  #settingsSaveBtn.ui.button {
    width: 100%;
  }
}

/* Cases view layout (reuse existing grid inside) */
.app.ui.grid {
  display: flex !important;
  flex-wrap: nowrap !important;
  height: 100vh;               /* full screen */
  margin: 0;
}

/* Remove Semantic's default column padding a bit (optional) */
.app > .column {
  padding: 0.75rem !important;
}

/* Make both columns stretch full height */
.sidebar, .chat {
  height: 100%;
}

/* Cases view: flex row, left panel resizable from 350px */
.cases-grid {
  display: flex;
  flex-direction: row;
  height: 100%;
  margin: 0;
  width: 100%;
  min-width: 0;
}

.cases-list {
  flex: 0 0 auto;
  width: 350px;
  min-width: 350px;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0 !important;
}

.cases-resize-handle {
  flex: 0 0 6px;
  cursor: col-resize;
  background: rgba(0, 0, 0, 0.08);
  transition: background 0.15s;
}
.cases-resize-handle:hover,
.cases-resize-handle.resizing {
  background: rgba(0, 0, 0, 0.15);
}

.cases-chat {
  flex: 1 1 auto;
  min-width: 400px;
  height: 100%;
}

.view-cases.is-case-placeholder-layout .cases-chat {
  min-width: 0;
}

/* COLUMN 3: Case details */
.cases-details-column {
  flex: 0 0 416px;
  width: 416px;
  min-width: 416px;
  max-width: 416px;
  height: 100%;
  overflow: hidden;
  border-left: none;
}

.view-cases.is-case-placeholder-layout .cases-details-column {
  display: none;
}

.cases-details-inner {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.case-details-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.case-details-quality-panel {
  flex: 0 0 auto;
  padding: 0.6rem 1.25rem 0.35rem;
  border-top: 1px solid #e5e7eb;
  background: #fff;
}

.case-details-quality-panel:empty {
  display: none;
}

.case-details-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding:8px;
}

.case-details-panel .case-empty-state.ui.placeholder.segment {
  width: 100%;
  min-height: 10rem;
  margin: 0;
}

.ui.top.attached.menu.chat-header {
  border: 0px !important;
}

.ui.top.attached.menu.chat-header  .item:before {
  width:0px !important
}

.case-details-panel .case-details-section {
  width: 100%;
  padding-left: 0;
  padding-right: 0;
}

.case-details-panel .case-details-section h2.ui.sub.header {
  padding-left: 1rem !important;
  padding-right: 1rem !important;
  padding-bottom: 0.2rem;
}

.case-details-panel .case-details-section td {
  padding-left: 1rem !important;
  padding-right: 1rem !important;
}

.case-details-card {
  border: 1px solid #e1e2e4;
  border-radius: 1.0rem;
  background: #f6f7f9;
  padding: 1rem 1.1rem;
}

/* Order and file segments - Semantic UI card-like blocks */
.case-details-panel .case-order-segment,
.case-details-panel .case-file-segment {
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  border-radius: 1.75rem;
  border: 1px solid #e1e2e4;
  background: #f6f7f9;
  box-shadow: none;
}

.case-details-panel .case-order-segment:last-of-type,
.case-details-panel .case-file-segment {
  margin-bottom: 0.5rem;
}

.case-details-panel .case-order-segment .case-segment-title {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.case-details-panel .case-file-segment .case-file-link-row {
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.case-details-panel .case-file-segment .case-file-link-main,
.case-details-panel .case-file-segment .case-file-link-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.case-details-panel .case-file-segment .case-file-link-actions {
  margin-left: auto;
}

.case-details-panel .case-file-segment .case-file-link-row a {
  font-weight: 500;
}

.case-details-panel .case-file-segment .case-file-analyze-link.is-disabled {
  opacity: 0.55;
  pointer-events: none;
  text-decoration: none;
}

.case-details-panel .case-ids-table,
.case-details-panel .case-fields-table {
  width: 100%;
  margin: 0px;
}

.case-details-panel .case-order-header-row {
  margin: 0px;
}

.case-details-panel .case-order-segment .case-fields-table,
.case-details-panel .case-file-segment .case-fields-table {
  margin-bottom: 0;
}

.case-details-panel table {
  width: 100% !important;
}

/* First column of details tables: fixed 75px */
.case-details-panel .case-ids-table tbody td:first-child,
.case-details-panel .case-fields-table thead th:first-child,
.case-details-panel .case-fields-table tbody td:first-child {
  width: 90px;
  min-width: 90px;
  max-width: 90px;
}

.case-details-panel .case-ids-table tbody td {
  padding: 0.45rem 0;
  vertical-align: middle;
  border-top: 1px solid #e1e2e4;
}

.case-details-panel .case-ids-table tbody tr:first-child td {
  border-top: none;
}

/* Second column of Order table */
.case-details-panel .case-fields-table th:nth-child(2),
.case-details-panel .case-fields-table td:nth-child(2) {
  min-width: 80px;
}

/* Definition table: flexible layout, avoid text compression */
.case-details-panel .case-fields-table.definition.table {
  table-layout: auto;
}

.case-details-panel .case-fields-table.definition.table tbody td:first-child {
  font-weight: 600;
  color: #374151;
  width: 90px;
  min-width: 90px;
  max-width: 90px;
  white-space: nowrap;
}

.case-details-panel .case-fields-table.definition.table tbody td:nth-child(2) {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.case-details-panel .case-fields-table.definition.table tbody td {
  padding: 0.5em 0.75em;
  vertical-align: middle;
}

/* Match level row colors: 0=red, 1=yellow, 2=green */
.case-details-panel .case-fields-table tbody tr.match-full {
  background-color: rgba(33, 186, 69, 0.15) !important;
}
.case-details-panel .case-fields-table tbody tr.match-threshold {
  background-color: rgba(251, 189, 8, 0.25) !important;
}
.case-details-panel .case-fields-table tbody tr.match-none {
  background-color: rgba(219, 40, 40, 0.15) !important;
}

.case-details-panel .case-file-segment {
  margin-bottom: 0.5rem;
}

.case-details-panel .case-file-fields-block {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
}

.case-details-panel .case-file-fields-extra {
  display: none;
}

.case-details-panel .case-file-fields-block.is-expanded .case-file-fields-extra {
  display: block;
}

.case-details-panel .case-file-fields-toggle {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: #2185d0;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.case-details-panel .case-file-fields-toggle:hover,
.case-details-panel .case-file-fields-toggle:focus {
  color: #1678c2;
  text-decoration: underline;
}

.case-details-panel .case-field-name-hint {
  display: block;
  max-width: 100%;
  cursor: help;
}

.case-details-panel .case-field-name-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-details-panel .case-files-list {
  list-style: none;
  margin: 0 0 1rem 0;
  padding: 0;
}

.case-details-panel .case-files-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.case-details-panel .case-order-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.case-details-panel .case-details-header-row {
  align-items: flex-start;
}

.case-details-panel .case-order-header-row h2.ui.sub.header,
.case-details-panel .case-details-card > h2.ui.sub.header {
  margin: 0;
}

.case-details-card-id {
  padding-right: 1rem;
  color: #6b7280;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.case-order-refresh-error {
  margin-top: 0.55rem;
  color: #b91c1c;
  font-size: 0.85rem;
}

.case-order-status-value {
  font-weight: 700;
}

button.case-order-status-value {
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

button.case-order-status-value:hover,
button.case-order-status-value:focus-visible {
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

button.case-order-status-value:focus-visible {
  outline: none;
}

button.case-order-status-value.disabled,
button.case-order-status-value:disabled {
  opacity: 0.65;
  cursor: default;
  text-decoration: none;
}

.case-details-panel .case-files-header-row h2.ui.sub.header {
  margin: 0;
}

.case-details-panel .case-details-section:last-child .case-files-list {
  margin-bottom: 0;
  margin: 1rem;
}

.case-details-panel .case-files-list li {
  margin-bottom: 0.75rem;
}

.case-details-panel .case-files-list li:last-child {
  margin-bottom: 0;
}

.case-details-panel .case-files-list a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #2185d0;
  text-decoration: none;
}

.case-details-panel .case-files-list a:hover {
  text-decoration: underline;
}

.case-details-panel .case-files-list a i {
  flex-shrink: 0;
}

.case-details-panel .case-file-type-label {
  margin: 0;
}

.case-file-card {
  border: 1px solid #d7dce5;
  border-radius: 1.5rem;
  background: #ffffff;
  padding: 1rem;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.case-file-card.is-clickable {
  cursor: pointer;
}

.case-file-card.is-clickable:hover {
  border-color: #b8c2d6;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.case-file-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.case-file-card-main {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  flex: 1 1 auto;
}

.case-file-card-preview {
  width: 4rem;
  height: 4rem;
  border-radius: 1.2rem;
  background: linear-gradient(180deg, #eef2ff 0%, #e0e7ff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 0 0 auto;
}

.case-file-preview-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.case-file-preview-icon {
  color: #6366f1;
  font-size: 1.8rem;
  line-height: 1;
}

.case-file-preview-icon i.icon {
  margin: 0;
}

.case-file-card-body {
  min-width: 0;
  flex: 1 1 auto;
}

.case-file-card-title {
  color: #111827;
  font-size: 1.18rem;
  font-weight: 700;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-details-panel .case-file-card-title .case-file-title-link,
.message-attachments .case-file-card-title .case-file-title-link {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
  text-decoration: none;
}

.case-details-panel .case-file-card-title .case-file-title-link:hover,
.message-attachments .case-file-card-title .case-file-title-link:hover,
.case-details-panel .case-file-card-title .case-file-title-link:focus,
.message-attachments .case-file-card-title .case-file-title-link:focus {
  color: #1d4ed8;
  text-decoration: underline;
}

.case-file-card-meta {
  margin-top: 0.2rem;
  color: #6b7280;
  font-size: 0.92rem;
  min-width: 0;
  display: grid;
  align-items: start;
}

.case-file-card-meta-primary,
.case-file-card-meta-secondary {
  grid-area: 1 / 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: opacity 0.14s ease;
}

.case-file-card-meta-secondary {
  opacity: 0;
  pointer-events: none;
}

.case-file-card-meta:hover .case-file-card-meta-primary {
  opacity: 0;
}

.case-file-card-meta:hover .case-file-card-meta-secondary {
  opacity: 1;
}

.case-file-card-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.6rem;
  flex: 0 0 auto;
}

.case-file-status {
  text-align: right;
}

.case-file-status-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1em;
}

.case-file-status-label i.icon {
  margin: 0;
}

.case-file-status-actor {
  line-height: 1.3em;
  color: #6b7280;
  font-size: 0.9rem;
}

.case-file-status.is-validated .case-file-status-label {
  color: #16a34a;
}

.case-file-status.is-review .case-file-status-label {
  color: #ca8a04;
}

.case-file-status.is-failed .case-file-status-label {
  color: #dc2626;
}

.case-file-status.is-processing .case-file-status-label {
  color: #4b5563;
}

.case-file-status.is-not-applicable .case-file-status-label {
  color: #64748b;
}

.case-file-status-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.18rem;
}

.case-file-status-dots span {
  width: 0.28rem;
  height: 0.28rem;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.25;
  animation: case-file-status-dot 1.1s infinite ease-in-out;
}

.case-file-status-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.case-file-status-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

.case-file-card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.case-file-action-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #fff;
  color: #374151;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.55rem 0.8rem;
  text-decoration: none;
}

.case-file-action-button:hover,
.case-file-action-button:focus {
  border-color: #9ca3af;
  background: #f9fafb;
  color: #111827;
  text-decoration: none;
}

.case-file-action-button.is-disabled,
.case-file-action-button[aria-disabled="true"] {
  opacity: 0.55;
  pointer-events: none;
}

.case-file-card .case-fields-table {
  margin-top: 0.9rem;
}

.case-details-panel .case-file-card {
  border: 1px solid #d7dce5;
  border-radius: 1.5rem;
  background: #ffffff;
  padding: 1rem;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.case-details-panel .case-file-card.is-clickable {
  cursor: pointer;
}

.case-details-panel .case-file-card.is-clickable:hover {
  border-color: #b8c2d6;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.case-details-panel .case-file-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.case-details-panel .case-file-card-main {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  flex: 1 1 auto;
}

.case-details-panel .case-file-card-preview {
  width: 4rem;
  height: 4rem;
  border-radius: 1.2rem;
  background: linear-gradient(180deg, #eef2ff 0%, #e0e7ff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 0 0 auto;
}

.case-details-panel .case-file-preview-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.case-details-panel .case-file-preview-icon {
  color: #6366f1;
  font-size: 1.8rem;
  line-height: 1;
}

.case-details-panel .case-file-preview-icon i.icon {
  margin: 0;
}

.case-details-panel .case-file-card-body {
  min-width: 0;
}

.case-details-panel .case-file-card-title {
  color: #111827;
  font-size: 1.18rem;
  font-weight: 700;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-details-panel .case-file-card-meta {
  margin-top: 0.2rem;
  color: #6b7280;
  font-size: 0.92rem;
}

.case-details-panel .case-file-card-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.6rem;
  flex: 0 0 auto;
}

.case-details-panel .case-file-status {
  text-align: right;
}

.case-details-panel .case-file-status-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
  font-size: 1rem;
}

.case-details-panel .case-file-status-label i.icon {
  margin: 0;
}

.case-details-panel .case-file-status-actor {
  color: #6b7280;
  line-height: 1.1em;
  font-size: 0.9rem;
}

.case-details-panel .case-file-status.is-validated .case-file-status-label {
  color: #16a34a;
}

.case-details-panel .case-file-status.is-review .case-file-status-label {
  color: #ca8a04;
}

.case-details-panel .case-file-status.is-failed .case-file-status-label {
  color: #dc2626;
}

.case-details-panel .case-file-status.is-processing .case-file-status-label {
  color: #4b5563;
}

.case-details-panel .case-file-status.is-not-applicable .case-file-status-label {
  color: #64748b;
}

.case-details-panel .case-file-status-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.18rem;
}

.case-details-panel .case-file-status-dots span {
  width: 0.28rem;
  height: 0.28rem;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.25;
  animation: case-file-status-dot 1.1s infinite ease-in-out;
}

.case-details-panel .case-file-status-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.case-details-panel .case-file-status-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

.case-details-panel .case-file-card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.case-details-panel .case-file-action-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #fff;
  color: #374151;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.55rem 0.8rem;
  text-decoration: none;
}

.case-details-panel .case-file-action-button:hover,
.case-details-panel .case-file-action-button:focus {
  border-color: #9ca3af;
  background: #f9fafb;
  color: #111827;
  text-decoration: none;
}

.case-details-panel .case-file-action-button.is-disabled,
.case-details-panel .case-file-action-button[aria-disabled="true"] {
  opacity: 0.55;
  pointer-events: none;
}

.case-details-panel .case-file-card .case-fields-table {
  margin-top: 0.9rem;
}

.case-details-panel .case-labels-editor {
  min-width: 0;
}

.case-details-panel .case-labels-editor .ui.dropdown {
  min-width: 100%;
}

@keyframes case-file-status-dot {
  0%, 80%, 100% {
    opacity: 0.2;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-1px);
  }
}

@media (max-width: 767px) {
  .case-file-card-head {
    flex-direction: column;
  }

  .case-file-card-side {
    width: 100%;
    align-items: flex-start;
  }

  .case-file-status {
    text-align: left;
  }

  .case-details-panel .case-file-card-head {
    flex-direction: column;
  }

  .case-details-panel .case-file-card-side {
    width: 100%;
    align-items: flex-start;
  }

  .case-details-panel .case-file-status {
    text-align: left;
  }
}

.case-details-panel .case-ids-table td:last-child .case-labels-editor .ui.dropdown {
  width: 100%;
}

.case-details-panel .extracted-data {
  margin: 0.2rem 0 0.4rem 1.4rem;
  padding: 0.3rem 0.5rem;
  background: #f8f9fa;
  border-left: 2px solid #d0d0d0;
  font-size: 0.8rem;
  line-height: 1.4;
}

.case-details-panel .extracted-field {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.case-details-panel .extracted-key {
  color: #888;
}

.case-details-panel .extracted-val {
  color: #333;
}

.case-details-panel .case-details-section h2.ui.sub.header {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
}


/* Inner wrappers use flex to create "header + scroll + footer" */
.chat-inner {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.cases-list .sidebar-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.cases-list-header {
  flex: 0 0 auto;
  margin: 0 !important;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem !important;
}

.cases-list-header .ui.icon.input {
  min-width: 0;
}

.cases-list-header .ui.icon.input input {
  padding: 0.4rem 0.5rem;
  font-size: 0.9rem;
}

.cases-search-wrap {
  position: relative;
  flex: 1 1 220px;
  min-width: 180px;
}
.cases-search-wrap .cases-search-clear {
  position: absolute;
  margin-top: 15px !important;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  opacity: 0.5;
  z-index: 1;
}
.cases-search-wrap .cases-search-clear:hover {
  opacity: 1;
}
.cases-search-wrap.has-value .search.icon {
  display: none;
}

/* Cases search above table */
.cases-search-segment {
  flex: 0 0 auto;
  padding: 0.5rem 0.75rem !important;
}
.cases-search-segment .ui.input input {
  padding: 0.5rem 0.75rem;
}
.cases-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.cases-toolbar .ui.button,
.cases-toolbar .ui.labeled.button {
  margin: 0 !important;
}

.cases-toolbar-labeled > .ui.button {
  white-space: nowrap;
}

.cases-toolbar-labeled .ui.label {
  min-width: 2.25rem;
  text-align: center;
}

.cases-toolbar-popup {
  min-width: 280px;
  max-width: min(420px, calc(100vw - 2rem));
  padding: 0.75rem 0.9rem !important;
}

.cases-filter-popup-section + .cases-filter-popup-section {
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px solid #e5e7eb;
}

.cases-filter-popup-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 0.5rem;
}

.cases-filter-popup-options {
  display: grid;
  gap: 0.4rem;
  max-height: 180px;
  overflow: auto;
  padding-right: 0.1rem;
}

.cases-filter-popup-checkbox {
  display: block !important;
}

.cases-filter-popup-empty {
  font-size: 0.85rem;
  color: #6b7280;
}

.cases-sort-popup-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 0;
  background: transparent;
  color: #111827;
  font: inherit;
  text-align: left;
  padding: 0.6rem 0.1rem;
  cursor: pointer;
}

.cases-sort-popup-option + .cases-sort-popup-option {
  border-top: 1px solid #e5e7eb;
}

.cases-sort-popup-option.is-active {
  font-weight: 700;
}

.cases-sort-popup-option:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.cases-sort-popup-option .icon {
  margin: 0 !important;
  color: #2185d0;
}

/* Cases table scroll: fills parent, overflow scroll */
.cases-table-scroll {
  flex: 1;
  overflow: auto;
  padding: 0 !important;
  min-height: 0;
  width: 100%;
  height: 100%;
}

.cases-pagination-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid #e5e7eb;
  background: #ffffff;
}

.cases-pagination-status {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  font-size: 0.85rem;
  color: #4b5563;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cases-pagination-bar .ui.button {
  flex: 0 0 auto;
}

.cases-pagination-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.cases-expand-table-btn {
  display: inline-flex !important;
  align-items: center;
  gap: 0.4rem;
}

.cases-expand-btn-arrow {
  font-size: 1rem;
  line-height: 1;
}

.view-cases.is-list-expanded .cases-list {
  flex: 1 1 auto !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
}

.view-cases.is-list-expanded .cases-resize-handle,
.view-cases.is-list-expanded .cases-chat,
.view-cases.is-list-expanded .cases-details-column {
  display: none;
}

/* Sidebar scrolling area (legacy / other uses) */
.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
}

/* Chats view layout: 3-column grid with fixed sidebars and flexible center */
.chats-grid {
  --chats-left-width: 350px;
  --chats-right-width: 620px;
  --chats-center-min-width: 320px;
  display: grid;
  grid-template-columns: var(--chats-left-width) 6px minmax(var(--chats-center-min-width), 1fr) 6px var(--chats-right-width);
  grid-template-rows: minmax(0, 1fr);
  width: 100%;
  height: 100%;
  margin: 0;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.chats-list {
  width: 100% !important;
  min-width: 0 !important;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0 !important;
}

.chats-resize-handle {
  width: 6px;
  height: 100%;
  cursor: col-resize;
  background: rgba(0, 0, 0, 0.08);
  transition: background 0.15s;
}
.chats-resize-handle:hover,
.chats-resize-handle.resizing {
  background: rgba(0, 0, 0, 0.15);
}

/* CENTER: Messaging window */
.chats-messaging {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chats-messaging-resize-handle {
  width: 6px;
  height: 100%;
  cursor: col-resize;
  background: rgba(0, 0, 0, 0.08);
  transition: background 0.15s;
}
.chats-messaging-resize-handle:hover,
.chats-messaging-resize-handle.resizing {
  background: rgba(0, 0, 0, 0.15);
}

/* RIGHT: Chat options column (resizable sidebar) */
.chats-options {
  width: 100% !important;
  min-width: 550px;
  max-width: none;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid rgba(34, 36, 38, 0.15);
}

.chats-options-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
  overflow: hidden;
}

.chats-options-header {
  flex: 0 0 auto;
  margin: 0 !important;
}

.chats-options-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  min-height: 0;
}

.chat-list-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.chat-list-table-column,
.chat-list-detail-column {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.chat-list-detail-column {
  border-left: 1px solid rgba(34, 36, 38, 0.15);
}

.chat-list-table-shell,
.chat-list-detail-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.chat-list-table-header,
.chat-list-detail-header {
  flex: 0 0 auto;
  margin: 0 !important;
}

.chat-list-table-scroll,
.chat-list-detail-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0.75rem;
}

.chat-list-table {
  margin: 0 !important;
}

.chat-list-table tbody tr {
  cursor: pointer;
}

.chat-list-table tbody tr.active {
  background: rgba(33, 133, 208, 0.08);
}

.chat-list-detail-shell {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-list-detail-table td:first-child {
  width: 150px;
  color: rgba(0, 0, 0, 0.68);
}

.chat-list-detail-table .ui.dropdown,
.chat-list-detail-table .ui.checkbox {
  width: 100%;
}

/* Agents view: list left, edit right */
.view-agents {
  height: 100%;
  padding: 0;
}
.agents-grid {
  display: flex;
  flex-direction: row;
  height: 100%;
  width: 100%;
  margin: 0;
  min-width: 0;
}
.agents-list {
  flex: 0 0 auto;
  width: 480px;
  min-width: 400px;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0 !important;
}
.agents-resize-handle {
  flex: 0 0 6px;
  cursor: col-resize;
  background: rgba(0, 0, 0, 0.08);
  transition: background 0.15s;
}
.agents-resize-handle:hover,
.agents-resize-handle.resizing {
  background: rgba(0, 0, 0, 0.15);
}
.agents-list .sidebar-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.agents-list-header {
  flex: 0 0 auto;
  margin: 0 !important;
}
.agents-list-header-modern {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 1rem;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
}
.agents-list-title-block {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  min-width: 0;
}
.agents-list-meta {
  color: #6b7280;
  font-size: 0.9rem;
}
.agents-list-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.agents-filter-popover {
  position: relative;
}
.agents-filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  padding: 0 0.38rem;
  border-radius: 999px;
  background: #e0ecff;
  color: #1d4ed8;
  font-size: 0.76rem;
  font-weight: 700;
}
.agents-filter-menu {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  width: min(24rem, calc(100vw - 2rem));
  padding: 1rem;
  border: 1px solid #dbe4ef;
  border-radius: 1.2rem;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(18px);
  z-index: 12;
}
.agents-filter-menu-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}
.agents-filter-menu-title {
  font-size: 1rem;
  font-weight: 700;
  color: #111827;
}
.agents-filter-menu-copy {
  margin-top: 0.2rem;
  color: #6b7280;
  font-size: 0.88rem;
  line-height: 1.4;
}
.agents-filter-form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.agents-filter-form .field,
.agents-filter-form .fields {
  margin-bottom: 0 !important;
}
.agents-table-scroll {
  flex: 1;
  overflow: auto;
  padding: 0 !important;
  min-height: 0;
  background: #ffffff;
}
#agentsListTable {
  --agents-col-name-width: 180px;
  --agents-col-conversation-width: 200px;
  --agents-col-role-width: 180px;
  --agents-col-bot-width: 140px;
  --agents-col-runtime-width: 260px;
  --agents-col-active-width: 90px;
  --agents-col-namespace-width: 160px;
  --agents-col-source-width: 180px;
  width: max-content;
  min-width: 100%;
  table-layout: fixed;
}
#agentsListTable thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  white-space: nowrap;
}
#agentsListTable th.agents-col-resizable {
  position: relative;
  padding-right: 0.85rem !important;
}
#agentsListTable .agents-col-resize-handle {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  z-index: 3;
}
#agentsListTable .agents-col-resize-handle::after {
  content: "";
  position: absolute;
  top: 18%;
  bottom: 18%;
  left: 2px;
  width: 2px;
  background: transparent;
  border-radius: 999px;
  transition: background 0.12s ease;
}
#agentsListTable th.agents-col-resizable:hover .agents-col-resize-handle::after,
#agentsListTable .agents-col-resize-handle.active::after {
  background: rgba(59, 130, 246, 0.45);
}
body.agent-col-resizing {
  cursor: col-resize !important;
  user-select: none;
}
#agentsListTable tbody td {
  vertical-align: top;
}
#agentsListTable .agents-col-name {
  width: var(--agents-col-name-width);
  min-width: var(--agents-col-name-width);
  max-width: var(--agents-col-name-width);
}
#agentsListTable .agents-col-conversation {
  width: var(--agents-col-conversation-width);
  min-width: var(--agents-col-conversation-width);
  max-width: var(--agents-col-conversation-width);
}
#agentsListTable .agents-col-role {
  width: var(--agents-col-role-width);
  min-width: var(--agents-col-role-width);
  max-width: var(--agents-col-role-width);
}
#agentsListTable .agents-col-bot {
  width: var(--agents-col-bot-width);
  min-width: var(--agents-col-bot-width);
  max-width: var(--agents-col-bot-width);
}
#agentsListTable .agents-col-runtime {
  width: var(--agents-col-runtime-width);
  min-width: var(--agents-col-runtime-width);
  max-width: var(--agents-col-runtime-width);
}
#agentsListTable .agents-col-active {
  width: var(--agents-col-active-width);
  min-width: var(--agents-col-active-width);
  max-width: var(--agents-col-active-width);
}
#agentsListTable .agents-col-namespace {
  width: var(--agents-col-namespace-width);
  min-width: var(--agents-col-namespace-width);
  max-width: var(--agents-col-namespace-width);
}
#agentsListTable .agents-col-source {
  width: var(--agents-col-source-width);
  min-width: var(--agents-col-source-width);
  max-width: var(--agents-col-source-width);
}
.agents-detail {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  padding: 1rem 1.5rem;
  background:
    radial-gradient(circle at top right, rgba(191, 219, 254, 0.35), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}
.agents-detail-placeholder {
  padding: 2rem;
  color: #999;
}
.agents-detail-content {
  max-width: 58rem;
}
.agents-detail-shell {
  gap: 1rem;
}
.agent-form-hero {
  padding: 1.2rem 1.25rem;
}
.agent-form-hero form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.agent-form-card {
  margin: 0 !important;
}
.agent-form-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.9rem;
  margin-bottom: 0.85rem;
}
.agent-form-card-header .ui.header {
  margin: 0 !important;
}
.agent-form-card-header .conversation-section-copy {
  margin-top: 0.28rem;
}
.agent-inline-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
}
.agent-inline-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.85rem;
  padding: 0.75rem 0.95rem;
  border-radius: 1rem;
  border: 1px solid #dbe4ef;
  background: #ffffff;
  color: #1d4ed8;
  font-weight: 600;
  text-decoration: none;
}
.agent-inline-link:hover {
  border-color: #93c5fd;
  color: #1e40af;
}
.agent-status-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
}
.agent-status-fields .field {
  margin-bottom: 0 !important;
}
.agent-form-actions {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}
.agent-form-save-status {
  min-height: 1.2rem;
  color: #6b7280;
  font-size: 0.95rem;
}
.agent-form-save-status.success {
  color: #0f766e;
}
.agent-form-save-status.error {
  color: #b91c1c;
}
.agents-connections-scroll {
  overflow-x: auto;
  margin-bottom: 1rem;
}

.view-namespaces .agents-detail {
  overflow: hidden;
}

.namespace-detail-content {
  max-width: none;
  height: 100%;
}

.namespace-detail-layout {
  display: flex;
  gap: 1.5rem;
  height: 100%;
  min-height: 0;
  align-items: stretch;
}

.namespace-main-column {
  flex: 0 0 300px;
  width: 300px;
  min-width: 300px;
  max-width: 300px;
  overflow-y: auto;
}

.namespace-form-shell {
  width: 100%;
  max-width: none;
  padding-bottom: 1rem;
}

.namespace-meta-lines {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0 0 1rem;
}

.namespace-meta-line {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid #eceff3;
}

.namespace-meta-label {
  flex: 0 0 4.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b7280;
}

.namespace-meta-value {
  font-size: 0.95rem;
  font-weight: 500;
  color: #111827;
  line-height: 1.45;
  word-break: break-word;
}

.namespace-form-actions {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.namespace-save-status {
  min-height: 1.2rem;
  color: #6b7280;
  font-size: 0.95rem;
}

.namespace-side-panel {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  max-width: none;
  height: 100%;
  overflow: hidden;
}

.namespace-side-panel-inner {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.namespace-relations-empty {
  margin: 0 !important;
  border-radius: 1.25rem !important;
  border: 1px dashed #d4d4d8 !important;
  box-shadow: none !important;
  color: #4b5563 !important;
}

.namespace-side-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.2rem;
}

.namespace-related-card {
  border: 1px solid #e5e7eb;
  border-radius: 1.35rem;
  background: #f8fafc;
  margin-bottom: 0.95rem;
  overflow: hidden;
}

.namespace-related-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.95rem 1rem 0.75rem;
}

.namespace-related-title.ui.header {
  margin: 0;
  font-size: 1rem;
}

.namespace-related-count.ui.label {
  margin: 0;
  border-radius: 999px;
}

.namespace-related-body {
  padding: 0 1rem 1rem;
}

.namespace-related-scroll {
  overflow-x: auto;
}

.namespace-related-table {
  margin: 0 !important;
  background: #fff;
}

.namespace-related-table td.center.aligned,
.namespace-related-table th.center.aligned {
  white-space: nowrap;
}

.entity-filter-form {
  padding: 0.75rem 0.75rem 0.25rem;
  border-bottom: 1px solid #e5e7eb;
  background: #ffffff;
}

.entity-filter-form .fields {
  margin-bottom: 0 !important;
}

.entity-list-table {
  margin: 0 !important;
}

.entity-list-table tbody tr {
  cursor: pointer;
}

.entity-list-table tbody tr.active {
  background: rgba(33, 133, 208, 0.08) !important;
}

.entity-usage-panel {
  margin-top: 1.25rem !important;
  border-radius: 1.35rem !important;
  border: 1px solid #e5e7eb !important;
  background: #f8fafc !important;
  box-shadow: none !important;
}

.entity-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.entity-section-header .ui.header {
  margin: 0 !important;
}

.conversation-detail-shell {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.conversation-summary-card {
  padding: 1rem 1.1rem;
}

.conversation-summary-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.conversation-summary-subtitle {
  color: #6b7280;
  font-size: 0.92rem;
}

.conversation-summary-table {
  margin: 0 !important;
}

.conversation-summary-table tbody td:first-child {
  width: 88px;
  color: #6b7280;
  font-weight: 600;
}

.conversation-section-copy,
.conversation-empty-copy {
  margin: 0.25rem 0 0;
  color: #6b7280;
  font-size: 0.9rem;
}

.conversation-set-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.conversation-set-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.6rem 0.45rem 0.8rem;
  border-radius: 999px;
  border: 1px solid #dbe4ef;
  background: #ffffff;
  font-size: 0.88rem;
  color: #1f2937;
}

.conversation-agent-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.conversation-agent-cards {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.conversation-agent-card {
  border: 1px solid #e5e7eb;
  border-radius: 1.2rem;
  background: #ffffff;
  padding: 0.9rem 1rem;
}

.conversation-agent-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
}

.conversation-agent-card-header .ui.header {
  margin: 0 !important;
}

.conversation-agent-subtitle {
  margin-top: 0.2rem;
  color: #6b7280;
  font-size: 0.88rem;
}

.conversation-agent-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.conversation-agent-card-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem 0.85rem;
  margin-top: 0.8rem;
  color: #374151;
  font-size: 0.9rem;
}

.conversation-agent-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.85rem;
}

.conversation-metadata-table {
  margin: 0 !important;
}

.conversation-metadata-table input[type="text"] {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 0.75rem;
  padding: 0.45rem 0.6rem;
}

@media (max-width: 920px) {
  .conversation-agent-card-header,
  .entity-section-header,
  .conversation-summary-header {
    flex-direction: column;
  }

  .agents-list-header-modern,
  .agent-form-actions,
  .agents-filter-menu-header {
    flex-direction: column;
    align-items: stretch;
  }

  .agent-inline-control {
    grid-template-columns: 1fr;
  }

  .conversation-agent-card-meta {
    grid-template-columns: 1fr;
  }

  .agents-list {
    min-width: 320px;
    width: 360px;
  }

  .agents-filter-menu {
    right: auto;
    left: 0;
    width: min(22rem, calc(100vw - 2rem));
  }
}

.docfields-type-blocks {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.doc-type-block {
  margin: 0 !important;
}

.doc-type-block-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.doc-type-title {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
}

.doc-type-code {
  color: #6b7280;
  font-size: 0.85rem;
  margin-top: 0.15rem;
}

.doc-type-instructions {
  color: #374151;
  font-size: 0.85rem;
  line-height: 1.35;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.6rem;
  white-space: pre-wrap;
}

.doc-type-instructions.empty {
  color: #9ca3af;
}

.doc-type-fields-table {
  margin: 0 !important;
}

.doc-type-fields-table .docfield-id-cell {
  width: 4.5rem;
  color: #6b7280;
}

#docfieldsTypeBlocks .df-row.active td {
  background: #eaf4ff !important;
}

/* Agent row edit mode highlighting */
tr.agent-row-editing {
  background-color: #f8fff8 !important;
}
tr.agent-row-editing td {
  background-color: #f8fff8 !important;
}
/* Compact toggle checkboxes in tables */
.ui.fitted.toggle.checkbox.green-toggle {
  min-height: 1.2rem;
}
.ui.fitted.toggle.checkbox.green-toggle label {
  padding-left: 3rem;
}
/* Light green toggle switches */
.ui.toggle.checkbox.green-toggle input:checked ~ label::before {
  background-color: #a8e6a1 !important;
}
.ui.toggle.checkbox.green-toggle input:checked ~ .box::before,
.ui.toggle.checkbox.green-toggle input:checked ~ label::before {
  background-color: #a8e6a1 !important;
}
.ui.toggle.checkbox.green-toggle input:focus:checked ~ label::before {
  background-color: #8fdc86 !important;
}
/* Edit mode toggle in header */
#agentsEditModeToggle,
#convAgentsEditModeToggle {
  font-size: 0.9em;
}
#agentsEditModeToggle label,
#convAgentsEditModeToggle label {
  font-weight: 600;
  color: #21ba45 !important;
}

/* Chats sidebar: no padding, menu fills area */
.chats-sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
  overflow: hidden;
}

.chats-list-header {
  flex: 0 0 auto;
  margin: 0 !important;
}

.chats-list-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  min-height: 0;
  min-width: 0;
}

.chats-menu {
  border-radius: 0 !important;
  border-left: none !important;
  border-right: none !important;
  margin: 0 !important;
  box-shadow: none !important;
  min-width: 0;
}

.chats-menu .item {
  cursor: pointer;
  min-width: 0;
  overflow: hidden;
}

.chats-menu .item.active {
  font-weight: 600;
}

/* Prevent chat titles from wrapping; truncate with ellipsis instead */
.chats-menu .item > span:nth-child(2) {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.chats-filter-wrap {
  flex: 0 0 auto;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid rgba(34, 36, 38, 0.1);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.chats-filter-wrap .chats-search-input {
  margin: 0;
}

.chats-filter-wrap .chats-bot-select {
  padding: 0.4em 0.6em;
  border: 1px solid rgba(34, 36, 38, 0.15);
  border-radius: 0.28rem;
  font-size: 0.9em;
  background: #fff;
  width: 100%;
}

.chats-messaging .chat-inner.chats-chat-inner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow: hidden;
}

.chats-chat-header {
  flex: 0 0 auto;
  margin: 0 !important;
  border-radius: 0 !important;
}

.chats-chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: #fafafa;
  margin: 0 !important;
  border-radius: 0 !important;
  padding: 1rem 1.25rem !important;
}

.chats-composer {
  flex: 0 0 auto;
  flex-shrink: 0;
  min-height: 5rem;
  margin: 0 !important;
  border-radius: 0 !important;
  overflow: visible;
}

#chatMessages {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  border: none !important;
  box-shadow: none !important;
}

#chatMessages .agent-timeline {
  min-height: 0;
}

#chatMessages .chats-messages-placeholder {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#chatMessages .chats-messages-loading {
  flex: 1;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#conversationDetail {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Cases table: recreated from scratch */
.case-table {
  --case-col-status-width: 120px;
  --case-col-ids-width: 270px;
  --case-col-merchant-name-width: 180px;
  --case-col-operator-name-width: 180px;
  --case-col-assignee-width: 180px;
  --case-col-created-at-width: 180px;
  --case-col-order-status-width: 160px;
  --case-col-order-amount-width: 120px;
  --case-col-merchant-chat-width: 220px;
  --case-col-operator-chat-width: 220px;
  --case-col-title-width: 190px;
  --case-col-labels-width: 240px;
  width: max-content;
  min-width: 100%;
  margin: 0;
  font-size: 0.96rem;
  border-collapse: collapse;
  border-spacing: 0;
  table-layout: fixed;
}

.case-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9fafb;
}

.case-table thead th {
  padding: 0.4rem 0.5rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
  position: relative;
}

.case-table thead th .case-col-header-label {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-table thead th.case-col-draggable {
  cursor: grab;
}

.case-table thead th.case-col-dragging {
  opacity: 0.48;
  cursor: grabbing;
}

.case-table thead th.case-col-drop-before::before,
.case-table thead th.case-col-drop-after::after {
  content: "";
  position: absolute;
  top: 0.28rem;
  bottom: 0.28rem;
  width: 3px;
  background: #2563eb;
  border-radius: 999px;
  z-index: 4;
}

.case-table thead th.case-col-drop-before::before {
  left: -2px;
}

.case-table thead th.case-col-drop-after::after {
  right: -2px;
}

.case-table thead th.case-col-resizable {
  padding-right: 0.8rem;
}

.case-table .case-col-resize-handle {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  z-index: 3;
}

.case-table .case-col-resize-handle::after {
  content: "";
  position: absolute;
  top: 18%;
  bottom: 18%;
  left: 2px;
  width: 2px;
  background: transparent;
  border-radius: 999px;
  transition: background 0.12s ease;
}

.case-table thead th.case-col-resizable:hover .case-col-resize-handle::after,
.case-table .case-col-resize-handle.active::after {
  background: rgba(59, 130, 246, 0.45);
}

body.case-col-resizing {
  cursor: col-resize !important;
  user-select: none;
}

.case-table tbody td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: top;
  font-size: inherit;
}

/* Col 1: Escalated */
.case-table .case-col-escalated {
  width: 2.5rem;
  min-width: 2.5rem;
  text-align: center;
  vertical-align: middle;
}

.case-escalated-list-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #db2828;
  box-shadow: 0 0 0 2px rgba(219, 40, 40, 0.15);
  flex: 0 0 auto;
}

.case-table .case-col-attention {
  width: 2.3rem;
  min-width: 2.3rem;
  max-width: 2.3rem;
  text-align: center;
  vertical-align: middle;
}

.case-attention-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2185d0;
  box-shadow: 0 0 0 2px rgba(33, 133, 208, 0.15);
  flex: 0 0 auto;
}

.case-table .case-col-status {
  width: var(--case-col-status-width);
  min-width: var(--case-col-status-width);
  max-width: var(--case-col-status-width);
}

.case-table .case-col-ids {
  width: var(--case-col-ids-width);
  min-width: var(--case-col-ids-width);
  max-width: var(--case-col-ids-width);
}

.case-table .case-col-merchant-name {
  width: var(--case-col-merchant-name-width);
  min-width: var(--case-col-merchant-name-width);
  max-width: var(--case-col-merchant-name-width);
}

.case-table .case-col-operator-name {
  width: var(--case-col-operator-name-width);
  min-width: var(--case-col-operator-name-width);
  max-width: var(--case-col-operator-name-width);
}

.case-table .case-col-assignee {
  width: var(--case-col-assignee-width);
  min-width: var(--case-col-assignee-width);
  max-width: var(--case-col-assignee-width);
}

.case-table .case-col-created-at {
  width: var(--case-col-created-at-width);
  min-width: var(--case-col-created-at-width);
  max-width: var(--case-col-created-at-width);
}

.case-table .case-col-order-status {
  width: var(--case-col-order-status-width);
  min-width: var(--case-col-order-status-width);
  max-width: var(--case-col-order-status-width);
}

.case-table .case-col-order-amount {
  width: var(--case-col-order-amount-width);
  min-width: var(--case-col-order-amount-width);
  max-width: var(--case-col-order-amount-width);
  text-align: right;
}

/* Merchant/Operator chats */
.case-table .case-col-merchant-chat,
.case-table .case-col-operator-chat {
  width: var(--case-col-merchant-chat-width);
  min-width: var(--case-col-merchant-chat-width);
  max-width: var(--case-col-merchant-chat-width);
}

.case-table .case-col-operator-chat {
  width: var(--case-col-operator-chat-width);
  min-width: var(--case-col-operator-chat-width);
  max-width: var(--case-col-operator-chat-width);
}

.case-table .case-col-labels {
  width: var(--case-col-labels-width);
  min-width: var(--case-col-labels-width);
  max-width: var(--case-col-labels-width);
}

.case-ids-cell {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  line-height: 1.3;
}

.case-id-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.case-id-value {
  font-weight: 600;
  font-size: 0.95em;
}

.case-id-primary-line {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.case-table .order-id-value {
  font-family: inherit;
}

.case-chat-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.case-status-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.case-assignee-cell {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.case-assignee-avatar {
  width: 1.45rem;
  height: 1.45rem;
  min-width: 1.45rem;
  border-radius: 999px;
  background: #9ca3af;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
}

.case-assignee-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.case-order-status-cell,
.case-created-at-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.case-order-amount-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.case-problem-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.case-labels-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.case-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.25rem;
  margin-left: 0.25rem;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  color: #4b5563;
  background: #e5e7eb;
  border-radius: 8px;
  vertical-align: middle;
}

/* Col 5: Title */
.case-table .case-col-title {
  width: var(--case-col-title-width);
  min-width: var(--case-col-title-width);
  max-width: var(--case-col-title-width);
}

.case-table .case-col-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Row states */
.case-table tbody tr.case-row {
  cursor: pointer;
  background: #fff;
}

.case-table tbody tr.case-row.accuracy-success {
  background: #ecfdf3;
}

.case-table tbody tr.case-row.accuracy-fail {
  background: #fff1f0;
}

.case-table tbody tr.case-row.accuracy-flagged {
  background: #fffbeb;
}

#agentsListTable tbody tr.agent-row.active,
#rolesListTable tbody tr.role-row.active {
  background-color: rgba(0, 0, 0, 0.05);
}
.case-table tbody tr.case-row.active {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16), inset 0 0 0 2px rgba(59, 130, 246, 0.8);
}

.case-table tbody tr.case-row.case-row--mode-faded {
  opacity: 0.42;
}

.case-table tbody tr.case-row.needs-attention {
  font-weight: 700;
}

/* Placeholder text */
.case-loading-text {
  color: #6b7280;
}

.case-error-text {
  color: #b91c1c;
  font-size: 0.85rem;
}

/* Chat header stays on top automatically via flex layout */
.chat-header {
  flex: 0 0 auto;
}

.view-cases.is-case-placeholder-layout .chat-header {
  display: none;
}

.chat-header .chat-header-title {
  width: 100% !important;
  display: flex !important;
  align-items: center !important;
}

.chat-header .chat-header-title.fluid {
  flex: 1;
  min-width: 0;
}

.chat-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  min-width: 0;
}

.chat-header-row.is-empty .chat-title-merchant {
  display: none;
}

.chat-header-row .chat-title-merchant {
  flex: 1 1 auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-row .chat-title-merchant .icon {
  flex-shrink: 0;
  margin-right: 0.25rem;
}

.chat-header-row .chat-title-operator {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50%;
}

.case-header-toolbelt {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.case-header-toolbelt .case-escalation-panel {
  margin: 0;
}

.case-escalation-panel {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
}

.ai-markup-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 1.5rem;
  width: 100%;
}

.ai-markup-buttons {
  flex: 0 0 auto;
}

.ai-markup-toggle {
  flex: 0 0 auto;
  margin-left: auto;
  flex-shrink: 0;
}

.case-action-buttons {
  margin: 0 !important;
}

.case-action-buttons .button,
.case-action-buttons .ui.button {
  justify-content: flex-start;
}

.case-panel-grid {
  display: flex;
  flex-wrap: wrap;
}

.case-info-column {
  padding: 0.75rem !important;
  flex: 1 1 auto;
  min-width: 0;
}

.case-fields-column {
  flex: 1 1 auto;
  min-width: 0;
}

.case-actions-column {
  width: 90px;
  min-width: 90px;
  max-width: 90px;
  padding-top: 0 !important;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.case-assignee-display {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.case-chat-buttons-row {
  margin-top: 0.5rem;
  padding: 0 !important;
}

.case-chat-btn {
  text-align: left !important;
}

.case-escalation-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.case-escalation-dot-active {
  background-color: #21ba45; /* green */
}

.case-escalation-dot-disabled {
  background-color: #db2828; /* red */
}

.case-active-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #21ba45;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.case-inactive-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #db2828;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.case-escalated-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #f2c61f;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.case-bot-link {
  color: #2185d0;
  text-decoration: none;
}

.case-bot-link:hover {
  text-decoration: underline;
}

.case-detail-inline-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  min-width: 0;
}

.case-detail-inline-main {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  min-width: 0;
}

.case-attention-action {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  color: #2185d0;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.case-attention-action:hover,
.case-attention-action:focus-visible {
  color: #1678c2;
}

.case-attention-action:focus-visible {
  outline: none;
}

.case-attention-action.is-loading,
.case-attention-action.disabled,
.case-attention-action:disabled {
  cursor: default;
}

.case-attention-action__label {
  white-space: nowrap;
}

.case-attention-action__label--hover {
  display: none;
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

.case-attention-action:hover .case-attention-action__label--default,
.case-attention-action:focus-visible .case-attention-action__label--default {
  display: none;
}

.case-attention-action:hover .case-attention-action__label--hover,
.case-attention-action:focus-visible .case-attention-action__label--hover {
  display: inline;
}

.case-attention-action.is-loading .case-attention-action__label--default,
.case-attention-action.is-loading .case-attention-action__label--hover,
.case-attention-action.disabled .case-attention-action__label--hover,
.case-attention-action:disabled .case-attention-action__label--hover {
  display: none;
}

.case-status-menu-wrap,
.case-message-action-menu-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  justify-content: flex-end;
}

.case-status-menu-trigger,
.case-message-action-menu-trigger {
  display: inline-flex;
  align-items: center;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  box-shadow: none;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.case-status-menu-trigger:focus,
.case-status-menu-trigger:focus-visible,
.case-message-action-menu-trigger:focus,
.case-message-action-menu-trigger:focus-visible {
  outline: none;
  box-shadow: none;
}

.case-status-menu-wrap.loading .case-status-menu-trigger,
.case-status-menu-wrap.disabled .case-status-menu-trigger,
.case-message-action-menu-wrap.loading .case-message-action-menu-trigger,
.case-message-action-menu-wrap.disabled .case-message-action-menu-trigger {
  opacity: 0.6;
  cursor: progress;
  pointer-events: none;
}

.case-status-menu.ui.vertical.menu,
.case-message-action-menu.ui.vertical.menu {
  display: none;
  position: absolute;
  top: calc(100% + 0.45rem);
  left: 0;
  right: auto;
  z-index: 40;
  min-width: 12rem;
  max-width: min(18rem, calc(100vw - 1rem));
  max-height: min(22rem, calc(100vh - 1rem));
  margin: 0 !important;
  border-radius: 0.95rem !important;
  border: 1px solid #d8e1ee !important;
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.14) !important;
  background: rgba(255, 255, 255, 0.98) !important;
  overflow: hidden;
  overflow-y: auto;
  transform-origin: top left;
}

.case-status-menu-wrap.is-open .case-status-menu.ui.vertical.menu {
  display: block;
}

.case-message-action-menu-wrap.is-open .case-message-action-menu.ui.vertical.menu {
  display: block;
}

.case-message-action-menu-wrap.is-open {
  z-index: 80;
}

.case-message-action-menu--floating {
  position: fixed !important;
  right: auto !important;
  z-index: 120 !important;
  transform-origin: top right !important;
}

.case-status-menu.ui.vertical.menu .item,
.case-message-action-menu.ui.vertical.menu .item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 0;
  background: transparent !important;
  box-shadow: none;
  color: #334155 !important;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.case-status-menu.ui.vertical.menu .item:hover,
.case-status-menu.ui.vertical.menu .item:focus-visible,
.case-message-action-menu.ui.vertical.menu .item:hover,
.case-message-action-menu.ui.vertical.menu .item:focus-visible {
  background: #f1f5f9 !important;
  outline: none;
}

.case-status-menu.ui.vertical.menu .item .ui.label {
  margin: 0;
}

.case-message-action-menu-trigger .message-time {
  cursor: pointer;
}

.case-message-action-menu-trigger:hover .message-time,
.case-message-action-menu-trigger:focus .message-time {
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

.case-message-action-menu.ui.vertical.menu .item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.case-detail-inline-main .case-assignee-cell {
  min-width: 0;
}

.case-detail-inline-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-left: auto;
  flex: 0 0 auto;
}

.case-detail-inline-actions .ui.button,
.case-detail-inline-actions .ui.dropdown {
  margin: 0 !important;
}

.case-detail-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  min-width: 0;
}

.case-detail-stack-primary,
.case-detail-stack-secondary {
  display: block;
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.case-detail-stack-primary {
  font-weight: inherit;
}

.case-detail-stack-secondary {
  font-size: inherit;
}

.case-detail-stack-empty {
  color: inherit;
}

.case-assignee-empty {
  color: #9ca3af;
  font-weight: 500;
}

.case-assignee-link {
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  color: #2185d0;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.12em;
  cursor: pointer;
}

.case-assignee-link:hover,
.case-assignee-link:focus-visible {
  color: #1678c2;
}

.case-assignee-link:focus-visible {
  outline: none;
}

.case-ai-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: #21ba45;
  font-weight: 600;
}

.case-ai-status-escalated {
  color: #db2828;
}

.case-ai-status .ui.circular.label {
  padding: 0.4em;
  min-width: 1.8em;
  min-height: 1.8em;
}

.case-ai-status-disabled {
  color: #6b7280;
}

.case-ids-table .agent-enabled-toggle label {
  color: #21ba45 !important;
  font-weight: 600;
}

.case-ai-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.65rem;
  width: 100%;
}

.case-ai-controls {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  overflow-x: auto;
}

.case-ai-indicators {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  overflow-x: auto;
}

.case-ai-control {
  width: 110px;
  margin: 0 !important;
  padding: 0.64rem 0.78rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.95rem;
  background: #ffffff;
  color: #111827;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  justify-content: flex-start;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  flex: 0 0 auto;
  white-space: nowrap;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.case-ai-indicator {
  width: auto;
  margin: 0 !important;
  padding: 0.64rem 0.78rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.95rem;
  background: #ffffff;
  color: #111827;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  justify-content: flex-start;
  font-weight: 600;
  font-size: 0.95rem;
  flex: 0 0 auto;
  white-space: nowrap;
}

.case-ai-control:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.case-ai-control.is-disabled,
.case-ai-control:disabled {
  opacity: 0.7;
  cursor: default;
}

.case-ai-control-dot {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 999px;
  flex: 0 0 auto;
}

.case-ai-control-dot--green {
  background: #21ba45;
}

.case-ai-control-dot--yellow {
  background: #f2c037;
}

.case-ai-control-dot--red {
  background: #db2828;
}

.case-ai-control-label {
  min-width: 0;
  text-align: left;
  line-height: 1.2;
}

.case-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.case-detail-actions .ui.button {
  margin: 0 !important;
}

.case-quality-actions {
  margin-top: 0;
  flex-wrap: nowrap;
}

.case-quality-actions .ui.button {
  padding: 0.55em 0.9em;
}

.case-quality-actions .case-markup-action.ui.button {
  margin: 0 !important;
  white-space: nowrap;
}

.case-quality-actions .case-markup-action--good.is-active.ui.button {
  background: #ecfdf3 !important;
  border-color: #86efac !important;
  color: #15803d !important;
}

.case-quality-actions .case-markup-action--fail.is-active.ui.button {
  background: #fef2f2 !important;
  border-color: #fca5a5 !important;
  color: #b91c1c !important;
}

.case-quality-segment {
  margin: 0 !important;
  padding: 0.55rem 0.7rem !important;
}

.case-quality-inline-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.case-quality-accuracy {
  white-space: nowrap;
  font-weight: 600;
}

.case-quality-problem-type {
  white-space: nowrap;
  color: #4b5563;
  font-weight: 500;
}

.case-quality-segment.case-quality-good {
  background: #ecfdf3 !important;
  border-color: #86efac !important;
}

.case-quality-segment.case-quality-bad {
  background: #fef2f2 !important;
  border-color: #fca5a5 !important;
}

.case-validation-ok {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: #21ba45;
  font-weight: 600;
}

.case-priority-high {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: #b91c1c;
  font-weight: 600;
}

.case-priority-high .flag.icon {
  color: #dc2626;
}

.case-ids-table tr.warning td,
.case-ids-table tr.case-status-row--orange td {
  background-color: #fff8dc !important;
}

.case-ids-table tr.case-status-row--blue td {
  background-color: #eef6ff !important;
}

.case-ids-table tr.case-status-row--green td {
  background-color: #effaf1 !important;
}

.case-ids-table tr.case-status-row--red td {
  background-color: #fef2f2 !important;
}

.case-ids-table tr.case-status-row--grey td,
.case-ids-table tr.case-status-row--gray td {
  background-color: #f3f4f6 !important;
}

.case-escalation-label {
  color: #555;
}

.case-escalation-cell {
  text-align: center;
  width: 32px;
}

.case-escalated-icon {
  font-size: 14px;
  line-height: 1;
}

.chat-header-title .case-details {
  color: #666;
  font-weight: normal;
  margin-top: 0.15rem;
  min-width: 300px;
}

.case-ids-table tbody td:first-child {
  font-weight: 600;
  width: 100px;
  min-width: 100px;
  max-width: 100px;
}

.case-comment-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.case-merchant-id-missing-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.case-merchant-id-missing-wrap .set-merchant-order-id-btn.ui.button {
  margin: 0 !important;
}

.case-fields-table tbody td:first-child {
  font-weight: 600;
  width: 80px;
  min-width: 80px;
  max-width: 80px;
}

.case-ids-table,
.case-fields-table {
  font-size: 1.1rem;
  table-layout: fixed;
}

.case-order-ids {
  margin-top: 0.2rem;
}

.case-order-id-line {
  margin-bottom: 0.15rem;
}

.case-order-id-line:last-child {
  margin-bottom: 0;
}

.case-order-id-label {
  font-weight: 600;
  color: #374151;
  margin-right: 0.25rem;
}

.case-order-id-value {
  font-weight: 600;
  font-size: 0.85rem;
}

.copy-on-click {
  cursor: pointer;
}

.copy-on-click:hover {
  text-decoration: underline;
}

.copy-feedback-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(2rem);
  padding: 0.4rem 0.75rem;
  background: #1f2937;
  color: #f9fafb;
  border-radius: 4px;
  font-size: 0.8rem;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.copy-feedback-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}


/* Case thread shell */
.chat-thread-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  padding: 0 !important;
  border: none !important;
  background: #ffffff;
  border-radius: 0 0 1.75rem 1.75rem !important;
  overflow: hidden;
}

/* Chat messages scroll */
.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: transparent;
  padding: 1rem 1.25rem 0.85rem !important;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.chat-messages.is-empty {
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  overflow: hidden;
  padding: 1.5rem !important;
}

.chat-messages::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.case-empty-state.ui.placeholder.segment {
  width: 100%;
  margin: 0;
}

.chat-messages .case-empty-state.ui.placeholder.segment {
  flex: 1 1 auto;
  min-height: 100%;
  max-width: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 1.75rem;
  padding: 2rem;
}

.view-cases.is-case-placeholder-layout .chat-thread-shell {
  border-radius: 1.75rem !important;
}

/* Composer pinned bottom - ensure always visible */
.chat-composer {
  flex: 0 0 auto;
  min-height: 0;
  position: relative;
  padding: 0.65rem 0.85rem 0.85rem;
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  align-items: stretch;
}

.chat-composer-panel,
.case-accuracy-panel {
  min-width: 460px;
}

.chat-composer-panel {
  position: relative;
  border: 1px solid #e5e7eb;
  border-radius: 1.75rem;
  background: #ffffff;
  padding: 0.85rem 1rem 0.8rem;
  gap: 0.65rem;
  display: flex;
  flex-direction: column;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.chat-composer-panel.is-drop-target {
  border-color: #cbd5e1;
  background: #f8fafc;
  box-shadow: inset 0 0 0 1px rgba(203, 213, 225, 0.8);
}

.chat-composer-panel.is-drop-target::after {
  content: "Drop files to upload";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed #cbd5e1;
  border-radius: 1.75rem;
  color: #6b7280;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: rgba(248, 250, 252, 0.72);
  pointer-events: none;
}

.chat-composer-input-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.chat-composer-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
}

.chat-composer-left,
.chat-composer-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-composer-selected-files {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding-top: 0.15rem;
}

.chat-composer-selected-files:empty {
  display: none;
}

.case-accuracy-panel {
  display: none;
  border: 1px solid #e5e7eb;
  border-radius: 1.75rem;
  background: #ffffff;
  padding: 0.85rem 1rem 0.8rem;
  margin: 0 0.85rem 0.85rem;
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.case-accuracy-panel.is-good {
  background: #ecfdf3;
  border-color: #bbf7d0;
}

.case-accuracy-panel.is-bad {
  background: #fef2f270;
  border-color: #fecaca;
}

.case-accuracy-panel-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  min-width: 0;
}

.case-accuracy-bad-flow {
  display: none;
  align-items: center;
  gap: 0.65rem;
  flex: 1 1 20rem;
  min-width: 0;
}

.case-accuracy-bad-flow.is-visible {
  display: flex;
}

.case-accuracy-problem-dropdown.ui.dropdown {
  min-width: 16rem;
  flex: 1 1 16rem;
}

.case-accuracy-submit-btn.ui.button {
  margin: 0 !important;
  min-height: 2.85rem;
  padding: 0.78rem 1rem !important;
  border-radius: 999px !important;
  border: 1px solid transparent !important;
  background: transparent !important;
  box-shadow: none !important;
  color: #4b5563 !important;
  font-weight: 600;
}

.case-accuracy-submit-btn.ui.button:hover,
.case-accuracy-submit-btn.ui.button:focus {
  background: #f3f4f6 !important;
  border-color: #d1d5db !important;
}

.case-accuracy-submit-btn.ui.button.loading,
.case-accuracy-submit-btn.ui.button.disabled,
.case-accuracy-submit-btn.ui.button:disabled {
  opacity: 0.55 !important;
  cursor: not-allowed !important;
}

.case-composer-upload-input {
  display: none;
}

.case-composer-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  max-width: 100%;
  padding: 0.28rem 0.4rem 0.28rem 0.4rem;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  color: #111827;
  font-size: 0.88rem;
  line-height: 1.2;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.case-composer-file-chip.is-neutral {
  background: #ffffff;
  border-color: #e5e7eb;
}

.case-composer-file-chip.is-partially-matched {
  background: #fef9c3;
  border-color: #fcd34d;
}

.case-composer-file-chip.is-fully-matched {
  background: #ecfdf3;
  border-color: #86efac;
}

.case-composer-file-chip.is-busy {
  opacity: 0.68;
}

.case-composer-file-chip-trigger {
  border: none;
  background: transparent;
  color: inherit;
  padding: 0.15rem 0.2rem 0.15rem 0;
  margin: 0;
  min-width: 0;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  cursor: pointer;
  text-align: left;
}

.case-composer-file-chip-trigger.is-static {
  cursor: default;
}

.case-composer-file-chip-trigger:not(.is-static):hover .case-composer-file-chip-label,
.case-composer-file-chip-trigger:not(.is-static):focus .case-composer-file-chip-label {
  text-decoration: underline;
}

.case-composer-file-chip-trigger:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.28);
  outline-offset: 2px;
}

.case-composer-file-chip-icon {
  width: 1.65rem;
  height: 1.65rem;
  min-width: 1.65rem;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #eef2f7;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
}

.case-composer-file-chip-icon .icon {
  margin: 0 !important;
  font-size: 0.8rem;
}

.case-composer-file-chip-copy {
  min-width: 0;
  display: inline-flex;
  flex-direction: column;
  gap: 0.08rem;
}

.case-composer-file-chip-label {
  min-width: 0;
  max-width: 15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.case-composer-file-chip-status {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.72rem;
  color: #6b7280;
}

.case-composer-file-chip.is-partially-matched .case-composer-file-chip-status {
  color: #92400e;
}

.case-composer-file-chip.is-fully-matched .case-composer-file-chip-status {
  color: #166534;
}

.case-composer-file-chip-remove {
  border: none;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  padding: 0;
  width: 1.25rem;
  height: 1.25rem;
  min-width: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border-radius: 999px;
}

.case-composer-file-chip-remove:hover {
  color: #111827;
  background: #f3f4f6;
}

.case-composer-file-chip-remove .icon {
  margin: 0 !important;
  font-size: 0.8rem;
}

#msgInput {
  width: 100%;
  min-height: 4.8rem;
  max-height: 10rem;
  resize: none;
  border: none;
  outline: none;
  box-shadow: none;
  background: transparent;
  color: #111827;
  font: inherit;
  font-size: 1.05rem;
  line-height: 1.45;
  padding: 0.15rem 0.1rem;
  overflow-y: auto;
}

#msgInput::placeholder {
  color: #b5aca1;
}

.case-attachment-picker {
  position: relative;
}

.case-attachment-toggle.ui.button,
.case-dictation-btn.ui.button,
.case-scroll-down-btn.ui.button,
.case-send-btn.ui.button,
.case-send-btn.ui.primary.button {
  width: 2.85rem;
  height: 2.85rem;
  min-width: 2.85rem;
  min-height: 2.85rem;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 999px !important;
  border: 1px solid transparent !important;
  background: transparent !important;
  color: #6b7280 !important;
  box-shadow: none !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  outline: none !important;
}

.case-attachment-toggle.ui.button:hover,
.case-attachment-toggle.ui.button:focus,
.case-dictation-btn.ui.button:hover:not(:disabled),
.case-dictation-btn.ui.button:focus:not(:disabled),
.case-scroll-down-btn.ui.button:hover,
.case-scroll-down-btn.ui.button:focus,
.case-send-btn.ui.button:hover:not(:disabled),
.case-send-btn.ui.button:focus:not(:disabled),
.case-send-btn.ui.primary.button:hover:not(:disabled),
.case-send-btn.ui.primary.button:focus:not(:disabled) {
  background: #f3f4f6 !important;
  border-color: #d1d5db !important;
  color: #374151 !important;
}

.case-attachment-toggle.ui.button.is-active {
  background: #f3f4f6 !important;
  border-color: #d1d5db !important;
  color: #374151 !important;
}

.case-dictation-btn.ui.button.disabled,
.case-dictation-btn.ui.button:disabled {
  opacity: 0.45 !important;
  cursor: not-allowed !important;
}

.case-attachment-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 0.6rem);
  width: 19rem;
  max-height: 17rem;
  overflow-y: auto;
  display: none;
  padding: 0.35rem;
  border-radius: 1rem;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.14);
  z-index: 15;
}

.case-attachment-picker.menu-open .case-attachment-menu {
  display: block;
}

.case-attachment-menu-empty {
  padding: 0.7rem 0.85rem;
  color: #8c8174;
  font-size: 0.9rem;
}

.case-attachment-menu-divider {
  height: 1px;
  margin: 0.35rem 0;
  background: #e5e7eb;
}

.case-attachment-item {
  width: 100%;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.7rem 0.75rem;
  border-radius: 0.85rem;
  cursor: pointer;
  text-align: left;
  color: #2f2a24;
}

.case-attachment-item:hover {
  background: #f3f4f6;
}

.case-attachment-item.is-selected {
  background: #eef2f7;
}

.case-attachment-item.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.case-attachment-item.is-disabled:hover {
  background: transparent;
}

.case-attachment-item-main {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.case-attachment-item-text {
  min-width: 0;
}

.case-attachment-item-label,
.case-attachment-item-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-attachment-item-label {
  font-weight: 600;
}

.case-attachment-item-meta {
  font-size: 0.78rem;
  color: #8a8177;
  margin-top: 0.15rem;
}

.case-attachment-item-check {
  flex: 0 0 auto;
  color: #8a8177;
}

.case-attachment-upload-item .case-attachment-item-label {
  font-weight: 700;
}

.case-attachment-upload-item .case-attachment-item-meta {
  color: #6b7280;
}

.case-attachment-item.is-selected .case-attachment-item-check {
  color: #4b5563;
}

.case-accuracy-dropdown.ui.button,
.case-target-dropdown.ui.dropdown {
  min-height: 2.85rem;
  margin: 0 !important;
  border-radius: 999px !important;
  border: 1px solid transparent !important;
  background: transparent !important;
  box-shadow: none !important;
  color: #4b5563 !important;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  outline: none !important;
}

.case-accuracy-dropdown.ui.button {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  padding: 0.78rem 1rem !important;
}

.case-accuracy-dropdown.ui.button > .text {
  font-weight: 600;
  white-space: nowrap;
}

.case-accuracy-dropdown.ui.button .dropdown.icon {
  position: static !important;
  top: auto !important;
  right: auto !important;
  transform: none !important;
  margin: 0 0 0 0.4rem !important;
  line-height: 1 !important;
}

.case-accuracy-dropdown.is-neutral {
  color: #6b7280 !important;
}

.case-accuracy-dropdown.is-good {
  color: #15803d !important;
}

.case-accuracy-dropdown.is-bad {
  color: #b91c1c !important;
}

.case-accuracy-dropdown.is-pending {
  color: #b91c1c !important;
}

.case-accuracy-option {
  font-weight: 600;
}

.case-accuracy-option-good {
  color: #15803d;
}

.case-accuracy-option-neutral {
  color: #6b7280;
}

.case-accuracy-option-bad {
  color: #b91c1c;
}

.case-target-dropdown.ui.dropdown {
  min-width: 9.75rem;
  padding: 0.78rem 1rem !important;
}

.case-accuracy-dropdown.ui.button:hover,
.case-accuracy-dropdown.ui.button:focus,
.case-target-dropdown.ui.dropdown:hover,
.case-target-dropdown.ui.dropdown:focus,
.case-target-dropdown.ui.dropdown.active,
.case-target-dropdown.ui.dropdown.visible,
.case-accuracy-dropdown.ui.button.active,
.case-accuracy-dropdown.ui.button.visible {
  background: #f3f4f6 !important;
  border-color: #d1d5db !important;
}

.case-target-dropdown.ui.dropdown > .text {
  font-weight: 600;
  white-space: nowrap;
}

.case-accuracy-panel .case-accuracy-dropdown.ui.button {
  flex: 0 0 auto;
}

.case-target-dropdown.ui.dropdown > .dropdown.icon {
  position: static !important;
  top: auto !important;
  right: auto !important;
  transform: none !important;
  margin: 0 0 0 0.4rem !important;
  line-height: 1 !important;
}

.case-send-btn.ui.button {
  position: relative;
  overflow: visible !important;
  color: #6b7280 !important;
}

.case-send-btn.ui.button:disabled {
  opacity: 0.45 !important;
  cursor: not-allowed !important;
}

.case-send-btn-ring {
  position: absolute;
  inset: -0.18rem;
  width: calc(100% + 0.36rem);
  height: calc(100% + 0.36rem);
  pointer-events: none;
  transform: rotate(-90deg);
  opacity: 0;
  transition: opacity 0.12s ease;
}

.case-send-btn-ring-track,
.case-send-btn-ring-progress {
  fill: none;
  stroke-width: 3;
}

.case-send-btn-ring-track {
  stroke: rgba(209, 213, 219, 0.4);
}

.case-send-btn-ring-progress {
  stroke: #6b7280;
  stroke-linecap: round;
  stroke-dasharray: 119.38;
  stroke-dashoffset: var(--case-send-ring-offset, 119.38);
}

.case-send-btn.is-countdown {
  background: #f3f4f6 !important;
  border-color: #d1d5db !important;
  color: #374151 !important;
}

.case-send-btn.is-countdown .case-send-btn-ring {
  opacity: 1;
}

.case-message-delete-btn.ui.button {
  background: #fff1f2 !important;
  border-color: #fecdd3 !important;
  color: #be123c !important;
}

.case-message-delete-btn.ui.button:hover:not(:disabled),
.case-message-delete-btn.ui.button:focus:not(:disabled) {
  background: #ffe4e6 !important;
  border-color: #fda4af !important;
  color: #9f1239 !important;
}

.case-message-delete-btn.ui.button .case-send-btn-ring-track {
  stroke: rgba(244, 63, 94, 0.18);
}

.case-message-delete-btn.ui.button .case-send-btn-ring-progress {
  stroke: #e11d48;
}

.case-send-btn.ui.button .icon,
.case-dictation-btn.ui.button .icon,
.case-attachment-toggle.ui.button .icon,
.case-scroll-down-btn.ui.button .icon {
  margin: 0 !important;
  position: relative;
  z-index: 1;
}

.case-scroll-down-btn {
  position: absolute !important;
  right: 0.9rem;
  top: -3.15rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.4rem);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 4;
}

.case-scroll-down-btn.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Timeline layout: one message per row, placed by role */
.agent-timeline {
  width: 100%;
}

.agent-timeline-head,
.timeline-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  overflow: visible;
}

.timeline-cell {
  display: flex;
  overflow: visible;
}

.agent-timeline-body {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  overflow: visible;
}

.role-agentA-cell {
  justify-content: flex-start;
}

.role-agentB-cell {
  justify-content: center;
  align-items: center;
}

.role-agentC-cell {
  justify-content: flex-end;
}

.message-card {
  width: 360px !important;
  min-width: 360px;
  max-width: 360px !important;
  margin: 0 !important;
  flex: 0 0 360px;
  position: relative;
  border-radius: 14px !important;
  border: 1px solid #dfe7f1 !important;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06) !important;
  overflow: visible;
  z-index: 1;
}

.message-card > .content {
  display: flex;
  flex-direction: column;
  padding: 0.8rem 0.95rem !important;
  overflow: visible;
}

.message-card.message-card--case-file > .content {
  padding: 0.72rem 0.8rem 0.78rem !important;
}

.role-agentA {
  border-top: 3px solid #3b82f6;
}

.role-agentB {
  border-top: 3px solid #16a34a;
}

.message-card.role-agentB.center-supervisor {
  border-top: 3px solid #f2711c;
  border-left: 3px solid #f2711c;
  background-color: #fff4ea;
}

.message-card.role-agentB.center-own {
  border-top: 3px solid #fbbd08;
  border-left: 3px solid #fbbd08;
  background-color: #ffffff;
}

.role-agentC {
  border-top: 3px solid #f59e0b;
}

.message-card.role-assistant {
  background-color: #eff6ff;
  border-left: 3px solid #3b82f6;
}

.message-card.message-card--tg-declined,
.message-card.message-card--tg-deleted {
  background-color: #f8fafc !important;
  border-color: #dbe4ee !important;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04) !important;
}

.message-card.message-card--tg-declined.role-assistant,
.message-card.message-card--tg-deleted.role-assistant {
  background-color: #f8fafc !important;
  border-top: 3px solid #cbd5e1 !important;
  border-left: 3px solid #cbd5e1 !important;
}

.message-card.message-card--editing {
  box-shadow: 0 10px 26px rgba(59, 130, 246, 0.16) !important;
}

.message-card.team-octo {
  background-color: #dcfce7 !important;
  border-left: 4px solid #16a34a !important;
  color: #14532d;
}

.message-card .header {
  display: block;
  font-size: 0.7rem;
  line-height: 1.25;
}

.message-card .message-author {
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: #111827;
  white-space: normal;
  overflow-wrap: anywhere;
}

.message-card .message-author-by {
  margin-left: 0.35rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: #6b7280;
}

.system-line {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.25rem 0.5rem;
  width: 100%;
  min-width: 500px;
  max-width: 550px;
  text-align: center;
  color: #727272;
  font-weight: 600;
  font-size: 0.84rem;
  line-height: 1.35;
  padding: 0.18rem 0.2rem;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.system-line .system-line-label {
  font-weight: 700;
  color: #727272;
}

.system-line .system-line-time {
  color: #727272;
  font-weight: 500;
}

.system-line.toolcall-system-line {
  cursor: pointer;
  text-decoration: none;
}

.system-line.toolcall-system-line:hover,
.system-line.toolcall-system-line:focus {
  color: #727272;
}

.reaction-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.45rem;
  width: 360px;
  min-width: 360px;
  max-width: 360px;
  color: #64748b;
  font-weight: 600;
  font-size: 0.82rem;
  line-height: 1.35;
  padding: 0.18rem 0.2rem;
  white-space: normal;
  overflow-wrap: anywhere;
  border-radius: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.reaction-line-controls {
  flex: 0 0 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.reaction-line--right .reaction-line-controls {
  justify-content: flex-end;
}

.reaction-line .message-moderation-actions {
  margin-top: 0.3rem;
}

.reaction-line--left .message-moderation-actions {
  justify-content: flex-start;
}

.reaction-line--center .message-moderation-actions {
  justify-content: center;
}

.reaction-line--right .message-moderation-actions {
  justify-content: flex-end;
}

.reaction-line--left {
  text-align: left;
  justify-content: flex-start;
}

.reaction-line--center {
  text-align: center;
  justify-content: center;
}

.reaction-line--right {
  text-align: right;
  justify-content: flex-end;
}

.reaction-line .reaction-line-author {
  font-weight: 700;
  color: #475569;
}

.reaction-line .reaction-line-by {
  color: #64748b;
}

.reaction-line .reaction-line-action {
  color: #b45309;
  font-weight: 700;
  text-transform: lowercase;
}

.reaction-line .reaction-line-emoji {
  font-size: 1rem;
  line-height: 1;
}

.reaction-line.reaction-line--remove {
  color: #9a3412;
}

.reaction-line.reaction-line--remove .reaction-line-author,
.reaction-line.reaction-line--remove .reaction-line-time,
.reaction-line.reaction-line--remove .reaction-line-by {
  color: #9a3412;
}

.reaction-line.reaction-line--tg-declined,
.reaction-line.reaction-line--tg-deleted {
  color: #94a3b8;
  background-color: #f8fafc;
  border: 1px solid #dbe4ee;
  border-left: 3px solid #cbd5e1;
  border-radius: 14px;
  padding: 0.45rem 0.6rem;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.03);
}

.reaction-line.reaction-line--tg-declined .reaction-line-author,
.reaction-line.reaction-line--tg-declined .reaction-line-time,
.reaction-line.reaction-line--tg-deleted .reaction-line-author,
.reaction-line.reaction-line--tg-deleted .reaction-line-time {
  color: #94a3b8;
}

.reaction-line.reaction-line--tg-declined .reaction-line-emoji,
.reaction-line.reaction-line--tg-deleted .reaction-line-emoji {
  opacity: 0.55;
}

.reaction-line .reaction-line-delivery-mark {
  color: #94a3b8;
  font-weight: 700;
  letter-spacing: -0.06em;
}

.message-card .description p {
  margin: 0.35rem 0 0;
  white-space: pre-wrap;
  font-size: 0.96rem;
  line-height: 1.45;
  color: #334155;
}

.message-card .description p:empty {
  display: none;
}

.message-card.message-card--tg-declined .message-author,
.message-card.message-card--tg-deleted .message-author {
  color: #475569;
}

.message-card.message-card--tg-declined .message-author-by,
.message-card.message-card--tg-declined .message-time,
.message-card.message-card--tg-declined .message-chat-badge,
.message-card.message-card--tg-deleted .message-author-by,
.message-card.message-card--tg-deleted .message-time,
.message-card.message-card--tg-deleted .message-chat-badge {
  color: #94a3b8;
}

.message-card.message-card--tg-declined .message-chat-badge,
.message-card.message-card--tg-deleted .message-chat-badge {
  background-color: #f1f5f9;
  border-color: #dbe4ee;
}

.message-card.message-card--tg-declined .description p,
.message-card.message-card--tg-deleted .description p {
  color: #64748b;
}

.message-card.message-card--tg-declined .message-attachments,
.message-card.message-card--tg-declined .message-user-prompt-menu,
.message-card.message-card--tg-deleted .message-attachments,
.message-card.message-card--tg-deleted .message-user-prompt-menu {
  opacity: 0.72;
}

.message-card-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.45rem;
}

.message-card-footer-left {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.message-card-footer-right {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  flex: 0 0 auto;
  position: relative;
  overflow: visible;
}

.message-time-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
}

.message-status-label {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.01em;
}

.message-status-label--declined {
  flex: 0 0 100%;
  margin-top: 0.15rem;
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.message-status-label--deleted {
  flex: 0 0 100%;
  margin-top: 0.15rem;
  background-color: #f8fafc;
  border: 1px solid #dbe4ee;
  color: #475569;
}

.message-status-label--edited {
  background-color: #f8fafc;
  border: 1px solid #dbe4ee;
  color: #64748b;
}

.case-message-edit-shell {
  margin-top: 0.45rem;
}

.case-message-edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.case-message-edit-textarea {
  width: 100%;
  min-height: 5.5rem;
  resize: vertical;
  padding: 0.75rem 0.85rem;
  border-radius: 0.95rem;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #0f172a;
  font: inherit;
  line-height: 1.45;
  outline: none;
}

.case-message-edit-textarea:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(147, 197, 253, 0.22);
}

.case-message-edit-textarea:disabled {
  background: #f8fafc;
  color: #64748b;
}

.case-message-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.case-message-edit-attachments-section {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.case-message-edit-attachment-controls {
  display: flex;
  justify-content: flex-start;
}

.case-message-edit-attach-btn.ui.button.is-active {
  background: #f3f4f6 !important;
  border-color: #d1d5db !important;
  color: #374151 !important;
}

.case-message-edit-attachment-picker {
  position: relative;
}

.case-message-edit-attachment-menu {
  display: none;
  width: 100%;
  max-height: 17rem;
  overflow-y: auto;
  padding: 0.35rem;
  border-radius: 1rem;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.1);
}

.case-message-edit-attachment-picker.menu-open .case-message-edit-attachment-menu {
  display: block;
}

.case-message-edit-selected-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.case-message-edit-note {
  padding: 0.7rem 0.85rem;
  border-radius: 0.9rem;
  background: #f8fafc;
  border: 1px solid #dbe4ee;
  color: #64748b;
  font-size: 0.9rem;
}

.message-moderation-actions {
  margin-top: 0.7rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.message-moderation-actions .ui.button {
  margin: 0 !important;
}

.message-attachments {
  margin-top: 0.45rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.message-attachments.message-attachments--case-file {
  margin-top: 0.5rem;
}

.message-attachments .attachment-case-file {
  flex: 1 1 100%;
  min-width: 0;
}

.message-attachments .case-file-card {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 0.86rem 0.88rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.82);
  border-color: #d8e1ee;
  box-shadow: none;
}

.message-attachments .case-file-card.is-clickable:hover {
  transform: none;
  box-shadow: none;
  border-color: #cbd5e1;
}

.message-attachments .case-file-card .case-file-card-head {
  gap: 0.9rem;
}

.message-attachments .case-file-card .case-file-card-main {
  gap: 0.78rem;
}

.message-attachments .case-file-card .case-file-card-preview {
  width: 3.15rem;
  height: 3.15rem;
  border-radius: 0.98rem;
}

.message-attachments .case-file-card .case-file-preview-icon {
  font-size: 1.45rem;
}

.message-attachments .case-file-card .case-file-card-title {
  font-size: 0.9rem;
  line-height: 1.22;
}

.message-attachments .case-file-card .case-file-card-meta {
  margin-top: 0.12rem;
  font-size: 0.78rem;
}

.message-attachments .case-file-card .case-file-card-side {
  gap: 0.4rem;
}

.message-attachments .case-file-card .case-file-status-label {
  font-size: 0.82rem;
  gap: 0.25rem;
}

.message-attachments .case-file-card .case-file-status-actor {
  font-size: 0.72rem;
}

.message-attachments .case-file-card .case-fields-table {
  margin-top: 0.72rem;
  font-size: 0.82rem;
}

.message-attachments .case-file-card .case-fields-table.definition.table tbody td {
  padding: 0.38em 0.55em;
}

.message-attachments .case-file-card .case-fields-table tbody td:first-child {
  width: 76px;
  min-width: 76px;
  max-width: 76px;
}

.message-attachments .case-file-card .case-fields-table tbody tr.match-full {
  background-color: rgba(33, 186, 69, 0.15) !important;
}

.message-attachments .case-file-card .case-fields-table tbody tr.match-threshold {
  background-color: rgba(251, 189, 8, 0.25) !important;
}

.message-attachments .case-file-card .case-fields-table tbody tr.match-none {
  background-color: rgba(219, 40, 40, 0.15) !important;
}

.message-attachments .case-file-card .case-file-card-actions {
  justify-content: flex-end;
}

.message-attachments .case-file-card .case-file-action-button {
  padding: 0.42rem 0.68rem;
  font-size: 0.78rem;
}

@media (max-width: 767px) {
  .message-card,
  .reaction-line {
    width: min(360px, calc(100vw - 2.5rem)) !important;
    min-width: 0;
    max-width: min(360px, calc(100vw - 2.5rem)) !important;
    flex-basis: auto;
  }
}

.message-attachments .attachment-card {
  margin: 0 !important;
  border-radius: 12px !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: none !important;
  overflow: hidden;
}

.message-attachments .attachment-image {
  width: min(144px, 100%) !important;
  max-width: 144px !important;
}

.message-attachments .attachment-file {
  width: auto !important;
  max-width: 100% !important;
}

.message-attachments .attachment-file .content {
  padding: 0.55rem 0.7rem !important;
  background: #f8fafc;
}

.message-attachments .attachment-image .attachment-image-shell {
  width: 100%;
  max-width: 100%;
  background: #f8fafc;
  display: block;
  padding: 0.25rem;
}

.message-attachments .attachment-image .attachment-image-trigger {
  width: 100%;
  display: flex;
}

.message-attachments .attachment-image .attachment-image-frame {
  position: relative;
  width: 100%;
  height: 112px;
  min-height: 112px;
  max-height: 112px;
  overflow: hidden;
  border-radius: 10px;
  background: #ffffff;
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.message-attachments .attachment-image .attachment-image-placeholder {
  position: absolute !important;
  inset: 0;
  margin: 0 !important;
  border-radius: 10px !important;
  overflow: hidden;
  pointer-events: none;
}

.message-attachments .attachment-image .attachment-image-placeholder .image {
  height: 100%;
  width: 100%;
}

.message-attachments .attachment-image .attachment-image-placeholder .image::before {
  width: 100%;
  height: 100%;
  padding-top: 0 !important;
}

.message-attachments .attachment-image .attachment-image-element {
  width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
  object-fit: contain;
  display: block;
  border-radius: 10px;
  opacity: 0;
  transition: opacity 0.16s ease;
  position: relative;
  z-index: 1;
}

.message-attachments .attachment-image .attachment-image-frame.is-loaded .attachment-image-element,
.message-attachments .attachment-image .attachment-image-frame.is-error .attachment-image-element {
  opacity: 1;
}

.message-attachments .attachment-image .attachment-image-frame.is-loaded .attachment-image-placeholder,
.message-attachments .attachment-image .attachment-image-frame.is-error .attachment-image-placeholder {
  display: none;
}

.message-attachments .attachment-preview-trigger {
  display: block;
  cursor: zoom-in;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.message-attachments .attachment-file .content .attachment-preview-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  font-size: 0.86rem;
  color: #334155;
  text-decoration: none;
}

.message-attachments .attachment-file .content .attachment-preview-trigger:hover,
.message-attachments .attachment-file .content .attachment-preview-trigger:focus {
  color: #1d4ed8;
}

.message-user-prompt-menu.ui.vertical.menu {
  width: 100%;
  margin: 0.7rem 0 0 !important;
  border-radius: 0.95rem !important;
  border: 1px solid #d8e1ee !important;
  box-shadow: none !important;
  background: rgba(248, 250, 252, 0.96) !important;
}

.message-user-prompt-menu.ui.vertical.menu .item {
  font-size: 0.9rem;
  line-height: 1.35;
  color: #334155 !important;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.message-user-prompt-menu.ui.vertical.menu .item.active {
  background: #eef6ff !important;
  color: #1d4ed8 !important;
  font-weight: 700;
}

.message-user-prompt-menu.ui.vertical.menu .item.disabled,
.message-user-prompt-menu.ui.vertical.menu .item.is-loading {
  opacity: 0.58;
  pointer-events: none;
  cursor: default;
}

.message-user-prompt-menu.ui.vertical.menu .item:hover {
  background: #f1f5f9 !important;
}

.message-reactions {
  margin-top: 0.45rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.message-card-footer .message-reactions {
  margin-top: 0;
}

.message-chat-badge {
  text-align: left;
}

.message-chat-link {
  display: inline-flex;
  align-items: flex-end;
  justify-content: flex-start;
}

.message-reactions .reaction-emoji-h3 {
  cursor: default;
}

.message-reactions .reaction-emoji-h3.message-reaction-chip--interactive {
  cursor: pointer;
}

.message-reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(241, 245, 249, 0.96));
  border: 1px solid #c7d7ea;
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.12);
}

.message-reaction-chip:hover,
.message-reaction-chip:focus {
  border-color: #93c5fd;
}

.message-reaction-chip--interactive {
  cursor: pointer;
}

.message-reaction-chip--pending-add,
.message-reaction-chip--pending-remove {
  opacity: 0.3;
  box-shadow: none;
}

.message-reaction-chip--pending-add {
  color: inherit;
}

.message-reaction-chip--pending-remove {
  color: inherit;
}

.message-reaction-chip-emoji {
  font-size: 1rem;
  line-height: 1;
}

.message-reaction-chip-count {
  font-size: 0.75rem;
  line-height: 1;
  font-weight: 700;
  color: #475569;
}

.reaction-popup-content {
  display: inline-flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-start;
  max-width: min(80vw, 34rem);
}

.reaction-popup-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  justify-content: flex-start;
  width: 100%;
  max-width: 100%;
  white-space: nowrap;
  text-align: left;
}

.reaction-popup-item-emoji {
  font-size: 1rem;
  line-height: 1.2;
}

.reaction-popup-item-name {
  font-weight: 600;
  color: #1f2937;
  line-height: 1.25;
}

.reaction-popup-item-by {
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  line-height: 1.25;
}

.reaction-popup-item-time {
  font-size: 0.78rem;
  color: #6b7280;
  margin-left: auto;
}

.message-reaction-picker-trigger {
  border: 1px solid transparent;
  background: transparent;
  color: #6b7280;
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: none;
}

.message-reaction-picker-trigger:hover,
.message-reaction-picker-trigger:focus,
.message-reaction-picker-trigger:focus-visible {
  background: #e5e7eb;
  border-color: #9ca3af;
  color: #374151;
}

.message-reaction-picker-trigger.disabled,
.message-reaction-picker-trigger:disabled {
  opacity: 0.5;
  cursor: default;
}

.message-reaction-picker-icon {
  font-size: 1rem;
  line-height: 1;
  font-weight: 700;
}

.message-reaction-picker-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  max-width: 14rem;
}

.message-reaction-picker-option {
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111827;
  min-width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.message-reaction-picker-option:hover,
.message-reaction-picker-option:focus {
  border-color: #93c5fd;
  background: #eff6ff;
}

.message-reaction-picker-option.is-disabled,
.message-reaction-picker-option:disabled {
  opacity: 0.45;
  cursor: default;
}

.message-reaction-remove-btn {
  border: none;
  background: transparent;
  color: #94a3b8;
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
}

.message-reaction-remove-btn:hover,
.message-reaction-remove-btn:focus {
  background: #fee2e2;
  color: #b91c1c;
}

.message-reaction-remove-btn.is-disabled,
.message-reaction-remove-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.message-time {
  font-size: 0.76rem;
  font-weight: 500;
  color: #64748b;
  white-space: nowrap;
  text-align: right;
}

.message-time-link {
  display: inline-flex;
  align-items: flex-end;
  justify-content: flex-end;
  color: inherit;
  text-decoration: none;
}

.message-time-link:hover .message-time,
.message-time-link:focus .message-time {
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

.ui.popup .toolcall-popup {
  max-width: min(680px, 78vw);
}

.toolcall-popup-title {
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.toolcall-popup-call {
  border-top: 1px solid #e5e7eb;
  padding-top: 0.5rem;
  margin-top: 0.5rem;
}

.toolcall-popup-call:first-of-type {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.toolcall-popup-call-title {
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.toolcall-popup-meta {
  color: #6b7280;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.toolcall-popup-label {
  margin-top: 0.35rem;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #374151;
}

.toolcall-popup-empty {
  color: #6b7280;
  font-size: 0.85rem;
  font-style: italic;
}

.ui.popup .case-field-name-popup-content {
  max-width: min(280px, 60vw);
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: break-word;
}

.toolcall-args-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.toolcall-args-table td {
  border-top: 1px solid #f1f5f9;
  vertical-align: top;
  padding: 0.3rem 0.25rem;
}

.toolcall-args-table tr:first-child td {
  border-top: 0;
}

.toolcall-arg-key {
  width: 34%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.82rem;
  color: #4b5563;
  word-break: break-word;
}

.toolcall-arg-value {
  width: 66%;
  word-break: break-word;
}

.toolcall-json {
  margin: 0;
  padding: 0.35rem 0.5rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.28571429rem;
  background: #f8fafc;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow: auto;
  font-size: 0.82rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.ui.modal.case-files-modal {
  width: 90vw !important;
  max-width: 90vw !important;
  height: 90vh;
  max-height: 90vh;
  margin: 0 0 0 -45vw !important;
  top: 5vh !important;
  border-radius: 0;
  overflow: visible;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

.ui.modal.case-files-modal.visible.active {
  display: flex !important;
  flex-direction: column;
}

.case-files-modal > .close.icon {
  top: 0.35rem;
  right: 0.35rem;
  color: #fff;
}

.case-files-modal .content {
  flex: 1 1 auto;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  background: transparent !important;
}

.case-files-modal-layout {
  display: grid;
  grid-template-columns: auto 400px;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: auto;
  max-width: 100%;
  height: 100%;
  min-height: 0;
}

.case-files-modal-stage {
  min-width: 0;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: calc(90vw - 400px - 20px);
  height: 100%;
}

.case-files-modal-preview {
  width: auto;
  height: auto;
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 0;
  background: transparent;
}

.case-files-modal-preview.is-image {
  max-width: calc(90vw - 400px - 20px);
  max-height: 90vh;
}

.case-files-modal-preview.is-pdf {
  width: min(900px, calc(90vw - 400px - 20px));
  height: 90vh;
  max-width: calc(90vw - 400px - 20px);
}

.case-files-modal-preview.is-file {
  width: min(520px, calc(90vw - 400px - 20px));
  min-height: 280px;
}

.case-files-modal-image {
  display: block;
  width: auto;
  height: auto;
  max-width: calc(90vw - 400px - 20px);
  max-height: 90vh;
  object-fit: contain;
  object-position: center;
}

.case-files-modal-frame {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0.75rem;
  background: #fff;
}

.case-files-modal-placeholder {
  width: 100%;
  height: 100%;
  border-radius: 0.85rem;
  border: 1px dashed rgba(148, 163, 184, 0.45);
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.25rem;
}

.case-files-modal-sidebar {
  width: 400px;
  min-width: 400px;
  max-width: 400px;
  min-height: 0;
  display: flex;
  height: 100%;
}

.case-files-modal-sidebar-inner {
  width: 100%;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  padding: 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.case-files-modal-section {
  padding-bottom: 1rem;
  border-bottom: 1px solid #eef2f7;
}

.case-files-modal-section:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.case-files-modal-section--fields {
  flex: 1 1 auto;
  min-height: 0;
}

.case-files-modal-file-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.case-files-modal-file-heading {
  min-width: 0;
}

.case-files-modal-file-name {
  font-size: 1.22rem;
  font-weight: 700;
  line-height: 1.2;
  color: #111827;
  word-break: break-word;
}

.case-files-modal-file-meta {
  margin-top: 0.35rem;
  color: #6b7280;
  font-size: 0.95rem;
}

.case-files-modal-validation-badge .case-file-status {
  text-align: left;
}

.case-files-modal-section-title {
  margin-bottom: 0.7rem;
  color: #64748b;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.case-files-modal-facts-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.case-files-modal-fact-row {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}

.case-files-modal-fact-label {
  color: #64748b;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.case-files-modal-fact-value {
  color: #111827;
  word-break: break-word;
}

.case-files-modal-sidebar-actions {
  margin-top: 0.9rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.case-files-modal-sidebar-actions .ui.button,
.case-files-modal-sidebar-actions .ui.primary.button {
  margin: 0 !important;
  border-radius: 999px !important;
}

.case-files-modal-empty {
  color: #6b7280;
  font-size: 0.93rem;
  line-height: 1.4;
}

.case-files-modal-sidebar .case-fields-table {
  width: 100%;
  margin: 0;
}

.case-files-modal-sidebar table {
  width: 100% !important;
}

.case-files-modal-sidebar .case-fields-table.definition.table {
  table-layout: auto;
}

.case-files-modal-sidebar .case-fields-table.definition.table tbody td:first-child {
  width: 167px;
  min-width: 167px;
  max-width: 167px;
  font-weight: 600;
  color: #374151;
  white-space: normal;
}

.case-files-modal-sidebar .case-fields-table.definition.table tbody td:nth-child(2) {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.case-files-modal-sidebar .case-fields-table.definition.table tbody td {
  padding: 0.58em 0.75em;
  vertical-align: middle;
}

.case-files-modal-sidebar .case-fields-table tbody tr.match-full {
  background-color: rgba(33, 186, 69, 0.15) !important;
}

.case-files-modal-sidebar .case-fields-table tbody tr.match-threshold {
  background-color: rgba(251, 189, 8, 0.25) !important;
}

.case-files-modal-sidebar .case-fields-table tbody tr.match-none {
  background-color: rgba(219, 40, 40, 0.15) !important;
}

.case-files-modal-fields {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.case-files-modal-field-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.8rem 0.9rem;
  border-radius: 0.9rem;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
}

.case-files-modal-field-main {
  min-width: 0;
  flex: 1 1 auto;
}

.case-files-modal-field-name {
  margin-bottom: 0.3rem;
  color: #64748b;
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.case-files-modal-field-value {
  color: #111827;
  font-size: 0.95rem;
  line-height: 1.4;
  word-break: break-word;
}

.case-files-modal-field-side {
  flex: 0 0 auto;
}

.case-files-modal-field-status {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.34rem 0.62rem;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #64748b;
  font-size: 0.77rem;
  font-weight: 700;
  white-space: nowrap;
}

.case-files-modal-field-status.is-validated {
  border-color: rgba(22, 163, 74, 0.24);
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
}

.case-files-modal-field-status.is-review {
  border-color: rgba(202, 138, 4, 0.25);
  background: rgba(250, 204, 21, 0.16);
  color: #a16207;
}

.case-files-modal-field-status.is-failed {
  border-color: rgba(220, 38, 38, 0.22);
  background: rgba(248, 113, 113, 0.13);
  color: #b91c1c;
}

.case-files-modal-field-status.is-processing,
.case-files-modal-field-status.is-not-applicable,
.case-files-modal-field-status.is-empty {
  color: #64748b;
}

.case-files-modal-download-row {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
}

.case-files-modal-download-name {
  min-width: 0;
  flex: 1 1 auto;
  word-break: break-word;
}

.case-files-modal-download-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  border: 1px solid #dbe3f1;
  background: #f8fafc;
  color: #2563eb;
  text-decoration: none;
}

.case-files-modal-download-action:hover,
.case-files-modal-download-action:focus {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.case-files-modal-field-footer {
  margin-top: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.case-file-review-button.ui.button {
  margin: 0 !important;
  border-radius: 999px !important;
}

.case-file-review-button.ui.button.is-disabled {
  opacity: 0.55 !important;
  pointer-events: none !important;
}

.case-file-approve-button.ui.button {
  border-color: rgba(22, 163, 74, 0.24) !important;
  color: #15803d !important;
}

.case-file-approve-button.ui.button:hover,
.case-file-approve-button.ui.button:focus {
  background: rgba(22, 163, 74, 0.08) !important;
}

.case-file-report-mistake-button.ui.button.is-active {
  background: rgba(250, 204, 21, 0.16) !important;
  border-color: rgba(202, 138, 4, 0.25) !important;
  color: #a16207 !important;
}

@media (max-width: 1280px) {
  .view-namespaces .agents-detail {
    overflow-y: auto;
  }

  .namespace-detail-layout {
    flex-direction: column;
    height: auto;
  }

  .namespace-main-column,
  .namespace-side-panel {
    width: 100%;
    min-width: 0;
    height: auto;
    overflow: visible;
  }

  .namespace-main-column {
    padding-right: 0;
  }

  .namespace-side-panel-inner,
  .namespace-side-scroll {
    height: auto;
    overflow: visible;
    padding-right: 0;
  }
}

@media (max-width: 720px) {
  .app-layout {
    flex-direction: column;
  }

  .app-sidebar {
    width: 100%;
    flex-direction: row;
    justify-content: center;
  }

  .app-main {
    height: calc(100vh - 64px);
  }

  .cases-grid {
    flex-direction: column;
  }

  .chat-list-grid {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  }

  .chat-list-detail-column {
    border-left: none;
    border-top: 1px solid rgba(34, 36, 38, 0.15);
  }

  .cases-list,
  .cases-chat,
  .cases-details-column {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
  }

  .cases-resize-handle {
    display: none;
  }

  .case-table .case-col-resize-handle {
    display: none;
  }

  .timeline-row {
    grid-template-columns: 1fr;
  }

  .chat-composer-panel,
  .chat-composer-controls-row {
    gap: 0.65rem;
  }

  .chat-composer-controls-row {
    flex-direction: column;
    align-items: stretch;
  }

  .chat-composer-left,
  .chat-composer-right {
    width: 100%;
  }

  .chat-composer-left {
    justify-content: space-between;
  }

  .chat-composer-right {
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .case-target-dropdown.ui.dropdown {
    flex: 1 1 auto;
    min-width: 0;
  }

  .case-send-btn.ui.button {
    flex: 0 0 auto;
  }

}

@media (max-width: 720px) {
  .ui.modal.case-files-modal {
    width: 96vw !important;
    max-width: 96vw !important;
    height: 94vh;
    max-height: 94vh;
    margin-left: -48vw !important;
    top: 3vh !important;
  }

  .case-files-modal .content {
    padding-bottom: 0 !important;
  }

  .case-files-modal-layout {
    gap: 0.85rem;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .case-files-modal-stage {
    min-height: 40vh;
    max-width: 100%;
  }

  .case-files-modal-preview.is-image,
  .case-files-modal-preview.is-pdf,
  .case-files-modal-preview.is-file,
  .case-files-modal-image {
    max-width: 100%;
  }

  .case-files-modal-preview.is-pdf {
    width: 100%;
    height: 40vh;
  }

  .case-files-modal-sidebar {
    width: 100%;
    min-width: 0;
    max-width: none;
    height: auto;
  }

  .case-files-modal-file-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .case-files-modal-fact-row {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .case-files-modal-field-row {
    flex-direction: column;
  }

  .case-files-modal-field-side {
    width: 100%;
  }

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

  .insights-card-wide {
    grid-column: span 1;
  }
}

/* ── Insights ── */
.insights-dashboard {
  padding: 20px;
  width: 100%;
  overflow-y: auto;
}

.insights-filters {
  margin-top: 4px;
}

.insights-filters .fields {
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

.insights-filters .field {
  min-width: 180px;
}

.insights-filters .field.insights-filters-actions {
  min-width: 0;
}

.insights-filters-note {
  color: #9ca3af;
  font-size: 12px;
  margin-top: 6px;
}

.insights-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.insights-section {
  margin-top: 22px;
}

.insights-section-title.ui.header {
  color: #e5e7eb;
  margin-bottom: 0;
}

.insights-summary-card {
  background: linear-gradient(180deg, rgba(31, 41, 55, 0.98), rgba(17, 24, 39, 0.98));
  border: 1px solid rgba(75, 85, 99, 0.45);
  border-radius: 10px;
  padding: 16px;
  min-height: 116px;
}

.insights-summary-card.is-highlight {
  border-color: rgba(96, 165, 250, 0.55);
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.15) inset;
}

.insights-summary-label {
  color: #9ca3af;
  font-size: 12px;
  letter-spacing: 0.03em;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.insights-summary-value {
  color: #f9fafb;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
}

.insights-summary-meta {
  color: #cbd5e1;
  font-size: 12px;
  margin-top: 8px;
}

.insights-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 16px;
}

.insights-card {
  background: #1f2937;
  border-radius: 8px;
  padding: 16px;
  min-height: 370px;
}

.insights-card-wide {
  grid-column: span 2;
}
