/* ============================================================
   NOWFit CRM — Design System CSS
   Dark SaaS dashboard  |  Inter font  |  Orange accent
   Ported from NOWFit HQ + CRM-specific extensions
   ============================================================ */

/* ─────────────────────────────────────────
   1. DESIGN TOKENS
────────────────────────────────────────── */
:root {
  /* Brand Colors */
  --orange: #EA8D5C;
  --orange-dark: #D25818;
  --orange-light: #F2A97E;
  --orange-glow: rgba(234, 141, 92, 0.15);
  --orange-glow-strong: rgba(234, 141, 92, 0.3);
  --gradient: linear-gradient(135deg, #EA8D5C, #D25818);
  --gradient-text: linear-gradient(135deg, #EA8D5C 0%, #F2A97E 50%, #D25818 100%);
  --gradient-hover: linear-gradient(135deg, #F2A97E, #EA8D5C);

  /* Dark Backgrounds */
  --bg-darkest: #07060B;
  --bg-dark: #0B0A0F;
  --bg-card: #111017;
  --bg-elevated: #18171F;
  --bg-surface: #1F1E27;
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-glass-hover: rgba(255, 255, 255, 0.06);

  /* Text Colors */
  --text-primary: #FFFFFF;
  --text-secondary: #A4A7AE;
  --text-muted: #6B6B7B;

  /* Borders */
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --border-orange: rgba(234, 141, 92, 0.2);

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(234, 141, 92, 0.15);

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Layout */
  --sidebar-width: 220px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --transition: 0.35s cubic-bezier(0.25, 0.1, 0.25, 1);
  --transition-fast: 0.2s ease;

  /* Status Colors */
  --success: #34D399;
  --warning: #F59E0B;
  --error: #EF4444;
  --green: #34D399;
  --yellow: #F59E0B;
  --blue: #3B82F6;
  --red: #EF4444;
  --purple: #8B5CF6;
}


/* ─────────────────────────────────────────
   2. RESET
────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font);
  background-color: var(--bg-darkest);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: var(--font);
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input,
select,
textarea {
  font-family: var(--font);
}

img,
svg {
  display: block;
  max-width: 100%;
}

ul,
ol {
  list-style: none;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.25;
}


/* ─────────────────────────────────────────
   3. SCROLLBAR STYLES
────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

::selection {
  background: var(--orange-glow-strong);
  color: var(--text-primary);
}

:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}


/* ─────────────────────────────────────────
   4. APP LAYOUT
────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 32px;
  min-height: 100vh;
  background-color: var(--bg-darkest);
}

.main-content > * + * {
  margin-top: 24px;
}


/* ─────────────────────────────────────────
   5. SIDEBAR
────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background-color: var(--bg-dark);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo img {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.sidebar-logo-subtitle {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.03em;
  margin-top: 1px;
}

.sidebar-section {
  padding: 12px 8px;
  flex: 1;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 8px 8px 4px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-nav-item:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.sidebar-nav-item.active {
  background: rgba(234, 141, 92, 0.12);
  color: var(--orange);
}

.sidebar-nav-item .nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-nav-item.active .nav-icon {
  opacity: 1;
}

.sidebar-nav-item .nav-badge {
  margin-left: auto;
  background: var(--orange-glow);
  color: var(--orange);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  line-height: 1.4;
}

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.sidebar-user:hover {
  background: var(--bg-glass-hover);
}

.sidebar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--text-muted);
}


/* ─────────────────────────────────────────
   6. PAGE HEADER
────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.page-greeting {
  flex: 1;
}

.page-greeting-eyebrow {
  font-size: 12px;
  font-weight: 500;
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}


/* ─────────────────────────────────────────
   7. CARDS
────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover {
  border-color: var(--border-hover);
}

.card-elevated {
  background: var(--bg-elevated);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.card-header-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-header-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-glass);
}

.card-grid {
  display: grid;
  gap: 16px;
}

.card-grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.card-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}


/* ─────────────────────────────────────────
   8. BUTTONS
────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  border: none;
  outline: none;
  white-space: nowrap;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 12px;
}

.btn-lg {
  padding: 13px 28px;
  font-size: 15px;
  border-radius: var(--radius);
}

.btn-icon {
  padding: 10px;
  border-radius: var(--radius-sm);
}

.btn-icon.btn-sm {
  padding: 7px;
}

/* Primary */
.btn-primary {
  background: var(--gradient);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(234, 141, 92, 0.25);
}

.btn-primary:hover {
  background: var(--gradient-hover);
  box-shadow: 0 6px 24px rgba(234, 141, 92, 0.4);
}

/* Secondary (glass) */
.btn-secondary {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

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

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

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

/* Danger */
.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--red);
}

.btn-danger:hover {
  background: var(--red);
  color: #ffffff;
  border-color: var(--red);
}

/* Orange outline */
.btn-outline {
  background: transparent;
  border: 1px solid var(--border-orange);
  color: var(--orange);
}

.btn-outline:hover {
  background: var(--orange-glow);
}


/* ─────────────────────────────────────────
   9. FORMS
────────────────────────────────────────── */
.form-group {
  margin-bottom: 18px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.form-label .required {
  color: var(--red);
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--border-orange);
  box-shadow: 0 0 0 3px var(--orange-glow);
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B6B7B' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-select option {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.form-textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.5;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 5px;
}

.form-error {
  font-size: 11px;
  color: var(--red);
  margin-top: 5px;
}


/* ─────────────────────────────────────────
   10. MODAL
────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 6, 11, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-fast), visibility var(--transition-fast);
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  transform: scale(0.95);
  transition: transform var(--transition);
}

.modal-overlay.visible .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  transition: background var(--transition-fast), color var(--transition-fast);
  cursor: pointer;
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-glass);
}


/* ─────────────────────────────────────────
   11. TOAST NOTIFICATIONS
────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  padding: 14px 18px;
  min-width: 300px;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  pointer-events: all;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity var(--transition), transform var(--transition);
  border-left: 3px solid var(--border-hover);
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

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

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

.toast-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.toast-message {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.4;
}

.toast-close {
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
  line-height: 1;
}

.toast-close:hover {
  opacity: 1;
}

/* Toast variants */
.toast-success { border-left-color: var(--green); }
.toast-success .toast-icon { color: var(--green); }

.toast-error { border-left-color: var(--red); }
.toast-error .toast-icon { color: var(--red); }

.toast-info { border-left-color: var(--blue); }
.toast-info .toast-icon { color: var(--blue); }

.toast-warning { border-left-color: var(--yellow); }
.toast-warning .toast-icon { color: var(--yellow); }


/* ─────────────────────────────────────────
   12. BADGES & TAGS
────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-orange  { background: var(--orange-glow); color: var(--orange); }
.badge-green   { background: rgba(52, 211, 153, 0.12); color: var(--green); }
.badge-yellow  { background: rgba(245, 158, 11, 0.12); color: var(--yellow); }
.badge-red     { background: rgba(239, 68, 68, 0.12); color: var(--red); }
.badge-blue    { background: rgba(59, 130, 246, 0.12); color: var(--blue); }
.badge-purple  { background: rgba(139, 92, 246, 0.12); color: var(--purple); }
.badge-muted   { background: var(--bg-glass-hover); color: var(--text-muted); }


/* ─────────────────────────────────────────
   13. PROGRESS BARS
────────────────────────────────────────── */
.progress-track {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gradient);
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.progress-fill.green  { background: var(--green); }
.progress-fill.yellow { background: var(--yellow); }
.progress-fill.red    { background: var(--red); }


/* ─────────────────────────────────────────
   14. AVATAR
────────────────────────────────────────── */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  border: 2px solid var(--bg-darkest);
}

.avatar-group {
  display: flex;
}

.avatar-group .avatar {
  margin-left: -10px;
}

.avatar-group .avatar:first-child {
  margin-left: 0;
}


/* ─────────────────────────────────────────
   15. TABS
────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.tab-btn:hover {
  color: var(--text-secondary);
}

.tab-btn.active {
  color: var(--orange);
  border-bottom-color: var(--orange);
}

.tab-panel {
  display: none;
}

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


/* ─────────────────────────────────────────
   16. UTILITY CLASSES
────────────────────────────────────────── */

/* Text */
.text-primary    { color: var(--text-primary) !important; }
.text-secondary  { color: var(--text-secondary) !important; }
.text-muted      { color: var(--text-muted) !important; }
.text-orange     { color: var(--orange) !important; }
.text-green      { color: var(--green) !important; }
.text-red        { color: var(--red) !important; }
.text-yellow     { color: var(--yellow) !important; }
.text-blue       { color: var(--blue) !important; }

.text-sm   { font-size: 12px; }
.text-xs   { font-size: 11px; }
.text-base { font-size: 14px; }
.text-lg   { font-size: 16px; }
.text-xl   { font-size: 20px; }
.text-2xl  { font-size: 24px; }

.font-normal   { font-weight: 400; }
.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

/* Layout */
.flex            { display: flex; }
.flex-col        { flex-direction: column; }
.items-center    { align-items: center; }
.items-start     { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.flex-1          { flex: 1; }
.flex-wrap       { flex-wrap: wrap; }

.gap-4  { gap: 4px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.gap-24 { gap: 24px; }

/* Spacing */
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.p-8   { padding: 8px; }
.p-12  { padding: 12px; }
.p-16  { padding: 16px; }
.p-20  { padding: 20px; }
.p-24  { padding: 24px; }

/* Display */
.hidden      { display: none !important; }
.invisible   { visibility: hidden; }
.block       { display: block; }
.inline      { display: inline; }
.inline-flex { display: inline-flex; }

/* Borders */
.border       { border: 1px solid var(--border); }
.rounded-sm   { border-radius: var(--radius-sm); }
.rounded      { border-radius: var(--radius); }
.rounded-lg   { border-radius: var(--radius-lg); }
.rounded-full { border-radius: 9999px; }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Width */
.w-full { width: 100%; }
.w-auto { width: auto; }

/* Cursor */
.cursor-pointer { cursor: pointer; }

/* Opacity */
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }

/* Delta indicators */
.delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 600;
}
.delta.up   { color: var(--green); }
.delta.down { color: var(--red); }


/* ─────────────────────────────────────────
   17. BANNER
────────────────────────────────────────── */
.banner {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.banner-warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--yellow);
}

.banner-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--red);
}

.banner-success {
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.3);
  color: var(--green);
}


/* ─────────────────────────────────────────
   18. KPI CARDS (CRM-specific)
────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

.kpi-card.active {
  border-color: var(--orange);
  box-shadow: 0 0 20px rgba(234, 141, 92, 0.1);
}

.kpi-card-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--orange-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  font-size: 16px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 4px;
}

.kpi-value.gradient-text {
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 6px;
}

.kpi-delta.up   { color: var(--green); }
.kpi-delta.down { color: var(--red); }


/* ─────────────────────────────────────────
   19. COACH CARD GRID (CRM-specific)
────────────────────────────────────────── */
.coach-card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.coach-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.coach-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

.coach-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.coach-initials {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.coach-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.coach-card-email {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.coach-card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.coach-stat {
  text-align: center;
}

.coach-stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.coach-stat-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ─────────────────────────────────────────
   20. FUNNEL VISUALIZATION (CRM-specific)
────────────────────────────────────────── */
.funnel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0;
}

.funnel-stage {
  display: flex;
  align-items: center;
  gap: 12px;
}

.funnel-bar-wrap {
  flex: 1;
  display: flex;
  align-items: center;
}

.funnel-bar {
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--gradient);
  opacity: 0.85;
  transition: opacity var(--transition-fast);
  min-width: 4px;
}

.funnel-stage:hover .funnel-bar {
  opacity: 1;
}

.funnel-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  width: 100px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.funnel-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  width: 48px;
  text-align: right;
  flex-shrink: 0;
}

.funnel-pct {
  font-size: 11px;
  color: var(--text-muted);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}


/* ─────────────────────────────────────────
   21. ENTRY FORM (CRM-specific)
────────────────────────────────────────── */
.entry-form {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.entry-form .form-group {
  margin-bottom: 0;
}

.entry-form-section {
  grid-column: 1 / -1;
  padding-top: 8px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
}

.entry-form-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
}


/* ─────────────────────────────────────────
   22. BULK GRID (CRM-specific)
────────────────────────────────────────── */
.bulk-grid-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.bulk-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.bulk-grid th,
.bulk-grid td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: left;
}

.bulk-grid th {
  background: var(--bg-dark);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  position: sticky;
  top: 0;
  z-index: 2;
}

.bulk-grid td {
  color: var(--text-secondary);
  background: var(--bg-card);
}

.bulk-grid tr:last-child td {
  border-bottom: none;
}

.bulk-grid tr:hover td {
  background: var(--bg-elevated);
}

/* Sticky first column */
.bulk-grid th:first-child,
.bulk-grid td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--bg-dark);
  border-right: 1px solid var(--border);
}

.bulk-grid td:first-child {
  background: var(--bg-card);
  font-weight: 600;
  color: var(--text-primary);
}

.bulk-grid tr:hover td:first-child {
  background: var(--bg-elevated);
}

/* Editable cell */
.bulk-grid td input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast);
}

.bulk-grid td input:focus {
  border-color: var(--border-orange);
  background: var(--bg-elevated);
}


/* ─────────────────────────────────────────
   23. DATE RANGE PICKER (CRM-specific)
────────────────────────────────────────── */
.date-range-picker {
  display: inline-flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.date-range-picker .drp-btn {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
}

.date-range-picker .drp-btn:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.date-range-picker .drp-btn.active {
  background: rgba(234, 141, 92, 0.12);
  color: var(--orange);
  font-weight: 600;
}

.date-range-picker .drp-divider {
  width: 1px;
  height: 16px;
  background: var(--border);
  flex-shrink: 0;
}


/* ─────────────────────────────────────────
   24. SKELETON LOADING (CRM-specific)
────────────────────────────────────────── */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 0.7; }
}

.skeleton {
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
}

.skeleton-text.wide  { width: 80%; }
.skeleton-text.mid   { width: 55%; }
.skeleton-text.short { width: 35%; }

.skeleton-title {
  height: 20px;
  width: 50%;
  margin-bottom: 12px;
}

.skeleton-card {
  height: 120px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skeleton-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}


/* ─────────────────────────────────────────
   25. EMPTY STATE (CRM-specific)
────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state-message {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 300px;
  line-height: 1.6;
  margin-bottom: 20px;
}


/* ─────────────────────────────────────────
   26. RESPONSIVE
────────────────────────────────────────── */
@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .coach-card-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .entry-form {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  /* Sidebar collapses */
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition);
    z-index: 200;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(7, 6, 11, 0.7);
    z-index: 199;
  }

  .sidebar.open ~ .sidebar-backdrop,
  .sidebar-backdrop.visible {
    display: block;
  }

  .main-content {
    margin-left: 0;
    padding: 20px 16px;
  }

  .mobile-menu-btn {
    display: flex;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .coach-card-grid {
    grid-template-columns: 1fr;
  }

  .entry-form {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
  }

  .card-grid-2,
  .card-grid-3 {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .modal {
    max-width: 100%;
    border-radius: var(--radius);
    margin: 0;
  }

  .modal-overlay {
    align-items: flex-end;
  }

  .toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }

  .toast {
    min-width: unset;
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .main-content {
    padding: 16px 12px;
  }
}

/* Mobile menu button — hidden by default on desktop */
.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

.mobile-menu-btn:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

/* sidebar-toggle is an alias for mobile-menu-btn — hidden by default */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}


/* ─────────────────────────────────────────
   27. RESPONSIVE ADDITIONS
────────────────────────────────────────── */

/* ── 992px: tablet mid-range ── */
@media (max-width: 992px) {
  /* Dashboard bottom row: funnel + top coaches stack vertically */
  #bottom-row,
  .card-grid-2[id="bottom-row"] {
    grid-template-columns: 1fr !important;
  }

  /* Entry form: 3 → 2 columns at tablet */
  .entry-form {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── 768px additions ── */
@media (max-width: 768px) {
  /* Show sidebar-toggle button on mobile */
  .sidebar-toggle {
    display: flex;
  }

  /* Date range picker: full width, wrap buttons */
  .date-range-picker {
    width: 100%;
    flex-wrap: wrap;
  }

  /* Coach selector: full width */
  #coach-selector {
    width: 100% !important;
  }
}

/* ── 480px additions ── */
@media (max-width: 480px) {
  /* Slightly smaller headings */
  .page-title {
    font-size: 20px;
  }

  h1 { font-size: 20px; }
  h2 { font-size: 17px; }
  h3 { font-size: 15px; }

  .kpi-value {
    font-size: 20px;
  }

  .card-header-title {
    font-size: 13px;
  }

  /* Reduce padding on cards */
  .card-body {
    padding: 14px;
  }

  .card-header {
    padding: 14px 16px;
  }

  .kpi-card {
    padding: 14px;
  }

  .coach-card {
    padding: 14px;
  }
}
