:root {
  --bg: #000000;
  --surface: #111111;
  --surface-2: #1a1a1a;
  --surface-elevated: #1f1f1f;
  --border: #2e2e2e;
  --text: #f5f5f5;
  --muted: #737373;
  --accent: #dc2626;
  --accent-hover: #ef4444;
  --accent-muted: rgba(220, 38, 38, 0.12);
  --accent-glow: rgba(220, 38, 38, 0.35);
  --bg-grid-image: url('../assets/grid-tile.svg');
  --bg-grid-size: 56px 56px;
  --bg-ambient: radial-gradient(
    ellipse 150% 100% at 80% -10%,
    rgba(220, 38, 38, 0.03) 0%,
    transparent 68%
  );
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background-color: var(--bg);
}

body {
  margin: 0;
  font-family: var(--sans);
  background-color: var(--bg);
  background-image: var(--bg-ambient), var(--bg-grid-image);
  background-size: auto, var(--bg-grid-size);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  background: transparent;
}

.layout-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.setup-mode-banner-root:not([hidden]) {
  display: block;
  flex-shrink: 0;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  box-shadow: inset -2px 0 0 var(--accent-muted);
}

.brand {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--text);
  letter-spacing: 0.02em;
}

.brand span,
.brand-accent {
  color: var(--accent);
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0;
}

.tenant-switcher {
  margin-bottom: 1.5rem;
}

.tenant-switcher label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.tenant-select,
#tenant-select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

#tenant-select:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

#tenant-select:focus,
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.nav-icon {
  width: 1.1rem;
  flex-shrink: 0;
  text-align: center;
  font-size: 0.9rem;
  opacity: 0.85;
}

.nav-link.active .nav-icon {
  opacity: 1;
}

.nav-section {
  margin-bottom: 0;
  padding-bottom: 0.15rem;
}

.nav-section:not(:first-child) {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}

.nav-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
}

.nav-section-label {
  display: block;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.45rem 0.5rem;
  font-weight: 600;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.nav-link.active {
  background: var(--accent-muted);
  color: var(--text);
  text-decoration: none;
  border-left: 3px solid var(--accent);
  padding-left: calc(0.75rem - 3px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.main {
  position: relative;
  width: 100%;
  max-width: 1100px;
  padding: 1.5rem 2rem;
  min-width: 0;
  flex: 1;
  background-color: transparent;
  background-image: linear-gradient(
    180deg,
    rgba(5, 5, 5, 0.4) 0%,
    rgba(0, 0, 0, 0.2) 120px,
    transparent 280px
  );
}

.sidebar-nav-toggle {
  display: none;
  width: 100%;
  margin-top: 1rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.sidebar-nav-toggle:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
}

.sidebar-logout {
  width: 100%;
  margin-top: 1rem;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
  color: var(--text);
}

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

.page-header .page-title {
  margin-bottom: 0;
  flex: 1 1 auto;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  padding-top: 0.35rem;
}

.page-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.page-refresh-btn.is-refreshing .page-refresh-icon {
  display: inline-block;
  animation: page-refresh-spin 0.8s linear infinite;
}

@keyframes page-refresh-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.page-desc {
  color: var(--muted);
  margin: 0 0 1.5rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

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

.grid-actions {
  grid-template-columns: 1fr auto;
  align-items: end;
}

.grid.mb-1 {
  margin-bottom: 1rem;
}

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

.status-card .status-card-extra {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  word-break: break-word;
}

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

.overview-section-header h3 {
  margin: 0;
}

.overview-readiness {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.9rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.overview-readiness strong {
  display: block;
  margin-bottom: 0.15rem;
}

.overview-readiness span {
  color: var(--muted);
  font-size: 0.9rem;
}

.overview-readiness-ok {
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.25);
}

.overview-readiness-warn {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.25);
}

.overview-readiness-link {
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

a.overview-readiness-link:hover {
  text-decoration: underline;
}

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

.overview-summary-header h3 {
  margin: 0;
}

.overview-summary-grid {
  margin-bottom: 1rem;
}

.overview-usage-monitor {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.overview-usage-period {
  color: var(--muted);
  font-size: 0.9rem;
}

.overview-usage-grid {
  margin-top: 1rem;
}

.overview-usage-charge-ok .value {
  color: var(--ok);
}

.overview-usage-charge-warn .value {
  color: var(--warn);
}

.overview-plan-card .value {
  color: var(--accent);
}

.overview-plan-period {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
}

.overview-quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.overview-quick-link {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  text-decoration: none;
}

.overview-quick-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.phone-list-mobile {
  display: none;
}

.call-log-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  margin-bottom: 0.4rem;
}

.call-log-card:last-child {
  margin-bottom: 0;
}

.call-log-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
}

.call-log-card-name {
  font-weight: 600;
  font-size: 0.88rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-log-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.3rem;
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.3;
}

.call-log-card-meta > span {
  white-space: nowrap;
}

.call-log-card-dot {
  opacity: 0.45;
  user-select: none;
}

.call-log-card-summary {
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 0.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-log-card .status-pill {
  flex-shrink: 0;
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
}

.recent-call-card {
  cursor: default;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.call-log-row,
.contact-activity-row {
  cursor: pointer;
}

.call-log-row:hover,
.call-log-row.is-selected,
.contact-activity-row:hover,
.contact-activity-row.is-selected {
  background: var(--surface-2);
}

.phone-list-mobile .call-log-row:hover,
.phone-list-mobile .call-log-row.is-selected,
.phone-list-mobile .contact-activity-row:hover,
.phone-list-mobile .contact-activity-row.is-selected {
  border-color: var(--accent);
  background: var(--surface);
}

.phone-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
}

.phone-card:last-child {
  margin-bottom: 0;
}

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

.phone-card-number {
  font-weight: 600;
  font-size: 1rem;
  word-break: break-all;
}

.phone-card-meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.phone-card-sid code {
  font-size: 0.75rem;
  word-break: break-all;
}

.phone-card-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.text-break {
  word-break: break-word;
  overflow-wrap: anywhere;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top-color: rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
  transition:
    box-shadow 0.2s ease,
    border-color 0.2s ease,
    transform 0.15s ease;
}

.card:hover {
  border-color: rgba(220, 38, 38, 0.22);
  box-shadow:
    0 0 24px var(--accent-muted),
    0 1px 0 rgba(255, 255, 255, 0.05);
  transform: translateY(-1px);
}

.card h3 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.card .value {
  font-size: 1.1rem;
  font-weight: 600;
}

.status-pill {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-ok {
  background: rgba(34, 197, 94, 0.15);
  color: var(--ok);
}

.status-bad {
  background: rgba(239, 68, 68, 0.15);
  color: var(--bad);
}

.status-warn {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warn);
}

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

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

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
}

code,
pre {
  font-family: var(--mono);
  font-size: 0.85rem;
}

pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
}

.form-group {
  margin-bottom: 1rem;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input,
textarea,
select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

input[type='checkbox'],
input[type='radio'] {
  width: auto;
  padding: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
}

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

.btn {
  display: inline-block;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 16px var(--accent-glow);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.contact-list-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.contact-list-search {
  flex: 1 1 280px;
  max-width: 420px;
  margin: 0;
}

.contact-list-search-input {
  width: 100%;
  margin: 0;
}

.pagination-summary,
.pagination-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.pagination-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pagination-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.rule-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.rule-row .rule-input {
  flex: 1;
}

.prompt-preview {
  max-height: 420px;
  overflow-y: auto;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.user-badge {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.35rem;
  line-height: 1.35;
}

.wizard-steps {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.wizard-step {
  flex: 1;
  min-width: 120px;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.wizard-step.active {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-muted);
}

.wizard-step.done {
  color: var(--ok);
  border-color: rgba(34, 197, 94, 0.35);
}

.wizard-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.review-table th {
  width: 140px;
  vertical-align: top;
}

.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background-color: var(--bg);
  background-image: var(--bg-ambient), var(--bg-grid-image);
  background-size: auto, var(--bg-grid-size);
}

.login-page-brand {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 2rem;
  color: var(--text);
}

.login-page-desc {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0;
}

.login-error {
  color: var(--bad);
  font-size: 0.85rem;
  min-height: 1.25rem;
  margin: 0 0 0.75rem;
}

.login-submit {
  width: 100%;
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 0 0 1px var(--accent-muted), 0 24px 48px rgba(0, 0, 0, 0.6);
}

.login-box h2 {
  color: var(--text);
  margin-top: 0;
}

.login-box h2::after {
  content: '';
  display: block;
  width: 2.5rem;
  height: 3px;
  background: var(--accent);
  margin-top: 0.5rem;
  border-radius: 2px;
}

.login-forgot-wrap {
  margin: 0.75rem 0 0;
  text-align: center;
}

.login-forgot-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
  text-decoration: underline;
}

.login-forgot-panel[hidden],
#login-form[hidden],
#login-header[hidden] {
  display: none;
}

.login-forgot-message {
  font-size: 0.85rem;
  min-height: 1.25rem;
  margin: 0 0 0.75rem;
}

.login-forgot-message-ok {
  color: var(--ok);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
}

.modal-card h3 {
  margin-top: 0;
}

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

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

.temp-password-value {
  display: inline-block;
  margin-left: 0.35rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95rem;
}

.users-actions-cell {
  white-space: nowrap;
}

.users-actions-cell .btn {
  margin-right: 0.35rem;
  margin-bottom: 0.25rem;
}

.hidden {
  display: none !important;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-warn {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fcd34d;
}

.alert-ok {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #86efac;
}

.alert-bad {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.method {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.method-get {
  background: rgba(34, 197, 94, 0.2);
  color: var(--ok);
}

.method-post {
  background: var(--accent-muted);
  color: var(--accent-hover);
}

.method-ws {
  background: rgba(220, 38, 38, 0.08);
  color: #f87171;
}

.integration-ref-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.integration-ref-item {
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.integration-ref-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.integration-ref-meta strong {
  font-size: 0.95rem;
}

.integration-ref-note {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.35rem 0 0.65rem;
}

.integration-ref-url-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.integration-ref-url {
  flex: 1 1 240px;
  display: block;
  word-break: break-all;
  font-size: 0.82rem;
  padding: 0.5rem 0.65rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.integration-ref-copy {
  flex-shrink: 0;
}

.drawer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 0.75rem;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  list-style: none;
  user-select: none;
}

.drawer-header::-webkit-details-marker {
  display: none;
}

.drawer-header::marker {
  content: '';
}

.drawer-header:hover {
  color: var(--text);
}

.drawer-title {
  flex: 1;
}

.drawer-meta {
  font-size: 0.75rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  color: var(--muted);
}

.drawer-chevron {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.drawer:not([open]) .drawer-chevron {
  transform: rotate(-90deg);
}

.drawer-body {
  padding: 0 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
}

.drawer-nested {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.75rem;
  background: var(--surface-2);
}

.drawer-nested .drawer-header {
  padding: 0.65rem 1rem;
  font-size: 0.8rem;
}

.drawer-nested .drawer-body {
  padding: 0 1rem 1rem;
}

.kb-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

#ghl-disposition-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.disposition-drawer .drawer-header {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
}

.disposition-summary .drawer-title {
  font-weight: 600;
  color: var(--text);
}

.disposition-summary .drawer-meta {
  font-size: 0.8rem;
}

.kb-section {
  margin-bottom: 1rem;
}

.kb-section-heading {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--text);
}

.kb-category-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.kb-entry-drawer .drawer-header {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
}

.kb-entry-summary .drawer-title {
  font-weight: 600;
  color: var(--text);
}

.kb-entry-summary .drawer-meta {
  max-width: 48%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
}

.kb-readonly-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  background: var(--surface);
}

.kb-readonly-agent {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.kb-readonly-preview {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.kb-card {
  overflow: visible;
}

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

.kb-add-section {
  min-width: 0;
}

.kb-add-drawer {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.kb-add-drawer > .kb-add-form-body {
  padding-top: 0;
}

.kb-add-summary {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
}

.kb-add-summary .drawer-title {
  font-weight: 600;
  color: var(--text);
}

.kb-starter-summary-btn {
  display: none;
  margin-left: auto;
  margin-right: 0.35rem;
}

.kb-add-form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.kb-controls {
  display: grid;
  grid-template-columns: 1fr minmax(160px, 220px);
  gap: 0.75rem;
  align-items: end;
}

.kb-category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.kb-category-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
}

.kb-category-pill.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

.kb-pill-count {
  color: var(--muted);
  font-size: 0.75rem;
}

.kb-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 1rem;
  align-items: start;
}

.kb-list-panel,
.kb-editor-panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  min-width: 0;
}

.kb-list-panel {
  padding: 0.75rem;
}

.kb-list-meta {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.kb-list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.kb-list-table th {
  text-align: left;
  padding: 0.45rem 0.5rem;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}

.kb-list-table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.kb-list-row {
  cursor: pointer;
}

.kb-list-row:hover {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

.kb-list-row.is-selected {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.kb-list-row.is-dragging {
  opacity: 0.55;
}

.kb-list-row.is-drop-target td {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.kb-drag-handle {
  width: 1.5rem;
  color: var(--muted);
  cursor: grab;
  user-select: none;
  font-size: 0.9rem;
  letter-spacing: -0.15em;
}

.kb-list-title {
  font-weight: 600;
  max-width: 12rem;
}

.kb-list-preview {
  color: var(--muted);
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-list-empty {
  text-align: center;
  color: var(--muted);
  padding: 1.5rem 0.5rem !important;
}

.kb-list-mobile {
  display: none;
}

.kb-list-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--surface);
  cursor: pointer;
}

.kb-list-card:last-child {
  margin-bottom: 0;
}

.kb-list-card:hover {
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

.kb-list-card.is-selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}

.kb-list-card.is-dragging {
  opacity: 0.55;
}

.kb-list-card.is-drop-target {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
}

.kb-list-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.kb-list-card-title {
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 0;
}

.kb-list-card-meta {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.kb-list-card-preview {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kb-editor-panel {
  padding: 1rem;
  position: sticky;
  top: 0.5rem;
}

.kb-editor-empty p {
  margin: 0;
  color: var(--muted);
}

.kb-editor-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.kb-readonly-content {
  margin: 0.75rem 0;
  padding: 0.75rem;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  white-space: pre-wrap;
  font-size: 0.85rem;
  max-height: 320px;
  overflow: auto;
}

@media (min-width: 961px) {
  .kb-add-section {
    position: sticky;
    top: 0;
    z-index: 2;
    margin-bottom: 0.25rem;
  }

  .kb-add-drawer > summary {
    display: none;
  }

  .kb-add-drawer > .kb-add-form-body {
    display: block !important;
  }
}

@media (max-width: 960px) {
  .kb-add-section {
    order: 0;
  }

  .kb-workspace-controls {
    order: 1;
  }

  .kb-workspace-pills {
    order: 2;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
    scrollbar-width: none;
  }

  .kb-workspace-pills::-webkit-scrollbar {
    display: none;
  }

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

  .kb-add-summary-meta {
    display: none;
  }

  .kb-starter-summary-btn {
    display: inline-flex;
  }

  .kb-add-form-header .kb-starter-btn:not(.kb-starter-summary-btn) {
    display: none;
  }

  .kb-add-form-header h3 {
    display: none;
  }

  .kb-editor-panel {
    position: static;
  }

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

  .kb-list-table-wrap,
  .kb-list-table-desktop {
    display: none;
  }

  .kb-list-mobile {
    display: block;
  }

  .kb-list-meta {
    font-size: 0.75rem;
  }
}

.drawer-footer {
  padding-top: 0.5rem;
  margin-top: 0.25rem;
}

.analytics-presets {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.analytics-summary-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

#analytics-content {
  min-width: 0;
  max-width: 100%;
}

.analytics-summary-card .value {
  font-size: 1.1rem;
}

.analytics-range-note {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 1rem;
}

.analytics-synopsis-card {
  margin-bottom: 1rem;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
}

.analytics-synopsis-loading {
  margin-bottom: 1rem;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border));
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--accent) 6%, var(--surface)) 0%,
    var(--surface) 55%
  );
}

.analytics-synopsis-loading:hover {
  transform: none;
}

.analytics-synopsis-loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: 7rem;
  padding: 1.25rem 1rem;
}

.analytics-synopsis-loader {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.35rem;
  height: 2.25rem;
}

.analytics-synopsis-loader span {
  display: block;
  width: 0.35rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
  animation: analytics-synopsis-wave 1s ease-in-out infinite;
}

.analytics-synopsis-loader span:nth-child(1) {
  animation-delay: 0s;
}

.analytics-synopsis-loader span:nth-child(2) {
  animation-delay: 0.12s;
}

.analytics-synopsis-loader span:nth-child(3) {
  animation-delay: 0.24s;
}

.analytics-synopsis-loader span:nth-child(4) {
  animation-delay: 0.36s;
}

.analytics-synopsis-loader span:nth-child(5) {
  animation-delay: 0.48s;
}

.analytics-synopsis-loading-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
  animation: analytics-synopsis-text-fade 1.8s ease-in-out infinite;
}

@keyframes analytics-synopsis-wave {
  0%,
  100% {
    height: 0.5rem;
    opacity: 0.45;
  }

  50% {
    height: 2rem;
    opacity: 1;
  }
}

@keyframes analytics-synopsis-text-fade {
  0%,
  100% {
    opacity: 0.72;
  }

  50% {
    opacity: 1;
  }
}

.analytics-synopsis-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.analytics-synopsis-headline {
  margin: 0;
  font-size: 1.15rem;
}

.analytics-synopsis-meta {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0.35rem 0 0;
}

.analytics-sentiment-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}

.analytics-sentiment-badge.positive {
  background: color-mix(in srgb, #22c55e 18%, transparent);
  color: #15803d;
}

.analytics-sentiment-badge.mixed {
  background: color-mix(in srgb, #f59e0b 18%, transparent);
  color: #b45309;
}

.analytics-sentiment-badge.neutral {
  background: color-mix(in srgb, var(--muted) 18%, transparent);
  color: var(--muted);
}

.analytics-sentiment-badge.negative {
  background: color-mix(in srgb, #ef4444 18%, transparent);
  color: #b91c1c;
}

.analytics-synopsis-section {
  margin-top: 1rem;
}

.analytics-synopsis-section h4 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

.analytics-synopsis-section ul {
  margin: 0;
  padding-left: 1.1rem;
}

.analytics-synopsis-section li + li {
  margin-top: 0.35rem;
}

.analytics-synopsis-sentiment-notes {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.5rem 0 0;
}

.analytics-scroll-hint {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0 0 0.75rem;
}

.agency-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1rem;
}

.agency-section-head h3,
.agency-inline-heading {
  margin: 0;
}

.agency-section-sub {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.35rem 0 0;
}

.agency-inline-heading {
  margin: 0 0 0.25rem;
}

.agency-plan-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.agency-plan-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: var(--surface-2, rgba(255, 255, 255, 0.06));
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  font-size: 0.8rem;
  color: var(--muted);
}

.agency-recurring-card .analytics-summary-grid {
  margin-top: 0;
}

.agency-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.agency-tab {
  appearance: none;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  background: var(--surface-2, rgba(255, 255, 255, 0.04));
  color: var(--muted);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.agency-tab:hover {
  color: var(--text);
}

.agency-tab.is-active {
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.agency-tab-panel[hidden] {
  display: none !important;
}

.agency-financial-hero {
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
}

.agency-hero-grid {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.analytics-chart-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.analytics-outcomes-grid {
  margin-top: 1rem;
  min-width: 0;
}

.analytics-outcomes-grid .card {
  min-width: 0;
}

.agent-breakdown-mobile {
  display: none;
}

.analytics-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  min-height: 200px;
  padding-top: 0.5rem;
  width: max-content;
  min-width: 100%;
  box-sizing: border-box;
}

.analytics-bar {
  flex: 1 1 28px;
  min-width: 28px;
  max-width: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  height: 180px;
}

.analytics-bar-count {
  font-size: 0.7rem;
  color: var(--muted);
  min-height: 1rem;
}

.analytics-bar-fill {
  width: 100%;
  background: linear-gradient(180deg, var(--accent-hover), var(--accent));
  border-radius: 4px 4px 0 0;
  min-height: 4px;
}

.analytics-bar-stack {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-radius: 4px 4px 0 0;
  overflow: hidden;
  min-height: 4px;
}

.analytics-bar-stack--empty {
  min-height: 0;
}

.analytics-bar-segment {
  width: 100%;
  min-height: 0;
}

.analytics-bar-segment--booked {
  background: #22c55e;
}

.analytics-bar-segment--qualified {
  background: #eab308;
}

.analytics-bar-segment--other {
  background: linear-gradient(180deg, var(--accent-hover), var(--accent));
}

.analytics-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.analytics-chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.analytics-chart-legend-swatch {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 2px;
  flex-shrink: 0;
}

.analytics-bar-label {
  font-size: 0.65rem;
  color: var(--muted);
  white-space: nowrap;
}

.analytics-chart--scrollable .analytics-bar {
  flex: 0 0 24px;
  min-width: 24px;
  max-width: 24px;
}

.outcome-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.outcome-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.75rem;
  align-items: center;
}

.outcome-row-main {
  min-width: 0;
}

.outcome-label {
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
  text-transform: capitalize;
  overflow-wrap: anywhere;
}

.outcome-bar-track {
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.outcome-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.outcome-count,
.outcome-percent {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

.outcome-count {
  font-weight: 600;
  color: var(--text);
}

.outcome-stats-mobile {
  display: none;
}

@media (max-width: 768px) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    overflow-x: hidden;
  }

  .layout {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
  }

  .sidebar-nav-toggle {
    display: block;
  }

  .sidebar-nav-panel {
    display: none;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
  }

  .sidebar-nav-panel.is-open {
    display: block;
  }

  .main {
    padding: 1rem;
    min-width: 0;
    max-width: 100%;
    overflow-x: clip;
  }

  .card {
    min-width: 0;
    max-width: 100%;
    overflow-x: clip;
  }

  .tab-strip {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab-strip-btn {
    flex: 0 0 auto;
    min-width: auto;
  }

  .config-summary,
  .integration-health-grid {
    grid-template-columns: 1fr;
  }

  .page-title {
    font-size: 1.35rem;
  }

  .page-desc {
    margin-bottom: 1rem;
  }

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

  .analytics-outcomes-grid {
    min-width: 0;
  }

  .analytics-outcomes-grid .card {
    min-width: 0;
  }

  .grid-2,
  .grid-actions {
    grid-template-columns: 1fr;
  }

  .grid-actions .btn {
    width: 100%;
  }

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

  .drawer-meta {
    flex-basis: 100%;
    margin-top: 0.15rem;
  }

  th,
  td {
    padding: 0.5rem 0.6rem;
    font-size: 0.85rem;
  }

  .rule-row {
    flex-wrap: wrap;
  }

  .rule-row .btn {
    width: 100%;
  }

  .wizard-step {
    min-width: 0;
    flex: 1 1 calc(50% - 0.25rem);
  }

  .login-page {
    padding: 1rem;
  }

  .login-box {
    padding: 1.5rem;
  }

  .phone-list-mobile {
    display: block;
  }

  .phone-table-desktop {
    display: none;
  }

  .phone-card-actions .btn {
    width: 100%;
  }

  .btn-full-mobile {
    width: 100%;
  }

  .card .value {
    word-break: break-word;
  }

  .card p {
    word-break: break-word;
  }

  .outcome-row {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .outcome-stats-desktop {
    display: none;
  }

  .outcome-stats-mobile {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.35rem;
    font-size: 0.85rem;
  }

  .outcome-count,
  .outcome-percent {
    display: inline-block;
    margin-right: 0;
  }

  .status-grid {
    grid-template-columns: 1fr;
    gap: 0.65rem;
    margin-bottom: 1rem;
  }

  .status-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 0.75rem;
    padding: 0.85rem 1rem;
  }

  .status-card h3 {
    margin: 0;
    flex: 1 1 140px;
    font-size: 0.8rem;
    line-height: 1.3;
  }

  .status-card .value {
    font-size: 0.9rem;
    flex-shrink: 0;
  }

  .status-card .status-card-extra {
    flex-basis: 100%;
    margin-top: 0;
    font-size: 0.8rem;
  }

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

  .overview-section-header .btn {
    width: 100%;
    text-align: center;
  }

  .overview-readiness {
    flex-direction: column;
    align-items: stretch;
  }

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

  .overview-summary-header .btn {
    width: 100%;
    text-align: center;
  }

  #health-json {
    font-size: 0.75rem;
    padding: 0.75rem;
  }

  .analytics-presets {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .analytics-presets .btn {
    width: 100%;
  }

  .analytics-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
    margin-bottom: 1rem;
  }

  .analytics-summary-card {
    padding: 0.85rem 1rem;
  }

  .analytics-summary-card h3 {
    font-size: 0.72rem;
    margin-bottom: 0.35rem;
    line-height: 1.3;
  }

  .analytics-summary-card .value {
    font-size: 1rem;
  }

  .analytics-range-note {
    font-size: 0.85rem;
  }

  .analytics-chart {
    min-height: 150px;
    gap: 0.25rem;
    margin: 0;
    padding: 0.25rem 0 0;
  }

  .analytics-chart--scrollable .analytics-bar,
  .analytics-bar {
    flex: 0 0 34px;
    min-width: 34px;
    max-width: 34px;
    height: 140px;
  }

  .analytics-bar-count {
    font-size: 0.65rem;
  }

  .analytics-bar-label {
    display: none;
  }

  .agent-breakdown-mobile {
    display: block;
  }

  .agent-breakdown-desktop {
    display: none;
  }

  .agent-stat-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    margin-bottom: 0.65rem;
  }

  .agent-stat-card:last-child {
    margin-bottom: 0;
  }

  .agent-stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
  }

  .agent-stat-name {
    font-weight: 600;
    font-size: 0.95rem;
  }

  .agent-stat-slug {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.15rem;
    word-break: break-all;
  }
}

/* Tab strip (Agent & Prompts) */
.tab-strip {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.tab-strip-btn {
  flex: 1 1 auto;
  min-width: 5.5rem;
  padding: 0.55rem 0.85rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab-strip-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.tab-strip-btn.active {
  background: var(--accent-muted);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.tab-section {
  margin-bottom: 1rem;
}

.tab-section:last-child {
  margin-bottom: 0;
}

.tab-section h3 {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.tab-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* Config completion summary */
.config-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.config-summary-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.75rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
}

.config-summary-item strong {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 0.15rem;
}

.config-summary-item span {
  color: var(--muted);
  font-size: 0.8rem;
}

.config-summary-icon {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
}

.config-summary-item.is-ok .config-summary-icon {
  background: rgba(34, 197, 94, 0.15);
  color: var(--ok);
}

.config-summary-item.is-warn .config-summary-icon {
  background: rgba(234, 179, 8, 0.15);
  color: var(--warn);
}

/* Integration health card (Control Panel) */
.integration-health-card {
  margin-bottom: 1rem;
}

.integration-health-card.needs-attention {
  border-color: rgba(234, 179, 8, 0.35);
}

.integration-health-card.is-healthy {
  border-color: rgba(34, 197, 94, 0.25);
}

.integration-health-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.integration-health-header h3 {
  margin: 0;
}

.integration-health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.65rem;
}

.integration-health-item {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: 0.85rem;
}

.integration-health-item strong {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 0.1rem;
}

.integration-health-item span {
  color: var(--muted);
  font-size: 0.8rem;
  word-break: break-word;
}

.integration-health-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 0.35rem;
}

.integration-health-item.is-ok .integration-health-dot {
  background: var(--ok);
}

.integration-health-item.is-warn .integration-health-dot {
  background: var(--warn);
}

.billing-rates-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 1rem 0 0;
}

.billing-rates-fieldset legend {
  padding: 0 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.billing-rates-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.billing-rate-actions {
  margin-top: 1rem;
}

.billing-included-card {
  margin-top: 1rem;
}

.billing-progress-track {
  height: 0.65rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 80%, transparent);
  overflow: hidden;
}

.billing-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #fff));
  transition: width 0.3s ease;
}

.billing-bar-fill {
  background: color-mix(in srgb, var(--accent) 85%, #fff);
}

.billing-rates-dl {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem 1.5rem;
  margin: 0;
}

.billing-rates-dl div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
}

.billing-rates-dl dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.billing-rates-dl dd {
  margin: 0;
  font-weight: 600;
}

/* UI kit */
.ui-skeleton {
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--border) 60%, transparent) 25%,
    color-mix(in srgb, var(--border) 30%, transparent) 50%,
    color-mix(in srgb, var(--border) 60%, transparent) 75%
  );
  background-size: 200% 100%;
  animation: ui-shimmer 1.2s ease-in-out infinite;
  border-radius: 4px;
  min-height: 0.85rem;
}

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

.ui-skeleton-card {
  display: grid;
  gap: 0.75rem;
}

.ui-skeleton-table-wrap .ui-skeleton-line {
  min-height: 0.65rem;
}

.ui-card-hint {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.ui-empty-state {
  padding: 1.5rem 0;
  text-align: center;
  color: var(--muted);
}

.ui-empty-title {
  margin: 0;
  font-weight: 600;
  color: var(--text);
}

.ui-empty-desc {
  margin: 0.35rem 0 0;
}

.toast-root {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.ui-toast {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transform: translateY(0.5rem);
  transition: opacity 0.25s, transform 0.25s;
}

.ui-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.ui-toast-ok {
  border-color: color-mix(in srgb, var(--ok) 40%, var(--border));
}

.ui-toast-bad {
  border-color: color-mix(in srgb, var(--bad) 40%, var(--border));
}

.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;
}

.ai-chat-layout {
  display: flex;
  flex-direction: column;
  min-height: 28rem;
  max-height: calc(100vh - 12rem);
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 16rem;
}

.ai-chat-empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  max-width: 28rem;
}

.ai-chat-empty p {
  margin: 0.35rem 0 0;
}

.ai-chat-message {
  display: flex;
}

.ai-chat-message.is-user {
  justify-content: flex-end;
}

.ai-chat-message.is-assistant {
  justify-content: flex-start;
}

.ai-chat-bubble {
  max-width: min(100%, 42rem);
  padding: 0.85rem 1rem;
  border-radius: calc(var(--radius) + 2px);
  line-height: 1.5;
}

.ai-chat-message.is-user .ai-chat-bubble {
  background: color-mix(in srgb, var(--accent) 18%, var(--card));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
}

.ai-chat-message.is-assistant .ai-chat-bubble {
  background: color-mix(in srgb, var(--border) 25%, var(--card));
  border: 1px solid var(--border);
}

.ai-chat-starters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0 1rem 0.75rem;
  border-top: 1px solid var(--border);
}

.ai-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
  align-items: end;
}

.ai-chat-form textarea {
  resize: vertical;
  min-height: 3rem;
  max-height: 10rem;
}

.ai-chat-artifacts {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.ai-chat-artifact {
  padding: 0.75rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--card) 85%, var(--bg));
  border: 1px solid var(--border);
}

.ai-chat-artifact-title {
  font-weight: 600;
}

.ai-chat-artifact-meta,
.ai-chat-artifact-summary {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.ai-chat-artifact-link {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

@media (max-width: 768px) {
  .ai-chat-layout {
    max-height: none;
    min-height: 24rem;
  }

  .ai-chat-form {
    grid-template-columns: 1fr;
  }
}

.setup-mode-banner {
  margin: 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.85rem 2rem;
}

.setup-mode-banner-copy {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.setup-mode-banner-copy span {
  color: var(--muted);
  font-size: 0.92rem;
}

@media (max-width: 768px) {
  .setup-mode-banner {
    padding: 0.85rem 1rem;
  }
}

.setup-checklist {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.85rem;
}

.setup-checklist-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: start;
}

.setup-checklist-item p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.setup-checklist-marker {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 0.85rem;
}

.setup-checklist-item.is-done .setup-checklist-marker {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
}
