:root {
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-muted: #f6f8fb;
  --ink: #172033;
  --muted: #667085;
  --line: #d8dee8;
  --accent: #256f5b;
  --accent-strong: #195243;
  --blue: #315fbd;
  --danger: #b42318;
  --success: #23714f;
  --warning: #b54708;
  --info: #315fbd;
  --interactive: #7367f0;
  --interactive-hover: #5d52d6;
  --focus-ring: rgba(115, 103, 240, 0.62);
  --status-neutral: #667085;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --violet: var(--interactive);
  --violet-soft: #f1efff;
  --shadow: 0 16px 40px rgba(31, 42, 68, 0.08);
  --shadow-menu: 0 14px 36px rgba(47, 43, 61, 0.16);
}

/* Page-specific work surfaces: keep dense admin workflows scannable without
   changing the shared panel, form, table, or button primitives. */
#account-section .account-security-fields {
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  max-width: 760px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

#account-section .account-security-fields > label:first-child {
  grid-column: 1 / -1;
}

#account-section .account-security-fields input {
  background: #ffffff;
}

#account-section .account-security-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: none;
}

#account-section #account-password-result {
  max-width: 760px;
}

#users-section .customer-user-create-fields {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

#users-section .customer-user-create-fields input,
#users-section .customer-user-create-fields select {
  background: #ffffff;
}

#users-section .customer-user-create-actions {
  display: flex;
  justify-content: flex-start;
  max-width: none;
}

#users-section .customer-users-toolbar {
  grid-template-columns: minmax(220px, 1.55fr) repeat(5, minmax(110px, 1fr)) auto;
  align-items: end;
}

#users-section #customer-users-result {
  overflow: visible;
}

#sessions-section .sessions-filter-toolbar {
  grid-template-columns: minmax(220px, 1.5fr) repeat(3, minmax(120px, 1fr)) auto;
  align-items: end;
}

#sessions-section #conversation-list-result {
  overflow: visible;
}

#chat-test-section .chat-test-composer {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

#chat-test-section .chat-test-composer input,
#chat-test-section .chat-test-composer textarea {
  background: #ffffff;
}

#chat-test-section .chat-test-transcript {
  min-height: 360px;
  padding: 16px;
  border: 1px solid var(--line);
  background: #f8fafc;
}

@media (max-width: 760px) {
  #account-section .account-security-fields {
    grid-template-columns: 1fr;
  }

  #account-section .account-security-fields > label:first-child {
    grid-column: auto;
  }

  #users-section .customer-users-toolbar,
  #sessions-section .sessions-filter-toolbar {
    grid-template-columns: 1fr;
  }

  #users-section .customer-user-create-fields {
    padding: 12px;
  }

  #chat-test-section .chat-test-composer,
  #chat-test-section .chat-test-transcript {
    padding: 12px;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(238, 242, 246, 0.96)),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
}

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 24px 44px;
}

body.is-authenticated .container {
  width: 90vw;
  max-width: none;
  padding-inline: 0;
}

.card,
.panel,
.metric-card {
  background: var(--surface);
  border: 1px solid rgba(216, 222, 232, 0.86);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.card {
  padding: 24px;
  margin-bottom: 20px;
}

.container > .card:first-child {
  padding: 26px 28px;
  background: linear-gradient(135deg, #ffffff 0%, #f6faf9 100%);
}

.container > .card:first-child h1 {
  font-size: 30px;
  line-height: 1.15;
}

.container > .card:first-child p {
  margin-bottom: 0;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.hidden-control {
  display: none !important;
}

body.modal-open {
  overflow: hidden;
}

.login-shell {
  display: flex;
  justify-content: center;
  padding-top: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
}

.login-form {
  display: grid;
  gap: 2px;
}

.login-form button {
  margin-top: 14px;
}

.login-error {
  min-height: 20px;
  margin-top: 12px;
  color: var(--danger);
  font-size: 13px;
}

h1,
h2,
p {
  margin-top: 0;
}

h2 {
  margin-bottom: 14px;
  font-size: 20px;
}

label {
  display: block;
  margin-top: 12px;
}

label span,
legend {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
textarea,
select,
button {
  width: 100%;
  border-radius: 8px;
  font: inherit;
}

input,
textarea,
select {
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: var(--ink);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

textarea.compact-textarea {
  min-height: 42px;
  overflow-y: hidden;
  resize: none;
  white-space: pre-wrap;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(37, 111, 91, 0.14);
}

button {
  position: relative;
  min-height: 42px;
  padding: 10px 14px;
  border: 0;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
  transition:
    background 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

button:hover {
  background: var(--accent-strong);
  box-shadow: 0 8px 18px rgba(37, 111, 91, 0.18);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.72;
  transform: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.is-loading::after {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 8px;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-top-color: #ffffff;
  border-radius: 999px;
  content: "";
  animation: spin 0.72s linear infinite;
}

.secondary-action {
  width: auto;
  background: #e8eef8;
  color: #244272;
}

.secondary-action:hover {
  background: #dbe6f7;
}

.ghost-action {
  width: auto;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
}

.ghost-action:hover {
  background: var(--surface-muted);
}

.icon-action {
  display: inline-grid;
  place-items: center;
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  background: #f3f5f9;
  color: #344054;
}

.icon-action:hover {
  background: var(--violet-soft);
  color: var(--violet);
  box-shadow: none;
}

.status-line {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.workspace-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  gap: 18px;
  width: 100%;
  margin-top: 0;
  align-items: start;
  transition: grid-template-columns 0.18s ease;
}

.workspace-shell.menu-collapsed {
  grid-template-columns: 86px minmax(0, 1fr);
}

.workspace-shell.menu-collapsed .side-menu {
  padding-inline: 12px;
}

.workspace-shell.menu-collapsed .brand-block {
  justify-content: center;
}

.workspace-shell.menu-collapsed .brand-block > div:last-child,
.workspace-shell.menu-collapsed .menu-heading {
  display: none;
}

.workspace-shell.menu-collapsed .menu-item {
  display: flex;
  justify-content: center;
  min-height: 42px;
  padding: 8px;
  gap: 0;
}

.side-menu {
  position: sticky;
  top: 24px;
  min-height: calc(100vh - 48px);
  padding: 18px 14px;
  background: #ffffff;
  border: 1px solid rgba(216, 222, 232, 0.86);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #172033;
  color: #ffffff;
  font-weight: 800;
}

.brand-block strong,
.brand-block span {
  display: block;
}

.brand-block span {
  color: var(--muted);
  font-size: 12px;
}

.menu-list {
  display: grid;
  gap: 6px;
  margin-top: 16px;
}

.menu-heading {
  padding: 4px 12px;
  color: #98a2b3;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 8px;
  color: #344054;
  font-weight: 700;
  text-decoration: none;
  transition:
    background 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease;
}

.menu-item .menu-icon {
  flex-shrink: 0;
  color: currentColor;
}

.menu-item .menu-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-shell.menu-collapsed .menu-item .menu-label {
  display: none;
}

.menu-item:hover {
  background: var(--violet-soft);
  color: var(--interactive-hover);
  transform: translateX(3px);
}

.workspace-shell.menu-collapsed .menu-item:hover {
  transform: none;
}

.menu-item.active {
  background: linear-gradient(90deg, rgba(115, 103, 240, 0.16), rgba(115, 103, 240, 0.08));
  color: var(--violet);
  box-shadow: inset 3px 0 0 var(--violet);
}

.workspace-content {
  min-width: 0;
  width: 100%;
}

.workspace-page.hidden-page {
  display: none !important;
}

.workspace-topbar {
  position: sticky;
  top: 18px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(216, 222, 232, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.topbar-actions {
  position: relative;
  display: flex;
  align-items: center;
  margin-left: auto;
  gap: 8px;
}

.avatar-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  background: var(--violet);
  color: #ffffff;
  border-radius: 999px;
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px;
  background: #172033;
  color: #ffffff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  scroll-margin-top: 96px;
}

.workspace-header h1 {
  margin-bottom: 0;
  font-size: 26px;
}

.workspace-header .eyebrow,
.workspace-header .user-chip strong {
  color: #b7c6d8;
}

.user-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-chip {
  display: grid;
  gap: 3px;
  min-width: 220px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
}

.user-chip span,
.user-chip strong {
  overflow-wrap: anywhere;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 16px 0;
}

.metric-card {
  position: relative;
  padding: 16px;
  overflow: hidden;
  transition:
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

.metric-card:hover {
  box-shadow: 0 18px 38px rgba(47, 43, 61, 0.12);
  transform: translateY(-2px);
}

.metric-card::after {
  position: absolute;
  right: -18px;
  bottom: -22px;
  width: 82px;
  height: 82px;
  background: rgba(115, 103, 240, 0.08);
  border-radius: 999px;
  content: "";
}

.metric-icon {
  display: inline-grid !important;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-bottom: 10px;
  background: var(--violet-soft);
  color: var(--violet) !important;
  border-radius: 8px;
  font-size: 11px !important;
  font-weight: 800 !important;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 6px;
}

/* Customer dashboard: keep the top-line context compact, then give the
   service scope panel one clear reading order: heading, scope rows, actions. */
.customer-dashboard-metrics {
  gap: 12px;
  margin: 14px 0 16px;
}

.customer-dashboard-metrics .metric-card {
  min-height: 104px;
  padding: 15px 16px;
  border-top: 3px solid var(--accent);
  box-shadow: 0 8px 22px rgba(31, 42, 68, 0.06);
}

.customer-dashboard-metrics .metric-card::after {
  display: none;
}

.customer-dashboard-metrics .metric-icon {
  margin-bottom: 9px;
  background: #e8f5ee;
  color: var(--accent) !important;
}

.customer-dashboard-metrics .metric-card strong {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.3;
}

.customer-dashboard-scope {
  padding: 22px 24px 24px;
}

.customer-dashboard-scope .panel-header {
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.customer-dashboard-scope .panel-header h2 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.customer-dashboard-scope .panel-header > .pill {
  align-self: flex-start;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid rgba(35, 113, 79, 0.2);
  white-space: nowrap;
}

.customer-dashboard-scope .scope-summary {
  display: grid;
  grid-template-columns: minmax(132px, 18%) minmax(0, 1fr);
  gap: 8px 18px;
  align-items: baseline;
  margin: 0;
  padding: 12px 0;
  border-bottom: 1px solid #edf0f4;
}

.customer-dashboard-scope .scope-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1.35;
  text-transform: uppercase;
}

.customer-dashboard-scope .scope-value {
  min-width: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.customer-dashboard-scope .scope-value strong {
  font-weight: 750;
}

.customer-dashboard-scope .scope-unavailable .scope-value {
  color: var(--muted);
}

.customer-dashboard-scope .scope-unavailable .scope-value strong {
  color: var(--ink);
}

.customer-dashboard-scope .scope-next-steps {
  margin-top: 4px;
  padding-top: 14px;
  border-bottom: 0;
}

.customer-dashboard-scope .scope-next-steps .scope-value {
  font-weight: 600;
}

.customer-dashboard-scope .dashboard-cta-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.customer-dashboard-scope .dashboard-cta-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: auto;
  min-width: 0;
  min-height: 44px;
  padding: 11px 13px;
  border: 1px solid rgba(37, 111, 91, 0.25);
  background: #f3f8f5;
  color: var(--accent-strong);
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
  text-decoration: none;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

.customer-dashboard-scope .dashboard-cta-list a::after {
  flex-shrink: 0;
  margin-left: 10px;
  content: "→";
  font-size: 16px;
  line-height: 1;
}

.customer-dashboard-scope .dashboard-cta-list a:hover {
  border-color: rgba(37, 111, 91, 0.45);
  background: #e8f5ee;
  box-shadow: 0 7px 16px rgba(37, 111, 91, 0.12);
  transform: translateY(-1px);
}

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

.panel {
  position: relative;
  padding: 20px;
  scroll-margin-top: 96px;
  overflow: visible;
}

.panel:hover {
  box-shadow: 0 18px 42px rgba(47, 43, 61, 0.1);
}

.span-2 {
  grid-column: span 2;
}

.panel-header {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.panel-header h2 {
  margin-bottom: 0;
}

.inline-actions {
  position: relative;
  display: flex;
  gap: 10px;
}

.panel-tools {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.inline-actions button {
  width: auto;
}

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

/* Cache controls are intentionally denser than the generic form grid: each
   label is one complete, keyboard-focusable option rather than a detached
   checkbox and caption. */
#cache-section {
  padding: 22px 24px 24px;
}

#cache-section .panel-header {
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

#cache-section .panel-header h2 {
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

#cache-section .panel-header .eyebrow {
  margin-bottom: 7px;
  color: var(--accent);
}

#cache-section .cache-panel-description {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

#cache-section .panel-tools {
  align-self: flex-start;
}

#cache-clear-btn {
  width: auto;
  min-width: 132px;
  white-space: nowrap;
}

.cache-options {
  gap: 10px;
  margin: 0;
}

.cache-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 70px;
  margin: 0;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  cursor: pointer;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

.cache-option:hover {
  border-color: rgba(37, 111, 91, 0.38);
  background: #f8fbfa;
  transform: translateY(-1px);
}

.cache-option:has(input:checked) {
  border-color: rgba(37, 111, 91, 0.42);
  background: #f2f8f5;
  box-shadow: inset 3px 0 0 var(--accent);
}

.cache-option:has(input:focus-visible) {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.cache-option:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.62;
}

.cache-option:has(input:disabled):hover {
  transform: none;
}

.cache-option > input {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.cache-option > span,
.cache-option .cache-option-body,
.cache-option .cache-option-status {
  display: block;
  margin: 0;
  text-transform: none;
}

.cache-option-body {
  min-width: 0;
}

.cache-option-body strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cache-option-status {
  margin-top: 5px !important;
  color: var(--status-neutral);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}

.cache-option-status::before {
  content: "○";
}

.cache-option > input:checked + .cache-option-body .cache-option-status {
  color: var(--success);
}

.cache-option > input:checked + .cache-option-body .cache-option-status::before {
  content: "●";
}

#cache-clear-result {
  display: block;
  margin-top: 16px;
  min-height: 64px;
  padding: 14px 16px;
  border-left: 3px solid var(--line);
  background: #f8fafc;
}

#cache-clear-result:has(.notice.success) {
  border-color: var(--success);
  background: #f0f8f3;
}

#cache-clear-result:has(.notice.danger) {
  border-color: var(--danger);
  background: #fff5f3;
}

#cache-clear-result .notice {
  width: 100%;
  padding: 0;
  background: transparent;
}

#cache-clear-result .raw-details {
  width: 100%;
}

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

.panel-actions {
  margin-top: 14px;
  max-width: 260px;
}

.service-fieldset {
  margin: 12px 0 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.checkbox-line input {
  width: auto;
}

.checkbox-line span {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-transform: none;
}

.result-surface {
  margin-top: 14px;
  min-height: 56px;
  padding: 12px;
  overflow: auto;
  background: var(--surface-muted);
  border: 1px solid #e1e7ef;
  border-radius: 8px;
  color: var(--muted);
}

.conversation-list-surface,
.conversation-detail-surface {
  min-height: 220px;
}

.embed-snippet-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  margin-top: 14px;
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.embed-snippet-box h3 {
  margin: 2px 0 0;
}

.code-snippet {
  grid-column: 1 / -1;
  margin: 0;
  padding: 12px;
  overflow: auto;
  background: #111827;
  color: #e5e7eb;
  border-radius: 8px;
  white-space: pre-wrap;
}

.session-detail-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 24px;
}

.session-detail-modal.hidden {
  display: none !important;
}

.session-detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(4px);
}

.session-detail-dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(980px, calc(100vw - 32px));
  max-height: min(86vh, 920px);
  overflow: hidden;
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.28);
}

.session-detail-dialog .conversation-detail-surface {
  flex: 1;
  min-height: 360px;
  overflow: auto;
}

.image-crop-modal {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: grid;
  place-items: center;
  padding: 24px;
}

.image-crop-modal.hidden {
  display: none !important;
}

.knowledge-edit-modal {
  position: fixed;
  inset: 0;
  z-index: 1250;
  display: grid;
  place-items: center;
  padding: 24px;
}

.knowledge-edit-modal.hidden {
  display: none !important;
}

.knowledge-edit-dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(820px, calc(100vw - 32px));
  max-height: min(90vh, 860px);
  overflow: hidden;
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.28);
}

.knowledge-edit-body {
  display: grid;
  gap: 16px;
  padding: 18px;
  overflow: auto;
}

.knowledge-edit-content {
  min-height: 280px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.55;
}

.knowledge-edit-actions {
  justify-content: flex-end;
  padding: 0 18px 18px;
}

.image-crop-dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(560px, calc(100vw - 32px));
  max-height: min(90vh, 760px);
  overflow: hidden;
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.28);
}

.image-crop-body {
  display: grid;
  gap: 16px;
  padding: 18px;
  overflow: auto;
}

.image-crop-stage {
  display: grid;
  place-items: center;
  background:
    linear-gradient(45deg, #eef2f7 25%, transparent 25%),
    linear-gradient(-45deg, #eef2f7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef2f7 75%),
    linear-gradient(-45deg, transparent 75%, #eef2f7 75%);
  background-color: #ffffff;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  aspect-ratio: 1;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.image-crop-stage:active {
  cursor: grabbing;
}

.image-crop-stage canvas {
  display: block;
  width: min(100%, 320px);
  height: auto;
  aspect-ratio: 1;
}

.image-crop-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(130px, 0.55fr) 88px;
  gap: 16px;
  align-items: end;
}

.image-crop-controls label[hidden] {
  display: none;
}

.image-crop-preview {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.image-crop-preview canvas {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 8px;
}

.image-crop-actions {
  justify-content: flex-end;
  padding: 0 18px 18px;
}

@media (max-width: 640px) {
  .image-crop-controls {
    grid-template-columns: 1fr;
  }

  .image-crop-preview {
    width: 72px;
    height: 72px;
  }
}

.conversation-list {
  display: grid;
  gap: 10px;
}

.conversation-item {
  display: grid;
  grid-template-columns: 44px minmax(280px, 1.6fr) 88px 140px 140px 72px;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: auto;
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  text-align: left;
  box-shadow: none;
  transform: none;
}

.conversation-item-head-row {
  padding-block: 10px;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.conversation-item:hover {
  background: var(--violet-soft);
  color: var(--ink);
  box-shadow: none;
  transform: none;
}

.conversation-item.selected-row {
  background: #f8fbff;
  border-color: rgba(105, 108, 255, 0.45);
}

.conversation-item.internal-test-session {
  background: #fff8e8;
  border-color: #f3c96b;
  box-shadow: inset 3px 0 0 #d99718;
}

.conversation-item.internal-test-session:hover {
  background: #fff3d4;
}

.conversation-item.active {
  border-color: rgba(115, 103, 240, 0.38);
  background: linear-gradient(90deg, rgba(115, 103, 240, 0.12), rgba(255, 255, 255, 0.96));
  box-shadow: inset 3px 0 0 var(--violet);
}

.conversation-item.internal-test-session.active {
  border-color: #d99718;
  background: linear-gradient(90deg, rgba(217, 151, 24, 0.18), rgba(255, 248, 232, 0.96));
  box-shadow: inset 3px 0 0 #d99718;
}

.conversation-select-btn {
  display: grid;
  gap: 6px;
  min-height: auto;
  padding: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  box-shadow: none;
  transform: none;
  min-width: 0;
}

.conversation-select-btn:hover {
  background: transparent;
  box-shadow: none;
  transform: none;
}

.conversation-row-actions {
  position: relative;
  justify-self: end;
}

.conversation-action-menu {
  min-width: 120px;
}

.conversation-action-menu button[data-conversation-action="delete"] {
  color: var(--danger);
}

.conversation-action-menu button[data-conversation-action="delete"]:hover {
  background: #fff0ee;
  color: var(--danger);
}

.conversation-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.conversation-item-head strong {
  color: var(--ink);
}

.conversation-item-head span,
.conversation-preview {
  color: var(--muted);
  font-size: 12px;
}

.session-source-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #7a4d00;
  color: #fff7df !important;
  font-size: 11px !important;
  font-weight: 800;
  line-height: 1;
}

.conversation-preview {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

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

.pagination-bar button {
  min-width: 76px;
}

.conversation-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.conversation-detail-head h3 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 18px;
}

.chat-test-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1.2fr);
  gap: 14px;
}

.chat-test-controls {
  display: grid;
  align-content: start;
  gap: 12px;
}

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

.chat-test-actions button {
  width: auto;
}

.chat-test-surface {
  min-height: 420px;
}

.chat-test-session-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.empty-state {
  display: grid;
  min-height: 96px;
  place-items: center;
  color: var(--muted);
  background: #ffffff;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.skeleton-block {
  min-height: 72px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0)),
    #e9eef5;
  background-size: 220% 100%;
  animation: skeleton 1.1s linear infinite;
}

.compact-result {
  min-height: 80px;
}

.notice {
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink);
  background: #edf1f5;
}

.notice.success {
  color: var(--success);
  background: #e8f5ee;
}

.notice.danger {
  color: var(--danger);
  background: #fff0ee;
}

.stale-result {
  margin-top: 10px;
  opacity: 0.82;
}

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

.compact-summary {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.summary-item {
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-item strong {
  display: block;
  margin-top: 5px;
}

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

.large-textarea {
  min-height: 150px;
}

#knowledge-create-section {
  padding: 22px 24px 24px;
}

#knowledge-create-section .panel-header {
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

#knowledge-create-section .panel-header h2 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.knowledge-config-strip {
  display: flex;
  align-items: center;
  min-height: 44px;
  margin: 0 0 16px;
  padding: 10px 12px;
  overflow-wrap: anywhere;
  background: var(--surface-muted);
  border: 1px solid #e1e7ef;
  border-left: 3px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.knowledge-create-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
  margin-bottom: 14px;
}

.knowledge-create-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  min-height: 100%;
  padding: 16px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(31, 42, 68, 0.05);
}

.knowledge-create-head {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
  min-height: 54px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}

.knowledge-create-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.knowledge-create-head strong {
  color: var(--ink);
  font-size: 16px;
  line-height: 1.3;
}

.knowledge-create-card > label {
  margin-top: 0;
}

.knowledge-create-card > label > span {
  margin-bottom: 6px;
}

.knowledge-create-card .two-columns {
  gap: 10px;
}

.knowledge-create-card .knowledge-create-btn {
  width: 100%;
  min-height: 44px;
  margin-top: auto;
}

.knowledge-create-result {
  min-height: 78px;
  margin-top: 0;
  padding: 14px 16px;
  border-left: 3px solid var(--line);
  background: #f8fafc;
}

.knowledge-create-result:has(.notice.success) {
  border-color: var(--success);
  background: #f0f8f3;
}

.knowledge-create-result:has(.notice.danger) {
  border-color: var(--danger);
  background: #fff5f3;
}

.knowledge-create-result .notice {
  width: 100%;
  overflow-wrap: anywhere;
}

.knowledge-create-result .knowledge-create-cta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.knowledge-create-result .knowledge-create-cta button {
  width: 100%;
}

.knowledge-workbench {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 14px;
}

.knowledge-list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.knowledge-list-toolbar span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.knowledge-list-toolbar strong {
  color: var(--ink);
  font-size: 16px;
}

.knowledge-list-controls {
  display: flex;
  gap: 8px;
}

.knowledge-list-controls select {
  min-width: 112px;
}

.knowledge-assets-surface,
.knowledge-search-surface {
  min-height: 260px;
}

.knowledge-asset-table,
.knowledge-match-list {
  display: grid;
  gap: 10px;
}

.knowledge-asset-row,
.knowledge-match {
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.knowledge-asset-row {
  display: grid;
  grid-template-columns: 44px 96px minmax(260px, 1.6fr) 92px 92px 88px 128px 132px 64px;
  gap: 12px;
  align-items: start;
}

.knowledge-asset-row.selected-row {
  background: #f8fbff;
  border-color: rgba(105, 108, 255, 0.45);
}

.knowledge-asset-head {
  padding-block: 10px;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.knowledge-asset-title-cell {
  min-width: 0;
  overflow-wrap: anywhere;
}

.knowledge-asset-title-cell .notice {
  overflow-wrap: anywhere;
}

.knowledge-asset-title-cell strong,
.knowledge-match h3 {
  display: block;
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 16px;
}

.knowledge-asset-title-cell p,
.knowledge-match p {
  display: -webkit-box;
  margin-bottom: 0;
  overflow: hidden;
  overflow-wrap: anywhere;
  color: var(--muted);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.knowledge-asset-details {
  grid-column: 1 / -1;
  grid-row: auto;
  display: block;
  width: 100%;
  min-width: 0;
  justify-self: stretch;
  align-self: stretch;
}

.knowledge-asset-details pre {
  width: 100%;
  box-sizing: border-box;
}

.knowledge-asset-row > div:not(.knowledge-asset-title-cell):not(.knowledge-row-actions) {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.knowledge-row-actions {
  position: relative;
  display: flex;
  justify-content: flex-end;
}

.knowledge-action-menu {
  min-width: 148px;
}

.knowledge-action-menu button[data-asset-action="delete"] {
  color: var(--danger);
}

.knowledge-action-menu button[data-asset-action="delete"]:hover {
  background: #fff0ee;
  color: var(--danger);
}

/* Scoped operational surfaces share one compact hierarchy while retaining the
   existing global form, table, and button primitives. */
#company-section,
#widget-section,
#knowledge-section {
  padding: 22px 24px 24px;
}

#company-section .panel-header,
#widget-section .panel-header,
#knowledge-section .panel-header {
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

#company-section .panel-header h2,
#widget-section .panel-header h2,
#knowledge-section .panel-header h2 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

#company-section .form-grid,
#widget-section .form-grid {
  gap: 14px 12px;
}

#company-section .form-grid > label,
#widget-section .form-grid > label {
  min-width: 0;
  margin-top: 0;
}

#company-section .form-grid textarea {
  min-height: 104px;
}

#company-section .panel-actions {
  margin-top: 16px;
}

#company-section .panel-actions {
  max-width: 220px;
}

#widget-section .checkbox-line {
  min-height: 46px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

#widget-section .form-grid input[type="color"] {
  min-height: 42px;
  padding: 4px;
}

#widget-section .embed-snippet-box {
  margin-top: 18px;
  padding: 16px;
  background: var(--surface-muted);
}

#widget-section .embed-snippet-box h3 {
  margin-bottom: 0;
  font-size: 16px;
}

#company-section #company-profile-result,
#widget-section #widget-config-result {
  min-height: 72px;
  margin-top: 16px;
  border-left: 3px solid var(--line);
}

#company-section #company-profile-result:has(.notice.success),
#widget-section #widget-config-result:has(.notice.success) {
  border-color: var(--success);
  background: #f0f8f3;
}

#company-section #company-profile-result:has(.notice.danger),
#widget-section #widget-config-result:has(.notice.danger) {
  border-color: var(--danger);
  background: #fff5f3;
}

#knowledge-section .knowledge-search-box {
  padding: 14px;
  border-left: 3px solid var(--accent);
  background: var(--surface-muted);
}

#knowledge-section .knowledge-search-box > label,
#knowledge-section .knowledge-search-box .two-columns label {
  margin-top: 0;
}

#knowledge-section .knowledge-search-box > button {
  width: auto;
  min-width: 132px;
}

#knowledge-section .knowledge-list-toolbar {
  margin-bottom: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

#knowledge-section .knowledge-list-controls {
  min-width: 0;
  flex-wrap: wrap;
}

#knowledge-section .knowledge-list-controls select {
  min-width: 0;
}

#knowledge-section .knowledge-asset-row {
  grid-template-columns: 36px 80px minmax(0, 1.5fr) repeat(4, minmax(70px, 0.7fr)) minmax(96px, 1fr) 44px;
  gap: 8px;
  padding: 10px;
}

#knowledge-section .knowledge-asset-row > div {
  min-width: 0;
  overflow-wrap: anywhere;
}

.user-table {
  display: grid;
  gap: 10px;
}

.user-list-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(5, minmax(120px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  margin: 14px 0;
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.user-list-toolbar button {
  min-height: 42px;
}

.bulk-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.bulk-action-bar > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.danger-action {
  color: var(--danger);
}

.danger-action:hover {
  background: #fff0ee;
  color: var(--danger);
}

.user-row {
  display: grid;
  grid-template-columns: 44px minmax(260px, 1.5fr) minmax(140px, 0.9fr) 96px minmax(140px, 0.9fr) 138px 72px;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.user-row.selected-row {
  background: #f8fbff;
  border-color: rgba(105, 108, 255, 0.45);
}

.user-row-head {
  padding-block: 10px;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.row-select-checkbox {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  accent-color: var(--violet);
}

.user-row > div {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.user-row strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
}

.user-row span:not(.pill) {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.user-row-actions {
  position: relative;
  display: flex;
  justify-content: flex-end;
}

.user-action-menu {
  min-width: 140px;
}

.user-action-menu button[data-user-action="delete"] {
  color: var(--danger);
}

.user-action-menu button[data-user-action="delete"]:hover {
  background: #fff0ee;
  color: var(--danger);
}

.knowledge-search-box {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.knowledge-match-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.knowledge-match-head span {
  color: var(--violet);
  font-weight: 800;
}

.status-ready,
.status-completed {
  background: #e8f5ee;
  color: var(--success);
}

.status-failed {
  background: #fff0ee;
  color: var(--danger);
}

.status-processing,
.status-running,
.status-queued {
  background: var(--violet-soft);
  color: var(--violet);
}

.pill.status-uploaded {
  background: #fff4cc;
  color: #8a5a00;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  border-radius: 8px;
  overflow: hidden;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--muted);
  background: #f9fbfd;
  font-size: 12px;
  text-transform: uppercase;
}

code {
  font-family: var(--mono);
  overflow-wrap: anywhere;
  color: #244272;
}

.pill {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e8f5ee;
  color: var(--success);
  font-size: 12px;
  font-weight: 700;
}

.message-stack {
  display: grid;
  gap: 10px;
}

.message-row {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--line);
}

.message-row.outbound {
  justify-self: start;
  background: #e8f5ee;
  border-color: rgba(35, 113, 79, 0.18);
}

.message-row.inbound {
  justify-self: end;
  background: #ffffff;
  border-color: rgba(118, 95, 239, 0.22);
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.message-meta span {
  color: var(--muted);
  font-size: 12px;
}

.message-content a {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.message-copy-btn {
  display: inline-grid;
  place-items: center;
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.message-copy-btn:hover {
  background: rgba(105, 108, 255, 0.1);
  color: var(--violet);
}

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 44px;
  min-height: 20px;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #70809c;
  animation: typingPulse 1s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.16s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.32s;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5 {
  margin-bottom: 0;
}

.markdown-body p + p,
.markdown-body p + ul,
.markdown-body p + ol,
.markdown-body ul + p,
.markdown-body ol + p,
.markdown-body h3 + p,
.markdown-body h4 + p,
.markdown-body h5 + p {
  margin-top: 8px;
}

.markdown-body ul {
  padding-left: 18px;
}

.markdown-body ol {
  padding-left: 22px;
}

.markdown-body li + li {
  margin-top: 4px;
}

.markdown-body code {
  padding: 2px 5px;
  background: rgba(15, 23, 42, 0.06);
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 0.92em;
}

.markdown-body a {
  color: var(--blue);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.raw-details {
  margin-top: 10px;
}

.raw-details summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 700;
}

.raw-details[open] summary {
  margin-bottom: 8px;
}

.raw-details pre {
  max-height: 260px;
  overflow: auto;
  padding: 12px;
  background: #111827;
  color: #e5e7eb;
  border-radius: 8px;
  white-space: pre-wrap;
}

.chat-log {
  min-height: 56px;
  display: grid;
  gap: 10px;
  align-content: start;
  max-height: 360px;
  overflow: auto;
  background: var(--surface-muted);
  border-radius: 8px;
  padding: 12px;
}

.floating-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 60;
  display: none;
  min-width: 184px;
  padding: 8px;
  background: #ffffff;
  border: 1px solid rgba(216, 222, 232, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow-menu);
}

.panel-header > .panel-menu-btn + .floating-menu {
  right: 0;
  top: 44px;
}

.floating-menu.open {
  display: grid;
  gap: 4px;
  animation: menuIn 0.14s ease-out;
}

.floating-menu button {
  width: 100%;
  min-height: 34px;
  padding: 8px 10px;
  background: transparent;
  color: #344054;
  text-align: left;
  box-shadow: none;
  transform: none;
}

.floating-menu button:hover {
  background: var(--violet-soft);
  color: var(--violet);
}

.floating-menu button:disabled,
.floating-menu button[aria-disabled="true"] {
  color: #98a2b3;
  cursor: not-allowed;
  opacity: 0.58;
}

.floating-menu button:disabled:hover,
.floating-menu button[aria-disabled="true"]:hover {
  background: transparent;
  color: #98a2b3;
}

.menu-user {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--line);
}

.menu-user strong,
.menu-user span {
  display: block;
  overflow-wrap: anywhere;
}

.menu-user span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.toast-region {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100;
  display: grid;
  gap: 10px;
  width: min(320px, calc(100vw - 32px));
}

.toast {
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid rgba(216, 222, 232, 0.9);
  border-left: 4px solid var(--violet);
  border-radius: 8px;
  box-shadow: var(--shadow-menu);
  animation: toastIn 0.18s ease-out;
}

.toast.success {
  border-left-color: var(--success);
}

.toast.danger {
  border-left-color: var(--danger);
}

.toast.leaving {
  animation: toastOut 0.2s ease-in forwards;
}

.unsaved-indicator {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent);
  border-radius: 999px;
  color: var(--warning);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.unsaved-indicator[hidden] {
  display: none;
}

.knowledge-create-result .notice {
  display: grid;
  gap: 8px;
}

.knowledge-create-cta {
  margin-top: 4px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes typingPulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@keyframes skeleton {
  to {
    background-position: -220% 0;
  }
}

@keyframes menuIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .menu-item:hover,
  button:hover,
  .secondary-action:hover,
  .ghost-action:hover,
  .icon-action:hover {
    transform: none !important;
  }

  .skeleton-block {
    animation: none !important;
    background-position: 0 0 !important;
  }

  .floating-menu.open,
  .toast,
  .toast.leaving,
  .typing-indicator,
  .typing-indicator span {
    animation: none !important;
  }

  .image-crop-stage {
    transition: none !important;
  }
}

@media (min-width: 761px) and (max-width: 1100px) {
  body.is-authenticated .container {
    width: 100%;
    padding-inline: 14px;
  }

  .workspace-shell {
    grid-template-columns: 216px minmax(0, 1fr);
    gap: 12px;
  }

  .workspace-shell.menu-collapsed {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .side-menu {
    padding-inline: 10px;
  }

  .workspace-shell.menu-collapsed .side-menu {
    padding-inline: 8px;
  }

  .brand-block {
    padding-inline: 4px;
  }

  .workspace-topbar {
    top: 12px;
  }

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

  .user-cluster {
    justify-content: space-between;
  }

  .panel {
    padding: 16px;
  }

  .panel-header {
    flex-wrap: wrap;
  }

  .knowledge-create-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .knowledge-list-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .knowledge-list-controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .knowledge-list-controls select {
    min-width: 0;
  }

  .user-list-toolbar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .conversation-item,
  .knowledge-asset-row,
  .user-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .conversation-item-head-row,
  .knowledge-asset-head,
  .user-row-head {
    display: none;
  }

  .conversation-item > div::before,
  .knowledge-asset-row > div::before,
  .user-row > div::before {
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    content: attr(data-label);
  }

  .conversation-select-btn,
  .knowledge-asset-title-cell,
  .user-row > div:nth-child(2) {
    grid-column: 1 / -1;
  }

  .conversation-row-actions,
  .knowledge-row-actions,
  .user-row-actions {
    justify-content: flex-start;
    justify-self: start;
  }

  .bulk-action-bar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .bulk-action-bar .inline-actions {
    flex-wrap: wrap;
  }

  .table-wrap,
  .result-surface {
    max-width: 100%;
  }
}

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

  .workspace-shell.menu-collapsed {
    grid-template-columns: 1fr;
  }

  .workspace-shell.menu-collapsed .brand-block > div:last-child,
  .workspace-shell.menu-collapsed .menu-heading {
    display: block;
  }

  .workspace-shell.menu-collapsed .menu-item {
    display: flex;
    padding: 11px 12px;
    gap: 12px;
    min-height: auto;
  }

  .workspace-shell.menu-collapsed .menu-item .menu-label {
    display: block;
  }

  .side-menu {
    position: static;
    min-height: auto;
  }

  .menu-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace-header,
  .panel-header,
  .user-cluster {
    align-items: stretch;
    flex-direction: column;
  }

  #cache-section {
    padding: 18px 16px 20px;
  }

  #knowledge-create-section {
    padding: 18px 16px 20px;
  }

  #knowledge-create-section .panel-header {
    margin-bottom: 16px;
    padding-bottom: 14px;
  }

  #company-section,
  #widget-section,
  #knowledge-section {
    padding: 18px 16px 20px;
  }

  #knowledge-section .knowledge-search-box > button {
    width: 100%;
  }

  #cache-section .panel-header {
    margin-bottom: 16px;
    padding-bottom: 14px;
  }

  #cache-section .panel-tools,
  #cache-clear-btn {
    width: 100%;
  }

  .customer-dashboard-scope {
    padding: 18px 16px 20px;
  }

  .customer-dashboard-scope .panel-header {
    margin-bottom: 6px;
    padding-bottom: 14px;
  }

  .customer-dashboard-scope .panel-header > .pill {
    align-self: flex-start;
  }

  .customer-dashboard-scope .scope-summary {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 11px 0;
  }

  .customer-dashboard-scope .dashboard-cta-list {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .knowledge-create-grid {
    gap: 10px;
    margin-bottom: 12px;
  }

  .knowledge-create-card {
    padding: 14px;
  }

  .knowledge-create-head {
    min-height: 0;
  }

  .knowledge-create-result .knowledge-create-cta {
    grid-template-columns: 1fr;
  }

  .cache-options {
    grid-template-columns: 1fr;
  }

  .workspace-topbar {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
  }

  .topbar-actions {
    justify-content: flex-end;
  }

  .metric-strip,
  .workspace-grid,
  .form-grid,
  .summary-grid,
  .compact-summary,
  .knowledge-create-grid,
  .knowledge-workbench,
  .chat-test-layout {
    grid-template-columns: 1fr;
  }

	  .knowledge-list-toolbar,
	  .knowledge-list-controls {
	    align-items: stretch;
	    flex-direction: column;
	  }

	  .user-list-toolbar,
	  .user-row,
	  .conversation-list-toolbar,
	  .conversation-item {
	    grid-template-columns: 1fr;
	  }

	  .bulk-action-bar,
	  .bulk-action-bar .inline-actions {
	    align-items: stretch;
	    flex-direction: column;
	  }

	  .user-row-head,
	  .conversation-item-head-row {
	    display: none;
	  }

	  .user-row > div::before,
	  .conversation-item > div::before {
	    display: block;
	    margin-bottom: 3px;
	    color: var(--muted);
	    font-size: 11px;
	    font-weight: 800;
	    text-transform: uppercase;
	    content: attr(data-label);
	  }

	  .user-row-actions,
	  .conversation-row-actions {
	    justify-content: flex-start;
	    justify-self: start;
	  }

	  .knowledge-asset-head {
	    display: none;
	  }

  .knowledge-asset-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .knowledge-asset-row > div::before {
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    content: attr(data-label);
  }

  .knowledge-row-actions {
    justify-content: flex-start;
  }

  .conversation-detail-head {
    flex-direction: column;
  }

  .span-2 {
    grid-column: span 1;
  }

  .inline-actions {
    flex-direction: column;
  }

  .chat-test-actions {
    flex-direction: column;
  }

  .inline-actions button,
  .chat-test-actions button,
  .secondary-action,
  .ghost-action {
    width: 100%;
  }
}
