/* ============================================================================
   TB Data Automation — Design System  ·  "Aurora"
   A modern, friendly SaaS interface: soft depth, generous radii, fluid motion,
   and a full light/dark theme built on design tokens.
   ----------------------------------------------------------------------------
   1. Tokens               5. Sidebar
   2. Base & scrollbars    6. Topbar
   3. Bootstrap overrides  7. Components
   4. App shell            8. Auth · Toasts · Responsive · Motion
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@600;700;800&display=swap');

/* ---------------------------------------------------------------------------
   1. Tokens
   ------------------------------------------------------------------------- */
:root {
  /* Brand ramp */
  --tb-brand-50:  #f0efff;
  --tb-brand-100: #e4e2ff;
  --tb-brand-200: #cdc9ff;
  --tb-brand-300: #ada5ff;
  --tb-brand-400: #8b7cff;
  --tb-brand-500: #6d5efc;
  --tb-brand-600: #5a45f0;
  --tb-brand-700: #4a35d4;
  --tb-brand-800: #3d2daa;
  --tb-brand-900: #342a86;

  --tb-primary: var(--tb-brand-500);
  --tb-primary-strong: var(--tb-brand-600);
  --tb-primary-soft: var(--tb-brand-50);

  /* Semantic */
  --tb-success: #0ea472;
  --tb-success-soft: #e3f8ef;
  --tb-warning: #d97706;
  --tb-warning-soft: #fef3e2;
  --tb-danger: #e11d48;
  --tb-danger-soft: #ffe9ee;
  --tb-info: #0284c7;
  --tb-info-soft: #e2f2fe;

  /* Surfaces */
  --tb-canvas: #f4f5fa;
  --tb-canvas-tint:
    radial-gradient(1100px 560px at 10% -12%, #ebe8ff 0%, transparent 62%),
    radial-gradient(900px 480px at 100% -4%, #e1f0ff 0%, transparent 58%);
  --tb-surface: #ffffff;
  --tb-surface-2: #f8f9fc;
  --tb-surface-3: #f1f3f9;
  --tb-elevated: #ffffff;
  --tb-glass: rgba(255, 255, 255, .78);

  /* Lines & text */
  --tb-border: #e7e9f2;
  --tb-border-strong: #d5d9e6;
  --tb-text: #14161f;
  --tb-text-muted: #656d80;
  --tb-text-subtle: #98a0b3;

  /* Effects */
  --tb-gradient: linear-gradient(135deg, #8b7cff 0%, #6d5efc 45%, #4a8dff 100%);
  --tb-gradient-soft: linear-gradient(135deg, #f4f2ff 0%, #eef4ff 100%);
  --tb-glow: 0 8px 24px -8px rgba(109, 94, 252, .55);
  --tb-ring: 0 0 0 3px rgba(109, 94, 252, .22);

  --tb-shadow-xs: 0 1px 2px rgba(18, 22, 40, .05);
  --tb-shadow-sm: 0 1px 2px rgba(18, 22, 40, .04), 0 2px 6px -2px rgba(18, 22, 40, .07);
  --tb-shadow-md: 0 4px 12px -4px rgba(18, 22, 40, .10), 0 10px 28px -12px rgba(18, 22, 40, .14);
  --tb-shadow-lg: 0 12px 32px -12px rgba(18, 22, 40, .18), 0 24px 56px -24px rgba(18, 22, 40, .22);

  /* Geometry */
  --tb-r-xs: 8px;
  --tb-r-sm: 10px;
  --tb-r-md: 14px;
  --tb-r-lg: 18px;
  --tb-r-xl: 24px;
  --tb-r-pill: 999px;

  --tb-sidebar-w: 262px;
  --tb-sidebar-rail: 80px;

  --tb-ease: cubic-bezier(.22, 1, .36, 1);
  --tb-fast: .16s var(--tb-ease);
  --tb-med: .28s var(--tb-ease);

  color-scheme: light;
}

[data-bs-theme="dark"] {
  --tb-primary: var(--tb-brand-400);
  --tb-primary-strong: var(--tb-brand-300);
  --tb-primary-soft: rgba(139, 124, 255, .15);

  --tb-success: #34d399;
  --tb-success-soft: rgba(52, 211, 153, .15);
  --tb-warning: #fbbf24;
  --tb-warning-soft: rgba(251, 191, 36, .15);
  --tb-danger: #fb7185;
  --tb-danger-soft: rgba(251, 113, 133, .15);
  --tb-info: #38bdf8;
  --tb-info-soft: rgba(56, 189, 248, .15);

  --tb-canvas: #0a0c13;
  --tb-canvas-tint:
    radial-gradient(1100px 560px at 10% -12%, rgba(109, 94, 252, .18) 0%, transparent 62%),
    radial-gradient(900px 480px at 100% -4%, rgba(56, 189, 248, .10) 0%, transparent 58%);
  --tb-surface: #11141d;
  --tb-surface-2: #161a25;
  --tb-surface-3: #1d2231;
  --tb-elevated: #171b26;
  --tb-glass: rgba(17, 20, 29, .8);

  --tb-border: #242938;
  --tb-border-strong: #333a4e;
  --tb-text: #eef1f8;
  --tb-text-muted: #99a2b8;
  --tb-text-subtle: #6b7489;

  --tb-gradient-soft: linear-gradient(135deg, rgba(139, 124, 255, .14) 0%, rgba(74, 141, 255, .10) 100%);
  --tb-glow: 0 8px 26px -10px rgba(139, 124, 255, .7);
  --tb-ring: 0 0 0 3px rgba(139, 124, 255, .26);

  --tb-shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
  --tb-shadow-sm: 0 1px 2px rgba(0, 0, 0, .35), 0 2px 8px -2px rgba(0, 0, 0, .45);
  --tb-shadow-md: 0 6px 16px -6px rgba(0, 0, 0, .55), 0 12px 32px -14px rgba(0, 0, 0, .6);
  --tb-shadow-lg: 0 16px 40px -14px rgba(0, 0, 0, .65), 0 28px 64px -28px rgba(0, 0, 0, .7);

  color-scheme: dark;
}

/* ---------------------------------------------------------------------------
   2. Base
   ------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  background-color: var(--tb-canvas);
  background-image: var(--tb-canvas-tint);
  background-attachment: fixed;
  color: var(--tb-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -.005em;
  margin: 0;
}

h1, h2, h3, h4, h5, h6, .tb-display {
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: -.022em;
  color: var(--tb-text);
}

a { color: var(--tb-primary); text-decoration: none; }
a:hover { color: var(--tb-primary-strong); }
hr { border-color: var(--tb-border); opacity: 1; }

/* Numeric data reads better tabular */
.tb-num, .tb-stat-value, .tb-kpi-value, .tb-page-num { font-variant-numeric: tabular-nums; }

::selection { background: var(--tb-brand-200); color: var(--tb-brand-900); }
[data-bs-theme="dark"] ::selection { background: rgba(139, 124, 255, .35); color: #fff; }

:focus-visible { outline: 2px solid var(--tb-primary); outline-offset: 2px; border-radius: var(--tb-r-xs); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--tb-border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--tb-border-strong); border-radius: var(--tb-r-pill);
  border: 3px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--tb-text-subtle); background-clip: content-box; }

/* ---------------------------------------------------------------------------
   3. Bootstrap overrides
   ------------------------------------------------------------------------- */
.form-label {
  font-size: 12.5px; font-weight: 600; color: var(--tb-text-muted);
  letter-spacing: .01em; margin-bottom: 6px;
}
.form-control, .form-select {
  background: var(--tb-surface); border: 1px solid var(--tb-border); color: var(--tb-text);
  border-radius: var(--tb-r-sm); padding: .58rem .8rem; font-size: 14px;
  transition: border-color var(--tb-fast), box-shadow var(--tb-fast), background var(--tb-fast);
}
.form-control::placeholder { color: var(--tb-text-subtle); }
.form-control:hover:not(:focus), .form-select:hover:not(:focus) { border-color: var(--tb-border-strong); }
.form-control:focus, .form-select:focus {
  background: var(--tb-surface); color: var(--tb-text);
  border-color: var(--tb-primary); box-shadow: var(--tb-ring);
}
.form-control:disabled, .form-select:disabled,
fieldset:disabled .form-control, fieldset:disabled .form-select {
  background: var(--tb-surface-3); color: var(--tb-text-muted); opacity: 1;
}
textarea.form-control {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 13px; line-height: 1.65;
}
.form-text { color: var(--tb-text-subtle); font-size: 12.5px; margin-top: 6px; }
.input-group-text {
  background: var(--tb-surface-2); border-color: var(--tb-border); color: var(--tb-text-subtle);
}
.input-group:focus-within .input-group-text { border-color: var(--tb-primary); color: var(--tb-primary); }
.form-check-input { border-color: var(--tb-border-strong); background-color: var(--tb-surface); cursor: pointer; }
.form-check-input:checked { background-color: var(--tb-primary); border-color: var(--tb-primary); }
.form-check-input:focus { box-shadow: var(--tb-ring); border-color: var(--tb-primary); }
.form-check-label { font-size: 13.5px; cursor: pointer; }

/* Buttons */
.btn {
  --bs-btn-focus-box-shadow: var(--tb-ring);
  border-radius: var(--tb-r-sm); font-weight: 600; font-size: 14px;
  padding: .55rem 1rem; display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  line-height: 1.35; border-width: 1px;
  transition: transform .12s var(--tb-ease), box-shadow var(--tb-fast), background var(--tb-fast),
              border-color var(--tb-fast), color var(--tb-fast), filter var(--tb-fast);
}
.btn i { font-size: 15px; line-height: 1; }
.btn-sm { padding: .4rem .75rem; font-size: 13px; border-radius: var(--tb-r-xs); }
.btn-lg { padding: .72rem 1.25rem; font-size: 15px; border-radius: var(--tb-r-md); }
.btn:active { transform: translateY(1px) scale(.99); }

.btn-primary {
  background: var(--tb-gradient); border-color: transparent; color: #fff;
  box-shadow: var(--tb-glow);
}
.btn-primary:hover, .btn-primary:focus-visible, .btn-primary:active {
  background: var(--tb-gradient) !important; border-color: transparent !important; color: #fff !important;
  filter: saturate(1.1) brightness(1.07); box-shadow: 0 12px 30px -10px rgba(109, 94, 252, .7);
}
.btn-primary:disabled, .btn-primary.disabled { background: var(--tb-gradient); box-shadow: none; opacity: .45; }

.btn-outline-secondary {
  color: var(--tb-text); border-color: var(--tb-border); background: var(--tb-surface);
  box-shadow: var(--tb-shadow-xs);
}
.btn-outline-secondary:hover, .btn-outline-secondary:focus-visible {
  background: var(--tb-surface-2); border-color: var(--tb-border-strong); color: var(--tb-text);
}
.btn-outline-secondary:disabled { background: var(--tb-surface); color: var(--tb-text-subtle); border-color: var(--tb-border); }
.btn-outline-primary { color: var(--tb-primary); border-color: var(--tb-brand-200); background: var(--tb-surface); }
.btn-outline-primary:hover, .btn-outline-primary:focus-visible {
  background: var(--tb-primary-soft); border-color: var(--tb-primary); color: var(--tb-primary-strong);
}
[data-bs-theme="dark"] .btn-outline-primary { border-color: var(--tb-border-strong); }
.btn-outline-danger { color: var(--tb-danger); border-color: var(--tb-border); background: var(--tb-surface); }
.btn-outline-danger:hover, .btn-outline-danger:focus-visible {
  background: var(--tb-danger-soft); border-color: var(--tb-danger); color: var(--tb-danger);
}
.btn-success { background: var(--tb-success); border-color: transparent; color: #fff; box-shadow: 0 8px 20px -10px rgba(14, 164, 114, .85); }
.btn-success:hover, .btn-success:focus-visible { background: var(--tb-success); filter: brightness(1.08); color: #fff; border-color: transparent; }
.btn-warning { background: var(--tb-warning); border-color: transparent; color: #fff; box-shadow: 0 8px 20px -10px rgba(217, 119, 6, .85); }
.btn-warning:hover, .btn-warning:focus-visible { background: var(--tb-warning); filter: brightness(1.08); color: #fff; border-color: transparent; }
.btn-danger { background: var(--tb-danger); border-color: transparent; color: #fff; box-shadow: 0 8px 20px -10px rgba(225, 29, 72, .85); }
.btn-danger:hover, .btn-danger:focus-visible { background: var(--tb-danger); filter: brightness(1.08); color: #fff; border-color: transparent; }
[data-bs-theme="dark"] .btn-success,
[data-bs-theme="dark"] .btn-warning,
[data-bs-theme="dark"] .btn-danger { color: #0b0d14; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--tb-text-muted); }
.btn-ghost:hover, .btn-ghost:focus-visible { background: var(--tb-surface-3); color: var(--tb-text); }

.tb-btn-icon { width: 38px; height: 38px; padding: 0; flex-shrink: 0; }
.tb-btn-icon.btn-sm { width: 32px; height: 32px; }

/* Badges */
.badge {
  border-radius: var(--tb-r-pill); font-weight: 600; font-size: 11.5px; letter-spacing: .01em;
  padding: .36em .72em; display: inline-flex; align-items: center; gap: .35em; line-height: 1.45;
}

/* Dropdowns */
.dropdown-menu {
  background: var(--tb-elevated); border: 1px solid var(--tb-border); border-radius: var(--tb-r-md);
  box-shadow: var(--tb-shadow-lg); padding: 6px; font-size: 14px;
  animation: tb-pop .16s var(--tb-ease);
}
.dropdown-item {
  border-radius: var(--tb-r-xs); padding: .5rem .65rem; color: var(--tb-text);
  display: flex; align-items: center; gap: .6rem; font-weight: 500;
}
.dropdown-item i { color: var(--tb-text-subtle); font-size: 15px; width: 18px; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--tb-surface-3); color: var(--tb-text); }
.dropdown-item:hover i { color: var(--tb-primary); }
.dropdown-item.tb-danger-item:hover { background: var(--tb-danger-soft); color: var(--tb-danger); }
.dropdown-item.tb-danger-item:hover i { color: var(--tb-danger); }
.dropdown-divider { border-color: var(--tb-border); margin: 6px 4px; }
.dropdown-header {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700;
  color: var(--tb-text-subtle); padding: .5rem .65rem .3rem;
}
@keyframes tb-pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }

/* Modals */
.modal-content {
  background: var(--tb-elevated); border: 1px solid var(--tb-border);
  border-radius: var(--tb-r-lg); box-shadow: var(--tb-shadow-lg);
}
.modal-header { border-bottom: 1px solid var(--tb-border); padding: 18px 22px; }
.modal-title { font-size: 16.5px; font-weight: 700; }
.modal-body { padding: 22px; }
.modal-footer { border-top: 1px solid var(--tb-border); padding: 14px 22px; background: var(--tb-surface-2); border-radius: 0 0 var(--tb-r-lg) var(--tb-r-lg); }
.modal-backdrop.show { opacity: .5; }
.btn-close { border-radius: var(--tb-r-xs); opacity: .5; }
.btn-close:hover { opacity: 1; }
[data-bs-theme="dark"] .btn-close { filter: invert(1) grayscale(1) brightness(2); }

/* Alerts */
.alert {
  border-radius: var(--tb-r-md); border: 1px solid var(--tb-border); font-size: 14px;
  padding: .85rem 1rem; display: flex; align-items: flex-start; gap: .65rem;
  background: var(--tb-surface-2); color: var(--tb-text); margin-bottom: 14px;
}
.alert-danger { background: var(--tb-danger-soft); border-color: transparent; color: var(--tb-danger); }
.alert-secondary { background: var(--tb-surface-3); border-color: transparent; color: var(--tb-text-muted); }

/* Tables */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--tb-text);
  --bs-table-border-color: var(--tb-border);
  margin-bottom: 0;
}
.table > :not(caption) > * > * { background: transparent; color: var(--tb-text); }

/* Text helpers mapped to tokens */
.text-muted { color: var(--tb-text-muted) !important; }
.tb-subtle { color: var(--tb-text-subtle) !important; }
.tb-mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------------------------------------------------------------------------
   4. App shell
   ------------------------------------------------------------------------- */
.tb-shell { display: flex; min-height: 100vh; }

.tb-main {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  margin-left: var(--tb-sidebar-w); transition: margin-left var(--tb-med);
}
.tb-rail .tb-main { margin-left: var(--tb-sidebar-rail); }

.tb-content { padding: 26px 28px 48px; flex: 1; width: 100%; max-width: 1560px; margin: 0 auto; }

/* Skip link for keyboard users */
.tb-skip {
  position: absolute; left: -9999px; top: 10px; z-index: 3000;
  background: var(--tb-surface); color: var(--tb-text); padding: 10px 16px;
  border-radius: var(--tb-r-sm); box-shadow: var(--tb-shadow-lg); font-weight: 600;
}
.tb-skip:focus { left: 16px; }

/* ---------------------------------------------------------------------------
   5. Sidebar
   ------------------------------------------------------------------------- */
.tb-sidebar {
  width: var(--tb-sidebar-w); flex-shrink: 0;
  background: var(--tb-surface);
  border-right: 1px solid var(--tb-border);
  display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0; z-index: 1045;
  transition: transform var(--tb-med), width var(--tb-med);
}
.tb-rail .tb-sidebar { width: var(--tb-sidebar-rail); }

.tb-sidebar-brand {
  display: flex; align-items: center; gap: 11px; padding: 18px 18px 16px;
  min-height: 74px; position: relative;
}
.tb-logo-badge {
  width: 40px; height: 40px; border-radius: 13px; background: var(--tb-gradient);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 19px; flex-shrink: 0; box-shadow: var(--tb-glow);
  position: relative; overflow: hidden;
}
.tb-logo-badge::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(140deg, rgba(255, 255, 255, .45) 0%, transparent 46%);
}
.tb-brand-text { min-width: 0; overflow: hidden; }
.tb-brand-name { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 800; font-size: 15.5px; line-height: 1.15; white-space: nowrap; }
.tb-brand-sub {
  font-size: 10px; color: var(--tb-text-subtle); letter-spacing: .13em;
  text-transform: uppercase; font-weight: 700; white-space: nowrap;
}

.tb-rail-toggle {
  position: absolute; right: -13px; top: 30px; z-index: 2;
  width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--tb-border);
  background: var(--tb-surface); color: var(--tb-text-muted); box-shadow: var(--tb-shadow-sm);
  display: flex; align-items: center; justify-content: center; font-size: 13px; cursor: pointer;
  opacity: 0; transition: opacity var(--tb-fast), color var(--tb-fast), border-color var(--tb-fast);
}
.tb-sidebar:hover .tb-rail-toggle, .tb-rail-toggle:focus-visible { opacity: 1; }
.tb-rail-toggle:hover { color: var(--tb-primary); border-color: var(--tb-primary); }
.tb-rail .tb-rail-toggle i { transform: rotate(180deg); }

.tb-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 14px 14px; }
.tb-nav-group { margin-bottom: 16px; }
.tb-nav-label {
  font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--tb-text-subtle); padding: 8px 12px 6px; white-space: nowrap;
}
.tb-nav-link {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--tb-r-sm);
  color: var(--tb-text-muted); font-size: 14px; font-weight: 500; margin-bottom: 3px;
  position: relative; white-space: nowrap;
  transition: background var(--tb-fast), color var(--tb-fast), transform .12s var(--tb-ease);
}
.tb-nav-link i { font-size: 17px; width: 20px; text-align: center; flex-shrink: 0; transition: color var(--tb-fast), transform var(--tb-fast); }
.tb-nav-link:hover { background: var(--tb-surface-3); color: var(--tb-text); }
.tb-nav-link:hover i { transform: scale(1.1); }
.tb-nav-link.active {
  background: var(--tb-primary-soft); color: var(--tb-primary-strong); font-weight: 600;
}
.tb-nav-link.active i { color: var(--tb-primary); }
.tb-nav-link.active::before {
  content: ''; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--tb-gradient);
}
.tb-nav-badge {
  margin-left: auto; font-size: 10.5px; font-weight: 700; padding: 2px 7px;
  border-radius: var(--tb-r-pill); background: var(--tb-surface-3); color: var(--tb-text-muted);
}
.tb-nav-link.active .tb-nav-badge { background: rgba(109, 94, 252, .16); color: var(--tb-primary-strong); }

/* Sidebar footer / user */
.tb-sidebar-foot { padding: 12px 14px 16px; border-top: 1px solid var(--tb-border); }
.tb-user-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px;
  border: 1px solid transparent; border-radius: var(--tb-r-md); background: var(--tb-surface-2);
  color: var(--tb-text); text-align: left; cursor: pointer; transition: background var(--tb-fast), border-color var(--tb-fast);
}
.tb-user-btn:hover { background: var(--tb-surface-3); border-color: var(--tb-border); }
.tb-user-btn::after { display: none; }
.tb-user-meta { min-width: 0; flex: 1; overflow: hidden; }
.tb-user-name { font-size: 13.5px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-user-role { font-size: 11.5px; color: var(--tb-text-subtle); white-space: nowrap; }
.tb-user-caret { color: var(--tb-text-subtle); font-size: 13px; flex-shrink: 0; }

.tb-avatar {
  width: 36px; height: 36px; border-radius: 12px; background: var(--tb-gradient); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0; letter-spacing: .02em;
}
.tb-avatar-sm { width: 32px; height: 32px; border-radius: 10px; font-size: 12px; }
.tb-avatar-lg { width: 46px; height: 46px; border-radius: 14px; font-size: 16px; }

/* Rail (collapsed) mode */
.tb-rail .tb-brand-text,
.tb-rail .tb-nav-label,
.tb-rail .tb-nav-link span,
.tb-rail .tb-nav-badge,
.tb-rail .tb-user-meta,
.tb-rail .tb-user-caret { display: none; }
.tb-rail .tb-sidebar-brand { justify-content: center; padding-left: 0; padding-right: 0; }
.tb-rail .tb-nav-group { margin-bottom: 10px; position: relative; }
.tb-rail .tb-nav-group + .tb-nav-group::before {
  content: ''; display: block; height: 1px; background: var(--tb-border); margin: 0 8px 10px;
}
.tb-rail .tb-nav-link { justify-content: center; padding: 11px 0; }
.tb-rail .tb-nav-link.active::before { display: none; }
.tb-rail .tb-user-btn { justify-content: center; padding: 8px; }

/* Rail tooltips */
.tb-rail .tb-nav-link::after {
  content: attr(data-label); position: absolute; left: calc(100% + 14px); top: 50%;
  transform: translateY(-50%) translateX(-4px);
  background: var(--tb-text); color: var(--tb-canvas); font-size: 12.5px; font-weight: 600;
  padding: 6px 10px; border-radius: var(--tb-r-xs); white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity var(--tb-fast), transform var(--tb-fast); z-index: 20;
  box-shadow: var(--tb-shadow-md);
}
.tb-rail .tb-nav-link:hover::after { opacity: 1; transform: translateY(-50%) translateX(0); }

/* Mobile scrim */
.tb-scrim {
  position: fixed; inset: 0; background: rgba(10, 12, 19, .5); backdrop-filter: blur(2px);
  z-index: 1040; opacity: 0; pointer-events: none; transition: opacity var(--tb-med);
}
.tb-nav-open .tb-scrim { opacity: 1; pointer-events: auto; }

/* ---------------------------------------------------------------------------
   6. Topbar
   ------------------------------------------------------------------------- */
.tb-topbar {
  display: flex; align-items: center; gap: 14px; padding: 13px 28px;
  background: var(--tb-glass); backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--tb-border);
  position: sticky; top: 0; z-index: 1020; min-height: 66px;
}
.tb-topbar .tb-menu-btn { display: none; }
.tb-crumbs {
  display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--tb-text-subtle);
  margin-bottom: 1px; min-width: 0; overflow: hidden; white-space: nowrap;
}
.tb-crumbs > span, .tb-crumbs > a { overflow: hidden; text-overflow: ellipsis; }
.tb-crumbs a { color: var(--tb-text-subtle); font-weight: 500; }
.tb-crumbs a:hover { color: var(--tb-primary); }
.tb-crumbs i { font-size: 10px; opacity: .6; }
.tb-topbar-titles { flex: 1; min-width: 0; }
.tb-page-title {
  font-size: 19px; font-weight: 700; margin: 0; line-height: 1.25; letter-spacing: -.025em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tb-topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.tb-icon-btn {
  width: 38px; height: 38px; border-radius: var(--tb-r-sm); border: 1px solid var(--tb-border);
  background: var(--tb-surface); color: var(--tb-text-muted); display: inline-flex;
  align-items: center; justify-content: center; font-size: 16px; cursor: pointer;
  transition: background var(--tb-fast), color var(--tb-fast), border-color var(--tb-fast), transform .12s var(--tb-ease);
}
.tb-icon-btn:hover { background: var(--tb-surface-2); color: var(--tb-text); border-color: var(--tb-border-strong); }
.tb-icon-btn:active { transform: scale(.94); }

.tb-theme-toggle .bi-moon-stars-fill { display: none; }
[data-bs-theme="dark"] .tb-theme-toggle .bi-sun-fill { display: none; }
[data-bs-theme="dark"] .tb-theme-toggle .bi-moon-stars-fill { display: inline-block; }

.tb-role-pill {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  padding: 5px 11px; border-radius: var(--tb-r-pill); display: inline-flex; align-items: center; gap: 5px;
}
.tb-role-admin { background: var(--tb-primary-soft); color: var(--tb-primary-strong); }
.tb-role-member { background: var(--tb-surface-3); color: var(--tb-text-muted); }

/* Live "pulse" status chip in the topbar */
.tb-live-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px 6px 11px;
  border-radius: var(--tb-r-pill); font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--tb-border); background: var(--tb-surface); color: var(--tb-text-muted);
  white-space: nowrap;
}
.tb-live-chip.is-live { color: var(--tb-success); background: var(--tb-success-soft); border-color: transparent; }
.tb-pulse { width: 8px; height: 8px; border-radius: 50%; background: currentColor; position: relative; flex-shrink: 0; }
.tb-live-chip.is-live .tb-pulse::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%; background: currentColor;
  animation: tb-ping 1.8s var(--tb-ease) infinite;
}
@keyframes tb-ping { 0% { transform: scale(1); opacity: .7; } 70%, 100% { transform: scale(2.6); opacity: 0; } }

/* ---------------------------------------------------------------------------
   7. Components
   ------------------------------------------------------------------------- */

/* --- Page header (in-content) --- */
.tb-page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 22px;
}
.tb-page-head h2 { font-size: 22px; margin: 0 0 3px; }
.tb-page-head p { color: var(--tb-text-muted); margin: 0; font-size: 14px; }

/* --- Card --- */
.tb-card {
  background: var(--tb-surface); border: 1px solid var(--tb-border); border-radius: var(--tb-r-lg);
  box-shadow: var(--tb-shadow-sm); padding: 22px; margin-bottom: 20px; position: relative;
  animation: tb-rise .4s var(--tb-ease) both;
}
.tb-card-flush { padding: 0; overflow: hidden; }
.tb-card-flush > .tb-card-header { padding: 20px 22px; margin-bottom: 0; border-bottom: 1px solid var(--tb-border); }
.tb-card-flush > .tb-card-foot { padding: 14px 22px; border-top: 1px solid var(--tb-border); background: var(--tb-surface-2); }
@keyframes tb-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.tb-card:nth-of-type(2) { animation-delay: .05s; }
.tb-card:nth-of-type(3) { animation-delay: .1s; }
.tb-card:nth-of-type(4) { animation-delay: .15s; }

.tb-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; gap: 14px; flex-wrap: wrap;
}
.tb-card-header h5, .tb-card-header h4 { margin: 0; font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.tb-card-subtitle { color: var(--tb-text-muted); font-size: 13px; margin-top: 3px; }
.tb-card-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* --- Hero / welcome banner --- */
.tb-hero {
  position: relative; overflow: hidden; border-radius: var(--tb-r-xl); color: #fff;
  padding: 30px 32px; margin-bottom: 22px; background: var(--tb-gradient);
  box-shadow: 0 18px 40px -22px rgba(90, 69, 240, .8);
  animation: tb-rise .45s var(--tb-ease) both;
}
.tb-hero::before {
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(600px 260px at 88% -30%, rgba(255, 255, 255, .3), transparent 70%),
    radial-gradient(420px 220px at 8% 130%, rgba(255, 255, 255, .16), transparent 70%);
}
.tb-hero::after {
  content: ''; position: absolute; right: -70px; top: -70px; width: 260px; height: 260px;
  border-radius: 50%; border: 42px solid rgba(255, 255, 255, .07);
}
.tb-hero > * { position: relative; z-index: 1; }
.tb-hero-eyebrow {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase; color: rgba(255, 255, 255, .82);
  background: rgba(255, 255, 255, .16); padding: 5px 12px; border-radius: var(--tb-r-pill); margin-bottom: 14px;
}
.tb-hero h2 { color: #fff; font-size: 27px; margin: 0 0 6px; letter-spacing: -.03em; }
.tb-hero p { color: rgba(255, 255, 255, .82); margin: 0 0 22px; font-size: 14.5px; max-width: 62ch; }
.tb-hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.tb-hero .btn-light {
  background: #fff; color: var(--tb-brand-700); border: none; font-weight: 650;
  box-shadow: 0 8px 20px -10px rgba(0, 0, 0, .45);
}
.tb-hero .btn-light:hover { background: #fff; color: var(--tb-brand-800); filter: brightness(.97); }
.tb-hero .btn-glass {
  background: rgba(255, 255, 255, .17); color: #fff; border: 1px solid rgba(255, 255, 255, .28);
  backdrop-filter: blur(6px);
}
.tb-hero .btn-glass:hover { background: rgba(255, 255, 255, .27); color: #fff; }

/* --- KPI grid --- */
.tb-kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(232px, 1fr)); gap: 16px; margin-bottom: 20px;
}
.tb-kpi {
  background: var(--tb-surface); border: 1px solid var(--tb-border); border-radius: var(--tb-r-lg);
  padding: 18px 20px; box-shadow: var(--tb-shadow-sm); position: relative; overflow: hidden;
  transition: transform var(--tb-fast), box-shadow var(--tb-fast), border-color var(--tb-fast);
  animation: tb-rise .4s var(--tb-ease) both;
}
.tb-kpi:nth-child(2) { animation-delay: .06s; }
.tb-kpi:nth-child(3) { animation-delay: .12s; }
.tb-kpi:nth-child(4) { animation-delay: .18s; }
.tb-kpi:hover { transform: translateY(-3px); box-shadow: var(--tb-shadow-md); border-color: var(--tb-border-strong); }
.tb-kpi::after {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: var(--tb-accent, var(--tb-gradient)); opacity: 0; transition: opacity var(--tb-fast);
}
.tb-kpi:hover::after { opacity: 1; }
.tb-kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.tb-kpi-label {
  font-size: 12px; font-weight: 650; color: var(--tb-text-muted);
  text-transform: uppercase; letter-spacing: .06em;
}
.tb-kpi-icon {
  width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center;
  justify-content: center; font-size: 18px; flex-shrink: 0;
}
.tb-kpi-value { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 30px; font-weight: 800; line-height: 1.05; letter-spacing: -.035em; }
.tb-kpi-value small { font-size: 16px; font-weight: 700; color: var(--tb-text-subtle); letter-spacing: -.02em; }
.tb-kpi-foot { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--tb-text-subtle); margin-top: 8px; }

/* Tinted icon chips (shared by KPIs, stat rows, list icons) */
.tb-tint-brand  { background: var(--tb-primary-soft); color: var(--tb-primary-strong); }
.tb-tint-green  { background: var(--tb-success-soft); color: var(--tb-success); }
.tb-tint-red    { background: var(--tb-danger-soft); color: var(--tb-danger); }
.tb-tint-amber  { background: var(--tb-warning-soft); color: var(--tb-warning); }
.tb-tint-blue   { background: var(--tb-info-soft); color: var(--tb-info); }
.tb-tint-slate  { background: var(--tb-surface-3); color: var(--tb-text-muted); }

/* Progress meter inside KPI */
.tb-meter {
  height: 6px; border-radius: var(--tb-r-pill); background: var(--tb-surface-3);
  overflow: hidden; margin-top: 12px; transition: opacity var(--tb-fast);
}
.tb-meter.is-idle { opacity: 0; }
.tb-meter span {
  display: block; height: 100%; border-radius: var(--tb-r-pill); background: var(--tb-gradient);
  transition: width .8s var(--tb-ease);
}
.tb-meter.is-green span { background: linear-gradient(90deg, #10b981, #0ea472); }
.tb-meter.is-amber span { background: linear-gradient(90deg, #fbbf24, #d97706); }

/* --- Status badges (soft, dot-prefixed) --- */
.tb-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px 4px 9px;
  border-radius: var(--tb-r-pill); font-size: 12px; font-weight: 600; white-space: nowrap;
}
.tb-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.tb-badge-nodot::before { display: none; }
.tb-badge-pending, .tb-badge-secondary { background: var(--tb-surface-3); color: var(--tb-text-muted); }
.tb-badge-transferred, .tb-badge-success, .tb-badge-inserted { background: var(--tb-success-soft); color: var(--tb-success); }
.tb-badge-failed, .tb-badge-danger, .tb-badge-invalid { background: var(--tb-danger-soft); color: var(--tb-danger); }
.tb-badge-warning, .tb-badge-duplicate { background: var(--tb-warning-soft); color: var(--tb-warning); }
.tb-badge-brand, .tb-badge-primary { background: var(--tb-primary-soft); color: var(--tb-primary-strong); }
.tb-badge-info { background: var(--tb-info-soft); color: var(--tb-info); }

.tb-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: var(--tb-r-xs);
  border: 1px solid var(--tb-border); background: var(--tb-surface-2); color: var(--tb-text-muted);
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}

/* --- Segmented control / filter pills --- */
.tb-segment {
  display: inline-flex; background: var(--tb-surface-3); border-radius: var(--tb-r-sm);
  padding: 4px; gap: 3px; border: 1px solid var(--tb-border); flex-wrap: wrap;
}
.tb-segment button, .tb-segment a {
  border: none; background: transparent; cursor: pointer; color: var(--tb-text-muted);
  padding: 6px 13px; border-radius: 7px; font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  transition: background var(--tb-fast), color var(--tb-fast), box-shadow var(--tb-fast);
}
.tb-segment button:hover, .tb-segment a:hover { color: var(--tb-text); }
.tb-segment button.active, .tb-segment a.active {
  background: var(--tb-surface); color: var(--tb-text); box-shadow: var(--tb-shadow-xs);
}
.tb-segment .tb-seg-count {
  font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: var(--tb-r-pill);
  background: var(--tb-surface); color: var(--tb-text-subtle); min-width: 20px; text-align: center;
}
.tb-segment button.active .tb-seg-count { background: var(--tb-primary-soft); color: var(--tb-primary-strong); }

/* --- Toolbar search --- */
.tb-search { position: relative; }
.tb-search > i {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--tb-text-subtle); font-size: 15px; pointer-events: none;
}
.tb-search .form-control { padding-left: 36px; padding-right: 34px; min-width: 284px; }
.tb-search kbd {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  font-size: 10.5px; font-family: inherit; font-weight: 600; color: var(--tb-text-subtle);
  background: var(--tb-surface-3); border: 1px solid var(--tb-border); border-radius: 5px;
  padding: 2px 6px; pointer-events: none;
}
.tb-search .form-control:focus + kbd, .tb-search .form-control:not(:placeholder-shown) + kbd { opacity: 0; }

/* --- Tables --- */
.tb-table-wrap { overflow-x: auto; }
.tb-table { width: 100%; margin: 0; border-collapse: separate; border-spacing: 0; }
.tb-table thead th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700;
  color: var(--tb-text-subtle); background: var(--tb-surface-2); padding: 11px 16px;
  border-bottom: 1px solid var(--tb-border); border-top: 1px solid var(--tb-border);
  white-space: nowrap; position: sticky; top: 0; z-index: 2;
}
.tb-table thead th:first-child { padding-left: 22px; }
.tb-table thead th:last-child { padding-right: 22px; }
.tb-table tbody td {
  padding: 13px 16px; border-bottom: 1px solid var(--tb-border); vertical-align: middle; font-size: 13.5px;
}
.tb-table tbody td:first-child { padding-left: 22px; }
.tb-table tbody td:last-child { padding-right: 22px; }
.tb-table tbody tr { transition: background var(--tb-fast); }
.tb-table tbody tr:hover { background: var(--tb-surface-2); }
.tb-table tbody tr.tb-phone-row-invalid { background: color-mix(in srgb, var(--tb-danger-soft) 52%, transparent); }
.tb-table tbody tr.tb-phone-row-invalid:hover { background: color-mix(in srgb, var(--tb-danger-soft) 78%, transparent); }
.tb-table tbody tr:last-child td { border-bottom: none; }
.tb-row-click { cursor: pointer; }
.tb-th-sort {
  border: none; background: transparent; color: inherit; padding: 0; font: inherit; font-weight: 700;
  text-transform: inherit; letter-spacing: inherit; display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer;
}
.tb-th-sort:hover, .tb-th-sort.is-asc, .tb-th-sort.is-desc { color: var(--tb-primary-strong); }
.tb-th-sort i { font-size: 13px; }

/* Trailing action buttons in a table row */
.tb-row-actions { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }

/* Wide reports (many columns) read better on one line each — the wrapper
   scrolls horizontally rather than letting every cell wrap to two lines. */
.tb-table-wide { min-width: 100%; }
.tb-table-wide tbody td, .tb-table-wide thead th { white-space: nowrap; }
.tb-table-wide tbody td { max-width: 280px; }
.tb-row-click:hover .tb-cell-name { color: var(--tb-primary-strong); }

.tb-cell-primary { display: flex; align-items: center; gap: 11px; min-width: 0; }
.tb-cell-name { font-weight: 600; font-size: 13.5px; transition: color var(--tb-fast); }
.tb-cell-sub { font-size: 12px; color: var(--tb-text-subtle); font-weight: 400; }
.tb-truncate { max-width: min(260px, 100%); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.tb-phone-pill { display: inline-flex; align-items: center; border-radius: var(--tb-r-xs); padding: 2px 6px; }
.tb-phone-pill.is-invalid {
  background: var(--tb-danger-soft); color: var(--tb-danger); font-weight: 700;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tb-danger) 22%, transparent);
}

/* Lead card view */
.tb-view-toggle button { min-width: 38px; justify-content: center; padding-inline: 10px; }
.tb-lead-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(285px, 1fr)); gap: 14px;
  padding: 18px 22px 22px;
}
.tb-lead-card {
  border: 1px solid var(--tb-border); border-radius: var(--tb-r-md); background: var(--tb-surface);
  padding: 15px; cursor: pointer; box-shadow: var(--tb-shadow-xs);
  transition: transform var(--tb-fast), box-shadow var(--tb-fast), border-color var(--tb-fast), background var(--tb-fast);
}
.tb-lead-card:hover { transform: translateY(-2px); box-shadow: var(--tb-shadow-sm); border-color: var(--tb-border-strong); }
.tb-lead-card.is-phone-invalid { background: color-mix(in srgb, var(--tb-danger-soft) 42%, var(--tb-surface)); border-color: color-mix(in srgb, var(--tb-danger) 24%, var(--tb-border)); }
.tb-lead-card-top { display: flex; align-items: center; gap: 11px; margin-bottom: 13px; min-width: 0; }
.tb-lead-card-fields { display: grid; gap: 9px; }
.tb-lead-card-fields > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.tb-lead-card-fields > div > span:first-child { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--tb-text-subtle); }
.tb-lead-card-fields strong { font-size: 13px; color: var(--tb-text); font-weight: 650; min-width: 0; }
.tb-card-edit { margin-top: 14px; width: 100%; }

/* Skeleton loading */
.tb-skeleton {
  display: block; height: 13px; border-radius: 6px; width: 100%;
  background: linear-gradient(90deg, var(--tb-surface-3) 25%, var(--tb-surface-2) 37%, var(--tb-surface-3) 63%);
  background-size: 400% 100%; animation: tb-shimmer 1.3s ease infinite;
}
.tb-skeleton-row td { padding-top: 16px; padding-bottom: 16px; }
@keyframes tb-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* Empty & error states */
.tb-empty { text-align: center; padding: 52px 20px; }
.tb-empty-icon {
  width: 66px; height: 66px; border-radius: 20px; background: var(--tb-surface-3);
  color: var(--tb-text-subtle); display: inline-flex; align-items: center; justify-content: center;
  font-size: 28px; margin-bottom: 14px;
}
.tb-empty-title { font-weight: 700; font-size: 15.5px; margin-bottom: 4px; color: var(--tb-text); }
.tb-empty-text { color: var(--tb-text-muted); font-size: 13.5px; max-width: 44ch; margin: 0 auto; }

/* Pagination */
.tb-pagebar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.tb-pagenums { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.tb-page-num {
  border: 1px solid var(--tb-border); background: var(--tb-surface); border-radius: var(--tb-r-xs);
  min-width: 34px; height: 34px; font-size: 13px; font-weight: 600; color: var(--tb-text-muted);
  padding: 0 8px; cursor: pointer; transition: all var(--tb-fast);
}
.tb-page-num:hover:not(.active) { background: var(--tb-surface-3); color: var(--tb-text); border-color: var(--tb-border-strong); }
.tb-page-num.active { background: var(--tb-gradient); color: #fff; border-color: transparent; box-shadow: var(--tb-glow); }
.tb-page-ellipsis { color: var(--tb-text-subtle); padding: 0 2px; }

/* Bulk selection bar */
.tb-bulkbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--tb-primary-soft); border: 1px solid transparent; border-radius: var(--tb-r-md);
  padding: 10px 14px; margin-bottom: 14px; font-size: 13.5px; color: var(--tb-primary-strong);
  animation: tb-rise .2s var(--tb-ease);
}
.tb-bulkbar .btn-link { text-decoration: none; font-weight: 600; padding: 0; color: var(--tb-primary-strong); }
.tb-bulkbar .btn-link:hover { text-decoration: underline; }

/* Column visibility: the table gets .tb-hide-<col>, and every matching header
   and cell carries data-col="<col>". Keys are shared by the Leads table and the
   Import Result report. */
.tb-hide-name [data-col="name"],
.tb-hide-lastname [data-col="lastname"],
.tb-hide-phone [data-col="phone"],
.tb-hide-digits [data-col="digits"],
.tb-hide-email [data-col="email"],
.tb-hide-source [data-col="source"],
.tb-hide-language [data-col="language"],
.tb-hide-market [data-col="market"],
.tb-hide-city [data-col="city"],
.tb-hide-status [data-col="status"],
.tb-hide-outcome [data-col="outcome"],
.tb-hide-reason [data-col="reason"],
.tb-hide-rownum [data-col="rownum"],
.tb-hide-sentat [data-col="sentat"] { display: none; }
.tb-col-menu { min-width: 220px; }
.tb-col-menu .form-check { padding: 7px 10px 7px 2.1em; margin: 0; border-radius: var(--tb-r-xs); }
.tb-col-menu .form-check:hover { background: var(--tb-surface-3); }

/* --- Activity chart (inline SVG area) --- */
.tb-chart { width: 100%; height: 190px; display: block; overflow: visible; }
.tb-chart .tb-grid-line { stroke: var(--tb-border); stroke-width: 1; stroke-dasharray: 3 5; }
.tb-chart .tb-area { fill: url(#tbAreaGrad); }
.tb-chart .tb-line { fill: none; stroke: var(--tb-primary); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.tb-chart .tb-dot { fill: var(--tb-surface); stroke: var(--tb-primary); stroke-width: 2.5; transition: r var(--tb-fast); }
.tb-chart .tb-axis-label { fill: var(--tb-text-subtle); font-size: 10.5px; font-weight: 600; }
.tb-chart-legend { display: flex; align-items: center; gap: 16px; font-size: 12.5px; color: var(--tb-text-muted); flex-shrink: 0; }
.tb-chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tb-legend-swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--tb-primary); }

/* Bar chart variant (pure CSS columns) */
.tb-bars { display: flex; align-items: stretch; gap: 10px; height: 158px; padding-top: 8px; }
.tb-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.tb-bar-track { width: 100%; flex: 1; display: flex; align-items: flex-end; }
.tb-bar {
  width: 100%; border-radius: 7px 7px 3px 3px; background: var(--tb-gradient); min-height: 4px;
  animation: tb-bar-grow .7s var(--tb-ease) both; position: relative; cursor: default;
}
.tb-bar.is-empty { background: var(--tb-surface-3); }
.tb-bar-label { font-size: 10.5px; color: var(--tb-text-subtle); font-weight: 600; white-space: nowrap; }
@keyframes tb-bar-grow { from { transform: scaleY(0); transform-origin: bottom; } to { transform: scaleY(1); } }
.tb-bar[data-value]:hover::after {
  content: attr(data-value); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--tb-text); color: var(--tb-canvas); font-size: 11.5px; font-weight: 700;
  padding: 4px 9px; border-radius: 6px; white-space: nowrap; box-shadow: var(--tb-shadow-md);
}

.tb-bar-label.tb-bar-today { color: var(--tb-primary); font-weight: 700; }

/* Stacked proportion bar (pipeline breakdown) */
.tb-stack {
  display: flex; height: 9px; border-radius: var(--tb-r-pill); overflow: hidden;
  background: var(--tb-surface-3); margin-top: 4px;
}
.tb-stack-seg { display: block; height: 100%; transition: width .8s var(--tb-ease); }
.tb-stack-seg.is-green { background: var(--tb-success); }
.tb-stack-seg.is-slate { background: var(--tb-border-strong); }
.tb-stack-seg.is-red { background: var(--tb-danger); }
.tb-stack-seg.is-amber { background: var(--tb-warning); }
.tb-stack-seg.is-brand { background: var(--tb-primary); }

/* --- Definition rows (key/value lists) --- */
/* minmax(0, 1fr) is required: a bare `auto` column takes its min-content size as a
   minimum, so one long value (a webhook URL) would push every row wider than the
   card and spill out of it. */
.tb-dl { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; min-width: 0; }
.tb-dl-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 11px 0; border-bottom: 1px dashed var(--tb-border); flex-wrap: wrap;
}
.tb-dl-row:last-child { border-bottom: none; }
.tb-dl-key { font-size: 13px; color: var(--tb-text-muted); font-weight: 500; flex-shrink: 0; }
.tb-dl-val {
  font-size: 13.5px; font-weight: 600; text-align: right;
  min-width: 0; flex: 0 1 auto; overflow-wrap: anywhere;
}
.tb-dl-val > .tb-truncate { display: inline-block; max-width: 100%; vertical-align: bottom; }

/* Rows whose value is long (URLs) read better stacked: label on top, value on its
   own full-width line underneath. */
.tb-dl-row-stack { flex-direction: column; align-items: stretch; gap: 4px; }
.tb-dl-row-stack .tb-dl-val { text-align: left; width: 100%; }

/* Section heading inside cards/modals */
.tb-section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--tb-text-subtle); display: flex; align-items: center; gap: 8px; margin: 0 0 6px;
  font-family: 'Inter', sans-serif;
}
.tb-section-title i { font-size: 13px; }

/* Spinning refresh icon */
.tb-spin { display: inline-block; animation: tb-rotate .6s linear; }
@keyframes tb-rotate { to { transform: rotate(360deg); } }

/* Keyboard focus on clickable rows */
.tb-row-click:focus-visible { outline: 2px solid var(--tb-primary); outline-offset: -2px; background: var(--tb-surface-2); }

/* --- Feed / list rows --- */
.tb-feed-row {
  display: flex; align-items: center; gap: 13px; padding: 13px 0;
  border-bottom: 1px solid var(--tb-border);
}
.tb-feed-row:last-child { border-bottom: none; }
.tb-feed-icon {
  width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center;
  justify-content: center; font-size: 17px; flex-shrink: 0;
}
.tb-feed-body { flex: 1; min-width: 0; }
.tb-feed-title { font-weight: 650; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-feed-meta { font-size: 12px; color: var(--tb-text-subtle); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.tb-feed-meta .tb-dot-sep { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .5; }

/* --- Stepper (import wizard) --- */
.tb-steps { display: flex; align-items: center; gap: 0; margin-bottom: 24px; flex-wrap: wrap; }
.tb-step { display: flex; align-items: center; gap: 10px; }
.tb-step-num {
  width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0;
  background: var(--tb-surface-3); color: var(--tb-text-subtle); border: 1px solid var(--tb-border);
}
.tb-step-text { font-size: 13.5px; font-weight: 600; color: var(--tb-text-subtle); white-space: nowrap; }
.tb-step.is-active .tb-step-num { background: var(--tb-gradient); color: #fff; border-color: transparent; box-shadow: var(--tb-glow); }
.tb-step.is-active .tb-step-text { color: var(--tb-text); }
.tb-step.is-done .tb-step-num { background: var(--tb-success-soft); color: var(--tb-success); border-color: transparent; }
.tb-step.is-done .tb-step-text { color: var(--tb-text-muted); }
.tb-step-line { flex: 1; min-width: 28px; height: 2px; background: var(--tb-border); margin: 0 14px; border-radius: 2px; }
.tb-step-line.is-done { background: var(--tb-success); opacity: .5; }

/* --- Dropzone --- */
.tb-dropzone {
  border: 2px dashed var(--tb-border-strong); border-radius: var(--tb-r-lg); background: var(--tb-surface-2);
  padding: 46px 24px; text-align: center; cursor: pointer; position: relative; overflow: hidden;
  transition: border-color var(--tb-fast), background var(--tb-fast), transform var(--tb-fast);
}
.tb-dropzone:hover { border-color: var(--tb-primary); background: var(--tb-primary-soft); }
.tb-dropzone.tb-dropzone-drag {
  border-color: var(--tb-primary); background: var(--tb-primary-soft); transform: scale(1.01);
  box-shadow: var(--tb-ring);
}
.tb-dropzone-icon {
  width: 62px; height: 62px; border-radius: 20px; background: var(--tb-gradient); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 27px;
  margin-bottom: 16px; box-shadow: var(--tb-glow);
  transition: transform var(--tb-med);
}
.tb-dropzone:hover .tb-dropzone-icon { transform: translateY(-3px) scale(1.04); }
.tb-dropzone-title { font-weight: 700; font-size: 15.5px; margin-bottom: 5px; font-family: 'Plus Jakarta Sans', sans-serif; }
.tb-dropzone-hint { color: var(--tb-text-muted); font-size: 13px; }
.tb-dropzone-file {
  display: none; align-items: center; gap: 11px; justify-content: center; margin-top: 18px;
  background: var(--tb-surface); border: 1px solid var(--tb-border); border-radius: var(--tb-r-md);
  padding: 12px 16px; max-width: 420px; margin-left: auto; margin-right: auto; text-align: left;
}
.tb-dropzone-file.is-set { display: flex; animation: tb-rise .25s var(--tb-ease); }
.tb-file-name { font-weight: 650; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-file-size { font-size: 12px; color: var(--tb-text-subtle); }

/* Column picker grid (import step 2) */
.tb-colgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 8px; }
.tb-colpick {
  display: flex; align-items: center; gap: 10px; padding: 10px 13px; border-radius: var(--tb-r-sm);
  border: 1px solid var(--tb-border); background: var(--tb-surface-2); cursor: pointer;
  font-size: 13.5px; font-weight: 500; transition: all var(--tb-fast); min-width: 0;
}
.tb-colpick:hover { border-color: var(--tb-border-strong); background: var(--tb-surface-3); }
.tb-colpick:has(input:checked) { border-color: var(--tb-primary); background: var(--tb-primary-soft); color: var(--tb-primary-strong); font-weight: 600; }
.tb-colpick input { margin: 0; flex-shrink: 0; }
.tb-colpick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Preview table (compact, scrollable) */
.tb-preview {
  border: 1px solid var(--tb-border); border-radius: var(--tb-r-md); overflow: auto;
  max-height: 262px; background: var(--tb-surface);
}
.tb-preview table { width: 100%; margin: 0; white-space: nowrap; border-collapse: separate; border-spacing: 0; }
.tb-preview th {
  position: sticky; top: 0; background: var(--tb-surface-2); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .06em; font-weight: 700; color: var(--tb-text-subtle); padding: 9px 13px;
  border-bottom: 1px solid var(--tb-border); z-index: 1;
}
.tb-preview td { padding: 9px 13px; font-size: 12.5px; color: var(--tb-text-muted); border-bottom: 1px solid var(--tb-border); }
.tb-preview tr:last-child td { border-bottom: none; }

/* --- Password requirement checklist --- */
.tb-reqs { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 5px; }
.tb-reqs li {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px;
  color: var(--tb-text-subtle); transition: color var(--tb-fast);
}
.tb-reqs li i { font-size: 13px; flex-shrink: 0; }
.tb-reqs li.is-met { color: var(--tb-success); }
.tb-reqs li.is-met span { text-decoration: none; }

/* --- Radio cards (pick one of a few options) --- */
.tb-radio-cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.tb-radio-card {
  display: flex; align-items: flex-start; gap: 11px; padding: 13px 15px; cursor: pointer;
  border: 1px solid var(--tb-border); border-radius: var(--tb-r-md); background: var(--tb-surface-2);
  transition: border-color var(--tb-fast), background var(--tb-fast), box-shadow var(--tb-fast);
}
.tb-radio-card:hover { border-color: var(--tb-border-strong); }
.tb-radio-card input {
  margin: 3px 0 0; accent-color: var(--tb-primary); width: 16px; height: 16px; flex-shrink: 0; cursor: pointer;
}
.tb-radio-card:has(input:checked) {
  border-color: var(--tb-primary); background: var(--tb-primary-soft); box-shadow: var(--tb-ring);
}
.tb-radio-body { min-width: 0; }
.tb-radio-title { display: flex; align-items: center; gap: 7px; font-weight: 650; font-size: 13.5px; }
.tb-radio-title i { color: var(--tb-text-subtle); font-size: 14px; }
.tb-radio-card:has(input:checked) .tb-radio-title { color: var(--tb-primary-strong); }
.tb-radio-card:has(input:checked) .tb-radio-title i { color: var(--tb-primary); }
.tb-radio-text { display: block; font-size: 12.5px; color: var(--tb-text-muted); margin-top: 2px; line-height: 1.5; }

/* --- Delivery pace callout (webhook settings) --- */
.tb-pace {
  display: flex; align-items: center; gap: 14px; margin-top: 16px;
  padding: 15px 18px; border-radius: var(--tb-r-md);
  background: var(--tb-gradient-soft); border: 1px solid var(--tb-border);
  flex-wrap: wrap;
}
.tb-pace-icon {
  width: 42px; height: 42px; border-radius: 13px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; font-size: 19px;
  background: var(--tb-gradient); color: #fff; box-shadow: var(--tb-glow);
}
.tb-pace-body { flex: 1; min-width: 160px; }
.tb-pace-headline {
  font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 700; font-size: 15.5px;
  letter-spacing: -.02em; color: var(--tb-text);
}
.tb-pace-sub { font-size: 12.5px; color: var(--tb-text-muted); margin-top: 2px; }
.tb-pace-figure {
  text-align: right; padding-left: 14px; border-left: 1px solid var(--tb-border); flex-shrink: 0;
}
.tb-pace-figure-value {
  display: block; font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 800;
  font-size: 17px; color: var(--tb-primary-strong); letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.tb-pace-figure-label {
  display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  font-weight: 700; color: var(--tb-text-subtle); margin-top: 1px;
}
.tb-pace-warn {
  display: flex; align-items: flex-start; gap: 9px; margin-top: 10px;
  font-size: 12.5px; color: var(--tb-warning); background: var(--tb-warning-soft);
  border-radius: var(--tb-r-sm); padding: 9px 12px;
}
.tb-pace-warn i { flex-shrink: 0; margin-top: 1px; }
@media (max-width: 575.98px) {
  .tb-pace-figure { border-left: none; padding-left: 0; text-align: left; }
}

/* --- Toggle switch (start/stop) --- */
.tb-switch-card {
  display: flex; align-items: center; gap: 16px; padding: 16px 18px; border-radius: var(--tb-r-md);
  background: var(--tb-surface-2); border: 1px solid var(--tb-border); flex-wrap: wrap;
}
.tb-switch-card.is-on { background: var(--tb-success-soft); border-color: transparent; }
.tb-switch-body { flex: 1; min-width: 180px; }
.tb-switch-title { font-weight: 700; font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.tb-switch-text { font-size: 12.5px; color: var(--tb-text-muted); margin-top: 2px; }
.tb-switch-card.is-on .tb-switch-text { color: var(--tb-success); opacity: .9; }

/* --- Code / JSON hint block --- */
.tb-code-hint {
  background: var(--tb-surface-2); border: 1px solid var(--tb-border); border-radius: var(--tb-r-sm);
  padding: 10px 12px; font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 12px; color: var(--tb-text-muted); overflow-x: auto; white-space: pre;
}
.tb-field-tag {
  display: inline-block; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px;
  background: var(--tb-surface-3); border: 1px solid var(--tb-border); border-radius: 6px;
  padding: 1px 6px; margin: 2px 3px 2px 0; color: var(--tb-text-muted);
}

/* --- App footer --- */
.tb-footer {
  display: flex; align-items: center; gap: 10px; padding: 16px 28px;
  border-top: 1px solid var(--tb-border); color: var(--tb-text-subtle);
  font-size: 12.5px; margin-top: auto;
}
.tb-footer-spacer { flex: 1; }
.tb-dot-sep { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .5; flex-shrink: 0; }

/* --- Two-column page split (form + side panel) ---
   Collapses at 1200px rather than 992px: between those widths the side column
   gets too narrow to hold a label/value row on one line. */
.tb-split { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.tb-split-wide { grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); }
@media (max-width: 1199.98px) { .tb-split, .tb-split-wide { grid-template-columns: minmax(0, 1fr); } }

/* --- Sticky side panel --- */
.tb-sticky { position: sticky; top: 90px; }
@media (max-width: 1199.98px) { .tb-sticky { position: static; } }

/* --- Info / tip callout --- */
.tb-note {
  display: flex; gap: 11px; padding: 13px 15px; border-radius: var(--tb-r-md);
  background: var(--tb-gradient-soft); border: 1px solid var(--tb-border);
  font-size: 13px; color: var(--tb-text-muted); line-height: 1.55;
}
.tb-note i { color: var(--tb-primary); font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.tb-note strong { color: var(--tb-text); font-weight: 650; }

/* ---------------------------------------------------------------------------
   8a. Auth / login
   ------------------------------------------------------------------------- */
.tb-auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }

.tb-auth-brand {
  position: relative; overflow: hidden; background: var(--tb-gradient); color: #fff;
  padding: 52px 56px; display: flex; flex-direction: column; justify-content: space-between;
}
.tb-auth-brand::before {
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(720px 420px at 82% 8%, rgba(255, 255, 255, .26), transparent 66%),
    radial-gradient(560px 380px at 6% 96%, rgba(255, 255, 255, .16), transparent 66%);
}
.tb-auth-blob {
  position: absolute; border-radius: 50%; filter: blur(46px); opacity: .5; pointer-events: none;
  animation: tb-float 15s ease-in-out infinite;
}
.tb-auth-blob.b1 { width: 340px; height: 340px; background: #ff9ad5; top: -70px; right: -60px; }
.tb-auth-blob.b2 { width: 300px; height: 300px; background: #52e5ff; bottom: -80px; left: -50px; animation-delay: -5s; }
.tb-auth-blob.b3 { width: 220px; height: 220px; background: #ffd166; top: 46%; right: 22%; animation-delay: -9s; opacity: .34; }
@keyframes tb-float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(24px, -30px) scale(1.08); }
  66% { transform: translate(-20px, 22px) scale(.95); }
}
.tb-auth-brand > *:not(.tb-auth-blob) { position: relative; z-index: 1; }
.tb-auth-logo { display: flex; align-items: center; gap: 12px; }
.tb-auth-logo .tb-logo-badge { background: rgba(255, 255, 255, .2); box-shadow: none; backdrop-filter: blur(6px); }
.tb-auth-logo .tb-brand-name { color: #fff; font-size: 17px; }
.tb-auth-logo .tb-brand-sub { color: rgba(255, 255, 255, .7); }
.tb-auth-headline { font-size: 38px; line-height: 1.12; color: #fff; letter-spacing: -.035em; margin: 0 0 16px; max-width: 15ch; }
.tb-auth-sub { color: rgba(255, 255, 255, .82); font-size: 15.5px; max-width: 46ch; margin: 0 0 30px; }
.tb-auth-features { list-style: none; padding: 0; margin: 0; display: grid; gap: 13px; }
.tb-auth-features li { display: flex; align-items: flex-start; gap: 12px; font-size: 14.5px; color: rgba(255, 255, 255, .93); }
.tb-auth-features i {
  width: 26px; height: 26px; border-radius: 9px; background: rgba(255, 255, 255, .2);
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0;
  backdrop-filter: blur(4px);
}
.tb-auth-foot { font-size: 12.5px; color: rgba(255, 255, 255, .62); }

.tb-auth-panel {
  display: flex; align-items: center; justify-content: center; padding: 40px 28px;
  background: var(--tb-surface); position: relative;
}
.tb-auth-card { width: 100%; max-width: 392px; animation: tb-rise .5s var(--tb-ease) both; }
.tb-auth-card h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: -.03em; }
.tb-auth-card .tb-auth-lead { color: var(--tb-text-muted); font-size: 14.5px; margin: 0 0 28px; }
.tb-auth-mobile-logo { display: none; align-items: center; gap: 11px; margin-bottom: 26px; }
.tb-auth-theme { position: absolute; top: 22px; right: 22px; }
.tb-auth-hint {
  margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--tb-border);
  font-size: 12.5px; color: var(--tb-text-subtle); text-align: center;
}

/* Password reveal button inside input */
.tb-pw-wrap { position: relative; }
.tb-pw-wrap .form-control { padding-right: 44px; }
.tb-pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border: none; background: transparent; color: var(--tb-text-subtle);
  border-radius: var(--tb-r-xs); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.tb-pw-toggle:hover { background: var(--tb-surface-3); color: var(--tb-text); }
.tb-input-icon { position: relative; }
.tb-input-icon > i.tb-lead-icon {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--tb-text-subtle); font-size: 15px; pointer-events: none; transition: color var(--tb-fast);
}
.tb-input-icon:focus-within > i.tb-lead-icon { color: var(--tb-primary); }
.tb-input-icon .form-control { padding-left: 38px; }

/* ---------------------------------------------------------------------------
   8a. Global top-of-page loading bar (auto-driven by assets/js/loader.js)
   ------------------------------------------------------------------------- */
#tbLoaderBar {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 3000;
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
#tbLoaderBar.tb-loader-active { opacity: 1; }
#tbLoaderBar .tb-loader-fill {
  height: 100%; width: 0%; background: var(--tb-gradient);
  box-shadow: var(--tb-glow, 0 0 8px rgba(109, 94, 252, .55));
  transition: width .2s ease;
}

/* Real byte-progress bar shown inside the upload dropzone while a file transfers */
.tb-upload-progress {
  height: 8px; border-radius: var(--tb-r-pill); background: var(--tb-surface-3);
  overflow: hidden; margin-top: 14px;
}
.tb-upload-progress > span {
  display: block; height: 100%; border-radius: var(--tb-r-pill); background: var(--tb-gradient);
  width: 0%; transition: width .15s linear;
}
.tb-upload-progress-label {
  display: flex; justify-content: space-between; font-size: 12.5px; color: var(--tb-text-muted);
  margin-top: 6px;
}

/* ---------------------------------------------------------------------------
   8b. Toasts
   ------------------------------------------------------------------------- */
.tb-toast-container {
  position: fixed; top: 18px; right: 18px; z-index: 2000;
  display: flex; flex-direction: column; gap: 10px; max-width: 380px; pointer-events: none;
}
.tb-toast {
  background: var(--tb-elevated); border: 1px solid var(--tb-border); border-radius: var(--tb-r-md);
  box-shadow: var(--tb-shadow-lg); padding: 13px 15px; display: flex; align-items: flex-start; gap: 11px;
  animation: tb-toast-in .32s var(--tb-ease); font-size: 13.5px; pointer-events: auto;
  position: relative; overflow: hidden;
}
.tb-toast-icon {
  width: 30px; height: 30px; border-radius: 10px; display: inline-flex; align-items: center;
  justify-content: center; font-size: 15px; flex-shrink: 0;
}
.tb-toast-msg { flex: 1; min-width: 0; padding-top: 4px; color: var(--tb-text); }
.tb-toast-close {
  border: none; background: transparent; color: var(--tb-text-subtle); cursor: pointer;
  width: 26px; height: 26px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 14px;
}
.tb-toast-close:hover { background: var(--tb-surface-3); color: var(--tb-text); }
.tb-toast-bar { position: absolute; left: 0; bottom: 0; height: 2.5px; width: 100%; transform-origin: left; }
.tb-toast-success .tb-toast-bar { background: var(--tb-success); }
.tb-toast-danger .tb-toast-bar { background: var(--tb-danger); }
.tb-toast-warning .tb-toast-bar { background: var(--tb-warning); }
.tb-toast-secondary .tb-toast-bar { background: var(--tb-primary); }
.tb-toast-out { animation: tb-toast-out .22s var(--tb-ease) forwards; }
@keyframes tb-toast-in { from { opacity: 0; transform: translateX(28px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes tb-toast-out { to { opacity: 0; transform: translateX(28px) scale(.96); } }
@keyframes tb-toast-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ---------------------------------------------------------------------------
   8c. Responsive
   ------------------------------------------------------------------------- */
/* Between these widths auto-fit lands on three columns and orphans the fourth
   KPI on its own row — a 2x2 block reads better. */
@media (min-width: 992px) and (max-width: 1399.98px) {
  .tb-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1199.98px) {
  .tb-auth { grid-template-columns: 1fr; }
  .tb-auth-brand { display: none; }
  .tb-auth-mobile-logo { display: flex; }
}

@media (max-width: 991.98px) {
  .tb-sidebar { transform: translateX(-100%); box-shadow: none; }
  .tb-nav-open .tb-sidebar { transform: translateX(0); box-shadow: var(--tb-shadow-lg); }
  .tb-rail .tb-sidebar { width: var(--tb-sidebar-w); }
  .tb-main, .tb-rail .tb-main { margin-left: 0; }
  .tb-topbar .tb-menu-btn { display: inline-flex; }
  .tb-rail-toggle { display: none; }
  .tb-content { padding: 18px 16px 40px; }
  .tb-topbar { padding: 11px 16px; }
  .tb-rail .tb-brand-text,
  .tb-rail .tb-nav-label,
  .tb-rail .tb-nav-link span,
  .tb-rail .tb-nav-badge,
  .tb-rail .tb-user-meta,
  .tb-rail .tb-user-caret { display: revert; }
  .tb-rail .tb-nav-link { justify-content: flex-start; padding: 9px 12px; }
  .tb-rail .tb-sidebar-brand { justify-content: flex-start; padding: 18px 18px 16px; }
  .tb-rail .tb-user-btn { justify-content: flex-start; padding: 8px 10px; }
  .tb-rail .tb-nav-link::after { display: none; }
  .tb-rail .tb-nav-group + .tb-nav-group::before { display: none; }
}

@media (max-width: 767.98px) {
  .tb-hero { padding: 24px 20px; border-radius: var(--tb-r-lg); }
  .tb-hero h2 { font-size: 22px; }
  .tb-card { padding: 18px 16px; border-radius: var(--tb-r-md); }
  .tb-card-flush > .tb-card-header { padding: 16px; }
  .tb-table thead th:first-child, .tb-table tbody td:first-child { padding-left: 16px; }
  .tb-table thead th:last-child, .tb-table tbody td:last-child { padding-right: 16px; }
  .tb-search .form-control { min-width: 0; width: 100%; }
  .tb-page-title { font-size: 17px; }
  .tb-kpi-value { font-size: 26px; }
  .tb-toast-container { left: 12px; right: 12px; max-width: none; }

  /* A 14-day chart is tight on a phone: shrink the gaps and thin out the labels. */
  .tb-bars { gap: 5px; height: 140px; }
  .tb-bar-label { font-size: 9.5px; }
  .tb-bar { border-radius: 5px 5px 2px 2px; }
  .tb-dl-val { text-align: left; }
}

@media (max-width: 575.98px) {
  .tb-bars { gap: 3px; }
  .tb-bar-col:nth-child(even) .tb-bar-label { visibility: hidden; }
}

/* ---------------------------------------------------------------------------
   8d. Motion preferences & print
   ------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}

@media print {
  .tb-sidebar, .tb-topbar, .tb-toast-container, .tb-card-tools, .tb-pagebar { display: none !important; }
  .tb-main { margin-left: 0 !important; }
  body { background: #fff; }
  .tb-card { box-shadow: none; border-color: #ddd; break-inside: avoid; }
}
