/* AeroCRM Theme System & Design CSS Custom Stylesheet */

/* --- Fonts & Variables --- */
:root {
  /* Common Core Colors (HSL base) */
  --font-title: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* HSL Tailored Palettes */
  --indigo-hsl: 239, 84%, 66%;     /* #6366f1 - Indigo Accent */
  --emerald-hsl: 161, 84%, 43%;    /* #10b981 - Success Green */
  --amber-hsl: 38, 92%, 50%;       /* #f59e0b - Warning Amber */
  --crimson-hsl: 354, 84%, 60%;    /* #ef4444 - Danger Red */
  
  --accent-indigo: hsl(var(--indigo-hsl));
  --accent-emerald: hsl(var(--emerald-hsl));
  --accent-amber: hsl(var(--amber-hsl));
  --accent-crimson: hsl(var(--crimson-hsl));

  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease-out;
  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  
  --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.24);
  --shadow-subtle: 0 4px 12px 0 rgba(0, 0, 0, 0.08);
}

/* --- Dark Theme Tokens (Default) --- */
[data-theme="dark"] {
  --bg-primary: #0a0b10;
  --bg-secondary: #12131a;
  
  --bg-card: rgba(22, 24, 35, 0.6);
  --bg-card-hover: rgba(30, 32, 48, 0.85);
  --bg-card-rgb: 22, 24, 35;
  --bg-solid-card: #161823;
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-rgb: 255, 255, 255;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --bg-input: rgba(10, 11, 16, 0.6);
  --bg-input-focus: rgba(22, 24, 35, 0.9);
  
  --glass-glow: radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.15) 0%, transparent 75%);
  --sidebar-width: 260px;
}

/* --- Light Theme Tokens --- */
[data-theme="light"] {
  --bg-primary: #f4f6fc;
  --bg-secondary: #ffffff;
  
  --bg-card: rgba(255, 255, 255, 0.7);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --bg-card-rgb: 255, 255, 255;
  --bg-solid-card: #ffffff;
  
  --border-color: rgba(99, 102, 241, 0.1);
  --border-rgb: 99, 102, 241;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  --bg-input: rgba(244, 246, 252, 0.8);
  --bg-input-focus: #ffffff;
  
  --glass-glow: radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.06) 0%, transparent 70%);
  --sidebar-width: 260px;
}

/* --- Base & Scrollbar Reset --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.4s ease, color 0.4s ease;
  position: relative;
}

/* Glowing Orbs in Background */
.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  opacity: 0.25;
  pointer-events: none;
  transition: var(--transition-smooth);
}
.orb-1 {
  width: 400px;
  height: 400px;
  top: 10%;
  left: 20%;
  background: var(--accent-indigo);
}
.orb-2 {
  width: 300px;
  height: 300px;
  bottom: 20%;
  right: 10%;
  background: var(--accent-emerald);
}
.orb-3 {
  width: 350px;
  height: 350px;
  top: 50%;
  left: 60%;
  background: var(--accent-amber);
}

[data-theme="light"] .glow-orb {
  opacity: 0.1;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* --- Application Layout Grid --- */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100vw;
  position: relative;
}

/* --- Sidebar Navigation --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px;
  flex-shrink: 0;
  transition: var(--transition-smooth);
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-indigo), #818cf8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.brand-name {
  font-family: var(--font-title);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-nav {
  flex-grow: 1;
}

.sidebar-nav ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 500;
  font-size: 15px;
  transition: var(--transition-fast);
}

.nav-item i {
  width: 20px;
  height: 20px;
  transition: var(--transition-fast);
}

.nav-item:hover {
  background: rgba(var(--border-rgb), 0.05);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(var(--indigo-hsl), 0.1);
  color: var(--accent-indigo);
  font-weight: 600;
}

.nav-item.active i {
  color: var(--accent-indigo);
}

/* Sidebar Footer & User Profile */
.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.theme-toggle-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition-fast);
}

.theme-toggle-btn:hover {
  background: rgba(var(--border-rgb), 0.05);
  color: var(--text-primary);
}

.theme-toggle-btn i {
  width: 18px;
  height: 18px;
}

[data-theme="dark"] .theme-toggle-btn .sun-icon { display: block; }
[data-theme="dark"] .theme-toggle-btn .moon-icon { display: none; }
[data-theme="light"] .theme-toggle-btn .sun-icon { display: none; }
[data-theme="light"] .theme-toggle-btn .moon-icon { display: block; }

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--border-color);
  border: 1px solid rgba(var(--border-rgb), 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}

.user-info {
  display: flex;
  flex-direction: column;
}

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

.user-role {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* --- Main Content Panel --- */
.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0; /* Prevents overflow */
  height: 100vh;
}

.main-header {
  height: 80px;
  border-bottom: 1px solid var(--border-color);
  padding: 0 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(var(--bg-card-rgb), 0.2);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
}

.main-header h1 {
  font-family: var(--font-title);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.search-bar {
  position: relative;
  width: 280px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
}

.search-bar input {
  width: 100%;
  height: 42px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 16px 0 40px;
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition-fast);
}

.search-bar input:focus {
  outline: none;
  border-color: var(--accent-indigo);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* --- Dynamic Viewport Area --- */
.viewport {
  flex-grow: 1;
  padding: 40px;
  overflow-y: auto;
  position: relative;
}

/* Glassmorphism Section/Card panels */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-premium);
  position: relative;
  overflow: hidden;
  transition: var(--transition-smooth);
}

.glass-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: var(--glass-glow);
  pointer-events: none;
  z-index: 0;
}

/* --- Generic Styles: Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 20px;
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-indigo), #818cf8);
  color: white;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}
.btn-primary:active {
  transform: translateY(0);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-primary);
}
.btn-outline:hover {
  background: rgba(var(--border-rgb), 0.05);
  border-color: var(--text-secondary);
}

.btn-danger {
  background: linear-gradient(135deg, var(--accent-crimson), #f87171);
  color: white;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.45);
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-full {
  width: 100%;
}

/* --- Dashboard Specific UI --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  margin-bottom: 32px;
}

.stats-card {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.stats-icon-wrapper {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-blue { background: rgba(99, 102, 241, 0.15); color: var(--accent-indigo); }
.icon-green { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.icon-amber { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.icon-crimson { background: rgba(239, 68, 68, 0.15); color: var(--accent-crimson); }

.stats-details {
  display: flex;
  flex-direction: column;
}

.stats-label {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 4px;
}

.stats-value {
  font-size: 24px;
  font-family: var(--font-title);
  font-weight: 700;
  color: var(--text-primary);
}

.dashboard-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 32px;
}

.dashboard-charts-column {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.chart-card {
  padding: 24px;
  min-height: 350px;
  display: flex;
  flex-direction: column;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.chart-header h3 {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 18px;
}

.chart-body {
  flex-grow: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* SVG Chart Elements */
.svg-chart {
  width: 100%;
  height: 240px;
}

.chart-line {
  fill: none;
  stroke: var(--accent-indigo);
  stroke-width: 3.5px;
  stroke-linecap: round;
}

.chart-gradient-fill {
  fill: url(#chart-gradient);
}

.chart-axis-line {
  stroke: var(--border-color);
  stroke-dasharray: 4;
}

.chart-axis-text {
  fill: var(--text-tertiary);
  font-size: 11px;
  font-family: var(--font-body);
}

.chart-point {
  fill: var(--bg-solid-card);
  stroke: var(--accent-indigo);
  stroke-width: 2.5px;
  r: 5px;
  transition: var(--transition-fast);
  cursor: pointer;
}

.chart-point:hover {
  r: 8px;
  stroke: #818cf8;
}

/* Donut Chart specific */
.donut-circle-bg {
  fill: none;
  stroke: var(--border-color);
  stroke-width: 24px;
}
.donut-circle-value {
  fill: none;
  stroke: var(--accent-indigo);
  stroke-width: 24px;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s ease-in-out;
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-left: 24px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

/* Recent Tasks Panel Dashboard */
.recent-tasks-panel {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.recent-tasks-panel h3 {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.dashboard-task-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- Contacts View UI --- */
.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.toolbar-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-button-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.select-filter {
  height: 38px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 14px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
}
.select-filter:focus {
  border-color: var(--accent-indigo);
}

.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-subtle);
}

.contacts-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.contacts-table th,
.contacts-table td {
  padding: 16px 24px;
  font-size: 14px;
}

.contacts-table th {
  background: rgba(var(--bg-card-rgb), 0.4);
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.contacts-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition-fast);
  cursor: pointer;
}

.contacts-table tbody tr:hover {
  background: rgba(var(--border-rgb), 0.03);
}

.contacts-table tbody tr:last-child {
  border-bottom: none;
}

.contact-name-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.contact-avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(var(--indigo-hsl), 0.1);
  color: var(--accent-indigo);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.contacts-table td .company {
  color: var(--text-secondary);
  font-weight: 500;
}

/* Badges styling */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 20px;
  white-space: nowrap;
}

.badge-lead { background: rgba(99, 102, 241, 0.1); color: var(--accent-indigo); }
.badge-mql { background: rgba(245, 158, 11, 0.1); color: var(--accent-amber); }
.badge-sql { background: rgba(239, 68, 68, 0.1); color: var(--accent-crimson); }
.badge-customer { background: rgba(16, 185, 129, 0.1); color: var(--accent-emerald); }
.badge-evangelist { background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(16, 185, 129, 0.15)); color: var(--text-primary); border: 1px solid rgba(var(--indigo-hsl), 0.2); }

.badge-active { background: rgba(16, 185, 129, 0.1); color: var(--accent-emerald); }
.badge-nurturing { background: rgba(245, 158, 11, 0.1); color: var(--accent-amber); }
.badge-inactive { background: rgba(255, 255, 255, 0.05); color: var(--text-tertiary); }

.text-accent {
  color: var(--accent-indigo);
  font-weight: 600;
}

/* --- Drag-and-Drop Pipeline Kanban Board --- */
.pipeline-container {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  padding-bottom: 20px;
  min-height: calc(100vh - 200px);
  align-items: flex-start;
}

.pipeline-column {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 220px);
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 22px color-mix(in srgb, var(--stage-color, var(--accent-indigo)) 13%, transparent);
}

.pipeline-column::before {
  content: '';
  height: 3px;
  width: 100%;
  background: var(--stage-color, var(--accent-indigo));
  box-shadow: 0 0 18px var(--stage-color, var(--accent-indigo));
  flex-shrink: 0;
}

.pipeline-column.drag-over {
  border-color: var(--stage-color, var(--accent-indigo));
  background: color-mix(in srgb, var(--stage-color, var(--accent-indigo)) 8%, var(--bg-card));
  box-shadow: 0 0 24px color-mix(in srgb, var(--stage-color, var(--accent-indigo)) 28%, transparent);
}

.column-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.column-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.column-title h4 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: var(--font-title);
  color: var(--text-primary);
  font-weight: 700;
}

.column-count {
  font-size: 12px;
  background: color-mix(in srgb, var(--stage-color, var(--accent-indigo)) 18%, transparent);
  color: var(--text-primary);
  border: 1px solid color-mix(in srgb, var(--stage-color, var(--accent-indigo)) 35%, transparent);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.column-value {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 600;
}

.column-cards-list {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  flex-grow: 1;
  min-height: 150px;
}

/* Kanban Cards styling */
.deal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: grab;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-subtle);
  position: relative;
}

.deal-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--stage-color, var(--accent-indigo)) 35%, rgba(var(--border-rgb), 0.25));
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15), 0 0 16px color-mix(in srgb, var(--stage-color, var(--accent-indigo)) 13%, transparent);
}

.deal-card:active {
  cursor: grabbing;
}

.deal-card.dragging {
  opacity: 0.4;
  transform: scale(0.95);
  border-style: dashed;
  border-color: var(--accent-indigo);
}

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

.deal-card-company {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}

.deal-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
}

.deal-card-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--stage-color, var(--accent-indigo));
}

.stage-color-control .stage-color-dot {
  position: absolute;
  left: 11px;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--stage-color, var(--accent-indigo));
  box-shadow: 0 0 12px var(--stage-color, var(--accent-indigo));
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 1;
}

.stage-color-control select {
  padding-left: 32px !important;
  border-color: color-mix(in srgb, var(--stage-color, var(--accent-indigo)) 38%, var(--border-color)) !important;
  box-shadow: 0 0 14px color-mix(in srgb, var(--stage-color, var(--accent-indigo)) 15%, transparent);
}

.deal-card-date {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* --- Task Board Specific --- */
.tasks-container {
  max-width: 1000px;
  margin: 0 auto;
}

.tasks-card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.task-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition-fast);
}

.task-item:hover {
  border-color: rgba(var(--border-rgb), 0.15);
}

.task-item-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.task-checkbox {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: var(--transition-fast);
}

.task-checkbox:hover {
  border-color: var(--accent-indigo);
}

.task-item.completed .task-checkbox {
  background: var(--accent-emerald);
  border-color: var(--accent-emerald);
  color: white;
}

.task-item-content {
  display: flex;
  flex-direction: column;
}

.task-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  transition: var(--transition-fast);
}

.task-item.completed .task-title {
  color: var(--text-tertiary);
  text-decoration: line-through;
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.task-meta-dot {
  width: 4px;
  height: 4px;
  background: var(--text-tertiary);
  border-radius: 50%;
}

.priority-ring {
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  text-transform: uppercase;
}
.priority-high { background: rgba(239, 68, 68, 0.1); color: var(--accent-crimson); }
.priority-medium { background: rgba(245, 158, 11, 0.1); color: var(--accent-amber); }
.priority-low { background: rgba(99, 102, 241, 0.1); color: var(--accent-indigo); }

.task-item-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.btn-icon:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-crimson);
}

/* --- Slide-out Details Drawer Pane --- */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  z-index: 990;
  transition: opacity 0.3s ease;
}

.drawer-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.contact-drawer {
  position: fixed;
  top: 0;
  right: -500px;
  width: 500px;
  height: 100vh;
  background: var(--bg-solid-card);
  border-left: 1px solid var(--border-color);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.contact-drawer.active {
  right: 0;
}

.drawer-header {
  padding: 30px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.drawer-header-left h2 {
  font-family: var(--font-title);
  font-size: 22px;
  font-weight: 700;
  margin: 6px 0 2px 0;
}

.drawer-header-left span {
  font-size: 13px;
  color: var(--text-secondary);
}

.btn-close-drawer {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.btn-close-drawer:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.drawer-content {
  flex-grow: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.drawer-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: rgba(var(--bg-card-rgb), 0.2);
}

.drawer-tab {
  flex-grow: 1;
  text-align: center;
  padding: 14px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition-fast);
}

.drawer-tab:hover {
  color: var(--text-primary);
}

.drawer-tab.active {
  color: var(--accent-indigo);
  border-color: var(--accent-indigo);
}

.drawer-pane {
  display: none;
  padding: 30px;
  flex-direction: column;
  gap: 24px;
}

.drawer-pane.active {
  display: flex;
}

.section-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-group h3 {
  font-family: var(--font-title);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  font-weight: 700;
  margin-bottom: 4px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-label {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 600;
  text-transform: uppercase;
}

.detail-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.associated-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 6px;
}

.associated-item {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.associated-item-title {
  font-weight: 600;
  color: var(--text-primary);
}

.associated-item-subtitle {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* Timeline & Interaction Logger Styles */
.timeline-composer {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-subtle);
  margin-bottom: 20px;
}

.composer-tabs {
  display: flex;
  gap: 8px;
}

.composer-tab {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-fast);
}

.composer-tab i {
  width: 14px;
  height: 14px;
}

.composer-tab:hover,
.composer-tab.active {
  background: rgba(var(--indigo-hsl), 0.08);
  border-color: var(--accent-indigo);
  color: var(--accent-indigo);
}

.composer-textarea {
  resize: none;
  min-height: 80px;
}

.composer-footer {
  display: flex;
  justify-content: flex-end;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
  padding-left: 20px;
}

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

.timeline-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.timeline-dot {
  position: absolute;
  left: -20px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg-solid-card);
  border: 3px solid var(--accent-indigo);
}

.timeline-item.Note .timeline-dot { border-color: var(--accent-indigo); }
.timeline-item.Call .timeline-dot { border-color: var(--accent-amber); }
.timeline-item.Email .timeline-dot { border-color: var(--accent-emerald); }
.timeline-item.Meeting .timeline-dot { border-color: var(--accent-crimson); }

.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.timeline-type {
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
}

.timeline-date {
  color: var(--text-tertiary);
}

.timeline-body {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.drawer-footer {
  padding: 30px;
  border-top: 1px solid var(--border-color);
  background: rgba(var(--bg-card-rgb), 0.2);
}

/* --- Dialog Modal Framework --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  opacity: 0;
  pointer-events: none;
  z-index: 1010;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.25s ease-out;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: var(--bg-solid-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-premium);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 600px;
  transform: scale(0.92);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

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

.small-modal {
  max-width: 480px;
}

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

.modal-header h2 {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.btn-close-modal {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

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

.modal-body {
  padding: 30px;
  max-height: 70vh;
  overflow-y: auto;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  height: 42px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 16px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-body);
  transition: var(--transition-fast);
  width: 100%;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19.5 8.25l-7.5 7.5-7.5-7.5' /%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 16px;
  padding-right: 40px;
}

textarea.form-control {
  height: auto;
  padding: 12px 16px;
  min-height: 100px;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-indigo);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-row {
  display: flex;
  gap: 20px;
}

.col-6 {
  width: 50%;
}

.modal-footer {
  padding: 20px 30px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background: rgba(var(--bg-card-rgb), 0.2);
}

/* Quick Action Creator Specific */
.quick-options {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 30px;
}

.quick-opt-card {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 20px;
  cursor: pointer;
  text-align: left;
  transition: var(--transition-fast);
}

.quick-opt-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-indigo);
  transform: translateY(-2px);
}

.opt-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.opt-icon i {
  width: 22px;
  height: 22px;
}

.opt-text h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.opt-text p {
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.4;
}

/* --- Toast Alert Notifications --- */
.toast-container {
  position: fixed;
  bottom: 40px;
  right: 40px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  background: var(--bg-solid-card);
  border-left: 4px solid var(--accent-indigo);
  box-shadow: var(--shadow-premium);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  width: 320px;
  display: flex;
  align-items: center;
  gap: 14px;
  pointer-events: auto;
  animation: slideInToast 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transition: var(--transition-smooth);
}

.toast.success { border-left-color: var(--accent-emerald); }
.toast.warning { border-left-color: var(--accent-amber); }
.toast.danger { border-left-color: var(--accent-crimson); }

.toast-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.toast.success .toast-icon { color: var(--accent-emerald); }
.toast.warning .toast-icon { color: var(--accent-amber); }
.toast.danger .toast-icon { color: var(--accent-crimson); }

.toast-message {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}

.toast-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-close:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

/* --- Settings View --- */
.settings-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 24px;
  max-width: 900px;
}

.settings-section {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.settings-section-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.settings-section-header h2 {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.settings-section-header span {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.settings-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-icon i {
  width: 20px;
  height: 20px;
}

.theme-choice-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.theme-choice {
  height: 74px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-fast);
}

.theme-choice:hover {
  color: var(--text-primary);
  border-color: rgba(var(--border-rgb), 0.22);
  background: var(--bg-input-focus);
}

.theme-choice.active {
  color: var(--accent-indigo);
  border-color: var(--accent-indigo);
  background: rgba(var(--indigo-hsl), 0.1);
  box-shadow: 0 0 18px rgba(99, 102, 241, 0.18);
}

.theme-choice i {
  width: 18px;
  height: 18px;
}

.settings-install-btn {
  align-self: flex-start;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* --- Responsive Adaptations --- */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .dashboard-charts-column {
    gap: 24px;
  }
}

@media (max-width: 1024px) {
  body {
    width: 100%;
  }

  .app-container {
    width: 100%;
  }

  .main-content {
    height: 100dvh;
    min-height: 100dvh;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    height: 100dvh;
    box-shadow: 20px 0 48px rgba(0, 0, 0, 0.32);
    transform: translateX(calc(-100% - 24px));
  }

  .sidebar.active {
    left: 0;
    transform: translateX(0);
  }

  .mobile-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .main-header {
    padding: 0 28px;
  }

  .main-header h1 {
    max-width: 38vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-right {
    gap: 12px;
  }

  .header-right .search-bar {
    width: min(280px, 34vw);
  }

  .viewport {
    padding: 28px;
  }

  .toolbar-actions {
    align-items: stretch;
  }

  .toolbar-filters,
  .toolbar-button-group,
  .pipeline-toolbar-actions {
    width: 100%;
  }

  .toolbar-filters .search-bar {
    width: min(100%, 320px) !important;
    flex: 1 1 240px;
  }

  .toolbar-button-group,
  .pipeline-toolbar-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .contacts-table {
    min-width: 760px;
  }

  .users-table {
    min-width: 680px;
  }

  .pipeline-container {
    gap: 16px;
    min-height: calc(100dvh - 190px);
    scroll-padding-left: 2px;
  }

  .pipeline-column {
    width: 300px;
    max-height: calc(100dvh - 210px);
  }

  .tasks-container {
    max-width: none;
  }

  .settings-layout {
    grid-template-columns: 1fr;
    max-width: none;
  }

  .contact-drawer {
    display: none;
    width: min(500px, 92vw);
    right: 0;
    overflow: hidden;
    border-left: 1px solid var(--border-color);
    transform: none;
  }

  .contact-drawer.active {
    display: flex;
    animation: mobileDrawerIn 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }
}

@media (max-width: 768px) {
  .main-header {
    height: auto;
    min-height: 116px;
    align-items: stretch;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    padding: 14px 18px;
  }

  .header-left,
  .header-right {
    width: 100%;
  }

  .header-left {
    gap: 10px;
  }

  .main-header h1 {
    max-width: none;
    flex: 1 1 auto;
    min-width: 0;
    font-size: 22px;
    letter-spacing: 0;
  }

  .header-right {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
  }

  .header-right .search-bar {
    width: 100%;
  }

  .viewport {
    padding: 20px 16px 24px;
  }

  .stats-grid {
    gap: 16px;
    margin-bottom: 24px;
  }

  .stats-card {
    padding: 18px;
    gap: 14px;
  }

  .stats-icon-wrapper {
    width: 46px;
    height: 46px;
  }

  .stats-value {
    font-size: 22px;
  }

  .dashboard-layout,
  .dashboard-charts-column {
    gap: 20px;
  }

  .chart-card,
  .recent-tasks-panel,
  .settings-section {
    padding: 18px;
  }

  .chart-card {
    min-height: 300px;
  }

  .chart-header {
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
  }

  .chart-header h3 {
    font-size: 16px;
  }

  #pipeline-chart-container > div {
    flex-direction: column !important;
    gap: 16px;
  }

  .donut-legend {
    width: 100%;
    margin-left: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar-actions {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 18px;
  }

  .toolbar-filters,
  .toolbar-button-group,
  .pipeline-toolbar-actions {
    align-items: stretch;
  }

  .toolbar-filters .search-bar {
    width: 100% !important;
  }

  .select-filter,
  .toolbar-button-group .btn,
  .pipeline-toolbar-actions .btn {
    flex: 1 1 180px;
  }

  .pipeline-container {
    min-height: calc(100dvh - 240px);
    padding-bottom: 16px;
    scroll-snap-type: x mandatory;
  }

  .pipeline-column {
    width: min(320px, calc(100vw - 40px));
    max-height: calc(100dvh - 260px);
    scroll-snap-align: start;
  }

  .task-item {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
  }

  .task-item-left {
    align-items: flex-start;
    min-width: 0;
  }

  .task-item-content,
  .task-title {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .task-meta {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 6px 10px;
  }

  .task-item-right {
    justify-content: space-between;
    padding-left: 36px;
  }

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

  .modal-box {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - 24px);
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-lg);
  }

  .small-modal {
    max-width: none;
  }

  .modal-header {
    padding: 18px 20px;
  }

  .modal-header h2 {
    font-size: 18px;
  }

  .modal-body,
  .quick-options {
    padding: 20px;
    max-height: none;
    flex: 1 1 auto;
  }

  .modal-footer {
    padding: 16px 20px;
    flex-wrap: wrap;
  }

  .quick-opt-card {
    align-items: flex-start;
    gap: 14px;
    padding: 14px;
  }

  .contact-drawer {
    width: 100%;
    right: 0;
  }

  .drawer-header,
  .drawer-pane,
  .drawer-footer {
    padding: 22px;
  }

  .drawer-header-left h2 {
    font-size: 20px;
  }

  .glow-orb {
    position: fixed;
    width: min(260px, 65vw);
    height: min(260px, 65vw);
    filter: blur(90px);
  }

  .orb-1 {
    left: 5%;
  }

  .orb-2 {
    right: 2%;
  }

  .orb-3 {
    left: 28%;
  }

  .composer-tabs {
    flex-wrap: wrap;
  }

  .composer-tab {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
  }
}

@media (max-width: 820px) {
  .table-wrapper {
    overflow: visible;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .contacts-table,
  .contacts-table tbody,
  .contacts-table tr,
  .contacts-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .contacts-table {
    min-width: 0;
    border-collapse: separate;
  }

  .contacts-table thead {
    display: none;
  }

  .contacts-table tbody {
    display: grid;
    gap: 12px;
  }

  .contacts-table tbody tr {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-subtle);
    padding: 16px;
    overflow: hidden;
  }

  .contacts-table tbody tr:hover {
    background: var(--bg-card-hover);
  }

  .contacts-table td {
    display: grid;
    grid-template-columns: minmax(86px, 0.42fr) minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 0;
    text-align: left !important;
  }

  .contacts-table td + td {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
  }

  .contacts-table td::before {
    color: var(--text-tertiary);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
  }

  .contacts-table td[colspan] {
    display: block;
    text-align: center !important;
  }

  .contacts-table td[colspan]::before {
    content: none;
  }

  .contacts-list-table td:nth-child(1)::before { content: "Contact"; }
  .contacts-list-table td:nth-child(2)::before { content: "Company"; }
  .contacts-list-table td:nth-child(3)::before { content: "Stage"; }
  .contacts-list-table td:nth-child(4)::before { content: "Status"; }
  .contacts-list-table td:nth-child(5)::before { content: "Value"; }
  .contacts-list-table td:nth-child(6)::before { content: "Created"; }

  .users-table td:nth-child(1)::before { content: "User"; }
  .users-table td:nth-child(2)::before { content: "Username"; }
  .users-table td:nth-child(3)::before { content: "Role"; }
  .users-table td:nth-child(4)::before { content: "Created"; }
  .users-table td:nth-child(5)::before { content: "Actions"; }

  .contact-name-cell {
    min-width: 0;
  }

  .contact-name-cell > div:last-child {
    min-width: 0;
  }

  .contact-name-cell .name,
  .contacts-table .company,
  .contacts-table code {
    overflow-wrap: anywhere;
  }

  .stage-add-row {
    flex-wrap: wrap;
  }

  .stage-add-row > div:first-child {
    flex: 1 1 220px !important;
  }

  .stage-add-row .stage-color-control {
    width: auto !important;
    flex: 1 1 140px;
  }

  .stage-manager-item {
    flex-wrap: wrap;
    align-items: stretch !important;
  }

  .stage-manager-item > div:first-child {
    flex: 1 1 100% !important;
  }

  .stage-manager-item .stage-color-control {
    width: auto !important;
    flex: 1 1 150px;
  }
}

@media (max-width: 600px) {
  #login-screen {
    width: 100% !important;
    height: 100dvh !important;
    min-height: 100dvh;
    padding: 18px;
    overflow-y: auto;
  }

  #login-screen .glass-panel {
    max-width: 420px !important;
    padding: 26px 22px !important;
  }

  .login-captcha-row {
    flex-wrap: wrap;
  }

  #login-captcha {
    min-width: 160px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .col-6 {
    width: 100%;
  }

  .toolbar-button-group,
  .pipeline-toolbar-actions {
    display: grid !important;
    grid-template-columns: 1fr;
  }

  .toolbar-button-group .btn,
  .pipeline-toolbar-actions .btn,
  .select-filter,
  .settings-install-btn {
    width: 100%;
  }

  .chart-card {
    min-height: 280px;
  }

  .svg-chart {
    height: 220px;
  }

  .donut-legend {
    grid-template-columns: 1fr;
  }

  .detail-value,
  .associated-item-title,
  .associated-item-subtitle,
  .timeline-body {
    overflow-wrap: anywhere;
  }

  .associated-item {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

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

  .toast {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .main-header {
    min-height: 154px;
    padding: 12px 14px;
  }

  .header-right {
    grid-template-columns: 1fr;
  }

  #btn-quick-create {
    width: 100%;
  }

  .viewport {
    padding: 16px 12px 20px;
  }

  .stats-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .chart-card,
  .recent-tasks-panel,
  .settings-section {
    padding: 16px;
  }

  .chart-header {
    flex-direction: column;
  }

  .task-item-right {
    padding-left: 0;
  }

  .drawer-header,
  .drawer-pane,
  .drawer-footer {
    padding: 18px;
  }

  .drawer-tabs {
    position: sticky;
    top: 0;
    z-index: 1;
  }

  .modal-overlay {
    padding: 8px;
  }

  .modal-header,
  .modal-body,
  .quick-options,
  .modal-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .modal-footer .btn {
    width: 100%;
  }

  .quick-opt-card {
    gap: 12px;
  }

  .opt-icon {
    width: 40px;
    height: 40px;
  }

  .stage-add-row > div,
  .stage-add-row .stage-color-control,
  .stage-add-row .btn,
  .stage-manager-item .stage-color-control {
    width: 100% !important;
    flex-basis: 100%;
  }

  .stage-manager-item > div:last-child {
    width: 100%;
    justify-content: space-between;
  }

  .stage-manager-item > div:last-child .btn {
    flex: 1 1 0;
  }

  .theme-choice-group {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .sidebar {
    width: min(86vw, var(--sidebar-width));
    padding: 20px 16px;
  }

  .sidebar-brand {
    margin-bottom: 28px;
  }

  .nav-item {
    padding: 13px 14px;
  }

  #login-screen .glass-panel {
    padding: 22px 18px !important;
  }

  .login-captcha-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 42px;
    align-items: center;
  }

  #captcha-canvas {
    width: 100%;
  }

  #login-captcha {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .main-header h1 {
    font-size: 20px;
  }

  .btn {
    padding-left: 14px;
    padding-right: 14px;
  }

  .contacts-table tbody tr {
    padding: 14px;
  }

  .contacts-table td {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .pipeline-column {
    width: calc(100vw - 28px);
  }

  .column-header,
  .column-cards-list {
    padding-left: 14px;
    padding-right: 14px;
  }
}

/* --- Animation Keyframes --- */
@keyframes slideInToast {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes mobileDrawerIn {
  from {
    opacity: 0.96;
    transform: translateX(18px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
