:root {
  color-scheme: light dark;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-elevated: #fff;
  --border: #d0d7e6;
  --accent: #2563eb;
  --accent-muted: rgba(37, 99, 235, 0.12);
  --text: #0f172a;
  --text-muted: #64748b;
  --success: #16a34a;
  --danger: #dc2626;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
}

.app-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading {
  text-align: center;
  color: var(--text-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  margin: 24px auto;
  animation: spin 0.9s linear infinite;
}

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

.layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  width: 100%;
  min-height: 100vh;
}

.sidebar {
  background: #0f172a;
  color: #e2e8f0;
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar h1 {
  font-size: 20px;
  margin: 0;
  font-weight: 600;
}

.sidebar .tenant {
  font-size: 13px;
  color: #cbd5f5;
  margin-top: 6px;
}

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

.nav button {
  background: transparent;
  border: none;
  color: inherit;
  padding: 10px 12px;
  border-radius: 10px;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.nav button.active {
  background: rgba(148, 163, 255, 0.18);
  color: #fff;
}

.nav button:hover {
  background: rgba(148, 163, 255, 0.12);
}

.content {
  padding: 28px 36px;
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

.billing-export-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.billing-export-range-row {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

.billing-export-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.billing-export-field input {
  min-width: 148px;
}

.billing-export-actions {
  display: flex;
  gap: 8px;
}

.billing-quick-ranges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}

.billing-quick-title {
  font-weight: 600;
}

.billing-quick-range-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.billing-quick-range {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.billing-quick-range:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.billing-quick-range.is-active {
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--accent);
}

.billing-quick-range:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.billing-range-label {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
}

.secret-editor {
  font-family: inherit;
  letter-spacing: 0.5px;
  -webkit-text-security: disc;
}

.secret-editor[data-visible="true"] {
  -webkit-text-security: none;
}

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

.secret-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  color: var(--text-muted);
  transition: border-color 0.2s ease, color 0.2s ease;
}

.secret-toggle:hover,
.secret-toggle:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.secret-toggle[data-active="true"] {
  color: var(--accent);
}

.input-editable {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  min-height: 38px;
  width: 100%;
  display: block;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-editable:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.build-badge {
  position: fixed;
  top: 12px;
  right: 12px;
  background: rgba(15, 23, 42, 0.9);
  color: #fff;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  z-index: 9999;
  pointer-events: none;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
}

.input-editable[data-placeholder]:empty:before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}

.billing-export-form .btn {
  height: 38px;
}

.openai-status {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.openai-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

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

.chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-muted);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.chip.status-ok {
  background: #dcfce7;
  color: #166534;
}

.chip.status-error {
  background: #fee2e2;
  color: #b91c1c;
}

.chip.status-pending {
  background: #fef3c7;
  color: #92400e;
}

.grid {
  display: grid;
  gap: 20px;
}

.grid.two {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid.two-cols {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.grid.three {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card {
  background: var(--surface);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 18px 35px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.metric-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
}

.metric-sub {
  font-size: 13px;
  color: var(--text-muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

tbody tr:hover {
  background: rgba(37, 99, 235, 0.06);
  cursor: pointer;
}

tbody tr.active {
  background: rgba(37, 99, 235, 0.12);
}

.billing-table {
  width: 100%;
  margin-top: 12px;
  border-collapse: collapse;
}

.billing-table td {
  border: none;
  padding: 6px 0;
}

.billing-table td:last-child {
  text-align: right;
  font-weight: 500;
}

.billing-table tr.total td {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  font-weight: 700;
}

.billing-table tr:hover {
  background: transparent;
  cursor: default;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.pill.green {
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
}

.pill.amber {
  background: rgba(245, 158, 11, 0.15);
  color: #b45309;
}

.pill.red {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
}

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

.section-title h3 {
  margin: 0;
}

.config-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.config-tabs button {
  border: 1px solid rgba(37, 99, 235, 0.2);
  background: #fff;
  color: #1f2937;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.config-tabs button.active {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.25);
}

.config-tabs button:not(.active):hover {
  background: rgba(37, 99, 235, 0.08);
}

.config-panel-wrapper {
  display: grid;
  gap: 18px;
}

.build-info-badge {
  position: fixed;
  left: 16px;
  bottom: 16px;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
  z-index: 30;
}

.build-info-badge button {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 11px;
  text-decoration: underline;
  padding: 0;
}

.config-panel {
  display: none;
  gap: 18px;
}

.config-panel[data-active="true"] {
  display: grid;
}

.config-panel .card + .card {
  margin-top: 18px;
}

.hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 6px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.08);
  color: #2563eb;
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.stack > * + * {
  margin-top: 6px;
}

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.btn.secondary {
  background: #e2e8f0;
  color: var(--text);
}

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

.btn.ghost.danger {
  color: var(--danger);
}

.btn:hover {
  filter: brightness(0.95);
}

.form-grid {
  display: grid;
  gap: 14px;
}

.form-grid.two {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.system-status {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

label {
  font-size: 13px;
  font-weight: 600;
  display: block;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  box-sizing: border-box;
}

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

.color-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.color-field input[type="color"] {
  width: 42px;
  height: 42px;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.color-field span {
  font-family: 'JetBrains Mono', 'SFMono-Regular', ui-monospace, monospace;
  font-size: 13px;
  color: var(--text-muted);
}

.branding-preview {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  display: grid;
  gap: 10px;
  transition: transform 0.2s ease;
}

.branding-preview:hover {
  transform: translateY(-2px);
}

.branding-logo {
  max-width: 160px;
  max-height: 48px;
  object-fit: contain;
}

.branding-wordmark {
  font-size: 22px;
  font-weight: 700;
}

.branding-tagline {
  margin: 0;
  font-size: 14px;
  opacity: 0.85;
}

.branding-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  width: max-content;
}

.onboarding-card .chip {
  background: var(--accent-muted);
  color: var(--accent);
}

.chip.status-completed {
  background: rgba(16, 185, 129, 0.18);
  color: #047857;
}

.chip.status-in_progress {
  background: rgba(234, 179, 8, 0.18);
  color: #b45309;
}

.chip.status-pending {
  background: rgba(148, 163, 184, 0.25);
  color: var(--text-muted);
}

.onboarding-progress {
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.28);
  overflow: hidden;
  margin: 12px 0 16px;
}

.onboarding-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.3s ease;
}

.onboarding-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.onboarding-step {
  display: flex;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  align-items: flex-start;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.onboarding-step.done {
  border-color: rgba(16, 185, 129, 0.38);
  background: rgba(16, 185, 129, 0.08);
}

.onboarding-checkbox {
  position: relative;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.onboarding-checkbox input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.onboarding-check-icon {
  width: 100%;
  height: 100%;
  border: 2px solid var(--border);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.onboarding-checkbox input:checked + .onboarding-check-icon {
  background: #10b981;
  border-color: #059669;
}

.onboarding-checkbox input:checked + .onboarding-check-icon::after {
  content: '✓';
  font-size: 14px;
}

.onboarding-checkbox input:focus-visible + .onboarding-check-icon {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.onboarding-body {
  flex: 1;
  display: grid;
  gap: 8px;
}

.onboarding-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 600;
  color: var(--text);
}

.onboarding-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.onboarding-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
}

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

.onboarding-note label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.onboarding-note textarea {
  min-height: 60px;
  resize: vertical;
}

.onboarding-step-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.onboarding-step.empty {
  justify-content: center;
  border-style: dashed;
  color: var(--text-muted);
  font-size: 13px;
}

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

.timeline {
  display: grid;
  gap: 14px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 8px;
}

.timeline-group {
  display: grid;
  gap: 10px;
}

.date-label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.preview {
  display: inline-block;
  color: #475569;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bubble {
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.bubble.out {
  border-left: 4px solid var(--accent);
}

.bubble.in {
  border-left: 4px solid #10b981;
}

.bubble .meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.media-thumb {
  max-width: 240px;
  border-radius: 12px;
  display: block;
  margin-bottom: 6px;
}

.analysis-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-row {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.status-row span {
  color: var(--text-muted);
}

.version-row,
.deploy-row {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-word;
}

.deploy-row {
  min-height: 16px;
}

.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-box {
  background: #fff;
  border-radius: 18px;
  width: min(420px, 90vw);
  padding: 32px;
  box-shadow: 0 30px 70px rgba(15, 23, 42, 0.45);
  display: grid;
  gap: 18px;
}

.login-box h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}

.login-box p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.token-field {
  display: grid;
  gap: 12px;
}

.token-field input {
  letter-spacing: 0.5px;
}

.input-with-addon {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.btn.icon {
  padding: 8px 12px;
  font-size: 16px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 24px;
}

.modal {
  background: #ffffff;
  border-radius: 18px;
  width: min(520px, 100%);
  max-width: 520px;
  padding: 28px;
  box-shadow: 0 30px 70px rgba(15, 23, 42, 0.35);
  display: grid;
  gap: 20px;
}

.modal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.token-box {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: #f8fafc;
  display: grid;
  gap: 10px;
}

.token-box .label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

.token-value {
  font-family: "IBM Plex Mono", "SFMono-Regular", ui-monospace, Menlo, monospace;
  font-size: 13px;
  word-break: break-all;
  background: #fff;
  border-radius: 10px;
  padding: 10px;
  border: 1px dashed rgba(37, 99, 235, 0.4);
}

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

.modal footer {
  display: flex;
  justify-content: flex-end;
}

.knowledge-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 14px;
  background: rgba(148, 163, 184, 0.12);
  margin-bottom: 12px;
}

.knowledge-item .muted {
  font-size: 12px;
}
.knowledge-facts {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--text-muted);
  font-size: 12px;
}
.knowledge-facts li {
  margin-bottom: 4px;
  line-height: 1.4;
}
.operators-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.operators-table th,
.operators-table td {
  padding: 8px 6px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
  text-align: left;
}
.operators-table th {
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 11px;
}
.operators-table .table-actions {
  display: flex;
  gap: 6px;
}
.operators-table tbody tr:last-child td {
  border-bottom: none;
}
.conversation-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.conversation-actions {
  display: flex;
  gap: 12px;
}

.conversation-actions .toggle-list {
  display: none;
}

.conversation-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  min-height: 520px;
  position: relative;
}

.conversation-sidebar {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  max-height: min(78vh, 720px);
  overflow: hidden;
  position: relative;
  z-index: 45;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.sidebar-close {
  display: none;
}

.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 12px 18px;
  overflow-y: auto;
}

.conversation-list .empty {
  padding: 28px 12px;
  text-align: center;
}

.conversation-item {
  display: grid;
  text-align: left;
  gap: 6px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: #f8fafc;
  cursor: pointer;
  position: relative;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.conversation-item:hover {
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.conversation-item.active {
  border-color: var(--accent);
  box-shadow: 0 16px 32px rgba(37, 99, 235, 0.15);
}

.conversation-item .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
  position: absolute;
  top: 12px;
  right: 12px;
}

.conversation-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}

.conversation-item-preview {
  display: flex;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  align-items: center;
}

.conversation-item-preview .preview {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item-preview .badge {
  flex-shrink: 0;
}

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

.conversation-main {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.conversation-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.conversation-card.placeholder {
  min-height: 420px;
  align-items: center;
  justify-content: center;
}

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

.conversation-header-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conversation-header .drawer-trigger {
  display: none;
}

.summary-card {
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 14px;
  padding: 16px;
  background: #f8fafc;
  display: grid;
  gap: 10px;
}

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

.summary-card p {
  margin: 0;
  line-height: 1.4;
}

.summary-meta {
  font-size: 12px;
}

.summary-disclaimer {
  font-size: 12px;
}

.summary-card .btn {
  white-space: nowrap;
}

.chip-human {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
}

.chip-ai {
  background: rgba(14, 165, 233, 0.12);
  color: #0369a1;
}

.conversation-thread-wrapper {
  position: relative;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 18px;
  padding: 16px;
  background: linear-gradient(135deg, rgba(248, 250, 252, 0.95), #fff);
  min-height: 420px;
  max-height: min(72vh, 640px);
  display: flex;
  flex-direction: column;
}

.conversation-thread {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 8px;
  padding-bottom: 56px;
}

.conversation-thread .timeline-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.conversation-thread .date-label {
  align-self: center;
  background: rgba(15, 23, 42, 0.08);
  color: #334155;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.chat-composer {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.chat-composer textarea {
  min-height: 72px;
}

.chat-composer .btn {
  justify-self: flex-end;
}

.openai-probe {
  margin-top: 16px;
  display: grid;
  gap: 8px;
}

.openai-probe textarea {
  min-height: 80px;
  resize: vertical;
}

.openai-probe .probe-output {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 10px;
  padding: 10px;
  font-family: var(--font-mono, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace);
  font-size: 12px;
  min-height: 48px;
  white-space: pre-wrap;
}

.conversation-details {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 14px;
  padding: 0 16px 16px;
  background: rgba(148, 163, 184, 0.08);
}
.conversation-details summary {
  cursor: pointer;
  padding: 16px 0 12px;
  font-weight: 600;
  list-style: none;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.conversation-details summary::-webkit-details-marker {
  display: none;
}
.conversation-details[open] summary {
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  margin-bottom: 12px;
}
.conversation-details summary::after {
  content: '▾';
  font-size: 12px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}
.conversation-details[open] summary::after {
  transform: rotate(180deg);
}
.conversation-details .details-body {
  display: grid;
  gap: 16px;
}

.conversation-details select {
  position: relative;
  z-index: 10;
}
.conversation-details .actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.chat-row {
  display: flex;
  width: 100%;
}
.chat-row.in {
  justify-content: flex-start;
}
.chat-row.out {
  justify-content: flex-end;
}
.chat-row .bubble {
  border: none;
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.12);
  max-width: min(76%, 460px);
  padding: 12px 16px;
}
.chat-row.in .bubble {
  background: #f8fafc;
  border-radius: 18px 18px 18px 8px;
  color: var(--text);
}
.chat-row.out .bubble {
  background: #0ea5e9;
  border-radius: 18px 18px 8px 18px;
  color: #f8fafc;
}
.chat-row.in .bubble .meta {
  color: #64748b;
}
.chat-row.out .bubble .meta {
  color: rgba(248, 250, 252, 0.8);
}
.chat-row.out .bubble a {
  color: #f0f9ff;
}
.chat-row.out .analysis-label {
  color: rgba(248, 250, 252, 0.78);
}
.messages-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.btn.tertiary {
  background: rgba(56, 189, 248, 0.12);
  color: #0ea5e9;
  border: 1px solid rgba(14, 165, 233, 0.4);
}
.btn.tertiary:hover {
  background: rgba(14, 165, 233, 0.16);
}
.new-badge {
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 999px;
  position: absolute;
  bottom: 18px;
  right: 22px;
  box-shadow: 0 14px 24px rgba(14, 165, 233, 0.25);
}

@media (max-width: 960px) {
  .conversation-layout {
    grid-template-columns: 1fr;
  }
  .conversation-actions .toggle-list {
    display: inline-flex;
    align-items: center;
  }
  .conversation-header .drawer-trigger {
    display: inline-flex;
  }
  .sidebar-close {
    display: inline-flex;
  }
  .conversation-sidebar {
    position: fixed;
    top: 96px;
    bottom: 24px;
    left: 16px;
    right: 16px;
    max-width: 360px;
    transform: translateX(-110%);
    transition: transform 0.28s ease;
    box-shadow: 0 28px 60px rgba(15, 23, 42, 0.35);
  }
  .conversation-layout.list-visible .conversation-sidebar {
    transform: translateX(0);
  }
  .conversation-layout.list-visible::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 40;
  }
}
.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
}
.modal {
  background: #ffffff;
  color: var(--text);
  border-radius: 16px;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.18);
  padding: 24px;
  max-width: 420px;
  width: calc(100% - 32px);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.modal-header h3 {
  margin: 0;
  font-size: 18px;
}
.modal-body {
  display: block;
}
.modal-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.modal-grid dt {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.modal-grid dd {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--text);
}
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: rgba(15, 23, 42, 0.92);
  color: #f8fafc;
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.25);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1100;
}
.toast.visible {
  opacity: 1;
  transform: translateY(0);
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.muted {
  color: var(--text-muted);
  font-size: 13px;
}

.list-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  background: #fff;
  border-radius: 12px;
}

.flex {
  display: flex;
  gap: 12px;
}

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

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

.badge {
  background: rgba(148, 163, 184, 0.2);
  color: #475569;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-info {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}

.badge-warning {
  background: rgba(234, 179, 8, 0.15);
  color: #b45309;
}

.badge-success {
  background: rgba(34, 197, 94, 0.15);
  color: #15803d;
}

.status-human {
  color: #b91c1c;
  font-weight: 600;
}

.status-agent {
  color: #16a34a;
  font-weight: 600;
}

.staff-settings .form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  align-items: center;
}

.staff-settings label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.staff-quick-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.staff-quick-form .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
  flex: 1 1 200px;
}

.staff-quick-form input,
.staff-quick-form select {
  width: 100%;
}

.staff-quick-card .hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

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

.table-wrapper table {
  min-width: 100%;
}

.staff-table .actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
}

.table .compact {
  width: 1%;
  white-space: nowrap;
}

.btn.tiny {
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.2;
}

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

.btn.tiny.ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid rgba(15, 23, 42, 0.12);
}

.icon-button {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  line-height: 1;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.icon-button:hover {
  color: var(--accent);
}

.icon-button.danger {
  color: #dc2626;
}

.badge-neutral {
  background: rgba(148, 163, 184, 0.2);
  color: #334155;
  margin-left: 8px;
}

.role-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.role-item {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  background: var(--surface);
}

.role-item.inactive {
  opacity: 0.65;
}

.role-item.base-role {
  background: rgba(37, 99, 235, 0.04);
}

.role-body {
  flex: 1;
  display: grid;
  gap: 10px;
}

.role-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.role-field label {
  font-size: 12px;
  color: var(--text-muted);
}

.role-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.toggle {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
}

.toggle input {
  width: 16px;
  height: 16px;
}

.toggle input[disabled] {
  cursor: not-allowed;
  opacity: 0.45;
}

.toggle input[disabled] + span {
  color: var(--text-muted);
  opacity: 0.75;
}

.empty-copy {
  margin: 0;
  padding: 12px 0;
  color: var(--text-muted);
}

@media (max-width: 760px) {
  .staff-quick-form {
    align-items: stretch;
  }
  .staff-quick-form .field,
  .staff-quick-form button {
    flex: 1 1 100%;
  }
  .role-item {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .role-actions {
    flex-direction: row;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
  }
}

.staff-queries {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.staff-query {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--surface);
  transition: border 0.2s ease;
}

.staff-query[open] {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.08);
}

.staff-query summary {
  list-style: none;
  cursor: pointer;
  display: block;
}

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

.staff-query-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.staff-query-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}

.staff-query-body {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
}

.staff-query-context {
  background: rgba(37, 99, 235, 0.06);
  padding: 10px;
  border-radius: 12px;
  white-space: pre-wrap;
}

.staff-answers {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.staff-answer {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
}

.staff-answer-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.staff-queries-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.chip-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  background: #fff;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

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

.sse-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f97316;
  box-shadow: 0 0 0 rgba(249, 115, 22, 0.4);
  animation: pulse 2s infinite;
}

.credential-block {
  margin-bottom: 1.5rem;
}

.credential-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}

.credential-header h4 {
  margin: 0;
  font-size: 1rem;
}

.credential-header .chip {
  margin-left: 0.5rem;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.4); }
  70% { box-shadow: 0 0 0 12px rgba(249, 115, 22, 0); }
  100% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0); }
}

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: 200px 1fr;
  }
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
  }
  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .nav button {
    font-size: 13px;
  }
}
