/* ========================================================================
   Components Library v2 - Enhanced
   ======================================================================== */

/* ---------- BUTTONS (5 variants base + 4 special) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  line-height: 1.25;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(0.5px); }

/* Sizes */
.btn-sm  { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); border-radius: var(--radius-md); }
.btn-lg  { padding: var(--space-3) var(--space-6); font-size: var(--text-base); }
.btn-xl  { padding: var(--space-4) var(--space-8); font-size: var(--text-base); }

/* Standard variants */
.btn-primary {
  background: var(--color-brand-600);
  color: white;
  box-shadow: var(--shadow-xs);
}
.btn-primary:hover:not(:disabled) { background: var(--color-brand-700); box-shadow: var(--shadow-sm); }

.btn-secondary {
  background: white;
  color: var(--color-gray-700);
  border-color: var(--color-border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--color-gray-50);
  border-color: var(--color-border-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--color-gray-700);
}
.btn-ghost:hover:not(:disabled) { background: var(--color-gray-100); }

.btn-danger {
  background: var(--color-danger-600);
  color: white;
}
.btn-danger:hover:not(:disabled) { background: var(--color-danger-700); }

.btn-success {
  background: var(--color-success-600);
  color: white;
}
.btn-success:hover:not(:disabled) { background: var(--color-success-700); }

/* === ENHANCED VARIANTS === */
/* Gradient with shine effect */
.btn-gradient {
  background: var(--gradient-brand);
  color: white;
  box-shadow: var(--shadow-md), 0 0 0 1px rgb(255 255 255 / 0.1) inset;
}
.btn-gradient:hover:not(:disabled) {
  box-shadow: var(--shadow-lg), 0 0 24px rgb(59 130 246 / 0.3), 0 0 0 1px rgb(255 255 255 / 0.15) inset;
  transform: translateY(-1px);
}
.btn-gradient::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}
.btn-gradient:hover::before { left: 100%; }

/* Outlined with brand */
.btn-outline {
  background: white;
  color: var(--color-brand-600);
  border-color: var(--color-brand-600);
}
.btn-outline:hover:not(:disabled) {
  background: var(--color-brand-50);
}

/* Soft - pastel filled */
.btn-soft {
  background: var(--color-brand-100);
  color: var(--color-brand-700);
}
.btn-soft:hover:not(:disabled) {
  background: var(--color-brand-200);
}

.btn-soft-success { background: var(--color-success-100); color: var(--color-success-700); }
.btn-soft-success:hover:not(:disabled) { background: var(--color-success-50); }
.btn-soft-danger { background: var(--color-danger-100); color: var(--color-danger-700); }
.btn-soft-danger:hover:not(:disabled) { background: var(--color-danger-50); }
.btn-soft-warning { background: var(--color-warning-100); color: var(--color-warning-700); }

/* Icon button */
.btn-icon { width: 36px; height: 36px; padding: 0; }
.btn-icon.btn-sm { width: 28px; height: 28px; }
.btn-icon.btn-lg { width: 44px; height: 44px; }

/* Loading state */
.btn-loading {
  pointer-events: none;
  color: transparent !important;
}
.btn-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%; left: 50%;
  margin: -8px 0 0 -8px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  color: white;
}
.btn-secondary.btn-loading::after,
.btn-ghost.btn-loading::after { color: var(--color-gray-700); }

/* ---------- INPUTS ---------- */
.input {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  line-height: 1.25;
  color: var(--color-text);
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: all var(--transition-fast);
}

.input::placeholder { color: var(--color-text-subtle); }
.input:hover:not(:disabled):not(:focus) { border-color: var(--color-border-hover); }
.input:focus {
  outline: none;
  border-color: var(--color-brand-500);
  box-shadow: var(--shadow-focus);
}
.input:disabled { background: var(--color-gray-50); cursor: not-allowed; }

.input-lg { padding: var(--space-3) var(--space-4); font-size: var(--text-base); }
.input-sm { padding: var(--space-1) var(--space-2); font-size: var(--text-xs); }

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group .input-icon {
  position: absolute;
  left: var(--space-3);
  color: var(--color-text-subtle);
  pointer-events: none;
  display: flex;
}

.input-group .input { padding-left: 38px; }
.input-group .input-icon-right { left: auto; right: var(--space-3); pointer-events: auto; }

/* Form */
.form-field { display: flex; flex-direction: column; gap: var(--space-2); }
.form-label {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-hint { font-size: var(--text-xs); color: var(--color-text-subtle); }
.form-error { font-size: var(--text-xs); color: var(--color-danger-600); }

/* ---------- CARDS ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: all var(--transition-base);
}

.card-elevated { border: none; box-shadow: var(--shadow-md); }
.card-hover:hover {
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* Glass card (frosted) */
.card-glass {
  background: rgb(255 255 255 / 0.7);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgb(255 255 255 / 0.4);
  box-shadow: var(--shadow-lg);
}

/* Gradient bordered card */
.card-gradient-border {
  position: relative;
  background: white;
  border: none;
}
.card-gradient-border::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  background: var(--gradient-brand);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

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

.card-title { font-size: var(--text-base); font-weight: var(--font-semibold); }
.card-body { padding: var(--space-6); }
.card-body-tight { padding: var(--space-4); }
.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  background: var(--color-gray-50);
}

/* ---------- BADGES ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  line-height: 1.25;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
}

.badge-success { background: var(--color-success-50); color: var(--color-success-700); border-color: rgb(34 197 94 / 0.2); }
.badge-warning { background: var(--color-warning-50); color: var(--color-warning-700); border-color: rgb(245 158 11 / 0.2); }
.badge-danger  { background: var(--color-danger-50);  color: var(--color-danger-700);  border-color: rgb(239 68 68 / 0.2); }
.badge-info    { background: var(--color-brand-50);   color: var(--color-brand-700);   border-color: rgb(59 130 246 / 0.2); }
.badge-accent  { background: var(--color-accent-50);  color: var(--color-accent-700);  border-color: rgb(139 92 246 / 0.2); }
.badge-neutral { background: var(--color-gray-100);   color: var(--color-gray-700);    border-color: var(--color-gray-200); }

.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
}

/* Live/animated badge with ping */
.badge-live {
  position: relative;
}
.badge-live::before {
  animation: pingDot 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
  background: currentColor;
}
.badge-live::after {
  content: '';
  position: absolute;
  left: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
}

/* Solid badge variants */
.badge-solid-success { background: var(--color-success-600); color: white; }
.badge-solid-danger { background: var(--color-danger-600); color: white; }
.badge-solid-warning { background: var(--color-warning-600); color: white; }
.badge-solid-brand { background: var(--color-brand-600); color: white; }

/* Gradient badge */
.badge-gradient {
  background: var(--gradient-brand);
  color: white;
  border: none;
}

/* ---------- AVATAR ---------- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--color-brand-100);
  color: var(--color-brand-700);
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  overflow: hidden;
  flex-shrink: 0;
  user-select: none;
  position: relative;
}

.avatar-sm { width: 28px; height: 28px; font-size: var(--text-xs); }
.avatar-md { width: 36px; height: 36px; font-size: var(--text-sm); }
.avatar-lg { width: 44px; height: 44px; font-size: var(--text-base); }
.avatar-xl { width: 64px; height: 64px; font-size: var(--text-lg); }
.avatar-2xl { width: 96px; height: 96px; font-size: var(--text-2xl); }

/* Avatar with status indicator */
.avatar-status::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 30%;
  height: 30%;
  background: var(--color-success-500);
  border: 2px solid white;
  border-radius: var(--radius-full);
}
.avatar-status-busy::after { background: var(--color-warning-500); }
.avatar-status-offline::after { background: var(--color-gray-400); }

/* Avatar group (overlapping) */
.avatar-group {
  display: inline-flex;
}
.avatar-group .avatar {
  border: 2px solid white;
  margin-left: -8px;
}
.avatar-group .avatar:first-child { margin-left: 0; }

/* Gradient avatar */
.avatar-gradient {
  background: var(--gradient-brand);
  color: white;
}

/* ---------- TABLES ---------- */
.table-wrapper {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: white;
}

.table { width: 100%; font-size: var(--text-sm); }

.table thead th {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
  background: var(--color-gray-50);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.table tbody td {
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--transition-fast); }
.table tbody tr:hover { background: var(--color-gray-50); }
.table-clickable tbody tr { cursor: pointer; }
.table-compact thead th, .table-compact tbody td { padding: var(--space-2) var(--space-3); }

/* ---------- TABS ---------- */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--color-border);
  padding: 0 var(--space-2);
}

.tab {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.tab:hover { color: var(--color-text); }
.tab.active {
  color: var(--color-brand-600);
  border-bottom-color: var(--color-brand-600);
}

.tab-count {
  background: var(--color-gray-100);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  padding: 0 6px;
  border-radius: var(--radius-full);
  font-weight: var(--font-medium);
}
.tab.active .tab-count {
  background: var(--color-brand-100);
  color: var(--color-brand-700);
}

/* ---------- SEGMENTED CONTROL (iOS-style) ---------- */
.segmented {
  display: inline-flex;
  background: var(--color-gray-100);
  border-radius: var(--radius-lg);
  padding: 3px;
  gap: 2px;
}

.segmented-item {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-muted);
  border-radius: calc(var(--radius-lg) - 3px);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.segmented-item:hover { color: var(--color-text); }
.segmented-item.active {
  background: white;
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

/* ---------- TOGGLE / SWITCH ---------- */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--color-gray-300);
  border-radius: var(--radius-full);
  transition: background var(--transition-fast);
}

.switch-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  top: 2px;
  background: white;
  border-radius: var(--radius-full);
  transition: transform var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.switch input:checked + .switch-slider { background: var(--color-brand-600); }
.switch input:checked + .switch-slider::before { transform: translateX(16px); }

/* ---------- ALERTS ---------- */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid;
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  font-size: var(--text-sm);
}

.alert-icon { flex-shrink: 0; margin-top: 2px; }

.alert-info     { background: var(--color-brand-50);   border-color: rgb(59 130 246 / 0.2); color: var(--color-brand-900); }
.alert-success  { background: var(--color-success-50); border-color: rgb(34 197 94 / 0.2); color: var(--color-success-700); }
.alert-warning  { background: var(--color-warning-50); border-color: rgb(245 158 11 / 0.25); color: var(--color-warning-700); }
.alert-danger   { background: var(--color-danger-50);  border-color: rgb(239 68 68 / 0.25); color: var(--color-danger-700); }

/* ---------- DIVIDER ---------- */
.divider {
  height: 1px;
  background: var(--color-border);
  border: none;
  margin: var(--space-4) 0;
}

.divider-label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-4) 0;
  color: var(--color-text-subtle);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.divider-label::before, .divider-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* ---------- DROPDOWN ---------- */
.dropdown { position: relative; }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 180px;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-1);
  z-index: var(--z-dropdown);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all var(--transition-fast);
}

.dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text);
  border-radius: var(--radius-md);
  text-align: left;
  transition: background var(--transition-fast);
}

.dropdown-item:hover { background: var(--color-gray-100); }
.dropdown-divider { height: 1px; background: var(--color-border); margin: var(--space-1) 0; }

/* ---------- MODAL ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgb(15 23 42 / 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--space-4);
  animation: fadeIn var(--transition-base);
}

.modal {
  background: white;
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-2xl);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: scaleIn var(--transition-base);
}

.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }

.modal-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: var(--text-lg); font-weight: var(--font-semibold); }
.modal-body { padding: var(--space-6); }
.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  background: var(--color-gray-50);
}

/* ---------- TOAST ---------- */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 400px;
}

.toast {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 280px;
  animation: slideInRight var(--transition-base);
}

.toast-success { border-left: 3px solid var(--color-success-500); }
.toast-danger  { border-left: 3px solid var(--color-danger-500); }
.toast-warning { border-left: 3px solid var(--color-warning-500); }
.toast-info    { border-left: 3px solid var(--color-brand-500); }

/* ---------- PROGRESS BAR ---------- */
.progress {
  height: 6px;
  background: var(--color-gray-100);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  background: var(--color-brand-600);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
  position: relative;
}

.progress-bar-success { background: var(--color-success-500); }
.progress-bar-warning { background: var(--color-warning-500); }
.progress-bar-danger  { background: var(--color-danger-500); }
.progress-bar-gradient { background: var(--gradient-brand); }

/* Animated stripes */
.progress-bar-striped {
  background-image: linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%);
  background-size: 16px 16px;
  animation: stripeMove 1s linear infinite;
}
@keyframes stripeMove { from { background-position: 0 0; } to { background-position: 16px 0; } }

/* Indeterminate progress */
.progress-indeterminate .progress-bar {
  width: 30% !important;
  animation: indeterminate 1.5s ease-in-out infinite;
}
@keyframes indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

/* Circular progress */
.progress-ring {
  width: 80px;
  height: 80px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.progress-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-ring-track { stroke: var(--color-gray-100); fill: none; }
.progress-ring-fill { stroke: var(--color-brand-600); fill: none; stroke-linecap: round; transition: stroke-dashoffset 1s; }

.progress-ring-text {
  position: absolute;
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--color-text);
}

/* ---------- EMPTY STATE ---------- */
.empty-state {
  padding: var(--space-12) var(--space-6);
  text-align: center;
  color: var(--color-text-subtle);
}

.empty-state-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--space-4);
  color: var(--color-gray-300);
  background: var(--color-gray-100);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state-title { font-size: var(--text-base); font-weight: var(--font-medium); color: var(--color-text); margin-bottom: var(--space-1); }

/* ---------- KBD ---------- */
.kbd {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--color-gray-100);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  box-shadow: 0 1px 0 var(--color-border);
}

/* ---------- TIMELINE ---------- */
.timeline {
  position: relative;
  padding-left: var(--space-8);
}

.timeline::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--color-border);
}

.timeline-item {
  position: relative;
  padding-bottom: var(--space-5);
}

.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
  position: absolute;
  left: -25px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full);
  background: var(--color-brand-500);
  border: 3px solid white;
  box-shadow: 0 0 0 1px var(--color-border);
}

.timeline-dot-success { background: var(--color-success-500); }
.timeline-dot-warning { background: var(--color-warning-500); }
.timeline-dot-danger { background: var(--color-danger-500); }

.timeline-time {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  font-family: var(--font-mono);
  margin-bottom: 2px;
}

.timeline-title {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text);
  margin-bottom: 2px;
}

.timeline-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ---------- SKELETON LOADER ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--color-gray-100) 0%, var(--color-gray-200) 50%, var(--color-gray-100) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 12px;
  border-radius: var(--radius-sm);
}

.skeleton-circle {
  border-radius: var(--radius-full);
}

/* ---------- TOOLTIP (CSS-only) ---------- */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-gray-900);
  color: white;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  border-radius: var(--radius-md);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  pointer-events: none;
  z-index: var(--z-dropdown);
}

.tooltip::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--color-gray-900);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  pointer-events: none;
}

.tooltip:hover::after, .tooltip:hover::before {
  opacity: 1;
  visibility: visible;
}

/* ---------- STAT CARDS ---------- */
.stat-card {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
}

.stat-card:hover {
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card-label {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.stat-card-value {
  font-size: var(--text-3xl);
  font-weight: var(--font-semibold);
  color: var(--color-text);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.stat-card-meta {
  margin-top: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
}

.stat-trend-up   { color: var(--color-success-600); display: inline-flex; align-items: center; gap: 2px; }
.stat-trend-down { color: var(--color-danger-600); display: inline-flex; align-items: center; gap: 2px; }

.stat-card-icon {
  position: absolute;
  top: var(--space-5);
  right: var(--space-5);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-brand-50);
  color: var(--color-brand-600);
}

/* ENHANCED stat cards */
.stat-card-gradient {
  background: var(--gradient-brand);
  color: white;
  border: none;
  position: relative;
}

.stat-card-gradient::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 50%);
  pointer-events: none;
}

.stat-card-gradient .stat-card-label,
.stat-card-gradient .stat-card-value { color: white; }
.stat-card-gradient .stat-card-label { color: rgba(255,255,255,0.8); }
.stat-card-gradient .stat-card-icon {
  background: rgba(255,255,255,0.2);
  color: white;
  backdrop-filter: blur(10px);
}

.stat-card-mini {
  padding: var(--space-4);
}
.stat-card-mini .stat-card-value { font-size: var(--text-xl); }

/* Sparkline area in stat card */
.stat-sparkline {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50px;
  pointer-events: none;
  opacity: 0.6;
}

/* ---------- CHIP / TAG (different from badge: removable, interactive) ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  background: var(--color-gray-100);
  color: var(--color-gray-700);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  border-radius: var(--radius-full);
  transition: background var(--transition-fast);
}

.chip:hover { background: var(--color-gray-200); }

.chip-active {
  background: var(--color-brand-100);
  color: var(--color-brand-700);
}

.chip-remove {
  width: 14px;
  height: 14px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-left: 2px;
}
.chip-remove:hover { background: rgb(0 0 0 / 0.1); }

/* ---------- METRIC ROW (for compact lists) ---------- */
.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}

.metric-row:last-child { border-bottom: none; }

.metric-row-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.metric-row-value {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  font-family: var(--font-mono);
}

/* ---------- LIST ITEM (rich rows) ---------- */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  transition: background var(--transition-fast);
  cursor: pointer;
}

.list-item:hover { background: var(--color-gray-50); }

.list-item-content {
  flex: 1;
  min-width: 0;
}

.list-item-title {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text);
  margin-bottom: 1px;
}

.list-item-subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
}

.list-item-meta {
  text-align: right;
  flex-shrink: 0;
}

/* ---------- SOFT DIVIDER PATTERN ---------- */
.bg-grid {
  background-image:
    linear-gradient(to right, var(--color-gray-100) 1px, transparent 1px),
    linear-gradient(to bottom, var(--color-gray-100) 1px, transparent 1px);
  background-size: 24px 24px;
}

.bg-dots {
  background-image: radial-gradient(circle, var(--color-gray-200) 1px, transparent 1px);
  background-size: 16px 16px;
}

.bg-mesh {
  background-image: var(--gradient-mesh-1);
}

/* ---------- CARD WITH ACCENT STRIPE ---------- */
.card-accent {
  position: relative;
  padding-left: calc(var(--space-6) + 4px);
}

.card-accent::before {
  content: '';
  position: absolute;
  left: 0;
  top: var(--space-4);
  bottom: var(--space-4);
  width: 4px;
  border-radius: var(--radius-full);
  background: var(--color-brand-500);
}

.card-accent-success::before { background: var(--color-success-500); }
.card-accent-danger::before { background: var(--color-danger-500); }
.card-accent-warning::before { background: var(--color-warning-500); }

/* ---------- LOADING SPINNER ---------- */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-gray-200);
  border-top-color: var(--color-brand-600);
  border-radius: var(--radius-full);
  animation: spin 0.7s linear infinite;
}

.spinner-sm { width: 14px; height: 14px; border-width: 1.5px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

/* ---------- TAB CONTENT TRANSITIONS ---------- */
.tab-content {
  display: none;
  animation: tabFadeIn 0.25s ease;
}

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

@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
