html {
  -webkit-tap-highlight-color: transparent;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --surface: #ffffff;
  --panel-surface: #ffffff;
  --panel-border: #e2e8f0;
  --sidebar-bg: #f8fafc;
  --sidebar-border: #e2e8f0;
  --bento-surface: #ffffff;
  --bento-border: #e2e8f0;
  --bento-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  --bento-shadow-hover: 0 6px 16px rgba(15, 23, 42, 0.1);
  --bento-glow: none;
  --input-bg: #ffffff;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --brand-rgb: 37, 99, 235;
  --danger-bg: #fef2f2;
  --danger-text: #b91c1c;
  --success-bg: #ecfdf5;
  --success-text: #047857;
  --success-border: #a7f3d0;
  --submenu-panel-border: rgba(0, 0, 0, 0.08);
  --nav-hover: rgba(0, 0, 0, 0.04);
  --title-icon-bg: rgba(var(--brand-rgb), 0.12);
  --chat-thread-bg: #f8f9fa;
  --chat-user-bubble: #e9eef6;
  --chat-user-border: transparent;
  --chat-assistant-bubble: transparent;
  --chat-compose-bg: #ffffff;
  --ring-track: #e2e8f0;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ec-toast-ok: #dcfce7;
  --ec-toast-ok-text: #14532d;
  --ec-toast-ok-b: #86efac;
  --ec-toast-err: #3d1a1a;
  --ec-toast-err-text: #ffebee;
  --ec-toast-err-b: #6b2e2e;
  --knowledge-bg: rgba(37, 99, 235, 0.06);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #050505;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --border: #262626;
  --border-strong: #3f3f3f;
  --surface: #0f0f0f;
  --panel-surface: #0a0a0a;
  --panel-border: #262626;
  --sidebar-bg: #0a0a0a;
  --sidebar-border: #262626;
  --bento-surface: #0a0a0a;
  --bento-border: #262626;
  --bento-shadow: 0 0 0 1px rgba(91, 156, 245, 0.08);
  --bento-shadow-hover: 0 8px 28px rgba(0, 0, 0, 0.55);
  --bento-glow: 0 0 24px rgba(91, 156, 245, 0.1);
  --input-bg: #0a0a0a;
  --accent: #5b9cf5;
  --accent-hover: #7eb0f7;
  --brand-rgb: 91, 156, 245;
  --danger-bg: #3d2020;
  --danger-text: #f0a8a8;
  --success-bg: #1a2d24;
  --success-text: #9ed5b0;
  --success-border: #2d4a38;
  --submenu-panel-border: rgba(255, 255, 255, 0.05);
  --nav-hover: rgba(255, 255, 255, 0.05);
  --title-icon-bg: rgba(91, 156, 245, 0.14);
  --chat-thread-bg: #131314;
  --chat-user-bubble: #282a2c;
  --chat-user-border: transparent;
  --chat-assistant-bubble: transparent;
  --chat-compose-bg: #1e1f20;
  --ring-track: #2a2a2a;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ec-toast-ok: #1a3d2a;
  --ec-toast-ok-text: #e8f5e9;
  --ec-toast-ok-b: #2e6b3e;
  --ec-toast-err: #3d1a1a;
  --ec-toast-err-text: #ffebee;
  --ec-toast-err-b: #6b2e2e;
  --knowledge-bg: rgba(91, 156, 245, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
}

/* Smooth theme changes on common surfaces */
body,
.site-header,
.sidebar,
.main,
.panel,
.bento-card,
.title-icon-wrap,
.field__input,
.btn,
.table th,
.table td,
.chatx-thread,
.chatx-compose,
.chatx-msg__bubble,
.chatx-budget,
.agent-tabs__tab,
.knowledge-ingest-panel,
.dropzone,
.email-config-pnav,
.email-callout,
.ec-toast {
  transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out, border-color 0.2s ease-in-out,
    box-shadow 0.2s ease-in-out;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--panel-surface);
}

.site-header__inner {
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}

.site-header__left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.site-header__right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem 1rem;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}

.site-header__theme {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.2s ease-in-out;
}

.theme-toggle:hover {
  border-color: var(--border-strong);
  color: var(--accent);
}

.theme-toggle__icon {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  stroke: currentColor;
}

.theme-toggle__icon svg {
  width: 1.1rem;
  height: 1.1rem;
}

html[data-theme="light"] .theme-toggle__icon--moon,
html[data-theme="dark"] .theme-toggle__icon--sun {
  display: none;
}

.theme-pref-to-system {
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 0.25rem 0.4rem;
  cursor: pointer;
  transition: color 0.2s ease-in-out, background 0.2s ease-in-out;
}

.theme-pref-to-system:hover {
  background: var(--title-icon-bg);
  color: var(--text);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.brand:hover {
  color: var(--org-primary, var(--accent));
}

.brand__logo {
  display: block;
  max-height: 36px;
  width: auto;
  max-width: 168px;
  object-fit: contain;
}

.site-header[data-org-header="1"] {
  background: var(--org-header-bg) !important;
  border-bottom-color: color-mix(in srgb, var(--org-header-fg) 14%, var(--org-header-bg)) !important;
}

.site-header[data-org-header="1"] .brand,
.site-header[data-org-header="1"] .brand:hover,
.site-header[data-org-header="1"] .site-nav__user {
  color: var(--org-header-fg) !important;
}

.site-header[data-org-header="1"] .btn--ghost {
  color: var(--org-header-fg) !important;
  border-color: color-mix(in srgb, var(--org-header-fg) 28%, var(--org-header-bg)) !important;
}

.site-header[data-org-header="1"] .btn--ghost:hover {
  color: var(--org-header-fg) !important;
  background: color-mix(in srgb, var(--org-header-fg) 10%, var(--org-header-bg)) !important;
}

.site-header[data-org-header="1"] .theme-toggle {
  border-color: color-mix(in srgb, var(--org-header-fg) 30%, var(--org-header-bg)) !important;
  background: color-mix(in srgb, var(--org-header-fg) 8%, var(--org-header-bg)) !important;
  color: var(--org-header-fg) !important;
}

.site-header[data-org-header="1"] .theme-toggle:hover {
  color: var(--org-header-fg) !important;
  border-color: color-mix(in srgb, var(--org-header-fg) 45%, var(--org-header-bg)) !important;
}

.site-header[data-org-header="1"] .theme-pref-to-system {
  color: var(--org-header-fg) !important;
}

.site-header[data-org-header="1"] .theme-pref-to-system:hover {
  background: color-mix(in srgb, var(--org-header-fg) 12%, var(--org-header-bg)) !important;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-toggle {
  padding: 0.35rem 0.7rem;
}

.inline-form {
  margin: 0;
}

.main {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

.panel {
  background: var(--panel-surface);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.panel--narrow {
  max-width: 380px;
  margin: 2rem auto;
}

.panel--tight {
  padding: 0.9rem 1.1rem;
  font-size: 0.9rem;
  line-height: 1.45;
}

/* Bento-style summary / stat cards */
.bento {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.9rem;
  margin: 1rem 0;
  align-items: stretch;
}

.bento--cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.bento--cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.bento--cols-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

@media (max-width: 1100px) {
  .bento--cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bento--cols-5 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .bento--cols-3 {
    grid-template-columns: 1fr;
  }
}

.bento-card,
.email-card,
.email-config-pnav {
  background: var(--bento-surface);
  border: 1px solid var(--bento-border);
  border-radius: 12px;
  box-shadow: var(--bento-shadow);
}

html[data-theme="dark"] .bento-card,
html[data-theme="dark"] .email-card {
  box-shadow: var(--bento-glow);
}

.bento-card {
  padding: 1.15rem 1.25rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.bento-card:hover {
  box-shadow: var(--bento-shadow-hover);
  transform: translateY(-2px);
}

html[data-theme="dark"] .bento-card:hover {
  box-shadow: var(--bento-glow), var(--bento-shadow-hover);
}

.bento-card--static,
.bento-card--static:hover {
  transform: none;
  box-shadow: var(--bento-shadow);
}

.bento-card--stat {
  padding: 0.9rem 1.05rem;
  font-size: 0.9rem;
  line-height: 1.45;
}

.bento-card--soft {
  box-shadow: none;
}

/* Page and section headers with Lucide (icon in rounded “chip”) */
.page-head,
.section-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.page-head {
  margin: 0 0 0.5rem;
}

.page-head--stack .page-head,
.chatx__head .page-head {
  margin: 0;
}

.panel__head .page-head {
  margin: 0;
  min-width: 0;
  flex: 1;
}

.page-head__title,
.section-head__title {
  margin: 0;
  min-width: 0;
  letter-spacing: -0.02em;
  color: var(--text);
}

.section-head {
  margin: 1.1rem 0 0.65rem;
}

.section-head--tightTop {
  margin-top: 1rem;
}

.section-head--compact {
  margin: 0 0 0.5rem;
}

.section-head--compact .section-head__title {
  font-size: 1rem;
  font-weight: 600;
}

.section-head--inCard {
  margin: 0 0 0.9rem;
}

.section-head__title {
  line-height: 1.2;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.title-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 9px;
  background: var(--title-icon-bg);
  flex-shrink: 0;
}

.title-icon,
.title-icon-wrap .title-icon svg,
.page-head .title-icon svg,
.section-head .title-icon svg {
  width: 1.2rem;
  height: 1.2rem;
  stroke: var(--accent);
}

.page-head--inline {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.panel__title {
  margin: 0 0 1rem;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.muted {
  margin: 0;
  color: var(--muted);
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field__inline {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.field__inline .field__input {
  flex: 1;
  min-width: 0;
}

.field__inline .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.field__label {
  font-size: 0.875rem;
  color: var(--muted);
}

.field__input {
  padding: 0.55rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
}

.field__input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.field--checkbox {
  justify-content: center;
}

.field__checkbox-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
}

.dropzone {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 1rem;
  cursor: pointer;
}

.dropzone--active {
  border-color: var(--accent);
  background: rgba(91, 156, 245, 0.08);
}

.agent-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  margin-top: 1em;
}

.agent-tabs__tab {
  display: inline-block;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  font-size: 0.95rem;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
}

a.agent-tabs__tab:hover {
  color: var(--text);
  background: var(--nav-hover);
}

.agent-tabs__tab--active {
  color: var(--org-primary, var(--accent));
  border-color: var(--border);
  background: var(--title-icon-bg);
}

.btn {
  font: inherit;
  cursor: pointer;
  border-radius: 6px;
  padding: 0.55rem 1rem;
  border: 1px solid transparent;
}

.btn--primary {
  background: var(--org-primary, var(--accent));
  color: #ffffff;
  font-weight: 600;
  border: 1px solid transparent;
}

.btn--primary:hover {
  background: var(--org-primary-hover, var(--accent-hover));
}

.btn--ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

.btn--ghost:hover {
  color: var(--text);
  border-color: var(--muted);
}

.alert {
  margin: 0 0 1rem;
  padding: 0.65rem 0.85rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

.alert--error {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--border-strong);
}

.alert--success {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.app-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.site-nav__user {
  font-size: 0.875rem;
  color: var(--muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-shell {
  display: flex;
  flex: 1;
  /*max-width: 1200px;*/
  width: 100%;
  margin: 0 auto;
  min-height: 0;
}

.app-shell:has(.chatx) {
  align-items: stretch;
}

.sidebar {
  flex-shrink: 0;
  width: 240px;
  overflow: hidden;
  border-right: 1px solid var(--sidebar-border);
  background: var(--sidebar-bg);
  padding: 0.75rem 0 1rem;
  transition: width 0.2s ease, padding 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 1rem 0.5rem 1.1rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  border-left: 3px solid transparent;
  border-radius: 0 8px 8px 0;
  margin-right: 0.4rem;
}

.sidebar__link-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
  opacity: 0.92;
}

.sidebar__link-icon svg {
  width: 1.2rem;
  height: 1.2rem;
  stroke: currentColor;
}

.sidebar__link-text {
  flex: 1;
  min-width: 0;
}

.sidebar__link:hover {
  color: var(--text);
  background: var(--nav-hover);
}

.sidebar__link--disabled {
  opacity: 0.42;
  pointer-events: none;
  cursor: not-allowed;
  color: var(--muted);
  border-left-color: transparent;
}

.sidebar__link--disabled:hover {
  color: var(--muted);
  background: transparent;
}

.sidebar__link--active {
  color: var(--org-primary, var(--accent));
  border-left-color: var(--org-primary, var(--accent));
  background: color-mix(in srgb, var(--org-primary, var(--accent)) 14%, transparent);
}

.sidebar__link--active .sidebar__link-icon {
  opacity: 1;
}

.sidebar__link--nested {
  font-size: 0.88rem;
  padding-left: 1.15rem;
}

.sidebar__link--nested .sidebar__link-text {
  font-weight: 400;
}

.sidebar__submenu {
  margin: 0.35rem 0.4rem 0.25rem 0;
  border-radius: 0 8px 8px 0;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.sidebar__submenu-summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 1rem 0.55rem 1.1rem;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
  user-select: none;
  border-left: 3px solid transparent;
  transition: color 0.12s, background 0.12s;
}

.sidebar__submenu-summary::-webkit-details-marker {
  display: none;
}

.sidebar__submenu-summary::marker {
  content: none;
}

.sidebar__submenu-summary:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.sidebar__submenu[open] > .sidebar__submenu-summary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.sidebar__submenu:has(.sidebar__link--active) > .sidebar__submenu-summary {
  color: var(--org-primary, var(--accent));
  border-left-color: var(--org-primary, var(--accent));
  background: color-mix(in srgb, var(--org-primary, var(--accent)) 10%, transparent);
}

.sidebar__submenu-chevron {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  opacity: 0.7;
  transition: transform 0.2s ease;
}

.sidebar__submenu-chevron svg {
  width: 1rem;
  height: 1rem;
  stroke: currentColor;
}

.sidebar__submenu[open] .sidebar__submenu-chevron {
  transform: rotate(180deg);
}

.sidebar__submenu-panel {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.15rem 0.35rem 0.55rem 0;
  border-top: 1px solid var(--submenu-panel-border);
}

.sidebar__submenu-panel .sidebar__link--nested {
  border-radius: 0 6px 6px 0;
  margin-right: 0;
  padding-left: 0.5rem;
  padding-top: 0.42rem;
  padding-bottom: 0.42rem;
}

.sidebar__submenu-panel .sidebar__link--nested .sidebar__link-icon {
  width: 1.05rem;
  height: 1.05rem;
}

.sidebar__submenu-panel .sidebar__link--nested .sidebar__link-icon svg {
  width: 1.05rem;
  height: 1.05rem;
}

.main--with-sidebar {
  flex: 1;
  max-width: none;
  min-width: 0;
  transition: margin-left 0.2s ease;
}

.sidebar-collapsed .sidebar {
  width: 0;
  padding: 0;
  border-right-color: transparent;
}

.sidebar-collapsed .sidebar__link,
.sidebar-collapsed .sidebar__submenu {
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 900px) {
  .site-header__inner {
    padding: 0.75rem 0.9rem;
  }

  .site-nav__user {
    max-width: 140px;
  }
}

.panel--wide {
  max-width: 100%;
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.panel__head .panel__title {
  margin: 0;
}

.stack--form {
  max-width: 820px;
}

.panel__subtitle {
  margin: 0.5rem 0 0;
  font-size: 1rem;
  color: var(--muted);
}

.section-head .section-head__title.panel__subtitle,
.section-head .panel__subtitle {
  margin: 0;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 600;
}

.stack--form > .form-actions,
.stack--form > .panel__subtitle {
  grid-column: 1 / -1;
}

@media (min-width: 900px) {
  .stack--form {
    display: grid;
    /*grid-template-columns: repeat(2, minmax(0, 1fr));*/
    gap: 1rem 1.25rem;
    align-items: start;
  }
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

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

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

.table th,
.table td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.table__cell-clip {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn--small {
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.btn--danger {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid #5c3030;
}

.btn--danger:hover {
  background: #4a2828;
}

.token-ring-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.token-ring {
  display: block;
  flex-shrink: 0;
}

.token-ring__track {
  stroke: var(--ring-track);
  stroke-width: 3;
}

.token-ring__arc {
  stroke-width: 3;
  stroke-linecap: round;
  fill: none;
}

.token-ring__arc--good {
  stroke: #22c55e;
}

.token-ring__arc--warn {
  stroke: #f59e0b;
}

.token-ring__arc--bad {
  stroke: #ef4444;
}

.token-ring__label {
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  min-width: 2.5ch;
  color: var(--text-muted, #9ca3af);
}

.token-ring {
  width: 20px;
  height: 20px;
}

.chatx {
  --gx-bg: #131314;
  --gx-surface: #1e1f20;
  --gx-border: #2d2e31;
  --gx-text: #e3e2e6;
  --gx-muted: #8e918f;
  --gx-user: #282a2c;
  --gx-sparkle: linear-gradient(135deg, #4285f4, #9b51e0, #d946ef);
  --gx-radius-pill: 28px;
  --gx-col: 48rem; /* 768px */

  color: var(--gx-text);
  background: var(--gx-bg);
  width: 100%;
  flex: 1;
  min-height: calc(100vh - 3.5rem);
  display: flex;
  flex-direction: column;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  margin: 0;
  font-family: "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
}

html[data-theme="light"] .chatx {
  --gx-bg: #f8f9fa;
  --gx-surface: #ffffff;
  --gx-border: #e0e3e7;
  --gx-text: #1f1f1f;
  --gx-muted: #8e918f;
  --gx-user: #e9eef6;
}

.main:has(.chatx),
.main--with-sidebar:has(.chatx) {
  max-width: none;
  width: 100%;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: calc(100vh - 3.5rem);
  background: #131314;
}

html[data-theme="light"] .main:has(.chatx),
html[data-theme="light"] .main--with-sidebar:has(.chatx) {
  background: #f8f9fa;
}

.chatx__frame {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  background: var(--gx-bg);
}

.chatx__column {
  width: 100%;
  max-width: var(--gx-col);
  margin: 0 auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.chatx__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.25rem 0.75rem;
  max-width: calc(var(--gx-col) + 2.5rem);
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.chatx__head-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.chatx__head-copy {
  min-width: 0;
}

.chatx__title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--gx-text);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chatx__subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
  color: var(--gx-muted);
}

.chatx__nav-link {
  flex-shrink: 0;
  color: var(--gx-muted);
  text-decoration: none;
  font-size: 0.86rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.chatx__nav-link:hover {
  color: var(--gx-text);
  border-color: var(--gx-border);
  background: color-mix(in srgb, var(--gx-surface) 80%, transparent);
}

.chatx__head-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.chatx__new-form {
  margin: 0;
}

button.chatx__nav-link--btn {
  cursor: pointer;
  font: inherit;
  background: transparent;
  appearance: none;
}

.chatx-sparkle {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-weight: 600;
  letter-spacing: -0.08em;
  background: var(--gx-sparkle);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  user-select: none;
}

.chatx-sparkle--sm {
  font-size: 0.95rem;
}

.chatx-sparkle--md {
  font-size: 1.25rem;
}

.chatx-sparkle--lg {
  font-size: 2.4rem;
  animation: chatx-sparkle-pulse 2.8s ease-in-out infinite;
}

@keyframes chatx-sparkle-pulse {
  0%,
  100% {
    transform: scale(1);
    filter: saturate(1);
  }
  50% {
    transform: scale(1.06);
    filter: saturate(1.15);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chatx-sparkle--lg {
    animation: none;
  }
}

.chatx-budget {
  max-width: var(--gx-col);
  margin: 0 auto 0.5rem;
  width: calc(100% - 2.5rem);
  border: 1px solid var(--gx-border);
  border-radius: 16px;
  padding: 0.65rem 0.85rem;
  background: var(--gx-surface);
  box-shadow: none;
}

.chatx-budget__row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
  font-size: 0.82rem;
  color: var(--gx-muted);
}

.chatx-budget__track {
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--gx-border) 80%, transparent);
  overflow: hidden;
}

.chatx-budget__fill {
  height: 100%;
  background: var(--gx-sparkle);
  transition: width 160ms ease;
}

.chatx-alert {
  max-width: var(--gx-col);
  margin: 0.35rem auto;
  width: calc(100% - 2.5rem);
  border-radius: 14px;
  padding: 0.7rem 0.95rem;
  font-size: 0.88rem;
  line-height: 1.45;
  border: 1px solid var(--gx-border);
  background: var(--gx-surface);
  color: var(--gx-text);
}

.chatx-alert--error {
  border-color: color-mix(in srgb, #f87171 45%, var(--gx-border));
  color: #fca5a5;
}

html[data-theme="light"] .chatx-alert--error {
  color: #b91c1c;
}

.chatx-alert--success {
  border-color: color-mix(in srgb, #34d399 40%, var(--gx-border));
}

.chatx-alert--info {
  color: var(--gx-muted);
}

.chatx__viewport {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 0.5rem 0 1rem;
}

.chatx-thread {
  border: none;
  border-radius: 0;
  background: transparent;
  min-height: min(52vh, 28rem);
  max-height: none;
  overflow: visible;
  padding: 1.25rem 0 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.chatx-empty {
  margin: auto;
  text-align: center;
  padding: 3rem 1rem 4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  max-width: 28rem;
}

.chatx-empty__title {
  margin: 0;
  font-size: clamp(1.45rem, 2.6vw, 1.85rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--gx-text);
  line-height: 1.25;
}

.chatx-empty__lead {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--gx-muted);
}

.chatx-msg {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  animation: chatx-msg-in 0.35s ease-out;
}

@keyframes chatx-msg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chatx-msg {
    animation: none;
  }
}

.chatx-msg__meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--gx-muted);
  font-weight: 500;
}

.chatx-msg__who {
  color: var(--gx-text);
}

.chatx-msg__run {
  color: var(--gx-muted);
  font-weight: 400;
}

.chatx-msg__bubble {
  white-space: pre-wrap;
  border-radius: 22px;
  padding: 0.85rem 1.05rem;
  line-height: 1.55;
  border: none;
  font-size: 0.98rem;
  color: var(--gx-text);
}

.chatx-msg--user {
  align-items: flex-end;
}

.chatx-msg--user .chatx-msg__bubble {
  background: var(--gx-user);
  max-width: min(85%, 36rem);
  border-radius: 22px 22px 8px 22px;
}

.chatx-msg--assistant {
  align-items: stretch;
  gap: 0.55rem;
}

.chatx-msg--assistant .chatx-msg__body {
  max-width: 100%;
  font-size: 1.02rem;
  line-height: 1.65;
  color: var(--gx-text);
  letter-spacing: 0.005em;
}

.chatx-md__p {
  margin: 0 0 0.85rem;
}

.chatx-md__p:last-child {
  margin-bottom: 0;
}

.chatx-md__h {
  margin: 1rem 0 0.5rem;
  font-weight: 560;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: var(--gx-text);
}

.chatx-md__list {
  margin: 0.35rem 0 0.85rem;
  padding-left: 1.25rem;
}

.chatx-md__list li {
  margin: 0.25rem 0;
}

.chatx-md__code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  padding: 0.12em 0.35em;
  border-radius: 6px;
  background: color-mix(in srgb, var(--gx-surface) 88%, var(--gx-border));
  border: 1px solid var(--gx-border);
}

.chatx-md__pre {
  margin: 0.65rem 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: var(--gx-surface);
  border: 1px solid var(--gx-border);
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.5;
}

.chatx-md__pre code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--gx-text);
}

.chatx__dock {
  position: sticky;
  bottom: 0;
  z-index: 5;
  padding: 0.35rem 0 1.15rem;
  background: linear-gradient(180deg, transparent 0%, var(--gx-bg) 28%, var(--gx-bg) 100%);
}

.chatx-compose {
  margin: 0;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 0.55rem;
  max-width: none;
  padding: 0.55rem 0.55rem 0.55rem 1.05rem;
  background: var(--gx-surface);
  border: 1px solid var(--gx-border);
  border-radius: var(--gx-radius-pill);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

html[data-theme="light"] .chatx-compose {
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
}

.chatx-compose:focus-within {
  border-color: color-mix(in srgb, #9b51e0 45%, var(--gx-border));
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.28), 0 0 0 1px color-mix(in srgb, #4285f4 25%, transparent);
}

html[data-theme="light"] .chatx-compose:focus-within {
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1), 0 0 0 1px color-mix(in srgb, #4285f4 22%, transparent);
}

.chatx-compose.chatx-compose--hint {
  animation: chatx-compose-hint 1.65s ease-out;
}

@keyframes chatx-compose-hint {
  0% {
    border-color: color-mix(in srgb, #4285f4 40%, var(--gx-border));
    box-shadow: 0 0 0 0 color-mix(in srgb, #9b51e0 30%, transparent);
  }
  32% {
    border-color: color-mix(in srgb, #9b51e0 55%, var(--gx-border));
    box-shadow: 0 0 0 6px color-mix(in srgb, #4285f4 16%, transparent);
  }
  100% {
    border-color: var(--gx-border);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chatx-compose.chatx-compose--hint {
    animation: none;
    border-color: color-mix(in srgb, #9b51e0 50%, var(--gx-border));
  }
}

.chatx-compose__field {
  flex: 1;
  margin: 0;
  min-width: 0;
}

.chatx-compose__input {
  display: block;
  width: 100%;
  resize: none;
  min-height: 24px;
  max-height: 160px;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
  color: var(--gx-text);
  font: inherit;
  font-size: 1rem;
  line-height: 1.45;
  padding: 0.55rem 0.15rem;
  border-radius: 0;
}

.chatx-compose__input::placeholder {
  color: var(--gx-muted);
}

.chatx-compose__send {
  flex-shrink: 0;
  width: 2.55rem;
  height: 2.55rem;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  color: #fff;
  background: var(--gx-sparkle);
  background-size: 160% 160%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
}

.chatx-compose__send:hover {
  filter: brightness(1.08);
  transform: scale(1.04);
}

.chatx-compose__send:active {
  transform: scale(0.97);
}

.chatx-compose__send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chatx-auth {
  margin: 0 auto;
  border: 1px solid var(--gx-border);
  border-radius: 20px;
  padding: 1.15rem 1.2rem;
  background: var(--gx-surface);
  max-width: 26rem;
  color: var(--gx-text);
}

.chatx-auth__title {
  margin: 0 0 0.35rem;
  font-weight: 560;
  font-size: 1.05rem;
  color: var(--gx-text);
}

.chatx-auth__lead {
  margin: 0 0 0.85rem;
  font-size: 0.9rem;
  color: var(--gx-muted);
  line-height: 1.5;
}

.chatx-auth__form .field {
  margin-bottom: 0.75rem;
}

.chatx-auth__form .field__label {
  color: var(--gx-muted);
}

.chatx-auth__form .field__input {
  background: var(--gx-bg);
  border-color: var(--gx-border);
  color: var(--gx-text);
}

.chatx-auth__btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.15rem;
  font: inherit;
  font-weight: 500;
  color: #fff;
  background: var(--gx-sparkle);
  cursor: pointer;
}

.chatx-auth__btn--ghost {
  background: transparent;
  color: var(--gx-muted);
  border: 1px solid var(--gx-border);
}

.chatx-abac {
  margin: 0 0 0.55rem;
  font-size: 0.8rem;
  color: var(--gx-muted);
  text-align: center;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tenant-admin__tabs {
  display: flex;
  gap: 0.35rem;
  margin: 1rem 0 0.85rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.35rem;
}

.tenant-admin__tab {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}

.tenant-admin__tab--active {
  background: var(--surface-elevated, rgba(127, 127, 127, 0.12));
  color: var(--text);
  font-weight: 600;
}

.tenant-admin__panel {
  margin-top: 0.5rem;
}

.tenant-admin__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.tenant-admin__subtitle {
  margin: 0;
  font-size: 1.05rem;
}

.tenant-admin__inline-add {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-end;
  margin-bottom: 0.85rem;
}

.tenant-admin__inline-field {
  flex: 1 1 220px;
  margin: 0;
}

.tenant-admin__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tenant-admin__list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}

dialog.modal {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  max-width: 440px;
  width: calc(100% - 2rem);
  background: var(--panel-bg, var(--bg));
  color: var(--text);
}

dialog.modal::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.modal__body {
  padding: 1.1rem 1.25rem;
}

.modal__title {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.knowledge-ingest-panel {
  display: none;
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--knowledge-bg);
}

.knowledge-ingest-panel.is-visible {
  display: block;
}

.knowledge-ingest-panel p {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.knowledge-index-bar {
  height: 6px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
}

.knowledge-index-bar__indeterminate {
  width: 40%;
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  animation: knowledge-index-sweep 1.2s ease-in-out infinite;
}

@keyframes knowledge-index-sweep {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(350%);
  }
}

.knowledge-file-status {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 12rem;
}

.knowledge-file-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.knowledge-file-progress__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent, #3b82f6);
  transition: width 0.35s ease;
}

.knowledge-file-progress__fill--active {
  background: var(--accent, #3b82f6);
}

.knowledge-file-progress__fill--done {
  background: #16a34a;
}

.knowledge-file-progress__fill--failed {
  background: #dc2626;
}

/* —— Email config (SMTP) —— */
.email-config-outer {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
  max-width: 1100px;
}

@media (max-width: 900px) {
  .email-config-outer {
    grid-template-columns: 1fr;
  }

  .email-config-pnav {
    position: static;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
  }

  .email-config-pnav__link {
    display: inline-block;
    margin-bottom: 0;
  }
}

.email-config-pnav {
  position: sticky;
  top: 1rem;
  padding: 1rem 1.1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.email-config-pnav__label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

.email-config-pnav__link {
  display: block;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 0.2rem;
  font-size: 0.9rem;
}

.email-config-pnav__link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.email-config-pnav__link--active {
  color: var(--accent);
  background: rgba(91, 156, 245, 0.12);
}

#section-connection,
#section-security-help {
  scroll-margin-top: 1.25rem;
}

.email-config__lead {
  color: var(--muted);
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
}

.email-card {
  padding: 1.2rem 1.35rem;
  margin-bottom: 1.15rem;
}

.email-card--mute {
  background: var(--bento-surface);
  opacity: 0.95;
  filter: saturate(0.95);
}

html[data-theme="light"] .email-card--mute {
  background: #f8fafc;
  filter: none;
  opacity: 1;
}

.email-card__desc {
  margin: 0 0 0.9rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.email-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 0.8rem;
  margin-top: 0.15rem;
}

.field-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.field--grow {
  flex: 1;
  min-width: 10rem;
}

.field--port {
  max-width: 6.5rem;
}

.email-callout {
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  margin-bottom: 0.9rem;
  font-size: 0.86rem;
  line-height: 1.5;
  border: 1px solid rgba(245, 166, 35, 0.4);
  background: rgba(245, 166, 35, 0.1);
  color: var(--text);
}

.email-callout a {
  color: var(--accent);
}

.email-callout p {
  margin: 0 0 0.4rem;
}

.email-callout p:last-child {
  margin-bottom: 0;
}

.email-seg {
  display: inline-flex;
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
  vertical-align: middle;
}

.email-seg__btn {
  font: inherit;
  padding: 0.42rem 0.9rem;
  background: var(--input-bg);
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.88rem;
}

.email-seg__btn:hover {
  color: var(--text);
  background: var(--nav-hover);
}

.email-seg__btn--active {
  color: var(--accent);
  background: var(--title-icon-bg);
  font-weight: 500;
}

.is-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

.email-config-content .form-actions {
  margin-top: 0.2rem;
}

.ec-toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  padding: 0.75rem 1.1rem;
  border-radius: 10px;
  max-width: 360px;
  z-index: 2000;
  font-size: 0.9rem;
  line-height: 1.4;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
  border: 1px solid var(--ec-toast-ok-b);
  background: var(--ec-toast-ok);
  color: var(--ec-toast-ok-text);
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.ec-toast--visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.ec-toast--error {
  background: var(--ec-toast-err);
  border-color: var(--ec-toast-err-b);
  color: var(--ec-toast-err-text);
}

/* ---------- Human-in-the-loop approval cards ---------- */

.appr-section-title {
  margin: 1.4rem 0 0.6rem;
  font-size: 1rem;
}

.appr-list {
  display: grid;
  gap: 0.9rem;
}

.appr-list--muted .appr-card {
  opacity: 0.82;
}

.appr-card {
  border: 1px solid var(--gx-border, var(--border));
  border-left: 3px solid var(--muted);
  border-radius: 14px;
  background: var(--gx-surface, var(--surface));
  color: var(--gx-text, var(--text));
  padding: 0.9rem 1rem 0.75rem;
  display: grid;
  gap: 0.6rem;
  text-align: left;
}

.appr-card--destructive {
  border-left-color: #ef4444;
}

.appr-card--side_effect {
  border-left-color: #f59e0b;
}

.appr-card--resolved {
  border-left-color: #10b981;
}

.appr-card--busy {
  opacity: 0.75;
}

.appr-card__head {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.appr-card__icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  margin-top: 0.1rem;
  color: var(--gx-muted, var(--muted));
}

.appr-card__headings {
  flex: 1 1 12rem;
  min-width: 0;
}

.appr-card__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.appr-card__subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.86rem;
  color: var(--gx-muted, var(--muted));
  overflow-wrap: anywhere;
}

.appr-card__tags {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.appr-tag {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--gx-border, var(--border));
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--gx-muted, var(--muted));
  white-space: nowrap;
}

.appr-tag--destructive {
  border-color: color-mix(in srgb, #ef4444 55%, var(--border));
  color: #ef4444;
}

.appr-tag--side_effect {
  border-color: color-mix(in srgb, #f59e0b 55%, var(--border));
  color: #d97706;
}

.appr-tag--status-pending,
.appr-tag--status-processing {
  border-color: color-mix(in srgb, #6366f1 55%, var(--border));
  color: #818cf8;
}

.appr-tag--status-approved,
.appr-tag--status-edited {
  border-color: color-mix(in srgb, #10b981 55%, var(--border));
  color: #10b981;
}

.appr-tag--status-rejected,
.appr-tag--status-cancelled,
.appr-tag--status-expired {
  border-color: color-mix(in srgb, #ef4444 45%, var(--border));
  color: #f87171;
}

.appr-card__meta,
.appr-card__id {
  margin: 0;
  font-size: 0.78rem;
  color: var(--gx-muted, var(--muted));
  overflow-wrap: anywhere;
}

.appr-card__block {
  display: grid;
  gap: 0.3rem;
}

.appr-card__block-title {
  margin: 0;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gx-muted, var(--muted));
}

.appr-card__edited-flag {
  margin-left: 0.4rem;
  text-transform: none;
  letter-spacing: 0;
  font-style: italic;
}

.appr-card__rationale {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.appr-card__muted {
  color: var(--gx-muted, var(--muted));
  font-size: 0.86rem;
  margin: 0;
}

.appr-card__gate {
  padding-top: 0.2rem;
}

.appr-card__consequence {
  margin: 0;
  font-size: 0.83rem;
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  border: 1px dashed color-mix(in srgb, #ef4444 40%, var(--border));
  color: var(--gx-text, var(--text));
}

.appr-args {
  margin: 0;
  display: grid;
  gap: 0.3rem;
  font-size: 0.88rem;
}

.appr-args__row {
  display: grid;
  grid-template-columns: minmax(6rem, 9rem) 1fr;
  gap: 0.5rem;
  align-items: start;
}

.appr-args__row--stacked {
  grid-template-columns: 1fr;
  gap: 0.15rem;
}

.appr-args__key {
  margin: 0;
  font-weight: 600;
  color: var(--gx-muted, var(--muted));
}

.appr-args__val {
  margin: 0;
  overflow-wrap: anywhere;
}

.appr-args__val--pre {
  white-space: pre-wrap;
  max-height: 14rem;
  overflow-y: auto;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  background: color-mix(in srgb, var(--gx-border, var(--border)) 35%, transparent);
  font-size: 0.84rem;
}

.appr-args__empty {
  color: var(--gx-muted, var(--muted));
  font-style: italic;
}

.appr-card__actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  align-items: center;
}

.appr-card__reject-btn {
  color: #f87171;
}

.appr-panel {
  border-top: 1px solid var(--gx-border, var(--border));
  padding-top: 0.7rem;
}

.appr-panel__form {
  gap: 0.55rem;
}

.appr-panel__hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--gx-muted, var(--muted));
}

.appr-panel__buttons {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.appr-panel__json {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
}

.appr-fields {
  display: grid;
  gap: 0.55rem;
}

.appr-fields__field--check {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.appr-fields__check {
  width: 1rem;
  height: 1rem;
}

.appr-fields__hint {
  font-size: 0.74rem;
  color: var(--gx-muted, var(--muted));
}

.appr-card__resolution {
  margin: 0;
  font-size: 0.84rem;
}

.appr-card__feedback {
  margin: 0;
  font-size: 0.85rem;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  border: 1px solid var(--gx-border, var(--border));
}

.appr-card__feedback--error {
  border-color: color-mix(in srgb, #ef4444 50%, var(--border));
  color: #f87171;
}

.appr-card__feedback--success {
  border-color: color-mix(in srgb, #10b981 50%, var(--border));
}

.appr-card__feedback--busy {
  color: var(--gx-muted, var(--muted));
}

.chatx-approval {
  width: 100%;
  margin: 0.35rem 0 1rem;
  display: grid;
  gap: 0.4rem;
}

.chatx-approval__lead {
  margin: 0;
  font-size: 0.84rem;
  color: var(--gx-muted, var(--muted));
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.chatx-approval__dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: #f59e0b;
  flex: 0 0 auto;
}

.sidebar__link-badge {
  margin-left: auto;
  min-width: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.25rem;
  text-align: center;
}

@media (max-width: 640px) {
  .appr-args__row {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
}