/* ===========================================================================
   Wary Connect CRM — design system + admin shell
   Palette: lime #C9E167 + ink, on a pure-white surface.
   Type: Inter (UI) + JetBrains Mono (numerals/IDs).
   Refined SaaS-grade: token scale, complete states, calm micro-interactions.
   =========================================================================== */

/* ---- Fonts (graceful system fallback until .woff2 files are added) ---- */
@font-face{font-family:'Inter';font-style:normal;font-weight:400;font-display:swap;src:url('/assets/fonts/Inter-Regular.woff2') format('woff2');}
@font-face{font-family:'Inter';font-style:normal;font-weight:500;font-display:swap;src:url('/assets/fonts/Inter-Medium.woff2') format('woff2');}
@font-face{font-family:'Inter';font-style:normal;font-weight:600;font-display:swap;src:url('/assets/fonts/Inter-SemiBold.woff2') format('woff2');}
@font-face{font-family:'Inter';font-style:normal;font-weight:700;font-display:swap;src:url('/assets/fonts/Inter-Bold.woff2') format('woff2');}
@font-face{font-family:'JetBrains Mono';font-style:normal;font-weight:400;font-display:swap;src:url('/assets/fonts/JetBrainsMono-Regular.woff2') format('woff2');}
@font-face{font-family:'JetBrains Mono';font-style:normal;font-weight:500;font-display:swap;src:url('/assets/fonts/JetBrainsMono-Medium.woff2') format('woff2');}

:root{
  /* surfaces — cool, clean neutrals (industrial) */
  --bg:#ffffff; --surface:#ffffff; --surface-2:#f5f6f8; --surface-hover:#eef0f4;
  --topbar-bg:rgba(255,255,255,.82);
  /* brand */
  --brand:#c9e167; --brand-strong:#bcd84f; --brand-soft:#f0f6da; --brand-tint:#f7fbe9; --brand-ink:#404e13;
  /* ink — slightly cooler greys */
  --ink:#0b0c0e; --ink-2:#363840; --ink-3:#64656d; --ink-4:#9a9ba3;
  /* lines — crisper, cool hairlines */
  --border:#e8e9ed; --border-2:#e0e1e7; --border-strong:#d2d4db;
  /* status */
  --danger:#cf2a3e; --danger-bg:#fef2f3; --danger-border:#f3c4cb;
  --success:#4f7d1f; --success-bg:#f3f9e9; --success-border:#cfe39a;
  /* chat bubbles */
  --bubble-in:#ffffff; --bubble-in-text:#111b21; --bubble-out:#d9fdd3; --bubble-out-text:#111b21;
  --chat-day-bg:#ffffff; --chat-day-text:#54656f;
  /* type */
  --font-ui:'Inter','Segoe UI',system-ui,-apple-system,sans-serif;
  --font-mono:'JetBrains Mono','Consolas',monospace;
  /* radius — soft, rounded corners */
  --r-sm:9px; --r:12px; --r-lg:16px;
  /* shadow — soft, blended elevation */
  --shadow-xs:0 1px 2px rgba(20,22,28,.05);
  --shadow-sm:0 2px 6px rgba(20,22,28,.07), 0 1px 2px rgba(20,22,28,.05);
  --shadow:0 6px 22px rgba(20,22,28,.09), 0 2px 6px rgba(20,22,28,.05);
  --shadow-lg:0 18px 44px rgba(20,22,28,.13), 0 6px 16px rgba(20,22,28,.07);
  --shadow-brand:0 4px 14px rgba(188,216,79,.4);
  /* motion */
  --ease:cubic-bezier(.16,1,.3,1); --dur:.16s; --dur-2:.24s;
}

/* Dark theme */
[data-theme="dark"]{
  /* surfaces */
  --bg:#0f0f11; --surface:#1a1a1d; --surface-2:#232326; --surface-hover:#2a2a2e;
  --topbar-bg:rgba(18,18,21,.82);
  /* brand (slightly muted for dark mode) */
  --brand:#b8d158; --brand-strong:#a4be4d; --brand-soft:#2d3619; --brand-tint:#222812; --brand-ink:#d4e896;
  /* ink */
  --ink:#e8e8eb; --ink-2:#c7c7ce; --ink-3:#9a9aa3; --ink-4:#6b6b74;
  /* lines */
  --border:#2e2e33; --border-2:#3a3a40; --border-strong:#47474f;
  /* status */
  --danger:#e84d63; --danger-bg:#2a1417; --danger-border:#4a2228;
  --success:#6fa332; --success-bg:#1a2412; --success-border:#2d3f1e;
  /* chat bubbles */
  --bubble-in:#2a2a2e; --bubble-in-text:#e8e8eb; --bubble-out:#2d3619; --bubble-out-text:#d4e896;
  --chat-day-bg:#232326; --chat-day-text:#9a9aa3;
  /* shadow — soft, blended elevation */
  --shadow-xs:0 1px 2px rgba(0,0,0,.35);
  --shadow-sm:0 2px 6px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --shadow:0 6px 22px rgba(0,0,0,.5), 0 2px 6px rgba(0,0,0,.35);
  --shadow-lg:0 18px 44px rgba(0,0,0,.65), 0 6px 16px rgba(0,0,0,.45);
  --shadow-brand:0 4px 14px rgba(164,190,77,.32);
}

*{box-sizing:border-box}
html,body{margin:0;padding:0}
html{
  transition:background-color 0.3s ease, color 0.3s ease;
}
body{
  background:var(--surface-2); color:var(--ink);
  font-family:var(--font-ui); font-size:14px; line-height:1.5; letter-spacing:-.006em;
  -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility;
  transition:background-color 0.3s ease, color 0.3s ease;
}
a{color:var(--brand-ink); text-decoration:none; transition:color var(--dur) var(--ease)}
a:hover{color:#33400e; text-decoration:underline}
.mono{font-family:var(--font-mono); font-variant-numeric:tabular-nums; font-feature-settings:"tnum" 1}
h1,h2,h3{letter-spacing:-.018em}

/* Keyboard focus ring — accessibility floor */
:focus-visible{outline:2px solid var(--brand-strong); outline-offset:2px; border-radius:4px}
button:focus:not(:focus-visible),a:focus:not(:focus-visible){outline:none}

/* Subtle, unobtrusive scrollbars */
*{scrollbar-width:thin; scrollbar-color:#d9d9de transparent}
*::-webkit-scrollbar{width:10px; height:10px}
*::-webkit-scrollbar-thumb{background:#dadade; border-radius:8px; border:3px solid var(--bg)}
*::-webkit-scrollbar-thumb:hover{background:#c7c7cd}

/* Dark theme scrollbars */
[data-theme="dark"] *{scrollbar-color:#47474f transparent}
[data-theme="dark"] *::-webkit-scrollbar-thumb{background:#47474f}
[data-theme="dark"] *::-webkit-scrollbar-thumb:hover{background:#5a5a62}

/* ===========================================================================
   App shell: sidebar + topbar + content
   =========================================================================== */
.shell{display:flex; min-height:100vh}
.sidebar{
  width:252px; flex:0 0 252px; background:var(--surface);
  padding:18px 14px; position:sticky; top:0; height:100vh;
  display:flex; flex-direction:column; z-index:10;
  box-shadow:6px 0 22px -16px rgba(20,22,28,.16);
}
.brand{display:flex; align-items:center; gap:11px; padding:4px 8px 16px; margin-bottom:6px}
.brand img{height:34px; width:auto}
.brand-name{font-weight:700; font-size:15.5px; letter-spacing:-.02em; color:var(--ink)}
.nav{display:flex; flex-direction:column; gap:1px; margin-top:10px}
.nav a{
  display:flex; align-items:center; gap:11px; padding:10px 13px; border-radius:var(--r);
  color:var(--ink-2); font-weight:500; font-size:13.5px; position:relative;
  transition:background var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.nav a svg{width:18px; height:18px; flex:0 0 18px; opacity:.6; transition:opacity var(--dur) var(--ease)}
.nav a:hover{background:var(--surface-hover); text-decoration:none; color:var(--ink)}
.nav a:hover svg{opacity:.85}
/* Active = filled gradient pill with a soft brand glow */
.nav a.active{background:linear-gradient(135deg, var(--brand), var(--brand-strong)); color:#1b2207; font-weight:600; box-shadow:0 5px 14px -3px rgba(188,216,79,.6)}
.nav a.active svg{opacity:1; color:#1b2207}
.nav .sep{margin:14px 8px 7px; font-size:10.5px; text-transform:uppercase; letter-spacing:.08em; color:var(--ink-4); font-weight:700}

.main{flex:1; display:flex; flex-direction:column; min-width:0; position:relative}
/* Faint logo watermark behind every page (bottom-right corner) */
.main::after{
  content:""; position:fixed; right:-6vw; top:50%; transform:translateY(-50%);
  width:48vw; height:52vw; max-width:720px; max-height:780px;
  background:url('/assets/images/bg.svg') no-repeat center/contain;
  opacity:.34; pointer-events:none; z-index:0;
  filter:drop-shadow(0 22px 44px rgba(17,18,20,.22));
}
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 22px; margin:16px 22px 0; border-radius:var(--r-lg);
  background:var(--surface); border:1px solid var(--border);
  position:sticky; top:16px; z-index:20; box-shadow:var(--shadow);
}
.topbar h1{font-size:18px; font-weight:600; margin:0; letter-spacing:-.02em}
.topbar .user{display:flex; align-items:center; gap:16px; font-size:13px; color:var(--ink-3)}
.content{padding:22px; flex:1; position:relative; z-index:1; animation:fadeUp var(--dur-2) var(--ease)}
@keyframes fadeUp{from{opacity:0; transform:translateY(6px)} to{opacity:1; transform:none}}

/* Hamburger + drawer overlay — hidden on desktop, activated by the mobile query */
.nav-toggle{display:none; flex-direction:column; justify-content:center; gap:4px; width:40px; height:40px;
  padding:0 9px; border:1px solid var(--border-strong); border-radius:var(--r-sm); background:#fff; cursor:pointer; flex:0 0 auto}
.nav-toggle span{display:block; height:2px; width:100%; background:var(--ink-2); border-radius:2px; transition:transform var(--dur) var(--ease), opacity var(--dur) var(--ease)}
.nav-overlay{display:none; position:fixed; inset:0; background:rgba(10,10,10,.42); z-index:39; opacity:0; transition:opacity var(--dur-2) var(--ease)}

/* ===========================================================================
   Cards
   =========================================================================== */
.card{background:var(--surface); border:1px solid var(--border); border-radius:var(--r-lg); padding:24px; box-shadow:var(--shadow)}
.card + .card{margin-top:18px}
.card h2{font-size:15.5px; font-weight:600; margin:0 0 16px; letter-spacing:-.02em}

.grid{display:grid; gap:18px}
.grid-4{grid-template-columns:repeat(4,1fr)}
.grid-2{grid-template-columns:repeat(2,1fr)}
@media(max-width:1200px){.grid-4{grid-template-columns:repeat(2,1fr)}}
@media(max-width:900px){.grid-2{grid-template-columns:1fr}}

/* Stat tiles */
.stat{background:var(--surface); border:1px solid var(--border); border-radius:var(--r); padding:18px 20px; box-shadow:var(--shadow-sm); transition:transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease)}
.stat:hover{transform:translateY(-2px); box-shadow:var(--shadow); border-color:var(--border-2)}
.stat .label{font-size:11.5px; font-weight:600; color:var(--ink-3); text-transform:uppercase; letter-spacing:.05em}
.stat .value{font-size:30px; font-weight:700; margin-top:8px; font-variant-numeric:tabular-nums; letter-spacing:-.03em; line-height:1}

/* ===========================================================================
   Dashboard analytics cards
   =========================================================================== */
.section-head{display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:16px}
.btn.sm{padding:6px 12px; font-size:12.5px}
/* Cards are links — keep them looking like cards, not text links */
.kpi,.gcard,.pipe-chip{text-decoration:none; cursor:pointer}
.kpi:hover,.gcard:hover,.pipe-chip:hover{text-decoration:none}

/* Primary KPI row — white card with a lime or black icon tile (brand only) */
.kpi-grid{display:grid; grid-template-columns:repeat(4,1fr); gap:16px}
.kpi{display:flex; align-items:center; gap:14px; background:var(--surface); border:1px solid var(--border);
  border-radius:var(--r); padding:16px 18px; box-shadow:var(--shadow-sm);
  transition:transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease)}
.kpi:hover{transform:translateY(-2px); box-shadow:var(--shadow); border-color:var(--border-2)}
.kpi-ico{flex:0 0 auto; width:48px; height:48px; border-radius:13px; display:flex; align-items:center; justify-content:center}
.kpi-ico svg{width:24px; height:24px}
.kpi-label{font-size:11px; font-weight:700; color:var(--ink-3); text-transform:uppercase; letter-spacing:.05em}
.kpi-value{font-size:26px; font-weight:700; margin-top:4px; line-height:1; letter-spacing:-.03em; color:var(--ink)}
.kpi-lime .kpi-ico{background:linear-gradient(135deg,var(--brand),var(--brand-strong)); color:var(--brand-ink)}
.kpi-dark .kpi-ico{background:linear-gradient(135deg,var(--ink-2),var(--ink)); color:var(--brand)}

/* WhatsApp overview — full brand cards, lime or black, with the icon on the right */
.gcard-grid{display:grid; grid-template-columns:repeat(4,1fr); gap:16px}
.gcard{position:relative; overflow:hidden; display:flex; align-items:center; justify-content:space-between; gap:10px;
  border-radius:var(--r); padding:18px 20px; box-shadow:var(--shadow-sm);
  transition:transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease)}
.gcard:hover{transform:translateY(-3px); box-shadow:var(--shadow)}
.gcard-label{font-size:12.5px; font-weight:600; letter-spacing:.01em}
.gcard-value{font-size:30px; font-weight:800; margin-top:6px; line-height:1; letter-spacing:-.03em; font-variant-numeric:tabular-nums}
.gcard-ico{flex:0 0 auto}
.gcard-ico svg{width:34px; height:34px}
.gcard::after{content:""; position:absolute; right:-26px; bottom:-30px; width:96px; height:96px; border-radius:50%}
/* Lime card: black text/icon on lime */
.gcard.lime{background:linear-gradient(135deg,var(--brand),var(--brand-strong))}
.gcard.lime .gcard-label{color:var(--brand-ink)}
.gcard.lime .gcard-value{color:var(--ink)}
.gcard.lime .gcard-ico{color:var(--brand-ink)}
.gcard.lime::after{background:rgba(10,10,10,.07)}
/* Black card: lime accents on near-black */
.gcard.dark{background:linear-gradient(135deg,var(--ink-2),var(--ink))}
.gcard.dark .gcard-label{color:rgba(255,255,255,.72)}
.gcard.dark .gcard-value{color:var(--brand)}
.gcard.dark .gcard-ico{color:var(--brand)}
.gcard.dark::after{background:rgba(201,225,103,.14)}

/* Messages line chart (inline SVG) */
.chart-wrap{width:100%}
.msg-chart{width:100%; height:auto; display:block}
.msg-chart .grid-line{stroke:var(--border); stroke-width:1; stroke-dasharray:4 4}
.msg-chart .axis-label{fill:var(--ink-3); font-size:13px; font-family:var(--font-ui)}
.msg-chart .line-sent{fill:none; stroke:var(--brand-strong); stroke-width:2.5; stroke-linecap:round; stroke-linejoin:round}
.msg-chart .line-recv{fill:none; stroke:var(--ink); stroke-width:2.5; stroke-linecap:round; stroke-linejoin:round}
.msg-chart .area-sent{fill:var(--brand); fill-opacity:.16; stroke:none}
.msg-chart .area-recv{fill:var(--ink); fill-opacity:.05; stroke:none}
.chart-legend{display:flex; justify-content:center; gap:24px; margin-top:14px}
.leg{display:inline-flex; align-items:center; gap:7px; font-size:13px; color:var(--ink-2); font-weight:500}
.leg strong{color:var(--ink); font-weight:700}
.leg i{width:11px; height:11px; border-radius:50%; display:inline-block}
.leg-sent i{background:var(--brand-strong)}
.leg-recv i{background:var(--ink)}

/* Lead pipeline bar — lime ramp for progress, greys for start/closed */
.pipeline-bar{display:flex; height:14px; border-radius:8px; overflow:hidden; background:var(--surface-2); gap:2px}
.pipe-seg{transition:flex var(--dur-2) var(--ease)}
.pipeline-legend{display:flex; flex-wrap:wrap; gap:8px 16px; margin-top:14px}
.pipe-chip{display:inline-flex; align-items:center; gap:7px; font-size:12.5px; color:var(--ink-2); font-weight:500}
.pipe-chip strong{color:var(--ink); font-weight:700}
.pipe-chip i{width:10px; height:10px; border-radius:3px; display:inline-block}
.p-new       i,.p-new.pipe-seg{background:var(--ink-4)}
.p-contacted i,.p-contacted.pipe-seg{background:var(--brand-strong)}
.p-qualified i,.p-qualified.pipe-seg{background:var(--brand)}
.p-customer  i,.p-customer.pipe-seg{background:var(--brand-ink)}
.p-lost      i,.p-lost.pipe-seg{background:var(--ink-2)}

@media(max-width:1200px){.kpi-grid,.gcard-grid{grid-template-columns:repeat(2,1fr)}}
@media(max-width:640px){.kpi-grid,.gcard-grid{grid-template-columns:1fr}}

/* ===========================================================================
   Contacts list (avatars, status badges, assigned chips)
   =========================================================================== */
.contacts-table td{padding:12px 16px}
.contacts-table th{padding:11px 16px}
.contact-cell{display:flex; align-items:center; gap:12px; min-width:0}
.contact-id{min-width:0}
.contact-name{font-weight:600; color:var(--ink); font-size:13.5px; line-height:1.25;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:280px}
.contact-sub{font-size:12px; color:var(--ink-3); margin-top:1px}
.lock-ico{margin-left:7px; font-size:11px; opacity:.7; vertical-align:middle}

.avatar{width:38px; height:38px; border-radius:50%; flex:0 0 auto; display:flex; align-items:center; justify-content:center;
  font-weight:700; font-size:13px; letter-spacing:.02em; border:1px solid transparent}
.avatar svg{width:18px; height:18px}
/* Cached WhatsApp profile pictures fill the circular avatar slots. */
.avatar.has-img,.conv .avatar.has-img,.chat-avatar.has-img,.cp-avatar.has-img{background:var(--surface-2); padding:0; overflow:hidden}
.avatar img,.chat-avatar img,.cp-avatar img{width:100%; height:100%; object-fit:cover; border-radius:50%; display:block}
/* A profile picture (header/panel) is clickable to view full-size. */
.chat-avatar.has-img,.cp-avatar.has-img{cursor:pointer; transition:filter .12s, box-shadow .12s}
.chat-avatar.has-img:hover,.cp-avatar.has-img:hover{filter:brightness(1.04); box-shadow:0 0 0 2px var(--brand-strong)}
.avatar.av-lime{background:var(--brand-soft); color:var(--brand-ink); border-color:var(--brand-strong)}
.avatar.av-dark{background:var(--ink); color:var(--brand); border-color:var(--ink)}
.avatar.av-group{background:var(--surface-2); color:var(--ink-3); border-color:var(--border-2)}

/* Lead-status badges — lime intensity ramp, greys for start/closed */
.st{display:inline-flex; align-items:center; padding:3px 11px; border-radius:7px; font-size:11.5px; font-weight:600; border:1px solid transparent; white-space:nowrap}
.st-new{background:var(--surface-2); color:var(--ink-2); border-color:var(--border-2)}
.st-contacted{background:var(--brand-tint); color:var(--brand-ink); border-color:var(--brand-soft)}
.st-qualified{background:var(--brand-soft); color:var(--brand-ink); border-color:var(--brand-strong)}
.st-customer{background:var(--brand); color:var(--ink); border-color:var(--brand-strong)}
.st-lost{background:var(--surface-2); color:var(--ink-4); border-color:var(--border-2)}

.assigned-chip{display:inline-flex; align-items:center; gap:7px; font-size:12.5px; color:var(--ink-2); font-weight:500}
.assigned-chip .dot{width:7px; height:7px; border-radius:50%; background:var(--brand-strong); flex:0 0 auto}
.dash{color:var(--ink-4)}

/* Tag chips (contacts list + tags page) */
.tag-row{display:flex; flex-wrap:wrap; gap:4px; margin-top:5px}
.tag-chip{display:inline-flex; align-items:center; padding:1px 9px; border-radius:20px; font-size:11px; font-weight:600; line-height:1.7; white-space:nowrap; text-decoration:none; border:1px solid rgba(0,0,0,.06)}
a.tag-chip:hover{text-decoration:none; filter:brightness(.95)}

.empty-state{display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; padding:56px 20px}
.empty-ico{width:56px; height:56px; border-radius:50%; background:var(--surface-2); display:flex; align-items:center; justify-content:center; margin-bottom:14px}
.empty-ico svg{width:26px; height:26px; stroke:var(--ink-4); fill:none; stroke-width:2}

/* ===========================================================================
   Tables
   =========================================================================== */
table{width:100%; border-collapse:collapse; font-size:13.5px}
thead th{background:var(--surface-2)}
th{text-align:left; font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.05em; color:var(--ink-3); padding:11px 14px; border-bottom:1px solid var(--border)}
td{padding:13px 14px; border-bottom:1px solid var(--border); color:var(--ink-2); vertical-align:middle}
tbody tr{transition:background var(--dur) var(--ease)}
tbody tr:hover td{background:var(--surface-2)}
tbody tr:last-child td{border-bottom:0}

/* ===========================================================================
   Badges
   =========================================================================== */
.badge{display:inline-flex; align-items:center; gap:5px; padding:3px 10px; border-radius:6px; font-size:11.5px; font-weight:600; line-height:1.4; background:var(--brand-soft); color:var(--brand-ink); border:1px solid transparent}
.badge.gray{background:var(--surface-2); color:var(--ink-3); border-color:var(--border)}

/* ===========================================================================
   Forms
   =========================================================================== */
label{display:block; font-size:11.5px; font-weight:600; color:var(--ink-2); margin:14px 0 6px; text-transform:uppercase; letter-spacing:.04em}
/* Text-like fields only — checkboxes/radios/color/file keep native behaviour */
input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file]),
select,textarea{
  width:100%; padding:10px 13px; border:1px solid var(--border-strong); border-radius:var(--r-sm);
  font-size:14px; font-family:inherit; background:var(--surface); color:var(--ink); line-height:1.4;
  transition:border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); appearance:none;
}
input::placeholder,textarea::placeholder{color:var(--ink-4)}
input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file]):focus,
select:focus,textarea:focus{outline:none; border-color:var(--brand-strong); box-shadow:0 0 0 3px rgba(188,216,79,.3)}
select{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6b71' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 12px center; padding-right:34px}
/* Checkboxes & radios — native, clickable, brand-coloured */
input[type=checkbox],input[type=radio]{width:17px; height:17px; accent-color:var(--brand-strong); cursor:pointer; margin:0; vertical-align:middle}
input[type=color]{width:auto; height:38px; padding:3px; cursor:pointer}
input[type=file]{font-size:13px; cursor:pointer}

/* Password field with toggle */
.password-field{position:relative; display:flex; align-items:center}
.password-field input{padding-right:60px}
.password-toggle{position:absolute; right:8px; top:50%; transform:translateY(-50%); display:flex; align-items:center; justify-content:center; background:none; border:none; cursor:pointer; font-size:11.5px; font-weight:600; color:var(--brand-ink); padding:4px 8px; border-radius:4px; transition:background var(--dur) var(--ease), color var(--dur) var(--ease)}
.password-toggle:hover{background:var(--brand-soft); color:var(--brand-ink)}

/* Real-time password match message */
.password-match-msg{font-size:12.5px; font-weight:500; margin-top:6px; padding:6px 10px; border-radius:6px; transition:all var(--dur-2) var(--ease)}
.password-match-msg.match{color:var(--success); background:var(--success-bg); border:1px solid var(--success-border)}
.password-match-msg.no-match{color:var(--danger); background:var(--danger-bg); border:1px solid var(--danger-border)}

/* ===========================================================================
   Buttons
   =========================================================================== */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px; padding:10px 17px; border:1px solid transparent;
  border-radius:var(--r-sm); font-size:13.5px; font-weight:600; font-family:inherit; cursor:pointer;
  background:var(--brand); color:#13160a; box-shadow:var(--shadow-xs); line-height:1;
  transition:transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.btn:hover{background:var(--brand-strong); text-decoration:none; box-shadow:var(--shadow-sm)}
.btn:active{transform:translateY(.5px); box-shadow:var(--shadow-xs)}
.btn.ghost{background:var(--surface); border-color:var(--border-strong); color:var(--ink-2); box-shadow:var(--shadow-xs)}
.btn.ghost:hover{background:var(--surface-2); border-color:var(--border-strong); color:var(--ink); box-shadow:var(--shadow-xs)}
.btn.danger{background:var(--surface); border-color:var(--danger-border); color:var(--danger); box-shadow:var(--shadow-xs)}
.btn.danger:hover{background:var(--danger-bg); box-shadow:var(--shadow-xs)}
.btn.sm{padding:7px 12px; font-size:12.5px}
.btn:disabled,.btn[disabled]{opacity:.5; cursor:not-allowed; transform:none; box-shadow:none}

/* ===========================================================================
   Alerts
   =========================================================================== */
.alert{border-radius:var(--r-sm); padding:12px 15px; margin-bottom:18px; font-size:13.5px; border:1px solid transparent; border-left-width:4px}
.alert.error{background:var(--danger-bg); border-color:var(--danger-border); border-left-color:var(--danger); color:#9a1f30}
.alert.ok{background:var(--success-bg); border-color:var(--success-border); border-left-color:var(--brand-strong); color:var(--brand-ink)}

.page-actions{display:flex; justify-content:space-between; align-items:center; gap:14px; margin-bottom:20px; flex-wrap:wrap}
.muted{color:var(--ink-3)}
.flex{display:flex; align-items:center; gap:10px}

/* ===========================================================================
   Inbox (3-pane)
   =========================================================================== */
.inbox{display:grid; grid-template-columns:350px 1fr 300px; gap:0; border:1px solid var(--border); border-radius:var(--r); overflow:hidden; height:calc(100vh - 150px); box-shadow:var(--shadow-sm); background:var(--surface)}
.inbox-col{display:flex; flex-direction:column; min-width:0; min-height:0}
.inbox-list{border-right:1px solid var(--border); background:var(--surface)}
.inbox-chat{background:#efeae2}
[data-theme="dark"] .inbox-chat{background:#0b141a}
[data-theme="dark"] .chat-body{background-color:#0b141a}
.inbox-side{border-left:1px solid var(--border); padding:20px; overflow-y:auto; background:var(--surface)}
.inbox-filters{padding:13px 14px; border-bottom:1px solid var(--border); display:flex; flex-direction:column; gap:9px; background:#fbfbf9; flex:0 0 auto}
.inbox-filters select,.inbox-filters input{padding:9px 12px; font-size:13px; border-radius:10px}
/* WhatsApp-style quick filter chips above the chat list. */
.chat-filters{display:flex; gap:7px; padding:9px 14px; border-bottom:1px solid var(--border); background:#fbfbf9; flex:0 0 auto; overflow-x:auto}
.chip-filter{flex:0 0 auto; padding:5px 13px; font-size:12.5px; font-weight:600; color:var(--ink-3); background:var(--surface-2); border:1px solid var(--border-2); border-radius:999px; cursor:pointer; transition:background .12s, color .12s, border-color .12s}
.chip-filter:hover{background:var(--brand-soft)}
.chip-filter.active{background:var(--brand); color:var(--brand-ink); border-color:var(--brand-strong)}
.conv-list{overflow-y:auto; flex:1 1 auto; min-height:0; background:var(--surface)}
/* In-chat search bar + result highlighting. */
.chat-search{display:flex; align-items:center; gap:8px; padding:8px 12px; border-bottom:1px solid var(--border); background:#fbfbf9; flex:0 0 auto}
.chat-search[hidden]{display:none}   /* respect the hidden attribute (class display: would otherwise override it) */
.chat-search .cs-ico{width:16px; height:16px; color:var(--ink-3); flex:0 0 auto}
.chat-search input{flex:1; min-width:0; padding:7px 10px; font-size:13px; border-radius:9px; border:1px solid var(--border-2); background:var(--surface)}
.chat-search .cs-count{font-size:12px; color:var(--ink-3); white-space:nowrap; min-width:46px; text-align:right}
.chat-search .cs-nav,.chat-search .cs-close{flex:0 0 auto; width:26px; height:26px; border:none; background:transparent; color:var(--ink-2); cursor:pointer; border-radius:7px; font-size:15px; line-height:1}
.chat-search .cs-nav:hover,.chat-search .cs-close:hover{background:var(--surface-2)}
mark.search-mark{background:#ffe08a; color:inherit; border-radius:2px; padding:0 1px}
.msg-row.search-current .bubble{box-shadow:0 0 0 2px var(--brand-strong)}
/* Per-message hover action button + floating action menu + star marker. */
.msg-act{position:absolute; top:0; right:0; width:38px; height:26px; border:none; cursor:pointer; opacity:0; transition:opacity .12s; display:flex; align-items:flex-start; justify-content:flex-end; padding:3px 4px 0 0; color:#7d8b97; border-radius:0 8px 0 0; z-index:2}
.msg-act svg{width:16px; height:16px}
.bubble:hover .msg-act,.msg-act:focus-visible{opacity:1}
.bubble.in .msg-act{background:linear-gradient(to left, var(--bubble-in) 58%, transparent)}
.bubble.out .msg-act{background:linear-gradient(to left, var(--bubble-out) 58%, transparent)}
.star-ico{color:#f0b429; font-size:11px; line-height:1}
.msg-menu{position:fixed; z-index:1200; min-width:148px; background:var(--surface); border:1px solid var(--border-2); border-radius:10px; box-shadow:0 8px 28px rgba(0,0,0,.18); padding:5px}
.msg-menu[hidden]{display:none}
.msg-menu button{display:flex; align-items:center; gap:9px; width:100%; padding:8px 11px; border:none; background:transparent; color:var(--ink); font-size:13px; text-align:left; border-radius:7px; cursor:pointer}
.msg-menu button:hover{background:var(--surface-2)}
.msg-menu .mi-ico{width:16px; text-align:center}
.msg-menu button.mi-danger{color:#c0392b}
.msg-menu button.mi-danger:hover{background:#fdecea}
.icon-btn.active{background:var(--brand-soft); color:var(--brand-ink)}
/* Deleted-for-everyone placeholder + "edited" marker. */
.bubble.deleted .txt{font-style:italic; color:var(--ink-3)}
/* Clickable location pin. */
.bubble.loc{padding:8px 10px}
.loc-link{display:flex; align-items:center; gap:9px; text-decoration:none; color:inherit}
.loc-link .loc-pin{font-size:22px; line-height:1}
.loc-link .loc-body{display:flex; flex-direction:column; min-width:0}
.loc-link .loc-name{font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:220px}
.loc-link .loc-open{font-size:11.5px; color:var(--brand-strong); font-weight:600}
.loc-link:hover .loc-open{text-decoration:underline}
.m-edited{font-size:10.5px; color:#8696a0; font-style:italic; margin-right:1px}
/* Quick-react emoji row at the top of the action menu. */
.react-row{display:flex; gap:2px; padding:3px 2px 6px; margin-bottom:4px; border-bottom:1px solid var(--border)}
.react-emoji{border:none; background:transparent; cursor:pointer; font-size:19px; line-height:1; padding:4px 5px; border-radius:8px; transition:transform .1s, background .1s}
.react-emoji:hover{background:var(--surface-2); transform:scale(1.18)}
.react-emoji.on{background:var(--brand-soft)}
/* Reaction badge that overlaps the bottom of a bubble. */
.m-react{margin-top:-11px; margin-bottom:1px; background:var(--surface); border:1px solid var(--border-2); border-radius:11px; padding:0 7px; font-family:inherit; font-size:13px; line-height:18px; box-shadow:0 1px 3px rgba(0,0,0,.14); position:relative; z-index:3; cursor:pointer}
.m-react:hover{background:var(--surface-2)}
.msg-row.out .m-react{margin-right:8px}
.msg-row.in .m-react{margin-left:8px}
/* "Who reacted" popup (click a reaction badge). */
.react-pop{position:fixed; z-index:1250; min-width:160px; max-width:260px; background:var(--surface); border:1px solid var(--border-2); border-radius:10px; box-shadow:0 8px 28px rgba(0,0,0,.2); padding:7px 5px}
.react-pop[hidden]{display:none}
.react-pop .rp-title{font-size:10.5px; color:var(--ink-3); padding:2px 9px 6px; text-transform:uppercase; letter-spacing:.05em}
.react-pop .rp-row{display:flex; align-items:center; gap:10px; padding:5px 9px}
.react-pop .rp-emoji{font-size:18px; line-height:1}
.react-pop .rp-name{font-size:13px; color:var(--ink)}
/* Forward picker modal. */
.fwd-modal{position:fixed; inset:0; z-index:1400; background:rgba(0,0,0,.45); display:flex; align-items:center; justify-content:center; padding:16px}
.fwd-modal[hidden]{display:none}
.fwd-box{width:380px; max-width:100%; max-height:80vh; display:flex; flex-direction:column; background:var(--surface); border-radius:14px; box-shadow:0 18px 50px rgba(0,0,0,.3); overflow:hidden}
.fwd-head{display:flex; align-items:center; justify-content:space-between; padding:14px 16px; font-weight:600; border-bottom:1px solid var(--border)}
.fwd-head .fwd-close{border:none; background:transparent; font-size:20px; line-height:1; color:var(--ink-3); cursor:pointer; border-radius:7px; width:28px; height:28px}
.fwd-head .fwd-close:hover{background:var(--surface-2)}
.fwd-search{margin:12px 16px 8px; padding:9px 12px; font-size:13px; border-radius:10px; border:1px solid var(--border-2); background:var(--surface)}
.fwd-list{flex:1; overflow-y:auto; padding:4px 8px 10px}
.fwd-item{display:flex; align-items:center; gap:11px; width:100%; padding:8px 10px; border:none; background:transparent; cursor:pointer; border-radius:9px; text-align:left}
.fwd-item:hover{background:var(--surface-2)}
.fwd-av{flex:0 0 auto; width:36px; height:36px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:13px; background:linear-gradient(135deg,#e9f2cf,#d6e6b0); color:#3f4d29}
.fwd-meta{display:flex; flex-direction:column; min-width:0}
.fwd-name{font-size:13.5px; color:var(--ink); white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.fwd-sub{font-size:11.5px; color:var(--ink-3); white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.fwd-empty{padding:18px; text-align:center; color:var(--ink-3); font-size:13px}
/* Share location / contact forms (reuse the fwd-modal shell). */
.share-form{padding:12px 16px 16px; display:flex; flex-direction:column}
.share-form label{font-size:12px; color:var(--ink-3); margin:8px 0 3px}
.share-form input{padding:9px 11px; font-size:13px; border-radius:9px; border:1px solid var(--border-2); background:var(--surface)}
.share-actions{margin-top:14px; display:flex; justify-content:flex-end}
/* Group management modal. */
.grp-rename{display:flex; gap:8px; padding:12px 16px 8px}
.grp-rename input{flex:1; padding:9px 11px; font-size:13px; border-radius:9px; border:1px solid var(--border-2); background:var(--surface)}
.grp-member{display:flex; align-items:center; gap:11px; padding:8px 10px; border-radius:9px}
.grp-member:hover{background:var(--surface-2)}
.grp-member .gp-actions{margin-left:auto; display:flex; gap:6px; flex-wrap:wrap; justify-content:flex-end}
.gp-act{border:1px solid var(--border-2); background:var(--surface); color:var(--ink-2); font-size:11.5px; padding:4px 8px; border-radius:7px; cursor:pointer; white-space:nowrap}
.gp-act:hover{background:var(--surface-2)}
.gp-act.danger{color:#c0392b; border-color:#f3c9c4}
.gp-act.danger:hover{background:#fdecea}
.grp-badge{font-size:10px; font-weight:600; color:var(--brand-ink); background:var(--brand-soft); border-radius:6px; padding:1px 5px; margin-left:4px; vertical-align:middle}
.grp-foot{padding:12px 16px; border-top:1px solid var(--border); display:flex; justify-content:flex-start}
.grp-foot .grp-leave{color:#c0392b}
/* Transient toast. */
.wc-toast{position:fixed; bottom:24px; left:50%; transform:translateX(-50%); z-index:1500; background:var(--ink); color:#fff; padding:10px 16px; border-radius:10px; font-size:13px; box-shadow:0 8px 24px rgba(0,0,0,.25); max-width:80vw}
.wc-toast[hidden]{display:none}
.react-more{font-weight:700; color:var(--ink-3); font-size:18px}
/* Full emoji picker (reactions "+" and the composer emoji button). */
.emoji-pop{position:fixed; z-index:1300; width:300px; max-width:92vw; background:var(--surface); border:1px solid var(--border-2); border-radius:12px; box-shadow:0 10px 34px rgba(0,0,0,.22); overflow:hidden; display:flex; flex-direction:column}
.emoji-pop[hidden]{display:none}
.emoji-pop .ep-grid{display:grid; grid-template-columns:repeat(8,1fr); gap:1px; padding:8px; max-height:258px; overflow-y:auto}
.emoji-pop .ep-emoji{border:none; background:transparent; cursor:pointer; font-size:21px; line-height:1; padding:5px 0; border-radius:7px}
.emoji-pop .ep-emoji:hover{background:var(--surface-2)}
.emoji-pop .ep-tabs{display:flex; border-top:1px solid var(--border); background:#fbfbf9}
.emoji-pop .ep-tab{flex:1; border:none; background:transparent; cursor:pointer; font-size:16px; padding:7px 0; opacity:.55}
.emoji-pop .ep-tab:hover{opacity:1; background:var(--surface-2)}
.emoji-pop .ep-tab.on{opacity:1; border-bottom:2px solid var(--brand-strong)}
/* Compact template popup (replaces the wide Template… select). */
/* Composer toolbar: every control is one flat, equally-sized circular icon
   button, so the whole row reads as a consistent set. Send is the lone accent. */
#composer > .btn.ghost{width:40px; height:40px; flex:0 0 40px; padding:0; line-height:0; color:#54656f;
  border:1px solid transparent; background:transparent; box-shadow:none; border-radius:50%;
  display:flex; align-items:center; justify-content:center}
#composer > .btn.ghost:hover{color:var(--ink); background:var(--surface-2)}
#composer > .btn.ghost svg{width:20px; height:20px; display:block}
#composer > .btn.ghost:disabled{opacity:.45}
#composer > #composer-send{background:var(--brand); color:var(--brand-ink); border-color:transparent}
#composer > #composer-send:hover{background:var(--brand-strong); color:var(--brand-ink)}
#composer-send.sending{opacity:.5; pointer-events:none}
.tpl-menu{position:fixed; z-index:1200; min-width:170px; max-width:260px; max-height:300px; overflow-y:auto; background:var(--surface); border:1px solid var(--border-2); border-radius:10px; box-shadow:0 8px 28px rgba(0,0,0,.18); padding:5px}
.tpl-menu[hidden]{display:none}
.tpl-menu button{display:block; width:100%; text-align:left; padding:8px 11px; border:none; background:transparent; color:var(--ink); font-size:13px; border-radius:7px; cursor:pointer; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.tpl-menu button:hover{background:var(--surface-2)}
.tpl-menu .tpl-empty{padding:10px 11px; color:var(--ink-3); font-size:12.5px}
/* Reply/quote strip inside a bubble. */
.q-quote{display:block; border-left:3px solid var(--brand-strong); background:rgba(0,0,0,.05); border-radius:4px; padding:3px 8px; margin:1px 0 4px; font-size:12.5px; line-height:1.35; max-width:100%; overflow:hidden}
.bubble.out .q-quote{background:rgba(0,0,0,.07)}
.q-quote .q-sender{display:block; font-weight:600; color:var(--brand-strong); font-size:11.5px; margin-bottom:1px}
.q-quote .q-text{display:block; color:var(--ink-2); white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
/* "Forwarded" label on a message. */
.m-fwd{display:flex; align-items:center; gap:4px; color:var(--ink-3); font-size:12px; font-style:italic; margin:0 0 2px}
.m-fwd svg{width:13px; height:13px}
/* Reply composer bar (above the input). */
.reply-bar[hidden]{display:none}
.reply-bar .rb-bar{display:flex; align-items:center; gap:10px; background:var(--surface-2); border-left:3px solid var(--brand-strong); border-radius:7px; padding:7px 10px; margin:8px 12px 0}
.reply-bar .rb-body{flex:1; min-width:0; display:flex; flex-direction:column; font-size:12.5px; line-height:1.3}
.reply-bar .rb-sender{font-weight:600; color:var(--brand-strong); font-size:11.5px}
.reply-bar .rb-text{color:var(--ink-2); white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.reply-bar .rb-close{flex:0 0 auto; width:24px; height:24px; border:none; background:transparent; color:var(--ink-3); cursor:pointer; font-size:17px; line-height:1; border-radius:6px}
.reply-bar .rb-close:hover{background:var(--surface)}
/* Active chat fills the pane; only the message body scrolls so the composer stays fixed */
#chat-active{flex:1 1 auto; min-height:0; height:auto !important}
.chat-head{flex:0 0 auto}
.chat-composer{flex:0 0 auto}

/* ---- contact rows ---- */
.conv{display:flex; gap:12px; padding:11px 15px; border-bottom:1px solid #f2f1ed; cursor:pointer; align-items:center; transition:background var(--dur) var(--ease)}
.conv:hover{background:#f7f8f3}
.conv.active{background:var(--brand-soft); box-shadow:inset 3px 0 0 var(--brand-strong)}
.conv .avatar{width:46px; height:46px; border-radius:50%; background:linear-gradient(135deg,#e9f2cf,#d6e6b0); color:#3f4d29; display:flex; align-items:center; justify-content:center; font-weight:700; flex:0 0 46px; font-size:15px; letter-spacing:.4px; box-shadow:inset 0 0 0 1px rgba(0,0,0,.03)}
.conv .meta{min-width:0; flex:1; display:flex; flex-direction:column; justify-content:center; gap:3px}
.conv-top{display:flex; align-items:baseline; justify-content:space-between; gap:8px}
.conv .name{font-weight:600; font-size:14px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; color:var(--ink); flex:1; min-width:0}
.conv .time{font-size:11px; color:var(--ink-3); flex:0 0 auto; white-space:nowrap}
.conv-bot{display:flex; align-items:center; justify-content:space-between; gap:8px; min-height:17px}
.conv .preview{font-size:12.5px; color:var(--ink-3); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; flex:1; min-width:0}
.conv .phone{font-size:12px; color:var(--ink-3); font-family:var(--font-mono)}
.conv .unread{background:#25d366; color:#fff; border-radius:20px; font-size:11px; padding:1px 7px; font-weight:700; flex:0 0 auto; min-width:20px; text-align:center; line-height:1.6}

/* ---- chat header ---- */
.chat-head{padding:11px 18px; border-bottom:1px solid var(--border); display:flex; justify-content:space-between; align-items:center; background:var(--surface); box-shadow:0 1px 2px rgba(0,0,0,.04); z-index:1}
.chat-head-id{display:flex; align-items:center; gap:12px; min-width:0; flex:1 1 auto}
/* The name/phone column shrinks so a long name truncates instead of wrapping. */
.chat-head-txt{min-width:0; overflow:hidden; flex:1 1 auto}
.chat-avatar{width:42px; height:42px; border-radius:50%; background:linear-gradient(135deg,#e9f2cf,#d6e6b0); color:#3f4d29; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:15px; flex:0 0 42px}
.chat-presence{font-size:12px; color:var(--brand-strong); font-weight:600}
.chat-presence.typing{font-style:italic}

/* Group chats */
.conv .avatar.group,.chat-avatar.group{background:linear-gradient(135deg,#dbe8c6,#bcd2a0); color:#3a4a23}
.conv .avatar.group svg{width:24px; height:24px}
.chat-avatar.group svg{width:22px; height:22px}
.grp-tag{font-size:9.5px; font-weight:700; color:#3f4d29; background:#e9f2cf; border:1px solid #d6e6b0; border-radius:5px; padding:0 5px; vertical-align:middle; text-transform:uppercase; letter-spacing:.03em}
.grp-sender{display:block; font-size:12px; font-weight:700; color:#1f7a5a; margin:0 0 1px; line-height:1.25}
.bubble.out .grp-sender{display:none}
.chat-head .name{font-weight:600; font-size:15px; color:var(--ink); white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.chat-head #chat-phone{white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.chat-back{display:none; border:none; background:none; font-size:28px; line-height:1; color:var(--ink-2); cursor:pointer; padding:0 6px 0 0; flex:0 0 auto}

/* Chat-header toolbar: flat, minimal, evenly-spaced icon buttons (no boxy
   borders/shadows), grouped by a hair-line divider. */
.chat-actions{gap:2px; align-items:center; flex:0 0 auto}
.chat-div{width:1px; height:20px; background:var(--border); margin:0 5px; flex:0 0 auto}
.icon-btn{display:inline-flex; align-items:center; justify-content:center; width:36px; height:36px; border-radius:9px;
  border:1px solid transparent; background:transparent; color:var(--ink-3); cursor:pointer; flex:0 0 auto;
  transition:background var(--dur) var(--ease), color var(--dur) var(--ease)}
.icon-btn svg{width:18px; height:18px}
.icon-btn:hover{background:var(--brand-soft); color:var(--brand-ink)}
.icon-btn:active{background:var(--brand-soft)}
.icon-btn:disabled{opacity:.5; cursor:not-allowed}
.icon-btn.loading{pointer-events:none}
.icon-btn.loading svg{animation:pulse 1s ease-in-out infinite}
@keyframes pulse{0%,100%{opacity:1} 50%{opacity:.3}}
.chat-hint{margin:auto; max-width:300px; text-align:center; color:#54656f; font-size:14px; line-height:1.6; background:rgba(255,255,255,.72); padding:16px 18px; border-radius:12px; box-shadow:0 1px 2px rgba(0,0,0,.06)}
.chat-hint span{font-size:13px; color:#667781}

/* Pinned scheduled-messages bar (top of chat, WhatsApp pinned style) */
.sched-bar{flex:0 0 auto; background:var(--surface); border-bottom:1px solid var(--border); padding:7px 14px 9px; max-height:150px; overflow-y:auto}
.sched-bar-title{font-size:10.5px; font-weight:700; text-transform:uppercase; letter-spacing:.05em; color:var(--ink-4); margin:1px 0 5px}
.sched-item{display:flex; align-items:center; gap:10px; padding:6px 9px; border-radius:9px; background:var(--brand-tint); border-left:3px solid var(--brand-strong); margin-bottom:5px}
.sched-item:last-child{margin-bottom:0}
.sched-ic{font-size:15px; flex:0 0 auto}
.sched-meta{flex:1; min-width:0; display:flex; flex-direction:column; line-height:1.3}
.sched-when{font-size:12px; font-weight:700; color:var(--brand-ink)}
.sched-prev{font-size:12px; color:var(--ink-3); white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.sched-cancel-x{flex:0 0 auto; border:none; background:none; color:var(--ink-3); font-size:19px; line-height:1; cursor:pointer; padding:0 4px}
.sched-cancel-x:hover{color:var(--danger)}

/* Schedule-a-message modal */
.sched-modal{position:fixed; inset:0; z-index:60; display:flex; align-items:center; justify-content:center; padding:18px; background:rgba(10,10,10,.45)}
.sched-modal[hidden]{display:none}
.sched-card{width:100%; max-width:440px; background:var(--surface); border-radius:var(--r); box-shadow:var(--shadow-lg); overflow:hidden; animation:fadeUp var(--dur-2) var(--ease)}
.sched-head{display:flex; align-items:center; justify-content:space-between; padding:14px 18px; border-bottom:1px solid var(--border); font-weight:600; font-size:15px; color:var(--ink)}
.sched-x{border:none; background:none; font-size:24px; line-height:1; color:var(--ink-3); cursor:pointer; padding:0 2px}
.sched-x:hover{color:var(--ink)}
.sched-form{padding:14px 18px 20px}
.sched-form label{margin-top:14px}
.sched-form label:first-child{margin-top:0}
.sched-form textarea{resize:vertical; min-height:64px}

/* ---- message thread (WhatsApp style) ---- */
.chat-body{flex:1 1 auto; min-height:0; overflow-y:auto; padding:16px 7% 18px; display:flex; flex-direction:column; gap:2px;
  background-color:#efeae2}
.chat-day{align-self:center; margin:14px 0 8px; background:var(--chat-day-bg); color:var(--chat-day-text); font-size:11px; font-weight:600; padding:5px 13px; border-radius:9px; box-shadow:0 1px 1px rgba(0,0,0,.1); text-transform:uppercase; letter-spacing:.5px}
.bubble{position:relative; max-width:65%; padding:6px 9px 7px 10px; border-radius:8px; font-size:14.2px; line-height:1.42; white-space:pre-wrap; word-wrap:break-word; box-shadow:0 1px .5px rgba(0,0,0,.16); margin:2px 0}
.bubble .txt{display:inline}
.bubble .meta{float:right; margin:7px 0 -3px 12px; display:inline-flex; align-items:center; gap:3px; font-size:11px; line-height:1; color:#667781; user-select:none; position:relative; top:4px}
.bubble .tick{font-size:14px; line-height:1; letter-spacing:-3px; color:#8696a0; margin-left:2px}
.bubble .tick.read{color:#53bdeb}
.bubble.in{align-self:flex-start; background:var(--bubble-in); border-top-left-radius:0; color:var(--bubble-in-text)}
.bubble.out{align-self:flex-end; background:var(--bubble-out); border-top-right-radius:0; color:var(--bubble-out-text)}
.bubble.out .meta{color:#5c7a52}
.bubble .ph{color:#667781; font-style:italic}
/* tails */
.bubble.in::before{content:""; position:absolute; top:0; left:-8px; width:0; height:0; border-top:8px solid var(--bubble-in); border-left:8px solid transparent}
.bubble.out::before{content:""; position:absolute; top:0; right:-8px; width:0; height:0; border-top:8px solid var(--bubble-out); border-right:8px solid transparent}
/* voice note / audio */
.bubble.audio{padding:7px 8px 5px; max-width:330px}
.bubble.audio .voice{display:block; width:250px; height:40px; outline:none}
.bubble.out .voice{background:transparent}
.bubble.audio .meta{float:none; display:flex; justify-content:flex-end; margin:1px 2px 0 0; top:0}
/* image / video / document */
.bubble.media{padding:4px 4px 5px; max-width:300px}
.bubble.media .m-img{display:block; max-width:280px; max-height:340px; width:auto; border-radius:6px; cursor:pointer; background:#d9d3ca}
.bubble.media .m-img.sticker{max-width:130px; max-height:130px; background:transparent}
.bubble.media .m-vid{display:block; max-width:280px; max-height:340px; border-radius:6px; background:#000; outline:none}
.bubble.media .cap{padding:4px 6px 0; font-size:14px; line-height:1.4}
.bubble.media .doc{display:flex; align-items:center; gap:9px; padding:11px 13px; min-width:200px; max-width:280px; background:rgba(0,0,0,.045); border-radius:8px; color:inherit; text-decoration:none; font-size:13.5px}
.bubble.media .doc:hover{background:rgba(0,0,0,.075)}
.bubble.media .doc .ic{font-size:22px; flex:0 0 auto}
.bubble.media .doc .fn{flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.bubble.media .doc .dl{flex:0 0 auto; color:#54656f}
.bubble.media .meta{float:none; display:flex; justify-content:flex-end; margin:3px 4px 0 0; top:0}

/* video bubble: ⛶ expand button to open the lightbox */
.bubble.media.vid-wrap{position:relative}
.bubble.media .media-expand{position:absolute; top:9px; right:9px; width:30px; height:30px; border:none; border-radius:8px; background:rgba(0,0,0,.55); color:#fff; font-size:15px; line-height:1; cursor:pointer; display:flex; align-items:center; justify-content:center; opacity:.85}
.bubble.media .media-expand:hover{opacity:1; background:rgba(0,0,0,.75)}

/* Full-screen media lightbox */
.media-lightbox{position:fixed; inset:0; z-index:1000; background:rgba(12,12,12,.92); display:flex; align-items:center; justify-content:center; padding:34px}
.media-lightbox[hidden]{display:none}
.media-lightbox .ml-stage{max-width:94vw; max-height:88vh; display:flex; align-items:center; justify-content:center}
.media-lightbox .ml-stage img,
.media-lightbox .ml-stage video{max-width:94vw; max-height:88vh; width:auto; height:auto; border-radius:6px; box-shadow:0 12px 48px rgba(0,0,0,.5)}
.media-lightbox .ml-close{position:absolute; top:16px; right:18px; width:42px; height:42px; border:none; border-radius:50%; background:rgba(255,255,255,.12); color:#fff; font-size:26px; line-height:1; cursor:pointer; display:flex; align-items:center; justify-content:center}
.media-lightbox .ml-close:hover{background:rgba(255,255,255,.25)}
.media-lightbox .ml-download{position:absolute; bottom:18px; left:50%; transform:translateX(-50%); padding:9px 18px; border-radius:22px; background:var(--brand); color:var(--brand-ink); font-size:13.5px; font-weight:600; text-decoration:none}
.media-lightbox .ml-download:hover{filter:brightness(.96)}
.media-lightbox .ml-nav{position:absolute; top:50%; transform:translateY(-50%); width:46px; height:46px; border:none; border-radius:50%; background:rgba(255,255,255,.12); color:#fff; font-size:30px; line-height:1; cursor:pointer; display:flex; align-items:center; justify-content:center; padding-bottom:3px}
.media-lightbox .ml-nav:hover{background:rgba(255,255,255,.25)}
.media-lightbox .ml-prev{left:18px}
.media-lightbox .ml-next{right:18px}
.media-lightbox .ml-count{position:absolute; top:20px; left:50%; transform:translateX(-50%); color:rgba(255,255,255,.85); font-size:13px; letter-spacing:.03em}
@media (max-width:560px){.media-lightbox .ml-nav{width:40px; height:40px; font-size:26px} .media-lightbox .ml-prev{left:8px} .media-lightbox .ml-next{right:8px}}
body.ml-open{overflow:hidden}

/* Media gallery ("all media in this chat") — sits below the lightbox (z 1000). */
.media-modal{position:fixed; inset:0; z-index:70; display:flex; align-items:center; justify-content:center; padding:18px; background:rgba(10,10,10,.45)}
.media-modal[hidden]{display:none}
.mg-card{width:100%; max-width:720px; max-height:86vh; display:flex; flex-direction:column; background:var(--surface); border-radius:var(--r); box-shadow:var(--shadow-lg); overflow:hidden; animation:fadeUp var(--dur-2) var(--ease)}
.mg-head{display:flex; align-items:center; justify-content:space-between; padding:14px 18px; border-bottom:1px solid var(--border); font-weight:600; font-size:15px; color:var(--ink)}
.mg-x{border:none; background:none; font-size:24px; line-height:1; color:var(--ink-3); cursor:pointer; padding:0 2px}
.mg-filters{display:flex; gap:7px; padding:12px 16px 4px; flex-wrap:wrap}
.mg-chip{border:1px solid var(--border-strong); background:var(--surface); color:var(--ink-2); font:inherit; font-size:12.5px; padding:5px 13px; border-radius:16px; cursor:pointer}
.mg-chip.active{background:var(--brand); border-color:var(--brand); color:var(--brand-ink); font-weight:600}
.mg-note{padding:3px 18px 0; font-size:11.5px; color:var(--ink-3)}
.mg-note:empty{display:none}
.mg-body{padding:14px 16px 18px; overflow-y:auto}
.mg-grid{display:grid; grid-template-columns:repeat(auto-fill,minmax(104px,1fr)); gap:8px}
.mg-tile{position:relative; aspect-ratio:1/1; border:none; padding:0; border-radius:10px; overflow:hidden; cursor:pointer; background:var(--surface-2); display:block}
.mg-tile img,.mg-tile video{width:100%; height:100%; object-fit:cover; display:block}
.mg-vid .mg-play{position:absolute; inset:0; margin:auto; width:34px; height:34px; border-radius:50%; background:rgba(0,0,0,.5); color:#fff; display:flex; align-items:center; justify-content:center; font-size:14px}
.mg-vidph{background:linear-gradient(135deg,#2a333c,#171d24)}
.mg-vdate{position:absolute; left:6px; bottom:5px; font-size:10px; color:rgba(255,255,255,.82)}
.mg-file{display:flex; flex-direction:column; align-items:center; justify-content:center; gap:6px; text-decoration:none; color:var(--ink-2); padding:8px; text-align:center}
.mg-fic{font-size:26px; line-height:1}
.mg-fmeta{font-size:11px; line-height:1.35; word-break:break-word; max-height:48px; overflow:hidden}
.mg-fmeta i{color:var(--ink-3); font-style:normal}
.mg-empty{padding:40px 12px; text-align:center; color:var(--ink-3); font-size:13.5px}
.mg-loading{display:flex; align-items:center; justify-content:center; padding:48px 0}
body.mg-open{overflow:hidden}

/* ---- composer ---- */
.chat-composer{padding:9px 12px; border-top:1px solid var(--border); display:flex; gap:4px; background:#f0f1ea; align-items:flex-end}
.chat-composer textarea{resize:none; min-height:42px; max-height:120px; flex:1; margin:0 5px; padding:11px 16px; border-radius:21px; background:var(--surface); border:1px solid var(--border-2); font-size:14px}
/* voice recording bar */
.voice-bar{align-items:center; gap:12px}
.voice-bar .rec-dot{width:11px; height:11px; border-radius:50%; background:#e0245e; animation:recpulse 1.2s ease-in-out infinite; flex:0 0 11px}
@keyframes recpulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.3;transform:scale(.8)}}
.voice-bar #rec-time{font-size:15px; font-weight:700; color:#e0245e; min-width:42px}

/* file preview area (drag-drop & paste) */
.file-preview-area{flex:0 0 auto; padding:14px; background:var(--surface-2); border-top:1px solid var(--border)}
.file-preview-content{position:relative; background:var(--surface); border:1px solid var(--border-2); border-radius:var(--r); padding:14px; display:flex; flex-direction:column; gap:10px}
.file-preview-close{position:absolute; top:8px; right:8px; width:24px; height:24px; border-radius:50%; background:var(--ink-4); color:#fff; display:flex; align-items:center; justify-content:center; cursor:pointer; font-size:18px; line-height:1; transition:background var(--dur) var(--ease)}
.file-preview-close:hover{background:var(--ink-2)}
.file-preview-image{max-width:100%; max-height:240px; overflow:hidden; border-radius:var(--r-sm); display:flex; align-items:center; justify-content:center; background:var(--surface-2)}
.file-preview-image img{max-width:100%; max-height:240px; object-fit:contain; border-radius:var(--r-sm)}
.file-preview-doc{display:flex; align-items:center; gap:12px; padding:10px; background:var(--surface-2); border-radius:var(--r-sm)}
.file-preview-icon{font-size:32px; flex:0 0 32px}
.file-preview-name{font-weight:600; font-size:14px; color:var(--ink); flex:1; word-break:break-word}
.file-preview-size{font-size:12px; color:var(--ink-3); font-family:var(--font-mono)}
.file-preview-caption{border:1px solid var(--border-2); border-radius:8px; padding:10px 14px; font-size:14px; width:100%; font-family:var(--font-ui)}
.file-preview-caption:focus{outline:none; border-color:var(--brand-strong)}

/* drag overlay */
.drag-overlay{position:absolute; inset:0; background:rgba(201,225,103,0.9); backdrop-filter:blur(4px); z-index:100; display:flex; align-items:center; justify-content:center; animation:fadeIn var(--dur) var(--ease)}
@keyframes fadeIn{from{opacity:0}to{opacity:1}}
.drag-overlay-content{text-align:center; color:var(--brand-ink)}
.drag-overlay-icon{font-size:72px; margin-bottom:12px; animation:bounce 0.6s ease-in-out infinite}
@keyframes bounce{0%,100%{transform:translateY(0)}50%{transform:translateY(-10px)}}
.drag-overlay-text{font-size:20px; font-weight:700; letter-spacing:-.02em}

/* chat-active with drag-over state */
#chat-active.drag-over{position:relative}

.chat-empty{flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; color:#667781; font-size:14px; gap:12px; background:#eae6df; text-align:center; padding:30px}
.chat-empty::before{content:"💬"; font-size:48px; opacity:.55}
@media(max-width:1100px){.inbox{grid-template-columns:300px 1fr}.inbox-side{display:none}}

/* ===========================================================================
   Notification bell (topbar)
   =========================================================================== */
.notif-wrap{position:relative; display:inline-flex}
.notif{position:relative; display:inline-flex; align-items:center; justify-content:center; background:none; border:none; cursor:pointer; font-size:18px; line-height:1; padding:0; width:38px; height:38px; opacity:.82; transition:opacity var(--dur) var(--ease)}
.notif:hover{opacity:1}
.notif .dot{position:absolute; top:-5px; right:-6px; background:var(--danger); color:#fff; border-radius:20px; font-size:10px; min-width:17px; padding:1px 5px; font-weight:700; border:2px solid #fff; line-height:1.4; text-align:center}
.notif .dot[hidden]{display:none}

.notif-panel{position:absolute; top:calc(100% + 10px); right:0; width:340px; max-width:88vw; background:var(--surface);
  border:1px solid var(--border); border-radius:var(--r); box-shadow:var(--shadow-lg); z-index:50; overflow:hidden;
  animation:fadeUp var(--dur-2) var(--ease)}
.notif-panel[hidden]{display:none}
.notif-head{display:flex; align-items:center; justify-content:space-between; padding:12px 15px; border-bottom:1px solid var(--border); font-weight:600; font-size:13.5px; color:var(--ink)}
.notif-today{color:var(--ink-4); font-weight:500; font-size:11.5px}
.notif-readall{background:none; border:none; color:var(--brand-ink); font-size:12px; font-weight:600; cursor:pointer; padding:0}
.notif-readall:hover{text-decoration:underline}
.notif-list{max-height:60vh; overflow-y:auto}
.notif-item{display:block; padding:11px 15px; border-bottom:1px solid var(--border); text-decoration:none; color:var(--ink-2); transition:background var(--dur) var(--ease)}
.notif-item:last-child{border-bottom:0}
.notif-item:hover{background:var(--surface-2); text-decoration:none}
.notif-item.unread{background:var(--brand-tint)}
.notif-item.unread:hover{background:var(--brand-soft)}
.notif-item .nt{font-weight:600; color:var(--ink); font-size:13px; display:block}
.notif-item .nb{font-size:12.5px; color:var(--ink-3); margin-top:2px; display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.notif-item .na{font-size:11px; color:var(--ink-4); margin-top:3px; display:block}
.notif-empty{padding:34px 15px; text-align:center; color:var(--ink-4); font-size:13px}
.notif-foot{display:block; text-align:center; padding:11px; font-size:12.5px; color:var(--brand-ink); font-weight:600; border-top:1px solid var(--border)}
.notif-foot:hover{background:var(--surface-2); text-decoration:none}
@media(max-width:560px){.notif-panel{position:fixed; top:58px; right:8px; left:8px; width:auto; max-width:none}}

/* ===========================================================================
   Theme toggle button
   =========================================================================== */
.theme-toggle{
  position:relative; display:inline-flex; align-items:center; justify-content:center; 
  background:var(--surface-2); border:1px solid var(--border); border-radius:20px;
  cursor:pointer; width:38px; height:38px; padding:0; font-size:18px; line-height:1;
  transition:background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur-2) var(--ease);
}
.theme-toggle:hover{background:var(--surface-hover); border-color:var(--border-2); transform:scale(1.05)}
.theme-toggle:active{transform:scale(0.95)}

/* ===========================================================================
   Auth (login / 2FA)
   =========================================================================== */
.auth-wrap{min-height:100vh; display:flex; align-items:center; justify-content:center; padding:24px; background:radial-gradient(1200px 600px at 50% -10%, var(--brand-tint), #fff 60%); position:relative; overflow:hidden}
.auth-wrap::before{
  content:""; position:absolute; right:-8vw; top:50%; transform:translateY(-50%);
  width:42vw; height:46vw; max-width:560px; max-height:620px;
  background:url('/assets/images/bg.svg') no-repeat center/contain;
  opacity:.5; pointer-events:none;
  filter:drop-shadow(0 22px 44px rgba(17,18,20,.2));
}
.auth-card{position:relative; z-index:1}
.auth-card{width:100%; max-width:420px; border:1px solid var(--border); border-radius:var(--r-lg); padding:38px 36px; background:var(--surface); box-shadow:var(--shadow-lg)}
.auth-card .brand{justify-content:center; padding:0 0 6px; border-bottom:0; margin:0}
.auth-card .brand img{height:48px; width:auto}
.auth-head{display:flex; align-items:center; justify-content:center; gap:16px; margin:0 0 26px; padding-bottom:24px; border-bottom:1px solid var(--border)}
.auth-logo{height:58px; width:auto; flex:0 0 auto}
.auth-head-text{text-align:left; line-height:1.2}
.auth-head-text h1{font-size:22px; font-weight:700; margin:0; letter-spacing:-.025em}
.auth-head-text .sub{color:var(--ink-3); margin:4px 0 0; font-size:13px}
.auth-card > h1{font-size:21px; font-weight:700; text-align:center; margin:6px 0 2px; letter-spacing:-.025em}
.auth-card > .sub{text-align:center; color:var(--ink-3); margin:0 0 24px; font-size:13px}
.auth-card .btn{width:100%; justify-content:center; margin-top:24px; padding:11px}

/* ===========================================================================
   Responsive / mobile (≤900px: drawer nav; ≤760px: tighter, stacked)
   =========================================================================== */
@media(max-width:900px){
  /* Sidebar becomes an off-canvas drawer */
  .nav-toggle{display:flex}
  .sidebar{
    position:fixed; top:0; left:0; height:100dvh; width:264px; z-index:40;
    transform:translateX(-100%); transition:transform var(--dur-2) var(--ease);
    box-shadow:var(--shadow-lg); border-right:1px solid var(--border);
  }
  .shell.nav-open .sidebar{transform:translateX(0)}
  .shell.nav-open .nav-overlay{display:block; opacity:1}
  .nav-overlay{display:block; opacity:0; pointer-events:none}
  .shell.nav-open .nav-overlay{pointer-events:auto}
  /* hamburger → X when open */
  .shell.nav-open .nav-toggle span:nth-child(1){transform:translateY(6px) rotate(45deg)}
  .shell.nav-open .nav-toggle span:nth-child(2){opacity:0}
  .shell.nav-open .nav-toggle span:nth-child(3){transform:translateY(-6px) rotate(-45deg)}

  .topbar{padding:10px 14px; gap:12px; margin:12px 12px 0; top:12px; border-radius:var(--r)}
  .topbar h1{font-size:16px; flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
  .topbar .user{gap:12px}
  .topbar .user > span{display:none}              /* hide long "Name · Role" text */
  .content{padding:18px 16px}
  .main::after{display:none}                        /* drop heavy decorative watermark */

  .grid-4{grid-template-columns:repeat(2,1fr)}
}

@media(max-width:760px){
  /* iOS auto-zooms when focusing inputs under 16px — force 16px on touch sizes */
  input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file]),
  select,textarea{font-size:16px}
  .card{max-width:100%}

  /* Any table inside a card scrolls horizontally instead of breaking the layout
     (contacts is excluded — it adapts by hiding columns, so it fits as-is) */
  .card:has(table){overflow-x:auto; -webkit-overflow-scrolling:touch}
  .card:has(table) > table:not(.contacts-table){min-width:520px}
  .col-hide-sm{display:none}                        /* contacts: drop Company + Assigned */

  .card{padding:18px}
  .page-actions{gap:10px}
  .kpi-grid,.gcard-grid{grid-template-columns:repeat(2,1fr)}

  /* Inbox → single pane: list, then chat slides over it */
  .inbox{grid-template-columns:1fr; height:calc(100dvh - 124px)}
  .inbox-side{display:none}
  .inbox-list{border-right:0}
  .inbox-chat{display:none}
  .inbox.show-chat .inbox-list{display:none}
  .inbox.show-chat .inbox-chat{display:flex}
  .chat-back{display:block}
  .bubble{max-width:82%}

  /* Composer must never overflow: let the textarea shrink (buttons keep the
     uniform circular styling from the base rule). */
  .chat-composer{padding:8px 10px; gap:4px}
  .chat-composer textarea{min-width:0; min-height:42px; padding:10px 14px}
  /* keep the chat header from overflowing on narrow screens */
  .chat-head{padding:10px 12px}
  .chat-head-id{min-width:0}
  /* Name truncation is handled by the base rule + flex shrink; no fixed cap. */
}

@media(max-width:560px){
  .grid-4,.kpi-grid,.gcard-grid{grid-template-columns:1fr}
  .topbar h1{font-size:15px}
  .gcard-value{font-size:26px}
  .kpi-value{font-size:23px}
  /* Action bars: let buttons/forms wrap and fill the row */
  .page-actions .flex,.card > .flex,.section-head .flex{flex-wrap:wrap; gap:8px}
  .section-head{flex-wrap:wrap}
  /* Long unbreakable strings (JIDs, tokens, emails) never force sideways scroll */
  td .mono,.card .mono{overflow-wrap:anywhere}
  .chat-legend{gap:16px}

  /* Clean WhatsApp-style composer: one crisp input pill; the icon buttons keep
     their uniform circular styling from the base rule, just tighter spacing. */
  .chat-composer{gap:2px; padding:6px 8px; align-items:flex-end; background:#f0f1ea}
  .chat-composer #composer-attach:active,.chat-composer #composer-mic:active{background:rgba(0,0,0,.06)}
  .chat-composer textarea{margin:0 4px; min-height:40px; max-height:110px; padding:10px 16px; border-radius:21px;
    border:1px solid var(--border-2); background:#fff; box-shadow:0 1px 1px rgba(0,0,0,.04)}
  /* Login/2FA card fits comfortably on the smallest screens */
  .auth-card{padding:26px 20px}
  .auth-head{flex-wrap:wrap; gap:10px; margin-bottom:18px; padding-bottom:16px}
}

/* ===========================================================================
   Reduced motion — disable all entrance/lift animation
   =========================================================================== */
@media (prefers-reduced-motion: reduce){
  *,*::before,*::after{animation-duration:.001ms !important; animation-iteration-count:1 !important; transition-duration:.001ms !important}
  .btn:hover,.stat:hover{transform:none}
}

/* ===========================================================================
   Inbox — per-message sender/seen line + right-side CRM panel
   =========================================================================== */
/* Each message is now a column: the bubble, then a small "by Ali · Seen" line.
   The row owns the left/right alignment the bubble used to own. */
.msg-row{display:flex; flex-direction:column; margin:1px 0}
.msg-row.out{align-items:flex-end}
.msg-row.in{align-items:flex-start}
.msg-info{font-size:10.5px; color:#7c8893; line-height:1.2; margin:1px 4px 3px; user-select:none; letter-spacing:.01em}
.msg-row.out .msg-info{text-align:right}
.msg-info.fail{color:#d9534f; font-weight:600}
.bubble .tick.fail{color:#d9534f; font-weight:700; letter-spacing:0}

/* Right-side contact / CRM panel */
.cp-empty{padding:14px 2px; color:var(--ink-3)}
.cp-profile{text-align:center; padding:2px 0 16px; border-bottom:1px solid var(--border); margin-bottom:16px}
.cp-avatar{width:64px; height:64px; margin:0 auto 10px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:22px; background:linear-gradient(135deg,var(--brand),var(--brand-strong)); color:var(--brand-ink)}
.cp-avatar.group{background:linear-gradient(135deg,var(--ink-2),var(--ink)); color:var(--brand)}
.cp-avatar svg{width:30px; height:30px}
.cp-name{font-size:16px; font-weight:700; color:var(--ink); word-break:break-word}
.cp-sub{font-size:12.5px; color:var(--ink-3); margin-top:2px; word-break:break-word}
.cp-sub:empty{display:none}
.cp-section{margin-bottom:16px}
.cp-label{display:block; font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.05em; color:var(--ink-3); margin-bottom:6px}
.cp-input{width:100%; padding:8px 11px; border:1px solid var(--border-strong); border-radius:var(--r-sm); font-family:inherit; font-size:13px; background:var(--surface); color:var(--ink)}
textarea.cp-input{resize:vertical; min-height:64px; line-height:1.45}
.cp-input:disabled{background:var(--surface-2); color:var(--ink-3); cursor:not-allowed}
.cp-tags{display:flex; flex-wrap:wrap; gap:6px; margin-bottom:8px}
.cp-tag{display:inline-flex; align-items:center; gap:5px; padding:3px 4px 3px 9px; border-radius:20px; font-size:12px; font-weight:600}
.cp-tag-x{border:none; background:rgba(0,0,0,.18); color:inherit; width:15px; height:15px; border-radius:50%; cursor:pointer; font-size:13px; line-height:1; padding:0; display:inline-flex; align-items:center; justify-content:center}
.cp-tag-x:hover{background:rgba(0,0,0,.34)}
.cp-tag-add{display:flex; gap:6px}
.cp-tag-add .cp-input{flex:1 1 auto}
.cp-notes-bar{display:flex; align-items:center; justify-content:space-between; gap:10px; margin-top:8px}
.cp-saved{font-size:12px; color:var(--brand-ink); font-weight:600}
.btn.small{padding:6px 12px; font-size:12.5px}
.cp-facts{border-top:1px solid var(--border); padding-top:14px; display:flex; flex-direction:column; gap:9px}
.cp-fact{display:flex; align-items:center; justify-content:space-between; gap:10px; font-size:12.5px}
.cp-fact span{color:var(--ink-3)}
.cp-fact strong{color:var(--ink); font-weight:600; text-align:right}

/* ===========================================================================
   Role-Specific Dashboard Components
   =========================================================================== */

/* Dashboard Section */
.dash-section{margin-bottom:32px}
.dash-title{font-size:16px; font-weight:600; margin:0 0 16px; letter-spacing:-.02em; color:var(--ink)}
.section-head{display:flex; justify-content:space-between; align-items:center; margin-bottom:16px; flex-wrap:wrap; gap:12px}

/* Insights Banner */
.insights-banner{display:flex; flex-direction:column; gap:12px; margin-bottom:24px}
.insight-card{display:flex; align-items:flex-start; gap:12px; padding:14px 16px; border-radius:var(--r); border:1px solid; animation:slideIn .3s var(--ease)}
.insight-success{background:var(--success-bg); border-color:var(--success-border); color:var(--brand-ink)}
.insight-warning{background:#fff3cd; border-color:#ffc107; color:#856404}
.insight-alert{background:var(--danger-bg); border-color:var(--danger-border); color:#721c24}
.insight-info{background:#e3f2fd; border-color:#90caf9; color:#0d47a1}
.insight-icon{flex:0 0 auto; width:20px; height:20px}
.insight-icon svg{width:100%; height:100%; stroke-width:2.5}
.insight-text{flex:1; font-size:13.5px; font-weight:500; line-height:1.5}
@keyframes slideIn{from{opacity:0; transform:translateY(-10px)} to{opacity:1; transform:translateY(0)}}

/* Metric Grids */
.metric-grid-2{display:grid; grid-template-columns:repeat(2,1fr); gap:18px}
.metric-grid-3{display:grid; grid-template-columns:repeat(3,1fr); gap:18px}
.metric-grid-4{display:grid; grid-template-columns:repeat(4,1fr); gap:18px}

/* Metric Cards */
.metric-card{display:flex; align-items:center; gap:16px; padding:20px; border-radius:var(--r); border:1px solid var(--border); background:var(--surface); transition:transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease)}
.metric-card:hover{transform:translateY(-2px); box-shadow:var(--shadow)}
.metric-icon{width:48px; height:48px; display:flex; align-items:center; justify-content:center; border-radius:10px; flex:0 0 auto}
.metric-icon svg{width:24px; height:24px}
.metric-body{flex:1; min-width:0}
.metric-value{font-size:26px; font-weight:700; font-family:var(--font-mono); line-height:1; margin-bottom:4px; color:var(--ink)}
.metric-label{font-size:12px; font-weight:600; color:var(--ink-3); text-transform:uppercase; letter-spacing:.04em}
.metric-meta{font-size:11.5px; color:var(--ink-4); margin-top:2px}

.metric-lime .metric-icon{background:var(--brand-tint); color:var(--brand-ink)}
.metric-dark .metric-icon{background:var(--surface-2); color:var(--ink-2)}
.metric-danger .metric-icon{background:var(--danger-bg); color:var(--danger)}

/* Stat Cards */
.stat-card{text-align:center; padding:20px; border-radius:var(--r); background:var(--surface-2); border:1px solid var(--border)}
.stat-icon{width:36px; height:36px; margin:0 auto 12px; display:flex; align-items:center; justify-content:center; border-radius:8px; background:var(--brand-tint)}
.stat-icon svg{width:20px; height:20px; stroke:var(--brand-ink)}
.stat-value{font-size:28px; font-weight:700; font-family:var(--font-mono); color:var(--ink); line-height:1; margin-bottom:6px}
.stat-label{font-size:12px; font-weight:600; color:var(--ink-3); text-transform:uppercase; letter-spacing:.04em}

/* Trend Cards */
.trend-card{padding:18px; border-radius:var(--r); border:1px solid var(--border); background:var(--surface); transition:all var(--dur) var(--ease)}
.trend-card:hover{border-color:var(--border-2); box-shadow:var(--shadow-sm)}
.trend-header{display:flex; justify-content:space-between; align-items:center; margin-bottom:12px}
.trend-label{font-size:12px; font-weight:600; color:var(--ink-3); text-transform:uppercase; letter-spacing:.04em}
.trend-icon{width:28px; height:28px; border-radius:6px; display:flex; align-items:center; justify-content:center}
.trend-icon svg{width:18px; height:18px}
.trend-up{background:#e8f5e9; color:#2e7d32}
.trend-down{background:#ffebee; color:#c62828}
.trend-value{font-size:30px; font-weight:700; font-family:var(--font-mono); color:var(--ink); line-height:1; margin-bottom:8px}
.trend-change{font-size:12.5px; font-weight:600; margin-top:4px}
.trend-change.positive{color:#2e7d32}
.trend-change.negative{color:#c62828}
.trend-meta{font-size:12px; color:var(--ink-4); margin-top:4px}

/* Data Table */
.data-table{width:100%; border-collapse:collapse}
.data-table thead{background:var(--surface-2); border-bottom:2px solid var(--border-strong)}
.data-table th{padding:12px 16px; text-align:left; font-size:11.5px; font-weight:700; color:var(--ink-2); text-transform:uppercase; letter-spacing:.06em}
.data-table th.text-center{text-align:center}
.data-table td{padding:14px 16px; border-bottom:1px solid var(--border); color:var(--ink-2)}
.data-table td.text-center{text-align:center}
.data-table tbody tr:hover{background:var(--surface-2)}

/* Agent Cell */
.agent-cell{display:flex; align-items:center; gap:10px}
.rank-badge{width:26px; height:26px; border-radius:50%; display:flex; align-items:center; justify-content:center; background:var(--brand); flex:0 0 auto}
.rank-badge svg{width:14px; height:14px; stroke:#13160a}
.rank-gold{background:linear-gradient(135deg, #ffd700, #ffed4e)}
.rank-number{width:26px; height:26px; border-radius:50%; background:var(--surface-2); display:flex; align-items:center; justify-content:center; font-size:12px; font-weight:700; color:var(--ink-3); flex:0 0 auto}

/* Performance Bar */
.perf-bar{position:relative; width:100px; height:8px; background:var(--surface-2); border-radius:4px; overflow:hidden}
.perf-fill{height:100%; background:linear-gradient(90deg, var(--brand-strong), var(--brand)); border-radius:4px; transition:width .6s var(--ease)}

/* Pipeline Funnel */
.pipeline-funnel{display:flex; flex-direction:column; gap:10px; padding:8px 0}
.pipeline-stage{width:100%}
.pipeline-bar{min-height:48px; border-radius:8px; padding:12px 16px; display:flex; align-items:center; transition:all .3s var(--ease); border:1px solid rgba(0,0,0,.08)}
.pipeline-bar:hover{transform:translateX(4px); box-shadow:var(--shadow-sm)}
.pipeline-info{display:flex; justify-content:space-between; width:100%}
.pipeline-name{font-size:13.5px; font-weight:600; color:rgba(0,0,0,.75)}
.pipeline-count{font-size:16px; font-weight:700; font-family:var(--font-mono); color:rgba(0,0,0,.85)}

/* Conversion Badge */
.conversion-badge{display:inline-flex; align-items:center; gap:6px; padding:6px 12px; background:var(--brand-tint); border:1px solid var(--brand-soft); border-radius:8px}
.conversion-label{font-size:11.5px; font-weight:600; color:var(--brand-ink); text-transform:uppercase; letter-spacing:.04em}
.conversion-value{font-size:16px; font-weight:700; font-family:var(--font-mono); color:var(--brand-ink)}

/* Activity List */
.activity-list{display:flex; flex-direction:column; gap:0}
.activity-item{display:flex; gap:14px; padding:14px 16px; border-bottom:1px solid var(--border); transition:background var(--dur) var(--ease)}
.activity-item:last-child{border-bottom:none}
.activity-item:hover{background:var(--surface-2)}
.activity-dot{width:8px; height:8px; border-radius:50%; background:var(--brand-strong); margin-top:7px; flex:0 0 auto}
.activity-content{flex:1; min-width:0}
.activity-text{font-size:13.5px; color:var(--ink-2); margin-bottom:4px; line-height:1.5}
.activity-text strong{color:var(--ink); font-weight:600}
.activity-time{font-size:11.5px; color:var(--ink-4); font-family:var(--font-mono)}

/* Target Cards */
.target-card{text-align:center; padding:24px}
.target-header{display:flex; align-items:center; justify-content:center; gap:8px; margin-bottom:20px}
.target-icon{width:32px; height:32px; border-radius:8px; background:var(--brand-tint); display:flex; align-items:center; justify-content:center}
.target-icon svg{width:18px; height:18px; stroke:var(--brand-ink)}
.target-title{font-size:14px; font-weight:600; color:var(--ink-2); text-transform:uppercase; letter-spacing:.04em}
.target-progress{margin:0 auto 20px; width:fit-content}

/* Progress Ring */
.progress-ring{position:relative; width:120px; height:120px}
.progress-text{position:absolute; top:50%; left:50%; transform:translate(-50%, -50%); text-align:center}
.progress-value{font-size:30px; font-weight:700; font-family:var(--font-mono); color:var(--ink); line-height:1}
.progress-label{font-size:11px; color:var(--ink-4); margin-top:4px}

.target-status{font-size:13px; font-weight:600; padding:8px 14px; border-radius:8px; display:inline-block}
.status-complete{background:var(--success-bg); color:var(--success); border:1px solid var(--success-border)}
.status-pending{background:var(--surface-2); color:var(--ink-3); border:1px solid var(--border)}

/* Workload Cards */
.workload-card{text-align:center; padding:20px; border-radius:var(--r); background:var(--surface-2); border:1px solid var(--border); transition:all var(--dur) var(--ease)}
.workload-card:hover{border-color:var(--border-2); transform:translateY(-2px)}
.workload-number{font-size:34px; font-weight:700; font-family:var(--font-mono); color:var(--ink); line-height:1; margin-bottom:8px}
.workload-label{font-size:12px; font-weight:600; color:var(--ink-3); text-transform:uppercase; letter-spacing:.04em}
.workload-alert{background:#fff3cd; border-color:#ffc107}
.workload-alert .workload-number{color:#856404}
.workload-success{background:var(--success-bg); border-color:var(--success-border)}
.workload-success .workload-number{color:var(--success)}

/* Conversation List */
.conversation-list{display:flex; flex-direction:column; gap:0}
.conv-item{display:flex; align-items:center; gap:14px; padding:14px 16px; border-bottom:1px solid var(--border); transition:background var(--dur) var(--ease)}
.conv-item:last-child{border-bottom:none}
.conv-item:hover{background:var(--surface-2)}
.conv-avatar{width:44px; height:44px; border-radius:50%; background:var(--brand); color:#13160a; display:flex; align-items:center; justify-content:center; font-size:16px; font-weight:700; flex:0 0 auto}
.conv-details{flex:1; min-width:0}
.conv-name{font-size:14px; font-weight:600; color:var(--ink); margin-bottom:2px}
.conv-phone{font-size:12px; color:var(--ink-3); font-family:var(--font-mono)}
.conv-status{text-align:right; flex:0 0 auto}
.conv-badge{display:inline-flex; align-items:center; justify-content:center; min-width:22px; height:22px; padding:0 7px; background:var(--brand); color:#13160a; font-size:11px; font-weight:700; border-radius:11px; font-family:var(--font-mono); margin-bottom:4px}
.conv-time{font-size:11px; color:var(--ink-4); font-family:var(--font-mono)}

/* Responsive */
@media(max-width:900px){
  .metric-grid-4{grid-template-columns:repeat(2,1fr)}
  .metric-grid-3{grid-template-columns:repeat(2,1fr)}
}
@media(max-width:600px){
  .metric-grid-4,.metric-grid-3,.metric-grid-2{grid-template-columns:1fr}
  .insights-banner{margin-bottom:16px}
  .dash-section{margin-bottom:24px}
}
