/* ==========================================================================
   MixCRM - Design Foundation
   A small set of tokens (color, type, space, radius, shadow) drives every
   component below, so the whole product moves together when any of them
   change. Sections: tokens → base/type → shell → buttons → forms → cards →
   tables → badges → empty states → toasts → auth.
   ========================================================================== */

@font-face {
  font-family: 'Inter';
  src: url('/vendor/fonts/inter/Inter-Variable.woff2') format('woff2-variations'), url('/vendor/fonts/inter/Inter-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/vendor/fonts/inter/Inter-Italic-Variable.woff2') format('woff2-variations'), url('/vendor/fonts/inter/Inter-Italic-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

:root {
  /* ---- Brand ---- */
  --mc-navy: #16255C;
  --mc-navy-2: #1E3178;
  --mc-blue: #3B6FE0;
  --mc-blue-light: #EEF3FE;
  --mc-ink: #10142A;

  /* Back-compat aliases (existing views/inline styles still reference these) */
  --mc-whitish: var(--mc-gray-50, #F6F8FC);
  --mc-green: var(--mc-success, #1F9D6E);
  --mc-red: var(--mc-danger, #DC3545);
  --mc-amber: var(--mc-warning, #D97706);

  /* ---- Neutral scale (cool gray, not blue-washed) ---- */
  --mc-gray-50:  #F6F8FC;
  --mc-gray-100: #EEF1F7;
  --mc-gray-200: #E2E6F0;
  --mc-gray-300: #CBD1E0;
  --mc-gray-400: #9AA3BC;
  --mc-gray-500: #717B9B;
  --mc-gray-600: #545E7D;
  --mc-gray-700: #3A4260;
  --mc-gray-800: #262C45;
  --mc-gray-900: #171B2E;

  /* ---- Semantic ---- */
  --mc-success: #1F9D6E;
  --mc-success-bg: #E7F7F0;
  --mc-danger: #DC3545;
  --mc-danger-bg: #FCEBEC;
  --mc-warning: #D97706;
  --mc-warning-bg: #FDF3E4;
  --mc-info: var(--mc-blue);
  --mc-info-bg: var(--mc-blue-light);

  /* ---- Type ---- */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --fs-xs: .75rem;     /* 12px */
  --fs-sm: .8125rem;   /* 13px */
  --fs-base: .875rem;  /* 14px */
  --fs-md: 1rem;       /* 16px */
  --fs-lg: 1.125rem;   /* 18px */
  --fs-xl: 1.375rem;   /* 22px */
  --fs-2xl: 1.75rem;   /* 28px */

  /* ---- Space (4px base) ---- */
  --sp-1: .25rem; --sp-2: .5rem; --sp-3: .75rem; --sp-4: 1rem;
  --sp-5: 1.25rem; --sp-6: 1.5rem; --sp-8: 2rem; --sp-10: 2.5rem;

  /* ---- Radius ---- */
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px; --r-full: 999px;

  /* ---- Elevation (restrained - enterprise UI leans on borders, not shadow) ---- */
  --shadow-xs: 0 1px 2px rgba(16, 20, 42, .05);
  --shadow-sm: 0 1px 3px rgba(16, 20, 42, .07), 0 1px 2px rgba(16, 20, 42, .05);
  --shadow-md: 0 4px 12px rgba(16, 20, 42, .08), 0 2px 4px rgba(16, 20, 42, .04);
  --shadow-lg: 0 12px 32px rgba(16, 20, 42, .12), 0 4px 8px rgba(16, 20, 42, .04);
  --shadow-focus: 0 0 0 3px rgba(59, 111, 224, .22);

  --ease: cubic-bezier(.4, 0, .2, 1);
  --sidebar-width: 252px;
  --sidebar-collapsed-width: 72px;
  --topbar-height: 60px;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  background: var(--mc-gray-50);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  color: var(--mc-gray-800);
  line-height: 1.5;
  margin: 0;
}

h1, h2, h3, h4, h5, h6 { font-weight: 600; color: var(--mc-ink); letter-spacing: -.01em; }
a { color: var(--mc-blue); }
small, .small { color: var(--mc-gray-500); }
hr { border-color: var(--mc-gray-200); }

::selection { background: var(--mc-blue-light); color: var(--mc-navy); }

*:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--r-sm);
}

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--mc-navy) 0%, #101C48 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  transition: width .18s var(--ease);
  z-index: 40;
}
body.sidebar-collapsed .app-sidebar { width: var(--sidebar-collapsed-width); }
body.sidebar-collapsed .app-sidebar .brand-name,
body.sidebar-collapsed .app-sidebar .nav-link span,
body.sidebar-collapsed .app-sidebar .sidebar-bottom-link span { display: none; }
body.sidebar-collapsed .app-sidebar .sidebar-brand { justify-content: center; padding-left: 0; padding-right: 0; }
body.sidebar-collapsed .app-sidebar .brand-logo { display: none; }
body.sidebar-collapsed .app-sidebar .nav-link,
body.sidebar-collapsed .app-sidebar .sidebar-bottom-link { justify-content: center; padding-left: 0; padding-right: 0; }
body.sidebar-collapsed .app-sidebar .dropdown-toggle::after { display: none; }
body.sidebar-collapsed .app-sidebar .sidebar-collapse-btn i { transform: rotate(180deg); }

.sidebar-collapse-btn {
  position: absolute; top: 22px; right: -12px; width: 24px; height: 24px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 1px solid var(--mc-gray-200); background: #fff; color: var(--mc-gray-600);
  box-shadow: 0 1px 3px rgba(0,0,0,.15); cursor: pointer; z-index: 41;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.sidebar-collapse-btn:hover { background: var(--mc-gray-50); color: var(--mc-blue); }
.sidebar-collapse-btn i { font-size: 16px; transition: transform .18s var(--ease); }

/* Tooltips for icon-only (collapsed) nav */
body.sidebar-collapsed .app-sidebar .nav-link[data-tip]:hover::after {
  content: attr(data-tip); position: fixed; left: calc(var(--sidebar-collapsed-width) + 6px);
  background: var(--mc-navy); color: #fff; padding: 4px 10px; border-radius: var(--r-md);
  font-size: var(--fs-xs); white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.25); pointer-events: none; z-index: 60;
}
body.sidebar-collapsed .app-main { margin-left: var(--sidebar-collapsed-width); }

.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 16px; font-weight: 700; font-size: var(--fs-lg); letter-spacing: -.01em; }
.brand-logo { width: 26px; height: 26px; flex-shrink: 0; }

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: var(--sp-2) var(--sp-3) var(--sp-4); }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: var(--r-full); }

.nav-link {
  display: flex; align-items: center; gap: 12px;
  color: rgba(255,255,255,.68); text-decoration: none;
  padding: 8px 12px; border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: 500;
  margin-bottom: 1px; white-space: nowrap;
  position: relative;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.nav-link i { font-size: 18px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: rgba(255,255,255,.1); color: #fff; font-weight: 600; }
.nav-link.active::before {
  content: ''; position: absolute; left: -6px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: var(--r-full); background: #6D97F5;
}
body.sidebar-collapsed .nav-link.active::before { display: none; }
.nav-divider { border-top: 1px solid rgba(255,255,255,.1); margin: 10px 10px; }

.sidebar-bottom { border-top: 1px solid rgba(255,255,255,.1); padding: 8px; }
.sidebar-bottom-link { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.68); text-decoration: none; padding: 8px 10px; border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: 500; transition: background .12s var(--ease), color .12s var(--ease); }
.sidebar-bottom-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.avatar-circle { width: 24px; height: 24px; border-radius: 50%; background: var(--mc-blue); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }

.app-main { margin-left: var(--sidebar-width); flex: 1; transition: margin-left .18s var(--ease); min-width: 0; }

.app-topbar {
  height: var(--topbar-height); background: rgba(255,255,255,.85); backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--mc-gray-200);
  display: flex; align-items: center; gap: 16px; padding: 0 20px; position: sticky; top: 0; z-index: 30;
}
.topbar-search { flex: 1; max-width: 420px; position: relative; }
.topbar-search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--mc-gray-400); font-size: 16px; }
.topbar-search input {
  width: 100%; border: 1px solid var(--mc-gray-200); background: var(--mc-gray-50); border-radius: var(--r-md);
  padding: 8px 12px 8px 34px; font-size: var(--fs-sm); font-family: inherit; color: var(--mc-gray-800);
  transition: border-color .12s var(--ease), background .12s var(--ease), box-shadow .12s var(--ease);
}
.topbar-search input:focus { outline: none; background: #fff; border-color: var(--mc-blue); box-shadow: var(--shadow-focus); }
.topbar-search input::placeholder { color: var(--mc-gray-400); }


.app-content { padding: var(--sp-6); max-width: 1400px; }

/* ---------- Page basics ---------- */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-6); gap: var(--sp-4); }
.page-header h1 { font-size: var(--fs-xl); font-weight: 700; margin: 0; color: var(--mc-ink); }

/* ---------- Buttons ---------- */
.btn {
  font-size: var(--fs-sm); font-weight: 600; border-radius: var(--r-md);
  padding: 7px 14px; transition: background .12s var(--ease), border-color .12s var(--ease), box-shadow .12s var(--ease), transform .05s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 5px 10px; font-size: var(--fs-xs); }
.btn-lg { padding: 10px 20px; font-size: var(--fs-md); }

.btn-primary { background: var(--mc-blue); border-color: var(--mc-blue); box-shadow: 0 1px 2px rgba(59,111,224,.25); }
.btn-primary:hover, .btn-primary:focus { background: var(--mc-navy-2); border-color: var(--mc-navy-2); }
.btn-primary:active { background: var(--mc-navy); border-color: var(--mc-navy); }
.btn-primary:disabled { background: var(--mc-gray-300); border-color: var(--mc-gray-300); box-shadow: none; }

.btn-outline-secondary, .btn-light { border-color: var(--mc-gray-200); color: var(--mc-gray-700); background: #fff; }
.btn-outline-secondary:hover, .btn-light:hover { background: var(--mc-gray-50); border-color: var(--mc-gray-300); color: var(--mc-gray-800); }

.btn-outline-danger { color: var(--mc-danger); border-color: #F3C7CB; }
.btn-outline-danger:hover { background: var(--mc-danger); border-color: var(--mc-danger); }

.btn-outline-success { color: var(--mc-success); border-color: #B9E5D3; }
.btn-outline-success:hover { background: var(--mc-success); border-color: var(--mc-success); }

.btn:focus-visible { box-shadow: var(--shadow-focus); }

/* ---------- Forms ---------- */
.form-label { font-size: var(--fs-sm); font-weight: 600; color: var(--mc-gray-700); margin-bottom: 6px; }
.form-control, .form-select {
  border: 1px solid var(--mc-gray-200); border-radius: var(--r-md); font-size: var(--fs-base); font-family: inherit;
  padding: 8px 12px; color: var(--mc-gray-800);
  transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
}
.form-control:focus, .form-select:focus { border-color: var(--mc-blue); box-shadow: var(--shadow-focus); }
.form-control::placeholder { color: var(--mc-gray-400); }
.form-control-sm, .form-select-sm { padding: 5px 9px; font-size: var(--fs-sm); }
.form-check-input:checked { background-color: var(--mc-blue); border-color: var(--mc-blue); }
.form-check-input:focus { box-shadow: var(--shadow-focus); }

/* ---------- Cards ---------- */
.card { border: 1px solid var(--mc-gray-200); border-radius: var(--r-lg); box-shadow: none; }
.card:has(.card-header) .card-header { background: transparent; border-bottom: 1px solid var(--mc-gray-200); font-weight: 600; }

.kpi-card { background: #fff; border: 1px solid var(--mc-gray-200); border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5); }
.kpi-card .kpi-label { font-size: var(--fs-xs); color: var(--mc-gray-500); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi-card .kpi-value { font-size: 1.65rem; font-weight: 700; color: var(--mc-ink); margin-top: 6px; letter-spacing: -.01em; }

.kpi-card-link { display: block; text-decoration: none; color: inherit; transition: box-shadow .15s var(--ease), transform .15s var(--ease), border-color .15s var(--ease); border-radius: var(--r-lg); }
.kpi-card-link:hover .kpi-card { box-shadow: var(--shadow-md); border-color: #C7D5F7; }
.kpi-card-link:hover { transform: translateY(-2px); }
.kpi-card-link:focus-visible { box-shadow: var(--shadow-focus); }

/* ---------- Tables ---------- */
.table { font-size: var(--fs-sm); color: var(--mc-gray-800); }
.table thead th {
  font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--mc-gray-500);
  border-bottom: 1px solid var(--mc-gray-200); padding: 10px 12px; background: var(--mc-gray-50);
}
.table tbody td { padding: 12px; vertical-align: middle; border-bottom: 1px solid var(--mc-gray-100); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--mc-gray-50); }
.table-hover tbody tr { transition: background .1s var(--ease); }

/* ---------- Badges ---------- */
.badge { font-weight: 600; font-size: var(--fs-xs); padding: 4px 9px; border-radius: var(--r-full); letter-spacing: .01em; }
.badge.bg-light { background: var(--mc-gray-100) !important; color: var(--mc-gray-600) !important; border: 1px solid var(--mc-gray-200) !important; }
.badge-success, .badge.bg-success { background: var(--mc-success-bg) !important; color: var(--mc-success) !important; }
.badge-danger, .badge.bg-danger { background: var(--mc-danger-bg) !important; color: var(--mc-danger) !important; }
.badge-warning, .badge.bg-warning { background: var(--mc-warning-bg) !important; color: var(--mc-warning) !important; }
.badge-info, .badge.bg-info { background: var(--mc-info-bg) !important; color: var(--mc-info) !important; }

/* ---------- Empty states ---------- */
.empty-state { text-align: center; padding: 64px 20px; color: var(--mc-gray-500); }
.empty-state i { font-size: 40px; color: var(--mc-gray-300); margin-bottom: 12px; }
.empty-state h5 { color: var(--mc-gray-700); margin-bottom: 6px; }

/* ---------- Toasts (bottom-left) ---------- */
.toast-stack {
  position: fixed; left: 20px; bottom: 20px; z-index: 9999;
  display: flex; flex-direction: column-reverse; gap: 10px; width: 336px;
}
.app-toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: #fff; border: 1px solid var(--mc-gray-200); border-left: 3px solid var(--mc-blue);
  border-radius: var(--r-md); padding: 12px 14px; box-shadow: var(--shadow-lg);
  animation: toast-in .18s var(--ease);
}
.app-toast-success { border-left-color: var(--mc-success); }
.app-toast-error { border-left-color: var(--mc-danger); }
.app-toast-warning { border-left-color: var(--mc-warning); }
.app-toast-info { border-left-color: var(--mc-blue); }
.app-toast-icon i { font-size: 18px; color: var(--mc-blue); }
.app-toast-success .app-toast-icon i { color: var(--mc-success); }
.app-toast-error .app-toast-icon i { color: var(--mc-danger); }
.app-toast-warning .app-toast-icon i { color: var(--mc-warning); }
.app-toast-title { font-weight: 600; font-size: var(--fs-sm); color: var(--mc-ink); }
.app-toast-message { font-size: var(--fs-sm); color: var(--mc-gray-500); }
.app-toast-close { margin-left: auto; background: none; border: 0; color: var(--mc-gray-400); cursor: pointer; }
.app-toast-close:hover { color: var(--mc-gray-600); }
.app-toast-hide { opacity: 0; transform: translateY(6px); transition: all .2s var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Auth pages ---------- */
.auth-shell { min-height: 100vh; display: flex; background: #fff; }

.auth-brand-panel {
  flex: 0 0 42%; max-width: 560px; min-height: 100vh; position: relative; overflow: hidden;
  background: radial-gradient(120% 140% at 15% 0%, var(--mc-navy-2) 0%, var(--mc-navy) 45%, #0D1638 100%);
  color: #fff; display: flex; flex-direction: column; padding: var(--sp-8) var(--sp-10);
}
.auth-brand-panel::before {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.13) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,.6), transparent 70%);
  pointer-events: none;
}
.auth-brand-mark { display: flex; align-items: center; gap: 10px; font-size: var(--fs-lg); font-weight: 700; letter-spacing: -.01em; position: relative; z-index: 1; }
.auth-brand-mark img { width: 28px; height: 28px; }
.auth-brand-copy { margin-top: auto; margin-bottom: auto; max-width: 400px; position: relative; z-index: 1; }
.auth-brand-copy h2 { color: #fff; font-size: 1.85rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; margin-bottom: var(--sp-4); }
.auth-brand-copy p { color: rgba(255,255,255,.72); font-size: var(--fs-md); line-height: 1.6; }
.auth-trust-list { list-style: none; margin: var(--sp-6) 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; position: relative; z-index: 1; }
.auth-trust-list li { display: flex; align-items: center; gap: 10px; font-size: var(--fs-sm); color: rgba(255,255,255,.85); }
.auth-trust-list i { color: #7FD9AE; font-size: 16px; flex-shrink: 0; }
.auth-brand-foot { font-size: var(--fs-xs); color: rgba(255,255,255,.45); position: relative; z-index: 1; }

.auth-form-panel { flex: 1; display: flex; align-items: center; justify-content: center; padding: var(--sp-6); background: var(--mc-gray-50); }

.auth-card { background: #fff; border: 1px solid var(--mc-gray-200); border-radius: var(--r-xl); box-shadow: var(--shadow-md); padding: 40px; width: 100%; max-width: 400px; }
.auth-card h1 { color: var(--mc-ink); font-size: var(--fs-xl); font-weight: 700; margin-bottom: 4px; letter-spacing: -.01em; }

.oauth-buttons { display: flex; flex-direction: column; gap: 10px; }
.btn-oauth {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  border: 1px solid var(--mc-gray-200); background: #fff; border-radius: var(--r-md);
  padding: 9px 14px; font-size: var(--fs-sm); font-weight: 600; color: var(--mc-gray-700);
  text-decoration: none; transition: background .12s var(--ease), border-color .12s var(--ease);
}
.btn-oauth:hover { background: var(--mc-gray-50); border-color: var(--mc-gray-300); color: var(--mc-gray-800); }
.btn-oauth img { width: 18px; height: 18px; flex-shrink: 0; }

.auth-divider { display: flex; align-items: center; gap: 12px; margin: var(--sp-5) 0; color: var(--mc-gray-400); font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--mc-gray-200); }

@media (max-width: 900px) {
  .auth-brand-panel { display: none; }
}

/* ---- Contacts: operations UI ---- */
.contacts-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.contacts-table th.sortable:hover { color: var(--mc-blue); }
.contacts-table td, .contacts-table th { vertical-align: middle; font-size: var(--fs-sm); }
.contacts-table .col-check { width: 36px; }
.contacts-table td.inline { cursor: text; }
.contacts-table td.inline:hover .v { border-bottom: 1px dashed var(--mc-gray-400); }
.contacts-table td.editing { min-width: 150px; }
.contacts-table tr.row-archived td { opacity: .65; }
.bulk-bar { border-color: var(--mc-blue); background: #f5f8ff; }
.table-loading { position: absolute; inset: 0; background: rgba(255,255,255,.6); z-index: 5; display: flex; align-items: center; justify-content: center; }
.stat-box { background: var(--mc-gray-50); border: 1px solid var(--mc-gray-200); border-radius: var(--r-md); padding: 10px 6px; }
.stat-num { font-size: 20px; font-weight: 700; line-height: 1.1; }
.stat-lbl { font-size: var(--fs-xs); color: var(--mc-gray-500); }
.op-row { cursor: pointer; }
.op-tracker { position: fixed; right: 20px; bottom: 20px; width: 280px; z-index: 1080; display: flex; flex-direction: column; gap: 8px; }
.op-track-item { background: #fff; border: 1px solid var(--mc-gray-200); border-radius: var(--r-md); padding: 10px 12px; box-shadow: 0 4px 14px rgba(16,28,72,.15); }
.wizard-steps { color: var(--mc-gray-500); margin-top: 2px; }
.wizard-steps .wiz-step.active { color: var(--mc-blue); font-weight: 700; }
.wizard-steps .wiz-step.done { color: var(--mc-gray-700); }
.pre { white-space: pre-wrap; }
/* The sidebar's .nav-link styling is global; restore normal look inside page-level tabs/pills */
#contactTabs .nav-link, #detailTabs .nav-link, #addContactTabs .nav-link, #upTabs .nav-link { color: var(--mc-gray-600); background: transparent; margin: 0; padding: .5rem 1rem; gap: 0; }
#contactTabs .nav-link::before, #detailTabs .nav-link::before { display: none; }
#contactTabs .nav-link:hover, #detailTabs .nav-link:hover { color: var(--mc-ink); background: transparent; }
#contactTabs .nav-link.active, #detailTabs .nav-link.active { color: var(--mc-blue); background: #fff; font-weight: 600; }
#upTabs .nav-link.active, #addContactTabs .nav-link.active { color: #fff; background: var(--mc-blue); }
#paneContacts .form-select.w-auto, #paneAccounts .form-select.w-auto, #paneOps .form-select.w-auto { min-width: 140px; padding-right: 2rem; }

.drop-zone { border: 2px dashed var(--mc-gray-300); border-radius: var(--r-lg); padding: 28px; text-align: center; background: var(--mc-gray-50); transition: background .12s, border-color .12s; }
.drop-zone.drag { border-color: var(--mc-blue); background: #eef3ff; }
#optTabs .nav-link { color: var(--mc-gray-600); background: transparent; margin: 0; padding: .35rem .8rem; gap: 0; }
#optTabs .nav-link.active { color: #fff; background: var(--mc-blue); }

/* Deals pipeline board */
.kanban-scroll { overflow-x: auto; padding-bottom: 8px; }
.kanban-board { display: flex; gap: 12px; align-items: flex-start; min-height: 320px; }
.kanban-column { flex: 0 0 280px; background: var(--mc-gray-50); border: 1px solid var(--mc-gray-200); border-radius: var(--r-md); display: flex; flex-direction: column; max-height: 72vh; transition: box-shadow .12s, background .12s; }
.kanban-column.drop-target { background: #eef3ff; box-shadow: 0 0 0 2px var(--mc-blue); }
.kanban-column-header { display: flex; padding: 10px 12px; font-weight: 600; font-size: 13px; background: #fff; border-radius: var(--r-md) var(--r-md) 0 0; }
.kanban-cards { padding: 8px; overflow-y: auto; flex: 1; min-height: 60px; }
.kanban-card { background: #fff; border: 1px solid var(--mc-gray-200); border-radius: var(--r-md); padding: 10px; margin-bottom: 8px; cursor: grab; box-shadow: 0 1px 2px rgba(16,28,72,.06); }
.kanban-card:hover { box-shadow: 0 3px 10px rgba(16,28,72,.12); }
.kanban-card-title { font-weight: 600; font-size: 13px; color: var(--mc-gray-900, #1b2559); }
.kanban-card-meta { font-size: 12px; color: var(--mc-gray-600, #6b7280); margin: 2px 0 6px; }
.kanban-card-amount { font-weight: 600; font-size: 13px; }
.kanban-empty { text-align: center; padding: 14px 0; }

/* Ticket composer tabs (inside a card header the global nav-link colour is the sidebar's light text) */
#composerTabs .nav-link { color: var(--mc-gray-600, #5b6785); }
#composerTabs .nav-link.active { color: var(--mc-blue, #488BFD); font-weight: 600; }
#composerTabs .nav-link:hover { color: var(--mc-blue, #488BFD); }
.ticket-thread .msg .card-body { font-size: 14px; }

/* ===== Calendar ===== */
.cal-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 12px; align-items: start; }
.cal-side { position: sticky; top: 8px; }
.cal-side-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--mc-gray-500, #8a94b0); margin-bottom: 4px; }
.cal-check { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-bottom: 2px; cursor: pointer; }
.cal-check .dot, .cal-ag-row .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; text-align: center; font-size: 11px; }
.mini-dow { color: var(--mc-gray-500, #8a94b0); font-weight: 600; padding: 2px 0; }
.mini-day { position: relative; padding: 4px 0; border-radius: 4px; color: var(--mc-gray-800, #2b3556); text-decoration: none; }
.mini-day:hover { background: var(--mc-gray-100, #eef1f8); } .mini-day.muted { color: #b3bcd4; }
.mini-day.today { font-weight: 700; color: var(--mc-blue, #488BFD); } .mini-day.wk { background: #eef3ff; } .mini-day.sel { background: var(--mc-blue, #488BFD); color: #fff; }
.mini-dot { position: absolute; left: 50%; bottom: 1px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--mc-blue, #488BFD); } .mini-day.sel .mini-dot { background: #fff; }
.cal-canvas { min-height: 420px; overflow-x: auto; }
.cal-month { min-width: 640px; } .cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--mc-navy, #1C3988); color: #fff; font-size: 12px; font-weight: 600; text-align: center; }
.cal-dow > div { padding: 6px 0; } .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: #e3e9f5; }
.cal-cell { background: #fff; min-height: 104px; padding: 4px; font-size: 12px; } .cal-cell.muted { background: #fafbfd; } .cal-cell.today { background: #eef4ff; } .cal-cell.drop, .cal-adcell.drop, .cal-team-cell.drop { outline: 2px dashed var(--mc-blue, #488BFD); outline-offset: -2px; }
.cal-date { font-weight: 600; text-align: right; margin-bottom: 2px; } .cal-date a { color: inherit; text-decoration: none; padding: 0 3px; } .cal-cell.muted .cal-date a { color: #b3bcd4; }
.cal-chip { border-radius: 4px; padding: 1px 5px; margin-bottom: 2px; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; } .cal-chip:hover { filter: brightness(.96); }
.cal-chip.cancelled, .cal-ev.cancelled { text-decoration: line-through; opacity: .6; } .cal-chip.done, .cal-ev.done { opacity: .75; }
.cal-task { background: #e3f7e8; color: #1a7a3a; border-left: 3px solid #67C27C; } .cal-task.done { text-decoration: line-through; }
.cal-more { font-size: 11px; color: var(--mc-gray-600, #5b6785); }
.cal-week { min-width: 720px; } .cal-wk-head, .cal-wk-allday { display: grid; grid-template-columns: 52px repeat(var(--cols), minmax(0, 1fr)); } .cal-wk-head { background: #fff; border-bottom: 1px solid #e3e9f5; }
.cal-colhead { padding: 6px; text-align: center; font-size: 12px; border-left: 1px solid #e3e9f5; } .cal-colhead a { color: inherit; text-decoration: none; } .cal-colhead.today { background: #eef4ff; }
.cal-gutter { font-size: 10px; color: var(--mc-gray-500, #8a94b0); text-align: right; padding-right: 4px; } .cal-wk-allday { border-bottom: 1px solid #e3e9f5; min-height: 26px; } .cal-adcell { border-left: 1px solid #e3e9f5; padding: 2px; min-height: 26px; }
.cal-wk-scroll { max-height: 640px; overflow-y: auto; position: relative; } .cal-wk-body { display: grid; grid-template-columns: 52px repeat(var(--cols), minmax(0, 1fr)); }
.cal-hour { border-top: 1px solid #eef1f8; position: relative; } .cal-hour span { position: relative; top: -7px; background: #fff; padding-right: 2px; }
.cal-col { position: relative; border-left: 1px solid #e3e9f5; background-image: linear-gradient(#eef1f8 1px, transparent 1px); background-size: 100% 60px; min-height: 1440px; } .cal-col.today { background-color: #f7faff; }
.cal-ev { position: absolute; border-radius: 4px; padding: 1px 4px; font-size: 11px; overflow: hidden; cursor: pointer; user-select: none; z-index: 2; box-shadow: 0 1px 2px rgba(16,28,72,.12); } .cal-ev-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-resize { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; cursor: ns-resize; } .cal-now { position: absolute; left: 0; right: 0; height: 2px; background: #dc3545; z-index: 3; }
.cal-selbox { position: absolute; left: 2px; right: 2px; background: rgba(72,139,253,.25); border: 1px solid #488BFD; border-radius: 3px; z-index: 1; pointer-events: none; }
.cal-agenda { padding: 0 0 8px; } .cal-ag-head { padding: 8px 12px; border-bottom: 1px solid #e3e9f5; } .cal-ag-day { padding: 8px 12px; font-weight: 600; background: #f6f8fd; border-top: 1px solid #e3e9f5; } .cal-ag-day.today { background: #eef4ff; }
.cal-ag-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid #f0f3fa; } .cal-ag-time { width: 120px; flex-shrink: 0; font-size: 12px; color: var(--mc-gray-600, #5b6785); }
.cal-team { font-size: 12px; } .cal-team th.today { background: #eef4ff; } .cal-team-user { min-width: 150px; white-space: nowrap; font-weight: 600; } .cal-team-cell { min-width: 110px; vertical-align: top; }
@media (max-width: 991.98px) {
  .cal-layout { grid-template-columns: 1fr; } .cal-side { display: none; position: static; } .cal-side.open { display: block; }
  .cal-cell { min-height: 76px; padding: 2px; } .cal-chip { font-size: 10px; } .cal-ag-time { width: 86px; } .cal-ag-row { flex-wrap: wrap; }
}
@media (max-width: 575.98px) { .cal-header h1 { font-size: 1.15rem; } .cal-month { min-width: 0; } .cal-week { min-width: 560px; } }
/* Calendar on phones: nothing may push the page wider than the screen */
.cal-main { min-width: 0; }
@media (max-width: 991.98px) { .cal-layout { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 575.98px) { #viewSwitch, #scopeSwitch { flex-wrap: wrap; width: 100%; } #viewSwitch .btn, #scopeSwitch .btn { flex: 1 1 auto; padding: 2px 6px; font-size: 12px; } #calTitle { font-size: 1rem; } }

/* =====================================================================
   Enterprise layer: roomier layout, grouped navigation, clearer tables
   ===================================================================== */
:root { --sidebar-width: 264px; --topbar-height: 62px; }
html { scroll-behavior: auto; }
body.modal-open { overflow: hidden; }

/* scrolling: the page scrolls as one document; the sidebar list scrolls on its own and never traps the wheel */
.app-shell { align-items: stretch; }
.app-main { display: flex; flex-direction: column; min-height: 100vh; }
.app-content { flex: 1; width: 100%; max-width: 1760px; margin: 0 auto; padding: 28px 32px 56px; }
.sidebar-nav { min-height: 0; overscroll-behavior: auto; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent; }
.cal-wk-scroll { max-height: min(640px, 72vh); overscroll-behavior: auto; }
.kanban-cards { overscroll-behavior: auto; }
.table-responsive { overscroll-behavior-x: contain; }

/* grouped sidebar */
.nav-section { padding: 16px 12px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: rgba(255,255,255,.38); }
.nav-section:first-child { padding-top: 6px; }
.nav-link { padding: 9px 12px; }
body.sidebar-collapsed .nav-section { padding: 10px 0 2px; text-align: center; }
body.sidebar-collapsed .nav-section span { display: none; }
body.sidebar-collapsed .nav-section::before { content: ''; display: block; border-top: 1px solid rgba(255,255,255,.12); margin: 0 14px; }

/* top bar */
.app-topbar { padding: 0 32px; gap: 20px; }
.topbar-search { max-width: 520px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.topbar-workspace { font-size: var(--fs-sm); font-weight: 600; color: var(--mc-gray-600); display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--mc-gray-200); border-radius: var(--r-md); background: #fff; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-icon { position: relative; color: var(--mc-gray-600); font-size: 22px; line-height: 1; display: inline-flex; padding: 6px; border-radius: var(--r-md); text-decoration: none; }
.topbar-icon:hover { background: var(--mc-gray-100); color: var(--mc-ink); }
.topbar-icon .badge { position: absolute; top: 0; right: 0; font-size: 10px; }
@media (max-width: 991px) { .topbar-workspace { display: none; } .app-content { padding: 20px 16px 48px; } .app-topbar { padding: 0 16px; } }

/* page headers and cards */
.page-header { padding-bottom: 16px; margin-bottom: 22px; border-bottom: 1px solid var(--mc-gray-200); flex-wrap: wrap; }
.page-header h1 { font-size: 1.5rem; display: flex; align-items: center; gap: 10px; }
.page-header h1 > i { color: var(--mc-blue); font-size: 1.4em; }
.card { border-color: var(--mc-gray-200); border-radius: 10px; box-shadow: 0 1px 2px rgba(16,28,72,.04); }
.card-header { border-bottom-color: var(--mc-gray-200); }
.kpi-card { border: 1px solid var(--mc-gray-200); border-radius: 10px; box-shadow: 0 1px 2px rgba(16,28,72,.04); }
.nav-tabs { border-bottom-color: var(--mc-gray-200); }

/* tables: clearer headers, comfortable rows, sticky header inside scrolling tables */
.table > :not(caption) > * > * { padding: .7rem .85rem; vertical-align: middle; }
.table thead th { font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--mc-gray-500); background: var(--mc-gray-50); border-bottom: 1px solid var(--mc-gray-200); white-space: nowrap; }
.table-hover > tbody > tr:hover > * { background: #f5f8ff; }
.table-responsive { border-radius: 10px; }
th.sortable { cursor: pointer; user-select: none; } th.sortable:hover { color: var(--mc-blue); }
.empty-state { padding: 56px 20px; }

/* forms and filters */
.form-label { font-size: 12.5px; font-weight: 600; color: var(--mc-gray-600); margin-bottom: 4px; }
.form-control, .form-select { border-color: var(--mc-gray-300, #d5d9e4); }
.form-control-sm, .form-select-sm { min-height: 34px; }
.bulk-bar { border-left: 3px solid var(--mc-blue); }
.modal-content { border-radius: 12px; border: 0; box-shadow: 0 20px 50px rgba(16,28,72,.22); }
.modal-header { border-bottom-color: var(--mc-gray-200); } .modal-footer { border-top-color: var(--mc-gray-200); }

/* selects: keep room for the arrow (the padding shorthands above would otherwise cover it) */
.form-select { padding-right: 2.25rem; background-position: right .75rem center; }
.form-select-sm { padding-right: 2rem; background-position: right .6rem center; }
.input-group > .form-select { padding-right: 2rem; }

/* search-as-you-type result lists (deal / invoice pickers): opaque, bordered, above following fields */
.pick-results { position: absolute; left: 0; right: 0; top: 100%; z-index: 1056; max-height: 240px; overflow-y: auto; background: #fff; border: 1px solid var(--mc-gray-200); border-radius: var(--r-md); box-shadow: 0 8px 24px rgba(16,28,72,.14); margin-top: 2px; }
.pick-results:empty { display: none; }
.pick-results .list-group-item { border-left: 0; border-right: 0; border-radius: 0; white-space: normal; }
.pick-results .pick-empty { padding: 8px 12px; font-size: var(--fs-sm); color: var(--mc-gray-500); }
.pick-wrap { position: relative; }

/* invoice line items */
#itemsTable th, #itemsTable td { vertical-align: top; }
#itemsTable .ln-total { padding-top: 10px; white-space: nowrap; }
#itemsTable .ln-dates { display: flex; gap: 4px; margin-top: 4px; }
#itemsTable .ln-dates .form-control { min-width: 0; flex: 1 1 0; }
.tax-pick .ln-tax { display: none; margin-top: 4px; }
.tax-pick.is-custom .ln-tax { display: block; }
#itemsTable { table-layout: fixed; }
#itemsTable .ln-disc { min-width: 0; }

/* proposal template builder steps (page-level pills; the sidebar .nav-link look must not leak in) */
#tbSteps .nav-link { color: var(--mc-gray-700); background: var(--mc-gray-100); margin: 0; padding: .25rem .65rem; gap: 0; border-radius: 999px; font-size: var(--fs-sm); }
#tbSteps .nav-link::before { display: none; }
#tbSteps .nav-link:hover { color: var(--mc-ink); background: var(--mc-gray-200); }
#tbSteps .nav-link.active { color: #fff; background: var(--mc-blue); font-weight: 600; }

/* ---- Engage ---- */
.engage-tabs { gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--mc-gray-200); padding-bottom: 8px; }
.engage-tabs .nav-link { color: #42526e; padding: 6px 12px; border-radius: 8px; font-size: .875rem; display: inline-flex; align-items: center; gap: 6px; }
.engage-tabs .nav-link:hover { background: #f1f4fa; }
.engage-tabs .nav-link.active { background: var(--mc-blue, #488bfd); color: #fff; }
.engage-tabs .nav-link.active .badge { background: #fff !important; color: var(--mc-blue, #488bfd); }
.eng-pills .nav-link { color: #42526e; background: #fff; border: 1px solid #dfe4ee; }
.eng-pills .nav-link.active { background: var(--mc-blue, #488bfd); border-color: var(--mc-blue, #488bfd); color: #fff; }
.eng-pills .nav-link .badge { font-weight: 600; }
.eng-inbox { display: grid; grid-template-columns: 340px minmax(0, 1fr) 300px; gap: 0; height: calc(100vh - 290px); min-height: 520px; background: #fff; border: 1px solid var(--mc-gray-200); border-radius: 12px; overflow: hidden; }
.eng-inbox > div { min-height: 0; display: flex; flex-direction: column; }
.eng-inbox .pane-list { border-right: 1px solid var(--mc-gray-200); }
.eng-inbox .pane-info { border-left: 1px solid var(--mc-gray-200); overflow: auto; }
.eng-conv { padding: 10px 14px; border-bottom: 1px solid #eef1f6; cursor: pointer; }
.eng-conv:hover { background: #f7f9fd; } .eng-conv.active { background: #e9f1ff; }
.eng-conv.unread .eng-conv-name, .eng-conv.unread .eng-conv-subj { font-weight: 700; }
.eng-msg { max-width: 82%; padding: 10px 14px; border-radius: 12px; font-size: .9rem; white-space: pre-wrap; word-break: break-word; }
.eng-msg.in { background: #f1f4fa; align-self: flex-start; } .eng-msg.out { background: #e3eeff; align-self: flex-end; } .eng-msg.note { background: #fff7e0; border: 1px dashed #e8c766; align-self: center; max-width: 90%; }
.eng-ai-banner { background: #f4f0ff; border: 1px solid #ddd2ff; color: #5b3fc4; border-radius: 8px; padding: 6px 10px; font-size: .8rem; }
.eng-step { border: 1px solid var(--mc-gray-200); border-radius: 10px; background: #fff; }
.eng-step-dot { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 17px; flex: none; }
.eng-timeline { border-left: 2px solid #e5e9f2; margin-left: 14px; padding-left: 18px; }
.eng-timeline .item { position: relative; padding-bottom: 14px; }
.eng-timeline .item .dot { position: absolute; left: -33px; top: 0; width: 28px; height: 28px; border-radius: 50%; background: #e9f1ff; color: #488bfd; display: flex; align-items: center; justify-content: center; }
.eng-editor { min-height: 260px; max-height: 420px; overflow: auto; border: 1px solid #ced4da; border-radius: 0 0 6px 6px; padding: 12px; background: #fff; }
.eng-editor:focus { outline: 2px solid rgba(72,139,253,.35); }
.eng-toolbar { border: 1px solid #ced4da; border-bottom: 0; border-radius: 6px 6px 0 0; background: #f8f9fc; padding: 4px 6px; display: flex; flex-wrap: wrap; gap: 2px; }
.eng-toolbar .btn { padding: 2px 8px; }
.eng-preview { border: 1px solid #e3e7f0; border-radius: 8px; background: #fff; padding: 16px; overflow: auto; max-height: 420px; }
@media (max-width: 1200px) { .eng-inbox { grid-template-columns: 300px minmax(0, 1fr); } .eng-inbox .pane-info { display: none; } }
@media (max-width: 767px) { .eng-inbox { grid-template-columns: 1fr; height: auto; } .eng-inbox .pane-thread { display: none; } .eng-inbox.has-open .pane-list { display: none; } .eng-inbox.has-open .pane-thread { display: flex; min-height: 70vh; } }
#sideTabs .nav-link { color: #42526e; font-size: .85rem; padding: 6px 12px; }
#sideTabs .nav-link.active { color: #1f2937; font-weight: 600; }
