/* ===========================================================================
   ClientHub design system — ink sidebar · teal primary · cream canvas
   Re-themes the existing class names so every page updates at once.
   =========================================================================== */
:root {
  --ink: #14181F; --ink-2: #1C212B; --ink-3: #272D39;
  --canvas: #F6F5F2; --surface: #FFFFFF; --surface-2: #FBFAF8;
  --line: #E7E5E0; --line-2: #EFEEEA;
  --text: #1C212B; --muted: #6B7280; --muted-2: #9AA0AB; --faint: #B7BCC4;

  --brand: #0E8C8C; --brand-dark: #0A6E6E; --brand-soft: #E3F1F0;
  --brand-50: #E3F1F0; --brand-100: #CFE7E6;

  --pos: #1F9D6B; --pos-soft: #E4F4EC;
  --neu: #C2902A; --neu-soft: #F8EFD9;
  --neg: #D2473D; --neg-soft: #FBE7E5;
  --info: #4A6CF7; --info-soft: #E6EAFD;
  --violet: #7C3AED; --violet-soft: #EDE9FE;

  --wa: #25D366; --upwork: #108A00; --slack: #611F69; --email: #4A6CF7;
  --telegram: #229ED9; --other: #8A94A6;

  --r-s: 8px; --r-m: 12px; --r-l: 18px;
  --radius: 18px; --radius-sm: 12px;
  --sh-s: 0 1px 2px rgba(20,24,31,.05);
  --sh-m: 0 4px 16px rgba(20,24,31,.07);
  --sh-l: 0 18px 50px rgba(20,24,31,.16);
  --shadow-sm: var(--sh-s); --shadow-md: var(--sh-m);

  --display: 'Space Grotesk', sans-serif;
  --ui: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --sidebar-w: 250px;
}

* { box-sizing: border-box; }

body {
  background: var(--canvas);
  color: var(--text);
  font-family: var(--ui);
  font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv05", "ss01";
}
h1, h2, h3, h4, h5, h6, .page-title, .page-h, .modal-title, .offcanvas-title,
.card-header, .stat-val, .navbar-brand { font-family: var(--display); letter-spacing: -.2px; }
a { color: inherit; }
::selection { background: var(--brand-soft); }

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

.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--ink); color: #C9CDD5;
  position: sticky; top: 0; height: 100vh; overflow: hidden;
  display: flex; flex-direction: column; padding: 0;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 11px; padding: 18px 18px 14px; color: #fff; flex: none;
}
.sidebar .brand .logo {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  background: linear-gradient(150deg, var(--brand), #16B6A6);
  display: grid; place-items: center; font-size: 18px;
  box-shadow: 0 2px 10px rgba(14,140,140,.35);
}
.sidebar .brand h1 { font-size: 15.5px; font-weight: 600; color: #fff; line-height: 1.1; margin: 0; letter-spacing: -.1px; }
.sidebar .brand .tag {
  font-size: 9.5px; color: #6E7480; font-family: var(--mono);
  letter-spacing: .4px; text-transform: uppercase; margin-top: 2px;
}
.sidebar .nav {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 2px 10px 6px;
  scrollbar-width: none; -ms-overflow-style: none;
}
.sidebar .nav::-webkit-scrollbar { display: none; width: 0; height: 0; }
.sidebar .nav-section {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .13em;
  color: #545B66; font-weight: 700; padding: 12px 10px 4px;
}
.sidebar .nav-section:first-child { padding-top: 6px; }
.sidebar .nav-link {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 8px;
  color: #A6ACB6; font-weight: 500; font-size: 13px; position: relative;
  transition: background .14s, color .14s;
}
.sidebar .nav-link .ico {
  width: 24px; height: 24px; display: grid; place-items: center; border-radius: 7px;
  opacity: .85; flex: none; transition: background .14s, opacity .14s;
}
.sidebar .nav-link:hover { background: var(--ink-2); color: #EDEFF2; }
.sidebar .nav-link:hover .ico { opacity: 1; }
.sidebar .nav-link.active { background: var(--ink-3); color: #fff; }
.sidebar .nav-link.active .ico { background: rgba(14,140,140,.22); color: #4FD1CB; opacity: 1; }
.sidebar .nav-link.active::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px;
  background: var(--brand); border-radius: 0 3px 3px 0;
}

/* Sidebar footer: compact profile trigger + popover (role shown by default) */
.rail-foot { padding: 8px; border-top: 1px solid var(--ink-3); flex: none; }
.profile-trigger {
  width: 100%; display: flex; align-items: center; gap: 9px;
  background: transparent; border: 1px solid transparent; border-radius: 10px;
  padding: 7px 8px; cursor: pointer; transition: background .14s, border-color .14s;
}
.profile-trigger:hover { background: var(--ink-2); }
.profile-trigger[aria-expanded="true"] { background: var(--ink-2); border-color: var(--ink-3); }
.profile-trigger .av {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--brand), #16B6A6);
  display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff;
}
.profile-trigger .role-txt {
  flex: 1; text-align: left; font-size: 12.5px; font-weight: 600;
  text-transform: capitalize; color: #EDEFF2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profile-trigger .chev { color: #6E7480; flex: none; display: grid; transition: transform .16s; }
.profile-trigger[aria-expanded="true"] .chev { transform: rotate(180deg); }

.profile-menu {
  width: 236px; background: var(--surface); border: 1px solid var(--line); border-radius: 13px;
  box-shadow: var(--sh-l); padding: 6px; margin-bottom: 8px !important;
}
.profile-menu-head { display: flex; align-items: center; gap: 10px; padding: 9px 8px 11px; }
.profile-menu-head .av {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, var(--brand), #16B6A6);
  display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff;
}
.profile-menu-head .pm-info { min-width: 0; }
.profile-menu-head .nm { font-weight: 600; font-size: 13.5px; color: var(--text); line-height: 1.25; }
.profile-menu-head .em {
  font-size: 11.5px; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 160px;
}
.profile-menu .dropdown-item {
  display: flex; align-items: center; gap: 9px; border-radius: 8px; padding: 8px 10px;
  font-size: 13px; font-weight: 500;
}

/* ----------------------------------------------------------------- Main area */
.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px; flex: none; background: rgba(246,245,242,.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); display: flex; align-items: center;
  justify-content: space-between; gap: 16px; padding: 0 24px; position: sticky; top: 0; z-index: 20;
}
.topbar .crumbs { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.topbar .page-h { font-size: 17px; font-weight: 600; margin: 0; }
.topbar .crumb, .topbar .sub { color: var(--muted-2); font-size: 12.5px; }
.topbar .tb-right { display: flex; align-items: center; gap: 9px; }

/* Topbar global search */
.tb-search { position: relative; width: 300px; max-width: 32vw; }
.tb-search .s-ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-size: 12px; opacity: .5; pointer-events: none; }
.tb-search input { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 11px 8px 32px; font-size: 13px; color: var(--text); }
.tb-search input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.tb-results { position: absolute; top: 44px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--sh-l); max-height: 380px; overflow: auto; z-index: 60; padding: 6px; }
.tb-results .res { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: inherit; }
.tb-results .res:hover { background: var(--brand-soft); }
.tb-results .res .av { width: 30px; height: 30px; font-size: 11px; }
.tb-results .res-cat { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-2);
  padding: 9px 10px 4px; font-weight: 600; }
.icon-btn { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; color: var(--muted); cursor: pointer; font-size: 15px; transition: .14s; }
.icon-btn:hover { color: var(--text); border-color: var(--faint); }
@media (max-width: 900px) { .tb-search { display: none; } }

/* Legacy userchip (kept for any page that still renders it) */
.userchip { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 12px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.userchip .avatar { width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), #16B6A6); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.userchip .name { font-weight: 600; line-height: 1.1; }
.userchip .role { font-size: .7rem; color: var(--muted); text-transform: capitalize; }

.content { padding: 24px; max-width: 1340px; margin: 0 auto; width: 100%;
  animation: rise .3s cubic-bezier(.2,.7,.2,1); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ----------------------------------------------------------------- Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--sh-s); }
.card .card-header {
  background: transparent; border-bottom: 1px solid var(--line-2);
  font-weight: 600; font-size: 14.5px; padding: 15px 18px;
  display: flex; align-items: center; justify-content: space-between;
}
.card .card-body { padding: 18px; }

/* ----------------------------------------------------------------- Stat / KPI */
.stat { display: flex; align-items: center; gap: 15px; padding: 16px 17px; }
.stat .stat-ico { width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center;
  font-size: 20px; flex: none; }
.stat .stat-val { font-size: 1.7rem; font-weight: 600; line-height: 1; letter-spacing: -.5px; }
.stat .stat-label { color: var(--muted); font-size: .82rem; margin-top: 4px; }
.tint-blue   { background: var(--brand-soft);  color: var(--brand); }
.tint-green  { background: var(--pos-soft);    color: var(--pos); }
.tint-violet { background: var(--violet-soft); color: var(--violet); }
.tint-amber  { background: var(--neu-soft);    color: var(--neu); }
.tint-sky    { background: var(--info-soft);   color: var(--info); }

/* ----------------------------------------------------------------- Tables */
.table { margin: 0; color: var(--text); }
.table thead th {
  background: var(--surface-2); border-bottom: 1px solid var(--line-2);
  text-transform: uppercase; font-size: 10.5px; letter-spacing: .07em;
  color: var(--muted-2); font-weight: 600; padding: 11px 16px;
}
.table tbody td { padding: 12px 16px; border-color: var(--line-2); vertical-align: middle; font-size: 13px; }
.table tbody tr { transition: background .12s; }
.table.row-hover tbody tr:hover, .table tbody tr.row-link:hover { background: var(--surface-2); cursor: pointer; }

/* ----------------------------------------------------------------- Buttons */
.btn { border-radius: 9px; font-weight: 550; font-size: 13px; padding: .5rem .9rem; transition: .14s; }
.btn-primary { background: var(--brand); border-color: var(--brand); box-shadow: var(--sh-s); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-sm { padding: .34rem .65rem; font-size: 12px; }
.btn-soft { background: var(--brand-soft); color: var(--brand-dark); border: 1px solid var(--brand-100); }
.btn-soft:hover { background: var(--brand-100); color: var(--brand-dark); }
.btn-light, .btn-ghost { background: var(--surface); border: 1px solid var(--line); color: var(--text); }
.btn-light:hover, .btn-ghost:hover { border-color: var(--faint); background: var(--surface); }
.btn-outline-danger { color: var(--neg); border-color: var(--neg-soft); }
.btn-outline-danger:hover { background: var(--neg); border-color: var(--neg); color: #fff; }
.btn-outline-secondary { color: var(--muted); border-color: var(--line); }
.btn-danger { background: var(--neg); border-color: var(--neg); color: #fff; }
.btn-success { background: var(--pos); border-color: var(--pos); color: #fff; }

/* ----------------------------------------------------------------- Badges / chips */
.badge { font-weight: 600; padding: .34em .7em; border-radius: 6px; font-size: .72rem; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 550; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--line-2);
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.ok     { background: var(--pos-soft); color: #16704C; border-color: transparent; }
.chip.bad    { background: var(--neg-soft); color: #A02E26; border-color: transparent; }
.chip.info   { background: var(--info-soft); color: #2C4BB8; border-color: transparent; }
.chip.violet { background: var(--violet-soft); color: var(--violet); border-color: transparent; }
.chip.amber  { background: var(--neu-soft); color: #8A6614; border-color: transparent; }

/* Platform pills */
.pf { text-transform: capitalize; }
.pf-whatsapp { background: #E6F9EE; color: #128C4B; border-color: transparent; }
.pf-slack    { background: var(--violet-soft); color: var(--slack); border-color: transparent; }
.pf-email    { background: var(--info-soft); color: #2C4BB8; border-color: transparent; }
.pf-upwork   { background: #E4F4E0; color: var(--upwork); border-color: transparent; }
.pf-telegram { background: #E2F1FB; color: #1B7BB0; border-color: transparent; }
.pf-other    { background: #EFEEEA; color: var(--muted); border-color: transparent; }

/* ----------------------------------------------------------------- Forms */
.form-control, .form-select {
  border-radius: 9px; border-color: var(--line); padding: .55rem .75rem; font-size: 13px;
  background: var(--surface); color: var(--text);
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.form-control-sm, .form-select-sm { font-size: 12.5px; }
/* Dropdown toggle styled as a <select>: match input/select height exactly */
button.form-select { line-height: 1.5; min-height: calc(1.5em + 1.1rem + 2px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.form-label { font-weight: 600; font-size: 12.5px; color: var(--text); margin-bottom: .3rem; }
.req { color: var(--neg); }

/* Compact multi-pick list (assignees, etc.) */
.pick-list { border: 1px solid var(--line); border-radius: 9px; padding: 6px; max-height: 132px;
  overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.pick-list label { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 7px;
  font-size: 13px; cursor: pointer; margin: 0; }
.pick-list label:hover { background: var(--brand-soft); }
.pick-list .me-tag { margin-left: auto; font-size: 10px; color: var(--brand-dark); background: var(--brand-soft);
  padding: 1px 6px; border-radius: 5px; font-weight: 600; }
/* selectable channel pills inside a modal */
#c-channels .pill { text-transform: none; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }

/* ----------------------------------------------------------------- Tabs */
.nav-tabs { border-bottom: 1px solid var(--line); gap: 4px; }
.nav-tabs .nav-link {
  border: none; color: var(--muted); font-weight: 600; border-radius: 9px 9px 0 0; padding: .6rem 1rem;
  font-family: var(--ui);
}
.nav-tabs .nav-link:hover { color: var(--brand-dark); background: var(--brand-soft); }
.nav-tabs .nav-link.active {
  color: var(--brand-dark); background: transparent; border-bottom: 2.5px solid var(--brand);
}

/* ----------------------------------------------------------------- Filters (channels/users) */
.filterbar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 10px 14px;
}
.seg { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.seg .pill {
  padding: 5px 12px; border-radius: 7px; font-size: 12.5px; font-weight: 500; color: var(--muted);
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; transition: .12s; text-transform: capitalize;
}
.seg .pill:hover { border-color: var(--faint); color: var(--text); }
.seg .pill.active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ----------------------------------------------------------------- Channel cards */
.chan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.chan-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l);
  padding: 17px; box-shadow: var(--sh-s); transition: .16s; cursor: pointer;
}
.chan-card:hover { box-shadow: var(--sh-m); transform: translateY(-2px); border-color: var(--faint); }
.chan-card .chan-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.chan-card .chan-ico { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; font-size: 19px; }
.chan-card .chan-name { font-family: var(--display); font-weight: 600; font-size: 1.02rem; margin-bottom: 2px; }
.chan-card .chan-meta { color: var(--muted-2); font-size: .8rem; }
.chan-card .chan-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 14px;
  padding-top: 12px; border-top: 1px solid var(--line-2); }

/* ----------------------------------------------------------------- Avatars */
.avatar-sm {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: var(--brand-soft); color: var(--brand-dark);
  display: inline-grid; place-items: center; font-weight: 700; font-size: 11px;
}
.role-super_admin { background: var(--violet); color: #fff; }
.role-admin { background: var(--info); color: #fff; }
.role-team_lead { background: var(--neu); color: #fff; }
.role-employee { background: var(--brand); color: #fff; }

/* ----------------------------------------------------------------- User-mgmt bits */
.bulkbar { display: flex; align-items: center; gap: 12px; background: var(--ink); color: #fff;
  border-radius: var(--r-m); padding: 10px 16px; margin-bottom: 14px; box-shadow: var(--sh-s); }
.bulkbar .btn { --bs-btn-padding-y: .3rem; }
.you-badge { font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  background: var(--brand-soft); color: var(--brand-dark); padding: 1px 6px; border-radius: 5px; margin-left: 6px; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable .caret { opacity: .4; font-size: .7rem; }
th.sortable.active .caret { opacity: 1; }
.pw-meter { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 6px; }
.pw-meter > span { display: block; height: 100%; width: 0; transition: width .2s, background .2s; }
.pw-weak > span { width: 33%; background: var(--neg); }
.pw-medium > span { width: 66%; background: var(--neu); }
.pw-strong > span { width: 100%; background: var(--pos); }
.invite-link-box { background: var(--brand-soft); border: 1px dashed var(--brand-100); border-radius: 9px;
  padding: 12px; word-break: break-all; font-size: .82rem; }

/* ----------------------------------------------------------------- Misc */
.muted { color: var(--muted); }
.page-title { font-weight: 600; letter-spacing: -.3px; }
.cursor-pointer { cursor: pointer; }
.sentiment-positive { color: var(--pos); font-weight: 600; }
.sentiment-neutral  { color: var(--muted); font-weight: 600; }
.sentiment-negative { color: var(--neg); font-weight: 600; }

.empty { text-align: center; color: var(--muted); padding: 46px 20px; }
.empty .em-ico { font-size: 32px; opacity: .55; display: block; margin-bottom: 10px; }

.chat-log {
  white-space: pre-wrap; font-family: var(--mono); font-size: .82rem; line-height: 1.5;
  background: var(--ink); color: #E2E8F0; border-radius: var(--r-m); padding: 14px;
  max-height: 360px; overflow: auto;
}
.list-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--r-m); margin-bottom: 8px; background: var(--surface);
  transition: box-shadow .12s, border-color .12s; }
.list-row:hover { box-shadow: var(--sh-s); border-color: var(--brand-100); }

.list-group-item { border-color: var(--line-2); }
.list-group-item a { color: var(--brand-dark); font-weight: 500; }

.modal-content { border: none; border-radius: var(--r-l); box-shadow: var(--sh-l); }
.modal-header { border-bottom: 1px solid var(--line-2); }
.modal-footer { border-top: 1px solid var(--line-2); }
.offcanvas { background: var(--canvas); }
.offcanvas-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.dropdown-menu { border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: var(--sh-m); font-size: 13px; }
.dropdown-item:active { background: var(--brand); }

#toast {
  position: fixed; top: 18px; right: 18px; z-index: 1080; min-width: 260px;
  box-shadow: var(--sh-l); border: none; border-radius: 11px;
}

/* Styled confirm dialog */
.confirm-icon {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto;
  display: grid; place-items: center; font-size: 26px;
  background: var(--brand-soft); color: var(--brand);
}
.confirm-icon.danger { background: var(--neg-soft); color: var(--neg); }
#confirmModal .modal-content { border-radius: 16px; }

/* ===========================================================================
   ClientHub view components (dashboard, clients, conversations, etc.)
   =========================================================================== */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { font-family: var(--display); font-size: 23px; font-weight: 600; letter-spacing: -.4px; }
.page-head p { color: var(--muted); font-size: 13px; margin-top: 3px; max-width: 580px; }
.head-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.card-h { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px;
  border-bottom: 1px solid var(--line-2); }
.card-h h3 { font-family: var(--display); font-size: 14.5px; font-weight: 600; }
.card-h .link { font-size: 12.5px; color: var(--brand); font-weight: 550; cursor: pointer; }
.card-pad { padding: 18px; }
.mono { font-family: var(--mono); }

/* KPI with delta */
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m);
  padding: 16px 17px; box-shadow: var(--sh-s); display: block; color: inherit;
  text-decoration: none; transition: box-shadow .16s, border-color .16s, transform .16s; }
a.kpi:hover { box-shadow: var(--sh-m); border-color: var(--faint); transform: translateY(-2px); }
.kpi .top { display: flex; align-items: center; justify-content: space-between; color: var(--muted);
  font-size: 12.5px; font-weight: 500; }
.kpi .ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); font-size: 16px; }
.kpi .val { font-family: var(--display); font-size: 27px; font-weight: 600; letter-spacing: -.5px; margin: 9px 0 3px; }
.kpi .delta { font-size: 12px; font-family: var(--mono); display: inline-flex; align-items: center; gap: 4px; }
.delta.up { color: var(--pos); } .delta.down { color: var(--neg); }

/* sentiment pill */
.spill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 550;
  padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.spill .pdot { width: 6px; height: 6px; border-radius: 50%; }
.s-pos { background: var(--pos-soft); color: #16704C; } .s-pos .pdot { background: var(--pos); }
.s-neu { background: var(--neu-soft); color: #8A6614; } .s-neu .pdot { background: var(--neu); }
.s-neg { background: var(--neg-soft); color: #A02E26; } .s-neg .pdot { background: var(--neg); }

/* status pills (projects) */
.st { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 6px; }
.st-active { background: var(--pos-soft); color: #16704C; }
.st-progress { background: #E6EEFB; color: #2C5AB8; }
.st-hold { background: var(--neu-soft); color: #8A6614; }
.st-done { background: #EEECEA; color: #71767E; }

/* channel chip */
.chan { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 550;
  padding: 3px 9px 3px 7px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--line-2); }
.chan .cd { width: 8px; height: 8px; border-radius: 3px; }
.av { border-radius: 8px; display: grid; place-items: center; font-weight: 650; color: #fff; flex: none; font-size: 12px; }
.t-name { display: flex; align-items: center; gap: 10px; }
.t-name .nm { font-weight: 550; } .t-name .sm { font-size: 11.5px; color: var(--muted-2); }

/* sentiment bar + legend + volume bars */
.sent-bar { height: 9px; border-radius: 5px; overflow: hidden; display: flex; background: var(--line); }
.sent-bar span { height: 100%; }
.legend { display: flex; gap: 14px; margin-top: 10px; flex-wrap: wrap; }
.legend div { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.legend .ld { width: 9px; height: 9px; border-radius: 3px; }
.bars { display: flex; align-items: flex-end; gap: 12px; height: 150px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; height: 100%; justify-content: flex-end; }
.bar-stack { width: 100%; max-width: 40px; display: flex; flex-direction: column; justify-content: flex-end;
  border-radius: 6px 6px 0 0; overflow: hidden; }
.bar-stack span { display: block; transition: height .5s; }
.bar-col .bl { font-size: 10.5px; color: var(--muted-2); font-family: var(--mono); }
.vol-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.vol-row .vn { font-size: 12px; width: 78px; color: var(--muted); }
.vol-row .vt { flex: 1; height: 7px; background: var(--line); border-radius: 4px; overflow: hidden; }
.vol-row .vt > div { height: 100%; border-radius: 4px; }
.vol-row .vp { font-family: var(--mono); font-size: 11.5px; color: var(--muted); width: 32px; text-align: right; }
.pbar { flex: 1; height: 6px; background: var(--line); border-radius: 3px; min-width: 50px; overflow: hidden; }
.pbar > div { height: 100%; background: var(--brand); border-radius: 3px; }

/* client cards */
.clients { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.client-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l);
  padding: 17px; box-shadow: var(--sh-s); transition: .16s; cursor: pointer; }
.client-card:hover { box-shadow: var(--sh-m); transform: translateY(-2px); border-color: var(--faint); }
.client-card .cc-top { display: flex; gap: 12px; align-items: center; margin-bottom: 13px; }
.client-card .av { width: 42px; height: 42px; font-size: 15px; }
.client-card h4 { font-family: var(--display); font-size: 15px; font-weight: 600; }
.client-card .co { font-size: 12px; color: var(--muted-2); }
.cc-chans { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 13px; min-height: 22px; }
.cc-stats { display: flex; border-top: 1px solid var(--line-2); padding-top: 12px; }
.cc-stats div { flex: 1; text-align: center; }
.cc-stats .n { font-family: var(--mono); font-weight: 600; font-size: 15px; }
.cc-stats .l { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-2); margin-top: 1px; }
.cc-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 13px; }
.cc-owner { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--muted); }
.cc-owner .av { width: 22px; height: 22px; font-size: 10px; }

/* conversations 3-pane */
.conv { display: grid; grid-template-columns: 320px 1fr 330px; height: calc(100vh - 60px);
  background: var(--surface); border-top: 1px solid var(--line); }
.conv-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.cl-head { padding: 14px 15px; border-bottom: 1px solid var(--line-2); }
.cl-head h3 { font-family: var(--display); font-size: 15px; font-weight: 600; }
.cl-head .sub { font-size: 11.5px; color: var(--muted-2); margin-top: 1px; }
.cl-filter { display: flex; gap: 5px; padding: 10px 12px; border-bottom: 1px solid var(--line-2); overflow-x: auto; }
.cl-filter::-webkit-scrollbar { display: none; }
.cl-scroll { flex: 1; overflow-y: auto; }
.ci { display: flex; gap: 11px; padding: 13px 15px; border-bottom: 1px solid var(--line-2); cursor: pointer;
  transition: .12s; position: relative; }
.ci:hover { background: var(--surface-2); }
.ci.on { background: var(--brand-soft); }
.ci.on::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand); }
.ci .av { width: 38px; height: 38px; font-size: 13px; position: relative; }
.ci .av .ch { position: absolute; bottom: -2px; right: -2px; width: 14px; height: 14px; border-radius: 5px; border: 2px solid var(--surface); }
.ci-body { min-width: 0; flex: 1; }
.ci-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ci-top .nm { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-top .tm { font-size: 10.5px; color: var(--muted-2); font-family: var(--mono); white-space: nowrap; }
.ci .prev { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 2px 0 5px; }
.ci-meta { display: flex; align-items: center; gap: 6px; }
.ci-del { position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border: none;
  background: transparent; color: var(--muted-2); border-radius: 6px; opacity: 0; transition: opacity .12s, background .12s; font-size: 12px; }
.ci:hover .ci-del { opacity: 1; }
.ci-del:hover { background: var(--neg-soft); color: var(--neg); }
.thread { display: flex; flex-direction: column; min-height: 0; }
.th-head { padding: 13px 18px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 12px; }
.th-head .av { width: 38px; height: 38px; font-size: 13px; }
.th-head .nm { font-family: var(--display); font-weight: 600; font-size: 15px; }
.th-head .meta { font-size: 11.5px; color: var(--muted-2); display: flex; align-items: center; gap: 7px; margin-top: 1px; }
.th-body { flex: 1; overflow-y: auto; padding: 20px 18px; background: var(--surface-2); display: flex; flex-direction: column; gap: 3px; }
.day-sep { text-align: center; margin: 10px 0; font-size: 10.5px; color: var(--muted-2); font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; }
.msg { max-width: 74%; display: flex; flex-direction: column; gap: 3px; margin-bottom: 9px; }
.msg .bubble { padding: 9px 13px; border-radius: 13px; font-size: 13px; line-height: 1.45; box-shadow: var(--sh-s); white-space: pre-wrap; }
.msg .meta { font-size: 10px; color: var(--muted-2); font-family: var(--mono); }
.msg.in { align-self: flex-start; align-items: flex-start; }
.msg.in .bubble { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.msg.out .bubble { background: var(--ink); color: #EAEBEE; border-bottom-right-radius: 4px; }
.msg.out .meta { text-align: right; }
.msg .who { font-weight: 600; color: var(--brand); margin-bottom: 2px; font-size: 11px; }
.composer { border-top: 1px solid var(--line-2); padding: 13px 16px; }
.perm-note { font-size: 11.5px; display: flex; align-items: center; gap: 7px; margin-bottom: 9px; padding: 7px 10px; border-radius: 8px; }
.perm-ok { background: var(--pos-soft); color: #16704C; }
.perm-no { background: var(--neu-soft); color: #8A6614; }
.composer-row { display: flex; gap: 9px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 11px; padding: 10px 13px;
  font-size: 13px; min-height: 42px; max-height: 120px; background: var(--surface); line-height: 1.4; font-family: var(--ui); }
.composer textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.composer textarea:disabled { background: var(--surface-2); cursor: not-allowed; }
.send { width: 42px; height: 42px; border-radius: 11px; background: var(--brand); color: #fff; display: grid; place-items: center; flex: none; border: none; }
.send:disabled { background: var(--faint); }

/* AI panel */
.ai-panel { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--surface-2); }
.aip-head { padding: 14px 16px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 9px; }
.aip-head .spark { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(140deg, #8B5CF6, #6366F1);
  display: grid; place-items: center; color: #fff; flex: none; font-size: 14px; }
.aip-head h3 { font-family: var(--display); font-size: 14px; font-weight: 600; }
.aip-head .sub { font-size: 10.5px; color: var(--muted-2); }
.aip-scroll { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 16px; }
.ai-empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.ai-empty .il { width: 54px; height: 54px; border-radius: 14px; background: #EEEAFB; color: #6366F1;
  display: grid; place-items: center; margin: 0 auto 14px; font-size: 26px; }
.ai-empty p { font-size: 12.5px; margin: 6px 0 16px; line-height: 1.5; }
.ai-block .lab { font-size: 10px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted-2);
  font-weight: 600; margin-bottom: 7px; display: flex; align-items: center; gap: 6px; }
.ai-sum { font-size: 12.5px; line-height: 1.55; }
.ai-list { list-style: none; display: flex; flex-direction: column; gap: 7px; padding: 0; margin: 0; }
.ai-list li { font-size: 12.5px; line-height: 1.45; padding-left: 18px; position: relative; }
.ai-list li::before { content: ""; position: absolute; left: 2px; top: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }
.ai-list.todo li::before { border-radius: 3px; background: var(--neu); }
.ai-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.ai-metric { background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 11px; }
.ai-metric .n { font-family: var(--mono); font-weight: 600; font-size: 16px; }
.ai-metric .l { font-size: 10px; color: var(--muted-2); text-transform: uppercase; letter-spacing: .04em; margin-top: 1px; }
.ai-follow { font-size: 12.5px; background: #EEEAFB; border: 1px solid #DDD5F5; color: #4B3B96;
  padding: 11px 12px; border-radius: 10px; line-height: 1.5; }

/* documents */
.doc-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 14px;
  box-shadow: var(--sh-s); transition: .14s; cursor: pointer; display: flex; gap: 12px; align-items: flex-start; }
.doc-card:hover { box-shadow: var(--sh-m); border-color: var(--faint); }
.doc-ic { width: 38px; height: 46px; border-radius: 7px; display: grid; place-items: center; color: #fff; font-size: 9px;
  font-weight: 700; flex: none; font-family: var(--mono); }
.doc-card h4 { font-size: 13px; font-weight: 600; line-height: 1.3; }
.doc-card .dm { font-size: 11px; color: var(--muted-2); margin-top: 3px; }
.doc-card .dlink { font-size: 11px; color: var(--brand); margin-top: 6px; font-weight: 550; }

/* call recordings */
.call-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.play { width: 40px; height: 40px; border-radius: 50%; background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; flex: none; transition: .14s; border: none; font-size: 15px; }
.play:hover { background: var(--brand); color: #fff; }
.wave { flex: 1; height: 30px; display: flex; align-items: center; gap: 2px; min-width: 80px; }
.wave i { flex: 1; background: var(--line); border-radius: 2px; display: block; }

/* permission matrix */
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.matrix .yes { color: var(--pos); font-weight: 700; }
.matrix .no { color: var(--faint); }

/* activity log timeline */
.log { position: relative; padding-left: 24px; }
.log::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.log-item { position: relative; padding: 0 0 18px; }
.log-item:last-child { padding-bottom: 0; }
.log-item .ld { position: absolute; left: -21px; top: 3px; width: 14px; height: 14px; border-radius: 50%;
  border: 3px solid var(--canvas); background: var(--brand); }
.log-item .lt { font-size: 13px; } .log-item .lt b { font-weight: 600; }
.log-item .lm { font-size: 11px; color: var(--muted-2); font-family: var(--mono); margin-top: 2px; }

/* drawer */
.scrim { position: fixed; inset: 0; background: rgba(20,24,31,.42); backdrop-filter: blur(2px); z-index: 1050;
  opacity: 0; pointer-events: none; transition: .25s; }
.scrim.show { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 480px; max-width: 94vw; background: var(--canvas);
  z-index: 1051; box-shadow: var(--sh-l); transform: translateX(100%); transition: .3s cubic-bezier(.3,.8,.3,1);
  display: flex; flex-direction: column; }
.drawer.show { transform: none; }
.dr-head { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; gap: 14px; align-items: center; background: var(--surface); }
.dr-head .av { width: 48px; height: 48px; font-size: 17px; }
.dr-head h3 { font-family: var(--display); font-size: 18px; font-weight: 600; }
.dr-head .co { font-size: 12.5px; color: var(--muted); }
.dr-close { margin-left: auto; width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; cursor: pointer; font-size: 16px; }
.dr-body { flex: 1; overflow-y: auto; padding: 20px; }
.dr-sec { margin-bottom: 22px; }
.dr-sec .h { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-2); font-weight: 600; margin-bottom: 11px; }
.info-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.info-row:last-child { border: none; }
.info-row .k { color: var(--muted); } .info-row .v { font-weight: 550; text-align: right; }

/* ===========================================================================
   Per-client chat page (/chat?id=) — 3 columns: threads · messages · summary
   =========================================================================== */
.chat-layout { display: grid; grid-template-columns: 300px 1fr 300px;
  height: calc(100vh - 60px); background: var(--surface); border-top: 1px solid var(--line); }
.chat-col { min-height: 0; display: flex; flex-direction: column; }
.chat-threads { border-right: 1px solid var(--line); }
.thread-search { padding: 12px; border-bottom: 1px solid var(--line-2); }
.thread-list { flex: 1; overflow-y: auto; padding: 6px; }
.thread { display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  border-radius: 11px; margin-bottom: 2px; cursor: pointer; transition: background .12s; position: relative; }
.thread:hover { background: var(--surface-2); }
.thread.active { background: var(--brand-soft); }
.thread.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  background: var(--brand); border-radius: 0 3px 3px 0; }
.thread .avatar-sm { width: 38px; height: 38px; font-size: 13px; position: relative; }
.thread .ch-dot { position: absolute; bottom: -2px; right: -2px; width: 13px; height: 13px;
  border-radius: 5px; border: 2px solid var(--surface); }
.thread .t-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread .t-sub { font-size: 11.5px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .ch-dot { position: absolute; bottom: -2px; right: -2px; width: 13px; height: 13px;
  border-radius: 5px; border: 2px solid var(--surface); }

.chat-center { min-width: 0; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--line-2); }
.chat-body { flex: 1; overflow-y: auto; padding: 20px 18px; background: var(--surface-2);
  display: flex; flex-direction: column; gap: 3px; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); max-width: 320px; }
.chat-empty .ce-ic { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 14px;
  display: grid; place-items: center; font-size: 30px; background: var(--brand-soft); color: var(--brand); }
.chat-empty .ce-title { font-family: var(--display); font-weight: 600; font-size: 16px; color: var(--ink); }
.chat-empty .ce-sub { font-size: 12.5px; line-height: 1.5; margin-top: 5px; }
.chat-head { gap: 12px; }
.chat-center .composer { display: flex; gap: 10px; align-items: flex-end;
  border-top: 1px solid var(--line-2); padding: 14px 18px; background: var(--surface); }
.composer-field { flex: 1; background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px;
  padding: 7px 14px; transition: border-color .14s, box-shadow .14s, background .14s; }
.composer-field:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); background: var(--surface); }
.composer-field textarea { width: 100%; border: none; background: transparent; resize: none; outline: none;
  font-family: var(--ui); font-size: 13.5px; line-height: 1.5; padding: 4px 0; min-height: 28px; max-height: 120px; }
.composer-send { width: 44px; height: 44px; border-radius: 50%; background: var(--brand); color: #fff; border: none;
  display: grid; place-items: center; flex: none; box-shadow: 0 4px 12px rgba(14,140,140,.3); transition: .14s; }
.composer-send:hover { background: var(--brand-dark); transform: translateY(-1px); }
.composer-send:disabled { background: var(--faint); box-shadow: none; cursor: not-allowed; }
.composer-send svg { width: 18px; height: 18px; }
.composer-attach { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--muted); display: grid; place-items: center; flex: none; transition: .14s; }
.composer-attach:hover { color: var(--brand); border-color: var(--brand-100); background: var(--brand-soft); }
.composer-attach svg { width: 18px; height: 18px; }
/* attachment bubbles */
.bubble-att { padding: 7px 9px !important; }
.msg.out .bubble-att { background: var(--ink); }
.file-att { display: flex; align-items: center; gap: 9px; text-decoration: none; color: inherit; max-width: 240px; }
.file-att .fa-ic { font-size: 18px; flex: none; }
.file-att .fa-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; font-weight: 500; }
.file-att .fa-dl { margin-left: auto; opacity: .7; }
.bubble-att audio { display: block; }

.day-sep span { background: var(--surface); border: 1px solid var(--line-2); padding: 2px 10px; border-radius: 20px; }

.chat-summary { border-left: 1px solid var(--line); overflow-y: auto; background: var(--surface-2); padding: 0 16px; }
.summary-sec { padding: 16px 0; border-bottom: 1px solid var(--line-2); }
.summary-sec:last-child { border-bottom: none; }
.summary-sec h6 { font-family: var(--display); font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted-2); font-weight: 700; margin-bottom: 9px; }
.summary-sec .kv { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 4px 0; align-items: center; }
.summary-sec .kv .k { color: var(--muted); }

@media (max-width: 1100px) {
  .chat-layout { grid-template-columns: 260px 1fr; }
  .chat-summary { display: none; }
}
@media (max-width: 820px) {
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .chat-threads { display: none; }
}

/* Responsive */
@media (max-width: 1100px) {
  .conv { grid-template-columns: 280px 1fr; }
  .ai-panel { display: none; }
  .g-4 { grid-template-columns: repeat(2, 1fr); }
  .clients { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .sidebar { position: fixed; left: -260px; z-index: 50; transition: left .2s; }
  .sidebar.open { left: 0; }
  .content { padding: 16px; }
  .g-4, .g-3, .g-2, .clients { grid-template-columns: 1fr; }
  .conv { grid-template-columns: 1fr; height: auto; }
}
/* ===========================================================================
   Dark mode
   =========================================================================== */
:root[data-theme="dark"] {
  --canvas: #0E1116; --surface: #171B21; --surface-2: #1E242C;
  --line: #2A313B; --line-2: #232A33;
  --text: #E6E8EC; --muted: #9AA0AB; --muted-2: #737B86; --faint: #4A515C;
  --brand-soft: #0E3A38; --brand-100: #14524F;
  --pos-soft: #0F2F1E; --neu-soft: #322806; --neg-soft: #3A1715; --info-soft: #15233F; --violet-soft: #241842;
  --sh-s: 0 1px 2px rgba(0,0,0,.4); --sh-m: 0 4px 16px rgba(0,0,0,.45); --sh-l: 0 18px 50px rgba(0,0,0,.6);
  color-scheme: dark;
}
body { transition: background-color .2s ease, color .2s ease; }

/* Bootstrap component surfaces that default to white */
[data-theme="dark"] .modal-content,
[data-theme="dark"] .dropdown-menu,
[data-theme="dark"] .list-group-item { background: var(--surface); color: var(--text); }
[data-theme="dark"] .dropdown-item { color: var(--text); }
[data-theme="dark"] .dropdown-item:hover { background: var(--surface-2); color: var(--text); }
[data-theme="dark"] .btn-light, [data-theme="dark"] .btn-ghost { background: var(--surface-2); border-color: var(--line); color: var(--text); }
[data-theme="dark"] .btn-light:hover { background: var(--line-2); }
[data-theme="dark"] .form-check-input { background-color: var(--surface-2); border-color: var(--line); }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(180%); }
[data-theme="dark"] .topbar { background: rgba(18,21,26,.82); }
[data-theme="dark"] .table thead th { background: var(--surface-2); }
[data-theme="dark"] .ai-follow { background: #241842; border-color: #3a2a6b; color: #cbbdf5; }
[data-theme="dark"] .ai-empty .il { background: #241842; color: #a99be6; }
[data-theme="dark"] .invite-link-box { background: var(--brand-soft); border-color: var(--brand-100); }
[data-theme="dark"] .day-sep span { background: var(--surface-2); }

/* ===========================================================================
   Collapsible sidebar (desktop) + mobile off-canvas
   =========================================================================== */
.sidebar { transition: width .2s ease, flex-basis .2s ease, left .2s ease; }
/* Width/flex-basis for the collapsed state are applied inline via JS (setNavCollapsed
   in layout.js) rather than here, alongside this class toggle for the rest of the styling. */
.app-shell.nav-collapsed .brand > div,
.app-shell.nav-collapsed .nav-section,
.app-shell.nav-collapsed .nav-link span:not(.ico),
.app-shell.nav-collapsed .profile-trigger .role-txt,
.app-shell.nav-collapsed .profile-trigger .chev { display: none; }
.app-shell.nav-collapsed .brand { justify-content: center; padding: 16px 0 12px; }
.app-shell.nav-collapsed .nav { padding: 8px 6px; }
.app-shell.nav-collapsed .nav-link { justify-content: center; padding: 9px 0; }
.app-shell.nav-collapsed .nav-link.active::before { left: 0; }
.app-shell.nav-collapsed .rail-foot { padding: 8px 6px; }
.app-shell.nav-collapsed .profile-trigger { justify-content: center; padding: 7px; }

/* Topbar nav toggle / hamburger */
.tb-nav-toggle { margin-right: 4px; }
.tb-hamburger { display: none; }
@media (max-width: 820px) {
  .tb-nav-toggle { display: none; }
  .tb-hamburger { display: grid; }
  .scrim-nav { position: fixed; inset: 0; background: rgba(15,17,22,.45); z-index: 45; opacity: 0; pointer-events: none; transition: .2s; }
  .scrim-nav.show { opacity: 1; pointer-events: auto; }
}

/* ===========================================================================
   Skeleton loaders
   =========================================================================== */
.skeleton { position: relative; overflow: hidden; background: var(--line-2); border-radius: 8px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent); animation: shimmer 1.4s infinite; }
[data-theme="dark"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent); }
@keyframes shimmer { 100% { transform: translateX(100%); } }
.skel-line { height: 12px; margin: 7px 0; }
.skel-title { height: 18px; width: 40%; margin-bottom: 12px; }
.skel-card { height: 132px; border-radius: var(--r-l); }
.skel-row td { padding: 14px 16px; }
.skel-row .skeleton { height: 14px; }

/* ===========================================================================
   Global request progress bar — perceived-speed feedback for every API call
   =========================================================================== */
#api-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0%;
  background: linear-gradient(90deg, var(--brand), #16B6A6);
  z-index: 2000; opacity: 0; pointer-events: none;
  box-shadow: 0 0 8px var(--brand-soft);
  transition: opacity .2s ease;
}
#api-progress.show { opacity: 1; animation: api-progress-grow 1.1s ease-in-out infinite; }
@keyframes api-progress-grow {
  0%   { width: 0%;  margin-left: 0; }
  55%  { width: 62%; }
  100% { width: 0%;  margin-left: 100%; }
}

/* ===========================================================================
   Tactile micro-interactions — press feedback, snappier hovers (no new colors)
   =========================================================================== */
.btn { transform: translateZ(0); }
.btn:active:not(:disabled) { transform: scale(.97); }
.icon-btn:active:not(:disabled) { transform: scale(.92); }
.card, .chan-card, .client-card, .kpi, .doc-card, .list-row {
  transition: box-shadow .18s ease, border-color .18s ease, transform .18s ease;
}
.chan-card:active, .client-card:active { transform: translateY(-1px) scale(.995); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ===========================================================================
   Print styles for report PDF export
   =========================================================================== */
@media print {
  .sidebar,
  .topbar,
  .no-print,
  .btn,
  .dropdown,
  header,
  aside,
  nav {
    display: none !important;
  }
  .app-shell {
    display: block !important;
  }
  .main {
    margin-left: 0 !important;
    padding: 0 !important;
  }
  body, .content {
    background: #fff !important;
    color: #000 !important;
  }
  .card {
    border: 1px solid var(--line) !important;
    box-shadow: none !important;
    break-inside: avoid;
  }
}

