/* =====================================================================
   AAIGL CRM — theme on top of Bootstrap 5.3
   Design tokens ported from the original HTML build. Workspace accents
   swap via [data-workspace] on <body>; dark mode via [data-bs-theme].
   ===================================================================== */

/* ============================= TOKENS ============================= */
:root {
  --n-0: #ffffff; --n-25: #fbfcfd; --n-50: #f6f8fa; --n-100: #eef1f5; --n-150: #e4e8ee; --n-200: #dde2e9;
  --n-300: #c6ccd6; --n-400: #9aa3b2; --n-500: #717c8d; --n-600: #545e6f; --n-700: #3b4453; --n-800: #262d3a; --n-900: #171c26;

  --bg-app: var(--n-50); --bg-surface: var(--n-0); --bg-sunken: var(--n-100);
  --bg-hover: rgba(23, 28, 38, .045); --bg-active: rgba(23, 28, 38, .07);
  --border-subtle: var(--n-150); --border-default: var(--n-200);
  --text-primary: var(--n-900); --text-secondary: var(--n-600); --text-tertiary: var(--n-400);

  --status-green-bg: #e7f6ec; --status-green-fg: #157a3d; --status-green-dot: #22c55e;
  --status-amber-bg: #fef3e2; --status-amber-fg: #a3620a; --status-amber-dot: #f59e0b;
  --status-red-bg: #fdecec; --status-red-fg: #c3271f; --status-red-dot: #ef4444;
  --status-blue-bg: #e8f1ff; --status-blue-fg: #1954b8; --status-blue-dot: #3b82f6;
  --status-grey-bg: #eef1f5; --status-grey-fg: #545e6f; --status-grey-dot: #9aa3b2;
  --status-purple-bg: #f1ecfd; --status-purple-fg: #6d3ed1; --status-purple-dot: #8b5cf6;

  --shadow-xs: 0 1px 2px rgba(23, 28, 38, .05);
  --shadow-sm: 0 1px 3px rgba(23, 28, 38, .08), 0 1px 2px rgba(23, 28, 38, .04);
  --shadow-md: 0 4px 14px rgba(23, 28, 38, .09), 0 1px 3px rgba(23, 28, 38, .06);
  --shadow-lg: 0 12px 32px rgba(23, 28, 38, .14), 0 2px 8px rgba(23, 28, 38, .06);

  --r-xs: 6px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px; --r-full: 999px;
  --ease-out: cubic-bezier(.16, 1, .3, 1); --dur-fast: 140ms; --dur-base: 220ms; --dur-slow: 320ms;
  --topbar-h: 58px; --sidebar-w: 216px; --sidebar-w-collapsed: 66px;

  /* Owner / "all" workspace = indigo */
  --ws-primary: #4338ca; --ws-primary-600: #372ea8; --ws-primary-50: #eeecfc; --ws-primary-100: #ddd9f8;
  --ws-accent: #ea580c; --ws-gradient: linear-gradient(135deg, #4338ca 0%, #6d28d9 100%);
  --ring-color: rgba(67, 56, 202, .22);

  /* Bootstrap mapping */
  --bs-body-font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bs-body-font-size: 14px;
  --bs-body-line-height: 1.5;
  --bs-body-bg: var(--bg-app);
  --bs-body-color: var(--text-primary);
  --bs-secondary-color: var(--text-secondary);
  --bs-tertiary-color: var(--text-tertiary);
  --bs-border-color: var(--border-default);
  --bs-border-radius: var(--r-sm);
  --bs-border-radius-lg: var(--r-md);
  --bs-link-color: var(--ws-primary);
  --bs-link-hover-color: var(--ws-primary-600);
  --bs-link-color-rgb: 67, 56, 202;
  --bs-emphasis-color: var(--text-primary);
  --bs-secondary-bg: var(--n-100);
  --bs-tertiary-bg: var(--n-50);
}

body[data-workspace="immigration"] {
  --ws-primary: #1d4ed8; --ws-primary-600: #1741b3; --ws-primary-50: #eaf1ff; --ws-primary-100: #d6e4ff;
  --ws-accent: #0891b2; --ws-gradient: linear-gradient(135deg, #1d4ed8 0%, #1e3a8a 100%); --ring-color: rgba(29, 78, 216, .22);
  --bs-link-color: #1d4ed8; --bs-link-color-rgb: 29, 78, 216;
}
body[data-workspace="travel"] {
  --ws-primary: #0d9488; --ws-primary-600: #0a7c72; --ws-primary-50: #e7f7f5; --ws-primary-100: #cdf0ea;
  --ws-accent: #f97316; --ws-gradient: linear-gradient(135deg, #0d9488 0%, #f97316 100%); --ring-color: rgba(13, 148, 136, .22);
  --bs-link-color: #0d9488; --bs-link-color-rgb: 13, 148, 136;
}

/* ------------------------------ DARK ------------------------------ */
[data-bs-theme="dark"] {
  --n-0: #1c212b; --n-25: #20262f; --n-50: #14171c; --n-100: #262c37; --n-150: #2f3642; --n-200: #3a4250;
  --n-300: #4c5563; --n-400: #7c8798; --n-500: #94a0b0; --n-600: #b3bcc8; --n-700: #cad1da; --n-800: #e1e5eb; --n-900: #f4f6f8;
  --bg-hover: rgba(255, 255, 255, .055); --bg-active: rgba(255, 255, 255, .09);
  --status-green-bg: #103522; --status-green-fg: #4ade80;
  --status-amber-bg: #3a2a0c; --status-amber-fg: #fbbf24;
  --status-red-bg: #3a1414; --status-red-fg: #f87171;
  --status-blue-bg: #102a4d; --status-blue-fg: #60a5fa;
  --status-grey-bg: #262c37; --status-grey-fg: #b3bcc8;
  --status-purple-bg: #291f47; --status-purple-fg: #a78bfa;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .5), 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, .45), 0 1px 3px rgba(0, 0, 0, .35);
  --shadow-lg: 0 12px 34px rgba(0, 0, 0, .6), 0 2px 10px rgba(0, 0, 0, .4);
  --bs-body-bg: var(--bg-app);
  --bs-body-color: var(--text-primary);
  --bs-border-color: var(--border-default);
  --bs-secondary-bg: var(--n-100);
  --bs-tertiary-bg: var(--n-50);
  --bs-emphasis-color: var(--text-primary);
  --ws-primary: #6366f1; --ws-primary-600: #818cf8; --ws-primary-50: #201c3a; --ws-primary-100: #2a2450; --ring-color: rgba(99, 102, 241, .35);
}
[data-bs-theme="dark"] body[data-workspace="immigration"] { --ws-primary: #3b82f6; --ws-primary-600: #60a5fa; --ws-primary-50: #142542; --ws-primary-100: #1a325a; --ring-color: rgba(59, 130, 246, .35); }
[data-bs-theme="dark"] body[data-workspace="travel"] { --ws-primary: #14b8a6; --ws-primary-600: #2dd4bf; --ws-primary-50: #0e2e2a; --ws-primary-100: #123a35; --ring-color: rgba(20, 184, 166, .35); }

/* ============================= BASE ============================= */
body { -webkit-font-smoothing: antialiased; background: var(--bg-app); color: var(--text-primary); }
a { text-decoration: none; }
h1, h2, h3, h4, h5, h6 { color: var(--text-primary); }
::selection { background: var(--ws-primary-100); color: var(--text-primary); }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--n-300); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--n-400); }
svg.lucide { width: 18px; height: 18px; flex-shrink: 0; }
[x-cloak], .u-hidden { display: none !important; }
.text-muted, .u-muted { color: var(--text-secondary) !important; }
.u-faint { color: var(--text-tertiary) !important; }
.u-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fs-xs { font-size: 11.5px !important; }
.fs-sm { font-size: 12.5px !important; }
.fs-md { font-size: 13.5px !important; }
.fw-800 { font-weight: 800 !important; }
.min-w-0 { min-width: 0 !important; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

/* ============================= BUTTONS ============================= */
.btn {
  --bs-btn-font-size: 13.5px; --bs-btn-font-weight: 600; --bs-btn-padding-x: 14px; --bs-btn-padding-y: 0;
  --bs-btn-border-radius: var(--r-sm); --bs-btn-focus-box-shadow: 0 0 0 3px var(--ring-color);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast), transform var(--dur-fast), box-shadow var(--dur-fast);
}
.btn:active { transform: scale(.97); }
.btn svg.lucide { width: 16px; height: 16px; }
.btn-sm { --bs-btn-font-size: 12.5px; --bs-btn-padding-x: 11px; height: 30px; --bs-btn-border-radius: var(--r-xs); }
.btn-sm svg.lucide { width: 14px; height: 14px; }
.btn-lg { --bs-btn-font-size: 14.5px; --bs-btn-padding-x: 20px; height: 42px; }
.btn-icon { width: 36px; padding: 0 !important; }
.btn-icon.btn-sm { width: 30px; }
.btn-primary {
  --bs-btn-bg: var(--ws-primary); --bs-btn-border-color: var(--ws-primary); --bs-btn-color: #fff;
  --bs-btn-hover-bg: var(--ws-primary-600); --bs-btn-hover-border-color: var(--ws-primary-600); --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--ws-primary-600); --bs-btn-active-border-color: var(--ws-primary-600); --bs-btn-active-color: #fff;
  --bs-btn-disabled-bg: var(--ws-primary); --bs-btn-disabled-border-color: var(--ws-primary); box-shadow: var(--shadow-xs);
}
.btn-secondary {
  --bs-btn-bg: var(--n-0); --bs-btn-border-color: var(--border-default); --bs-btn-color: var(--text-primary);
  --bs-btn-hover-bg: var(--n-50); --bs-btn-hover-border-color: var(--n-300); --bs-btn-hover-color: var(--text-primary);
  --bs-btn-active-bg: var(--n-100); --bs-btn-active-border-color: var(--n-300); --bs-btn-active-color: var(--text-primary);
  --bs-btn-disabled-bg: var(--n-0); --bs-btn-disabled-color: var(--text-tertiary); --bs-btn-disabled-border-color: var(--border-default);
}
.btn-ghost {
  --bs-btn-bg: transparent; --bs-btn-border-color: transparent; --bs-btn-color: var(--text-secondary);
  --bs-btn-hover-bg: var(--bg-hover); --bs-btn-hover-border-color: transparent; --bs-btn-hover-color: var(--text-primary);
  --bs-btn-active-bg: var(--bg-active); --bs-btn-active-border-color: transparent; --bs-btn-active-color: var(--text-primary);
}
.btn-soft {
  --bs-btn-bg: var(--ws-primary-50); --bs-btn-border-color: transparent; --bs-btn-color: var(--ws-primary);
  --bs-btn-hover-bg: var(--ws-primary-100); --bs-btn-hover-border-color: transparent; --bs-btn-hover-color: var(--ws-primary);
  --bs-btn-active-bg: var(--ws-primary-100); --bs-btn-active-color: var(--ws-primary);
}
.btn-danger { --bs-btn-bg: var(--status-red-fg); --bs-btn-border-color: var(--status-red-fg); --bs-btn-hover-bg: #a8201a; --bs-btn-hover-border-color: #a8201a; }
.btn-success { --bs-btn-bg: #157a3d; --bs-btn-border-color: #157a3d; --bs-btn-hover-bg: #0f5d34; --bs-btn-hover-border-color: #0f5d34; }

/* ============================= FORMS ============================= */
.form-label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-control, .form-select {
  min-height: 38px; font-size: 13.5px; border-radius: var(--r-sm); border-color: var(--border-default);
  background-color: var(--n-0); color: var(--text-primary);
}
textarea.form-control { min-height: 78px; line-height: 1.5; }
.form-control:focus, .form-select:focus { border-color: var(--ws-primary); box-shadow: 0 0 0 3px var(--ring-color); background-color: var(--n-0); color: var(--text-primary); }
.form-control::placeholder { color: var(--text-tertiary); }
.form-control-sm, .form-select-sm { min-height: 32px; font-size: 12.5px; }
.form-check-input:checked { background-color: var(--ws-primary); border-color: var(--ws-primary); }
.form-check-input:focus { box-shadow: 0 0 0 3px var(--ring-color); border-color: var(--ws-primary); }
.form-switch .form-check-input { width: 2.4em; height: 1.3em; cursor: pointer; }
.form-text { font-size: 11.5px; color: var(--text-tertiary); }
.invalid-feedback { font-size: 12px; }
.input-search { position: relative; }
.input-search > svg.lucide, .input-search > i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); pointer-events: none; width: 16px; height: 16px; }
.input-search .form-control { padding-left: 36px; }
.field-stack { display: flex; flex-direction: column; gap: 14px; }

/* ============================= CARDS ============================= */
.card { --bs-card-bg: var(--bg-surface); --bs-card-border-color: var(--border-subtle); --bs-card-border-radius: var(--r-md); box-shadow: var(--shadow-xs); color: var(--text-primary); }
.card-pad { padding: 18px 20px; }
@media (max-width: 575.98px) { .card-pad { padding: 14px 14px; } }
.section-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--text-tertiary); margin-bottom: 10px; }
.divider { height: 1px; background: var(--border-subtle); border: none; margin: 14px 0; opacity: 1; }

/* ============================= BADGES / CHIPS ============================= */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: var(--r-full);
  font-size: 11.5px; font-weight: 700; letter-spacing: .01em; white-space: nowrap; line-height: 1; vertical-align: middle;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge.no-dot::before { display: none; }
.badge svg.lucide { width: 11px; height: 11px; }
.badge-green { background: var(--status-green-bg); color: var(--status-green-fg); }
.badge-amber { background: var(--status-amber-bg); color: var(--status-amber-fg); }
.badge-red { background: var(--status-red-bg); color: var(--status-red-fg); }
.badge-blue { background: var(--status-blue-bg); color: var(--status-blue-fg); }
.badge-grey { background: var(--status-grey-bg); color: var(--status-grey-fg); }
.badge-purple { background: var(--status-purple-bg); color: var(--status-purple-fg); }
.text-capitalize-first::first-letter { text-transform: uppercase; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: var(--r-full);
  background: var(--n-100); color: var(--text-secondary); font-size: 12.5px; font-weight: 600; border: 1px solid transparent;
  cursor: pointer; transition: all var(--dur-fast); white-space: nowrap; text-decoration: none;
}
.chip:hover { background: var(--n-150); color: var(--text-primary); }
.chip.active { background: var(--ws-primary-50); color: var(--ws-primary); border-color: var(--ws-primary-100); }
.chip-count { font-size: 10.5px; font-weight: 800; opacity: .75; }
.chip-scroll { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
.chip-scroll::-webkit-scrollbar { display: none; }

.avatar {
  display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--ws-gradient);
  color: #fff; font-weight: 700; flex-shrink: 0; font-size: 12.5px; width: 30px; height: 30px; line-height: 1;
}
.avatar-lg { width: 52px; height: 52px; font-size: 18px; }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.kbd { display: inline-flex; align-items: center; padding: 1px 6px; border-radius: 5px; background: var(--n-100); border: 1px solid var(--border-default); font-size: 11px; font-weight: 700; color: var(--text-secondary); }
.score-bar { width: 40px; height: 5px; background: var(--n-150); border-radius: 99px; overflow: hidden; }
.score-bar > span { display: block; height: 100%; background: var(--ws-primary); }
.icon-tile { width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon-tile svg.lucide { width: 17px; height: 17px; }
.tint-blue { background: var(--status-blue-bg); color: var(--status-blue-fg); }
.tint-green { background: var(--status-green-bg); color: var(--status-green-fg); }
.tint-amber { background: var(--status-amber-bg); color: var(--status-amber-fg); }
.tint-red { background: var(--status-red-bg); color: var(--status-red-fg); }
.tint-purple { background: var(--status-purple-bg); color: var(--status-purple-fg); }
.tint-grey { background: var(--status-grey-bg); color: var(--status-grey-fg); }
.tint-ws { background: var(--ws-primary-50); color: var(--ws-primary); }

/* ============================= TABLES ============================= */
.dtable { width: 100%; margin: 0; border-collapse: collapse; --bs-table-bg: transparent; color: var(--text-primary); }
.dtable thead th {
  background: var(--n-25); text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-tertiary); padding: 10px 14px; border-bottom: 1px solid var(--border-subtle); white-space: nowrap;
}
.dtable thead th:first-child { border-top-left-radius: var(--r-md); }
.dtable thead th:last-child { border-top-right-radius: var(--r-md); }
.dtable tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border-subtle); font-size: 13.5px; vertical-align: middle; background: transparent; color: var(--text-primary); }
.dtable tbody tr { transition: background var(--dur-fast); }
.dtable tbody tr.row-link { cursor: pointer; }
.dtable tbody tr:hover td { background: var(--bg-hover); }
.dtable tbody tr:last-child td { border-bottom: none; }
.dtable .cell-actions { width: 1%; white-space: nowrap; text-align: right; }
.row-done td { opacity: .8; }
.row-done .task-title { text-decoration: line-through; opacity: .7; }
.table-responsive { border-radius: var(--r-md); }
.pagination { --bs-pagination-color: var(--text-secondary); --bs-pagination-bg: var(--n-0); --bs-pagination-border-color: var(--border-default); --bs-pagination-active-bg: var(--ws-primary); --bs-pagination-active-border-color: var(--ws-primary); --bs-pagination-hover-bg: var(--n-50); --bs-pagination-focus-box-shadow: 0 0 0 3px var(--ring-color); --bs-pagination-font-size: 13px; margin: 0; }
.list-footer { padding: 12px 14px; border-top: 1px solid var(--border-subtle); display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.list-footer nav p { display: none; }

/* ============================= APP SHELL ============================= */
#topbar {
  position: sticky; top: 0; z-index: 1030; height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: var(--bg-surface); border-bottom: 1px solid var(--border-subtle);
  padding-top: env(safe-area-inset-top, 0px); box-sizing: content-box;
}
.tb-logo { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 15px; color: var(--text-primary); }
.tb-logo:hover { color: var(--text-primary); }
.tb-logo-mark {
  width: 30px; height: 30px; border-radius: 9px; background: var(--ws-gradient); display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 900; transition: background var(--dur-base); flex-shrink: 0;
}
.ws-switcher-btn {
  display: flex; align-items: center; gap: 9px; height: 38px; padding: 0 10px 0 6px; border-radius: var(--r-sm);
  background: var(--n-100); cursor: pointer; border: 1px solid transparent; color: var(--text-primary); transition: background var(--dur-fast);
}
.ws-switcher-btn:hover, .ws-switcher-btn[aria-expanded="true"] { background: var(--n-150); }
.ws-switcher-icon { width: 26px; height: 26px; border-radius: 7px; display: flex; align-items: center; justify-content: center; background: var(--ws-gradient); color: #fff; }
.ws-switcher-icon svg.lucide { width: 15px; height: 15px; }
.ws-switcher-text { font-size: 13px; font-weight: 700; }
.ws-menu { width: 260px; padding: 6px; }
.ws-menu-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-sm); cursor: pointer; width: 100%; border: 0; background: transparent; text-align: left; color: var(--text-primary); }
.ws-menu-item:hover { background: var(--bg-hover); }
.ws-menu-item.active { background: var(--ws-primary-50); }
.ws-menu-item .dot { width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0; }
.ws-menu-item-title { font-size: 13px; font-weight: 700; display: block; }
.ws-menu-item-sub { font-size: 11px; color: var(--text-tertiary); display: block; }
.tb-search {
  flex: 1; max-width: 420px; height: 38px; border-radius: var(--r-sm); background: var(--n-100); display: flex; align-items: center;
  gap: 9px; padding: 0 12px; color: var(--text-tertiary); cursor: pointer; border: 0; transition: background var(--dur-fast); font-size: 13px;
}
.tb-search:hover { background: var(--n-150); }
.tb-search svg.lucide { width: 16px; height: 16px; }
.tb-spacer { flex: 1; }
.tb-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--r-sm); display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-secondary); cursor: pointer; position: relative; border: 0; background: transparent; transition: background var(--dur-fast), color var(--dur-fast);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn .dot-badge { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--status-red-dot); border: 2px solid var(--bg-surface); }
.tb-profile { display: flex; align-items: center; cursor: pointer; padding: 3px; border-radius: var(--r-full); border: 0; background: transparent; }
.tb-profile:hover { background: var(--bg-hover); }
.dropdown-menu { --bs-dropdown-bg: var(--bg-surface); --bs-dropdown-border-color: var(--border-subtle); --bs-dropdown-border-radius: var(--r-md); --bs-dropdown-link-color: var(--text-primary); --bs-dropdown-link-hover-bg: var(--bg-hover); --bs-dropdown-link-hover-color: var(--text-primary); --bs-dropdown-link-active-bg: var(--ws-primary-50); --bs-dropdown-link-active-color: var(--ws-primary); --bs-dropdown-font-size: 13px; box-shadow: var(--shadow-lg); padding: 6px; }
.dropdown-item { border-radius: var(--r-sm); padding: 8px 10px; display: flex; align-items: center; gap: 10px; font-weight: 600; }
.dropdown-item svg.lucide { width: 16px; height: 16px; color: var(--text-tertiary); }

#app-body { display: flex; min-height: calc(100vh - var(--topbar-h)); }
#sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--bg-surface); border-right: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; padding: 12px 10px; position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h)); overflow-y: auto; overflow-x: hidden; transition: width var(--dur-base) var(--ease-out); z-index: 1020;
}
#sidebar nav { flex: 1; }
.nav-group { margin-bottom: 4px; }
.nav-group-title { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text-tertiary); padding: 14px 10px 6px; white-space: nowrap; transition: opacity var(--dur-fast); }
.nav-item {
  display: flex; align-items: center; gap: 12px; height: 38px; padding: 0 10px; border-radius: var(--r-sm); color: var(--text-secondary);
  cursor: pointer; font-size: 13.3px; font-weight: 600; margin-bottom: 2px; transition: background var(--dur-fast), color var(--dur-fast);
  white-space: nowrap; position: relative; border: 0; background: transparent; width: 100%; text-align: left;
}
.nav-item svg.lucide { width: 18px; height: 18px; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--ws-primary-50); color: var(--ws-primary); }
.nav-label { transition: opacity var(--dur-fast); overflow: hidden; text-overflow: ellipsis; }
.nav-count { margin-left: auto; font-size: 10.5px; font-weight: 800; background: var(--n-150); color: var(--text-secondary); padding: 1px 7px; border-radius: 999px; }
.nav-item.active .nav-count { background: var(--ws-primary-100); color: var(--ws-primary); }
#sidebar-collapse-btn { margin-top: 8px; }
body.sidebar-collapsed #sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed #sidebar .nav-label, body.sidebar-collapsed #sidebar .nav-group-title, body.sidebar-collapsed #sidebar .nav-count { opacity: 0; width: 0; padding-left: 0; padding-right: 0; }
body.sidebar-collapsed #sidebar-collapse-btn svg { transform: rotate(180deg); }
#sidebar-backdrop { display: none; }

#main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#view-root { flex: 1; padding: 22px 26px 60px; animation: fadeUp var(--dur-base) var(--ease-out); min-width: 0; }

.view-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 12px 16px; flex-wrap: wrap; }
.view-title { font-size: 21px; font-weight: 800; letter-spacing: -.01em; margin: 0; line-height: 1.25; }
.view-sub { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }
.view-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.view-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px 12px; margin-bottom: 16px; flex-wrap: wrap; }
.view-toolbar-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.view-toggle { display: inline-flex; background: var(--n-100); border-radius: var(--r-sm); padding: 3px; }
.view-toggle a, .view-toggle button { border: none; background: transparent; height: 30px; padding: 0 12px; border-radius: 6px; font-size: 12.5px; font-weight: 700; color: var(--text-secondary); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: all var(--dur-fast); }
.view-toggle a svg.lucide, .view-toggle button svg.lucide { width: 15px; height: 15px; }
.view-toggle .active { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-xs); }

/* ============================= DASHBOARD ============================= */
.kpi-card { padding: 18px 20px; position: relative; overflow: hidden; height: 100%; }
.kpi-label { font-size: 12px; font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .03em; padding-right: 40px; }
.kpi-value { font-size: 27px; font-weight: 800; margin-top: 8px; letter-spacing: -.02em; line-height: 1.2; word-break: break-word; }
.kpi-trend { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; margin-top: 6px; color: var(--text-secondary); }
.kpi-trend svg.lucide { width: 14px; height: 14px; }
.kpi-trend.up { color: var(--status-green-fg); }
.kpi-trend.down { color: var(--status-red-fg); }
.kpi-icon { position: absolute; top: 16px; right: 16px; width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.kpi-icon svg.lucide { width: 18px; height: 18px; }
.kpi-mini { padding: 14px 16px; height: 100%; display: block; color: var(--text-primary); transition: transform var(--dur-fast), box-shadow var(--dur-fast); }
a.kpi-mini:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); color: var(--text-primary); }
.kpi-mini-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-mini-val { font-size: 22px; font-weight: 800; margin-top: 4px; line-height: 1.1; }
.chart-card { padding: 18px 20px; height: 100%; }
.chart-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 8px; }
.chart-card-title { font-size: 13.5px; font-weight: 800; }
.chart-wrap { position: relative; height: 230px; }
.chart-wrap.sm { height: 180px; }
@media (max-width: 575.98px) { .chart-wrap { height: 210px; } .kpi-value { font-size: 23px; } .kpi-card, .chart-card { padding: 14px; } }

.feed-item { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border-subtle); }
.feed-item:last-child { border-bottom: none; }
.feed-icon { width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--ws-primary-50); color: var(--ws-primary); }
.feed-icon svg.lucide { width: 15px; height: 15px; }
.feed-text { font-size: 13px; word-break: break-word; }
.feed-time { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }
.task-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border-subtle); min-width: 0; }
.task-item:last-child { border-bottom: none; }
.task-item-body { flex: 1; min-width: 0; }
.task-item-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-item-sub { font-size: 11.5px; color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================= RECORD DETAIL ============================= */
.record-topbar { display: flex; align-items: center; justify-content: space-between; padding-bottom: 14px; gap: 14px; flex-wrap: wrap; }
.record-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.record-heading h1 { font-size: 19px; font-weight: 800; margin: 0; word-break: break-word; }
.record-quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.field-list { display: flex; flex-direction: column; gap: 14px; }
.field-row { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.fl-label { font-size: 11px; font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .03em; }
.fl-value { font-size: 13.5px; font-weight: 600; word-break: break-word; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }

.stagebar { display: flex; align-items: center; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: thin; }
.stagebar-step { display: flex; align-items: center; flex: 0 0 auto; cursor: pointer; border: 0; background: transparent; padding: 0; color: inherit; }
.stagebar-step:disabled { cursor: default; }
.stagebar-dot { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--n-150); color: var(--text-tertiary); font-size: 11px; font-weight: 800; flex-shrink: 0; transition: all var(--dur-base) var(--ease-out); }
.stagebar-dot svg.lucide { width: 12px; height: 12px; }
.stagebar-label { font-size: 11.5px; font-weight: 600; color: var(--text-tertiary); margin-left: 8px; white-space: nowrap; }
.stagebar-line { width: 28px; height: 2px; background: var(--n-150); margin: 0 8px; flex-shrink: 0; }
.stagebar-step.done .stagebar-dot { background: var(--ws-primary); color: #fff; }
.stagebar-step.done .stagebar-label { color: var(--text-primary); }
.stagebar-line.done { background: var(--ws-primary); }
.stagebar-step.current .stagebar-dot { background: var(--ws-primary); color: #fff; box-shadow: 0 0 0 4px var(--ws-primary-50); }
.stagebar-step.current .stagebar-label { color: var(--text-primary); font-weight: 800; }
.stagebar-step:not(:disabled):hover .stagebar-label { color: var(--ws-primary); }

.timeline { display: flex; flex-direction: column; }
.timeline-item { display: flex; gap: 12px; padding-bottom: 18px; position: relative; }
.timeline-item::before { content: ""; position: absolute; left: 15px; top: 32px; bottom: 0; width: 2px; background: var(--border-subtle); }
.timeline-item:last-child::before { display: none; }
.timeline-icon { width: 31px; height: 31px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; z-index: 1; background: var(--n-100); color: var(--text-secondary); }
.timeline-icon svg.lucide { width: 15px; height: 15px; }
.timeline-card { flex: 1; min-width: 0; background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--r-md); padding: 12px 14px; }
.timeline-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; gap: 8px; flex-wrap: wrap; }
.timeline-title { font-size: 13px; font-weight: 700; }
.timeline-time { font-size: 11px; color: var(--text-tertiary); }
.timeline-body { font-size: 13px; color: var(--text-secondary); word-break: break-word; white-space: pre-line; }
.timeline-composer { display: flex; gap: 8px; margin-bottom: 18px; }
.timeline-scroll { max-height: 640px; overflow-y: auto; padding-right: 4px; }

.checklist-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border-subtle); min-width: 0; }
.checklist-item:last-child { border-bottom: none; }
.checklist-toggle { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; border: 0; background: transparent; padding: 0; text-align: left; color: inherit; cursor: pointer; }
.checklist-check { width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; border: 2px solid var(--n-300); color: transparent; transition: all var(--dur-fast); }
.checklist-check svg.lucide { width: 12px; height: 12px; }
.checklist-item.verified .checklist-check { background: var(--status-green-dot); border-color: var(--status-green-dot); color: #fff; }
.checklist-item.received .checklist-check { background: var(--status-amber-dot); border-color: var(--status-amber-dot); color: #fff; }
.checklist-name { font-size: 13px; font-weight: 600; flex: 1; min-width: 0; word-break: break-word; }
.progress-thin { height: 4px; background: var(--n-150); border-radius: 999px; overflow: hidden; }
.progress-thin > span { display: block; height: 100%; background: var(--ws-primary); border-radius: 999px; transition: width var(--dur-slow) var(--ease-out); }

/* ============================= KANBAN ============================= */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; height: calc(100vh - 230px); min-height: 440px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.kanban-col { flex: 0 0 272px; display: flex; flex-direction: column; background: var(--n-100); border-radius: var(--r-md); max-height: 100%; scroll-snap-align: start; }
.kanban-col-head { padding: 12px 14px 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kanban-col-title { font-size: 12.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; min-width: 0; }
.kanban-col-title .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.kanban-col-count { font-size: 11px; font-weight: 700; color: var(--text-tertiary); background: var(--n-0); border-radius: var(--r-full); padding: 1px 7px; }
.kanban-col-total { font-size: 11px; color: var(--text-tertiary); padding: 0 14px 8px; font-weight: 600; margin-top: -4px; }
.kanban-col-body { flex: 1; overflow-y: auto; padding: 2px 10px 10px; display: flex; flex-direction: column; gap: 9px; min-height: 60px; }
.kanban-card {
  display: block; background: var(--bg-surface); border-radius: var(--r-sm); border: 1px solid var(--border-subtle); padding: 12px 13px;
  cursor: grab; box-shadow: var(--shadow-xs); color: var(--text-primary); transition: box-shadow var(--dur-fast), transform var(--dur-fast), border-color var(--dur-fast);
}
.kanban-card:hover { box-shadow: var(--shadow-md); border-color: var(--n-300); transform: translateY(-1px); color: var(--text-primary); }
.kanban-card.sortable-ghost { opacity: .4; }
.kanban-card.sortable-chosen { box-shadow: var(--shadow-lg); }
.kanban-card-title { font-weight: 700; font-size: 13.5px; margin-bottom: 4px; word-break: break-word; }
.kanban-card-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 11.5px; color: var(--text-tertiary); margin-top: 8px; }
.kanban-empty { font-size: 11.5px; color: var(--text-tertiary); text-align: center; padding: 12px 6px; border: 1px dashed var(--n-300); border-radius: var(--r-sm); }
@media (max-width: 767.98px) {
  .kanban { height: auto; min-height: 0; }
  .kanban-col { flex-basis: 82vw; max-height: 72vh; }
}

/* ============================= MODAL / OFFCANVAS ============================= */
.modal { --bs-modal-bg: var(--bg-surface); --bs-modal-border-radius: var(--r-lg); --bs-modal-border-color: var(--border-subtle); --bs-modal-header-border-color: var(--border-subtle); --bs-modal-footer-border-color: var(--border-subtle); --bs-modal-padding: 20px 22px; --bs-modal-header-padding: 16px 22px; --bs-modal-color: var(--text-primary); }
.modal-content { box-shadow: var(--shadow-lg); }
.modal-title { font-size: 16px; font-weight: 800; }
.modal-footer { gap: 8px; }
.modal-footer > * { margin: 0; }
.modal-backdrop { --bs-backdrop-bg: #0f121a; --bs-backdrop-opacity: .45; }
.offcanvas { --bs-offcanvas-bg: var(--bg-surface); --bs-offcanvas-color: var(--text-primary); --bs-offcanvas-border-color: var(--border-subtle); --bs-offcanvas-padding-x: 22px; --bs-offcanvas-padding-y: 18px; }
.offcanvas.offcanvas-end { --bs-offcanvas-width: 480px; max-width: 100vw; box-shadow: var(--shadow-lg); }
.offcanvas.offcanvas-wide { --bs-offcanvas-width: 560px; }
.offcanvas-header { border-bottom: 1px solid var(--border-subtle); }
.offcanvas-title { font-size: 16px; font-weight: 800; }
.offcanvas-footer { padding: 14px 22px; border-top: 1px solid var(--border-subtle); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
.offcanvas form.offcanvas-form { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.offcanvas form.offcanvas-form .offcanvas-body { flex: 1; overflow-y: auto; }
.btn-close:focus { box-shadow: 0 0 0 3px var(--ring-color); }
[data-bs-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }
.drawer-loading { display: flex; align-items: center; justify-content: center; padding: 60px 0; color: var(--text-tertiary); }

/* ============================= TABS ============================= */
.tab-row { display: flex; gap: 4px; border-bottom: 1px solid var(--border-subtle); overflow-x: auto; scrollbar-width: none; }
.tab-row::-webkit-scrollbar { display: none; }
.tab-item { padding: 10px 4px; margin-right: 20px; font-size: 13px; font-weight: 700; color: var(--text-tertiary); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; transition: color var(--dur-fast), border-color var(--dur-fast); }
.tab-item:hover { color: var(--text-primary); }
.tab-item.active { color: var(--ws-primary); border-color: var(--ws-primary); }

/* ============================= EMPTY / TOAST ============================= */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 50px 20px; text-align: center; color: var(--text-secondary); }
.empty-state .icon-wrap { width: 56px; height: 56px; border-radius: 16px; background: var(--ws-primary-50); color: var(--ws-primary); display: flex; align-items: center; justify-content: center; margin-bottom: 16px; }
.empty-state .icon-wrap svg.lucide { width: 26px; height: 26px; }
.empty-state h3 { font-size: 15px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.empty-state p { font-size: 13px; max-width: 340px; margin-bottom: 16px; }
.empty-state.sm { padding: 24px 10px; }

.toast-stack { position: fixed; bottom: 96px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; max-width: calc(100vw - 40px); }
.crm-toast { display: flex; align-items: center; gap: 10px; background: #1c212b; color: #fff; padding: 12px 16px; border-radius: var(--r-md); box-shadow: var(--shadow-lg); font-size: 13px; font-weight: 600; min-width: 240px; animation: fadeUp var(--dur-base) var(--ease-out); transition: opacity 200ms, transform 200ms; }
.crm-toast.success { background: #0f5d34; }
.crm-toast.error { background: #7f1d1d; }
.crm-toast svg.lucide { width: 17px; height: 17px; flex-shrink: 0; }

/* ============================= COMMAND PALETTE ============================= */
.cmdk-input-row { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--border-subtle); }
.cmdk-input-row input { flex: 1; border: none; outline: none; font-size: 15px; background: transparent; color: var(--text-primary); min-width: 0; }
.cmdk-results { max-height: 400px; overflow-y: auto; padding: 8px; }
.cmdk-group-title { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--text-tertiary); padding: 10px 10px 4px; }
.cmdk-item { display: flex; align-items: center; gap: 11px; padding: 10px; border-radius: var(--r-sm); cursor: pointer; color: var(--text-primary); }
.cmdk-item:hover, .cmdk-item.sel { background: var(--bg-hover); color: var(--text-primary); }
.cmdk-item-icon { width: 30px; height: 30px; border-radius: 8px; background: var(--n-100); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cmdk-item-icon svg.lucide { width: 15px; height: 15px; }

/* ============================= AI ASSISTANT ============================= */
.ai-chat-fab {
  position: fixed; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); right: 24px; z-index: 1040; width: 56px; height: 56px; border: none; border-radius: 50%;
  background: linear-gradient(145deg, var(--ws-primary), #0f766e); color: #fff; cursor: pointer;
  box-shadow: 0 10px 28px rgba(13, 148, 136, .35), var(--shadow-md); display: flex; align-items: center; justify-content: center; transition: transform var(--dur-fast) var(--ease-out);
}
.ai-chat-fab:hover { transform: scale(1.06); }
.ai-chat-fab.is-open { background: var(--n-800); }
.ai-chat-fab svg.lucide { width: 24px; height: 24px; }
.ai-chat-panel {
  position: fixed; bottom: calc(92px + env(safe-area-inset-bottom, 0px)); right: 24px; z-index: 1040; width: min(380px, calc(100vw - 32px)); height: min(520px, calc(100vh - 130px));
  background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden; opacity: 0; pointer-events: none; transform: translateY(12px) scale(.98);
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}
.ai-chat-panel.open { opacity: 1; pointer-events: auto; transform: none; }
.ai-chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: linear-gradient(135deg, #0f766e 0%, #134e4a 100%); color: #fff; }
.ai-chat-head-icon { width: 36px; height: 36px; border-radius: 10px; background: rgba(255, 255, 255, .16); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ai-chat-head-title { font-size: 14px; font-weight: 800; line-height: 1.2; }
.ai-chat-head-sub { font-size: 11.5px; opacity: .8; margin-top: 2px; }
.ai-chat-close { width: 32px; height: 32px; border: none; border-radius: 8px; background: rgba(255, 255, 255, .12); color: #fff; display: flex; align-items: center; justify-content: center; margin-left: auto; }
.ai-chat-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: var(--bg-app); }
.ai-msg { max-width: 88%; display: flex; flex-direction: column; gap: 4px; }
.ai-msg.bot { align-self: flex-start; }
.ai-msg.user { align-self: flex-end; }
.ai-msg-bubble { padding: 10px 13px; border-radius: 14px; font-size: 13px; line-height: 1.45; box-shadow: var(--shadow-xs); word-break: break-word; }
.ai-msg.bot .ai-msg-bubble { background: var(--bg-surface); color: var(--text-primary); border: 1px solid var(--border-subtle); border-bottom-left-radius: 4px; }
.ai-msg.user .ai-msg-bubble { background: var(--ws-primary); color: #fff; border-bottom-right-radius: 4px; }
.ai-msg-time { font-size: 10.5px; color: var(--text-tertiary); padding: 0 4px; }
.ai-msg.user .ai-msg-time { text-align: right; }
.ai-chat-suggestions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; background: var(--bg-app); }
.ai-chip { border: 1px solid var(--border-default); background: var(--bg-surface); color: var(--text-secondary); font-size: 11.5px; font-weight: 650; padding: 6px 10px; border-radius: var(--r-full); cursor: pointer; }
.ai-chip:hover { border-color: var(--ws-primary); color: var(--ws-primary); background: var(--ws-primary-50); }
.ai-chat-input-row { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border-subtle); background: var(--bg-surface); }
.ai-chat-input-row input { flex: 1; border: 1px solid var(--border-default); border-radius: var(--r-full); padding: 10px 14px; font-size: 13px; background: var(--bg-app); color: var(--text-primary); outline: none; min-width: 0; }
.ai-chat-input-row input:focus { border-color: var(--ws-primary); box-shadow: 0 0 0 3px var(--ring-color); }
.ai-chat-send { width: 40px; height: 40px; border: none; border-radius: 50%; background: var(--ws-primary); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ai-chat-send:disabled { opacity: .5; }

/* ============================= TASKS ============================= */
.act-type-icon { width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--n-100); color: var(--text-secondary); }
.act-type-icon svg.lucide { width: 15px; height: 15px; }
.act-type-task { background: var(--status-blue-bg); color: var(--status-blue-fg); }
.act-type-followup { background: var(--status-amber-bg); color: var(--status-amber-fg); }
.act-type-call { background: var(--status-green-bg); color: var(--status-green-fg); }
.act-type-meeting { background: var(--status-purple-bg); color: var(--status-purple-fg); }
.act-type-email, .act-type-note { background: var(--status-grey-bg); color: var(--status-grey-fg); }
.act-type-whatsapp { background: var(--status-green-bg); color: var(--status-green-fg); }
.act-filterbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; margin-bottom: 14px; flex-wrap: wrap; }
.act-filterbar form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.act-filterbar .input-search { width: 220px; }
.act-filterbar .form-select { width: auto; min-width: 130px; }
@media (max-width: 575.98px) { .act-filterbar .input-search, .act-filterbar .form-select { width: 100%; flex: 1 1 100%; } }
.row-actions { display: inline-flex; align-items: center; gap: 4px; flex-wrap: nowrap; }

.cal-grid-head { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; font-size: 11.5px; font-weight: 700; color: var(--text-tertiary); text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-cell { min-height: 100px; border: 1px solid var(--border-subtle); border-radius: var(--r-sm); padding: 8px; background: var(--bg-surface); color: var(--text-primary); display: block; min-width: 0; transition: background var(--dur-fast); }
a.cal-cell:hover { background: var(--bg-hover); color: var(--text-primary); }
.cal-cell.is-empty { background: transparent; border-color: transparent; }
.cal-cell.is-today { border-color: var(--ws-primary); box-shadow: inset 0 0 0 1px var(--ws-primary-100); }
.cal-date { font-size: 12px; font-weight: 800; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }
.cal-dot-count { display: none; font-size: 10px; font-weight: 800; background: var(--ws-primary); color: #fff; border-radius: 99px; padding: 0 5px; }
.cal-chip { font-size: 10.5px; font-weight: 600; padding: 3px 6px; border-radius: 5px; margin-bottom: 3px; background: var(--ws-primary-50); color: var(--ws-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-chip.is-overdue { background: var(--status-red-bg); color: var(--status-red-fg); }
.cal-chip.is-done { background: var(--status-green-bg); color: var(--status-green-fg); text-decoration: line-through; }
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.cal-week-col { border: 1px solid var(--border-subtle); border-radius: var(--r-sm); padding: 10px; min-height: 180px; min-width: 0; }
.cal-week-col.is-today { border-color: var(--ws-primary); }
.cal-week-head { font-weight: 800; font-size: 12.5px; margin-bottom: 8px; }
.cal-event { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border-subtle); border-radius: var(--r-sm); margin-bottom: 8px; }
.cal-event.is-overdue { border-color: var(--status-red-fg); }
@media (max-width: 767.98px) {
  .cal-cell { min-height: 58px; padding: 5px; }
  .cal-cell .cal-chip, .cal-cell .cal-more { display: none; }
  .cal-dot-count { display: inline-block; }
  .cal-week { grid-template-columns: 1fr; }
  .cal-week-col { min-height: 0; }
}
.tpl-task { display: grid; grid-template-columns: 76px 1fr 44px; gap: 8px; align-items: center; font-size: 12.5px; padding: 8px 10px; background: var(--n-50); border-radius: var(--r-sm); }

/* ============================= EMAIL ============================= */
.mail-shell { display: grid; grid-template-columns: 330px minmax(0, 1fr); height: calc(100vh - 200px); min-height: 520px; overflow: hidden; }
.mail-list { border-right: 1px solid var(--border-subtle); overflow-y: auto; }
.mail-detail { overflow-y: auto; padding: 22px; min-width: 0; }
.mail-row { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border-subtle); color: var(--text-primary); }
.mail-row:hover { background: var(--bg-hover); color: var(--text-primary); }
.mail-row.active { background: var(--ws-primary-50); }
.mail-unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ws-primary); flex-shrink: 0; margin-top: 5px; }
.mail-msg { border-radius: var(--r-md); padding: 14px 16px; border: 1px solid var(--border-subtle); background: var(--n-50); }
.mail-msg.out { background: var(--ws-primary-50); }
.mail-msg-body { font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.mail-back { display: none; }
@media (max-width: 991.98px) {
  .mail-shell { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .mail-list { border-right: 0; max-height: none; }
  .mail-shell.has-selection .mail-list { display: none; }
  .mail-shell:not(.has-selection) .mail-detail { display: none; }
  .mail-back { display: inline-flex; }
  .mail-detail { padding: 16px; }
}

/* ============================= MISC MODULES ============================= */
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.slot-btn { justify-content: center; }
.date-chip { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 10px 14px; border-radius: var(--r-md); background: var(--n-100); color: var(--text-primary); border: 1px solid transparent; }
.date-chip:hover { background: var(--n-150); color: var(--text-primary); }
.date-chip.active { background: var(--ws-primary-50); color: var(--ws-primary); border-color: var(--ws-primary-100); }
.date-strip { display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 991.98px) { .date-strip { flex-direction: row; overflow-x: auto; padding-bottom: 4px; } .date-chip { flex: 0 0 150px; } }
.score-ring-wrap { position: relative; width: 170px; height: 170px; margin: 10px auto; }
.score-ring-wrap svg { transform: rotate(-90deg); }
.score-ring-wrap circle { transition: stroke-dashoffset 500ms ease; }
.score-ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score-num { font-size: 32px; font-weight: 900; line-height: 1; }
.stars { display: inline-flex; gap: 2px; }
.stars svg.lucide { width: 13px; height: 13px; }
.star-on { color: #f59e0b; fill: #f59e0b; }
.star-off { color: var(--n-200); }
.day-card { padding: 14px; border: 1px solid var(--border-subtle); border-radius: var(--r-md); background: var(--bg-surface); }
.integration-logo { width: 36px; height: 36px; border-radius: 8px; object-fit: contain; display: block; }
.setting-card-desc { font-size: 12px; color: var(--text-secondary); min-height: 34px; margin-bottom: 14px; }
.code-box { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--n-100); border: 1px solid var(--border-subtle); border-radius: var(--r-sm); padding: 8px 10px; word-break: break-all; }

/* ============================= LOGIN ============================= */
.login-wrap { min-height: 100vh; display: flex; }
.login-left { flex: 1; display: flex; align-items: center; justify-content: center; background: var(--n-0); padding: 40px 20px; }
.login-right { flex: 1; background: linear-gradient(135deg, #1d4ed8 0%, #4338ca 45%, #0d9488 100%); position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-box { width: 380px; max-width: 100%; }
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 34px; }
.login-logo .tb-logo-mark { width: 36px; height: 36px; border-radius: 10px; font-size: 15px; }
.login-title { font-size: 24px; font-weight: 800; margin-bottom: 6px; }
.login-sub { font-size: 13.5px; color: var(--text-secondary); margin-bottom: 28px; }
.login-divider { display: flex; align-items: center; gap: 12px; margin: 22px 0; color: var(--text-tertiary); font-size: 12px; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--border-default); }
.btn-google { display: flex; align-items: center; justify-content: center; gap: 10px; height: 44px; border: 1px solid var(--border-default); border-radius: var(--r-sm); background: var(--bg-surface); color: var(--text-primary); font-weight: 700; font-size: 13.5px; width: 100%; }
.btn-google:hover { background: var(--bg-hover); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.login-mock-card { position: relative; width: 420px; max-width: 100%; background: var(--bg-surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: 20px; animation: floatCard 6s ease-in-out infinite; }
@keyframes floatCard { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
.login-orb { position: absolute; border-radius: 50%; filter: blur(50px); opacity: .5; }
.theme-toggle-fab { position: fixed; top: 18px; right: 18px; z-index: 20; width: 40px; height: 40px; border-radius: 50%; background: var(--bg-surface); border: 1px solid var(--border-default); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm); }

/* ============================= DATA IMPORT ============================= */
.target-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.target-pick label { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1.5px solid var(--border-default); border-radius: var(--r-md); cursor: pointer; transition: border-color var(--dur-fast), background var(--dur-fast); }
.target-pick input { margin-top: 3px; }
.target-pick label:has(input:checked) { border-color: var(--ws-primary); background: var(--ws-primary-50); }
.target-pick b { display: block; font-size: 13.5px; }
.target-pick span { font-size: 12px; color: var(--text-secondary); }
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 26px 16px; border: 2px dashed var(--border-default); border-radius: var(--r-md); background: var(--n-25); color: var(--text-secondary); cursor: pointer; transition: border-color var(--dur-fast), background var(--dur-fast); }
.dropzone:hover, .dropzone.dragover { border-color: var(--ws-primary); background: var(--ws-primary-50); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone svg.lucide { width: 28px; height: 28px; color: var(--ws-primary); }
.dropzone .dz-file { font-weight: 700; color: var(--text-primary); word-break: break-all; }
.how-steps { counter-reset: step; list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.how-steps li { counter-increment: step; position: relative; padding-left: 34px; font-size: 13px; color: var(--text-secondary); }
.how-steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--ws-primary-50); color: var(--ws-primary); font-weight: 800; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.how-steps b { color: var(--text-primary); }
.map-grid { display: flex; flex-direction: column; }
.map-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1.2fr); gap: 14px; align-items: center; padding: 10px 18px; border-top: 1px solid var(--border-subtle); }
.map-row.map-head { border-top: 0; padding-top: 12px; padding-bottom: 8px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--text-tertiary); }
.map-row.is-skipped .map-col-name, .map-row.is-skipped .map-samples { opacity: .5; }
.map-col-name { font-weight: 700; font-size: 13.5px; word-break: break-word; }
.map-samples { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.map-samples span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--n-100); color: var(--text-secondary); }
.map-samples .empty { background: none; color: var(--text-tertiary); font-style: italic; padding-left: 0; }
@media (max-width: 767.98px) {
  .map-row { grid-template-columns: 1fr; gap: 6px; padding: 12px 14px; }
  .map-row.map-head { display: none; }
}
.preview-table td { font-size: 12.5px; vertical-align: top; max-width: 260px; }
.preview-table td .cell-notes { white-space: pre-line; max-height: 4.5em; overflow: hidden; color: var(--text-secondary); }
.import-stat { padding: 14px 16px; }
.import-stat .kpi-mini-val { font-variant-numeric: tabular-nums; }
.progress-import { height: 10px; }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; padding: 12px 0; background: linear-gradient(to top, var(--bg-app, var(--n-50)) 70%, transparent); }

/* ============================= PRINT (invoice) ============================= */
.print-sheet { max-width: 820px; margin: 30px auto; background: #fff; color: #171c26; padding: 44px; border-radius: 12px; box-shadow: var(--shadow-md); }
.print-sheet table { width: 100%; border-collapse: collapse; }
.print-sheet th, .print-sheet td { padding: 10px 8px; border-bottom: 1px solid #e4e8ee; font-size: 13px; text-align: left; }
.print-sheet th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: #717c8d; }
@media print { .no-print { display: none !important; } body { background: #fff !important; } .print-sheet { box-shadow: none; margin: 0; padding: 0; max-width: none; } }

/* ============================= RESPONSIVE SHELL ============================= */
@media (max-width: 1199.98px) { .tb-search { max-width: 300px; } }
@media (max-width: 991.98px) {
  #sidebar {
    position: fixed; left: 0; top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px)); bottom: 0; height: auto; width: 260px !important;
    transform: translateX(-100%); transition: transform var(--dur-base) var(--ease-out); box-shadow: var(--shadow-lg); z-index: 1045;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  body.sidebar-open #sidebar { transform: none; }
  body.sidebar-open #sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 18, 26, .45); z-index: 1044; }
  body.sidebar-collapsed #sidebar .nav-label, body.sidebar-collapsed #sidebar .nav-group-title, body.sidebar-collapsed #sidebar .nav-count { opacity: 1; width: auto; }
  #sidebar-collapse-btn { display: none; }
  .tb-search { display: none; }
  #view-root { padding: 18px 16px 90px; }
  .login-right { display: none; }
}
@media (max-width: 767.98px) {
  #topbar { gap: 6px; padding-left: 10px; padding-right: 10px; }
  .ws-switcher-text, .tb-brand { display: none; }
  .view-title { font-size: 19px; }
  .view-actions { width: 100%; }
  .view-actions > .btn, .view-actions > form, .view-actions > .dropdown { flex: 1 1 auto; }
  .view-actions > form > .btn, .view-actions > .dropdown > .btn { width: 100%; }
  .record-quick-actions { width: 100%; }
  .record-quick-actions .btn { flex: 1 1 auto; }
  .toast-stack { right: 12px; left: 12px; bottom: 90px; max-width: none; }
  .crm-toast { min-width: 0; }
  .ai-chat-panel { right: 12px; left: 12px; width: auto; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  .ai-chat-fab { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); width: 52px; height: 52px; }
  .modal-dialog { margin: 12px; }
}
@media (min-width: 992px) { #sidebar-toggle { display: none; } }
