/* ============================================================
   Gydon CRM – Application Stylesheet
   v3.1 — Enterprise (matches legacy design)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;600;700&display=swap');


/* ------------------------------------------------------------
   1. Theme tokens
   ------------------------------------------------------------ */
:root {
  /* Brand / accent — dark navy */
  --g-accent:                #092B4A;
  --g-accent-hover:          #0c3a6b;
  --g-accent-light:          rgba(9, 43, 74, 0.07);
  --g-accent-rgb:            9, 43, 74;

  /* Superbar */
  --g-superbar-height:       50px;
  --g-superbar-bg:           #1a4068;

  /* Sidebar */
  --g-sidebar-bg:            #091e34;
  --g-sidebar-width:         185px;
  --g-sidebar-link-color:    rgba(255,255,255,0.80);
  --g-sidebar-link-hover-bg: rgba(255,255,255,0.07);
  --g-sidebar-section-color: rgba(255,255,255,0.35);
  --g-sidebar-logo-height:   34px;

  /* App shell */
  --g-body-bg:               #f0f2f5;
  --g-topbar-bg:             #ffffff;
  --g-topbar-border:         #e2e8f0;
  --g-topbar-shadow:         0 2px 4px rgba(0,0,0,0.08);

  /* Cards */
  --g-card-radius:           8px;
  --g-card-shadow:           0 2px 20px rgba(0,0,0,0.08);
  --g-card-shadow-hover:     0 4px 25px rgba(0,0,0,0.13);

  /* Login page */
  --g-login-page-bg:         #092B4A;
  --g-login-card-shadow:     0 16px 48px rgba(0,0,0,0.30);
  --g-login-logo-height:     48px;

  /* Typography */
  --g-font-xs:               0.72rem;
  --g-font-sm:               0.8125rem;
  --g-font-badge-xs:         0.64rem;
  --g-font-badge-sm:         0.78rem;

  /* Component sizing */
  --g-select-type-width:       110px;
  --g-select-type-wide-width:  120px;
  --g-select-platform-width:   130px;
  --g-timeline-icon-size:      36px;
  --g-search-input-min-width:  220px;
}


/* ------------------------------------------------------------
   2. Base & typography
   ------------------------------------------------------------ */
body {
  font-family: 'Roboto', 'Segoe UI', sans-serif;
  background: var(--g-body-bg);
  color: #1e293b;
  font-size: 0.875rem;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
  font-weight: 600;
  color: #1e293b;
}

/* Bootstrap primary → corporate blue accent */
.btn-primary {
  background-color: var(--g-accent);
  border-color: var(--g-accent);
}
.btn-primary:hover, .btn-primary:active, .btn-primary:focus {
  background-color: var(--g-accent-hover);
  border-color: var(--g-accent-hover);
}
.btn-outline-primary { color: var(--g-accent); border-color: var(--g-accent); }
.btn-outline-primary:hover { background-color: var(--g-accent); border-color: var(--g-accent); color: #fff; }
.text-primary { color: var(--g-accent) !important; }
.bg-primary { background-color: var(--g-accent) !important; }
a { color: var(--g-accent); }
a:hover { color: var(--g-accent-hover); }

/* Controls */
.btn { border-radius: 10px; font-weight: 500; font-size: 0.8125rem; }
.btn-sm { border-radius: 6px; font-size: 0.78rem; }
.btn-lg { border-radius: 10px; }
.btn-primary:focus { box-shadow: 0 0 0 0.25rem rgba(9, 43, 74, 0.35); }

.form-control, .form-select, .input-group-text {
  border-radius: 10px;
  border-color: #e2e8f0;
  font-size: 0.8125rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--g-accent);
  box-shadow: 0 0 0 0.25rem rgba(var(--g-accent-rgb), 0.25);
}
.form-control-sm, .form-select-sm { border-radius: 8px; }
.input-group-text { background-color: #f5f5f5; border-color: #e2e8f0; font-size: 0.8125rem; }

/* Cards */
.card {
  border: 1px solid #e3e6ea;
  border-radius: var(--g-card-radius);
  box-shadow: var(--g-card-shadow);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid rgba(0,0,0,0.1);
  border-radius: var(--g-card-radius) var(--g-card-radius) 0 0 !important;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #1e293b;
}
.card-body { padding: 1rem; }

/* Tables */
.table { font-size: 0.8125rem; margin-bottom: 0; }
.table thead th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  padding: 0.5rem 0.75rem;
  white-space: nowrap;
}
.table td { padding: 0.5rem 0.75rem; vertical-align: middle; border-color: #f1f5f9; }
.table-hover > tbody > tr:hover > * { background-color: #f8fafc; }

/* Badges */
.badge { font-weight: 500; letter-spacing: 0.01em; border-radius: 6px; }

/* Alerts */
.alert { border-radius: 12px; border: none; font-size: 0.875rem; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
.alert-success { background: #d1fae5; color: #10b981; }
.alert-danger  { background: #fee2e2; color: #ef4444; }
.alert-warning { background: #fef3c7; color: #f59e0b; }
.alert-info    { background: #dbeafe; color: #1e40af; }

/* Dropdowns */
.dropdown-menu {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
  padding: 0.25rem;
  font-size: 0.8125rem;
}
.dropdown-item {
  border-radius: 4px;
  padding: 0.4rem 0.65rem;
  font-size: 0.8125rem;
  color: #1e293b;
}
.dropdown-item:hover { background: #f1f5f9; color: #0f172a; }
.dropdown-item.active, .dropdown-item:active { background: var(--g-accent); color: #fff; }
.dropdown-divider { margin: 0.25rem 0; border-color: #f1f5f9; }
.dropdown-header { font-size: 0.6875rem; color: #94a3b8; padding: 0.35rem 0.65rem; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }


/* ------------------------------------------------------------
   3. Superbar
   ------------------------------------------------------------ */
.superbar {
  position: fixed;
  top: 0;
  left: var(--g-sidebar-width);
  right: 0;
  height: var(--g-superbar-height);
  background: var(--g-superbar-bg);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 1rem;
  gap: 0.25rem;
  border-bottom: 1px solid rgba(0,0,0,0.15);
}

.superbar .btn-superbar {
  color: rgba(255,255,255,0.75);
  background: transparent;
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: color .15s, background .15s;
  font-family: inherit;
}
.superbar .btn-superbar:hover,
.superbar .btn-superbar.show {
  color: #fff;
  background: rgba(255,255,255,0.1);
}
.superbar .dropdown-menu {
  font-size: 0.8rem;
  min-width: 180px;
}

/* Quick-add (+) button */
.superbar .btn-superbar-add {
  width: auto;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1.5px solid rgba(255,255,255,0.3);
  border-radius: 8px;
  color: rgba(255,255,255,0.75);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
  padding: 0 0.75rem;
  gap: 0.35rem;
  font-family: inherit;
  line-height: 1;
  white-space: nowrap;
}
.superbar .btn-superbar-add:hover,
.superbar .btn-superbar-add.show {
  color: #fff;
  border-color: rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.08);
}
.superbar .quick-add-menu {
  min-width: 210px;
  font-size: 0.8rem;
  padding: 0.35rem 0;
}
.superbar .quick-add-menu .dropdown-header {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  padding: 0.4rem 1rem 0.2rem;
}
.superbar .quick-add-menu .dropdown-item {
  padding: 0.35rem 1rem;
  font-weight: 500;
}
.superbar .quick-add-menu .dropdown-item:hover {
  background: var(--g-accent-light);
}
.superbar .quick-add-menu .dropdown-divider {
  margin: 0.3rem 0;
}

/* Activity modal overrides */
#activityModal .modal-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e2e8f0;
}
#activityModal .modal-title {
  font-size: 0.9rem;
  color: var(--g-accent);
}
#activityModal .modal-body {
  padding: 1rem;
}
#activityModal .modal-footer {
  padding: 0.5rem 1rem;
  border-top: 1px solid #e2e8f0;
}

/* Toast overrides */
#globalToast {
  font-size: 0.8125rem;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}

/* Notification bell badge */
.notif-badge {
  position: absolute;
  top: 2px; right: 2px;
  min-width: 16px; height: 16px;
  font-size: 0.6rem; font-weight: 700;
  line-height: 16px; text-align: center;
  padding: 0 4px;
  border-radius: 999px;
  background: #ef4444; color: #fff;
}

/* Notification dropdown panel */
.notif-panel { border-radius: 10px !important; overflow: hidden; box-shadow: 0 8px 32px rgba(0,0,0,0.18) !important; }
.notif-panel-header { border-bottom: 1px solid rgba(0,0,0,0.08); font-size: 0.875rem; }
.notif-panel-footer { font-size: 0.8125rem; }
.notif-panel-footer a { color: var(--g-accent); }
.notif-panel-footer a:hover { background: var(--g-accent-light); }

.notif-item {
  display: flex; align-items: flex-start; gap: 0.65rem;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  text-decoration: none; color: inherit;
  transition: background 0.15s;
}
.notif-item:hover { background: rgba(0,0,0,0.03); }
.notif-item:not(.read) { background: rgba(59,130,246,0.04); }
.notif-item.read { opacity: 0.7; }

.notif-icon {
  width: 32px; height: 32px; min-width: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; color: #fff;
}
.notif-icon.bg-primary   { background: #3b82f6 !important; }
.notif-icon.bg-success   { background: #10b981 !important; }
.notif-icon.bg-danger    { background: #ef4444 !important; }
.notif-icon.bg-warning   { background: #f59e0b !important; color: #fff !important; }
.notif-icon.bg-info      { background: #0ea5e9 !important; }
.notif-icon.bg-secondary { background: #64748b !important; }

.notif-content { min-width: 0; flex: 1; overflow: hidden; }
.notif-title   { display: block; font-size: 0.8125rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-message { display: block; font-size: 0.75rem; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-time    { display: block; font-size: 0.68rem; color: #94a3b8; margin-top: 2px; }

/* Dismiss button in dropdown */
.notif-item-wrap { position: relative; display: flex; align-items: stretch; }
.notif-item-wrap .notif-item { flex: 1; }
.notif-dismiss-btn {
  display: none;
  position: absolute; top: 0; right: 0;
  width: 28px; height: 100%;
  background: none; border: none; padding: 0;
  color: #94a3b8; font-size: 1rem; cursor: pointer;
  align-items: center; justify-content: center;
}
.notif-dismiss-btn:hover { color: #ef4444; }
.notif-item-wrap:hover .notif-dismiss-btn { display: flex; }

/* Full page notification list */
.notif-page-item { border-bottom: 1px solid rgba(0,0,0,0.06); transition: background 0.15s; }
.notif-page-item:hover { background: rgba(0,0,0,0.02); }
.notif-page-item.unread { background: rgba(59,130,246,0.04); }
.notif-page-item.unread:hover { background: rgba(59,130,246,0.07); }
.notif-page-dismiss {
  opacity: 0;
  color: #94a3b8;
  transition: opacity 0.15s;
  text-decoration: none;
  border-left: 1px solid rgba(0,0,0,0.06);
}
.notif-page-item:hover .notif-page-dismiss { opacity: 1; }
.notif-page-dismiss:hover { color: #ef4444 !important; }
.notif-unread-dot {
  width: 8px; height: 8px; min-width: 8px;
  border-radius: 50%; background: #3b82f6;
  display: inline-block;
}


/* ------------------------------------------------------------
   4. Sidebar
   ------------------------------------------------------------ */
.sidebar {
  width: var(--g-sidebar-width);
  min-height: 100vh;
  background: var(--g-sidebar-bg);
  padding-top: 0;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(0,0,0,0.2);
}

.sidebar .brand {
  color: #fff;
  font-size: 1.125rem;
  font-weight: 700;
  padding: 0.875rem 1.125rem 0.875rem;
  display: block;
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 0.375rem;
}

.sidebar-logo {
  max-height: var(--g-sidebar-logo-height);
  max-width: 100%;
  width: auto;
}

.sidebar .nav-link {
  color: var(--g-sidebar-link-color);
  border-radius: 8px;
  margin: 2px 0.5rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background .15s, color .15s;
}

.sidebar .nav-link i {
  font-size: 0.95rem;
  opacity: 0.75;
  flex-shrink: 0;
}

.sidebar .nav-link:hover {
  background: var(--g-sidebar-link-hover-bg);
  color: #fff;
}

.sidebar .nav-link:hover i {
  opacity: 1;
}

.sidebar .nav-link.active {
  background: rgba(59,130,246,0.18);
  color: #fff;
  font-weight: 500;
  box-shadow: inset 3px 0 0 #60a5fa;
}

.sidebar .nav-link.active i {
  opacity: 1;
  color: #93c5fd;
}

.sidebar .nav-section {
  color: var(--g-sidebar-section-color);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 1rem 1.25rem 0.25rem;
}


/* ------------------------------------------------------------
   5. App shell — main content area
   ------------------------------------------------------------ */
.main {
  margin-left: var(--g-sidebar-width);
  padding: 1.5rem;
  padding-top: calc(var(--g-superbar-height) + 1.5rem);
  min-height: 100vh;
}

.topbar {
  background: var(--g-topbar-bg);
  border-bottom: 1px solid var(--g-topbar-border);
  box-shadow: var(--g-topbar-shadow);
  padding: 0.75rem 1.5rem;
  margin: -1.5rem -1.5rem 1.5rem;
  display: flex;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
}

.topbar h6 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0;
}


/* ------------------------------------------------------------
   6. Login page
   ------------------------------------------------------------ */
.login-page {
  background: var(--g-login-page-bg);
}

.login-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.login-logo {
  max-height: var(--g-login-logo-height);
  width: auto;
  margin-bottom: 1.5rem;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--g-login-card-shadow);
}

.login-subtitle {
  text-align: center;
  color: #64748b;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}


/* ------------------------------------------------------------
   7. TomSelect overrides
   ------------------------------------------------------------ */
.ts-wrapper.single .ts-control {
  background: #fff;
  border-radius: 10px;
}

.ts-dropdown {
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
}

.ts-opt {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.ts-opt-sub {
  color: #64748b;
  font-size: 0.75rem;
  margin-left: auto;
}

.ts-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}


/* ------------------------------------------------------------
   8. Stat cards
   ------------------------------------------------------------ */
.stat-card {
  display: block;
  text-decoration: none;
}

.stat-card .card {
  transition: box-shadow .3s ease, transform .3s ease;
  border: 1px solid #e3e6ea;
}

.stat-card:hover .card {
  box-shadow: var(--g-card-shadow-hover) !important;
  transform: translateY(-2px);
}

.stat-card__icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  font-size: 1.2rem;
}

/* Gradient icon backgrounds */
.stat-card__icon--blue    { background: linear-gradient(135deg, #3b82f6, #1e40af); }
.stat-card__icon--green   { background: linear-gradient(135deg, #10b981, #059669); }
.stat-card__icon--amber   { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-card__icon--red     { background: linear-gradient(135deg, #ef4444, #dc2626); }
.stat-card__icon--purple  { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.stat-card__icon--cyan    { background: linear-gradient(135deg, #06b6d4, #0284c7); }
.stat-card__icon--indigo  { background: linear-gradient(135deg, #6366f1, #4338ca); }
.stat-card__icon--orange  { background: linear-gradient(135deg, #f97316, #c2410c); }
.stat-card__icon--slate   { background: linear-gradient(135deg, #64748b, #334155); }
.stat-card__icon--teal    { background: linear-gradient(135deg, #14b8a6, #0f766e); }

.stat-card__primary {
  font-size: 1.3rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.2;
}

.stat-card__secondary {
  font-size: .875rem;
  font-weight: 600;
  color: #10b981;
}

.stat-card__label {
  font-size: .8rem;
  color: #64748b;
  margin-top: .1rem;
}


/* ------------------------------------------------------------
   9. Timeline
   ------------------------------------------------------------ */
.timeline-icon {
  width: var(--g-timeline-icon-size);
  height: var(--g-timeline-icon-size);
}

.timeline-meta {
  font-size: var(--g-font-xs);
}


/* ------------------------------------------------------------
   10. Badges & Status Badges
   ------------------------------------------------------------ */
.badge-xs { font-size: var(--g-font-badge-xs); }
.badge-sm { font-size: var(--g-font-badge-sm); }

/* Single unified pill / badge system
   All badges share identical shape, size and spacing.
   Colour applied via .bg-{colour} helpers below.
   Dot-status variants use .status-badge-* + an <i> dot element. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  white-space: nowrap;
}

/* Pastel bg + vivid text — canonical colour palette */
.badge.bg-primary   { background-color: #dbeafe !important; color: #1e40af !important; }
.badge.bg-info      { background-color: #e0f2fe !important; color: #0369a1 !important; }
.badge.bg-success   { background-color: #d1fae5 !important; color: #10b981 !important; }
.badge.bg-warning   { background-color: #fef3c7 !important; color: #f59e0b !important; }
.badge.bg-danger    { background-color: #fee2e2 !important; color: #ef4444 !important; }
.badge.bg-secondary { background-color: #f1f5f9 !important; color: #475569 !important; }

/* Status-badge aliases — identical look, exist for semantic clarity + dot support */
.status-badge-primary,
.status-badge-info,
.status-badge-teal,
.status-badge-success,
.status-badge-warning,
.status-badge-danger,
.status-badge-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
}

.status-badge-primary   { background-color: #dbeafe; color: #1e40af; }
.status-badge-info      { background-color: #e0f2fe; color: #0369a1; }
.status-badge-teal      { background-color: #ccfbf1; color: #0d9488; }
.status-badge-success   { background-color: #d1fae5; color: #10b981; }
.status-badge-warning   { background-color: #fef3c7; color: #f59e0b; }
.status-badge-danger    { background-color: #fee2e2; color: #ef4444; }
.status-badge-secondary { background-color: #f1f5f9; color: #475569; }

/* Dot inside status badge */
.status-badge-primary i,
.status-badge-info i,
.status-badge-teal i,
.status-badge-success i,
.status-badge-warning i,
.status-badge-danger i,
.status-badge-secondary i {
  font-size: 0.4rem;
}


/* ------------------------------------------------------------
   11. Form helpers
   ------------------------------------------------------------ */
.search-input     { min-width: var(--g-search-input-min-width); }
.select-type      { width: var(--g-select-type-width); }
.select-type-wide { width: var(--g-select-type-wide-width); }
.select-platform  { width: var(--g-select-platform-width); }


/* ------------------------------------------------------------
   12. Utilities
   ------------------------------------------------------------ */
.cursor-pointer { cursor: pointer; }

.shadow-sm  { box-shadow: var(--g-card-shadow) !important; }
.shadow     { box-shadow: 0 1px 3px rgba(0,0,0,0.10), 0 4px 12px rgba(0,0,0,0.05) !important; }
.shadow-lg  { box-shadow: var(--g-card-shadow-hover) !important; }

.text-muted { color: #64748b !important; }
.border     { border-color: #e2e8f0 !important; }
.bg-light   { background-color: #f5f5f5 !important; }


/* ------------------------------------------------------------
   13. Kanban board
   ------------------------------------------------------------ */
.kanban-board {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding-bottom: 1rem;
}

.kanban-col {
  flex: 1 1 0;
  min-width: 150px;
  background: #f0f2f5;
  border-radius: 8px;
  border: 1px solid #e3e6ea;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 148px);
}

.kanban-col-header {
  display: flex;
  align-items: center;
  padding: 0.6rem 0.85rem;
  font-weight: 600;
  font-size: 0.8rem;
  border-bottom: 1px solid #e3e6ea;
  background: #fff;
  border-radius: 8px 8px 0 0;
  gap: 0.35rem;
}

.kanban-stage-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.kanban-stage-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kanban-col-value {
  font-size: .75rem;
  font-weight: 600;
  color: #475569;
  padding: .2rem .85rem;
  border-bottom: 1px solid #e3e6ea;
  background: #fff;
}

.kanban-cards {
  flex: 1;
  overflow-y: auto;
  padding: .375rem;
  display: flex;
  flex-direction: column;
  gap: .375rem;
  min-height: 80px;
}

.deal-card {
  background: #fff;
  border: 1px solid #e3e6ea;
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  cursor: grab;
  position: relative;
  transition: box-shadow .3s ease, transform .3s ease;
}

.deal-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.10);
  transform: translateY(-1px);
}

.deal-card--closed { opacity: .65; }

.deal-card--ghost {
  opacity: .4;
  background: #dbeafe;
  border: 2px dashed #3b82f6;
}

.deal-card--drag {
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
  cursor: grabbing;
}

.deal-card-title {
  font-weight: 600;
  font-size: .8125rem;
  display: block;
  color: #1e293b;
  text-decoration: none;
  margin-bottom: .25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deal-card-title:hover { color: var(--g-accent); }

.deal-card-contact {
  display: flex;
  align-items: center;
  gap: .3rem;
  font-size: .75rem;
  margin-bottom: .35rem;
  color: #64748b;
}

.deal-card-footer {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .6875rem;
}

.deal-card-value { font-weight: 600; color: #059669; }

.deal-card-owner {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--g-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .55rem;
  font-weight: 700;
  flex-shrink: 0;
}

.deal-card-ribbon {
  position: absolute;
  top: .35rem;
  right: .35rem;
  font-size: .6rem;
  font-weight: 700;
  padding: .1rem .35rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.deal-card-ribbon--won  { background: #d1fae5; color: #065f46; }
.deal-card-ribbon--lost { background: #fee2e2; color: #991b1b; }

.deal-note-row {
  display: flex;
  gap: .75rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
}

.deal-note-row:last-child { border-bottom: none; }

.deal-note-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #64748b;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.deal-note-body    { flex: 1; min-width: 0; }
.deal-note-meta    { font-size: .8rem; margin-bottom: .2rem; color: #64748b; }
.deal-note-content { font-size: .875rem; word-break: break-word; }

.btn-xs {
  padding: .1rem .3rem;
  font-size: .7rem;
  line-height: 1.4;
  border-radius: 4px;
}


/* ------------------------------------------------------------
   14. Settings page
   ------------------------------------------------------------ */
.settings-layout { min-height: calc(100vh - 120px); }

.settings-nav-col { background: #fff; }

.settings-nav {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0;
  position: sticky;
  top: 1rem;
}

.settings-nav-link {
  display: flex;
  align-items: center;
  padding: .55rem 1.1rem;
  color: #64748b;
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  border-radius: 6px;
  margin: 1px 0.5rem;
  transition: all .3s ease;
}

.settings-nav-link:hover {
  color: var(--g-accent);
  background: var(--g-accent-light);
}

.settings-nav-link.active {
  color: var(--g-accent);
  background: var(--g-accent-light);
  font-weight: 600;
}

.settings-content { background: #fff; padding: 0; }

.settings-content-header {
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid #e2e8f0;
}

.settings-form { padding: .5rem 0; }

.settings-row {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  padding: 1rem 1.75rem;
  border-bottom: 1px solid #f1f5f9;
}

.settings-row:last-of-type { border-bottom: none; }

.settings-row-label {
  flex: 0 0 280px;
  max-width: 280px;
  padding-top: .25rem;
}

.settings-row-control { flex: 1; min-width: 0; }
.settings-input-narrow { max-width: 160px; }
.settings-input-medium { max-width: 380px; }

.settings-footer {
  padding: 1.25rem 1.75rem;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}


/* ------------------------------------------------------------
   15. Line items (quotes / orders new & edit forms)
   ------------------------------------------------------------ */
.line-item-card { background: #f8f9fa; border: 1px solid #dee2e6; border-radius: .5rem; padding: 1rem; margin-bottom: .75rem; }

.product-search-wrapper { position: relative; }

.product-dropdown {
    position: absolute; top: 100%; left: 0; right: 0;
    background: #fff; border: 1px solid #ced4da;
    border-top: none; border-radius: 0 0 .375rem .375rem;
    max-height: 220px; overflow-y: auto; z-index: 1050; display: none;
}
.product-dropdown .pd-item { padding: .45rem .75rem; cursor: pointer; font-size: .875rem; }
.product-dropdown .pd-item:hover { background: #e9ecef; }
.product-dropdown .pd-item .pd-sku { color: #6c757d; font-size: .75rem; font-family: monospace; }
.product-dropdown .pd-item .pd-type { float: right; font-size: .7rem; }

.totals-table td { padding: .35rem .5rem; }
.totals-table .grand-total td { font-weight: 700; font-size: 1.1rem; border-top: 2px solid #dee2e6; }

.addr-card { background: #f8f9fa; border: 1px solid #dee2e6; border-radius: .5rem; padding: 1rem; }


/* ============================================================
   SUPERBAR SEARCH
   ============================================================ */
.superbar-spacer {
    flex: 1 1 auto;
    min-width: 0;
}
.superbar-search {
    position: relative;
    display: flex;
    align-items: center;
    margin: 0 .5rem;
    flex: 0 0 50vw;
    width: 50vw;
    max-width: 50vw;
}
.superbar-search-inner {
    display: flex;
    align-items: center;
    width: 100%;
    height: 34px;
    background: #fff;
    border: 1.5px solid rgba(255,255,255,0.4);
    border-radius: 8px;
    padding: 0 .75rem;
    transition: border-color .2s, box-shadow .2s;
}
.superbar-search-inner:focus-within {
    background: #fff;
    border-color: #fff;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.2);
}
.superbar-search-icon {
    color: #64748b;
    font-size: .8rem;
    margin-right: .45rem;
    flex-shrink: 0;
}
.superbar-search-input {
    background: transparent;
    border: none;
    outline: none;
    color: #1e293b;
    font-size: .9rem;
    font-weight: 500;
    font-family: inherit;
    padding: 0;
    width: 100%;
}
.superbar-search-input::placeholder { color: #94a3b8; }

.superbar-search-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 780px;
    max-width: calc(100vw - 32px);
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    z-index: 9999;
    border: 1px solid #e2e8f0;
    overflow: hidden;
}
.superbar-mega-cols {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    min-height: 0;
}
.superbar-mega-col {
    border-right: 1px solid #e9eef4;
    min-width: 0;
}
.superbar-mega-col:last-child { border-right: none; }
.superbar-mega-col-header {
    padding: .3rem .75rem .2rem;
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #94a3b8;
    background: #f8fafc;
    border-bottom: 1px solid #e9eef4;
    display: flex;
    align-items: center;
    gap: .4rem;
}
.superbar-mega-col-header i { font-size: .75rem; }
.superbar-result-item {
    display: flex;
    align-items: center;
    padding: .38rem .75rem;
    text-decoration: none;
    color: #1e293b;
    font-size: .82rem;
    gap: .55rem;
    border-bottom: 1px solid #f1f5f9;
    transition: background .1s;
}
.superbar-result-item:last-child { border-bottom: none; }
.superbar-result-item:hover { background: #f0f2f5; color: #092b4a; }
.superbar-result-icon { color: #64748b; font-size: .82rem; flex-shrink: 0; }
.superbar-result-text { flex: 1; min-width: 0; }
.superbar-result-label { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .8rem; }
.superbar-result-sub { display: block; font-size: .7rem; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.superbar-result-group {
    padding: .35rem .85rem .2rem;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: #94a3b8;
    background: #f8fafc;
    border-bottom: 1px solid #e9eef4;
    pointer-events: none;
    user-select: none;
}
.superbar-result-group:not(:first-child) { border-top: 1px solid #e9eef4; }
.superbar-result-type { font-size: .68rem; color: #94a3b8; text-transform: uppercase; letter-spacing: .04em; flex-shrink: 0; }
.superbar-result-all {
    background: #f8fafc;
    color: #3b82f6;
    font-weight: 500;
    border-top: 1px solid #e2e8f0;
    padding: .45rem 1rem;
    font-size: .82rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    text-decoration: none;
    transition: background .1s;
}
.superbar-result-all:hover { background: #eff6ff; }
.superbar-mega-view-all {
    display: block;
    padding: .22rem .75rem .3rem;
    font-size: .7rem;
    color: #3b82f6;
    text-decoration: none;
    background: transparent;
    border-bottom: 1px solid #f1f5f9;
}
.superbar-mega-view-all:hover { text-decoration: underline; }

/* ============================================================
   BULK ACTION TOOLBAR
   ============================================================ */
.bulk-toolbar {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .45rem .75rem;
    background: #eff6ff;
    border-bottom: 1px solid #bfdbfe;
    font-size: .8125rem;
}
.bulk-count {
    font-weight: 600;
    color: #1e40af;
    margin-right: .25rem;
}

/* ============================================================
   TASK MODULE
   ============================================================ */
.task-priority-urgent  { border-left: 3px solid #ef4444 !important; }
.task-priority-high    { border-left: 3px solid #f59e0b !important; }
.task-priority-medium  { border-left: 3px solid #3b82f6 !important; }
.task-priority-low     { border-left: 3px solid #6b7280 !important; }

/* ============================================================
   TAGS ADMIN
   ============================================================ */
.tag-color-swatch {
    display: inline-block;
    width: 14px; height: 14px;
    border-radius: 3px;
    vertical-align: middle;
    margin-right: 4px;
    flex-shrink: 0;
}

/* ============================================================
   MAIL MODULE
   ============================================================ */
/* 2-column layout for standalone email view page (view.html.twig) */
.mail-layout {
    height: calc(100vh - var(--g-superbar-height) - 60px);
    overflow: hidden;
}

/* 3-pane Gmail/Outlook-style layout for inbox (inbox.html.twig) */
.mail-shell {
    display: flex;
    height: calc(100vh - var(--g-superbar-height) - 60px);
    overflow: hidden;
    margin: 0 -1.5rem -1.5rem;
    border-top: 1px solid var(--g-topbar-border);
}

.mail-account-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    display: flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
}

.mail-sidebar {
    width: 220px;
    background: #fff;
    border-right: 1px solid var(--g-topbar-border);
    padding: 1rem;
    overflow-y: auto;
    flex-shrink: 0;
}

.mail-folder-link {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    color: #475569;
    text-decoration: none;
    border-radius: 6px;
    margin-bottom: 2px;
    font-size: 0.875rem;
}

.mail-folder-link:hover {
    background: var(--g-accent-light);
    color: var(--g-accent);
}

.mail-folder-link.active {
    background: var(--g-accent);
    color: #fff;
}

.mail-folder-link.active .badge {
    background: rgba(255,255,255,0.2) !important;
    color: #fff !important;
}

.mail-list,
.mail-content {
    display: flex;
    flex-direction: column;
    background: #fff;
    overflow: hidden;
}

/* Narrow fixed-width list panel (inbox 3-pane) */
.mail-list-panel {
    width: 380px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid var(--g-topbar-border);
    background: #fff;
}

/* Reading pane (inbox 3-pane) */
.mail-reading-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    min-width: 0;
}

/* Full-view main area (view.html.twig inside mail-shell) */
.mail-view-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    min-width: 0;
}

.mail-view-main .mail-body {
    flex: 1;
    overflow-y: auto;
}

/* Toolbar inside the list panel */
.mail-list-toolbar {
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid var(--g-topbar-border);
    flex-shrink: 0;
    background: #fff;
}

.mail-toolbar,
.mail-view-toolbar {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--g-topbar-border);
    flex-shrink: 0;
}

.mail-messages {
    flex: 1;
    overflow-y: auto;
}

.mail-item {
    display: flex;
    align-items: flex-start;
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid #f1f5f9;
    text-decoration: none;
    color: inherit;
    gap: 0.625rem;
    cursor: pointer;
    transition: background 0.1s;
}

.mail-item:hover {
    background: #f8fafc;
}

.mail-item.active {
    background: #eff6ff;
    border-left: 3px solid var(--g-accent);
    padding-left: calc(0.875rem - 3px);
}

.mail-item.unread {
    background: #f0f9ff;
}

.mail-item.unread .mail-item-from,
.mail-item.unread .mail-item-subject {
    font-weight: 600;
}

.mail-item-check {
    flex-shrink: 0;
    padding-top: 2px;
}

.mail-item-star {
    flex-shrink: 0;
    cursor: pointer;
    padding-top: 1px;
    font-size: 0.8rem;
}

/* 3-row body layout */
.mail-item-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.mail-item-row1 {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.25rem;
}

.mail-item-from {
    font-size: 0.8125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.mail-item-date {
    font-size: 0.72rem;
    color: #94a3b8;
    white-space: nowrap;
    flex-shrink: 0;
}

.mail-item-row2 {
    min-width: 0;
}

.mail-item-subject {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.8125rem;
}

.mail-item-row3 {
    min-width: 0;
}

.mail-item-snippet {
    display: block;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.75rem;
}

.mail-pagination {
    padding: 0.75rem;
    border-top: 1px solid var(--g-topbar-border);
    flex-shrink: 0;
}

/* ── Pagination ─────────────────────────────────────────────────────────────── */
.pagination .page-link {
    color: var(--g-accent);
    border-color: #dee2e6;
    border-radius: 6px !important;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 0.25rem 0.6rem;
    margin: 0 2px;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.pagination .page-link:hover {
    background-color: var(--g-accent-light);
    border-color: var(--g-accent);
    color: var(--g-accent);
}
.pagination .page-item.active .page-link {
    background-color: var(--g-accent);
    border-color: var(--g-accent);
    color: #fff;
    box-shadow: none;
}
.pagination .page-item.disabled .page-link {
    color: #adb5bd;
    border-color: #dee2e6;
    background: transparent;
}
.pagination .page-item:first-child .page-link,
.pagination .page-item:last-child .page-link {
    border-radius: 6px !important;
}

/* Mail View */
.mail-view-header {
    padding: 1.5rem;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}

.mail-subject {
    font-size: 1.25rem;
    font-weight: 600;
}

.mail-avatar .avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--g-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
}

.mail-attachments {
    padding: 1rem 1.5rem;
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}

.attachment-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.8125rem;
    text-decoration: none;
    color: inherit;
}

.attachment-chip:hover {
    border-color: var(--g-accent);
    color: var(--g-accent);
}

.mail-crm-links {
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}

.mail-body {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

/* Mail Search */
.mail-search-item {
    display: flex;
    align-items: center;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    text-decoration: none;
    color: inherit;
    gap: 1rem;
}

.mail-search-item:hover {
    background: #f8fafc;
}

.mail-search-item.unread {
    background: #f0f9ff;
}

.mail-search-item.unread .mail-search-subject {
    font-weight: 600;
}

.mail-search-from {
    width: 160px;
    flex-shrink: 0;
}

.mail-search-content {
    flex: 1;
    min-width: 0;
    display: flex;
    gap: 0.5rem;
}

.mail-search-subject {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.875rem;
}

.mail-search-snippet {
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.8125rem;
}

.mail-search-meta {
    flex-shrink: 0;
    color: #94a3b8;
    font-size: 0.75rem;
}

/* Reading Pane ─────────────────────────────────────────────── */
.pane-email {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.pane-toolbar {
    padding: 0.5rem 0.875rem;
    border-bottom: 1px solid var(--g-topbar-border);
    flex-shrink: 0;
    background: #fff;
}

.pane-header {
    padding: 1rem 1.5rem 0.875rem;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
    background: #fff;
}

.pane-subject {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 0.75rem;
    line-height: 1.35;
    color: #1e293b;
}

.pane-avatar .avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--g-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.pane-attachments {
    padding: 0.5rem 1.5rem;
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.pane-crm-links,
.pane-crm-bar {
    padding: 0.375rem 1.5rem;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
    font-size: 0.8125rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pane-body {
    flex: 1;
    overflow: hidden;
}

.pane-body iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.pane-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #cbd5e1;
    gap: 0.75rem;
}

.pane-empty i {
    font-size: 3rem;
}

.pane-empty p {
    margin: 0;
    font-size: 0.9375rem;
    color: #94a3b8;
}

.pane-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

/* Compose */
.compose-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    /* fill viewport below superbar + topbar + bottom padding */
    min-height: calc(100vh - var(--g-superbar-height) - 56px - 4.5rem);
}

.compose-card {
    background: #fff;
    border-radius: var(--g-card-radius);
    box-shadow: var(--g-card-shadow);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.compose-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.compose-field {
    display: flex;
    align-items: center;
    padding: 0.5rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}

.compose-field:last-child {
    border-bottom: none;
}

.compose-label {
    width: 70px;
    flex-shrink: 0;
    font-size: 0.875rem;
    color: #64748b;
}

.compose-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.9375rem;
    padding: 0.375rem 0;
    background: transparent;
}

.compose-input:focus {
    outline: none;
}

.compose-body {
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* CKEditor fills the compose body */
.compose-body .ck.ck-editor {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}

.compose-body .ck.ck-editor__top .ck-sticky-panel .ck-sticky-panel__content {
    border-left: none !important;
    border-right: none !important;
    border-radius: 0 !important;
}

.compose-body .ck.ck-toolbar {
    border-left: none !important;
    border-right: none !important;
    border-radius: 0 !important;
    border-top: none !important;
}

.compose-body .ck.ck-editor__main {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.compose-body .ck.ck-editor__editable {
    height: 100%;
    min-height: 380px;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
    padding: 1.25rem 1.5rem !important;
}

.compose-body .ck.ck-editor__editable:focus {
    box-shadow: none !important;
}

.toggle-cc {
    font-size: 0.8125rem;
    color: #64748b;
    text-decoration: none;
    margin-left: 0.5rem;
}

.toggle-cc:hover {
    color: var(--g-accent);
}

.cc-bcc-fields {
    display: none;
}

.cc-bcc-fields.show {
    display: block;
}

/* Spin animation for sync */
.spin { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* ── Mail: CRM panel (replaces pane-crm-bar) ─────────────────── */
.pane-crm-panel {
    padding: 0.4rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    background: #fafbfc;
}

.pane-crm-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    background: #e8f0fe;
    border: 1px solid #c7d9fb;
    border-radius: 4px;
    padding: 0.15rem 0.45rem;
    font-size: 0.78rem;
    color: #1e40af;
}

.pane-crm-badge a { color: inherit; }

.btn-pane-unlink {
    background: none;
    border: none;
    padding: 0 2px;
    line-height: 1;
    cursor: pointer;
    color: #94a3b8;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.btn-pane-unlink:hover { color: #ef4444; }

.pane-crm-btn {
    display: inline-flex;
    align-items: center;
    font-size: 0.76rem;
    padding: 0.18rem 0.55rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #64748b;
    border-radius: 5px;
    text-decoration: none;
    cursor: pointer;
    gap: 0.2rem;
    white-space: nowrap;
}
.pane-crm-btn:hover {
    background: var(--g-accent-light);
    color: var(--g-accent);
    border-color: var(--g-accent);
}

/* Sender CRM "add to CRM" badge */
.pane-badge-add-crm {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
}
.pane-badge-add-crm:hover { background: #e2e8f0; }

/* ── Mail: compose TomSelect recipient fields ────────────────── */
.compose-field .ts-wrapper {
    flex: 1;
    min-width: 0;
}
.compose-field .ts-control {
    border: none !important;
    box-shadow: none !important;
    padding: 0.25rem 0 !important;
    background: transparent !important;
    min-height: unset !important;
}
.compose-field .ts-control input {
    font-size: 0.9375rem !important;
}
.compose-field .ts-dropdown {
    font-size: 0.875rem;
}

/* ── Compose: attachment zone ────────────────────────────────── */
.compose-attach-zone {
    flex: 1;
    min-width: 0;
}
.compose-attach-zone--dragover {
    background: rgba(59,130,246,0.06);
    border-radius: 6px;
}

/* Drop prompt */
.compose-attach-drop {
    font-size: 0.8125rem;
    color: #94a3b8;
    padding: 0.3rem 0;
    cursor: default;
}
.compose-attach-drop a {
    color: var(--g-accent);
    text-decoration: underline;
    cursor: pointer;
}
.compose-attach-drop.has-files {
    font-size: 0.75rem;
    padding-top: 0.15rem;
}

/* File chip list */
.compose-attach-file-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}
.compose-attach-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    line-height: 1.2;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    background: #f1f5f9;
    color: #334155;
    white-space: nowrap;
    max-width: 280px;
}
.compose-attach-chip i {
    font-size: 0.82rem;
    flex-shrink: 0;
}
.compose-attach-chip-name {
    overflow: hidden;
    text-overflow: ellipsis;
}
.compose-attach-chip-size {
    color: #94a3b8;
    font-size: 0.7rem;
    flex-shrink: 0;
}
.compose-attach-chip-remove {
    background: none;
    border: none;
    padding: 0 0.1rem;
    font-size: 1rem;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
}
.compose-attach-chip-remove:hover {
    color: #ef4444;
}

/* Document PDF chip variant */
.compose-attach-chip--doc {
    background: #fef2f2;
    color: #991b1b;
}
.compose-attach-chip--doc .compose-attach-chip-size { display: none; }

/* Inline template selector inside doc chip */
.compose-attach-template-select {
    font-size: 0.72rem !important;
    padding: 0 0.4rem !important;
    height: auto !important;
    line-height: 1.4 !important;
    border-radius: 4px !important;
    max-width: 160px;
    border-color: #fecaca !important;
}

/* ==========================================================================
   Internal Messaging
   ========================================================================== */

/* Superbar messages badge (mirrors .notif-badge but blue) */
.msg-superbar-badge {
    position: absolute;
    top: 2px; right: 2px;
    min-width: 16px; height: 16px;
    font-size: 0.6rem; font-weight: 700;
    line-height: 16px; text-align: center;
    padding: 0 4px;
    border-radius: 999px;
    background: #3b82f6; color: #fff;
}

/* Message delete button — visible on bubble-wrap hover */
.msg-delete-btn {
    opacity: 0;
    color: rgba(255,255,255,0.5);
    font-size: 0.8rem;
    transition: opacity 0.15s;
    text-decoration: none;
}
.msg-bubble-wrap:hover .msg-delete-btn {
    opacity: 1;
}
.msg-delete-btn:hover {
    color: #ef4444 !important;
}

/* Inbox list */
.messaging-conv-row {
    transition: background 0.1s;
}
.messaging-conv-row:hover {
    background: #f8fafc;
}
.messaging-conv-delete-form {
    opacity: 0;
    transition: opacity 0.15s;
}
.list-group-item:hover .messaging-conv-delete-form {
    opacity: 1;
}
.messaging-conv-delete-btn {
    color: #94a3b8;
    text-decoration: none;
}
.messaging-conv-delete-btn:hover {
    color: #ef4444;
}
.messaging-conv-row--unread {
    background: #eff6ff;
}
.messaging-conv-row--unread:hover {
    background: #dbeafe;
}
.messaging-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--g-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}
.messaging-name {
    font-size: var(--g-font-sm);
}
.messaging-preview {
    font-size: var(--g-font-xs);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Thread card — fills available space below topbar, compose bar always visible */
.messaging-thread-card {
    height: calc(100vh - var(--g-superbar-height) - 60px);
    min-height: 400px;
    overflow: hidden;
    margin: 0 -1.5rem -1.5rem;
    border-radius: 0 !important;
}
.messaging-thread {
    flex: 1;
    min-height: 0;   /* lets a flex child shrink below its content size */
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* Bubbles */
.messaging-bubble {
    max-width: 68%;
    padding: 0.5rem 0.75rem;
    border-radius: 14px;
    font-size: var(--g-font-sm);
    word-break: break-word;
}
.messaging-bubble--me {
    background: var(--g-accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.messaging-bubble--them {
    background: #f1f5f9;
    color: #1e293b;
    border-bottom-left-radius: 4px;
}
.messaging-bubble-name {
    font-size: var(--g-font-xs);
    font-weight: 600;
    opacity: 0.7;
    margin-bottom: 2px;
}
.messaging-bubble-body {
    line-height: 1.5;
}
.messaging-bubble-time {
    font-size: 0.65rem;
    opacity: 0.6;
    margin-top: 3px;
    text-align: right;
}
.messaging-bubble--them .messaging-bubble-time {
    text-align: left;
}

/* Compose bar */
.messaging-compose {
    background: #fff;
    flex-shrink: 0;
}

/* ------------------------------------------------------------
   AI Agent chat — mirrors messaging thread layout
   ------------------------------------------------------------ */

/* Make .main a flex column that fills the viewport so the card can flex-fill */
.chat-page .main {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    padding-bottom: 0;
}

/* Topbar keeps its margin/padding but must not grow */
.chat-page .topbar {
    flex-shrink: 0;
}

.chat-thread-card {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    margin: 0 -1.5rem 0;
    border-radius: 0 !important;
    display: flex;
    flex-direction: column;
}
.chat-thread-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scroll-behavior: smooth;
}
.chat-thread-compose {
    background: var(--bs-body-bg);
    flex-shrink: 0;
    border-top: 1px solid var(--bs-border-color);
    padding: 0.75rem 1rem;
}
.chat-agent-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    border-bottom: 1px solid var(--bs-border-color);
    background: var(--bs-tertiary-bg);
    flex-shrink: 0;
}
.chat-agent-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}
.chat-bubble-agent {
    max-width: 78%;
    padding: 0.6rem 0.9rem;
    border-radius: 14px 14px 14px 4px;
    background: #f1f5f9;
    color: #1e293b;
    font-size: var(--g-font-sm);
    word-break: break-word;
    align-self: flex-start;
}
.chat-bubble-agent pre {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
    font-size: inherit;
    margin: 0;
}
.chat-bubble-user {
    max-width: 78%;
    padding: 0.6rem 0.9rem;
    border-radius: 14px 14px 4px 14px;
    background: var(--g-accent);
    color: #fff;
    font-size: var(--g-font-sm);
    word-break: break-word;
    align-self: flex-end;
}
.chat-typing-dots span {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
    animation: chat-bounce 1.2s infinite;
}
.chat-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chat-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-6px); }
}
