/* Base overrides to align legacy elements with Teal Carbon tokens */
body {
  font-family: var(--font-family, 'Inter', system-ui, sans-serif);
  font-size: var(--font-md);
  background-color: var(--color-bg);
  color: var(--color-text);
  margin: 0;
}

.ui-shell h1,
.ui-shell h2,
.ui-shell h3,
.ui-shell h4,
.ui-shell h5,
.ui-shell h6 {
  font-family: var(--font-family-heading);
  letter-spacing: -0.01em;
}

header {
  background-color: var(--color-surface);
  box-shadow: var(--shadow-sm);
  border-bottom: 1px solid var(--color-border);
}

.ui-nav {
  display: flex;
  gap: 18px;
  align-items: center;
}

.ui-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-nav-text);
  transition: color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.ui-nav-link:hover {
  color: var(--color-nav-text-strong);
  background: var(--color-primary-weak);
}

.ui-nav-link.is-active {
  color: var(--color-nav-text-strong);
  background: var(--color-primary-weak);
  box-shadow: var(--glow-mint);
}

.ui-nav-cta {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: var(--radius-md);
  color: var(--color-on-primary);
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-strong));
  box-shadow: var(--glow-mint);
}

.ui-nav-cta:hover {
  filter: brightness(1.04);
}

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

a:hover {
  text-decoration: underline;
}

.ui-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-text-strong);
  background: color-mix(in srgb, var(--color-warning) 18%, white);
  border: 1px solid color-mix(in srgb, var(--color-warning) 35%, transparent);
}

.ui-card-light {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-sm);
  min-height: 140px;
}

/* Pattern primitives */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-strong);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.callout {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}

.guidance-card {
  border: 1px solid color-mix(in srgb, var(--color-primary) 35%, var(--color-border));
  background: color-mix(in srgb, var(--color-primary-weak) 30%, var(--color-surface));
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.empty-state {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 18px;
  background: var(--color-surface);
  color: var(--color-muted);
  text-align: center;
}

.step-rail {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.step-rail__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-muted);
  font-size: 12px;
  font-weight: 600;
}

.step-rail__item.is-active {
  color: var(--color-text-strong);
  border-color: var(--color-primary);
  background: var(--color-primary-weak);
}

.step-rail__item.is-complete {
  color: var(--color-text-strong);
  border-color: color-mix(in srgb, var(--color-primary) 45%, var(--color-border));
}

.step-rail__dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--color-border);
}

.step-rail__item.is-active .step-rail__dot,
.step-rail__item.is-complete .step-rail__dot {
  background: var(--color-primary);
}

.info-modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 18px;
  box-shadow: var(--modal-shadow-soft);
  padding: 24px;
}

.step-timeline {
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
}

.step-timeline__item {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 0;
  color: var(--color-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.step-timeline__dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--color-border);
  border: 2px solid var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-border);
  flex: 0 0 auto;
}

.step-timeline__item.is-active {
  color: var(--color-text-strong);
}

.step-timeline__item.is-active .step-timeline__dot,
.step-timeline__item.is-complete .step-timeline__dot {
  background: var(--color-primary);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-primary) 60%, var(--color-border));
}

.step-timeline__line {
  height: 1px;
  flex: 1 1 auto;
  background: var(--color-border);
  margin: 0 12px;
}

.step-timeline__label {
  white-space: nowrap;
}

.ui-header-actions {
  min-width: 220px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: var(--color-on-primary);
  font-weight: 600;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
  min-height: 44px;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--glow-mint);
}

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

.btn-secondary:hover {
  border-color: var(--color-primary);
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background-color: var(--color-surface);
  color: var(--color-text);
  min-height: 42px;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--color-muted) 50%),
    linear-gradient(135deg, var(--color-muted) 50%, transparent 50%),
    linear-gradient(to right, transparent, transparent);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 12px) calc(50% - 2px),
    calc(100% - 36px) 0.5rem;
  background-size: 6px 6px, 6px 6px, 1px 1.5rem;
  background-repeat: no-repeat;
  padding-right: 40px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 1.5px solid var(--color-focus);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-focus);
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  min-height: auto;
  padding: 0;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  accent-color: var(--color-primary);
  cursor: pointer;
}

input[type="radio"] {
  border-radius: 999px;
}

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.ui-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.ui-field .ui-input,
.ui-field input,
.ui-field select,
.ui-field textarea {
  margin-top: 0;
}

.ui-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-strong);
  letter-spacing: 0.01em;
}

.ui-field .ui-hint {
  font-size: 12px;
  color: var(--color-muted);
}

.ui-field .ui-inline,
.ui-inline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ui-field .ui-inline label,
.ui-inline label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  letter-spacing: 0;
}

.ui-input-compact {
  padding: 6px 10px;
  font-size: 13px;
}

.card {
  background-color: var(--color-panel);
  padding: 1.5rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
}

footer {
  background-color: var(--color-surface);
  color: var(--color-muted);
}

/* Toasts */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}
.toast {
  min-width: 260px;
  max-width: 360px;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-primary);
  color: var(--color-text);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  font-size: var(--font-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  backdrop-filter: blur(12px);
}
.toast.success { border-left-color: var(--color-success); }
.toast.error { border-left-color: var(--color-error); }
.toast .close {
  background: none;
  border: none;
  color: var(--color-muted);
  cursor: pointer;
}

/* Standard button variants */
.ui-btn-success {
  background: var(--color-success);
  color: var(--color-on-primary);
  border: 1px solid var(--color-success);
  box-shadow: none;
}

.ui-btn-danger {
  background: var(--color-error);
  color: var(--color-on-primary);
  border: 1px solid var(--color-error);
  box-shadow: none;
}

.ui-btn-ghost {
  background: var(--color-surface);
  border: 1px solid var(--color-primary);
  color: var(--color-primary);
}

.ui-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 12px;
}

.ui-icon-btn svg {
  width: 16px;
  height: 16px;
}

.ui-btn-close {
  background: transparent;
  border: none;
  color: var(--color-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: color 150ms ease;
}

.ui-btn-close:hover {
  color: var(--color-error);
}

.ui-auth-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(48px, 8vh, 88px) 16px;
  background:
    linear-gradient(180deg, var(--color-primary-weak), transparent 240px),
    var(--color-bg);
}

.ui-auth-shell--plain {
  background: var(--color-bg);
}

.ui-auth-card {
  width: min(680px, 100%);
  padding: clamp(24px, 3.2vw, 48px);
  border-radius: 20px;
  border: 1px solid var(--color-border);
  background: var(--color-panel);
  color: var(--color-text);
  box-shadow: var(--modal-shadow-soft);
}

.ui-auth-card .ui-input,
.ui-auth-card textarea.ui-input,
.ui-auth-card input.ui-input {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text);
}

.ui-auth-card .ui-input::placeholder {
  color: color-mix(in srgb, var(--color-muted) 88%, transparent);
}

.ui-auth-card a {
  color: var(--color-primary);
}

.ui-auth-card a:hover {
  color: var(--color-primary-strong);
}

.ui-auth-card.mfa-modal .ui-alert {
  background: var(--color-surface-muted);
  border-color: var(--color-border);
  color: var(--color-text);
}

.ui-auth-card.mfa-modal .ui-alert .text-[color:var(--color-muted)] {
  color: var(--color-muted);
}

.ui-auth-card.mfa-modal .ui-btn-secondary {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text);
}

.ui-auth-card.mfa-modal {
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: clamp(20px, 3vw, 32px);
  font-size: clamp(0.82rem, 1.05vw, 0.95rem);
  line-height: 1.35;
}

.ui-auth-card.mfa-modal.is-scroll {
  overflow-y: auto;
}

.ui-auth-card.mfa-modal .ui-input {
  padding: 10px 12px;
}

.ui-auth-card.mfa-modal .ui-auth-actions {
  gap: 12px;
}

.ui-auth-card.mfa-modal .ui-auth-actions .ui-btn {
  min-width: 140px;
}

.ui-auth-card.mfa-modal .mfa-qr {
  padding: 10px;
}

.ui-auth-card.mfa-modal .mfa-qr svg {
  width: clamp(150px, 26vw, 200px);
  height: clamp(150px, 26vw, 200px);
}

.ui-auth-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.ui-auth-actions .ui-btn {
  min-width: 160px;
}

.ui-link-emphasis {
  color: var(--color-secondary-strong);
  text-decoration: underline;
}

.ui-link-emphasis:hover {
  color: var(--color-secondary);
}

.ui-status-success {
  color: var(--color-success) !important;
}

.ui-status-error {
  color: var(--color-error) !important;
}

.ui-status-warning {
  color: var(--color-warning) !important;
}

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

.ui-alert-success {
  border-color: var(--color-success);
  background: var(--color-success-weak);
  color: var(--color-success);
}

.ui-alert-error {
  border-color: var(--color-error);
  background: var(--color-error-weak);
  color: var(--color-error);
}

.ui-alert-warning {
  border-color: var(--color-warning);
  background: var(--color-warning-weak);
  color: var(--color-warning);
}

.ui-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--banner-info-border);
  background: var(--banner-info-bg);
  color: var(--banner-info-text);
  box-shadow: var(--shadow-sm);
}

.ui-banner.hidden {
  display: none;
}

.ui-banner-warning {
  border-color: var(--banner-warning-border);
  background: var(--banner-warning-bg);
  color: var(--banner-warning-text);
}

.ui-banner-success {
  border-color: var(--banner-success-border);
  background: var(--banner-success-bg);
  color: var(--banner-success-text);
}

.ui-banner-error {
  border-color: var(--banner-error-border);
  background: var(--banner-error-bg);
  color: var(--banner-error-text);
}

.ui-tip-tooltip {
  position: fixed;
  z-index: 90;
  width: min(320px, 92vw);
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 12px 14px;
  display: grid;
  gap: 8px;
  color: var(--color-text);
}

.ui-tip-tooltip.hidden {
  display: none;
}

.ui-tip-tooltip::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--color-panel);
  border-left: 1px solid var(--color-border);
  border-top: 1px solid var(--color-border);
  transform: rotate(45deg);
}

.ui-tip-tooltip[data-placement="bottom"]::after {
  top: -7px;
  left: 18px;
}

.ui-tip-tooltip[data-placement="top"]::after {
  bottom: -7px;
  left: 18px;
  transform: rotate(225deg);
}

/* Confirm modal */
#confirm-modal {
  display: flex;
  align-items: center;
  justify-content: center;
}

#confirm-modal.hidden {
  display: none;
}

#confirm-modal .confirm-backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(var(--overlay-blur));
}

#confirm-modal .confirm-panel {
  position: relative;
  width: min(92vw, 480px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  box-shadow: var(--modal-shadow);
  z-index: 1;
  padding: 18px 20px;
}

#confirm-modal[data-tone="danger"] .confirm-panel {
  border-color: var(--modal-border-danger);
  box-shadow: var(--modal-shadow-danger);
}

#confirm-modal[data-tone="warning"] .confirm-panel {
  border-color: var(--modal-border-warning);
}

#confirm-modal .confirm-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

#confirm-modal .confirm-body {
  margin-top: 12px;
}

#confirm-modal .confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.ui-tip-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-strong);
}

.ui-tip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--color-primary-weak);
  color: var(--color-primary);
}

.ui-tip-body {
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-text);
}

.ui-tip-dismiss {
  justify-self: start;
  font-size: 11px;
  color: var(--color-muted);
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.ui-text-error {
  color: var(--color-error);
}

.ui-text-success {
  color: var(--color-success);
}

.ui-text-warning {
  color: var(--color-warning);
}

.ui-code-block {
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: var(--color-panel);
  color: var(--color-text);
  font-family: var(--font-mono, "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);
  font-size: 12px;
  line-height: 1.5;
  max-height: 280px;
  overflow: auto;
}

.ui-skeleton-w-80 {
  width: 80px;
}

.ui-skeleton-w-90 {
  width: 90px;
}

.ui-skeleton-w-110 {
  width: 110px;
}

.ui-skeleton-w-140 {
  width: 140px;
}

.ui-skeleton-w-160 {
  width: 160px;
}

.ui-skeleton-w-200 {
  width: 200px;
}

.ui-skeleton-w-80p {
  width: 80%;
}

.ui-skeleton-w-60p {
  width: 60%;
}

.ui-mt-8 {
  margin-top: 8px;
}

.ui-select-compact {
  max-width: 200px;
}

.ui-pointer-auto {
  pointer-events: auto;
}

.ui-btn-outline {
  background: transparent;
  border: 1px solid var(--color-primary);
  color: var(--color-primary);
}

.ui-pill-error {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--color-error);
  background: var(--color-error-weak);
  color: var(--color-error);
  font-weight: 800;
}

/* Map common Tailwind utility colors to theme tokens for consistency */
.bg-white { background-color: var(--color-panel) !important; }
.dark .dark\:bg-gray-800 { background-color: var(--color-panel) !important; }
.dark .dark\:bg-gray-900 { background-color: var(--color-bg) !important; }
.dark .dark\:bg-gray-700 { background-color: var(--color-panel) !important; }
.dark .dark\:bg-gray-800\/60 { background-color: var(--color-panel) !important; }
.dark .dark\:bg-gray-900\/60 { background-color: var(--color-bg) !important; }
.bg-gray-50 { background-color: var(--color-surface) !important; }
.bg-gray-100 { background-color: var(--color-bg) !important; }
.bg-gray-200 { background-color: var(--color-surface) !important; }
.bg-gray-700 { background-color: var(--color-panel) !important; }
.bg-gray-800 { background-color: var(--color-panel) !important; }
.bg-gray-900 { background-color: var(--color-bg) !important; }
.bg-gray-900\/60 { background-color: var(--color-bg) !important; }
.text-gray-900 { color: var(--color-text-strong) !important; }
.text-gray-800 { color: var(--color-text-strong) !important; }
.text-gray-700 { color: var(--color-text) !important; }
.text-gray-600 { color: var(--color-muted) !important; }
.text-gray-500 { color: var(--color-muted) !important; }
.text-gray-400 { color: var(--color-muted) !important; }
.dark .dark\:text-gray-100 { color: var(--color-text-strong) !important; }
.dark .dark\:text-gray-300 { color: var(--color-text) !important; }
.dark .dark\:text-gray-400 { color: var(--color-muted) !important; }
.dark .dark\:text-gray-200 { color: var(--color-text) !important; }
.border-gray-300 { border-color: var(--color-border) !important; }
.border-gray-200 { border-color: var(--color-border) !important; }
.border-gray-600 { border-color: var(--color-border) !important; }
.border-gray-700 { border-color: var(--color-border) !important; }
.border-gray-800 { border-color: var(--color-border) !important; }
.bg-blue-600 { background-color: var(--color-primary) !important; }
.bg-blue-700 { background-color: var(--color-primary-strong) !important; }
.hover\:bg-blue-700:hover { background-color: var(--color-primary-strong) !important; }
.text-blue-600 { color: var(--color-primary) !important; }
.text-blue-700 { color: var(--color-primary-strong) !important; }
.hover\:text-blue-500:hover { color: var(--color-primary-strong) !important; }
.border-blue-500 { border-color: var(--color-primary) !important; }
.hover\:bg-gray-100:hover { background-color: var(--color-primary-weak) !important; }
.dark .dark\:hover\:bg-gray-700:hover { background-color: var(--color-primary-weak) !important; }
.bg-blue-50 { background-color: var(--color-primary-weak) !important; }
.text-cyan-300 { color: var(--color-secondary) !important; }
.text-cyan-400 { color: var(--color-secondary) !important; }
.text-cyan-500 { color: var(--color-secondary) !important; }
.dark .dark\:text-cyan-300 { color: var(--color-secondary) !important; }
.dark .dark\:text-cyan-400 { color: var(--color-secondary) !important; }
.bg-cyan-500 { background-color: var(--color-secondary) !important; }
.dark .dark\:bg-cyan-500 { background-color: var(--color-secondary) !important; }
.hover\:bg-cyan-600:hover { background-color: var(--color-secondary-strong) !important; }
.bg-blue-100 { background-color: var(--color-secondary-weak) !important; }
.bg-blue-50 { background-color: var(--color-secondary-weak) !important; }
.text-blue-800 { color: var(--color-secondary-strong) !important; }
.text-blue-700 { color: var(--color-secondary-strong) !important; }
.dark .dark\:bg-cyan-900\/30 { background-color: var(--color-secondary-weak) !important; }
.dark .dark\:text-cyan-300 { color: var(--color-secondary) !important; }
.bg-red-600 { background-color: var(--color-error) !important; }
.hover\:bg-red-700:hover { background-color: var(--color-error) !important; filter: brightness(0.9); }
.text-red-500 { color: var(--color-error) !important; }

/* Tabulator global theme alignment */
.tabulator {
  background: var(--color-panel) !important;
  color: var(--color-text) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.tabulator .tabulator-tableholder,
.tabulator .tabulator-table {
  background: var(--color-panel) !important;
}

.tabulator .tabulator-header {
  background: var(--color-surface) !important;
  border-bottom: 1px solid var(--color-border) !important;
  color: var(--color-text-strong) !important;
}

.tabulator .tabulator-col .tabulator-col-content,
.tabulator .tabulator-col .tabulator-col-title {
  color: var(--color-text-strong) !important;
}

.tabulator .tabulator-header .tabulator-col {
  background: var(--color-surface) !important;
  color: var(--color-text-strong) !important;
}

.tabulator .tabulator-col-group,
.tabulator .tabulator-col-group .tabulator-col-content {
  background: var(--color-surface) !important;
  color: var(--color-text-strong) !important;
}

.dark .tabulator .tabulator-header,
.dark .tabulator .tabulator-header .tabulator-col,
.dark .tabulator .tabulator-col-group {
  background: var(--color-bg) !important;
  color: var(--color-text-strong) !important;
}

.dark .tabulator .tabulator-col .tabulator-col-title {
  color: var(--color-text-strong) !important;
}

.tabulator .tabulator-col,
.tabulator .tabulator-cell {
  border-right: 1px solid var(--color-border) !important;
}

.tabulator .tabulator-row {
  background: var(--color-panel) !important;
  color: var(--color-text) !important;
  border-bottom: 1px solid var(--color-border) !important;
}

.tabulator .tabulator-row.tabulator-row-even {
  background: var(--color-surface-muted) !important;
}

.tabulator .tabulator-row.tabulator-selected {
  background: var(--color-secondary-weak) !important;
}

.tabulator .tabulator-footer {
  background: var(--color-surface) !important;
  border-top: 1px solid var(--color-border) !important;
  color: var(--color-text) !important;
}

.tabulator .tabulator-footer .tabulator-page {
  background: var(--color-panel) !important;
  border: 1px solid var(--color-border) !important;
  color: var(--color-text) !important;
}

.tabulator .tabulator-footer .tabulator-page.active {
  background: var(--color-primary-weak) !important;
  border-color: var(--color-primary) !important;
  color: var(--color-text-strong) !important;
}

.tabulator .tabulator-edit-select,
.tabulator .tabulator-edit-input,
.tabulator .tabulator-edit-text {
  background: var(--color-bg) !important;
  color: var(--color-text-strong) !important;
  border: 1px solid var(--color-border) !important;
}

body[data-form="database"] main.ui-shell {
  max-width: 100%;
  padding-left: 8px;
  padding-right: 8px;
}

body[data-form="database"] .ui-header .ui-shell {
  max-width: 100%;
  padding-left: 8px;
  padding-right: 8px;
}
.text-red-600 { color: var(--color-error) !important; }
.text-red-400 { color: var(--color-error) !important; }
.bg-red-100 { background-color: var(--color-error-weak) !important; }
.text-red-700 { color: var(--color-error) !important; }
.border-red-400 { border-color: var(--color-error) !important; }
.border-red-200 { border-color: var(--color-error) !important; }
.dark .dark\:bg-red-900\/30 { background-color: var(--color-error-weak) !important; }
.dark .dark\:border-red-700 { border-color: var(--color-error) !important; }
.dark .dark\:text-red-200 { color: var(--color-error) !important; }
.bg-green-600 { background-color: var(--color-success) !important; }
.hover\:bg-green-700:hover { background-color: var(--color-success) !important; filter: brightness(0.9); }
.text-green-600 { color: var(--color-success) !important; }
.text-green-700 { color: var(--color-success) !important; }
.text-green-800 { color: var(--color-success) !important; }
.bg-green-100 { background-color: var(--color-success-weak) !important; }
.border-green-400 { border-color: var(--color-success) !important; }
.border-green-200 { border-color: var(--color-success) !important; }
.dark .dark\:bg-green-900\/30 { background-color: var(--color-success-weak) !important; }
.dark .dark\:text-green-200 { color: var(--color-success) !important; }

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
  border-radius: 10px;
  border: 3px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-muted);
}

/* Global loader blur */
body.loading-blur main,
body.loading-blur header,
body.loading-blur footer {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

.ui-inline-loader {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: var(--font-sm);
  color: var(--color-muted);
}

.ui-inline-spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  animation: ui-spin 1s linear infinite;
}

.ui-count {
  display: inline-block;
  min-width: 6ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ui-skeleton-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.ui-skeleton-line {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--color-surface-muted), transparent);
  opacity: 0.7;
  animation: ui-skeleton 1.4s ease-in-out infinite;
}

.ui-skeleton-line.sm {
  height: 10px;
}

.ui-skeleton-table {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.ui-skeleton-row {
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--color-surface-muted), transparent);
  opacity: 0.7;
  animation: ui-skeleton 1.4s ease-in-out infinite;
}

.ui-popover {
  position: fixed;
  z-index: var(--z-popover);
  min-width: 200px;
}

.ui-dropdown {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 6px;
  box-shadow: var(--shadow-md);
}

.ui-skeleton-bar {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--color-surface-muted), transparent);
  opacity: 0.7;
  animation: ui-skeleton 1.4s ease-in-out infinite;
}

@keyframes ui-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes ui-skeleton {
  0% { opacity: 0.5; }
  50% { opacity: 1; }
  100% { opacity: 0.5; }
}

.logo-spinner {
  position: relative;
  width: 170px;
  height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-spinner-mark {
  width: 88px;
  height: 88px;
  z-index: 2;
  filter: none;
  animation: logo-mark-pulse 2.4s ease-in-out infinite;
}

.logo-spinner--sm {
  width: 40px;
  height: 40px;
}

.logo-spinner--sm .logo-spinner-mark {
  width: 22px;
  height: 22px;
}

.logo-spinner--sm .logo-spinner-ring.outer {
  stroke: var(--color-primary);
  opacity: 0.7;
}

.logo-spinner--sm .logo-spinner-ring.inner {
  stroke: var(--color-secondary);
  opacity: 0.7;
}

.logo-spinner-orbit {
  position: absolute;
  width: 100%;
  height: 100%;
  animation: logo-orbit-spin 2.4s linear infinite;
  transform-origin: center;
}

.logo-spinner-ring {
  fill: none;
  stroke-width: 2.8;
  vector-effect: non-scaling-stroke;
}

@keyframes logo-orbit-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.logo-spinner-ring.outer {
  stroke: url(#orbitGradientOuter);
  opacity: 0.9;
}

.logo-spinner-ring.inner {
  stroke: url(#orbitGradientInner);
  opacity: 0.9;
}

.orbit-outer {
  animation: logo-orbit-spin 2.4s linear infinite;
  transform-origin: center;
  transform-box: fill-box;
}

.orbit-inner {
  animation: logo-orbit-spin-rev 3.2s linear infinite;
  transform-origin: center;
  transform-box: fill-box;
}

@keyframes logo-orbit-spin-rev {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(-360deg); }
}

@keyframes logo-mark-pulse {
  0% { transform: scale(1); opacity: 0.92; }
  50% { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); opacity: 0.92; }
}

.ai-ml {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.35rem;
  width: 18px;
  height: 18px;
  color: var(--color-text-strong);
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-shadow: 0 0 0 1px var(--color-border) inset;
}

.ai-ml svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ai-ml .node {
  fill: currentColor;
  stroke: none;
}
