/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2); padding: 10px var(--space-4);
  font-size: var(--text-sm); font-weight: 600;
  border-radius: var(--radius-md); transition: all var(--transition);
  cursor: pointer; border: none; white-space: nowrap;
  text-decoration: none; position: relative; overflow: hidden;
  font-family: var(--font-sans); line-height: 1;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--gradient-primary); color: white;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 4px 15px rgba(124,58,237,0.3);
}
.btn-primary:hover { box-shadow: inset 0 1px 0 rgba(255,255,255,0.22), 0 6px 20px rgba(124,58,237,0.5); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:focus-visible {
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 4px 15px rgba(124,58,237,0.3),
              0 0 0 3px var(--focus-ring);
}

.btn-secondary {
  background: transparent; color: var(--accent-violet-light);
  border: 1px solid rgba(124,58,237,0.5);
}
.btn-secondary:hover { background: var(--accent-violet-dim); border-color: var(--accent-violet-light); }

.btn-ghost {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border-hover); }

.btn-danger {
  background: rgba(239,68,68,0.12); color: var(--accent-red);
  border: 1px solid rgba(239,68,68,0.3);
}
.btn-danger:hover { background: rgba(239,68,68,0.22); border-color: var(--accent-red); }

.btn-success {
  background: rgba(16,185,129,0.12); color: var(--accent-green);
  border: 1px solid rgba(16,185,129,0.3);
}
.btn-success:hover { background: rgba(16,185,129,0.22); border-color: var(--accent-green); }

.btn-sm { padding: 6px 12px; font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn-sm svg { width: 13px; height: 13px; }
.btn-lg { padding: 13px var(--space-6); font-size: var(--text-base); border-radius: var(--radius-lg); }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: var(--radius-md); flex-shrink: 0; }
.btn-icon-sm { width: 28px; height: 28px; padding: 0; border-radius: var(--radius-sm); flex-shrink: 0; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-6);
  position: relative; overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition),
              transform var(--transition), background-color 0.25s var(--ease), color 0.25s var(--ease);
}
.card::before {
  content: ''; position: absolute; inset: 0;
  background: var(--gradient-card); pointer-events: none;
  border-radius: inherit; opacity: 0; transition: opacity var(--transition);
}
.card:hover { border-color: var(--border-hover); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card:hover::before { opacity: 1; }
.card-sm { padding: var(--space-4); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-4); gap: var(--space-3);
}
.card-title { font-size: var(--text-base); font-weight: 700; color: var(--text-primary); }
.card-body { position: relative; z-index: 1; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 3px 10px; border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: 600;
  background: var(--bg-elevated); color: var(--text-secondary);
  border: 1px solid var(--border); white-space: nowrap;
}
.badge::before {
  content: ''; width: 6px; height: 6px;
  border-radius: 50%; flex-shrink: 0; background: var(--text-muted);
}
.badge-active, .badge-running {
  background: rgba(16,185,129,0.1); color: var(--accent-green);
  border-color: rgba(16,185,129,0.3);
}
.badge-active::before, .badge-running::before {
  background: var(--accent-green); animation: pulseDot 2s ease infinite;
}
.badge-paused {
  background: rgba(245,158,11,0.1); color: var(--accent-orange);
  border-color: rgba(245,158,11,0.3);
}
.badge-paused::before { background: var(--accent-orange); }
.badge-stopped {
  background: rgba(239,68,68,0.1); color: var(--accent-red);
  border-color: rgba(239,68,68,0.3);
}
.badge-stopped::before { background: var(--accent-red); }
.badge-draft {
  background: rgba(71,85,105,0.15); color: var(--text-muted);
  border-color: var(--border);
}
.badge-draft::before { background: var(--text-muted); }
.badge-completed {
  background: rgba(6,182,212,0.1); color: var(--accent-cyan);
  border-color: rgba(6,182,212,0.3);
}
.badge-completed::before { background: var(--accent-cyan); }

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-group { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.label { font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary); }
.input, .textarea, .select {
  width: 100%; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 10px 14px; color: var(--text-primary);
  font-size: var(--text-sm); font-family: var(--font-sans);
  transition: border-color var(--transition), box-shadow var(--transition),
              background-color 0.25s var(--ease), color 0.25s var(--ease);
  outline: none; -webkit-appearance: none; appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent-violet);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.input:disabled, .textarea:disabled, .select:disabled { opacity: 0.5; cursor: not-allowed; }
.input.error, .textarea.error, .select.error { border-color: var(--accent-red); }
.textarea { resize: vertical; min-height: 100px; line-height: var(--leading-relaxed); }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath stroke='%2394A3B8' stroke-width='1.5' fill='none' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 36px; cursor: pointer;
}
.select option { background: var(--bg-elevated); color: var(--text-primary); }
.error-text { font-size: var(--text-xs); color: var(--accent-red); display: flex; align-items: center; gap: 4px; }
.helper-text { font-size: var(--text-xs); color: var(--text-muted); }

/* Chip Input */
.chip-input-wrapper {
  display: flex; flex-wrap: wrap; gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-md); min-height: 44px;
  align-items: center; cursor: text;
  transition: border-color var(--transition);
}
.chip-input-wrapper:focus-within {
  border-color: var(--accent-violet);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
}
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  background: var(--accent-violet-dim);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: 600; color: var(--accent-violet-light);
}
.chip-remove {
  cursor: pointer; display: flex; align-items: center;
  opacity: 0.7; background: none; border: none; padding: 0; color: inherit; line-height: 1;
}
.chip-remove:hover { opacity: 1; }
.chip-input {
  flex: 1; min-width: 80px; background: transparent;
  border: none; outline: none; color: var(--text-primary);
  font-size: var(--text-sm); font-family: var(--font-sans); padding: 2px 4px;
}

/* ============================================================
   TABLE
   ============================================================ */
.table-wrapper {
  overflow-x: auto; border: 1px solid var(--border);
  border-radius: var(--radius-lg); background: var(--bg-card);
}
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table thead tr { border-bottom: 1px solid var(--border); }
.table th {
  padding: var(--space-3) var(--space-4); text-align: left;
  font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-muted);
  background: var(--bg-elevated); white-space: nowrap;
  cursor: pointer; user-select: none;
}
.table th:hover { color: var(--text-secondary); }
.table th.sorted { color: var(--accent-violet-light); }
.table tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
.table tbody tr:last-child { border-bottom: none; }
.table tbody tr:hover { background: var(--hover-row); }
.table td { padding: var(--space-3) var(--space-4); color: var(--text-secondary); }
.table td:first-child { color: var(--text-primary); font-weight: 500; }
.table-actions { display: flex; gap: var(--space-2); }

/* Score circle */
.score-circle {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--text-xs); font-weight: 700;
}
.score-high   { background: rgba(16,185,129,0.15); color: var(--accent-green); }
.score-medium { background: rgba(245,158,11,0.15); color: var(--accent-orange); }
.score-low    { background: rgba(239,68,68,0.15);  color: var(--accent-red); }

/* Pagination */
.pagination {
  display: flex; align-items: center; justify-content: flex-end;
  gap: var(--space-2); padding: var(--space-4) var(--space-4) var(--space-3);
  border-top: 1px solid var(--border);
}
.pagination-info { font-size: var(--text-xs); color: var(--text-muted); margin-right: auto; }

/* ============================================================
   STAT CARD
   ============================================================ */
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-3);
  position: relative; overflow: hidden;
  transform-style: preserve-3d;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition),
              background-color 0.25s var(--ease), color 0.25s var(--ease);
}
.stat-card:hover { border-color: var(--border-hover); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card::after {
  content: ''; position: absolute; top: -40px; right: -40px;
  width: 120px; height: 120px; border-radius: 50%;
  background: var(--accent-color, var(--accent-violet));
  opacity: 0.04; pointer-events: none;
}
.stat-card-top { display: flex; align-items: flex-start; justify-content: space-between; }
.stat-card-icon {
  width: 44px; height: 44px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-card-icon svg { width: 22px; height: 22px; }
.stat-card-change {
  font-size: var(--text-xs); font-weight: 600;
  display: flex; align-items: center; gap: 3px;
  padding: 3px 8px; border-radius: var(--radius-full);
}
.stat-card-change.positive { color: var(--accent-green); background: rgba(16,185,129,0.1); }
.stat-card-change.negative { color: var(--accent-red);   background: rgba(239,68,68,0.1); }
.stat-card-value { font-size: var(--text-3xl); font-weight: 800; color: var(--text-primary); line-height: 1; }
.stat-card-label { font-size: var(--text-sm); color: var(--text-muted); font-weight: 500; }

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress-bar {
  height: 6px; background: var(--bg-elevated);
  border-radius: var(--radius-full); overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: var(--radius-full);
  background: var(--gradient-primary);
  transition: width 0.6s var(--ease);
  position: relative; overflow: hidden;
}
/* progress shimmer removed — solid fill only (no gradients) */
.progress-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: var(--text-xs); color: var(--text-muted); margin-bottom: var(--space-1);
}

/* ============================================================
   AVATAR
   ============================================================ */
.avatar {
  border-radius: var(--radius-full); background: var(--gradient-primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: white; flex-shrink: 0;
}
.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); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: var(--space-4); animation: fadeIn 0.18s var(--ease);
}
.modal-container {
  background: var(--bg-card); border: 1px solid var(--border-hover);
  border-radius: var(--radius-xl); width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  animation: scaleIn 0.22s var(--ease); box-shadow: var(--shadow-lg);
}
.modal-container.modal-lg { max-width: 720px; }
.modal-container.modal-sm { max-width: 400px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-5) var(--space-6); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg-card); z-index: 1;
}
.modal-title { font-size: var(--text-lg); font-weight: 700; color: var(--text-primary); }
.modal-close {
  width: 30px; height: 30px; display: flex; align-items: center;
  justify-content: center; border-radius: var(--radius-md);
  color: var(--text-muted); cursor: pointer; transition: all var(--transition);
  flex-shrink: 0; border: none; background: transparent;
}
.modal-close:hover { background: var(--bg-elevated); color: var(--text-primary); }
.modal-body { padding: var(--space-6); }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end;
  gap: var(--space-3); padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
}

/* ============================================================
   TOAST
   ============================================================ */
.toast-container {
  position: fixed; bottom: var(--space-6); right: var(--space-6);
  z-index: 2000; display: flex; flex-direction: column; gap: var(--space-3);
  pointer-events: none; max-width: 380px; width: calc(100vw - 48px);
}
.toast {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg); background: var(--bg-elevated);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  pointer-events: all; animation: fadeInUp 0.28s var(--ease);
}
.toast-icon {
  width: 30px; height: 30px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.toast-icon svg { width: 15px; height: 15px; }
.toast-body { flex: 1; min-width: 0; }
.toast-message { font-size: var(--text-sm); font-weight: 500; color: var(--text-primary); }
.toast-close {
  width: 22px; height: 22px; display: flex; align-items: center;
  justify-content: center; border-radius: var(--radius-sm);
  color: var(--text-muted); cursor: pointer; flex-shrink: 0;
  background: transparent; border: none;
}
.toast-close:hover { color: var(--text-primary); background: var(--hover-item); }
.toast-success { border-color: rgba(16,185,129,0.35); }
.toast-success .toast-icon { background: rgba(16,185,129,0.15); color: var(--accent-green); }
.toast-error   { border-color: rgba(239,68,68,0.35); }
.toast-error .toast-icon   { background: rgba(239,68,68,0.15);   color: var(--accent-red); }
.toast-info    { border-color: rgba(6,182,212,0.35); }
.toast-info .toast-icon    { background: rgba(6,182,212,0.15);   color: var(--accent-cyan); }
.toast-warning { border-color: rgba(245,158,11,0.35); }
.toast-warning .toast-icon { background: rgba(245,158,11,0.15);  color: var(--accent-orange); }

/* ============================================================
   SKELETON
   ============================================================ */
.skeleton {
  background: var(--skeleton-highlight);
  animation: pulse 1.4s ease-in-out infinite;
  border-radius: var(--radius-md);
}
.skeleton-text { height: 14px; border-radius: var(--radius-sm); margin-bottom: var(--space-2); }
.skeleton-text.w-80 { width: 80%; }
.skeleton-text.w-60 { width: 60%; }
.skeleton-text.w-40 { width: 40%; }
.skeleton-card { height: 140px; border-radius: var(--radius-lg); }
.skeleton-avatar { border-radius: var(--radius-full); }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: var(--space-16) var(--space-8); gap: var(--space-4);
}
.empty-state-icon {
  width: 72px; height: 72px; border-radius: var(--radius-xl);
  background: var(--bg-elevated); display: flex; align-items: center;
  justify-content: center; border: 1px solid var(--border); margin-bottom: var(--space-2);
}
.empty-state-icon svg { width: 32px; height: 32px; color: var(--text-muted); }
.empty-state-title { font-size: var(--text-xl); font-weight: 700; color: var(--text-primary); }
.empty-state-description {
  font-size: var(--text-sm); color: var(--text-muted);
  max-width: 320px; line-height: var(--leading-relaxed); margin: 0;
}

/* ============================================================
   LIVE DOT
   ============================================================ */
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-green); display: inline-block; flex-shrink: 0;
  animation: pulseDot 2s ease infinite;
}
.live-dot.offline { background: var(--text-muted); animation: none; }
.live-dot.warning { background: var(--accent-orange); }

/* Connection status */
.connection-status {
  display: flex; align-items: center; gap: var(--space-2);
  padding: 5px 12px; border-radius: var(--radius-full);
  background: var(--bg-elevated); border: 1px solid var(--border);
  font-size: var(--text-xs); font-weight: 600; color: var(--text-muted);
}
.connection-status.connected { border-color: rgba(16,185,129,0.3); color: var(--accent-green); }

/* ============================================================
   DROPDOWN
   ============================================================ */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 180px; background: var(--bg-elevated);
  border: 1px solid var(--border-hover); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); z-index: 200;
  animation: slideDown 0.15s var(--ease); overflow: hidden;
}
.dropdown-menu.left { right: auto; left: 0; }
.dropdown-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 10px var(--space-4); font-size: var(--text-sm);
  color: var(--text-secondary); cursor: pointer;
  transition: all var(--transition);
}
.dropdown-item:hover { background: var(--hover-item); color: var(--text-primary); }
.dropdown-item.danger { color: var(--accent-red); }
.dropdown-item.danger:hover { background: rgba(239,68,68,0.1); }
.dropdown-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.dropdown-divider { height: 1px; background: var(--border); margin: var(--space-1) 0; }

/* ============================================================
   TABS
   ============================================================ */
.tabs {
  display: flex; gap: 2px; background: var(--bg-elevated);
  border-radius: var(--radius-lg); padding: 4px;
  border: 1px solid var(--border); overflow-x: auto; flex-shrink: 0;
}
.tab {
  padding: 7px 16px; font-size: var(--text-sm); font-weight: 600;
  color: var(--text-muted); border-radius: var(--radius-md);
  cursor: pointer; transition: all var(--transition); white-space: nowrap;
  border: none; background: transparent; font-family: var(--font-sans);
}
.tab:hover { color: var(--text-secondary); }
.tab.active { background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow-sm); }

/* Theme toggle (topbar) */
.theme-toggle {
  width: 40px; height: 40px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-secondary); border-radius: var(--radius-md);
}
.theme-toggle:hover { color: var(--accent-violet-light); }
.theme-toggle svg { width: 18px; height: 18px; }

/* Topbar user */
.topbar-user { position: relative; }
.user-avatar-sm {
  width: 34px; height: 34px; border-radius: var(--radius-full);
  background: var(--gradient-primary); display: flex; align-items: center;
  justify-content: center; font-size: var(--text-xs); font-weight: 700;
  color: white; cursor: pointer; transition: all var(--transition);
}
.user-avatar-sm:hover { transform: scale(1.06); box-shadow: var(--shadow-glow); }

/* ============================================================
   MISC UTILS
   ============================================================ */
.divider { height: 1px; background: var(--border); margin: var(--space-4) 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.relative { position: relative; }
.overflow-hidden { overflow: hidden; }
.cursor-pointer { cursor: pointer; }
.select-none { user-select: none; }
.opacity-50 { opacity: 0.5; }

/* Inline alert banners */
.alert {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-4); border-radius: var(--radius-md); font-size: var(--text-sm);
  border: 1px solid;
}
.alert-error   { background: rgba(239,68,68,0.08);   border-color: rgba(239,68,68,0.25);   color: var(--red-soft); }
.alert-success { background: rgba(16,185,129,0.08);  border-color: rgba(16,185,129,0.25);  color: var(--green-soft); }
.alert-info    { background: rgba(6,182,212,0.08);   border-color: rgba(6,182,212,0.25);   color: var(--cyan-soft); }
.alert-warning { background: rgba(245,158,11,0.08);  border-color: rgba(245,158,11,0.25);  color: var(--orange-soft); }

/* Admin panel field: stacked label + input */
.admin-field { display: flex; flex-direction: column; gap: 4px; }
.admin-field > span {
  font-size: var(--text-xs); font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.04em;
}

/* Print rules — used by the invoice page's "Print / Save as PDF" */
@media print {
  .sidebar, .topbar, .toast-container, .no-print, .overlay { display: none !important; }
  .main-content { margin: 0 !important; }
  .page-content { padding: 0 !important; }
  .app-shell { display: block !important; }
  body { background: #fff !important; }
  .invoice-doc {
    border: none !important; box-shadow: none !important;
    background: #fff !important; color: #111 !important;
  }
  .invoice-doc .text-secondary { color: #555 !important; }
  .invoice-doc .table th, .invoice-doc .table td { color: #111 !important; border-color: #ddd !important; }
  .invoice-doc .badge-green { background: #e7f7ef !important; color: #067647 !important; }
}
