/* ══════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 8px 16px;
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast),
              transform var(--t-fast), opacity var(--t-fast);
  white-space: nowrap;
  user-select: none;
  position: relative;
  overflow: hidden;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

/* Primary */
.btn-primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
}

/* Secondary */
.btn-secondary {
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border-color: var(--border-default);
}
.btn-secondary:hover { background: var(--bg-surface-3); border-color: var(--border-strong); }

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-surface-2); color: var(--text-primary); }

/* Danger */
.btn-danger {
  background: var(--color-danger-dim);
  color: var(--color-danger);
  border-color: rgba(248, 113, 113, 0.22);
}
.btn-danger:hover { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }

/* Sizes */
.btn-sm { padding: 5px 11px; font-size: var(--text-sm); gap: 5px; }
.btn-sm svg { width: 13px; height: 13px; }

.btn-lg { padding: 11px 22px; font-size: var(--text-base); }

.btn-icon { width: 34px; height: 34px; padding: 0; flex-shrink: 0; border-radius: var(--r-md); }
.btn-icon.btn-sm { width: 28px; height: 28px; }

/* Loading */
.btn.is-loading { pointer-events: none; }
.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 13px; height: 13px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ══════════════════════════════════════════
   BADGES
══════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge svg { width: 10px; height: 10px; }

.badge-active    { background: var(--status-active-dim); color: var(--status-active); border-color: var(--status-active-border); }
.badge-irregular { background: var(--status-irregular-dim); color: var(--status-irregular); border-color: var(--status-irregular-border); }
.badge-inactive  { background: var(--status-inactive-dim); color: var(--status-inactive); border-color: var(--status-inactive-border); }
.badge-archived  { background: var(--status-archived-dim); color: var(--status-archived); border-color: var(--status-archived-border); }
.badge-trusted   { background: var(--status-trusted-dim); color: var(--status-trusted); border-color: var(--color-amber-border); }
.badge-accent    { background: var(--accent-dim); color: var(--accent-hover); border-color: var(--accent-border); }
.badge-default   { background: var(--bg-surface-3); color: var(--text-secondary); border-color: var(--border-subtle); }

/* Status dot */
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.status-dot.active    { background: var(--status-active); }
.status-dot.irregular { background: var(--status-irregular); }
.status-dot.inactive  { background: var(--status-inactive); }
.status-dot.archived  { background: var(--status-archived); }

/* Star badge */
.star-badge { color: var(--status-trusted); display: inline-flex; }
.star-badge svg { width: 13px; height: 13px; }
.star-badge.filled svg { fill: var(--status-trusted); }

/* ══════════════════════════════════════════
   STAT CARDS
══════════════════════════════════════════ */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  padding: var(--sp-5) var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  transition: border-color var(--t-base), transform var(--t-base);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  opacity: 0.8;
}
.stat-card:hover { border-color: var(--border-default); transform: translateY(-1px); }
.stat-card.accent::after  { background: var(--accent); }
.stat-card.success::after { background: var(--status-active); }
.stat-card.danger::after  { background: var(--color-danger); }
.stat-card.warning::after { background: var(--color-warning); }

.stat-card-icon {
  width: 40px; height: 40px;
  border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-card-icon svg { width: 19px; height: 19px; }
.stat-card-icon.accent  { background: var(--accent-dim); color: var(--accent-hover); }
.stat-card-icon.success { background: var(--status-active-dim); color: var(--status-active); }
.stat-card-icon.danger  { background: var(--color-danger-dim); color: var(--color-danger); }
.stat-card-icon.warning { background: var(--color-warning-dim); color: var(--color-warning); }

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

.stat-card-value {
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.04em;
  line-height: 1;
}

.stat-card-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: 500;
}

.stat-card-trend {
  font-size: var(--text-xs);
  font-weight: 600;
  display: flex; align-items: center; gap: 2px;
}
.stat-card-trend.up   { color: var(--status-active); }
.stat-card-trend.down { color: var(--color-danger); }

/* ══════════════════════════════════════════
   PLATFORM BADGES (icon-only, colored SVG)
══════════════════════════════════════════ */
.platform-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  background: transparent;
  flex-shrink: 0;
  overflow: hidden;
}

.platform-badge svg {
  width: 26px;
  height: 26px;
  display: block;
  flex-shrink: 0;
}

.platform-badge.has-label {
  width: auto;
  min-width: 0;
  height: 32px;
  padding: 0 10px 0 6px;
  gap: 8px;
  border-radius: 999px;
  overflow: visible;
  background: transparent;
  border: none;
}

.platform-badge.has-label svg {
  width: 18px;
  height: 18px;
}

.platform-badge.platform-badge-sm {
  height: 30px;
  padding: 0 9px 0 6px;
}

.platform-badge.platform-badge-sm svg {
  width: 16px;
  height: 16px;
}

.platform-badge-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.platform-badge-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}
.platform-badge-label {
  font-size: var(--text-xs);
  line-height: 1;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ══════════════════════════════════════════
   AVATAR
══════════════════════════════════════════ */
.avatar {
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-surface-3);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}
.avatar-sm  { width: 32px; height: 32px; font-size: var(--text-sm); }
.avatar-md  { width: 40px; height: 40px; font-size: var(--text-base); }
.avatar-lg  { width: 52px; height: 52px; font-size: var(--text-lg); }
.avatar-xl  { width: 68px; height: 68px; font-size: var(--text-xl); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ══════════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════════ */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: var(--sp-3);
  padding: var(--sp-16) var(--sp-8);
  text-align: center;
}
.empty-state-icon {
  width: 52px; height: 52px;
  border-radius: var(--r-xl);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}
.empty-state-icon svg { width: 22px; height: 22px; }
.empty-state h3 { font-size: var(--text-base); font-weight: 600; color: var(--text-primary); }
.empty-state p  { font-size: var(--text-sm); color: var(--text-muted); max-width: 320px; }

/* ══════════════════════════════════════════
   LOADING SPINNER
══════════════════════════════════════════ */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner-sm { width: 13px; height: 13px; border-width: 2px; }
.spinner-lg { width: 28px; height: 28px; border-width: 2px; }

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

/* ══════════════════════════════════════════
   PAGINATION
══════════════════════════════════════════ */
.pagination {
  display: flex; align-items: center; gap: 4px;
}
.pagination-btn {
  min-width: 32px; height: 32px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-2);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t-fast);
  padding: 0 var(--sp-2);
  cursor: pointer;
}
.pagination-btn:hover { background: var(--bg-surface-3); color: var(--text-primary); border-color: var(--border-default); }
.pagination-btn.is-active { background: var(--accent); color: #fff; border-color: transparent; }
.pagination-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.pagination-btn svg { width: 13px; height: 13px; }

/* ══════════════════════════════════════════
   CHIPS
══════════════════════════════════════════ */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: var(--text-xs); font-weight: 500;
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}
.chip-remove {
  width: 13px; height: 13px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; cursor: pointer; opacity: 0.6;
  transition: opacity var(--t-fast);
}
.chip-remove:hover { opacity: 1; }
.chip-remove svg { width: 9px; height: 9px; }

/* ══════════════════════════════════════════
   TOAST NOTIFICATIONS
══════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: var(--sp-6); right: var(--sp-6);
  z-index: 9999;
  display: flex; flex-direction: column; gap: var(--sp-2);
  max-width: 360px;
  width: calc(100vw - var(--sp-12));
}

.toast {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  animation: toast-in var(--t-spring) forwards;
}
.toast.is-leaving { animation: toast-out var(--t-base) forwards; }

.toast-icon { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }
.toast-icon svg { width: 14px; height: 14px; }

.toast-content { flex: 1; }
.toast-title   { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); }
.toast-message { font-size: var(--text-xs); color: var(--text-secondary); margin-top: 2px; }

.toast-close { color: var(--text-muted); padding: 2px; border-radius: var(--r-sm); transition: color var(--t-fast); cursor: pointer; }
.toast-close:hover { color: var(--text-primary); }
.toast-close svg { width: 13px; height: 13px; }

.toast.toast-success { border-color: var(--status-active-border); }
.toast.toast-success .toast-icon { color: var(--status-active); }
.toast.toast-error   { border-color: var(--status-inactive-border); }
.toast.toast-error   .toast-icon { color: var(--color-danger); }
.toast.toast-warning { border-color: var(--status-irregular-border); }
.toast.toast-warning .toast-icon { color: var(--color-warning); }
.toast.toast-info    { border-color: var(--accent-border); }
.toast.toast-info    .toast-icon { color: var(--accent-hover); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(16px); }
}

/* ══════════════════════════════════════════
   DROPDOWN
══════════════════════════════════════════ */
.dropdown { position: relative; display: inline-block; }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px); left: 0;
  min-width: 180px;
  background: var(--bg-dropdown);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  padding: 4px;
  z-index: 300;
  opacity: 0;
  transform: translateY(-5px) scale(0.97);
  pointer-events: none;
  transition: opacity var(--t-base), transform var(--t-base);
  transform-origin: top left;
}
.dropdown-menu.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.dropdown-menu.align-right { left: auto; right: 0; transform-origin: top right; }

.dropdown-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 7px var(--sp-3);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.dropdown-item:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.dropdown-item.danger:hover { background: var(--color-danger-dim); color: var(--color-danger); }
.dropdown-item svg { width: 14px; height: 14px; flex-shrink: 0; }
.dropdown-divider { height: 1px; background: var(--border-subtle); margin: 4px 0; }

/* ══════════════════════════════════════════
   POPOVER
══════════════════════════════════════════ */
.popover {
  position: absolute;
  z-index: 400;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--r-xl);
  padding: var(--sp-5);
  min-width: 240px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base), transform var(--t-base);
  transform: translateY(5px);
}
.popover.is-open { opacity: 1; pointer-events: auto; transform: translateY(0); }

/* ══════════════════════════════════════════
   TIMELINE
══════════════════════════════════════════ */
.timeline { display: flex; flex-direction: column; gap: 0; position: relative; }
.timeline::before {
  content: '';
  position: absolute; left: 18px; top: 18px; bottom: 18px;
  width: 1px;
}

.timeline-item {
  display: flex; gap: var(--sp-4); position: relative;
  padding-bottom: var(--sp-5);
}
.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-2); z-index: 1;
}
.timeline-dot svg { width: 15px; height: 15px; }
.timeline-dot.accent  { background: var(--accent-dim); border-color: var(--accent-border); color: var(--accent-hover); }
.timeline-dot.success { background: var(--status-active-dim); border-color: var(--status-active-border); color: var(--status-active); }
.timeline-dot.warning { background: var(--status-irregular-dim); border-color: var(--status-irregular-border); color: var(--status-irregular); }
.timeline-dot.danger  { background: var(--status-inactive-dim); border-color: var(--status-inactive-border); color: var(--status-inactive); }

.timeline-content { flex: 1; padding-top: 7px; }
.timeline-title { font-size: var(--text-base); font-weight: 600; color: var(--text-primary); }
.timeline-desc  { font-size: var(--text-sm); color: var(--text-secondary); margin-top: 3px; line-height: 1.6; }
.timeline-meta  { font-size: var(--text-xs); color: var(--text-muted); margin-top: 5px; }
