:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --text: #1a2332;
  --muted: #6b7887;
  --line: #e6eaf1;
  --accent: #206bc4;
  --accent-strong: #1a56a3;
  --accent-soft: rgb(32 107 196 / 10%);
  --danger: #b42318;
  --ok: #138a46;
  --soft: #eef1f7;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --control-height: 38px;
  --focus-ring: 0 0 0 3px rgb(32 107 196 / 18%);
  --shadow-sm: 0 3px 12px rgb(15 23 42 / 5%);
  --shadow: 0 10px 30px rgb(15 23 42 / 7%);
}

/* Dark mode — toggled by app.js's themeToggleButton (persisted to
   localStorage, applied pre-paint by theme-init.js). Deliberately scoped to
   the same core tokens the light theme is built from (--bg/--panel/--text/
   --muted/--line/--accent/--accent-strong/--danger/--ok/--soft), which
   cascade through every `var(--...)` use already in this file — both the
   legacy shell and every React module read the same stylesheet, so one
   attribute on <html> re-themes all of it with no per-module work. This is
   a best-effort pass, not a pixel-perfect audit: a handful of badge/status
   chips still use their own fixed pastel colors (readable either way, just
   not theme-reactive) rather than every one of this file's ~250 remaining
   one-off hex colors being individually retuned. */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1420;
  --panel: #171d2b;
  --text: #e6e9f0;
  --muted: #8b95a7;
  --line: #2a3244;
  --accent: #4c8dea;
  --accent-strong: #6fa4f0;
  --accent-soft: rgb(76 141 234 / 14%);
  --danger: #f2726c;
  --ok: #4fd88c;
  --soft: #1e2536;
  --focus-ring: 0 0 0 3px rgb(76 141 234 / 30%);
}

[data-theme="dark"] body {
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #eef2f9 0, var(--bg) 220px);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: clamp(12px, 2vw, 20px);
}

.toast-region {
  position: fixed;
  z-index: 1000;
  top: 18px;
  right: 18px;
  max-width: 520px;
  border: 1px solid #f0aaa2;
  border-radius: 8px;
  padding: 12px 16px;
  color: #7a271a;
  background: #fff2f0;
  box-shadow: var(--shadow);
}

.toast-region[hidden] {
  display: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  min-width: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.theme-toggle-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  min-height: var(--control-height);
  padding: 0;
  font-size: 16px;
  line-height: 1;
}

.user-badge {
  color: var(--muted);
  background: #eef7f5;
  border: 1px solid #cfe5df;
  border-radius: 999px;
  padding: 8px 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Shell chrome — layered on top of the app-wide Tabler-inspired tokens
   above (--accent/--line/--soft etc. already reflect the new palette
   everywhere); these rules just give the persistent header its own
   card/pill treatment instead of restating colors that come from :root. */
.topbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
}

.topbar h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.topbar .app-version {
  font-size: 11.5px;
  font-weight: 600;
}

.topbar #statusLine {
  font-size: 11.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar #statusLine::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #2fb344;
  box-shadow: 0 0 0 3px rgb(47 179 68 / 15%);
  flex-shrink: 0;
}

.topbar .view-tabs {
  border: none;
  background: var(--soft);
  border-radius: 9px;
}

.topbar .view-tab {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  border-radius: 6px;
}

.topbar .view-tab:hover:not(.active) {
  background: rgb(255 255 255 / 65%);
  color: var(--text);
}

.topbar .view-tab.active {
  background: var(--panel);
  color: var(--accent);
  box-shadow: 0 1px 2px rgb(20 40 80 / 10%);
}

.topbar .user-badge {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 600;
  font-size: 12.5px;
}

.topbar #logoutButton,
.topbar #refreshButton {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
}

.topbar #logoutButton:hover:not(:disabled),
.topbar #refreshButton:hover:not(:disabled) {
  background: var(--soft);
  border-color: var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
}

.app-version {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.version-signature {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
}

.app-version-signature {
  margin-top: 2px;
}

.changelog-content {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: inherit;
  line-height: 1.6;
}

h2 {
  font-size: 18px;
}

#statusLine {
  color: var(--muted);
  margin-top: 6px;
}

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-md);
  min-height: var(--control-height);
  padding: 7px 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease, color 150ms ease;
}

button:hover:not(:disabled) {
  background: var(--accent-strong);
}

button.secondary {
  background: var(--panel);
  color: var(--text);
  border-color: var(--line);
}

button.secondary:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #c5ced8;
}

button.danger-action {
  background: var(--panel);
  color: var(--danger);
  border-color: #f3c6c1;
}

button.danger-action:hover:not(:disabled) {
  color: #912018;
  background: #fff2f0;
  border-color: #e9a59e;
}

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

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.admin-only[hidden],
.support-only[hidden],
.whatsapp-manage-only[hidden] {
  display: none !important;
}

/* Legacy module containers use display:grid, which would otherwise override
   the hidden attribute set by syncReactModule() while a React module owns
   the view. */
.configuration-center[hidden],
.admin-page[hidden],
.notes-layout[hidden],
.kb-layout[hidden],
.integration-grid[hidden] {
  display: none !important;
}

.panel,
.content {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.panel,
.content {
  padding: 14px;
}

.settings-panel {
  width: 100%;
}

.configuration-center {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.configuration-nav {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 6px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.configuration-nav-title {
  display: grid;
  gap: 2px;
  margin-bottom: 8px;
  padding: 4px 6px 10px;
  border-bottom: 1px solid var(--line);
}

.configuration-nav-item {
  justify-content: flex-start;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--text);
  background: transparent;
  border-color: transparent;
  border-radius: 8px;
  text-align: left;
}

.configuration-nav-item:hover,
.configuration-nav-item:focus-visible {
  background: var(--soft);
  border-color: var(--line);
}

.configuration-nav-item.active {
  color: var(--accent-strong);
  background: #e8f3f1;
  border-color: #b7ddd7;
}

.configuration-main {
  min-width: 0;
}

.configuration-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  padding: 16px;
  background: rgba(246, 248, 251, .94);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(8px);
}

.configuration-header h2 {
  margin: 0;
}

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

.configuration-breadcrumb span + span::before {
  content: "/";
  margin-right: 8px;
  color: #94a3b8;
}

.configuration-content,
.configuration-section {
  display: grid;
  gap: 14px;
}

.configuration-section[hidden] {
  display: none;
}

.config-page-stack {
  display: grid;
  gap: 14px;
}

.config-section-header,
.section-title {
  align-items: flex-start;
}

.config-section-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.config-section-header h2,
.section-title h2 {
  margin-bottom: 2px;
}

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

.config-info-card {
  padding: 13px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.config-info-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.config-info-card strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.configuration-section[data-config-section-panel="operations"] .settings-panel {
  padding: 18px 16px;
}

.configuration-section[data-config-section-panel="operations"] .config-info-grid {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  margin-top: 14px;
}

.configuration-section[data-config-section-panel="operations"] .config-info-card {
  min-height: 72px;
}

.robot-management-layout {
  display: grid;
  gap: 14px;
}

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

.creatable-field input {
  flex: 1;
}

.robot-assets-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(4, minmax(150px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.robot-assets-table table {
  min-width: 1280px;
}

.robot-import-form {
  max-width: 760px;
}

.robot-import-result {
  margin-top: 8px;
}

.import-history-placeholder {
  margin-top: 14px;
  padding: 14px;
  background: var(--soft);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
}

.import-history-placeholder p {
  margin: 4px 0 0;
}

.organization-management-layout {
  display: grid;
  gap: 14px;
}

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

.organization-summary > div {
  padding: 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

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

.organization-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.organization-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1.5fr) repeat(3, minmax(160px, 1fr));
  gap: 10px;
}

.organization-table table {
  min-width: 900px;
}

.operational-config-grid {
  display: grid;
  gap: 14px;
}

.config-rule-grid,
.enabled-integrations-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.config-rule-card,
.enabled-integration-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.config-rule-card .badge,
.enabled-integration-card .badge {
  width: fit-content;
}

.config-rule-card h3,
.enabled-integration-card h3 {
  margin: 0;
}

.config-rule-card p,
.enabled-integration-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

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

.integration-config-card {
  align-content: start;
}

.integration-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.integration-modal-panel {
  max-width: 640px;
}

.wide-modal-panel {
  width: min(1120px, calc(100vw - 32px));
  max-width: 1120px;
}

.integration-enable-row {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
}

.config-placeholder-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.config-placeholder-list span {
  padding: 8px 10px;
  color: var(--muted);
  background: var(--soft);
  border: 1px dashed var(--line);
  border-radius: 999px;
  font-size: 13px;
}

.enabled-integration-card dl {
  display: grid;
  gap: 8px;
  margin: 4px 0 0;
}

.enabled-integration-card dl div {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 10px;
}

.enabled-integration-card dt {
  color: var(--muted);
  font-size: 12px;
}

.enabled-integration-card dd {
  margin: 0;
  font-size: 13px;
}

.changelog-preview {
  max-height: 360px;
  overflow: auto;
}

.session-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  margin-top: 12px;
}

.session-actions button {
  min-height: 40px;
  white-space: nowrap;
}

.notes-layout {
  display: grid;
  grid-template-columns: 220px 340px minmax(0, 1fr);
  gap: 14px;
  min-height: 72vh;
}

.notes-sidebar,
.notes-list-panel,
.notes-editor-panel {
  min-width: 0;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.notes-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notes-sidebar h2 {
  margin: 0 0 8px;
}

.notes-nav-section {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.notes-nav-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.notes-nav-list {
  display: grid;
  gap: 6px;
}

.small-text {
  font-size: 12px;
}

.notes-filter {
  justify-content: flex-start;
  color: var(--text);
  background: transparent;
  border-color: transparent;
}

.notes-filter:hover,
.notes-filter:focus-visible,
.notes-filter.active {
  color: var(--accent-strong);
  background: #e8f3f1;
  border-color: #b7ddd7;
}

.notes-list-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.notes-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.notes-list {
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
}

.note-list-skeleton {
  height: 74px;
  border-radius: 10px;
  background: linear-gradient(90deg, #eef2f7, #f8fafc, #eef2f7);
  background-size: 200% 100%;
  animation: notes-skeleton 1.2s ease-in-out infinite;
}

.note-list-skeleton.short {
  height: 54px;
}

@keyframes notes-skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.notes-empty-state {
  display: grid;
  gap: 4px;
  justify-items: start;
}

.notes-empty-state span {
  color: var(--muted);
  font-size: 12px;
}

.note-list-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 11px;
  color: var(--text);
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: left;
}

.note-list-item:hover,
.note-list-item:focus-visible,
.note-list-item.active {
  background: var(--panel);
  border-color: var(--accent);
}

.note-list-item span,
.note-list-item small {
  color: var(--muted);
  font-size: 12px;
}

.note-list-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.note-list-tag {
  padding: 2px 6px;
  color: var(--accent-strong);
  background: #e8f3f1;
  border-radius: 999px;
  font-size: 11px;
}

.notes-editor-panel {
  display: grid;
}

.note-editor-form {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(260px, 1fr) auto;
  gap: 12px;
}

.note-editor-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.note-save-status {
  margin: 0 auto 0 0;
  font-size: 12px;
}

.notes-back-button {
  display: none;
}

.note-editor-meta {
  display: grid;
  grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
  gap: 10px;
}

.note-editor-meta label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.note-tags-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.note-title-input {
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 8px 0;
  font-size: 28px;
  font-weight: 700;
}

.note-format-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
}

.note-format-toolbar button {
  padding: 6px 9px;
  color: var(--text);
  background: var(--panel);
  border-color: var(--line);
  font-size: 12px;
}

.note-format-toolbar button:hover,
.note-format-toolbar button:focus-visible {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.note-content-input {
  min-height: 360px;
  resize: vertical;
  line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.note-attachments-section {
  display: grid;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.note-upload-button {
  cursor: pointer;
  font-size: 12px;
}

.note-attachments-list {
  display: grid;
  gap: 8px;
}

.note-attachment-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
}

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

.note-attachment-card small {
  color: var(--muted);
  font-size: 12px;
}

.note-attachment-preview {
  width: 72px;
  height: 54px;
  padding: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.note-attachment-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.note-attachment-icon {
  display: grid;
  place-items: center;
  width: 72px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-size: 24px;
}

.note-attachment-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.kb-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 14px;
  min-height: calc(100vh - 200px);
}

.kb-list-panel,
.kb-editor-panel {
  min-width: 0;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.kb-list-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
}

.kb-toolbar {
  display: grid;
  gap: 8px;
}

.kb-documents-list {
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
}

.kb-editor-form {
  display: grid;
  grid-template-rows: auto auto minmax(360px, 1fr);
  gap: 12px;
  height: 100%;
}

.kb-editor-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.kb-save-status {
  margin: 0 auto 0 0;
  font-size: 12px;
}

.kb-back-button {
  display: none;
}

.kb-editor {
  position: relative;
  min-height: 420px;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.session-logs {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.session-logs > div {
  display: grid;
  grid-template-columns: minmax(120px, auto) minmax(160px, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.session-logs span,
.session-logs time {
  color: var(--muted);
  font-size: 12px;
}

.channels-workspace {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.channel-sidebar {
  --channel-sidebar-all-height: 42px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
  background: var(--panel);
}

/* Sits below the pinned "All channels" row (see .channel-sidebar-all) as its
   own sticky header. isolation+will-change force this onto its own paint
   layer so Chrome repaints it cleanly on scroll instead of a frame behind,
   which otherwise briefly shows the row it's covering through it. */
.channel-sidebar-group-label {
  position: sticky;
  top: var(--channel-sidebar-all-height);
  z-index: 1;
  padding: 10px 8px 4px;
  color: var(--muted);
  background: var(--panel);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  isolation: isolate;
  will-change: transform;
}

.channel-sidebar-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 8px 8px 8px 10px;
  text-align: left;
  background: transparent;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  min-height: 0;
  cursor: pointer;
}

.channel-sidebar-item:hover {
  background: var(--soft);
}

.channel-sidebar-item.active {
  background: rgb(15 118 110 / 10%);
  border-left-color: var(--accent);
}

/* Genuinely pinned at the top now (previously just first-in-flow, so it
   scrolled away like any other row despite the "pinned entry" comment on
   ChannelSidebar). Sits above .channel-sidebar-group-label (lower z-index),
   which offsets its own sticky `top` by --channel-sidebar-all-height so the
   two don't overlap. */
.channel-sidebar-all {
  position: sticky;
  top: 0;
  z-index: 2;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  min-height: var(--channel-sidebar-all-height);
  font-weight: 600;
  margin-bottom: 4px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  isolation: isolate;
  will-change: transform;
}

/* .channel-sidebar-item.active uses a 10%-alpha teal wash, which is fine for
   an ordinary (non-sticky) row but let the rows scrolling underneath this
   sticky one show through at ~90% strength — the actual "ghost text" bug.
   Same specificity as .channel-sidebar-item.active (two classes each), so
   source order (this rule comes later) makes it win; opaque tint matches the
   solid active color already used for .configuration-nav-item.active. */
.channel-sidebar-all.active {
  background: #e8f3f1;
}

.channel-sidebar-item-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.channel-sidebar-item-head time {
  flex: none;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.channel-sidebar-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.channel-sidebar-preview {
  flex: 1;
  min-width: 0;
}

.channel-sidebar-item-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.channel-sidebar-preview {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.channel-sidebar-badge {
  flex: none;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #d64545;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.channels-thread-pane {
  min-width: 0;
}

.channels-mobile-back {
  display: none;
  margin-bottom: 10px;
}

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

.channel-header-info {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.channel-header-customer {
  color: var(--muted);
  font-size: 13px;
}

/* Header action chips: quieter than primary buttons so the channel title
   stays the visual anchor; the active state marks the Media toggle. */
.channel-header-chip {
  flex: none;
  min-height: 30px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-strong);
  background: rgb(15 118 110 / 8%);
  border: 1px solid rgb(15 118 110 / 25%);
  border-radius: 999px;
}

.channel-header-chip:hover:not(:disabled) {
  color: #fff;
}

.channel-header-chip.active {
  color: #fff;
  background: var(--accent);
}

.channel-header-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 30px;
  min-height: 30px;
  padding: 0;
  color: var(--accent-strong);
  background: rgb(15 118 110 / 8%);
  border: 1px solid rgb(15 118 110 / 25%);
  border-radius: 999px;
}

.channel-header-icon:hover:not(:disabled) {
  color: #fff;
}

/* Standalone single-row filter bar (deliberately NOT .case-toolbar: its
   n-column grid + display:contents date group breaks with this item count). */
.channels-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.channels-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.channels-toolbar label > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.channels-toolbar-content {
  flex: 0 0 130px;
}

.channels-toolbar-search {
  flex: 1 1 220px;
  min-width: 180px;
}

.channels-toolbar-date {
  flex: 0 1 205px;
  min-width: 170px;
}

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

  .channels-workspace[data-mobile-view="list"] .channels-thread-pane {
    display: none;
  }

  .channels-workspace[data-mobile-view="thread"] .channel-sidebar {
    display: none;
  }

  .channels-workspace[data-mobile-view="thread"] .channels-mobile-back {
    display: inline-flex;
  }
}

.channel-feed-shell {
  position: relative;
}

.channel-feed {
  display: grid;
  gap: 10px;
  max-height: clamp(420px, calc(100vh - 270px), 720px);
  min-height: 420px;
  overflow: auto;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(37, 211, 102, 0.06), rgba(18, 140, 126, 0.07)),
    #edf5f1;
  border: 1px solid var(--line);
  border-radius: 12px;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.channel-new-messages {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 14px;
  min-height: 38px;
  transform: translateX(-50%);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.2);
}

.channel-new-messages[hidden] {
  display: none;
}

.channel-day-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0;
  color: var(--muted);
  font-size: 12px;
}

.channel-day-separator::before,
.channel-day-separator::after {
  content: "";
  flex: 1;
  border-top: 1px solid rgb(15 23 42 / 10%);
}

.channel-day-separator span {
  flex: none;
  padding: 2px 10px;
  background: rgb(255 255 255 / 70%);
  border-radius: 999px;
}

.channel-message {
  display: flex;
}

.channel-message.from-me {
  justify-content: flex-end;
}

.channel-bubble {
  max-width: min(720px, 78%);
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px 12px 12px 3px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
  overflow-wrap: anywhere;
}

.channel-message.from-me .channel-bubble {
  background: #dcf8c6;
  border-radius: 12px 12px 3px 12px;
}

.channel-message-head {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 6px;
}

.channel-message-head span,
.channel-bubble time {
  color: var(--muted);
  font-size: 12px;
}

.channel-bubble p {
  margin: 8px 0 4px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.channel-bubble-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.channel-reply-action {
  min-height: 0;
  padding: 2px 8px;
  color: var(--muted);
  font-size: 12px;
  background: transparent;
  border: 0;
}

.channel-reply-action:hover {
  color: var(--accent);
  background: transparent;
}

.channel-quote-preview {
  display: flex;
  grid-column: 1 / -1;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  padding: 6px 10px;
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--soft);
}

.channel-quote-preview-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 12px;
}

.channel-quote-preview-body span {
  overflow: hidden;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.channel-quote-preview-dismiss {
  flex: none;
  min-height: 0;
  padding: 0 6px;
  color: var(--muted);
  background: transparent;
  border: 0;
  font-size: 16px;
}

.channel-case-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
}

.channel-case-link {
  min-height: 0;
  padding: 4px 8px;
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
  font-size: 12px;
}

.channel-case-info .badge {
  min-height: 0;
  padding: 3px 8px;
  font-size: 11px;
}

.channel-case-assignee {
  color: var(--muted);
  font-size: 12px;
}

.channel-media {
  display: block;
  overflow: hidden;
  max-width: 360px;
  padding: 0;
  border-radius: 10px;
  border: 0;
  background: #0f172a;
  cursor: pointer;
}

.channel-media img,
.channel-media video {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: contain;
}

.channel-reply-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.channel-reply-form textarea {
  grid-column: 1 / -1;
  min-height: 48px;
  resize: vertical;
}

.channel-membership-warning {
  grid-column: 1 / -1;
  margin: 0 0 4px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: #fee2e2;
  color: #b91c1c;
  font-size: 0.9em;
}

/* Messenger-style composer: one rounded bar with attach icon, an autogrowing
   textarea (height driven from JS scrollHeight) and the primary Send. Shared
   by Channels and Case Detail via components/MessageComposer.tsx. */
.message-composer {
  margin-top: 12px;
}

.channel-composer-bar {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 8px 8px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow-sm);
}

/* @-mention picker, floating just above the composer bar. */
.rc-mention-list {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  z-index: 20;
  max-height: 220px;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}

.rc-mention-list li[role="option"] {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.rc-mention-list li[role="option"].active {
  background: var(--soft);
}

.rc-mention-name {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.rc-mention-phone {
  color: var(--muted);
  font-size: 12px;
}

.channel-composer-bar:focus-within {
  box-shadow: var(--focus-ring);
}

.rc-composer-drag-active {
  border-color: var(--accent);
  border-style: dashed;
  background: var(--soft);
}

.rc-composer-drop-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 24px;
  background: rgba(15, 118, 110, 0.06);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
  z-index: 5;
}

/* Wraps the message thread/Conversation panel (Channels + Cases) so a file
   can be dropped over the whole scrollback, not just the narrow composer
   bar below it — the composer-only drop target turned out too small a
   surface in practice. Same drag-active treatment as the composer bar. */
.rc-conversation-dropzone {
  position: relative;
}

.rc-conversation-dropzone.rc-conversation-drag-active {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
  border-radius: 10px;
}

.rc-conversation-drop-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 118, 110, 0.08);
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 700;
  pointer-events: none;
  z-index: 5;
  border-radius: 10px;
}

.channel-composer-bar textarea {
  flex: 1;
  min-height: 24px;
  max-height: 160px;
  padding: 7px 4px;
  border: 0;
  background: transparent;
  resize: none;
  overflow-y: auto;
}

.channel-composer-bar textarea:focus-visible {
  box-shadow: none;
}

.channel-composer-attach {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  min-height: 38px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
}

.channel-composer-attach:hover:not(:disabled) {
  color: var(--accent-strong);
  background: var(--soft);
}

.channel-composer-send {
  flex: none;
  min-height: 38px;
  padding: 7px 18px;
  border-radius: 999px;
}

.channel-composer-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 12px;
}

.channel-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  margin-bottom: 8px;
  padding: 4px 6px 4px 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
}

.channel-attachment-chip-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Wraps the main attachment chip + any queued-file chips (2nd+ file from a
   multi-file drop) so they lay out as a row instead of the queued ones
   being invisible until they silently auto-send — see MessageComposer.tsx. */
.rc-attachment-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.rc-attachment-chip-queued {
  opacity: 0.75;
  border-style: dashed;
}

.rc-attachment-chip-queued-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.file-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.channel-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

/* Quiet pill controls under the feed: loading older messages and jumping to
   a day are secondary actions, not primary-teal ones. */
.channel-more-pill {
  min-height: 32px;
  padding: 5px 14px;
  font-size: 13px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.channel-more-pill:hover:not(:disabled) {
  color: var(--accent-strong);
  background: var(--soft);
  border-color: var(--accent);
}

.channel-jump-date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 6px 0 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.channel-jump-date input[type="date"] {
  width: 130px;
  min-height: 0;
  padding: 4px 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.channel-jump-date input[type="date"]:focus-visible {
  box-shadow: none;
}

.channel-jump-date:focus-within {
  box-shadow: var(--focus-ring);
}

.channel-jump-clear {
  min-height: 32px;
  width: 32px;
  padding: 0;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 16px;
  line-height: 1;
}

.channel-jump-clear:hover:not(:disabled) {
  color: #b42318;
  background: #fef2f2;
  border-color: #fecaca;
}

.channel-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.channel-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  max-height: clamp(420px, calc(100vh - 270px), 720px);
  overflow-y: auto;
  padding: 4px;
}

.channel-media-grid-item {
  aspect-ratio: 1;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: #e5ebf0;
}

.channel-media-grid-item img,
.channel-media-grid-item video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

#saveStatus {
  color: var(--muted);
  font-size: 13px;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
  background: var(--panel);
  padding: 8px 10px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input:not([type="checkbox"]):not([type="radio"]),
select {
  min-height: var(--control-height);
}

input:hover,
select:hover,
textarea:hover {
  border-color: #bdc8d3;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.checkbox input {
  width: auto;
}

.sla-days-field {
  display: grid;
  gap: 8px;
}

.sla-days-field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.sla-days-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sla-days-grid .checkbox {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--panel);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1.25fr) minmax(150px, .8fr) minmax(220px, 1.2fr) minmax(260px, 1.4fr) auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.toolbar label {
  min-width: 0;
}

.date-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.media-toolbar {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(130px, .7fr) minmax(150px, .8fr) minmax(220px, 1.1fr) minmax(260px, 1.3fr);
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.case-toolbar {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.case-toolbar .case-list-tabs {
  grid-column: 1 / -1;
  justify-self: start;
}

.case-toolbar .date-filters {
  display: contents;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
  background: #f3f6f8;
}

.view-tabs {
  display: flex;
  flex-wrap: wrap;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
  background: #f3f6f8;
}

.tab,
.case-scope-tab,
.case-list-tab,
.view-tab {
  border: 0;
  border-radius: var(--radius-sm);
  min-height: 34px;
  background: transparent;
  color: var(--text);
  white-space: nowrap;
}

.tab:hover:not(.active),
.case-scope-tab:hover:not(.active),
.case-list-tab:hover:not(.active),
.view-tab:hover:not(.active) {
  background: #e7edf1;
}

.tab.active,
.case-scope-tab.active,
.case-list-tab.active,
.view-tab.active {
  background: var(--accent);
  color: #fff;
}

.messages {
  display: grid;
  gap: 10px;
}

.message {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
  box-shadow: 0 4px 18px rgb(15 23 42 / 5%);
  cursor: pointer;
  min-width: 0;
}

.message.no-media {
  grid-template-columns: 1fr;
}

.message:focus-within,
.message:hover {
  border-color: #b7c8d9;
}

.message.has-unread,
.media-card.has-unread,
.case-card.has-unread {
  border-color: #f59e0b;
  box-shadow: 0 0 0 1px rgb(245 158 11 / 22%), 0 8px 22px rgb(15 23 42 / 8%);
}

.thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #eef2f5;
}

.file-link {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 7px;
  border: 1px solid var(--line);
  color: var(--accent);
  text-align: center;
  text-decoration: none;
  padding: 10px;
}

.case-media-carousel {
  position: relative;
  align-self: start;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #eef2f5;
}

.media-card > .case-media-carousel {
  aspect-ratio: 4 / 3;
  border-width: 0 0 1px;
  border-radius: 0;
}

.case-card > .case-media-carousel {
  aspect-ratio: 16 / 10;
  border-width: 0 0 1px;
  border-radius: calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px) 0 0;
}

.case-media-open {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
}

.case-media-open:hover {
  background: #e5ebf0;
}

.case-media-open img,
.case-media-open video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.case-media-nav,
.modal-gallery-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 30px;
  min-height: 30px;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 70%);
  border-radius: 999px;
  background: rgb(15 23 42 / 62%);
  color: #fff;
  transform: translateY(-50%);
}

.case-media-nav.prev,
.modal-gallery-nav.prev {
  left: 6px;
}

.case-media-nav.next,
.modal-gallery-nav.next {
  right: 6px;
}

.case-media-count,
.modal-gallery-count {
  position: absolute;
  right: 6px;
  bottom: 6px;
  z-index: 2;
  border-radius: 999px;
  padding: 3px 7px;
  background: rgb(15 23 42 / 70%);
  color: #fff;
  font-size: 12px;
}

.media-download {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgb(255 255 255 / 72%);
  border-radius: 999px;
  background: rgb(15 23 42 / 70%);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
}

.media-download:hover {
  background: var(--accent);
  color: #fff;
}

.message-body {
  min-width: 0;
}

.message-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(170px, 210px);
  gap: 12px;
  align-items: start;
}

.message-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 3px 9px;
  background: #e8f3f1;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.badge.alert {
  background: #fee4e2;
  color: var(--danger);
}

.badge.case-id {
  color: #1d4ed8;
  background: #dbeafe;
}

.badge.status-new {
  background: #eef2f5;
  color: #475467;
}

.badge.status-reviewing {
  background: #fff4d6;
  color: #8a5a00;
}

.badge.status-resolved {
  background: #dcfce7;
  color: var(--ok);
}

.badge.status-not_a_case {
  background: #f1f5f9;
  color: #475569;
}

.badge.priority-low {
  background: #ecfdf3;
  color: #027a48;
}

.badge.priority-normal {
  background: #eff6ff;
  color: #1d4ed8;
}

.badge.priority-high {
  background: #fff7ed;
  color: #c2410c;
}

.badge.priority-urgent,
.badge.sla-breached {
  background: #fee2e2;
  color: #b91c1c;
}

.badge.sla-risk {
  background: #fef3c7;
  color: #92400e;
}

.badge.sla-critical {
  background: #ffe4d5;
  color: #c2410c;
}

/* Escalation: card/modal-level pulse for cases within the critical window or
   past due, on top of the existing SLA badge color. "breached" pulses more
   strongly than "critical". Respects prefers-reduced-motion below. */
.case-card.sla-escalation-critical,
.modal-panel.sla-escalation-critical {
  border-color: #fb923c;
  animation: sla-pulse-critical 2.2s ease-in-out infinite;
}

.case-card.sla-escalation-breached,
.modal-panel.sla-escalation-breached {
  border-color: #ef4444;
  animation: sla-pulse-breached 1.4s ease-in-out infinite;
}

@keyframes sla-pulse-critical {
  0%, 100% { box-shadow: 0 0 0 1px rgb(251 146 60 / 25%), 0 8px 22px rgb(15 23 42 / 8%); }
  50% { box-shadow: 0 0 0 4px rgb(251 146 60 / 35%), 0 8px 22px rgb(15 23 42 / 8%); }
}

@keyframes sla-pulse-breached {
  0%, 100% { box-shadow: 0 0 0 1px rgb(239 68 68 / 30%), 0 8px 22px rgb(15 23 42 / 8%); }
  50% { box-shadow: 0 0 0 5px rgb(239 68 68 / 45%), 0 8px 22px rgb(15 23 42 / 8%); }
}

@media (prefers-reduced-motion: reduce) {
  .case-card.sla-escalation-critical,
  .modal-panel.sla-escalation-critical,
  .case-card.sla-escalation-breached,
  .modal-panel.sla-escalation-breached {
    animation: none;
  }

  .case-card.sla-escalation-critical,
  .modal-panel.sla-escalation-critical {
    box-shadow: 0 0 0 2px rgb(251 146 60 / 35%), 0 8px 22px rgb(15 23 42 / 8%);
  }

  .case-card.sla-escalation-breached,
  .modal-panel.sla-escalation-breached {
    box-shadow: 0 0 0 3px rgb(239 68 68 / 45%), 0 8px 22px rgb(15 23 42 / 8%);
  }
}

.badge.sla-ok,
.badge.sla-met {
  background: #dcfce7;
  color: var(--ok);
}

.badge.unread-badge {
  background: #fff3cd;
  color: #92400e;
}

.badge.waiting-badge {
  background: #fee2e2;
  color: #b91c1c;
}

.badge.unread-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  padding: 0;
  border-radius: 50%;
  background: var(--accent);
}

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

.case-card-actions {
  display: grid;
  gap: 8px;
}

.pickup-case {
  width: 100%;
}

.case-table tr.has-unread {
  background: #fffaf0;
}

.case-table tr.has-unread td:first-child {
  box-shadow: inset 3px 0 0 #f59e0b;
}

.sender,
.time {
  color: var(--muted);
  font-size: 13px;
}

.message-text {
  white-space: pre-wrap;
  line-height: 1.42;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.status-control {
  display: grid;
  gap: 5px;
  margin: 0;
}

.status-control span {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.message-status,
.case-status,
.case-priority {
  min-height: 34px;
  border-color: transparent;
  font-weight: 700;
}

.message-status.status-new,
.case-status.status-new {
  background: #eef2f5;
  color: #475467;
}

.message-status.status-reviewing,
.case-status.status-reviewing {
  background: #fff4d6;
  color: #8a5a00;
}

.message-status.status-resolved,
.case-status.status-resolved {
  background: #dcfce7;
  color: var(--ok);
}

.message-status.status-not_a_case,
.case-status.status-not_a_case {
  background: #f1f5f9;
  color: #475569;
}

.case-priority.priority-low {
  background: #ecfdf3;
  color: #027a48;
}

.case-priority.priority-normal {
  background: #eff6ff;
  color: #1d4ed8;
}

.case-priority.priority-high {
  background: #fff7ed;
  color: #c2410c;
}

.case-priority.priority-urgent {
  background: #fee2e2;
  color: #b91c1c;
}

.media-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.case-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 14px;
}

/* No overflow:hidden here — the assignee dropdown at the card's bottom edge
   must be able to spill past the card. The media area clips its own top
   corners instead (see .case-card > .case-media-carousel / -empty). */
.case-card {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: 0 5px 20px rgb(15 23 42 / 6%);
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.case-card:hover {
  border-color: #a7c5c0;
  box-shadow: 0 10px 28px rgb(15 23 42 / 11%);
  transform: translateY(-1px);
}

.case-media-empty {
  display: grid;
  place-items: center;
  align-content: center;
  aspect-ratio: 16 / 10;
  gap: 7px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
  border-radius: calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px) 0 0;
  color: #708090;
  background:
    radial-gradient(circle at 50% 35%, rgb(15 118 110 / 8%), transparent 42%),
    #f4f7f9;
  text-align: center;
}

.case-media-empty svg {
  width: 44px;
  height: 44px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.case-media-empty strong {
  color: #475467;
  font-size: 14px;
}

.case-media-empty span {
  font-size: 12px;
}

/* Flex column so the action block can pin to the card's bottom edge with
   margin-top: auto — cards in a row stretch to equal height (grid default),
   and the leftover space collects between the message text and the actions,
   keeping every card's "Assign me"/assignee row on the same baseline. */
.case-card-body {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  padding: 12px;
}

.case-card-group {
  font-size: 15px;
}

.case-card-sender,
.case-card-meta {
  color: var(--muted);
  font-size: 13px;
}

/* One line: "WhatsApp group · sender" — truncated, full value in title. */
.case-card-sender {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.case-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
}

.case-card-body p {
  display: -webkit-box;
  min-height: 40px;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* First element of the bottom-pinned action block (see .case-card-body). */
.case-relation-suggestion {
  display: grid;
  gap: 7px;
  margin-top: auto;
  border: 1px solid #f0cf65;
  border-radius: 8px;
  padding: 9px;
  background: #fff9df;
  color: #694f00;
  font-size: 12px;
}

.case-relation-suggestion button {
  width: 100%;
  color: #694f00;
  border-color: #e2bd43;
  background: var(--panel);
}

.case-card-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

/* When a merge suggestion precedes the controls, the suggestion already
   carries the bottom-pinning auto margin — keep the pair together. */
.case-relation-suggestion + .case-card-controls {
  margin-top: 3px;
}

.case-card-controls > :only-child {
  grid-column: 1 / -1;
}

.case-card-controls .pickup-case {
  align-self: end;
}

.case-card-controls .case-assignment {
  grid-column: 1 / -1;
}

.case-card-controls select {
  min-height: 36px;
}

.media-card {
  display: grid;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.media-preview {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: #eef2f5;
  overflow: hidden;
}

.media-preview:hover {
  background: #e5ebf0;
}

.media-preview img,
.media-preview video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-file {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--muted);
}

.media-card-body {
  display: grid;
  gap: 6px;
  padding: 10px;
}

.media-card-body > span,
.media-card-body time {
  color: var(--muted);
  font-size: 13px;
}

.media-card-body p {
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  max-height: 60px;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.modal[hidden] {
  display: none;
}

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

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(15 23 42 / 72%);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(1040px, 100%);
  max-height: min(860px, 92vh);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: 0 24px 80px rgb(15 23 42 / 35%);
}

.modal-close {
  position: sticky;
  top: 12px;
  float: right;
  margin: 12px;
  z-index: 2;
  background: var(--panel);
  color: var(--text);
  border-color: var(--line);
}

.modal-body {
  display: grid;
}

.modal-media {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 280px;
  background: #111827;
}

.modal-media img,
.modal-media video,
.modal-media audio {
  display: block;
  max-width: 100%;
  max-height: 72vh;
}

.modal-media audio,
.case-detail-media-main audio {
  width: min(560px, 90%);
}

.media-error {
  color: #fff;
  padding: 16px;
  text-align: center;
}

.case-modal-media {
  min-height: 420px;
}

.case-modal-media a {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

.case-modal-media .media-download {
  display: grid;
  width: 32px;
  height: 32px;
}

.case-media-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--soft);
}

.case-media-thumb {
  flex: 0 0 72px;
  width: 72px;
  height: 58px;
  min-height: 58px;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 7px;
  padding: 0;
  background: #e5ebf0;
}

.case-media-thumb.active {
  border-color: var(--accent);
}

.case-media-thumb img,
.case-media-thumb video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-meta {
  display: grid;
  gap: 8px;
  padding: 16px;
}

.lightbox-case-badge {
  cursor: pointer;
}

.lightbox-case-badge:hover {
  text-decoration: underline;
}

.modal-meta .lightbox-open-case {
  min-height: 30px;
  margin-left: auto;
  padding: 4px 12px;
  font-size: 13px;
}

.modal-meta time,
.modal-meta p {
  color: var(--muted);
}

.modal-meta p {
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.case-detail {
  display: grid;
  background: var(--soft);
}

.case-detail-modal .modal-panel {
  width: min(1320px, 100%);
  max-height: 94vh;
}

.case-detail-header {
  position: sticky;
  top: 0;
  /* Above the media overlay buttons (z-index: 3 on .media-download /
     .media-zip-download) so once the photo scrolls up underneath this
     sticky header, the header actually covers it instead of the
     same-z-index tie letting the later-in-DOM buttons paint on top —
     that's what looked like the download buttons "jumping" during scroll. */
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(200px, auto);
  gap: 18px;
  align-items: start;
  border-bottom: 1px solid var(--line);
  padding: 20px 96px 18px 24px;
  background: var(--panel);
}

.case-detail-heading {
  min-width: 0;
}

.case-detail-eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.case-detail-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  margin-top: 5px;
}

.case-detail-title-row h2 {
  font-size: 22px;
}

.case-detail-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
}

.case-detail-copy:hover {
  color: var(--accent-strong);
  background: var(--soft);
}

.case-pill-select {
  width: auto;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 24px 3px 10px;
  font-size: 12px;
}

.case-pill-group {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
}

.case-pill-group small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

/* The customer's own message — the thing the agent actually needs to read
   first — gets a visually distinct block instead of blending into muted
   meta text next to the pills/badges above and the meta grid below. */
.case-message-preview {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--soft);
}

.case-message-sender {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.case-message-preview p {
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.case-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 12px;
}

.case-meta-item {
  display: grid;
  gap: 2px;
  min-width: 0;
  max-width: 340px;
  padding-left: 16px;
  border-left: 1px solid var(--line);
}

.case-meta-item:first-child {
  padding-left: 0;
  border-left: 0;
}

.case-meta-item small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.case-meta-item strong {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.case-meta-unassigned {
  color: #92400e;
}

.case-detail-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.case-detail-header-actions button {
  flex: 0 0 auto;
  min-height: 38px;
  white-space: nowrap;
}

.case-header-pickup {
  min-width: 110px;
}

.case-detail-header-actions .case-close-action {
  min-width: 90px;
}

.case-close-action {
  background: var(--panel);
  color: var(--danger);
  border-color: #f0aaa2;
}

.case-close-action:hover {
  background: #fff2f0;
}

.case-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
  padding: 18px;
}

.case-detail-content,
.case-detail-sidebar {
  display: grid;
  min-width: 0;
  gap: 16px;
}

.case-detail-sidebar {
  position: sticky;
  top: 14px;
}

.case-content-card,
.case-sidebar-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  background: var(--panel);
  box-shadow: 0 2px 8px rgb(15 23 42 / 4%);
}

.case-content-card > .section-title,
.case-sidebar-card > .section-title {
  margin-bottom: 12px;
}

.case-sidebar-card .compact-empty {
  padding: 8px 0;
  text-align: left;
}

.portal-case-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.portal-case-row input {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.portal-case-row button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 7px 12px;
}

.portal-case-open-icon {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  color: var(--accent-strong);
  background: var(--soft);
  border-radius: 8px;
}

.portal-case-open-icon:hover {
  background: #e8f3f1;
}

.case-merge-form {
  display: grid;
  gap: 10px;
}

.portal-case-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.portal-case-actions button {
  min-height: 34px;
  padding: 7px 12px;
}

.case-detail-media {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.case-detail-media-main {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 260px;
  max-height: 460px;
  background: #111827;
}

.case-detail-media-main img,
.case-detail-media-main video,
.case-detail-media-main audio {
  display: block;
  max-width: 100%;
  max-height: 460px;
}

.media-zip-download {
  position: absolute;
  top: 6px;
  right: 44px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid rgb(255 255 255 / 72%);
  border-radius: 999px;
  background: rgb(15 23 42 / 70%);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.media-zip-download:hover {
  background: var(--accent);
}

.case-detail-media-info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 12px;
  background: linear-gradient(to top, rgb(15 23 42 / 80%), transparent);
  color: #fff;
  font-size: 12px;
  pointer-events: none;
}

.case-detail-media-count {
  flex: 0 0 auto;
  opacity: .85;
}

.case-detail-media-who {
  overflow: hidden;
  text-align: right;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.case-notes-list,
.case-note-form {
  display: grid;
  gap: 14px;
}

.case-note-timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.case-note-timeline-item:not(:last-child)::before {
  content: "";
  position: absolute;
  top: 34px;
  bottom: -14px;
  left: 16px;
  width: 2px;
  background: #e1e7ed;
}

.case-note-avatar {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid #cbd8e6;
  border-radius: 50%;
  color: #344054;
  background: #eef4fb;
  font-size: 11px;
  font-weight: 800;
}

.case-note {
  border: 1px solid #eee0a8;
  border-radius: 7px;
  background: #fffdf3;
  overflow: hidden;
}

.case-note-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #f1e7bd;
  padding: 9px 11px;
  background: #fdf6de;
}

.case-note-header strong {
  color: var(--text);
  font-size: 13px;
}

.case-note-header time {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.case-note p {
  margin: 0;
  padding: 11px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.case-note-empty {
  padding: 10px 0;
  color: var(--muted);
  font-size: 13px;
}

.case-note-form {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fafbfc;
  transition: padding 120ms ease;
}

.case-note-form textarea {
  min-height: 30px;
  border-color: transparent;
  padding: 4px 2px;
  background: transparent;
  resize: none;
  transition: min-height 120ms ease;
}

.case-note-form.expanded {
  padding: 12px;
}

.case-note-form.expanded textarea {
  min-height: 84px;
  border-color: var(--line);
  padding: 8px 10px;
  background: var(--panel);
  resize: vertical;
}

.case-note-composer-hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.case-note-composer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

.case-note-composer-actions .reply-status {
  margin-right: auto;
}

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

.status-list div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

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

.status-list strong {
  color: var(--text);
  font-size: 16px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.reply-actions {
  display: grid;
  gap: 5px;
  justify-items: end;
}

.reply-actions button {
  min-width: 86px;
}

.reply-status {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.report-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(320px, 460px);
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.range-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.range-tab {
  min-height: 34px;
  background: var(--panel);
  color: var(--text);
  border-color: var(--line);
}

.range-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

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

.report-kpi-grid.cases-kpi-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.report-kpi-card {
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 84px;
  position: relative;
  overflow: hidden;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.report-kpi-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .06);
  transform: translateY(-1px);
}

.report-kpi-clickable {
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  width: 100%;
}

.report-kpi-clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.report-kpi-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.report-kpi-card.sla-risk strong {
  color: #92400e;
}

.report-kpi-card.sla-breached strong {
  color: #b91c1c;
}

.report-kpi-card.sla-ok strong {
  color: var(--ok);
}

.report-kpi-grid.is-loading {
  opacity: .55;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.kpi-group-heading {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.report-kpi-delta {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
}

.report-kpi-delta-good {
  color: var(--ok);
}

.report-kpi-delta-bad {
  color: #b91c1c;
}

.report-kpi-delta-neutral {
  color: var(--muted);
}

.report-kpi-progress {
  display: block;
  height: 5px;
  margin-top: 8px;
  border-radius: 999px;
  background: #e5eaf0;
  overflow: hidden;
}

.report-kpi-progress i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.report-kpi-card.sla-ok .report-kpi-progress i {
  background: var(--ok);
}

.report-kpi-card.sla-risk .report-kpi-progress i {
  background: #d97706;
}

.report-kpi-card.sla-breached .report-kpi-progress i {
  background: #dc2626;
}

.sla-rate-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 110px;
  white-space: nowrap;
}

.sla-rate-track {
  flex: 1;
  height: 5px;
  min-width: 48px;
  border-radius: 999px;
  background: #e5eaf0;
  overflow: hidden;
}

.sla-rate-track i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.sla-rate-ok .sla-rate-track i {
  background: var(--ok);
}

.sla-rate-risk .sla-rate-track i {
  background: #d97706;
}

.sla-rate-breached .sla-rate-track i {
  background: #dc2626;
}

.kpi-top-risk {
  margin: -4px 0 12px;
  font-size: 13px;
}

.kpi-filter-clear {
  display: flex;
  justify-content: flex-end;
}

.report-kpi-skeleton {
  padding: 12px;
}

.report-kpi-skeleton span,
.report-kpi-skeleton strong {
  display: block;
  height: 16px;
  width: 70%;
  border-radius: 6px;
  background: #dbe3ed;
}

.report-kpi-skeleton strong {
  width: 38%;
  margin-top: 6px;
}

.loading-skeleton {
  position: relative;
  min-height: 48px;
  border-radius: 8px;
  background: linear-gradient(90deg, #eef2f6 25%, #f9fbfd 50%, #eef2f6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

.loading-block {
  min-height: 170px;
}

.summary-grid div,
.chart-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary-grid div {
  padding: 12px;
}

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

.summary-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

.reports-toolbar {
  display: grid;
  gap: 12px;
}

.report-global-filters {
  display: grid;
  gap: 12px;
}

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

.report-range-panel {
  display: grid;
  gap: 10px;
  align-items: end;
}

.report-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.report-nav-tab {
  min-height: 34px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
}

.report-nav-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.report-content-area {
  display: block;
}

#reportsView.is-refreshing .report-content-area {
  opacity: .96;
  transition: opacity 160ms ease;
}

.report-section {
  display: grid;
  gap: 12px;
}

.report-section[hidden] {
  display: none;
}

.chart-panel-content p {
  margin: 4px 0;
}

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

.chart-panel {
  min-width: 0;
  padding: 12px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.chart-panel:hover {
  border-color: #cbd5e1;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .05);
}

.bar-chart {
  display: grid;
  gap: 9px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(120px, 1.2fr) minmax(36px, auto);
  gap: 8px;
  align-items: center;
  border-radius: 6px;
  min-height: 28px;
}

.bar-row.clickable {
  cursor: pointer;
  padding: 5px;
  margin: -5px;
  transition: background-color 140ms ease, transform 140ms ease;
}

.bar-row.clickable:hover,
.bar-row.clickable:focus-visible {
  background: #f7f9fb;
  transform: translateX(2px);
}

.bar-row.clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.bar-row span {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  overflow-wrap: anywhere;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  background: #eef2f6;
  border-radius: 999px;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 160ms ease;
}

.bar-row strong {
  font-size: 13px;
  text-align: right;
}

.bar-row small {
  grid-column: 2 / -1;
  color: var(--muted);
  font-size: 12px;
}

.compact-empty {
  padding: 18px;
}

.report-table {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.report-table,
.case-table,
.team-table {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.explore-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.explore-toolbar input,
.explore-toolbar select {
  min-width: 180px;
}

.column-picker {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.column-picker summary {
  cursor: pointer;
}

.column-picker div {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 8px;
}

.column-picker label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.explore-table {
  max-height: 520px;
}

.report-table th,
.team-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  box-shadow: 0 1px 0 var(--line);
}

.table-sort,
.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
}

.table-sort {
  color: inherit;
  font-weight: 700;
}

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

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

.reports-toolbar {
  display: grid;
  gap: 10px;
}

.report-table table,
.case-table table,
.team-table table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.sla-performance-table table {
  width: max-content;
  min-width: min(100%, 520px);
}

.sla-performance-table th,
.sla-performance-table td {
  white-space: nowrap;
}

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

.report-table th,
.case-table th,
.team-table th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .035em;
  text-transform: uppercase;
  background: var(--soft);
}

.report-table td,
.case-table td,
.team-table td {
  font-size: 14px;
}

.report-table td > span,
.report-table small,
.case-table td > span,
.case-table small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
  max-width: 320px;
  overflow-wrap: anywhere;
}

.case-table,
.team-table {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.case-table select {
  min-width: 140px;
}

.case-table tbody tr {
  cursor: pointer;
}

.case-table tbody tr:hover {
  background: var(--soft);
}

.report-table tbody tr:hover,
.team-table tbody tr:hover {
  background: var(--soft);
}

.report-table tbody tr:last-child td,
.case-table tbody tr:last-child td,
.team-table tbody tr:last-child td {
  border-bottom: 0;
}

.case-actions {
  display: grid;
  gap: 8px;
  min-width: 150px;
}

.team-panel {
  margin-bottom: 14px;
}

.status-stack {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.danger-text {
  color: var(--danger);
  font-weight: 700;
}

.previous-message {
  margin-top: 14px;
  border: 1px solid #dbe7e4;
  background: #f8fbfa;
  border-radius: 8px;
  padding: 12px;
}

.thread-message {
  margin: 0;
  border: 1px solid #e4e9ef;
  background: var(--soft);
  border-radius: 10px;
  padding: 16px;
  max-height: 560px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.thread-message ul {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.previous-message ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.previous-heading {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}

.previous-item {
  position: relative;
  display: grid;
  gap: 3px;
  padding-left: 14px;
}

.thread-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
}

.thread-item.outgoing {
  grid-template-columns: minmax(0, 1fr) 34px;
}

.thread-item.selectable {
  grid-template-columns: 20px 34px minmax(0, 1fr);
}

.thread-select {
  display: grid;
  place-items: center;
  padding-top: 8px;
}

.thread-select input {
  width: 16px;
  height: 16px;
}

.thread-move-toggle {
  padding: 0;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 11px;
  text-decoration: underline;
}

.thread-move-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed #dfe5ec;
}

.thread-split-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
}

/* Same controls repeated in .section-title (next to "Conversation") once
   split mode is active, so confirming a split doesn't require scrolling down
   to the bar below the message list. */
.thread-split-bar-top {
  margin-top: 0;
  padding: 0;
  border-top: none;
}

.split-action {
  box-shadow: 0 1px 3px rgb(15 118 110 / 40%);
}

.thread-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid #d4dde6;
  border-radius: 50%;
  color: #475467;
  background: var(--panel);
  font-size: 11px;
  font-weight: 800;
}

.thread-item.outgoing .thread-avatar {
  grid-column: 2;
  color: var(--accent-strong);
  background: #dff1ed;
  border-color: #b7ddd5;
}

.thread-bubble {
  display: grid;
  gap: 6px;
  justify-self: start;
  width: fit-content;
  max-width: min(720px, 88%);
  border: 1px solid #dfe5ec;
  border-radius: 5px 12px 12px;
  padding: 9px 11px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgb(15 23 42 / 4%);
}

.thread-item.outgoing .thread-bubble {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
  border-color: #cce4de;
  border-radius: 12px 5px 12px 12px;
  background: #e8f3f1;
}

.thread-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.thread-item.outgoing .thread-meta {
  justify-content: flex-end;
}

.thread-meta strong {
  color: var(--text);
  font-size: 13px;
}

.thread-meta time {
  color: var(--muted);
  font-size: 11px;
}

.thread-content {
  display: grid;
  gap: 7px;
}

.thread-content p {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.thread-item.outgoing .thread-content p {
  color: var(--accent-strong);
}

.thread-media {
  color: var(--accent);
  font-size: 13px;
}

.conversation-media {
  display: block;
  width: min(360px, 100%);
  margin-top: 2px;
  overflow: hidden;
  border-radius: 8px;
}

.conversation-media img,
.conversation-media video {
  display: block;
  width: 100%;
  max-height: 240px;
  border-radius: 8px;
  object-fit: contain;
  background: #0f172a;
}

.conversation-media.image img {
  object-fit: cover;
  object-position: center top;
}

.conversation-media audio {
  display: block;
  width: 100%;
  max-width: 340px;
  height: 38px;
}

.attachment-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 3px 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--text);
  background: rgb(255 255 255 / 78%);
  text-decoration: none;
}

.attachment-card span {
  grid-row: 1 / 3;
  font-size: 22px;
}

.attachment-card strong {
  overflow-wrap: anywhere;
}

.attachment-card small {
  color: var(--muted);
}

.import-result {
  color: var(--muted);
  line-height: 1.5;
}

.import-result ul {
  max-height: 220px;
  margin: 8px 0 0;
  overflow: auto;
}

.case-asset-panel {
  padding: 16px;
}

.case-asset-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}

.case-asset-details div {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  background: var(--soft);
}

.case-asset-details dt {
  color: var(--muted);
  font-size: 12px;
}

.case-asset-details dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

.case-asset-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.case-asset-summary {
  display: grid;
  gap: 4px;
}

.case-asset-toggle {
  justify-self: start;
}

.robot-select-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.robot-select-form .reply-status {
  grid-column: 1 / -1;
}

.case-problem-form {
  margin-top: 12px;
}

.rc-problem-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rc-problem-item {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  background: var(--soft);
}

.rc-problem-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.rc-problem-item-note {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.rc-problem-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}

.rc-problem-item-meta time {
  color: var(--muted);
  font-size: 11px;
}

.previous-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
}

.previous-item time {
  color: var(--muted);
  font-size: 12px;
}

.previous-item p {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
  line-height: 1.5;
  background: var(--soft);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(18px, 4vw, 48px);
  background:
    radial-gradient(circle at 18% 18%, rgb(20 184 166 / 18%), transparent 34%),
    radial-gradient(circle at 84% 12%, rgb(14 165 233 / 14%), transparent 28%),
    linear-gradient(135deg, #edf7f5 0%, #f8fafc 46%, #eef4ff 100%);
}

.login-shell {
  width: min(1080px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr);
  gap: clamp(18px, 4vw, 40px);
  align-items: stretch;
}

.login-hero,
.login-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgb(203 213 225 / 72%);
  border-radius: 24px;
  box-shadow: 0 24px 70px rgb(15 23 42 / 12%);
}

.login-hero {
  min-height: 560px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 26px;
  padding: clamp(28px, 5vw, 46px);
  color: #f8fafc;
  background:
    linear-gradient(135deg, rgb(15 118 110 / 92%), rgb(15 23 42 / 96%)),
    linear-gradient(45deg, transparent 0 48%, rgb(255 255 255 / 10%) 49% 51%, transparent 52%);
}

.login-hero::before,
.login-hero::after {
  content: "";
  position: absolute;
  pointer-events: none;
  border-radius: 999px;
}

.login-hero::before {
  width: 260px;
  height: 260px;
  right: -90px;
  top: -70px;
  background: rgb(45 212 191 / 22%);
}

.login-hero::after {
  width: 170px;
  height: 170px;
  left: 12%;
  bottom: -80px;
  background: rgb(96 165 250 / 18%);
}

.login-badge {
  width: fit-content;
  border: 1px solid rgb(255 255 255 / 22%);
  border-radius: 999px;
  padding: 8px 12px;
  color: #ccfbf1;
  background: rgb(255 255 255 / 10%);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
}

.login-eyebrow {
  margin-bottom: 12px;
  color: #99f6e4;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.login-hero h1 {
  max-width: 680px;
  color: #fff;
  font-size: clamp(36px, 5.2vw, 62px);
  line-height: .96;
  letter-spacing: -.055em;
}

.login-copy {
  max-width: 560px;
  margin-top: 18px;
  color: #dbeafe;
  font-size: 17px;
  line-height: 1.65;
}

.login-feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  position: relative;
  z-index: 1;
}

.login-feature-grid article,
.login-team-card {
  border: 1px solid rgb(255 255 255 / 16%);
  background: rgb(255 255 255 / 10%);
  backdrop-filter: blur(14px);
}

.login-feature-grid article {
  display: grid;
  gap: 7px;
  border-radius: 18px;
  padding: 16px;
}

.login-feature-grid strong,
.login-team-card strong {
  color: #fff;
}

.login-feature-grid span,
.login-team-card span {
  color: #cbd5e1;
  font-size: 13px;
  line-height: 1.45;
}

.login-team-card {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(190px, .8fr) minmax(260px, 1.2fr);
  align-items: center;
  gap: 18px;
  border-radius: 22px;
  padding: 18px;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 18%);
}

.login-team-card > div:first-child {
  display: grid;
  gap: 4px;
}

.login-team-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.login-avatar {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  min-width: 0;
  overflow: hidden;
  border: 2px solid rgb(255 255 255 / 78%);
  border-radius: 18px;
  color: #064e3b;
  background: linear-gradient(135deg, #ccfbf1, #f0fdfa);
  box-shadow: 0 12px 28px rgb(0 0 0 / 22%);
  font-size: 13px;
  font-weight: 800;
  transform: rotate(-2deg);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.login-avatar:nth-child(even) {
  transform: rotate(2deg);
}

.login-avatar:hover {
  transform: translateY(-3px) rotate(0deg);
  box-shadow: 0 16px 34px rgb(0 0 0 / 28%);
}

.login-avatar-more {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid rgb(255 255 255 / 78%);
  border-radius: 18px;
  color: #0f172a;
  background: linear-gradient(135deg, #fef3c7, #ccfbf1);
  box-shadow: 0 12px 28px rgb(0 0 0 / 18%);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.login-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.login-card {
  display: grid;
  align-content: center;
  gap: 22px;
  padding: clamp(24px, 4vw, 38px);
  background: rgb(255 255 255 / 88%);
  backdrop-filter: blur(18px);
}

.login-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--accent), #22c55e, #38bdf8);
}

.login-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-card-header h2 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -.03em;
}

.login-card-header p,
.login-security-note,
#loginStatus {
  color: var(--muted);
}

.login-logo-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #0f172a);
  box-shadow: 0 12px 28px rgb(15 118 110 / 24%);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: -.04em;
}

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

#passwordStep,
#otpStep {
  display: grid;
  gap: 14px;
}

#passwordStep[hidden],
#otpStep[hidden] {
  display: none;
}

.login-panel header {
  margin-bottom: 20px;
}

.login-panel input {
  min-height: 44px;
  border-radius: 12px;
  background: var(--soft);
}

.login-panel button {
  min-height: 46px;
  border-radius: 12px;
}

.login-security-note {
  padding-top: 4px;
  font-size: 12px;
  line-height: 1.5;
}

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

  .login-hero {
    min-height: auto;
  }

  .login-feature-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .login-page {
    align-items: start;
    padding: 14px;
  }

  .login-hero,
  .login-card {
    border-radius: 18px;
  }

  .login-hero h1 {
    font-size: 34px;
  }

  .login-team-card {
    grid-template-columns: 1fr;
  }

  .login-team-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.admin-page {
  display: grid;
  gap: 14px;
}

.admin-page-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.admin-page-header h2 {
  margin: 2px 0 0;
}

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

.admin-panel {
  min-width: 0;
}

.admin-users-header-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
}

.admin-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 170px 170px;
  gap: 10px;
  margin-bottom: 12px;
}

.qr-box {
  min-height: 260px;
  overflow: auto;
  margin: 0;
  padding: 16px;
  color: #0f172a;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  line-height: 1.1;
  white-space: pre;
}

.compact-form {
  display: grid;
  grid-template-columns: 1fr 1fr 140px 130px auto;
  align-items: end;
  gap: 10px;
}

.users-list {
  display: grid;
  gap: 8px;
}

.admin-table {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  -webkit-overflow-scrolling: touch;
}

.admin-table table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

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

.admin-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: var(--soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .035em;
  text-transform: uppercase;
}

.admin-table td {
  font-size: 14px;
}

.admin-table td > span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.admin-table tbody tr:hover {
  background: var(--soft);
}

.admin-table tbody tr:last-child td {
  border-bottom: 0;
}

/* Support Shift: week navigator + agent x day grid. Mirrors .admin-table's
   bordered/scrollable shell so it reads as part of the same design system. */
.shift-week-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.shift-grid-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  -webkit-overflow-scrolling: touch;
}

.shift-grid {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

.shift-grid th,
.shift-grid td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  border-left: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.shift-grid th:first-child,
.shift-grid td:first-child {
  border-left: 0;
}

.shift-grid th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: var(--soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .035em;
  text-transform: uppercase;
  white-space: nowrap;
}

.shift-grid-agent {
  min-width: 120px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.shift-grid-cell {
  min-width: 92px;
  display: table-cell;
}

.shift-pill,
.shift-cell-empty {
  display: block;
  width: 100%;
  margin-bottom: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.shift-pill:last-child,
.shift-cell-empty:last-child {
  margin-bottom: 0;
}

.shift-pill {
  border: 1px solid transparent;
  background: #e8f3f1;
  color: var(--accent-strong);
}

.shift-pill:hover {
  background: var(--accent);
  color: #fff;
}

.shift-pill-conflict {
  border-color: #f0aaa2;
  background: #fee4e2;
  color: var(--danger);
}

.shift-pill-conflict:hover {
  background: var(--danger);
  color: #fff;
}

.shift-cell-empty {
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--muted);
}

.shift-cell-empty:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--soft);
}

.shift-cell-add {
  display: block;
  width: 100%;
  padding: 2px 8px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  cursor: pointer;
}

.shift-cell-add:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--soft);
}

/* Support Shift quick-pick modal content: preset time buttons up front,
   "Custom hours…" as the escape hatch into the full date/time form. */
.shift-quick-picker {
  display: grid;
  gap: 10px;
}

.shift-quick-options {
  display: grid;
  gap: 8px;
}

.shift-quick-options button {
  min-height: 42px;
  font-size: 14px;
}

.shift-quick-custom {
  justify-self: start;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.shift-quick-back {
  justify-self: start;
  margin-bottom: 4px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.shift-quick-back:hover {
  color: var(--accent-strong);
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge-success {
  color: #047857;
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.badge-muted {
  color: #475569;
  background: var(--soft);
  border-color: #cbd5e1;
}

.user-modal-panel {
  width: min(680px, 96vw);
}

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

.user-modal-form .checkbox-row,
.user-modal-form .inline-actions {
  grid-column: 1 / -1;
}

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

.integration-panel {
  min-width: 0;
}

.integration-panel h3 {
  margin: 0;
}

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

.subsection-title {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.inline-actions,
.check-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}

.button-link {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  border: 1px solid var(--accent);
  border-radius: 7px;
  padding: 7px 13px;
  color: #fff;
  background: var(--accent);
  text-decoration: none;
  font-size: 13px;
}

.button-link.secondary {
  color: var(--text);
  border-color: var(--line);
  background: var(--panel);
}

.integration-status,
.api-key-reveal {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--soft);
  color: var(--muted);
}

.api-key-reveal {
  border-color: #e6c75d;
  background: #fffbea;
  color: var(--text);
}

.api-key-reveal code {
  display: block;
  margin-top: 8px;
  padding: 10px;
  overflow-wrap: anywhere;
  border-radius: 6px;
  background: #17202a;
  color: #fff;
}

.integration-form fieldset {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.integration-form legend {
  color: var(--muted);
  font-size: 13px;
  padding: 0 5px;
}

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

.integration-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.integration-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--soft);
}

.integration-item p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.integration-item .inline-actions {
  justify-content: flex-end;
}

@media (max-width: 1180px) {
  .notes-layout {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .kb-layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .notes-sidebar {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .notes-sidebar > div:first-child {
    flex: 1 0 180px;
  }

  .notes-nav-section {
    min-width: 180px;
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }

  .case-detail-header {
    grid-template-columns: 1fr;
  }

  .case-detail-header-actions {
    justify-content: flex-start;
    max-width: none;
  }
}

@media (max-width: 900px) {
  .shell {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
  }

  .layout,
  .notes-layout,
  .configuration-center,
  .report-toolbar,
  .report-global-filters,
  .summary-grid,
  .report-kpi-grid.cases-kpi-grid,
  .chart-grid,
  .case-detail-header,
  .case-detail-layout,
  .admin-grid,
  .admin-toolbar,
  .config-info-grid,
  .robot-assets-toolbar,
  .organization-summary,
  .organization-toolbar,
  .config-rule-grid,
  .enabled-integrations-list,
  .user-modal-form,
  .grid-four,
  .compact-form,
  .note-editor-meta,
  .note-tags-editor,
  .note-attachment-card,
  .user-row {
    grid-template-columns: 1fr;
  }

  .case-detail-header {
    padding-right: 72px;
  }

  .case-detail-header-actions {
    justify-content: flex-start;
    max-width: none;
  }

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

  .channels-toolbar label {
    flex: 1 1 46%;
    min-width: 0;
  }

  .message-top {
    grid-template-columns: 1fr;
  }

  .status-control span {
    text-align: left;
  }

  .media-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .case-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .case-toolbar .date-filters label {
    grid-column: 1 / -1;
  }

  .notes-layout {
    min-height: auto;
  }

  .kb-layout {
    min-height: auto;
  }

  .configuration-section[data-config-section-panel="operations"] .config-info-grid {
    grid-template-columns: 1fr 1fr;
  }

  .report-filter-grid {
    grid-template-columns: 1fr 1fr;
  }

  .tabs {
    grid-column: 1 / -1;
  }

  .case-detail-sidebar {
    position: static;
  }

  .channel-feed {
    max-height: 60vh;
    min-height: 360px;
  }

  .configuration-nav,
  .configuration-header {
    position: static;
  }

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

  .configuration-nav-title {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .view-tabs {
    width: 100%;
  }

  .view-tab {
    flex: 1 1 42%;
  }

  .grid-two,
  .date-filters,
  .toolbar,
  .media-toolbar,
  .case-toolbar,
  .report-filter-grid,
  .report-range-panel,
  .message-top,
  .reply-form,
  .message {
    grid-template-columns: 1fr;
  }

  .channels-toolbar label {
    flex: 1 1 100%;
  }

  .case-gallery {
    grid-template-columns: 1fr;
  }

  .reply-actions {
    justify-items: stretch;
  }

  .thread-bubble {
    max-width: 100%;
  }

  .channel-feed {
    min-height: 320px;
    max-height: 58vh;
    padding: 12px;
  }

  .channel-bubble {
    max-width: 92%;
  }

  .channel-media,
  .conversation-media {
    max-width: 100%;
  }

  .case-detail-header {
    padding: 18px 56px 18px 16px;
  }

  .case-detail-layout {
    padding: 12px;
  }

  .case-content-card,
  .case-sidebar-card {
    padding: 12px;
  }

  .case-note-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .case-note-composer-actions button {
    width: 100%;
  }

  .configuration-section[data-config-section-panel="operations"] .config-info-grid {
    grid-template-columns: 1fr;
  }

  .session-actions button {
    width: 100%;
  }

  .notes-sidebar {
    max-height: 220px;
    overflow: auto;
  }

  .notes-toolbar,
  .note-editor-actions,
  .note-attachment-actions {
    grid-template-columns: 1fr;
  }

  .notes-editor-panel {
    display: none;
  }

  .notes-editor-open .notes-sidebar,
  .notes-editor-open .notes-list-panel {
    display: none;
  }

  .notes-editor-open .notes-editor-panel {
    display: grid;
  }

  .notes-back-button {
    display: inline-flex;
  }

  .note-title-input {
    font-size: 22px;
  }

  .note-content-input {
    min-height: 300px;
  }

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

  .kb-editor-panel {
    display: none;
  }

  .notes-editor-open .kb-list-panel {
    display: none;
  }

  .notes-editor-open .kb-editor-panel {
    display: grid;
  }

  .kb-back-button {
    display: inline-flex;
  }

  .kb-editor {
    min-height: 360px;
  }

  .modal {
    padding: 10px;
  }

  .modal-panel {
    max-height: 96vh;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
  }

  .report-nav-tab {
    width: 100%;
  }

  .configuration-nav {
    grid-template-columns: 1fr;
  }

  .admin-page-header {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  .report-kpi-card,
  .chart-panel,
  .bar-row.clickable,
  .bar-fill,
  #reportsView.is-refreshing .report-content-area {
    transition: none;
  }

  .report-kpi-card:hover,
  .bar-row.clickable:hover,
  .bar-row.clickable:focus-visible {
    transform: none;
  }
}

/* Robot Error Reports (rc-robot-error-*) */

.rc-robot-error-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 10px 0;
}

.rc-robot-error-filter-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
}

.rc-robot-error-filter-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--soft);
  margin-bottom: 12px;
}

.rc-robot-error-filter-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.rc-robot-error-filter-grid {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  margin-top: 10px;
  max-height: 160px;
  overflow-y: auto;
}

.rc-robot-error-filter-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
  font-size: 13px;
  background: var(--panel);
}

.rc-robot-error-filter-item label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.rc-robot-error-filter-item .secondary {
  padding: 2px 10px;
  min-height: 24px;
  font-size: 12px;
  border-radius: 999px;
}

.rc-robot-error-clickable-cell {
  cursor: pointer;
  transition: filter 120ms ease;
}

.rc-robot-error-clickable-cell:hover {
  filter: brightness(0.94);
}

.rc-robot-error-total-row {
  font-weight: 600;
}

/* "Robot Error CSV Upload" panel's batch progress indicator — shown while
   uploading, especially useful for a multi-file re-upload where the
   previous plain "Uploading... N%" text reset per file with no sense of
   how many files were left. */
.rc-robot-error-upload-progress {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rc-robot-error-upload-progress-label {
  font-size: 12px;
  color: var(--muted);
}

.rc-robot-error-upload-progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--soft);
  overflow: hidden;
}

.rc-robot-error-upload-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.15s ease;
}

/* "Robot Error CSV Upload" panel's upload-status table (Settings > Robot
   Errors) — flags a site with no upload in a while (or ever) using the same
   warning red already used elsewhere in the app (channel-membership-warning
   etc.), scoped to this table only via the row's own td background so it
   doesn't bleed into the shared .report-table row styling used elsewhere. */
.rc-robot-error-upload-status-stale td {
  background: #fee2e2;
  color: #b91c1c;
}

.rc-robot-error-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.rc-robot-error-popup {
  position: relative;
  background: var(--panel);
  border-radius: 10px;
  padding: 20px;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
}

.rc-robot-error-popup-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.rc-robot-error-popup-header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.rc-robot-error-popup-totals {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

.rc-robot-error-popup-totals strong {
  color: var(--text);
}

.rc-robot-error-event-group {
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.rc-robot-error-sequence-header {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.rc-robot-error-sequence-total {
  font-weight: 600;
  color: var(--text);
}

.rc-robot-error-event-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  margin: 4px 0;
}

.rc-robot-error-event-duration {
  margin-left: auto;
  padding-left: 12px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

/* Dock/Lift/Conveyor/Web Hook Delay's diagnostic detail (model/direction/
   step.../station) -- flex-basis: 100% forces it onto its own line below
   the Start/End/duration row instead of squeezing into the same one,
   since Conveyor's step/state/error/status text can run fairly long. */
.rc-robot-error-event-extra {
  flex-basis: 100%;
  font-size: 12px;
  color: var(--muted);
  padding-left: 16px;
}

.rc-robot-error-time-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.rc-robot-error-time-dot--start {
  background: #4caf50;
}

.rc-robot-error-time-dot--end {
  background: #d32f2f;
}

.rc-robot-error-timeline-line {
  width: 20px;
  height: 1px;
  background: var(--line);
  display: inline-block;
}

/* Floating overlay pinned to the map container's top-right corner (the
   library's own documented pattern), not a separate row above the map that
   ate vertical space — scroll-wheel/pinch already zoom, these buttons are
   just a compact fallback/accessibility affordance. */
.rc-robot-error-map-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rc-robot-error-map-controls button {
  width: 30px;
  height: 30px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
}

.rc-robot-error-map-controls button:hover {
  background: var(--panel);
}

.rc-robot-error-map-container {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  /* Bumped from 420px — removing the Robot Filter's search box and
     expand/collapse toggle (unnecessary at this field's real robot counts,
     typically 3-10, max ~30) freed enough vertical space to give the map
     itself more room instead. */
  height: 560px;
  cursor: grab;
  background: var(--soft);
}

.rc-robot-error-map-container:active {
  cursor: grabbing;
}

.rc-robot-error-map-marker {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transform: translate(-50%, -50%);
}

.rc-robot-error-map-marker:hover {
  width: 18px;
  height: 18px;
}

.rc-robot-error-map-marker--selected {
  width: 20px;
  height: 20px;
  border-color: #ffd700;
  border-width: 3px;
  box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.5);
}

/* Dock/Lift/Conveyor/Web Hook Delay markers: diamond instead of circle
   (rotated square, border-radius softened rather than square corners) —
   the "this is a delay, not an error" signal, independent of dot color.
   Rotated on a nested pseudo-element rather than the element itself so the
   :hover/--selected size transitions (which also apply to this modifier)
   don't fight the 45deg rotation. */
.rc-robot-error-map-marker--delay {
  border-radius: 3px;
  transform: translate(-50%, -50%) rotate(45deg);
}

.rc-robot-error-map-tooltip {
  position: absolute;
  left: 0;
  bottom: 100%;
  transform: translate(-50%, -10px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #1f2933;
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  max-width: 260px;
  white-space: normal;
  pointer-events: none;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.rc-robot-error-map-tooltip strong {
  font-size: 12px;
}

.rc-robot-error-map-tooltip span {
  color: #cbd5e1;
  font-size: 11px;
}

.rc-robot-error-map-list-extra {
  color: var(--muted);
  font-size: 12px;
}

.rc-robot-error-map-filters {
  display: flex;
  gap: 16px;
  margin: 10px 0;
}

.rc-robot-error-map-filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.rc-robot-error-map-list {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.rc-robot-error-map-list-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.5fr 0.9fr 0.9fr 0.9fr 0.9fr 0.9fr 1fr;
  gap: 8px;
  padding: 8px;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .035em;
  text-transform: uppercase;
  color: var(--muted);
}

.rc-robot-error-map-list-body {
  display: grid;
  gap: 4px;
  padding: 4px;
}

.rc-robot-error-map-list-item {
  display: grid;
  grid-template-columns: 1.5fr 0.9fr 0.9fr 0.9fr 0.9fr 0.9fr 1fr;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

.rc-robot-error-map-list-item--selected {
  border-color: var(--accent);
}

.rc-robot-journey {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rc-robot-journey-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.rc-robot-journey-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.rc-robot-journey-toolbar select {
  min-width: 320px;
}

.rc-robot-journey-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rc-robot-journey-body {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 12px;
  align-items: start;
}

.rc-robot-journey-map {
  height: 480px;
}

.rc-robot-journey-svg {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  overflow: visible;
}

.rc-robot-journey-route-ghost {
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-dasharray: 6 6;
  opacity: 0.35;
}

.rc-robot-journey-route-traveled {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
}

.rc-robot-journey-waypoint {
  stroke: white;
  stroke-width: 2;
}

.rc-robot-journey-marker {
  stroke: white;
  stroke-width: 2.5;
  filter: drop-shadow(0 0 4px rgb(0 0 0 / 35%));
}

.rc-robot-journey-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--soft);
  align-self: stretch;
}

.rc-robot-journey-card-step {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .035em;
  text-transform: uppercase;
  color: var(--muted);
}

.rc-robot-journey-card-category {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.rc-robot-journey-card-detail {
  font-size: 13px;
  color: var(--muted);
}

.rc-robot-journey-card-timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.rc-robot-journey-card-timeline-dot {
  width: 14px;
  height: 14px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: transparent;
  cursor: pointer;
}

.rc-robot-journey-card-timeline-dot.done {
  background: var(--line);
}

.rc-robot-journey-card-timeline-dot.active {
  width: 18px;
  height: 18px;
  border-width: 3px;
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.25);
}

@media (max-width: 860px) {
  .rc-robot-journey-body {
    grid-template-columns: 1fr;
  }
}

.rc-robot-error-add-map {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--soft);
  margin-bottom: 12px;
}

.rc-robot-error-add-map label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.rc-robot-error-viewing-line {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.rc-robot-error-toolbar-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 12px;
}

.rc-robot-error-toolbar-filters > label {
  min-width: 160px;
  max-width: 220px;
}

.rc-robot-error-field-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.rc-robot-error-field-picker label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  min-width: 170px;
  max-width: 240px;
}

.rc-robot-error-field-picker label:last-child {
  min-width: 110px;
  max-width: 130px;
}

.rc-robot-error-field-picker .rc-searchable-select input {
  text-overflow: ellipsis;
}

.rc-robot-error-period-selector {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rc-robot-error-period-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.rc-robot-error-period-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.rc-robot-error-period-presets {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rc-robot-error-period-preset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--control-height);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: 999px;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.rc-robot-error-period-preset:hover {
  border-color: #cbd5e1;
}

.rc-robot-error-period-preset.active {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #fff;
}

.rc-robot-error-period-range {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rc-robot-error-period-range input[type="date"] {
  height: var(--control-height);
  padding: 0 8px;
  font-size: 13px;
}

.rc-robot-error-period-range span {
  color: var(--muted);
}


.rc-robot-error-tab-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.rc-robot-error-tab-row .tabs {
  margin-bottom: 0;
}

.rc-robot-error-export-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rc-robot-error-export-controls select {
  height: 36px;
  padding: 0 10px;
}

.rc-robot-error-export-controls button {
  white-space: nowrap;
  height: 36px;
  padding: 0 14px;
}

.rc-robot-error-summary-table td:not(:first-child),
.rc-robot-error-summary-table th:not(:first-child) {
  text-align: center;
}

.rc-robot-error-internal-table td:not(:first-child),
.rc-robot-error-internal-table th:not(:first-child) {
  text-align: center;
}

/* Missions tab (2026-08-10 mission-tracking update) — summary strip above
   the table, and the three fixed outcome-badge colors (unlike category
   badges, which get their color from the admin-extensible categoryColors
   map, "Finished"/"Aborted"/"Ongoing" are a closed set, so these are
   hardcoded here rather than threaded through CATEGORY_COLORS). Reuses the
   exact Lost/Offline hex pairs so an "Aborted" mission and a "Lost" event
   badge read as the same severity language at a glance. */
.rc-robot-error-missions-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.rc-robot-error-missions-summary strong {
  color: var(--text);
}

/* The Missions/Finished/Aborted/Ongoing counts double as an outcome filter
   for the table below — plain <button>s styled to read exactly like the
   inert text they replaced until interacted with, so the strip doesn't
   suddenly look like a toolbar. */
.rc-robot-error-outcome-filter {
  border: none;
  background: none;
  padding: 2px 6px;
  margin: -2px -6px;
  border-radius: 6px;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: background-color 140ms ease;
}

.rc-robot-error-outcome-filter:hover {
  background: var(--soft);
}

.rc-robot-error-outcome-filter--active {
  background: var(--accent);
  color: #fff;
}

.rc-robot-error-outcome-filter--active strong {
  color: #fff;
}

.rc-robot-error-missions-table td:not(:first-child),
.rc-robot-error-missions-table th:not(:first-child) {
  text-align: center;
}

.rc-robot-error-operations-report-table td:not(:first-child),
.rc-robot-error-operations-report-table th:not(:first-child) {
  text-align: center;
}

.rc-robot-error-operations-report .chart-panel {
  margin: 16px 0;
}

.rc-robot-error-mtbf-hint {
  margin: 0 0 12px;
  font-size: 13px;
}

.rc-robot-error-mtbf-table {
  margin-bottom: 16px;
}

.rc-robot-error-mtbf-table td {
  vertical-align: middle;
}

.rc-robot-error-mtbf-table td:first-child {
  width: 1%;
  white-space: nowrap;
  text-align: center;
}

.rc-robot-error-mtbf-table th:last-child,
.rc-robot-error-mtbf-table td:last-child {
  width: 160px;
}

.rc-robot-error-mtbf-threshold-input {
  width: 80px;
}

.rc-robot-error-mtbf-threshold-input:disabled {
  opacity: 0.4;
}

.rc-robot-error-field-sites-actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.rc-robot-error-field-sites-form-actions {
  display: flex;
  gap: 8px;
}

.rc-robot-error-map-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.rc-robot-error-map-layer-toggles {
  width: fit-content;
}

.rc-robot-error-mission-outcome--finished {
  background: #e8f5e9;
  color: #2e7d32;
}

.rc-robot-error-mission-outcome--aborted {
  background: #fee4e2;
  color: #b42318;
}

/* Distinct from Aborted (a Mission Aborted row we actually saw) -- Failed
   is inferred (no closing row ever arrived, but the robot moved on to a
   later mission), so it gets its own amber/warning color rather than
   reusing Aborted's red, matching this app's existing amber usage
   elsewhere (e.g. the Internal Error category color). */
.rc-robot-error-mission-outcome--failed {
  background: #fff3e0;
  color: #c05e00;
}

.rc-robot-error-mission-outcome--ongoing {
  background: #eceff1;
  color: #546e7a;
}

.rc-robot-error-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  /* A 2-3 digit count (e.g. "116") was wrapping mid-number inside the pill
     once the summary table grew past a dozen category columns (admin-added
     categories) and each <td> got squeezed narrower than the badge's
     natural width. The table already scrolls horizontally
     (.report-table { overflow-x: auto }) — this just lets it actually do
     that instead of wrapping the number first. */
  white-space: nowrap;
}

.rc-robot-error-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.rc-robot-error-chip:hover {
  border-color: #cbd5e1;
}

.rc-robot-error-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.rc-robot-error-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
  flex: none;
}

/* EditableList — General Settings' list fields (WhatsApp groups, excluded
   sender lists). Reuses .portal-case-actions (add-row: input + button) and
   .admin-table (the same bordered/scrollable table Problem Catalog, Robot
   Error Codes, and Internal Error Codes registries use) as-is — only the
   height cap below is new, since a list here (e.g. dozens of excluded
   senders) can run much longer than those registries' typical row counts
   and would otherwise stretch the Settings page out indefinitely. */
.rc-editable-list {
  display: grid;
  gap: 10px;
}

.rc-editable-list-table {
  max-height: 320px;
  overflow-y: auto;
}

.rc-editable-list-table table {
  min-width: 0;
}

/* ToggleChart (Recharts-based) — "Missions per Robot" (Operations Report).
   Recharts renders its own SVG axes/bars/lines; this only styles the
   Bar/Line toggle row above it. */
.rc-toggle-chart-buttons {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.rc-toggle-chart-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.rc-toggle-chart-button:hover {
  border-color: #bdc8d3;
}

.rc-toggle-chart-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Operations Report's KPI strip — scoped shrink of the shared
   .report-kpi-card (KPITile/KPIGrid, also used by Cases/Reports/KPI
   Follow/Internal Error Details — left untouched there). 6 short-value
   tiles (counts/percentages/durations) don't need the same footprint a
   Reports KPI card with a longer label does; also widened to 6 columns so
   they sit in one row instead of wrapping to a near-empty second row. */
.summary-grid.rc-robot-error-operations-kpi {
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.summary-grid.rc-robot-error-operations-kpi .report-kpi-card {
  min-height: 56px;
  padding: 8px 10px;
}

.summary-grid.rc-robot-error-operations-kpi span {
  font-size: 11px;
}

.summary-grid.rc-robot-error-operations-kpi strong {
  margin-top: 2px;
  font-size: 16px;
}

/* Office Fun — internal-team chore tracker (see AGENTS.md Platform Modules,
   OFFICE_FUN_MODULE_ENABLED). New rc-prefixed classes per Post-Migration
   Frontend Policy; reuses .view-tab/.secondary/.date-filters/.report-table
   for pixel parity with the rest of the app instead of inventing new ones. */
.rc-office-fun-tabs {
  margin: 0 0 14px;
}

.rc-office-fun-composer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  margin-bottom: 16px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.rc-office-fun-composer-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rc-office-fun-composer-categories button.rc-office-fun-category-active {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: rgb(32 107 196 / 8%);
}

.rc-office-fun-composer-row {
  display: flex;
  gap: 8px;
}

.rc-office-fun-composer-row input {
  flex: 1;
}

.rc-office-fun-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rc-office-fun-card {
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.rc-office-fun-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.rc-office-fun-card-icon {
  font-size: 22px;
  line-height: 1;
}

.rc-office-fun-card-headline {
  flex: 1;
  min-width: 0;
}

.rc-office-fun-card-note {
  margin: 4px 0 0;
  color: var(--text);
}

.rc-office-fun-card-time {
  white-space: nowrap;
  font-size: 12px;
}

.rc-office-fun-card-confirm {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.rc-office-fun-vote-active-confirm {
  border-color: var(--ok);
  color: var(--ok);
}

.rc-office-fun-vote-active-dispute {
  border-color: var(--danger);
  color: var(--danger);
}

.rc-office-fun-card-reactions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

.rc-office-fun-reaction {
  padding: 4px 9px;
  font-size: 13px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.rc-office-fun-reaction:hover {
  border-color: var(--accent);
}

.rc-office-fun-reaction-active {
  border-color: var(--accent);
  background: rgb(32 107 196 / 10%);
}

.rc-office-fun-comment-toggle {
  padding: 4px 9px;
  font-size: 13px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
}

.rc-office-fun-comment-toggle:hover {
  color: var(--accent-strong);
}

.rc-office-fun-comments {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--line);
}

.rc-office-fun-comment {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
  font-size: 13px;
}

.rc-office-fun-comment time {
  margin-left: auto;
  font-size: 11px;
}

.rc-office-fun-comment-form {
  display: flex;
  gap: 8px;
}

.rc-office-fun-comment-form input {
  flex: 1;
}

.rc-office-fun-report {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rc-robot-error-missions-search {
  max-width: 320px;
  margin-bottom: 12px;
}

.rc-robot-error-sortable-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.rc-robot-error-sortable-th:hover {
  color: var(--accent);
}

.rc-milvus-send-row {
  margin-top: 12px;
}

.rc-milvus-badges {
  margin-bottom: 14px;
}

.rc-milvus-attachments {
  display: grid;
  gap: 6px;
}

.rc-milvus-attachments-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.rc-milvus-media-picker {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
}

.rc-milvus-attachment-mismatch {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--danger);
  border-radius: 8px;
  background: var(--soft);
}

.rc-milvus-update {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.rc-milvus-sync {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.rc-milvus-sync-result {
  margin-top: 8px;
}

.rc-milvus-sync-unmatched {
  margin: 6px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  max-height: 140px;
  overflow-y: auto;
}

/* Resolve Wizard — interaction pattern (rail + live values + cascading
   validation + review) taken from the Claude Design handoff; visuals use
   the app's own tokens/radii/typography instead of that handoff's separate
   "Industry" design system, so it stays consistent with the rest of the app. */

.rc-wizard-panel {
  width: min(1180px, 100%);
  height: min(820px, 92vh);
  max-height: min(820px, 92vh);
  padding: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.rc-wizard-rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--soft);
}

.rc-wizard-rail-header {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.rc-wizard-kicker {
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.rc-wizard-case-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  margin-top: 4px;
}

.rc-wizard-case-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.rc-wizard-steps {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 0;
}

.rc-wizard-step-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  width: 100%;
  padding: 9px 16px;
  border: none;
  border-left: 2px solid transparent;
  background: none;
  text-align: left;
  cursor: pointer;
}

.rc-wizard-step-row:disabled {
  cursor: not-allowed;
  opacity: .5;
}

.rc-wizard-step-row.current {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.rc-wizard-step-row.done:hover,
.rc-wizard-step-row.todo:not(:disabled):hover {
  background: var(--panel);
}

.rc-wizard-step-badge {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text);
}

.rc-wizard-step-row.current .rc-wizard-step-badge,
.rc-wizard-step-row.done .rc-wizard-step-badge {
  border-color: var(--accent);
  color: var(--accent);
}

.rc-wizard-step-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.rc-wizard-step-opt {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 5px;
}

.rc-wizard-step-value {
  display: block;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.rc-wizard-rail-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.rc-wizard-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.rc-wizard-content-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 26px 14px;
  border-bottom: 1px solid var(--line);
}

.rc-wizard-heading-kicker {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent);
  font-weight: 700;
}

.rc-wizard-heading h2 {
  font-size: 22px;
  margin: 4px 0 6px;
}

.rc-wizard-heading p {
  font-size: 13px;
  color: var(--muted);
  max-width: 62ch;
  margin: 0;
}

.rc-wizard-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 22px 26px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.rc-wizard-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 26px;
  border-top: 1px solid var(--line);
  background: var(--soft);
}

.rc-wizard-footer-hint {
  font-size: 12px;
  color: var(--muted);
}

.rc-wizard-footer-actions {
  display: flex;
  gap: 8px;
}

.rc-wizard-target-toggle {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.rc-wizard-target-toggle button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.rc-wizard-target-toggle button:hover {
  border-color: #bdc8d3;
}

.rc-wizard-target-toggle button.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.rc-wizard-search {
  width: 100%;
}

.rc-wizard-search-wrap {
  position: relative;
}

.rc-wizard-search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.rc-wizard-search-wrap .rc-wizard-search {
  padding-left: 34px;
}

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

.rc-wizard-robot-card {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.rc-wizard-robot-card:hover {
  border-color: var(--accent);
}

.rc-wizard-robot-card.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.rc-wizard-robot-serial {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
}

.rc-wizard-robot-selected-tag {
  display: inline-block;
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
  visibility: hidden;
}

.rc-wizard-robot-card.selected .rc-wizard-robot-selected-tag {
  visibility: visible;
}

.rc-wizard-robot-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.rc-wizard-robot-strip small {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted);
}

.rc-wizard-spec-plate {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  background: var(--soft);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.rc-wizard-spec-plate small {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted);
}

.rc-wizard-cascade {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.rc-wizard-cascade-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
}

.rc-wizard-cascade-col:last-child {
  border-right: none;
}

.rc-wizard-cascade-col-header {
  padding: 8px 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: var(--soft);
}

.rc-wizard-cascade-list {
  max-height: 280px;
  overflow-y: auto;
}

.rc-wizard-cascade-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  font-size: 13px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
}

.rc-wizard-cascade-option:hover {
  background: var(--soft);
}

.rc-wizard-cascade-option.selected {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.rc-wizard-cascade-empty {
  padding: 12px 10px;
  font-size: 12px;
  color: var(--muted);
}

.rc-wizard-search-results {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  max-height: 320px;
  overflow-y: auto;
}

.rc-wizard-search-result {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: none;
  cursor: pointer;
  color: var(--text);
}

.rc-wizard-search-result:last-child {
  border-bottom: none;
}

.rc-wizard-search-result:hover {
  background: var(--soft);
}

.rc-wizard-search-result-path {
  font-size: 12px;
  color: var(--muted);
}

.rc-wizard-field {
  display: grid;
  gap: 6px;
}

/* Groups two related Send-to-Milvus-Portal fields onto one row (Priority +
   Status, Assignee + Second assignee) instead of each stacking full-width —
   halves the step's vertical length and reads as one decision per row. */
.rc-wizard-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.rc-wizard-field-row-assignee {
  align-items: start;
}

.rc-wizard-field-row-assignee .rc-wizard-field p {
  margin: 0;
  font-size: 13px;
}

.rc-wizard-field span {
  font-size: 12px;
  color: var(--muted);
}

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

.rc-wizard-fix-card {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  background: var(--panel);
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}

.rc-wizard-fix-card:hover {
  border-color: var(--accent);
}

.rc-wizard-fix-card.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  color: var(--accent);
}

.rc-wizard-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rc-wizard-chip {
  font-size: 12px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  cursor: pointer;
  color: var(--text);
}

.rc-wizard-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.rc-wizard-chip:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.rc-wizard-reference-plate {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  background: var(--soft);
  font-size: 13px;
}

.rc-wizard-reference-plate p {
  margin: 4px 0 0;
  color: var(--muted);
}

.rc-wizard-portal-row {
  display: flex;
  gap: 10px;
}

.rc-wizard-portal-row input {
  flex: 1;
}

.rc-wizard-review-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.rc-wizard-review-row.missing {
  border-style: dashed;
  border-color: var(--accent);
}

.rc-wizard-review-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

.rc-wizard-review-value {
  display: block;
  font-size: 14px;
}

.rc-wizard-review-sub {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

/* Grid tracks size to content by default, so the lone success child would
   otherwise sit top-left at its intrinsic size instead of filling/centering
   in the panel — switch the panel itself to flex for this state instead of
   fighting CSS Grid's row-sizing to make height:100% behave. */
.rc-wizard-panel.rc-wizard-panel-done {
  display: flex;
}

/* Classification Guidance — the guide plate (Step 2) and the recommendation
   banner (Step 3) share this tinted look, the one deliberately different
   "this is advice, not a field" surface in the wizard. */
.rc-wizard-guidance-plate {
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  background: var(--accent-soft);
  display: grid;
  gap: 10px;
}

.rc-wizard-guidance-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rc-wizard-guidance-kicker {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 700;
  color: var(--accent-strong);
}

.rc-wizard-mode-tags {
  display: flex;
  gap: 6px;
}

.rc-wizard-mode-tag {
  font-size: 10px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  text-decoration: line-through;
}

.rc-wizard-mode-tag.available {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--panel);
  text-decoration: none;
}

.rc-wizard-guidance-body {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 16px;
}

.rc-wizard-guidance-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 2px;
}

.rc-wizard-guidance-value {
  font-size: 14px;
  font-weight: 600;
}

.rc-wizard-guidance-why {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.rc-wizard-recommendation-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.rc-wizard-recommendation-name {
  font-size: 17px;
  font-weight: 700;
}

.rc-wizard-guidance-selected-tag {
  visibility: visible;
  white-space: nowrap;
}

.rc-wizard-fix-card-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.rc-wizard-fix-card.recommended {
  border-color: var(--accent);
}

.rc-wizard-guide-tag {
  flex: 0 0 auto;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent-strong);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 1px 6px;
}

.rc-wizard-fix-card-examples {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.rc-wizard-justification-field {
  border: 1px dashed var(--accent);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: grid;
  gap: 8px;
}

.rc-wizard-justification-field > span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--accent-strong);
  font-weight: 700;
}

.rc-wizard-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  text-align: center;
  padding: 40px;
}

/* Problem Catalog settings — Problem Type/Fix Type guidance columns. */
.rc-catalog-description-cell {
  min-width: 220px;
  max-width: 320px;
}

.rc-catalog-description-cell textarea {
  width: 100%;
}

.rc-catalog-guidance-fields {
  display: grid;
  gap: 6px;
  min-width: 160px;
}

.rc-wizard-success-icon {
  width: 54px;
  height: 54px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  color: var(--accent);
}

