/* Pier CRM Hub - Standalone Web UI Stylesheet
   Ported from Pier CRM partials + standalone layout additions */

/* ============================================================
   Reset & base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f3f4f6;
  color: #1f2937;
  line-height: 1.5;
}

/* ============================================================
   Top bar
   ============================================================ */
.crm-topbar {
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  z-index: 100;
}
.crm-topbar-inner {
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  height: 48px;
  gap: 1rem;
}
.crm-topbar-brand {
  font-size: 1.15rem;
  font-weight: 700;
  color: #3dbcC9;
  text-decoration: none;
  white-space: nowrap;
}
.crm-topbar-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.crm-topbar-username {
  font-size: 0.85rem;
  color: #6b7280;
  font-weight: 500;
}

/* ============================================================
   Left sidebar
   ============================================================ */
.crm-sidebar {
  position: fixed;
  top: 48px;
  left: 0;
  bottom: 0;
  width: 220px;
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
  overflow-y: auto;
  z-index: 90;
  padding: 0.75rem 0;
  transition: transform 0.25s ease;
}
.crm-sidebar-section {
  padding: 0.25rem 0.75rem;
}
.crm-sidebar-heading {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ca3af;
  padding: 0.5rem 0.75rem 0.25rem;
}
.crm-sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  text-decoration: none;
  color: #374151;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.crm-sidebar-link:hover {
  background: #f3f4f6;
  color: #1f2937;
}
.crm-sidebar-link.active {
  background: rgba(61,188,201,0.12);
  color: #3dbcC9;
  font-weight: 600;
}
.crm-sidebar-icon {
  width: 1.3rem;
  font-size: 1.1rem;
  text-align: center;
  flex-shrink: 0;
}
.crm-sidebar-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crm-sidebar-action {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  text-decoration: none;
  color: #3dbcC9;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.15s;
}
.crm-sidebar-action:hover {
  background: rgba(61,188,201,0.08);
}
.crm-sidebar-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 0.5rem 0.75rem;
}
.crm-sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: #374151;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}
.crm-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 80;
}

/* ============================================================
   Main content area
   ============================================================ */
.crm-main {
  margin-left: 220px;
  padding: 1.5rem;
  padding-top: calc(48px + 1.5rem);
}

/* ============================================================
   Login page
   ============================================================ */
.crm-login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #f3f4f6 0%, #e0f2f1 100%);
}
.crm-login-container { width: 100%; max-width: 400px; padding: 1rem; }
.crm-login-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 2.5rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.1);
}
.crm-login-header { text-align: center; margin-bottom: 2rem; }
.crm-login-header h1 { font-size: 1.75rem; font-weight: 700; color: #3dbcC9; }
.crm-login-header p { font-size: 0.95rem; color: #6b7280; margin-top: 0.25rem; }
.crm-login-divider {
  display: flex;
  align-items: center;
  margin: 1.25rem 0;
  color: #9ca3af;
  font-size: 0.8rem;
}
.crm-login-divider::before,
.crm-login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e5e7eb;
}
.crm-login-divider span { padding: 0 0.75rem; }

/* ============================================================
   Navigation (sub-nav within pages)
   ============================================================ */
.crm-nav {
  display: flex;
  gap: 0.25rem;
}
.crm-nav-link {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  text-decoration: none;
  color: #6b7280;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}
.crm-nav-link:hover { background: #f3f4f6; color: #1f2937; }
.crm-nav-link.active { background: #3dbcC9; color: #ffffff; }

/* ============================================================
   Status indicators
   ============================================================ */
.crm-status { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; }
.crm-status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.crm-status-dot.online { background: #22c55e; }
.crm-status-dot.offline { background: #ef4444; }

/* ============================================================
   Error banner
   ============================================================ */
.crm-error-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: #991b1b;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ============================================================
   Card grid
   ============================================================ */
.crm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.crm-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border: 2px solid transparent;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  text-decoration: none;
  display: block;
  color: inherit;
}
.crm-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.12); border-color: #3dbcC9; }
.crm-card-title { font-size: 1.1rem; font-weight: 600; color: #1f2937; margin-bottom: 0.5rem; }
.crm-card-value { font-size: 2rem; font-weight: 700; color: #3dbcC9; }
.crm-card-label { font-size: 0.85rem; color: #6b7280; }

/* ============================================================
   Search bar
   ============================================================ */
.crm-search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.crm-search-bar input[type="text"],
.crm-search-bar input[type="search"] {
  flex: 1;
  padding: 0.6rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}
.crm-search-bar input[type="text"]:focus,
.crm-search-bar input[type="search"]:focus { border-color: #3dbcC9; }
.crm-search-bar button {
  padding: 0.6rem 1.25rem;
  background: #3dbcC9;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.crm-search-bar button:hover { background: #2da8b3; }

/* ============================================================
   Filter bar
   ============================================================ */
.crm-filter-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  align-items: center;
}
.crm-filter-bar select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.85rem;
  background: #fff;
  color: #374151;
  outline: none;
}
.crm-filter-bar select:focus { border-color: #3dbcC9; }
.crm-search-input {
  flex: 1;
  min-width: 180px;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s;
}
.crm-search-input:focus { border-color: #3dbcC9; }

/* ============================================================
   Data table
   ============================================================ */
.crm-table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.crm-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: #f9fafb;
  color: #6b7280;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid #e5e7eb;
}
.crm-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f3f4f6;
  font-size: 0.9rem;
  color: #374151;
}
.crm-table tr:hover { background: #f9fafb; }
.crm-table a { color: #3dbcC9; text-decoration: none; font-weight: 500; }
.crm-table a:hover { text-decoration: underline; }

/* ============================================================
   Badges
   ============================================================ */
.crm-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}
.crm-badge-open, .crm-badge-active { background: #dcfce7; color: #166534; }
.crm-badge-closed, .crm-badge-resolved { background: #e5e7eb; color: #374151; }
.crm-badge-escalated, .crm-badge-urgent, .crm-badge-high { background: #fef2f2; color: #991b1b; }
.crm-badge-medium, .crm-badge-warning { background: #fef9c3; color: #854d0e; }
.crm-badge-low, .crm-badge-normal { background: #dbeafe; color: #1e40af; }
.crm-badge-waiting { background: #fef3c7; color: #92400e; }
.crm-badge-new { background: #ede9fe; color: #5b21b6; }
.crm-badge-breached { background: #ef4444; color: #ffffff; }
.crm-badge-email { background: #dbeafe; color: #1e40af; }
.crm-badge-phone { background: #dcfce7; color: #166534; }
.crm-badge-chat, .crm-badge-chatbot { background: #fae8ff; color: #86198f; }
.crm-badge-web, .crm-badge-portal { background: #f3f4f6; color: #374151; }

/* ============================================================
   Pagination
   ============================================================ */
.crm-pagination {
  display: flex;
  justify-content: center;
  gap: 0.25rem;
  margin-top: 1.5rem;
  padding: 0.5rem 0;
}
.crm-pagination a, .crm-pagination span {
  padding: 0.5rem 0.85rem;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  color: #6b7280;
  border: 1px solid #e5e7eb;
  transition: all 0.15s;
}
.crm-pagination a:hover { background: #f3f4f6; color: #1f2937; }
.crm-pagination .active { background: #3dbcC9; color: #ffffff; border-color: #3dbcC9; }

/* ============================================================
   Timeline
   ============================================================ */
.crm-timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.crm-timeline::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #e5e7eb;
}
.crm-timeline-item {
  position: relative;
  padding-left: 2.5rem;
  padding-bottom: 1.25rem;
}
.crm-timeline-dot {
  position: absolute;
  left: 5px;
  top: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #3dbcC9;
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 2px #e5e7eb;
}
.crm-timeline-content { font-size: 0.9rem; color: #374151; }
.crm-timeline-time { font-size: 0.8rem; color: #9ca3af; margin-top: 0.2rem; }

/* ============================================================
   Detail layout
   ============================================================ */
.crm-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.crm-detail-full { grid-column: 1 / -1; }
.crm-detail-section {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.crm-detail-section h3 { font-size: 1.1rem; color: #1f2937; margin-bottom: 1rem; font-weight: 600; }
.crm-field { margin-bottom: 0.75rem; }
.crm-field-label {
  font-size: 0.8rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.crm-field-value { font-size: 0.95rem; color: #1f2937; margin-top: 0.15rem; }

/* ============================================================
   Back link
   ============================================================ */
.crm-back {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: #6b7280;
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.crm-back:hover { color: #3dbcC9; }

/* ============================================================
   Empty state
   ============================================================ */
.crm-empty { text-align: center; padding: 3rem 1rem; color: #9ca3af; font-size: 0.95rem; }

/* ============================================================
   Section title + header actions
   ============================================================ */
.crm-section-title { font-size: 1.5rem; font-weight: 600; color: #1f2937; margin-bottom: 1.5rem; }
.crm-header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* ============================================================
   Buttons
   ============================================================ */
.crm-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}
.crm-btn-primary { background: #3dbcC9; color: #ffffff; border-color: #3dbcC9; }
.crm-btn-primary:hover { background: #2da8b3; border-color: #2da8b3; }
.crm-btn-secondary { background: #f3f4f6; color: #374151; border-color: #d1d5db; }
.crm-btn-secondary:hover { background: #e5e7eb; }
.crm-btn-danger { background: #ef4444; color: #ffffff; border-color: #ef4444; }
.crm-btn-danger:hover { background: #dc2626; border-color: #dc2626; }
.crm-btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

/* ============================================================
   Flash messages
   ============================================================ */
.crm-flash-success {
  background: #dcfce7;
  border: 1px solid #86efac;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: #166534;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}
.crm-flash-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: #991b1b;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* ============================================================
   Forms
   ============================================================ */
.crm-form { max-width: 640px; }
.crm-form-group { margin-bottom: 1rem; flex: 1; }
.crm-form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.3rem;
}
.crm-form-group input,
.crm-form-group select,
.crm-form-group textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #1f2937;
  background: #ffffff;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.crm-form-group input:focus,
.crm-form-group select:focus,
.crm-form-group textarea:focus { border-color: #3dbcC9; }
.crm-form-group textarea { resize: vertical; font-family: inherit; }
.crm-form-row { display: flex; gap: 1rem; }
.crm-form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }

/* Inline form (status change dropdowns) */
.crm-inline-form { display: flex; gap: 0.5rem; align-items: center; }
.crm-inline-form select {
  padding: 0.4rem 0.6rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.85rem;
  background: #fff;
  color: #374151;
  outline: none;
  cursor: pointer;
}
.crm-inline-form select:focus { border-color: #3dbcC9; }

/* ============================================================
   Message thread
   ============================================================ */
.crm-messages {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 0;
  max-height: 500px;
  overflow-y: auto;
}
.crm-message {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  max-width: 75%;
  word-wrap: break-word;
}
.crm-message-inbound {
  align-self: flex-start;
  background: #f3f4f6;
  color: #1f2937;
}
.crm-message-outbound {
  align-self: flex-end;
  background: #3dbcC9;
  color: #ffffff;
}
.crm-message-system {
  align-self: center;
  background: #fef9c3;
  color: #854d0e;
  font-size: 0.85rem;
  max-width: 90%;
}
.crm-message-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.8rem;
  margin-bottom: 0.3rem;
}
.crm-message-inbound .crm-message-meta { color: #6b7280; }
.crm-message-outbound .crm-message-meta { color: rgba(255,255,255,0.8); }
.crm-message-body { font-size: 0.9rem; line-height: 1.5; white-space: pre-wrap; }

/* ============================================================
   Recent items list (dashboard)
   ============================================================ */
.crm-recent-list { list-style: none; padding: 0; margin: 0; }
.crm-recent-item {
  padding: 0.6rem 0;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.crm-recent-item:last-child { border-bottom: none; }
.crm-recent-item a { color: #3dbcC9; text-decoration: none; font-weight: 500; font-size: 0.9rem; }
.crm-recent-item a:hover { text-decoration: underline; }
.crm-recent-meta { font-size: 0.8rem; color: #9ca3af; }

/* ============================================================
   Responsive
   ============================================================ */

/* Tablet: icons-only sidebar */
@media (max-width: 1024px) and (min-width: 769px) {
  .crm-sidebar { width: 60px; }
  .crm-sidebar-label,
  .crm-sidebar-heading { display: none; }
  .crm-sidebar-link,
  .crm-sidebar-action {
    justify-content: center;
    padding: 0.6rem;
  }
  .crm-sidebar-icon { width: auto; font-size: 1.2rem; }
  .crm-main { margin-left: 60px; }
}

/* Mobile: off-screen sidebar, hamburger visible */
@media (max-width: 768px) {
  .crm-sidebar-toggle { display: block; }
  .crm-sidebar {
    transform: translateX(-100%);
    width: 220px;
  }
  .crm-sidebar.open {
    transform: translateX(0);
  }
  .crm-sidebar.open ~ .crm-sidebar-overlay {
    display: block;
  }
  .crm-main {
    margin-left: 0;
    padding: 1rem;
    padding-top: calc(48px + 1rem);
  }
  .crm-topbar-inner { padding: 0 1rem; }
  .crm-detail { grid-template-columns: 1fr; }
  .crm-filter-bar { flex-direction: column; align-items: stretch; }
  .crm-form-row { flex-direction: column; }
  .crm-header-actions { flex-direction: column; align-items: flex-start; }
}

/* ============================================================
   Ticket lock banners
   ============================================================ */
.crm-lock-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}
.crm-lock-icon { font-size: 1.1rem; }
.crm-lock-banner-other {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
}
.crm-lock-banner-mine {
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
}
.crm-lock-banner-available {
  background: #dbeafe;
  border: 1px solid #93c5fd;
  color: #1e40af;
}

/* ============================================================
   Tab bar (queue / conversation views)
   ============================================================ */
.crm-tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid #e5e7eb;
}
.crm-tab-link {
  padding: 0.6rem 1.25rem;
  text-decoration: none;
  color: #6b7280;
  font-weight: 500;
  font-size: 0.9rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s ease;
}
.crm-tab-link:hover { color: #1f2937; border-bottom-color: #d1d5db; }
.crm-tab-link.active { color: #3dbcC9; border-bottom-color: #3dbcC9; }

/* Queue row lock indicators */
.crm-row-locked-other { background: #fff7ed !important; }
.crm-row-locked-mine { background: #f0fdf4 !important; }

/* ============================================================
   Email thread styles
   ============================================================ */
.crm-email-thread {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1rem 0;
}
.crm-email-card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  overflow: hidden;
}
.crm-email-header {
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.crm-email-header-inbound { background: #dbeafe; color: #1e40af; }
.crm-email-header-outbound { background: #dcfce7; color: #166534; }
.crm-email-header-draft { background: #fef3c7; color: #92400e; }
.crm-email-sender { font-weight: 600; font-size: 0.9rem; }
.crm-email-meta { font-size: 0.8rem; display: flex; gap: 0.75rem; align-items: center; }
.crm-email-body {
  padding: 1rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #374151;
}
.crm-email-body img { max-width: 100%; height: auto; }
.crm-email-attachments {
  padding: 0.5rem 1rem 0.75rem;
  border-top: 1px solid #f3f4f6;
  font-size: 0.85rem;
}
.crm-email-attachments a { color: #3dbcC9; text-decoration: none; }
.crm-email-attachments a:hover { text-decoration: underline; }

/* Reply form */
.crm-reply-form {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  margin-top: 1rem;
}
.crm-reply-form h3 { margin-bottom: 0.75rem; }
.crm-textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 100px;
  outline: none;
  margin-bottom: 0.75rem;
  box-sizing: border-box;
}
.crm-textarea:focus { border-color: #3dbcC9; }

/* Qube filing badge */
.crm-badge-filed { background: #dcfce7; color: #166534; }
.crm-badge-skipped { background: #f3f4f6; color: #9ca3af; }
.crm-badge-qube-failed { background: #fef2f2; color: #991b1b; }
.crm-badge-qube-pending { background: #fef9c3; color: #854d0e; }

/* ============================================================
   Workflow badges
   ============================================================ */
.crm-badge-trigger { background: #ede9fe; color: #5b21b6; }
.crm-badge-action { background: #dbeafe; color: #1e40af; }
.crm-badge-branch { background: #fef3c7; color: #92400e; }
.crm-badge-delay { background: #f3f4f6; color: #374151; }
.crm-badge-running { background: #dbeafe; color: #1e40af; }
.crm-badge-completed { background: #dcfce7; color: #166534; }
.crm-badge-failed { background: #fef2f2; color: #991b1b; }
.crm-badge-cancelled { background: #f3f4f6; color: #6b7280; }
.crm-badge-waiting { background: #fef3c7; color: #92400e; }
.crm-badge-skipped { background: #f3f4f6; color: #9ca3af; }
.crm-badge-pending { background: #fef9c3; color: #854d0e; }
.crm-badge-voice { background: #dcfce7; color: #166534; }
.crm-badge-ticket { background: #e5e7eb; color: #374151; }

/* ============================================================
   Contact History (collapsible timeline)
   ============================================================ */
.crm-history-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.crm-history-title-bar h3 { margin-bottom: 0; }
.crm-history-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}
.crm-history-entry {
  border-bottom: 1px solid #e5e7eb;
}
.crm-history-entry:last-child { border-bottom: none; }
.crm-history-entry-current {
  background: #f0fdf4;
}
.crm-history-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  width: 100%;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  color: #374151;
  text-align: left;
  transition: background 0.15s;
}
.crm-history-header:hover { background: #f9fafb; }
.crm-history-header-current:hover { background: #dcfce7; }
.crm-history-toggle {
  font-size: 0.7rem;
  color: #9ca3af;
  transition: transform 0.2s;
  flex-shrink: 0;
  width: 1rem;
  text-align: center;
}
.crm-history-header[aria-expanded="true"] .crm-history-toggle {
  transform: rotate(90deg);
}
.crm-history-date {
  font-size: 0.8rem;
  color: #6b7280;
  white-space: nowrap;
  flex-shrink: 0;
}
.crm-history-summary {
  flex: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crm-history-detail {
  font-size: 0.8rem;
  color: #9ca3af;
  white-space: nowrap;
  flex-shrink: 0;
}
.crm-history-body {
  padding: 0.75rem 1rem 1rem 2.75rem;
  background: #fafafa;
  border-top: 1px solid #e5e7eb;
}
.crm-history-messages {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.crm-history-msg {
  font-size: 0.85rem;
  line-height: 1.5;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  background: #ffffff;
  border-left: 3px solid #d1d5db;
}
.crm-history-msg-inbound { border-left-color: #3b82f6; }
.crm-history-msg-outbound { border-left-color: #22c55e; }
.crm-history-msg-sender {
  font-weight: 600;
  font-size: 0.8rem;
  color: #6b7280;
}
.crm-history-msg-text {
  color: #374151;
}
.crm-history-transcript,
.crm-history-description {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #374151;
  white-space: pre-wrap;
}
.crm-history-empty {
  font-size: 0.85rem;
  color: #9ca3af;
  font-style: italic;
}

/* ============================================================
   Agent Home Dashboard
   ============================================================ */
.crm-agent-home-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.crm-agent-home-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 2px solid transparent;
}
.crm-agent-home-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  border-color: #3dbcC9;
}
.crm-agent-home-card-value {
  font-size: 2rem;
  font-weight: 700;
  color: #3dbcC9;
  line-height: 1.2;
}
.crm-agent-home-card-label {
  font-size: 0.85rem;
  color: #6b7280;
  margin-top: 0.25rem;
}
.crm-agent-home-card--warning .crm-agent-home-card-value { color: #d97706; }
.crm-agent-home-card--danger .crm-agent-home-card-value { color: #ef4444; }

.crm-agent-home-section {
  background: #ffffff;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  margin-bottom: 1.5rem;
}
.crm-agent-home-section h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 1rem;
}
.crm-agent-home-table {
  width: 100%;
  border-collapse: collapse;
}
.crm-agent-home-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  color: #6b7280;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid #e5e7eb;
}
.crm-agent-home-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #f3f4f6;
  font-size: 0.9rem;
  color: #374151;
}
.crm-agent-home-table tr:hover { background: #f9fafb; }
.crm-agent-home-table a { color: #3dbcC9; text-decoration: none; font-weight: 500; }
.crm-agent-home-table a:hover { text-decoration: underline; }

/* ============================================================
   Highlights Bar (ticket/conversation header)
   ============================================================ */
.crm-highlights {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  margin-bottom: 1rem;
  flex-wrap: wrap;
  position: sticky;
  top: calc(48px + 0.5rem);
  z-index: 10;
}
.crm-highlights-number {
  font-weight: 700;
  font-size: 1rem;
  color: #3dbcC9;
}
.crm-highlights-subject {
  font-weight: 600;
  font-size: 1rem;
  color: #1f2937;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crm-highlights-sla {
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
}
.crm-highlights-assignee {
  font-size: 0.85rem;
  color: #6b7280;
  white-space: nowrap;
}

/* ============================================================
   Workspace — Three-column layout
   ============================================================ */
.crm-workspace {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  min-height: calc(100vh - 48px - 6rem);
}
.crm-workspace-center {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.crm-workspace-context {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: calc(48px + 1.5rem);
  max-height: calc(100vh - 48px - 3rem);
  overflow-y: auto;
  transition: width 0.25s ease, opacity 0.25s ease;
}
.crm-workspace-context.collapsed {
  width: 0;
  overflow: hidden;
  opacity: 0;
  gap: 0;
}
.crm-workspace-context-section {
  background: #ffffff;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.crm-workspace-context-section h3 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
  margin-bottom: 0.75rem;
}

/* Context panel toggle */
.crm-context-toggle {
  position: fixed;
  right: 1rem;
  top: calc(48px + 0.75rem);
  z-index: 20;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: #6b7280;
  transition: background 0.15s, color 0.15s;
}
.crm-context-toggle:hover {
  background: #f3f4f6;
  color: #1f2937;
}

/* ============================================================
   Composer (reply / internal note)
   ============================================================ */
.crm-composer {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  overflow: hidden;
}
.crm-composer-tabs {
  display: flex;
  border-bottom: 2px solid #e5e7eb;
}
.crm-composer-tab {
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s ease;
}
.crm-composer-tab:hover { color: #1f2937; }
.crm-composer-tab.active {
  color: #3dbcC9;
  border-bottom-color: #3dbcC9;
}
.crm-composer-tab--note.active {
  color: #d97706;
  border-bottom-color: #d97706;
}
.crm-composer-body {
  padding: 1rem;
}
.crm-composer-body[hidden] { display: none; }
.crm-composer-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.crm-composer-toolbar .crm-btn { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.crm-composer-textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 120px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.crm-composer-textarea:focus { border-color: #3dbcC9; }
.crm-composer-body--note .crm-composer-textarea {
  background: #fffbeb;
  border-color: #fcd34d;
}
.crm-composer-body--note .crm-composer-textarea:focus { border-color: #d97706; }
.crm-composer-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid #f3f4f6;
  background: #fafafa;
}

/* Send + Status group */
.crm-send-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}
.crm-send-status {
  padding: 0.5rem 0.6rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.85rem;
  background: #fff;
  color: #374151;
  outline: none;
  cursor: pointer;
}
.crm-send-status:focus { border-color: #3dbcC9; }

/* Canned responses dropdown */
.crm-canned-dropdown {
  position: relative;
  display: inline-block;
}
.crm-canned-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 30;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  min-width: 260px;
  max-height: 240px;
  overflow-y: auto;
  margin-top: 0.25rem;
}
.crm-canned-menu.open { display: block; }
.crm-canned-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border: none;
  background: none;
  font-size: 0.85rem;
  color: #374151;
  cursor: pointer;
  transition: background 0.1s;
}
.crm-canned-item:hover { background: #f3f4f6; }
.crm-canned-item-title { font-weight: 600; }
.crm-canned-item-shortcut { color: #9ca3af; font-size: 0.8rem; }
.crm-canned-search {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 0.85rem;
  margin-bottom: 4px;
  box-sizing: border-box;
}
.crm-canned-search:focus {
  outline: none;
  border-color: #3b82f6;
}
.crm-canned-items {
  max-height: 200px;
  overflow-y: auto;
}
.crm-canned-empty {
  padding: 0.75rem;
  text-align: center;
  color: #9ca3af;
  font-size: 0.85rem;
}

/* Close NFA */
.crm-close-nfa { display: inline-flex; }

/* ============================================================
   Internal note message in thread
   ============================================================ */
.crm-email-header-note {
  background: repeating-linear-gradient(
    -45deg,
    #fffbeb,
    #fffbeb 8px,
    #fef3c7 8px,
    #fef3c7 16px
  );
  color: #92400e;
}

/* ============================================================
   SLA countdown
   ============================================================ */
.crm-sla-countdown { font-weight: 600; }
.crm-sla-countdown--green { color: #16a34a; }
.crm-sla-countdown--amber { color: #d97706; }
.crm-sla-countdown--red { color: #ef4444; }
.crm-sla-countdown--breached { color: #ef4444; font-weight: 700; }

/* ============================================================
   Context panel field rows
   ============================================================ */
.crm-ctx-field {
  margin-bottom: 0.6rem;
}
.crm-ctx-field-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.crm-ctx-field-value {
  font-size: 0.9rem;
  color: #1f2937;
  margin-top: 0.1rem;
}
.crm-ctx-field-value a { color: #3dbcC9; text-decoration: none; }
.crm-ctx-field-value a:hover { text-decoration: underline; }
.crm-ctx-select {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.85rem;
  background: #fff;
  color: #374151;
  outline: none;
  cursor: pointer;
}
.crm-ctx-select:focus { border-color: #3dbcC9; }

/* ============================================================
   Responsive overrides for new components
   ============================================================ */
@media (max-width: 1024px) {
  .crm-agent-home-cards { grid-template-columns: repeat(2, 1fr); }
  .crm-workspace-context { width: 240px; }
}
@media (max-width: 768px) {
  .crm-agent-home-cards { grid-template-columns: 1fr; }
  .crm-workspace { flex-direction: column; }
  .crm-workspace-context {
    width: 100%;
    position: static;
    max-height: none;
  }
  .crm-workspace-context.collapsed { display: none; }
  .crm-context-toggle { position: static; margin-bottom: 0.5rem; }
  .crm-highlights { position: static; }
  .crm-global-search { display: none; }
}

/* ============================================================
   Toast notifications
   ============================================================ */
.crm-toast-container {
  position: fixed;
  top: 56px;
  right: 1rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.crm-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  animation: crm-toast-in 0.3s ease forwards;
  max-width: 380px;
}
.crm-toast-success {
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
}
.crm-toast-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}
.crm-toast-warning {
  background: #fef9c3;
  border: 1px solid #fde68a;
  color: #854d0e;
}
.crm-toast-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  padding: 0 0.25rem;
  line-height: 1;
}
.crm-toast-close:hover { opacity: 1; }
.crm-toast.crm-toast-out {
  animation: crm-toast-out 0.3s ease forwards;
}
@keyframes crm-toast-in {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes crm-toast-out {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(100%); opacity: 0; }
}

/* ============================================================
   Breadcrumbs
   ============================================================ */
.crm-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: #6b7280;
}
.crm-breadcrumb a {
  color: #6b7280;
  text-decoration: none;
  transition: color 0.15s;
}
.crm-breadcrumb a:hover { color: #3dbcC9; }
.crm-breadcrumb-sep { color: #d1d5db; }
.crm-breadcrumb-current {
  color: #1f2937;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}

/* ============================================================
   Global search (topbar)
   ============================================================ */
.crm-global-search {
  position: relative;
  flex: 1;
  max-width: 360px;
  margin: 0 1rem;
}
.crm-global-search-input {
  width: 100%;
  padding: 0.4rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.85rem;
  outline: none;
  background: #f9fafb;
  transition: border-color 0.15s, background 0.15s;
}
.crm-global-search-input:focus {
  border-color: #3dbcC9;
  background: #ffffff;
}
.crm-global-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 300;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  margin-top: 0.25rem;
  max-height: 400px;
  overflow-y: auto;
}
.crm-global-search-group {
  padding: 0.4rem 0.75rem 0.2rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9ca3af;
  background: #f9fafb;
  border-bottom: 1px solid #f3f4f6;
}
.crm-global-search-item {
  display: block;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  color: #374151;
  font-size: 0.85rem;
  border-bottom: 1px solid #f3f4f6;
  transition: background 0.1s;
}
.crm-global-search-item:hover { background: #f3f4f6; }
.crm-global-search-item:last-child { border-bottom: none; }
.crm-global-search-item strong { color: #1f2937; }
.crm-global-search-empty {
  padding: 1rem;
  text-align: center;
  color: #9ca3af;
  font-size: 0.85rem;
}

/* ============================================================
   Bulk action bar
   ============================================================ */
.crm-bulk-bar {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #dbeafe;
  border: 1px solid #93c5fd;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: #1e40af;
}
.crm-bulk-bar.visible { display: flex; }
.crm-bulk-count { font-weight: 600; }
.crm-bulk-bar select {
  padding: 0.4rem 0.6rem;
  border: 1px solid #93c5fd;
  border-radius: 6px;
  font-size: 0.85rem;
  background: #fff;
  color: #374151;
}

/* ============================================================
   Keyboard shortcuts modal
   ============================================================ */
.crm-shortcuts-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  align-items: center;
  justify-content: center;
}
.crm-shortcuts-overlay.visible { display: flex; }
.crm-shortcuts-modal {
  background: #ffffff;
  border-radius: 12px;
  padding: 1.5rem 2rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  max-width: 420px;
  width: 90%;
}
.crm-shortcuts-modal h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 1rem;
}
.crm-shortcuts-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.crm-shortcuts-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  font-size: 0.9rem;
  color: #374151;
  border-bottom: 1px solid #f3f4f6;
}
.crm-shortcuts-list li:last-child { border-bottom: none; }
kbd {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: #374151;
  line-height: 1.4;
}

/* ============================================================
   Unread indicators (conversation list)
   ============================================================ */
.crm-row-unread { background: #eff6ff; }
.crm-row-unread:hover { background: #dbeafe; }
.crm-link-bold { font-weight: 700; }
.crm-badge-unread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.3rem;
  height: 1.3rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: #3b82f6;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
  margin-left: 0.4rem;
  vertical-align: middle;
}

/* ============================================================
   Draft feedback UI (conversation detail)
   ============================================================ */
.crm-draft-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 1rem 0.75rem;
  border-top: 1px solid #fef3c7;
  background: #fffbeb;
}
.crm-draft-actions .crm-btn { font-size: 0.8rem; padding: 0.3rem 0.75rem; }
.crm-btn-approve { background: #16a34a; color: #fff; border: none; border-radius: 6px; cursor: pointer; }
.crm-btn-approve:hover { background: #15803d; }
.crm-btn-amend { background: #d97706; color: #fff; border: none; border-radius: 6px; cursor: pointer; }
.crm-btn-amend:hover { background: #b45309; }
.crm-btn-reject { background: #ef4444; color: #fff; border: none; border-radius: 6px; cursor: pointer; }
.crm-btn-reject:hover { background: #dc2626; }
.crm-draft-feedback-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}
.crm-draft-feedback-approved { background: #dcfce7; color: #166534; }
.crm-draft-feedback-amended { background: #fef3c7; color: #92400e; }
.crm-draft-feedback-rejected { background: #fef2f2; color: #991b1b; }

/* ============================================================
   SLA column in list tables
   ============================================================ */
.crm-table .crm-sla-cell { white-space: nowrap; }

/* ============================================================
   Reports & Analytics
   ============================================================ */
.crm-report-nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e5e7eb;
  margin-bottom: 1.5rem;
}
.crm-report-tab {
  padding: 0.5rem 1rem;
  color: #6b7280;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.crm-report-tab:hover { color: #1f2937; }
.crm-report-tab.active {
  color: #3b82f6;
  border-bottom-color: #3b82f6;
}

.crm-report-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.crm-report-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1.25rem;
  text-align: center;
}
.crm-report-card-sm { padding: 0.75rem; }
.crm-report-card-label {
  font-size: 0.8rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.25rem;
}
.crm-report-card-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: #1f2937;
}
.crm-report-card-sub {
  font-size: 0.8rem;
  color: #9ca3af;
  margin-top: 0.25rem;
}

.crm-report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.crm-report-section {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.crm-report-section h3 {
  font-size: 0.95rem;
  color: #374151;
  margin: 0 0 1rem 0;
}

/* CSS bar charts */
.crm-bar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.crm-bar-label {
  font-size: 0.85rem;
  color: #374151;
  min-width: 80px;
  flex-shrink: 0;
}
.crm-bar-track {
  flex: 1;
  height: 20px;
  background: #f3f4f6;
  border-radius: 4px;
  overflow: hidden;
}
.crm-bar-fill {
  height: 100%;
  background: #3b82f6;
  border-radius: 4px;
  min-width: 2px;
  transition: width 0.3s;
}
.crm-bar-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1f2937;
  min-width: 40px;
  text-align: right;
}

/* Status-coloured bars */
.crm-bar-new { background: #3b82f6; }
.crm-bar-open { background: #f59e0b; }
.crm-bar-waiting { background: #8b5cf6; }
.crm-bar-escalated { background: #ef4444; }
.crm-bar-resolved { background: #10b981; }
.crm-bar-closed { background: #6b7280; }

/* Priority-coloured bars */
.crm-bar-low { background: #10b981; }
.crm-bar-medium { background: #f59e0b; }
.crm-bar-high { background: #f97316; }
.crm-bar-urgent { background: #ef4444; }

/* Channel-coloured bars */
.crm-bar-email { background: #3b82f6; }
.crm-bar-phone { background: #10b981; }
.crm-bar-chatbot { background: #8b5cf6; }
.crm-bar-portal { background: #f59e0b; }
.crm-bar-web { background: #6b7280; }

/* Conditional text colours */
.crm-text-green { color: #16a34a; }
.crm-text-amber { color: #d97706; }
.crm-text-red { color: #ef4444; }

/* Admin form styles */
.crm-admin-form {
  max-width: 600px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1.5rem;
}
.crm-admin-form .crm-form-group {
  margin-bottom: 1rem;
}
.crm-admin-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.25rem;
}
.crm-admin-form input[type="text"],
.crm-admin-form input[type="number"],
.crm-admin-form textarea,
.crm-admin-form select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9rem;
}
.crm-admin-form textarea {
  min-height: 100px;
  resize: vertical;
}
.crm-admin-form .crm-form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.crm-admin-form .crm-form-check input[type="checkbox"] {
  width: auto;
}

/* Contact merge side-by-side */
.crm-merge-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.crm-merge-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1.25rem;
}
.crm-merge-card h3 {
  margin: 0 0 0.75rem 0;
  font-size: 1rem;
  color: #374151;
}
.crm-merge-field {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 0.85rem;
}
.crm-merge-field-label { color: #6b7280; }
.crm-merge-field-value { color: #1f2937; font-weight: 500; }

/* ── Mobile Bottom Navigation ─────────────────────────────────── */
.crm-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  z-index: 100;
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.crm-bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 4px 8px;
  color: #6b7280;
  text-decoration: none;
  font-size: 0.65rem;
  gap: 2px;
}
.crm-bottom-nav-item.active { color: #3dbcc9; }
.crm-bottom-nav-icon { font-size: 1.25rem; }
.crm-bottom-nav-label { font-size: 0.6rem; }

@media (max-width: 768px) {
  .crm-bottom-nav { display: flex; }
  .crm-sidebar { display: none !important; }
  .crm-sidebar-toggle { display: none !important; }
  .crm-sidebar-overlay { display: none !important; }
  .crm-main { margin-left: 0 !important; padding-bottom: 70px; }

  /* Touch-friendly targets */
  .crm-btn, .crm-select, .crm-tab-link, .crm-filter-bar button,
  .crm-pagination a, .crm-report-tab {
    min-height: 44px;
    min-width: 44px;
    padding: 10px 14px;
  }

  /* Prevent iOS zoom on input focus */
  input, select, textarea { font-size: 16px !important; }

  /* Stack table rows as cards */
  .crm-table thead { display: none; }
  .crm-table, .crm-table tbody, .crm-table tr, .crm-table td {
    display: block;
    width: 100%;
  }
  .crm-table tr {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    padding: 0.75rem;
    background: #fff;
  }
  .crm-table td {
    padding: 0.25rem 0;
    border: none;
  }
  .crm-table td:first-child { font-weight: 600; }

  /* Report cards stack */
  .crm-report-cards { grid-template-columns: 1fr !important; }
}
