/* ============================================
   Shadcn-style Dark Theme - Minimal & Clean
   ============================================ */

/* CSS Variables - Shadcn Dark Palette */
:root {
  /* Background colors */
  --background: hsl(240, 10%, 3.9%);
  --foreground: hsl(0, 0%, 98%);

  /* Card colors */
  --card: hsl(240, 10%, 3.9%);
  --card-foreground: hsl(0, 0%, 98%);

  /* Muted colors */
  --muted: hsl(240, 3.7%, 15.9%);
  --muted-foreground: hsl(240, 5%, 64.9%);

  /* Border & Input */
  --border: hsl(240, 3.7%, 15.9%);
  --input: hsl(240, 3.7%, 15.9%);
  --ring: hsl(240, 4.9%, 83.9%);

  /* Primary - neutral white accent */
  --primary: hsl(0, 0%, 98%);
  --primary-foreground: hsl(240, 5.9%, 10%);

  /* Secondary */
  --secondary: hsl(240, 3.7%, 15.9%);
  --secondary-foreground: hsl(0, 0%, 98%);

  /* Accent */
  --accent: hsl(240, 3.7%, 15.9%);
  --accent-foreground: hsl(0, 0%, 98%);

  /* Status colors - muted versions */
  --success: hsl(142, 71%, 45%);
  --warning: hsl(38, 92%, 50%);
  --danger: hsl(0, 72%, 51%);
  --info: hsl(217, 91%, 60%);

  /* UI */
  --radius: 8px;
  --radius-lg: 12px;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;

  /* Legacy mappings for compatibility */
  --bg-page: var(--background);
  --bg-surface: hsl(240, 6%, 6%);
  --bg-card: hsl(240, 6%, 8%);
  --text-primary: var(--foreground);
  --text-muted: var(--muted-foreground);
  --border-color: var(--border);
  --primary-color: hsl(262, 83%, 58%);
  --success-color: var(--success);
  --danger-color: var(--danger);
  --warning-color: var(--warning);
  --ui-radius: var(--radius);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scrollbar-gutter: stable;
  font-size: 15px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--background);
  color: var(--foreground);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-4);
  min-height: 100vh;
}

@media (min-width: 768px) {
  .container {
    padding: var(--space-5);
  }
}

@media (min-width: 1024px) {
  .container {
    padding: var(--space-6);
  }
}

/* ============================================
   Header - Clean & Compact
   ============================================ */
.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  position: sticky;
  top: var(--space-2);
  z-index: 50;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--foreground);
}

.brand img {
  height: 36px;
  width: auto;
  border-radius: var(--radius);
}

.brand span {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
}

#brand-edit {
  padding: 4px 8px;
  font-size: 0.75rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted-foreground);
  cursor: pointer;
  transition: all 0.15s ease;
}

#brand-edit:hover {
  background: var(--accent);
  color: var(--foreground);
}

/* Navigation */
.navigation {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: 1;
  justify-content: center;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.navigation::-webkit-scrollbar {
  display: none;
}

.navigation .nav-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted-foreground);
  text-decoration: none;
  border-radius: var(--radius);
  white-space: nowrap;
  transition: all 0.15s ease;
}

.navigation .nav-link:hover {
  background: var(--accent);
  color: var(--foreground);
}

.navigation .nav-link.active {
  background: var(--secondary);
  color: var(--foreground);
}

/* Open tickets badge */
.navigation .nav-link .open-tickets-badge {
  margin-left: var(--space-1);
}

.navigation .nav-link .open-tickets-badge .badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 9999px;
  background: var(--success);
  color: white;
}

/* Header Controls */
.header-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.bot-control {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.bot-control p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted-foreground);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.user-session-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.user-session-controls > span {
  font-size: 0.8rem;
  color: var(--muted-foreground);
}

/* Burger Menu (Mobile) */
.bm {
  display: none;
}

#burger {
  display: none;
}

label.burger_img {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  color: var(--foreground);
}

label.burger_img::before {
  content: "\2630";
  font-size: 16px;
}

.burger-menu {
  display: none;
}

.bm .burger-menu {
  position: absolute;
  right: 0;
  top: 44px;
  min-width: 180px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  z-index: 100;
}

.bm .burger-menu ul {
  list-style: none;
  padding: var(--space-2);
  margin: 0;
}

.bm .burger-menu li {
  margin: 2px 0;
}

.bm .burger-menu a {
  display: block;
  padding: var(--space-2) var(--space-3);
  color: var(--foreground);
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.bm .burger-menu a:hover {
  background: var(--accent);
}

#burger:checked ~ .burger-menu {
  display: block;
}

/* ============================================
   Buttons - Minimal
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  line-height: 1.25;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.8rem;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 0.75rem;
  line-height: 1.2;
}

.btn-primary {
  background: var(--foreground);
  color: var(--background);
  border-color: var(--foreground);
}

.btn-primary:hover {
  background: hsl(0, 0%, 90%);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--foreground);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: hsl(240, 3.7%, 20%);
}

.btn-outline-secondary {
  background: transparent;
  color: var(--foreground);
  border-color: var(--border);
}

.btn-outline-secondary:hover {
  background: var(--accent);
}

.btn-outline-primary {
  background: transparent;
  color: var(--foreground);
  border-color: var(--border);
}

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

.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.btn-success:hover {
  background: hsl(142, 71%, 40%);
}

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: hsl(0, 72%, 45%);
}

.btn-warning {
  background: var(--warning);
  color: hsl(240, 5.9%, 10%);
  border-color: var(--warning);
}

.btn-warning:hover {
  background: hsl(38, 92%, 45%);
}

.btn-outline-warning {
  background: transparent;
  color: var(--warning);
  border-color: var(--warning);
}

.btn-outline-warning:hover {
  background: hsla(38, 92%, 50%, 0.1);
}

.btn-glass {
  background: var(--bg-surface);
  border-color: var(--border);
  color: var(--foreground);
}

.btn-glass:hover {
  background: var(--accent);
}

/* Pill buttons */
.pill {
  border-radius: 9999px !important;
}

/* Legacy button class (login page) */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.button-primary {
  background: var(--foreground);
  color: var(--background);
}

.button-primary:hover {
  background: hsl(0, 0%, 85%);
}

/* ============================================
   Cards - Clean & Simple
   ============================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: transparent;
}

.card-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--foreground);
}

.card-body {
  padding: var(--space-4);
  overflow: visible;
}

.card.glass {
  background: var(--bg-card);
  border: 1px solid var(--border);
  overflow: visible;
}

.card-compact .card-body {
  padding: var(--space-3);
  overflow: visible;
}

.card-compact .card-header {
  padding: var(--space-2) var(--space-3);
}

/* ============================================
   Stat Cards
   ============================================ */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.subheader {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-1);
}

.h1 {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--foreground);
  line-height: 1.2;
}

.h1 small {
  font-size: 0.5em;
  font-weight: 400;
  color: var(--muted-foreground);
}

/* ============================================
   Tables
   ============================================ */
.table {
  width: 100%;
  border-collapse: collapse;
}

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

.table th {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: transparent !important;
}

.table td {
  font-size: 0.85rem;
  color: var(--foreground);
}

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

.table-vcenter td,
.table-vcenter th {
  vertical-align: middle;
}

.table-responsive {
  overflow-x: auto;
  overflow-y: visible;
}

.table-compact th,
.table-compact td {
  padding: var(--space-2);
  font-size: 0.8rem;
}

/* Override any Tabler table header colors */
.table thead th,
.table thead td,
[data-bs-theme='dark'] .table thead th,
[data-bs-theme='dark'] .table thead td {
  background-color: transparent !important;
  background: transparent !important;
  border-color: var(--border) !important;
}

/* ============================================
   Forms
   ============================================ */
.form-control,
.form-select {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--foreground);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus,
.form-select:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 2px hsla(240, 4.9%, 83.9%, 0.2);
}

.form-control::placeholder {
  color: var(--muted-foreground);
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--foreground);
  margin-bottom: var(--space-1);
}

.form-group {
  margin-bottom: var(--space-4);
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--foreground);
  margin-bottom: var(--space-2);
}

/* Bare inputs (login page) */
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="url"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.9rem;
  color: var(--foreground);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus,
.form-group input[type="email"]:focus,
.form-group input[type="url"]:focus,
.form-group input[type="number"]:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 2px hsla(240, 4.9%, 83.9%, 0.2);
}

.form-group input::placeholder {
  color: var(--muted-foreground);
}

.form-select-sm,
.form-control-sm {
  padding: 6px 10px;
  font-size: 0.8rem;
}

/* Input Groups */
.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .form-control,
.input-group .form-select {
  flex: 1;
}

.input-group .input-group-text {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--muted-foreground);
}

.input-group > *:not(:last-child) {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: 0;
}

.input-group > *:not(:first-child) {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* Soft Select (custom dropdown) */
.soft-select {
  position: relative;
}

.soft-select-toggle {
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--foreground);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.soft-select-toggle:focus {
  outline: none;
  border-color: var(--ring);
}

.soft-select.open .soft-select-toggle {
  border-color: var(--ring);
}

.soft-select .select-soft {
  display: none;
}

.soft-select-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: var(--space-1);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  max-height: 200px;
  overflow-y: auto;
  z-index: 60;
}

.soft-select-item {
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--foreground);
  cursor: pointer;
  transition: background 0.1s ease;
}

.soft-select-item:hover {
  background: var(--accent);
}

.soft-select-item.is-active {
  background: var(--secondary);
}

/* Password toggle */
.password-wrapper {
  position: relative;
}

.toggle-password {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  border-radius: var(--radius);
}

.toggle-password:hover {
  color: var(--foreground);
}

/* ============================================
   Badges
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 500;
  border-radius: var(--radius);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.bg-green-lt,
.badge-success,
.bg-green,
.badge.bg-green {
  background: hsla(142, 71%, 45%, 0.15) !important;
  color: var(--success) !important;
}

.bg-blue-lt,
.badge-info {
  background: hsla(217, 91%, 60%, 0.15);
  color: var(--info);
}

.bg-yellow-lt,
.badge-warning {
  background: hsla(38, 92%, 50%, 0.15);
  color: var(--warning);
}

.bg-red-lt,
.badge-danger,
.bg-red,
.badge.bg-red {
  background: hsla(0, 72%, 51%, 0.15) !important;
  color: var(--danger) !important;
}

/* ============================================
   Status Indicators
   ============================================ */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted-foreground);
  vertical-align: middle;
}

.status-dot-animated {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.status-dot.bg-green {
  background: var(--success);
}

.status-dot.bg-yellow {
  background: var(--warning);
}

.status-dot.bg-red {
  background: var(--danger);
}

.status-running {
  color: var(--success);
}

.status-stopped {
  color: var(--muted-foreground);
}

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

/* ============================================
   Charts
   ============================================ */
.chart {
  position: relative;
  width: 100%;
}

/* ============================================
   Pagination
   ============================================ */
.pagination {
  display: flex;
  gap: var(--space-1);
  list-style: none;
  padding: 0;
  margin: 0;
}

.page-item .page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 var(--space-2);
  font-size: 0.85rem;
  color: var(--foreground);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: all 0.15s ease;
}

.page-item .page-link:hover {
  background: var(--accent);
}

.page-item.active .page-link {
  background: var(--secondary);
  border-color: var(--secondary);
}

.page-item.disabled .page-link {
  opacity: 0.5;
  pointer-events: none;
}

/* ============================================
   Dropdown Menu (shadcn style)
   ============================================ */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: 6px 10px;
  font-size: 0.85rem;
}

.dropdown-toggle::after {
  display: none;
}

.dropdown-toggle:hover {
  background: var(--accent) !important;
  color: var(--foreground) !important;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  z-index: 9999;
  min-width: 200px;
  margin: var(--space-1) 0;
  padding: var(--space-1);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  list-style: none;
  display: none;
}

.dropdown-menu.show {
  display: block;
}

/* Меню, позиционируемое Popper: только position:fixed, top/left задаёт Popper инлайном */
.dropdown-menu[data-popper-placement] {
  position: fixed !important;
  z-index: 9999 !important;
}

.dropdown-menu-end {
  right: 0;
  left: auto;
}

.dropdown-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 6px 10px;
  font-size: 0.85rem;
  color: var(--foreground);
  background: transparent;
  border: none;
  border-radius: var(--radius);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.dropdown-item:hover {
  background: var(--accent);
}

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

.dropdown-item.text-danger {
  color: var(--danger);
}

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

.dropdown-divider {
  height: 1px;
  margin: var(--space-1) 0;
  background: var(--border);
  border: none;
}

/* Tooltips (Bootstrap/Tabler) */
.tooltip {
  z-index: 9999;
}

.tooltip-inner,
[data-bs-theme='dark'] .tooltip-inner {
  background: var(--bg-surface) !important;
  color: var(--foreground) !important;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  font-size: 0.8rem;
  padding: 6px 10px;
}

.tooltip .tooltip-arrow::before,
[data-bs-theme='dark'] .tooltip .tooltip-arrow::before {
  border-top-color: var(--bg-surface) !important;
  border-bottom-color: var(--bg-surface) !important;
  border-left-color: var(--bg-surface) !important;
  border-right-color: var(--bg-surface) !important;
}

/* ============================================
   Modals
   ============================================ */
/* Убираем затемнённый фон — не используем */
.modal-backdrop {
  display: none !important;
}

.modal {
  overflow-y: auto;
}

.modal-open {
  padding-right: 0 !important;
}

.modal-blur .modal-dialog {
  margin: var(--space-4) auto;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--foreground);
  margin: 0;
}

.modal-body {
  padding: var(--space-4);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4);
  border-top: 1px solid var(--border);
}

.btn-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--muted-foreground);
  cursor: pointer;
  border-radius: var(--radius);
  opacity: 1;
}

.btn-close:hover {
  background: var(--accent);
  color: var(--foreground);
}

.btn-close::before {
  content: "×";
  font-size: 20px;
  line-height: 1;
}

/* ============================================
   Alerts
   ============================================ */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  margin-bottom: var(--space-4);
}

.alert-success {
  border-left: 3px solid var(--success);
}

.alert-warning {
  border-left: 3px solid var(--warning);
}

.alert-danger {
  border-left: 3px solid var(--danger);
}

/* ============================================
   Toasts
   ============================================ */
.toast-container {
  z-index: 1080;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ============================================
   Page Header
   ============================================ */
.page-header {
  margin-bottom: var(--space-4);
}

.page-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--foreground);
  margin: 0 0 var(--space-1) 0;
}

.text-secondary {
  color: var(--muted-foreground) !important;
}

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

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

.text-danger {
  color: var(--danger) !important;
}

.text-muted {
  color: var(--muted-foreground) !important;
}

/* ============================================
   Utility Classes
   ============================================ */
.d-flex { display: flex; }
.d-inline-flex { display: inline-flex; }
.d-none { display: none !important; }
.d-block { display: block; }

.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }
.flex-grow-1 { flex-grow: 1; }

.align-items-center { align-items: center; }
.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-end { justify-content: flex-end; }

.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }

.m-0 { margin: 0; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.ms-1 { margin-left: var(--space-1); }
.ms-2 { margin-left: var(--space-2); }
.me-2 { margin-right: var(--space-2); }
.me-auto { margin-right: auto; }
.ms-auto { margin-left: auto; }

.p-3 { padding: var(--space-3); }
.py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }

.w-100 { width: 100%; }
.min-w-0 { min-width: 0; }

.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.small { font-size: 0.85rem; }
.tiny { font-size: 0.8rem; }
.fw-semibold { font-weight: 600; }

.rounded-start { border-top-left-radius: var(--radius); border-bottom-left-radius: var(--radius); }
.rounded-end { border-top-right-radius: var(--radius); border-bottom-right-radius: var(--radius); }

.float-end { float: right; }

/* ============================================
   Grid System (Bootstrap-compatible)
   ============================================ */
.row {
  display: flex;
  flex-wrap: wrap;
  margin-left: calc(-1 * var(--space-3));
  margin-right: calc(-1 * var(--space-3));
}

.row > * {
  padding-left: var(--space-3);
  padding-right: var(--space-3);
}

.row.g-2 { margin: calc(-1 * var(--space-2)); }
.row.g-2 > * { padding: var(--space-2); }
.row.g-3 { margin: calc(-1 * var(--space-3)); }
.row.g-3 > * { padding: var(--space-3); }

.col { flex: 1 0 0%; }
.col-auto { flex: 0 0 auto; width: auto; }

@media (min-width: 576px) {
  .col-sm-6 { flex: 0 0 50%; max-width: 50%; }
}

@media (min-width: 992px) {
  .col-lg-3 { flex: 0 0 25%; max-width: 25%; }
  .col-lg-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
  .col-lg-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
}

.row-deck > * {
  display: flex;
  flex-direction: column;
}

.row-deck > * > .card {
  flex: 1;
}

.row-cards > * {
  margin-bottom: var(--space-4);
}

/* ============================================
   Settings Page
   ============================================ */
.settings-section {
  margin-bottom: var(--space-6);
}

.settings-container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
}

.settings-column-left {
  flex: 2;
  min-width: 320px;
}

.settings-column-right {
  flex: 3;
  min-width: 400px;
}

/* Host Cards */
.host-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}

.host-card h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: var(--space-3);
}

.host-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.host-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

/* Host card inner card (SSH, plans) */
.host-card .card.glass {
  background: var(--bg-surface);
  margin: var(--space-3) 0;
}

.host-card .card.glass .card-body {
  padding: var(--space-3);
}

.host-card .card.glass .card-title {
  font-size: 0.85rem;
  margin-bottom: var(--space-3);
}

/* Plans Section */
.plans-section {
  padding: var(--space-4);
  border-top: 1px solid var(--border);
}

.plans-section h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: var(--space-3);
  color: var(--foreground);
}

.plans-section h5 {
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: var(--space-3);
  color: var(--muted-foreground);
}

/* Plan List */
.plan-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

/* Plan Item */
.plan-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.plan-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3);
  gap: var(--space-3);
}

.plan-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.plan-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--foreground);
}

.plan-details {
  font-size: 0.8rem;
  color: var(--muted-foreground);
}

.plan-discount {
  color: var(--success);
  font-weight: 500;
}

.plan-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}

.plan-delete-form {
  display: inline-flex;
}

/* Plan Edit Form */
.plan-edit {
  border-top: 1px solid var(--border);
  background: var(--background);
}

.plan-edit.collapse {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.2s ease, opacity 0.2s ease;
}

.plan-edit.collapse.show {
  opacity: 1;
}

.plan-edit-form {
  padding: var(--space-3);
}

.plan-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.plan-form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.plan-form-field label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.plan-form-field small {
  font-size: 0.7rem;
  color: var(--muted-foreground);
  margin-top: 2px;
}

.plan-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* Plan Add Section */
.plan-add-section {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.plan-add-section h5 {
  margin-bottom: var(--space-3);
}

/* Form control small */
.form-control-sm {
  padding: 6px 10px;
  font-size: 0.85rem;
}

/* ============================================
   Spinner
   ============================================ */
.spinner-aurora,
.spinner-border {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--foreground);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-spinner {
  text-align: center;
  padding: var(--space-5);
  color: var(--muted-foreground);
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
  text-align: center;
  padding: var(--space-6);
  color: var(--muted-foreground);
}

.empty-state i {
  font-size: 2.5rem;
  margin-bottom: var(--space-3);
  opacity: 0.5;
}

/* ============================================
   Monitor Page
   ============================================ */
.monitor-controls .btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--foreground);
}

.server-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
}

.server-name {
  font-weight: 600;
  color: var(--foreground);
}

.server-url {
  font-size: 0.85rem;
  color: var(--muted-foreground);
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: var(--space-2);
}

.status-indicator.bg-success {
  background: var(--success);
}

.status-indicator.bg-warning {
  background: var(--warning);
}

.status-indicator.bg-danger {
  background: var(--danger);
}

.monitor-info {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
}

.info-item {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

.info-item:last-child {
  border-bottom: none;
}

.disks-section {
  margin-top: var(--space-3);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
}

.disk-item {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

.disk-item:last-child {
  border-bottom: none;
}

/* Progress bars */
.progress {
  background: var(--bg-surface);
  border-radius: var(--radius);
  height: 8px;
  overflow: hidden;
}

.progress-bar {
  background: var(--foreground);
  height: 100%;
  transition: width 0.3s ease;
}

/* ============================================
   Login Page
   ============================================ */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-4);
}

.login-container {
  width: 100%;
  max-width: 380px;
  padding: var(--space-6);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.login-container h1 {
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: var(--space-5);
}

.login-container .flash {
  padding: var(--space-3);
  margin-bottom: var(--space-4);
  border-radius: var(--radius);
  font-size: 0.85rem;
}

.login-container .flash-danger {
  background: hsla(0, 72%, 51%, 0.15);
  color: var(--danger);
  border: 1px solid hsla(0, 72%, 51%, 0.3);
}

.login-container .flash-success {
  background: hsla(142, 71%, 45%, 0.15);
  color: var(--success);
  border: 1px solid hsla(142, 71%, 45%, 0.3);
}

.login-container input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--foreground);
}

.login-container .password-wrapper {
  position: relative;
}

.login-container .password-wrapper input {
  padding-right: 40px;
}

.login-container .toggle-password {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(25%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--muted-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-container .toggle-password:hover {
  color: var(--foreground);
}

.login-container .toggle-password svg {
  width: 18px;
  height: 18px;
}

/* ============================================
   Responsive - Mobile First
   ============================================ */
@media (max-width: 992px) {
  .navigation {
    display: none !important;
  }

  .bm {
    display: block;
    position: relative;
    order: 2;
    margin-left: auto;
  }

  label.burger_img {
    display: inline-flex;
  }

  .main-header {
    flex-wrap: wrap;
    padding: var(--space-2) var(--space-3);
    gap: var(--space-2);
  }

  .brand {
    order: 1;
  }

  .header-controls {
    order: 3;
    flex: 1 1 100%;
    justify-content: space-between;
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--border);
  }

  .brand img {
    height: 32px;
  }

  .brand span {
    font-size: 0.85rem;
  }

  #brand-edit {
    display: none;
  }
}

@media (max-width: 576px) {
  .container {
    padding: var(--space-3);
  }

  .main-header {
    top: var(--space-1);
  }

  .user-session-controls > span {
    display: none;
  }

  .bot-control p {
    font-size: 0.75rem;
  }

  .btn-sm {
    padding: 5px 8px;
    font-size: 0.75rem;
  }

  .card-body {
    padding: var(--space-3);
  }

  .h1 {
    font-size: 1.5rem;
  }

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

  .table th,
  .table td {
    padding: var(--space-2);
    font-size: 0.8rem;
  }
}

/* ============================================
   Transitions
   ============================================ */
[data-fetch-url] {
  transition: opacity 0.2s ease;
}

[data-fetch-url].loading {
  opacity: 0.6;
}

.is-swapping {
  transition: opacity 0.2s ease;
}

.flash {
  animation: flashHighlight 0.4s ease;
}

@keyframes flashHighlight {
  0% { background: hsla(0, 0%, 100%, 0.05); }
  100% { background: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   Layout Overrides
   ============================================ */
.layout-boxed {
  max-width: 100%;
}

main {
  position: relative;
  z-index: 1;
}

.main-footer {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

/* ============================================
   Headings
   ============================================ */
h1, h2, h3, h4, h5, h6 {
  color: var(--foreground);
  font-weight: 600;
  line-height: 1.3;
}

h2 {
  font-size: 1.1rem;
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

h3 {
  font-size: 1rem;
  margin-bottom: var(--space-2);
}

h4 {
  font-size: 0.9rem;
  margin-bottom: var(--space-2);
}

/* ============================================
   Form Checkbox
   ============================================ */
.form-group-checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.form-group-checkbox input[type='checkbox'] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary-color);
}

.form-group-checkbox label {
  margin: 0;
  font-weight: 400;
}

/* ============================================
   Tabler overrides for dark theme
   ============================================ */
[data-bs-theme='dark'],
:root {
  /* Override ALL Tabler colors */
  --tblr-bg-surface: var(--bg-surface) !important;
  --tblr-bg-surface-secondary: var(--bg-card) !important;
  --tblr-body-bg: var(--background) !important;
  --tblr-body-color: var(--foreground) !important;
  --tblr-border-color: var(--border) !important;
  --tblr-card-bg: var(--bg-card) !important;
  --tblr-card-border-color: var(--border) !important;
  --tblr-muted: var(--muted-foreground) !important;
  --tblr-primary: var(--foreground) !important;
  --tblr-primary-rgb: 250, 250, 250 !important;
  --tblr-secondary: var(--muted-foreground) !important;
  --bs-body-bg: var(--background) !important;
  --bs-body-color: var(--foreground) !important;
  --bs-border-color: var(--border) !important;
  --bs-card-bg: var(--bg-card) !important;
  --bs-primary: var(--foreground) !important;
  --bs-secondary-bg: var(--secondary) !important;

  /* Kill all blue/purple Tabler accent colors */
  --tblr-blue: var(--info) !important;
  --tblr-azure: var(--info) !important;
  --tblr-indigo: var(--muted-foreground) !important;
  --tblr-purple: var(--muted-foreground) !important;
  --tblr-pink: var(--muted-foreground) !important;
}

/* Force body background */
body,
html {
  background-color: var(--background) !important;
  background-image: none !important;
}

/* Override Tabler card */
.card,
[data-bs-theme='dark'] .card {
  background-color: var(--bg-card) !important;
  border-color: var(--border) !important;
  --tblr-card-bg: var(--bg-card) !important;
}

.card-header,
[data-bs-theme='dark'] .card-header {
  background-color: transparent !important;
  border-color: var(--border) !important;
}

/* Nav pills */
.nav {
  display: flex;
  flex-wrap: wrap;
  padding-left: 0;
  margin-bottom: 0;
  list-style: none;
}

.nav-item {
  display: inline-block;
}

.nav-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.nav-pills .nav-link {
  display: block;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted-foreground);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-pills .nav-link:hover {
  background: var(--accent);
  color: var(--foreground);
}

.nav-pills .nav-link.active {
  background: var(--secondary) !important;
  color: var(--foreground) !important;
  border-color: var(--border);
}

/* Form check (checkboxes) */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-left: 0;
}

.form-check-input {
  width: 16px;
  height: 16px;
  margin: 0;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}

.form-check-input:checked {
  background-color: var(--foreground);
  border-color: var(--foreground);
}

.form-check-input:focus {
  box-shadow: 0 0 0 2px hsla(240, 4.9%, 83.9%, 0.2);
  border-color: var(--ring);
}

.form-check-label {
  font-size: 0.85rem;
  color: var(--foreground);
  cursor: pointer;
}

/* hr-text divider */
.hr-text {
  display: flex;
  align-items: center;
  margin: var(--space-4) 0;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hr-text::before,
.hr-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.hr-text::before {
  margin-right: var(--space-3);
}

.hr-text::after {
  margin-left: var(--space-3);
}

.hr-text:empty::before {
  margin-right: 0;
}

.hr-text:empty::after {
  margin-left: 0;
}

/* Form text helper */
.form-text {
  font-size: 0.8rem;
  color: var(--muted-foreground);
  margin-top: var(--space-1);
}

/* Settings specific - Edit rows */
.edit-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

.edit-row:last-of-type {
  border-bottom: none;
}

.edit-row .form-label {
  font-size: 0.8rem;
  color: var(--muted-foreground);
  min-width: 140px;
  margin: 0;
}

.edit-row .form-control {
  flex: 1;
  min-width: 200px;
}

.edit-actions {
  display: flex;
  gap: var(--space-1);
  flex-shrink: 0;
}

.form-inline {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-2) 0;
}

/* Badge overrides */
.badge,
.badge-success,
.badge-danger {
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: var(--radius);
}

.badge-success {
  background: hsla(142, 71%, 45%, 0.15) !important;
  color: var(--success) !important;
}

.badge-danger {
  background: hsla(0, 72%, 51%, 0.15) !important;
  color: var(--danger) !important;
}

.bg-secondary-lt {
  background: var(--secondary) !important;
  color: var(--foreground) !important;
}

/* d-grid helper */
.d-grid {
  display: grid;
}

/* is-hidden helper (used by settings tabs JS) */
.is-hidden {
  display: none !important;
}

/* is-editing state for inline edits */
.is-editing {
  background-color: var(--bg-card) !important;
  border-color: var(--ring) !important;
}

/* Override any remaining Tabler form controls */
[data-bs-theme='dark'] .form-control,
[data-bs-theme='dark'] .form-select {
  background-color: var(--bg-surface) !important;
  border-color: var(--border) !important;
  color: var(--foreground) !important;
}

[data-bs-theme='dark'] .form-control:focus,
[data-bs-theme='dark'] .form-select:focus {
  background-color: var(--bg-surface) !important;
  border-color: var(--ring) !important;
  box-shadow: 0 0 0 2px hsla(240, 4.9%, 83.9%, 0.2) !important;
}

/* Override input group text */
[data-bs-theme='dark'] .input-group-text {
  background-color: var(--bg-surface) !important;
  border-color: var(--border) !important;
  color: var(--muted-foreground) !important;
}

/* Override textarea */
textarea.form-control {
  min-height: 80px;
  resize: vertical;
}

/* Tabler icons fix */
.ti {
  vertical-align: middle;
}

/* h3, h4 in cards - no border */
.card h2.card-title {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.card-body h3,
.card-body h4,
.card-body h5 {
  border-bottom: none;
  padding-bottom: 0;
}

/* Status bar */
.status-bar {
  margin-bottom: var(--space-3);
}

.status-bar p {
  margin: 0;
  font-size: 0.85rem;
}

/* pill-md variant */
.pill-md {
  border-radius: 10px !important;
}

/* Settings container responsive */
@media (max-width: 1200px) {
  .settings-container {
    flex-direction: column;
  }

  .settings-column-left,
  .settings-column-right {
    flex: none;
    width: 100%;
    min-width: 0;
  }
}

/* Row utilities */
.row.align-items-start {
  align-items: flex-start;
}

.row.align-items-end {
  align-items: flex-end;
}

.row.align-items-center {
  align-items: center;
}

/* Additional col utilities */
.col-12 { flex: 0 0 100%; max-width: 100%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }

@media (min-width: 768px) {
  .col-md-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
  .col-md-3 { flex: 0 0 25%; max-width: 25%; }
  .col-md-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
  .col-md-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
  .col-md-6 { flex: 0 0 50%; max-width: 50%; }
  .col-md-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
}

/* Additional utilities */
.me-1 { margin-right: var(--space-1); }
.px-3 { padding-left: var(--space-3); padding-right: var(--space-3); }
.mt-1 { margin-top: var(--space-1); }
.rounded-pill { border-radius: 9999px !important; }
.rounded-3 { border-radius: var(--radius-lg) !important; }

/* seamless input group */
.input-group.seamless > * {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
}

/* host-card inside plans */
.host-card .plans-section {
  padding: var(--space-3);
}

/* Override any remaining blue backgrounds */
[style*="rgb(27, 41, 58)"],
[style*="#1b293a"],
[style*="#151F2C"],
[style*="rgb(21, 31, 44)"] {
  background-color: var(--bg-surface) !important;
}

/* Force all backgrounds to our theme */
.page-wrapper,
.page-body,
.page-header {
  background: transparent !important;
}

/* ============================================
   AGGRESSIVE Tabler Color Overrides
   Kill ALL remaining Tabler theme colors
   ============================================ */

/* Override Tabler's default primary purple/blue */
[data-bs-theme='dark'] {
  --tblr-primary: hsl(0, 0%, 98%) !important;
  --tblr-primary-rgb: 250, 250, 250 !important;
  --tblr-link-color: hsl(0, 0%, 80%) !important;
  --tblr-link-hover-color: hsl(0, 0%, 98%) !important;
  --tblr-code-color: hsl(0, 0%, 70%) !important;

  /* Kill all accent colors */
  --tblr-blue: hsl(217, 91%, 60%) !important;
  --tblr-blue-rgb: 59, 130, 246 !important;
  --tblr-azure: hsl(217, 91%, 60%) !important;
  --tblr-indigo: hsl(240, 5%, 65%) !important;
  --tblr-purple: hsl(240, 5%, 65%) !important;
  --tblr-pink: hsl(240, 5%, 65%) !important;
  --tblr-red: hsl(0, 72%, 51%) !important;
  --tblr-orange: hsl(38, 92%, 50%) !important;
  --tblr-yellow: hsl(38, 92%, 50%) !important;
  --tblr-lime: hsl(142, 71%, 45%) !important;
  --tblr-green: hsl(142, 71%, 45%) !important;
  --tblr-teal: hsl(142, 71%, 45%) !important;
  --tblr-cyan: hsl(217, 91%, 60%) !important;

  /* Background overrides */
  --tblr-dark: var(--background) !important;
  --tblr-dark-rgb: 10, 10, 11 !important;
  --tblr-light: var(--bg-surface) !important;
  --tblr-gray-50: var(--background) !important;
  --tblr-gray-100: var(--bg-surface) !important;
  --tblr-gray-200: var(--bg-card) !important;
  --tblr-gray-300: var(--border) !important;
  --tblr-gray-400: var(--muted-foreground) !important;
  --tblr-gray-500: var(--muted-foreground) !important;
  --tblr-gray-600: var(--muted-foreground) !important;
  --tblr-gray-700: var(--foreground) !important;
  --tblr-gray-800: var(--foreground) !important;
  --tblr-gray-900: var(--foreground) !important;
}

/* Override any inline styles or computed Tabler colors */
*:not(.ti):not([class*="ti-"]) {
  --tblr-bg-surface: var(--bg-surface);
  --tblr-bg-surface-secondary: var(--bg-card);
}

/* Kill Tabler's btn-primary purple */
.btn-primary,
[data-bs-theme='dark'] .btn-primary {
  --tblr-btn-bg: var(--foreground) !important;
  --tblr-btn-border-color: var(--foreground) !important;
  --tblr-btn-hover-bg: hsl(0, 0%, 85%) !important;
  --tblr-btn-hover-border-color: hsl(0, 0%, 85%) !important;
  --tblr-btn-color: var(--background) !important;
  background-color: var(--foreground) !important;
  border-color: var(--foreground) !important;
  color: var(--background) !important;
}

.btn-primary:hover,
[data-bs-theme='dark'] .btn-primary:hover {
  background-color: hsl(0, 0%, 85%) !important;
  border-color: hsl(0, 0%, 85%) !important;
}

/* Override outline buttons */
.btn-outline-primary,
[data-bs-theme='dark'] .btn-outline-primary {
  --tblr-btn-color: var(--foreground) !important;
  --tblr-btn-border-color: var(--border) !important;
  --tblr-btn-hover-bg: var(--accent) !important;
  color: var(--foreground) !important;
  border-color: var(--border) !important;
  background: transparent !important;
}

.btn-outline-primary:hover,
[data-bs-theme='dark'] .btn-outline-primary:hover {
  background: var(--accent) !important;
  color: var(--foreground) !important;
}

/* Tables */
.table,
[data-bs-theme='dark'] .table {
  --tblr-table-bg: transparent !important;
  --tblr-table-border-color: var(--border) !important;
  --tblr-table-striped-bg: var(--accent) !important;
  --tblr-table-hover-bg: var(--accent) !important;
}

/* Links */
a {
  color: var(--muted-foreground);
}

a:hover {
  color: var(--foreground);
}

/* Nav link in navigation */
.nav-link {
  color: var(--muted-foreground) !important;
}

.nav-link:hover,
.nav-link.active {
  color: var(--foreground) !important;
}

/* Kill any remaining purple/blue focus rings */
*:focus {
  outline: none !important;
}

*:focus-visible {
  outline: 2px solid var(--ring) !important;
  outline-offset: 2px !important;
}

/* Form focus override */
.form-control:focus,
.form-select:focus,
input:focus,
select:focus,
textarea:focus,
button:focus {
  border-color: var(--ring) !important;
  box-shadow: 0 0 0 2px hsla(240, 4.9%, 83.9%, 0.2) !important;
}

/* Override Bootstrap/Tabler active states */
.active,
.show > .btn {
  box-shadow: none !important;
}

/* Alert overrides */
.alert-success,
[data-bs-theme='dark'] .alert-success {
  --tblr-alert-bg: hsla(142, 71%, 45%, 0.1) !important;
  --tblr-alert-border-color: hsla(142, 71%, 45%, 0.2) !important;
  --tblr-alert-color: var(--success) !important;
  background: hsla(142, 71%, 45%, 0.1) !important;
  border-color: hsla(142, 71%, 45%, 0.2) !important;
  color: var(--foreground) !important;
}

.alert-warning,
[data-bs-theme='dark'] .alert-warning {
  --tblr-alert-bg: hsla(38, 92%, 50%, 0.1) !important;
  --tblr-alert-border-color: hsla(38, 92%, 50%, 0.2) !important;
  --tblr-alert-color: var(--warning) !important;
  background: hsla(38, 92%, 50%, 0.1) !important;
  border-color: hsla(38, 92%, 50%, 0.2) !important;
  color: var(--foreground) !important;
}

.alert-danger,
[data-bs-theme='dark'] .alert-danger {
  --tblr-alert-bg: hsla(0, 72%, 51%, 0.1) !important;
  --tblr-alert-border-color: hsla(0, 72%, 51%, 0.2) !important;
  --tblr-alert-color: var(--danger) !important;
  background: hsla(0, 72%, 51%, 0.1) !important;
  border-color: hsla(0, 72%, 51%, 0.2) !important;
  color: var(--foreground) !important;
}
