/* CARD */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-tight { padding: 16px; }
.card-compact { padding: 14px 18px; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-header h2, .card-header h3 { font-size: 15px; font-weight: 600; }
.card-header .link-btn { color: var(--brand-primary); font-size: 13px; font-weight: 500; cursor: pointer; }
.card-header .link-btn:hover { color: var(--brand-primary-hover); }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-hover) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
}
.btn-primary:hover { background: var(--brand-primary-hover); box-shadow: 0 6px 16px rgba(139, 92, 246, 0.35); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--brand-primary); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-card); color: var(--text-primary); }

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

.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-lg { padding: 11px 22px; font-size: 14px; }
.btn-icon { padding: 9px; width: 38px; height: 38px; }

.btn .icon { width: 16px; height: 16px; }

/* BADGE */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
}
.badge-success { background: var(--status-success-bg); color: var(--status-success-text); }
.badge-warning { background: var(--status-warning-bg); color: var(--status-warning-text); }
.badge-danger  { background: var(--status-danger-bg);  color: var(--status-danger-text); }
.badge-info    { background: var(--status-info-bg);    color: var(--status-info-text); }
.badge-purple  { background: var(--status-purple-bg);  color: var(--status-purple-text); }
.badge-pink    { background: var(--status-pink-bg);    color: var(--status-pink-text); }
.badge-neutral { background: var(--bg-card-strong); color: var(--text-muted); }

.badge-dot::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* KPI CARD */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.kpi-card .kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-card .kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-card .kpi-icon.purple { background: var(--brand-primary-bg); color: var(--brand-primary); }
.kpi-card .kpi-icon.teal   { background: var(--brand-teal-soft); color: var(--brand-teal); }
.kpi-card .kpi-icon.success{ background: var(--status-success-bg); color: var(--status-success-text); }
.kpi-card .kpi-icon.warning{ background: var(--status-warning-bg); color: var(--status-warning-text); }
.kpi-card .kpi-icon.danger { background: var(--status-danger-bg); color: var(--status-danger-text); }
.kpi-card .kpi-icon.info   { background: var(--status-info-bg); color: var(--status-info-text); }
.kpi-card .kpi-icon.pink   { background: var(--status-pink-bg); color: var(--status-pink-text); }

.kpi-card .kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-card .kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.kpi-card .kpi-change {
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.kpi-card .kpi-change.up { color: var(--status-success-text); }
.kpi-card .kpi-change.down { color: var(--status-danger-text); }

/* TABLE */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: visible;
  position: relative;
}
.table-wrap .table { border-collapse: separate; border-spacing: 0; }
.table-wrap thead th:first-child { border-top-left-radius: var(--radius-lg); }
.table-wrap thead th:last-child { border-top-right-radius: var(--radius-lg); }

.row-actions { position: relative; }
.row-actions .dropdown-menu { z-index: 60; min-width: 180px; }
.table tbody tr:nth-last-child(-n+3) .row-actions .dropdown-menu {
  top: auto;
  bottom: calc(100% + 6px);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  text-align: left;
  padding: 12px 16px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-primary);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: var(--transition-fast); }
.table tbody tr:hover { background: var(--bg-card-hover); }
.table .row-checkbox { width: 32px; }

/* TABLE PAGINATION */
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-muted);
}
.pagination-pages { display: flex; gap: 4px; }
.pagination-pages .page-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 12.5px;
  background: transparent;
  border: 1px solid transparent;
}
.pagination-pages .page-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}
.pagination-pages .page-btn.active {
  background: var(--brand-primary);
  color: white;
  border-color: var(--brand-primary);
}

/* FORM */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
}
.form-input, .form-select, .form-textarea {
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  font-size: 13.5px;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition-fast);
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-glow-purple);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-faint); }
.form-textarea { min-height: 90px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

.search-input-wrap {
  position: relative;
  flex: 1;
  max-width: 360px;
}
.search-input-wrap input {
  width: 100%;
  padding: 9px 12px 9px 38px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: var(--transition-fast);
}
.search-input-wrap input:focus { border-color: var(--brand-primary); box-shadow: var(--shadow-glow-purple); }
.search-input-wrap .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted);
  width: 16px; height: 16px;
}

/* TABS */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
  overflow-x: auto;
}
.tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-fast);
  background: transparent;
}
.tab:hover { color: var(--text-primary); }
.tab.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
  font-weight: 600;
}

/* PILL TABS */
.pill-tabs {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 2px;
}
.pill-tabs .tab {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border-bottom: none;
  margin: 0;
}
.pill-tabs .tab.active {
  background: var(--brand-primary-bg);
  color: var(--brand-primary);
  box-shadow: var(--shadow-sm);
  border-bottom: none;
}

/* AVATAR */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8B5CF6 0%, #6D28D9 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 12.5px;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 56px; height: 56px; font-size: 18px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.avatar.color-2 { background: linear-gradient(135deg, #06B6D4 0%, #0891B2 100%); }
.avatar.color-3 { background: linear-gradient(135deg, #10B981 0%, #047857 100%); }
.avatar.color-4 { background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%); }
.avatar.color-5 { background: linear-gradient(135deg, #EC4899 0%, #BE185D 100%); }

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-row .name { font-weight: 500; color: var(--text-primary); font-size: 13px; }
.user-row .meta { font-size: 11.5px; color: var(--text-muted); }

/* TOAST */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px 14px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  pointer-events: auto;
  animation: toastIn 0.32s cubic-bezier(.4,1.4,.6,1);
}
.toast.toast-out { animation: toastOut 0.28s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px) scale(.96); } }
.toast .toast-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.toast.success .toast-icon { background: var(--status-success-bg); color: var(--status-success-text); }
.toast.error .toast-icon   { background: var(--status-danger-bg); color: var(--status-danger-text); }
.toast.info .toast-icon    { background: var(--brand-primary-bg); color: var(--brand-primary); }
.toast .toast-title { font-weight: 600; font-size: 13.5px; color: var(--text-primary); }
.toast .toast-desc { font-size: 12.5px; color: var(--text-muted); }

/* DROPDOWN */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  padding: 6px;
  z-index: 50;
  display: none;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-item {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
}
.dropdown-item:hover { background: var(--bg-card-hover); }
.dropdown-item.danger { color: var(--status-danger-text); }
.dropdown-divider { height: 1px; background: var(--border-soft); margin: 4px 0; }

/* MODAL */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: min(560px, 90vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h2 { font-size: 16px; }
.modal-body { padding: 22px; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-soft);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* CHIP */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  color: var(--text-secondary);
  background: var(--bg-card);
  cursor: pointer;
  transition: var(--transition-fast);
}
.chip:hover { background: var(--bg-card-hover); }
.chip.active {
  background: var(--brand-primary-bg);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  font-weight: 500;
}

/* PROGRESS */
.progress {
  height: 6px;
  background: var(--bg-card-strong);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-primary) 0%, var(--brand-primary-hover) 100%);
  border-radius: var(--radius-pill);
}
.progress-bar.warning { background: var(--status-warning); }
.progress-bar.danger { background: var(--status-danger); }

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

/* EMPTY STATE */
.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty .icon { width: 48px; height: 48px; margin: 0 auto 14px; opacity: 0.4; }
.empty .title { font-size: 15px; color: var(--text-primary); font-weight: 600; margin-bottom: 6px; }
.empty .desc { font-size: 13px; }

/* LOADING SKELETON */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 0%, var(--bg-card-hover) 50%, var(--bg-card) 100%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* TOGGLE SWITCH */
.toggle {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-card-strong);
  transition: var(--transition-fast);
  border-radius: var(--radius-pill);
}
.toggle .slider::before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: white;
  transition: var(--transition-fast);
  border-radius: 50%;
}
.toggle input:checked + .slider { background: var(--brand-primary); }
.toggle input:checked + .slider::before { transform: translateX(16px); }
