/* App styles — colours and sizes live in these variables; change them here to restyle the app.
   The brand colours (--brand, --teal …) are set from the environment (src/brand.js) and override the first block.
   Dark mode = the second block (html[data-theme="dark"]), switched in js/theme.js. */
:root {
  color-scheme: light;
  --brand: #3b4cca;          /* brand colour: active menu item, selected chips, main buttons */
  --brand-hover: #2f3da6;
  --brand-text: #3b4cca;     /* brand colour as text (titles, the product name) */
  --teal: #14a38b;           /* accent colour */
  --teal-light: #a6d4e8;     /* teal on navy */
  --navy: var(--brand);
  --blue: var(--brand);      /* main buttons, unread badges */
  --blue-hover: var(--brand-hover);
  --blue-soft: #e6edf8;      /* focus ring, open chat */
  --accent-text: #3b4cca;    /* links, counters, unread times */
  --focus: #14a38b;
  --amber: #f5b301;
  --bg: #f3f5f9;
  --panel: #ffffff;
  --surface: #ffffff;        /* buttons, inputs, chips */
  --hover: #f3f6fa;
  --hover-2: #e8edf4;
  --line: #e2e7ef;
  --line-2: #c5cfdd;
  --line-soft: #edf0f4;
  --head-bg: #f7f9fc;        /* table headers */
  --text: #1a1a2e;
  --text-2: #3d4455;
  --muted: #667085;
  --muted-2: #98a1b2;
  --preview: #4f5666;        /* last-message line in the chat list */
  --side: #f5f7fb;           /* left menu */
  --side-hover: #e7ecf4;
  --side-text: #3d4455;
  --convo-bg: #f4f6fa;       /* behind the messages */
  --bubble-in: #ffffff;
  --bubble-in-line: #e5e9f0;
  --bubble-out: #e6eef9;     /* our messages: light tint of the brand colour */
  --bubble-out-line: #d2def1;
  --day-sep-bg: #e3e8f0;
  --quote-bg: rgba(15, 23, 42, .05);
  --sel-bg: #eaf0fa; --sel-hover: #dde7f6; --sel-line: #c3d2ec; --sel-text: #3b4cca;
  --unread-bg: #f3f7fd;
  --ok-bg: #dcfce7; --ok-text: #166534;
  --warn-bg: #fef9c3; --warn-text: #854d0e;
  --danger-bg: #fef2f2; --danger-bg2: #fee2e2; --danger-text: #b91c1c; --danger-line: #fecaca;
  --info-bg: #e0f2fe; --info-text: #0369a1;
  --note-bg: #fffbeb; --note-bg2: #fef3c7; --note-line: #fde68a; --note-line2: #fcd34d; --note-text: #92400e;
  --cf-bg: #f5f3ff; --cf-line: #ddd6fe; --cf-text: #4c1d95; --cf-count: #6d28d9;
  --mention-bg: #dbeafe; --mention-text: #1e40af;
  --shadow: rgba(15, 23, 42, .18);
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 10px;
  --green: #16a34a;
  --rail-w: 236px;      /* left menu width */
  --list-w: 380px;      /* chat list width while a chat is open */
  /* Arabic falls through to the computer's own font (Segoe UI on Windows) */
  --font: 'Source Sans 3', 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans Arabic', sans-serif;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --brand: #2b54ac;
  --brand-hover: #3462c4;
  --brand-text: #dfe7f7;
  --teal: #4f9dbe;
  --teal-light: #a6d4e8;
  --blue-soft: rgba(79, 157, 190, .22);
  --accent-text: #8cc2df;
  --focus: #4f9dbe;
  --bg: #0d1422;
  --panel: #131c2c;
  --surface: #182233;
  --hover: #1a2537;
  --hover-2: #223047;
  --line: #263248;
  --line-2: #3a4864;
  --line-soft: #1c2638;
  --head-bg: #172133;
  --text: #e6eaf2;
  --text-2: #c3cad8;
  --muted: #8f9bb0;
  --muted-2: #6c7890;
  --preview: #aab4c5;
  --side: #0f1726;
  --side-hover: #1b2639;
  --side-text: #c3cad8;
  --convo-bg: #0b111c;
  --bubble-in: #1a2435;
  --bubble-in-line: #26334a;
  --bubble-out: #1d3461;
  --bubble-out-line: #2a4579;
  --day-sep-bg: #1d2839;
  --quote-bg: rgba(255, 255, 255, .06);
  --sel-bg: #1b2b48; --sel-hover: #213559; --sel-line: #2f4a7a; --sel-text: #b9cdf0;
  --unread-bg: #162238;
  --ok-bg: rgba(34, 197, 94, .16); --ok-text: #86efac;
  --warn-bg: rgba(234, 179, 8, .16); --warn-text: #fde047;
  --danger-bg: rgba(239, 68, 68, .12); --danger-bg2: rgba(239, 68, 68, .2); --danger-text: #fca5a5; --danger-line: rgba(239, 68, 68, .35);
  --info-bg: rgba(56, 189, 248, .15); --info-text: #7dd3fc;
  --note-bg: rgba(245, 158, 11, .1); --note-bg2: rgba(245, 158, 11, .17); --note-line: rgba(245, 158, 11, .3); --note-line2: rgba(245, 158, 11, .42); --note-text: #fcd34d;
  --cf-bg: rgba(139, 92, 246, .14); --cf-line: rgba(139, 92, 246, .38); --cf-text: #c4b5fd; --cf-count: #c4b5fd;
  --mention-bg: rgba(96, 165, 250, .2); --mention-text: #bfdbfe;
  --shadow: rgba(0, 0, 0, .5);
  --danger: #ef4444;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* touch screens: no grey flash on tap, no double-tap zoom delay */
button, a, label, select, .chat-item, .chip, .num-pill, .ms-item { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
/* scrolling a list to its end doesn't pull the whole page (or reload it on Android) */
.chat-list, .messages, .info-body, .page, .np-list, .menu, .ql-list { overscroll-behavior: contain; }
body { font: 15px/1.45 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); min-height: 1em; margin: 4px 0; }
.row { display: flex; align-items: center; justify-content: space-between; }
.row.gap { gap: 8px; justify-content: flex-start; }
.row.end { justify-content: flex-end; }
[dir="auto"] { unicode-bidi: plaintext; }

/* buttons & inputs */
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--line-2); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-hover); border-color: var(--blue-hover); }
.btn.danger { color: var(--danger); }
.btn.primary.small, .btn.small { font-size: 13.5px; }
.btn.small { padding: 5px 10px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 18px; width: 36px; height: 36px; border-radius: 8px; display: inline-grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--bg); }
input, select, textarea { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--surface); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 3px var(--blue-soft); }
select { cursor: pointer; }

/* brand: the product logo */
.brand-logo { width: 38px; height: 38px; flex: none; display: block; }
.empty-logo { display: block; margin: 0 auto 12px; opacity: .9; }
.home-mini { display: none; flex: none; }
.home-mini img { display: block; width: 34px; height: 34px; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; background: linear-gradient(135deg, var(--brand) 0%, var(--brand-hover) 55%, var(--teal) 140%); padding: 16px; }
html[data-theme="dark"] .login { background: linear-gradient(135deg, #0b1424 0%, #12224a 60%, #173a52 100%); }
.login-card { background: var(--panel); box-shadow: 0 24px 60px rgba(0, 0, 0, .25); width: 100%; max-width: 360px; border-radius: 16px; padding: 32px 28px; display: grid; gap: 12px; text-align: center; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-logo { display: block; margin: 0 auto 2px; }
.login-word { font-size: 20px; letter-spacing: .02em; color: var(--brand-text); margin-bottom: 2px; }
.login-word b { font-weight: 700; }
.login-card label { display: grid; gap: 4px; text-align: start; font-weight: 500; font-size: 13px; }

/* layout */
.app { display: flex; height: 100vh; height: 100dvh; height: var(--app-h, 100dvh); } /* --app-h: phones, set in app.js */
/* left menu: the functions with names */
.rail { width: var(--rail-w); background: var(--side); border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; padding-block: 16px 10px; padding-inline: 0 12px; flex: none; overflow-y: auto; overflow-x: hidden; }
.rail-brand { display: flex; align-items: center; gap: 10px; padding-block: 0 18px; padding-inline: 18px 0; text-decoration: none; color: inherit; border-start-start-radius: 0; border-start-end-radius: 10px; border-end-end-radius: 10px; border-end-start-radius: 0; flex: none; }
.rail-brand:hover .brand-name { color: var(--teal); }
.rail-brand:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.brand-name { font-size: 15px; letter-spacing: .01em; color: var(--brand-text); white-space: nowrap; transition: color .15s; }
.brand-name b { font-weight: 700; }
.rail-btn { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: transparent; color: var(--side-text); cursor: pointer; border-start-start-radius: 0; border-start-end-radius: 10px; border-end-end-radius: 10px; border-end-start-radius: 0; padding-block: 10px 10px; padding-inline: 22px 12px; font-size: 15px; font-weight: 500; text-align: start; white-space: nowrap; flex: none; }
.rail-btn svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rail-btn:hover { background: var(--side-hover); color: var(--text); }
.rail-btn.active { background: var(--navy); color: #fff; }
.rail-btn.active::before { content: ''; position: absolute; inset-inline-start: 0; top: 7px; bottom: 7px; width: 3px; border-start-start-radius: 0; border-start-end-radius: 3px; border-end-end-radius: 3px; border-end-start-radius: 0; background: var(--teal); }
.rail-sep { padding-block: 16px 4px; padding-inline: 22px 0; font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted-2); flex: none; }
.rail-spacer { flex: 1; min-height: 12px; }
.rail-me { margin-top: 4px; padding-block: 9px 9px; padding-inline: 18px 12px; }
.rail-me .avatar.small { width: 30px; height: 30px; font-size: 12px; }
.me-text { display: grid; min-width: 0; line-height: 1.25; }
.me-text b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.me-text small { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.rail-me.active .me-text small { color: #cbd5e1; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); margin-inline-start: auto; flex: none; }
.conn-dot.on { background: #22c55e; }
.view { flex: 1; min-width: 0; }
/* dark mode button in the left menu (shows the moon in light mode, the sun in dark mode) */
.theme-btn .i-sun { display: none; }
.theme-btn.is-dark .i-sun { display: block; }
.theme-btn.is-dark .i-moon { display: none; }
.appearance { margin: 18px 0 8px; display: grid; gap: 8px; justify-items: start; }
.appearance h3 { margin: 0; }

/* inbox columns */
.inbox { display: flex; height: 100%; }
/* no chat open: the chat list fills the screen; a chat open: list on the left, conversation on the right */
.list-pane { flex: 1; min-width: 0; background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.inbox.chat-open .list-pane { flex: none; width: var(--list-w); border-inline-end: 1px solid var(--line); }
.inbox:not(.chat-open) .convo-pane, .inbox:not(.chat-open) .info-pane { display: none; }
.list-head { padding: 14px 20px 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; border-bottom: 1px solid var(--line); }
.list-head > * { min-width: 0; }
.inbox.chat-open .list-head { padding: 12px 12px 0; gap: 8px; }
.topbar { display: flex; align-items: center; gap: 10px; }
.search-box { flex: 1; max-width: 620px; display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: text; }
.search-box:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px var(--blue-soft); }
.search-box svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex: none; }
#search { border: 0; box-shadow: none; padding: 0; height: 100%; flex: 1; min-width: 0; width: 100%; background: transparent; }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; height: 42px; padding: 0 18px; border-radius: 10px; margin-inline-start: auto; }
.btn.green:hover { background: #15803d; border-color: #15803d; }
.inbox.chat-open .btn.green { padding: 0; width: 42px; font-size: 20px; }
.inbox.chat-open .btn.green span { display: none; }
.list-head select { flex: 1; min-width: 0; padding-block: 6px 6px; padding-inline: 7px 4px; font-size: 14px; }
/* Select chats + "Actions with selected", then the filters that are on (each with ✕) */
.toolbar { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; padding: 0 0 10px; }
.sel-tools { display: flex; align-items: center; gap: 6px; flex: none; }
.sel-btn { display: inline-flex; align-items: center; gap: 8px; height: 32px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding-block: 0 0; padding-inline: 9px 12px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--brand-text); white-space: nowrap; }
.sel-btn:hover { border-color: var(--line-2); }
.sel-btn.on { background: var(--sel-bg); border-color: var(--sel-line); }
#bulkBtn { height: 32px; background: var(--navy); border-color: var(--navy); color: #fff; }
#bulkBtn:disabled { background: var(--surface); color: var(--muted); border-color: var(--line); }
#bulkBtn .caret { font-size: 11px; margin-inline-start: 2px; }
.inbox.chat-open .toolbar { padding-bottom: 8px; gap: 6px; }
.af-row { flex: 1 1 0; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.af-row:empty { display: none; }
.af-chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; max-width: 100%; padding-block: 0 0; padding-inline: 11px 5px; border: 1px solid var(--sel-line); background: var(--sel-bg); color: var(--sel-text); border-radius: 999px; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; overflow: hidden; }
.af-chip:hover { background: var(--sel-hover); }
.af-chip .agent-dot { width: 20px; height: 20px; font-size: 8.5px; margin-inline-start: -5px; }
.af-x { width: 20px; height: 20px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 10px; color: var(--muted); }
.af-chip:hover .af-x { background: var(--panel); color: var(--danger); }
.af-clear { border: 0; background: transparent; color: var(--muted); font-size: 13.5px; padding: 4px 6px; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.af-clear:hover { color: var(--text); }
.sw { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.sw.sq { border-radius: 3px; width: 10px; height: 10px; }
/* the Filters button above the list: phones only (computers have "Filters" in the left menu) */
.f-inline { display: none; }
.f-inline svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.f-inline b { background: var(--teal); color: #fff; border-radius: 999px; font-size: 11px; min-width: 18px; height: 18px; padding: 0 5px; display: inline-grid; place-items: center; }
.f-inline.on { background: var(--sel-bg); border-color: var(--sel-line); }

/* FILTERS PANEL (left of the chat list). Docked = part of the layout; .fp-float = floating over the list */
.filter-pane { display: none; width: 264px; flex: none; flex-direction: column; min-height: 0; background: var(--side); border-inline-end: 1px solid var(--line); }
.inbox.fp-open .filter-pane { display: flex; }
.inbox.fp-float { position: relative; }
.inbox.fp-float .filter-pane { position: absolute; inset-inline-start: 0; top: 0; bottom: 0; z-index: 16; width: 300px; background: var(--panel); box-shadow: 10px 0 34px var(--shadow); animation: fp-in .14s ease-out; }
@keyframes fp-in { from { transform: translateX(-14px); opacity: 0; } }
.fp-backdrop { display: none; }
.fp-head { display: flex; align-items: center; gap: 6px; padding-block: 12px 10px; padding-inline: 18px 8px; border-bottom: 1px solid var(--line); min-height: 64px; }
.fp-head h3 { margin: 0; font-size: 17px; font-weight: 600; flex: 1; color: var(--brand-text); }
.fp-head .icon-btn { font-size: 15px; color: var(--muted); }
.fp-head .icon-btn:hover { color: var(--text); background: var(--side-hover); }
.fp-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px 10px 18px; }
.fp-foot { display: none; }
.fp-sec { padding: 16px 10px 5px; font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted-2); }
.qf, .filter-pane .number-strip, .filter-pane .cf-row { display: flex; flex-direction: column; gap: 1px; }
/* each filter is one row: name on the left, count on the right */
.filter-pane .chip, .filter-pane .num-pill { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 36px; padding: 6px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--side-text); font-size: 15px; font-weight: 500; text-align: start; white-space: nowrap; opacity: 1; }
.filter-pane .chip:not(.active):hover, .filter-pane .num-pill:not(.active):hover { background: var(--side-hover); color: var(--text); }
.inbox.fp-float .filter-pane .chip:not(.active):hover, .inbox.fp-float .filter-pane .num-pill:not(.active):hover { background: var(--hover-2); }
.filter-pane .chip.active, .filter-pane .num-pill.active { background: var(--navy); color: #fff; }
.filter-pane .chip b, .filter-pane .num-pill b:first-of-type { margin-inline-start: auto; }
.filter-pane .chip b { font-size: 13px; color: var(--muted); }
.filter-pane .chip.active b { color: var(--teal-light); }
.filter-pane .num-pill i { width: 9px; height: 9px; }
.filter-pane .num-pill:not(:has(i))::before { content: ''; width: 9px; flex: none; } /* "All numbers" lines up with the others */
.filter-pane .num-pill.bad { color: var(--muted); }
.filter-pane .num-pill.bad::after { order: 3; }
.filter-pane .chip.missed.active { background: #991b1b; }
.filter-pane .chip[data-f="deleted"].active { background: #3f3f46; }
.fp-select { width: 100%; margin: 4px 0 0; font-size: 14.5px; padding: 7px 8px; }
.filter-pane .cf-row .chip.cf { background: transparent; color: var(--cf-text); }
.filter-pane .cf-row .chip.cf b { color: var(--cf-count); }
.filter-pane .cf-row .chip.cf:not(.active):hover { background: var(--cf-bg); }
.filter-pane .cf-row .chip.cf.active { background: #4c1d95; color: #fff; }
.filter-pane .cf-row .chip.cf.active b { color: #ddd6fe; }
.filter-pane .cf-row .chip.cf-add { margin-top: 4px; border: 1px dashed var(--line-2); color: var(--accent-text); justify-content: center; }
.filter-pane .chip > *:not(b), .filter-pane .num-pill { overflow: hidden; text-overflow: ellipsis; }
/* while a custom filter is on, the other filters are paused */
.filter-pane.cf-on .qf, .filter-pane.cf-on .number-strip, .filter-pane.cf-on .fp-select { opacity: .45; }
/* the Filters item in the left menu: lit while the panel is open; the badge = how many filters are on */
.rail-btn.fp-btn.on { background: var(--side-hover); color: var(--text); }
.rail-badge.info { background: var(--teal); }
.sel-banner { background: var(--sel-bg); color: var(--sel-text); font-size: 14px; padding: 7px 12px; border-radius: 8px; margin: -2px 0 10px; text-align: center; }
/* tick boxes */
.cbox { width: 18px; height: 18px; border: 1.8px solid var(--muted-2); border-radius: 5px; background: var(--surface); display: inline-grid; place-items: center; flex: none; transition: background .1s, border-color .1s; }
.cbox.on, .cbox.part, .chat-item.selected .cbox { background: var(--navy); border-color: var(--navy); }
.cbox.on::after, .chat-item.selected .cbox::after { content: ''; width: 9px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.cbox.part::after { content: ''; width: 8px; height: 2px; border-radius: 1px; background: #fff; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 11px; font-size: 14px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.chip:hover { border-color: var(--line-2); }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip b { font-size: 12px; font-weight: 600; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.chip b:empty { display: none; }
.chip.active b { color: var(--teal-light); }
/* missed calls: red counter */
.chip.missed b { background: var(--danger); color: #fff; border-radius: 999px; min-width: 18px; height: 18px; padding: 0 5px; display: inline-grid; place-items: center; font-size: 10.5px; }
.chip.missed b:empty { display: none; }
.chip.missed.active { background: #991b1b; border-color: #991b1b; }
.chip.missed.active b { background: #fff; color: #991b1b; }
.num-pill b.mc { background: var(--danger); color: #fff; }
.tag.missed { background: var(--danger-bg2); color: var(--danger-text); font-weight: 600; }
.nr-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 14px; background: var(--info-bg); color: var(--info-text); border-bottom: 1px solid var(--line); font-size: 14px; }
.call-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 14px; background: var(--danger-bg); color: var(--danger-text); border-bottom: 1px solid var(--danger-line); font-size: 14px; }
.msg.call { align-self: center; background: var(--danger-bg); border: 1px solid var(--danger-line); box-shadow: none; }
.msg.call .call-line { color: var(--danger-text); font-weight: 600; }
.msg.call .meta { justify-content: center; }
.msg.unreadable { border-style: dashed; opacity: .9; }
.msg.unreadable .unreadable-line { font-size: 13.5px; color: var(--muted, #667); }
.msg .meta .by.src { font-style: italic; }
.number-strip { display: flex; gap: 6px; flex-wrap: wrap; }
.number-strip:empty { display: none; }
.num-pill { font-size: 13.5px; border-radius: 999px; padding: 4px 10px; background: var(--bg); display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); cursor: pointer; font-weight: 500; }
.num-pill:hover { border-color: var(--line-2); }
.num-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.num-pill.bad { opacity: .75; }
.num-pill.bad::after { content: '⚠'; font-size: 11px; color: var(--danger); }
.num-pill b { background: var(--blue); color: #fff; border-radius: 999px; font-size: 10.5px; min-width: 18px; height: 18px; padding: 0 5px; display: inline-grid; place-items: center; }
.num-pill.active { background: var(--navy); color: #fff; border-color: var(--navy); opacity: 1; }
.num-pill.active b { background: var(--teal); color: #fff; }
.chat-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.chat-list.selecting { user-select: none; }
.chat-item { display: flex; align-items: flex-start; gap: 12px; padding-block: 12px 12px; padding-inline: 20px 14px; cursor: pointer; border-bottom: 1px solid var(--line-soft); position: relative; }
.inbox.chat-open .chat-item { gap: 10px; padding-block: 10px 10px; padding-inline: 14px 8px; }
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--blue-soft); }
.chat-item.selected { background: var(--sel-bg); }
.chat-item.selected:hover { background: var(--sel-hover); }
.chat-item .stripe { position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 3px; }
/* the round picture turns into a tick box on hover and in Select mode */
.ci-pick { position: relative; width: 40px; height: 40px; flex: none; display: grid; place-items: center; }
.ci-pick .avatar { transition: opacity .1s; }
.ci-pick .cbox { position: absolute; inset: 0; margin: auto; width: 22px; height: 22px; opacity: 0; pointer-events: none; }
@media (hover: hover) {
  .ci-pick:hover .avatar { opacity: 0; }
  .ci-pick:hover .cbox { opacity: 1; }
}
.chat-list.selecting .ci-pick .avatar { opacity: 0; }
.chat-list.selecting .ci-pick .cbox { opacity: 1; }
.chat-main { flex: 1; min-width: 0; }
.chat-top, .chat-bottom { display: flex; align-items: center; gap: 6px; }
.chat-name, .chat-preview, .convo-title .name { text-align: start; }
.chat-name { font-weight: 600; font-size: 15.5px; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox:not(.chat-open) .chat-name { font-size: 16px; }
.chat-time { font-size: 12.5px; color: var(--muted); flex: none; }
.chat-item.unread .chat-time { color: var(--accent-text); font-weight: 600; }
.chat-preview { flex: 1; min-width: 0; color: var(--preview); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; line-height: 1.4; }
.inbox:not(.chat-open) .chat-preview { font-size: 14.5px; }
.chat-top + .chat-bottom { margin-top: 2px; }
.chat-item.unread .chat-preview { color: var(--text); font-weight: 500; }
.badge { background: var(--blue); color: #fff; border-radius: 999px; font-size: 12px; font-weight: 600; min-width: 21px; height: 21px; padding: 0 6px; display: inline-grid; place-items: center; flex: none; }
/* who the chat is assigned to: a text line on the big list, a round badge in the narrow list */
.chat-resp { display: flex; align-items: center; gap: 5px; font-size: 13.5px; color: var(--muted); margin-top: 3px; }
.chat-resp b { font-weight: 600; color: var(--text-2); }
.chat-resp .agent-dot { width: 20px; height: 20px; font-size: 9px; }
.inbox.chat-open .chat-resp { display: none; }
.inbox:not(.chat-open) .chat-bottom .agent-dot { display: none; }
/* the ⋯ button on each chat */
.row-menu { flex: none; width: 32px; height: 32px; margin-block: -5px 0; margin-inline: 0 -2px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; display: grid; place-items: center; color: var(--muted-2); }
.row-menu svg { width: 18px; height: 18px; fill: currentColor; }
.row-menu:hover, .row-menu.open { background: var(--hover-2); color: var(--text); }
.inbox.chat-open .row-menu { width: 26px; height: 28px; margin-inline-end: 0; }
.chat-meta { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; align-items: center; }
.tag { font-size: 12px; border-radius: 4px; padding: 1px 7px; color: #fff; line-height: 17px; white-space: nowrap; }
.tag.num { background: var(--bg); color: var(--muted); }
.tag.who { background: transparent; color: var(--muted); border: 1px solid var(--line); }
/* assigned team member: round badge with initials */
.agent-dot { --c: var(--muted); width: 24px; height: 24px; border-radius: 50%; flex: none; display: inline-grid; place-items: center; font-size: 10px; font-weight: 600; letter-spacing: .02em;
  color: var(--c); background: color-mix(in srgb, var(--c) 12%, var(--panel)); border: 1.5px solid color-mix(in srgb, var(--c) 45%, var(--panel)); }
html[data-theme="dark"] .agent-dot:not(.me) { color: color-mix(in srgb, var(--c) 55%, #fff); }
.agent-dot.me { background: var(--c); color: #fff; border-color: var(--c); }
.agent-dot.big { width: 34px; height: 34px; font-size: 12.5px; }
.agent-dot.phone { --c: #64748b; font-size: 15px; }
/* team bar under the chat list: who is online */
.team-bar { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; padding: 8px 10px; border-top: 1px solid var(--line); background: var(--panel); }
.team-bar:empty { display: none; }
.tb-person { position: relative; display: inline-grid; cursor: default; }
.tb-person .agent-dot { width: 30px; height: 30px; font-size: 11px; }
.tb-person i { position: absolute; inset-inline-end: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--panel); background: #475569; }
.tb-person.active i { background: #22c55e; }
.tb-person.idle i { background: #eab308; }
.tb-person.offline .agent-dot { opacity: .55; }
/* numbers page: unread + mark as read */
.card .unread-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; background: var(--bg); border-radius: 8px; padding-block: 6px 6px; padding-inline: 10px 6px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: #cbd5e1; color: #fff; display: grid; place-items: center; font-weight: 600; flex: none; font-size: 15px; }
.avatar.small { width: 32px; height: 32px; font-size: 13px; background: var(--teal); color: #fff; }
.empty { color: var(--muted); text-align: center; padding: 30px; }
.empty.big { margin: auto; }

/* conversation */
.convo-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--convo-bg); }
.convo { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.convo-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.convo-title { flex: 1; min-width: 0; }
.convo-title .name { font-weight: 600; font-size: 16.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo-title .sub { font-size: 13px; color: var(--muted); }
.convo-head select { max-width: 170px; font-size: 14px; padding: 6px 8px; }
.back-btn { font-size: 28px; }
/* "Assigned to": a dropdown on computers; on phones a round button with initials (see the phone section) */
.assign-wrap { display: contents; }
.assign-face { display: none; }
.more-btn { display: none; }
.messages { flex: 1; overflow-y: auto; padding: 16px 6%; display: flex; flex-direction: column; gap: 6px; }
.day-sep { align-self: center; background: var(--day-sep-bg); color: var(--text-2); font-size: 12.5px; font-weight: 500; padding: 3px 10px; border-radius: 999px; margin: 10px 0 6px; }
.load-older { align-self: center; margin-bottom: 6px; }
.msg { max-width: min(600px, 78%); align-self: flex-start; background: var(--bubble-in); border: 1px solid var(--bubble-in-line); border-start-start-radius: 14px; border-start-end-radius: 14px; border-end-end-radius: 14px; border-end-start-radius: 5px; padding: 8px 12px 6px; font-size: 15px; line-height: 1.5; color: var(--text); box-shadow: 0 1px 1px rgba(16, 24, 40, .04); position: relative; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.out { align-self: flex-end; background: var(--bubble-out); border-color: var(--bubble-out-line); border-start-start-radius: 14px; border-start-end-radius: 14px; border-end-end-radius: 5px; border-end-start-radius: 14px; }
.msg .text { white-space: pre-wrap; }
.msg .meta { display: flex; justify-content: flex-end; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 2px; }
.msg .by { color: var(--accent-text); font-weight: 600; }
.msg .ticks.read { color: #0ea5e9; }
.msg .ticks.err { color: var(--danger); }
.msg.deleted .text { font-style: italic; color: var(--muted); }
.msg .quote { border-inline-start: 3px solid var(--teal); background: var(--quote-bg); border-radius: 6px; padding: 4px 8px; font-size: 13.5px; color: var(--text-2); margin-bottom: 4px; max-height: 60px; overflow: hidden; }
.msg .reaction { position: absolute; bottom: -12px; inset-inline-end: 8px; background: var(--panel); border-radius: 999px; padding: 0 5px; font-size: 13px; box-shadow: 0 1px 2px rgba(0, 0, 0, .15); }
.msg.has-reaction { margin-bottom: 12px; }
.msg img.media { display: block; max-width: 100%; max-height: 340px; border-radius: 6px; cursor: zoom-in; background: var(--hover-2); min-width: 120px; min-height: 80px; }
.msg img.sticker { max-width: 150px; background: transparent; cursor: default; }
.msg video.media { max-width: 100%; max-height: 340px; border-radius: 6px; background: #000; }
.msg audio { width: 260px; max-width: 100%; height: 40px; display: block; }
.msg .doc { display: flex; align-items: center; gap: 10px; padding: 8px; background: var(--quote-bg); border-radius: 8px; text-decoration: none; color: inherit; }
.msg .doc .ic { font-size: 22px; }
.msg .doc .dn { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.msg .media-missing { font-size: 13.5px; color: var(--muted); padding: 6px 0; }
/* Reply arrow beside the bubble. Its box reaches back to the bubble's edge (padding), so the mouse never leaves the
   message on its way to the arrow — before, a 6 px gap hid the arrow before it could be clicked. */
.msg .actions { position: absolute; top: 0; inset-inline-end: -36px; padding-block: 2px 8px; padding-inline: 10px 4px; display: none; z-index: 2; }
.msg.out .actions { inset-inline-end: auto; inset-inline-start: -36px; padding-block: 2px 8px; padding-inline: 4px 10px; }
.msg:hover .actions, .msg .actions:focus-within { display: block; }
.msg .actions button:hover { background: var(--hover-2); }
.msg .actions button { border: 0; background: var(--panel); color: var(--text); border-radius: 50%; width: 24px; height: 24px; cursor: pointer; box-shadow: 0 1px 2px rgba(0, 0, 0, .15); font-size: 12px; }
.msg.flash { animation: flash 1.2s; }
@keyframes flash { from { box-shadow: 0 0 0 3px var(--teal); } }
a { color: var(--accent-text); }
.reply-bar, .file-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 14px; background: var(--panel); border-top: 1px solid var(--line); font-size: 14px; }
.reply-bar span { color: var(--muted); }
.doc-toggle { display: flex; gap: 4px; align-items: center; font-size: 13px; color: var(--muted); }
.composer { display: flex; align-items: flex-end; gap: 6px; padding: 10px 14px; background: var(--panel); border-top: 1px solid var(--line); }
.composer textarea { flex: 1; resize: none; max-height: 160px; min-height: 42px; line-height: 1.45; font-size: 15px; }
.recording { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--note-bg); border-top: 1px solid var(--line); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.recording .muted { flex: 1; }
.offline-bar { background: var(--danger-bg); color: var(--danger-text); padding: 8px 14px; font-size: 14px; border-top: 1px solid var(--danger-line); }

/* details pane */
.info-pane { width: 320px; flex: none; background: var(--panel); border-inline-start: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.info-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.info-head h3 { margin: 0; font-size: 16px; }
.info-body { padding: 14px; overflow-y: auto; display: grid; gap: 10px; align-content: start; }
.info-body h4 { margin: 8px 0 0; font-size: 14px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.label-list { display: flex; flex-wrap: wrap; gap: 6px; }
.label-list .tag { display: inline-flex; gap: 4px; align-items: center; font-size: 12px; padding: 3px 8px; }
.label-list .tag button { border: 0; background: transparent; color: #fff; cursor: pointer; padding: 0; font-size: 12px; opacity: .8; }
.notes { display: grid; gap: 8px; }
.note { background: var(--note-bg); border: 1px solid var(--note-line); border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.note .nb { white-space: pre-wrap; }
.note .nm { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; justify-content: space-between; }
.note .nm button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; }
.note-form { display: grid; gap: 6px; }
.note-form textarea { resize: vertical; }
.info-actions { display: flex; gap: 8px; margin-top: 8px; }

/* admin pages */
.page { padding: 24px 32px; overflow-y: auto; height: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.page-head h2 { margin: 0; font-size: 22px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-top: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 10px; }
.card .top { display: flex; align-items: center; gap: 10px; }
.card .swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.card h3 { margin: 0; font-size: 16px; flex: 1; }
.status { font-size: 13px; border-radius: 999px; padding: 2px 10px; background: var(--bg); color: var(--muted); }
.status.open { background: var(--ok-bg); color: var(--ok-text); }
.status.qr, .status.connecting, .status.reconnecting { background: var(--warn-bg); color: var(--warn-text); }
.status.logged_out, .status.qr_expired, .status.new { background: var(--danger-bg2); color: var(--danger-text); }
.conn-log { background: #0f172a; color: #e2e8f0; padding: 8px; border-radius: 6px; font-size: 11px; white-space: pre-wrap; max-height: 220px; overflow: auto; margin: 6px 0 0; }
.card .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; align-items: center; }
.inline-form.vertical { flex-direction: column; align-items: stretch; max-width: 360px; }
.inline-form input[type="color"] { width: 44px; padding: 2px; height: 38px; }
.table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.table th, .table td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table th { font-size: 13px; color: var(--muted); font-weight: 600; background: var(--head-bg); }
.table td:last-child { text-align: end; white-space: nowrap; }
.table td[colspan] { text-align: center; }
/* phones: the buttons at the end of a row wrap onto a second line instead of being cut off */
@media (max-width: 820px) { .table td:last-child { white-space: normal; } .table td:last-child .btn { margin-block: 2px; } }
.table input { padding: 5px 8px; }
.export-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin: 16px 0; max-width: 900px; align-items: end; }
.export-form label { display: grid; gap: 4px; font-size: 14px; font-weight: 500; }
.export-help { max-width: 760px; }

/* team analytics */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); flex: none; }
.seg button { border: 0; background: transparent; padding: 7px 12px; cursor: pointer; font-size: 14px; font-weight: 500; white-space: nowrap; }
.seg button + button { border-inline-start: 1px solid var(--line); }
.seg button:hover { background: var(--bg); }
.seg button.active { background: var(--navy); color: #fff; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 12px; margin: 14px 0 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; align-content: start; }
.stat .k { font-size: 13.5px; color: var(--muted); font-weight: 500; }
.stat .v { font-size: 28px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 14px; font-weight: 500; color: var(--muted); }
.stat .s { font-size: 13px; color: var(--muted); }
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.member { display: flex; align-items: center; gap: 10px; }
.member .mn { font-weight: 600; }
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; white-space: nowrap; border-radius: 999px; padding-block: 2px 2px; padding-inline: 8px 10px; background: var(--bg); color: var(--muted); }
.st i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); flex: none; }
.st.active { background: var(--ok-bg); color: var(--ok-text); }
.st.active i { background: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, .2); }
.st.idle { background: var(--warn-bg); color: var(--warn-text); }
.st.idle i { background: #eab308; }
.st.disabled i { background: transparent; border: 1.5px solid var(--muted-2); }
.linkish { border: 0; background: none; color: var(--accent-text); cursor: pointer; padding: 0; font: inherit; font-weight: 600; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; }
.linkish:hover { text-decoration-style: solid; }
tr.phone-row td { background: var(--head-bg); color: var(--muted); }
tr.phone-row .mn { color: var(--text); }
tr.disabled-row td { opacity: .6; }
.an-help { max-width: 900px; margin-top: 18px; }
.an-help p { margin: 4px 0; }
/* period buttons + custom dates */
.an-head { align-items: center; flex-wrap: wrap; margin-bottom: 6px; row-gap: 10px; }
.an-note { margin: 0 0 14px; }
.an-note b { color: var(--text); font-weight: 600; }
.an-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.an-custom { position: relative; }
.date-btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 0 12px; cursor: pointer; font-size: 14px; font-weight: 500; white-space: nowrap; color: var(--text); }
.date-btn:hover { border-color: var(--line-2); }
.date-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; flex: none; }
.date-btn .caret { font-size: 11px; color: var(--muted); }
.date-btn.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.date-btn.active .caret { color: var(--teal-light); }
.seg + .an-custom .date-btn { height: 35px; }
.date-pop { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 25; width: 320px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px var(--shadow); padding: 14px; display: grid; gap: 10px; }
.dp-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dp-row label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.dp-row input { width: 100%; min-width: 0; padding: 7px 8px; }
.dp-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.dp-quick button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 10px; font-size: 13px; cursor: pointer; }
.dp-quick button:hover { border-color: var(--teal); color: var(--accent-text); }
.date-pop .error:empty { display: none; }
/* headline numbers: one bordered strip */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin: 0 0 18px; }
@media (min-width: 1480px) { .kpis { grid-template-columns: repeat(8, minmax(0, 1fr)); } }
.kpi { background: var(--panel); padding: 14px 14px 12px; display: grid; gap: 1px; align-content: start; min-width: 0; }
.kpi .k { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .v { font-size: 26px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; color: var(--text); margin-top: 2px; }
.kpi .v small { font-size: 14px; font-weight: 500; color: var(--muted); }
.kpi .c { min-height: 18px; }
.kpi .s { font-size: 12.5px; color: var(--muted); line-height: 1.35; margin-top: 2px; }
.chg { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chg.good { color: #15803d; }
.chg.bad { color: #c2410c; }
.chg.flat { color: var(--muted-2); font-weight: 500; }
html[data-theme="dark"] .chg.good { color: #4ade80; }
html[data-theme="dark"] .chg.bad { color: #fb923c; }
/* tables, each in a card with a title */
.an-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin: 0 0 18px; overflow: hidden; }
.an-card-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }
.an-card-head h3 { margin: 0; font-size: 17px; color: var(--text); }
.an-card-head p { margin: 2px 0 0; }
.an-card .table-wrap { border-radius: 0; }
.an-card .table { border: 0; border-radius: 0; }
.table.dt { font-size: 14.5px; }
.table.dt th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; line-height: 1.3; padding: 10px 12px; vertical-align: bottom; position: sticky; top: 0; z-index: 1; border-bottom: 1px solid var(--line); }
.table.dt td { padding: 10px 12px; white-space: nowrap; border-bottom: 1px solid var(--line-soft); }
.table.dt td:first-child, .table.dt th:first-child { padding-inline-start: 16px; }
.table.dt td:last-child, .table.dt th:last-child { padding-inline-end: 16px; }
.table.dt td:last-child { text-align: end; }
.table.dt th.num, .table.dt td.num { text-align: end; font-variant-numeric: tabular-nums; }
.table.dt tbody tr:hover td { background: var(--hover); }
.table.dt tbody tr:last-child td { border-bottom: 0; }
.table.dt tfoot td { border-top: 1px solid var(--line); border-bottom: 0; }
.table.dt tr.total-row td { font-weight: 700; background: var(--head-bg); color: var(--text); }
.table.dt tr.empty-row td { color: var(--muted-2); }
.table.dt th[data-sort] { cursor: pointer; user-select: none; }
.table.dt th[data-sort]:hover { color: var(--text); }
.table.dt th.sorted { color: var(--accent-text); }
.table.dt th.sorted::after { content: ' ▼'; font-size: 9px; }
.table.dt th.sorted[data-dir="asc"]::after { content: ' ▲'; }
.table-wrap.tall { max-height: 560px; overflow-y: auto; }
#anPerf, #anNums, #anDays { min-width: 900px; }
#anLive { min-width: 780px; }
#anPerf th:first-child { width: 26%; }
.share { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.share-bar { flex: 1; height: 8px; border-radius: 999px; background: var(--hover-2); overflow: hidden; }
.share-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--teal)); border-radius: 999px; }
.share-pct { width: 38px; text-align: end; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.num-cell { display: flex; align-items: center; gap: 10px; }
.num-cell i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.num-cell .mn { font-weight: 600; }
.bar-col { width: 22%; min-width: 120px; }
.day-bar { display: block; height: 8px; border-radius: 999px; background: var(--hover-2); overflow: hidden; }
.day-bar i { display: block; height: 100%; background: var(--teal); border-radius: 999px; }

/* custom filters (tabs above the chat list) */
.cf-row .chip.cf { background: var(--cf-bg); border-color: var(--cf-line); color: var(--cf-text); }
.cf-row .chip.cf b { color: var(--cf-count); }
.cf-row .chip.cf.active { background: #4c1d95; border-color: #4c1d95; color: #fff; }
.cf-row .chip.cf.active b { color: #ddd6fe; }
.cf-row .chip.cf-add { border-style: dashed; color: var(--accent-text); }
.cf-active { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--cf-bg); border: 1px solid var(--cf-line); border-radius: 8px; padding-block: 5px 5px; padding-inline: 10px 6px; font-size: 14px; color: var(--cf-text); }
.cf-active .cf-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cf-active .cf-actions { display: flex; gap: 4px; flex: none; }
.dimmed { opacity: .45; }
dialog.wide { width: min(760px, 96vw); }
dialog.wide .dialog-form { max-height: 86vh; overflow-y: auto; }
.dialog-form h4 { margin: 6px 0 0; font-size: 14px; }
.fd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.fd-grid > label { min-width: 0; }
.fd-grid select, .fd-grid input, .fd-date select { width: 100%; min-width: 0; }
.fd-checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.fd-check, .fd-inline { display: inline-flex !important; align-items: center; gap: 6px; font-weight: 400 !important; font-size: 14px !important; cursor: pointer; }
.fd-check .sw { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-inline-end: 2px; }
.fd-sub { margin-top: 2px; }
.fd-dates { display: grid; gap: 8px; }
.fd-date { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
.fd-date label { min-width: 260px; }
.fd-range { display: inline-flex; align-items: center; gap: 6px; }
.fd-count { margin: 4px 0 0; font-weight: 600; color: var(--cf-text); }
.fd-buttons { position: sticky; bottom: -20px; background: var(--panel); padding: 10px 0 0; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* calls page */
.cl-filters { margin: 10px 0 0; flex-wrap: wrap; }
.cl-filters select { font-size: 14px; padding: 6px 8px; }
.cl-table { min-width: 980px; }
.cl-table td { white-space: nowrap; }
.table td[colspan] { text-align: start !important; }
.cl-table tr.clickable { cursor: pointer; }
.cl-table tr.clickable:hover td { background: var(--hover); }
.cl-dir { font-size: 13.5px; font-weight: 600; }
.cl-dir.in { color: #0369a1; }
.cl-dir.out { color: #7c3aed; }
html[data-theme="dark"] .cl-dir.in { color: #7dd3fc; }
html[data-theme="dark"] .cl-dir.out { color: #c4b5fd; }
.cl-num { display: inline-flex; align-items: center; gap: 6px; }
.cl-num i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.cl-res { font-size: 13px; border-radius: 999px; padding: 2px 10px; font-weight: 600; background: var(--bg); color: var(--muted); }
.cl-res.ok { background: var(--ok-bg); color: var(--ok-text); }
.cl-res.bad { background: var(--danger-bg2); color: var(--danger-text); }
.cl-res.warn { background: var(--warn-bg); color: var(--warn-text); }
.cl-res.live { background: var(--info-bg); color: var(--info-text); }
.bad-num { color: var(--danger); }
a.icon-btn { text-decoration: none; }

/* composer tabs: Reply / Note / Quick replies / Reminder */
.convo { position: relative; }
.composer-tabs { display: flex; gap: 2px; padding: 6px 14px 0; background: var(--panel); border-top: 1px solid var(--line); }
.ctab { border: 0; background: transparent; padding: 4px 10px; border-radius: 6px; font-size: 14px; cursor: pointer; color: var(--muted); font-weight: 500; }
.ctab:hover { background: var(--bg); color: var(--text); }
.ctab.active { color: var(--accent-text); box-shadow: inset 0 -2px 0 var(--teal); border-radius: 0; }
.ctab[data-mode="note"].active { color: var(--note-text); box-shadow: inset 0 -2px 0 #d97706; }
.composer { border-top: 0; }
.composer.note-mode { background: var(--note-bg); }
.composer.note-mode textarea { background: var(--note-bg2); border-color: var(--note-line2); }
.composer.note-mode .btn.primary { background: #b45309; border-color: #b45309; }
.picker { position: absolute; inset-inline-start: 14px; inset-inline-end: 14px; bottom: 64px; max-height: 300px; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px var(--shadow); z-index: 15; }
.pk-head { font-size: 13px; font-weight: 600; padding: 7px 12px; border-bottom: 1px solid var(--line); background: var(--head-bg); position: sticky; top: 0; }
.pk-head .muted { font-weight: 400; margin-inline-start: 6px; }
.pk-item { display: flex; gap: 10px; align-items: baseline; padding: 7px 12px; cursor: pointer; font-size: 14px; }
.pk-item.on, .pk-item:hover { background: var(--blue-soft); }
.pk-body { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.pk-empty { padding: 10px 12px; font-size: 14px; color: var(--muted); }
.qr-sc { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; white-space: nowrap; flex: none; }
/* notes inside the conversation */
.msg.note-msg { align-self: center; max-width: min(620px, 86%); background: var(--note-bg2); border: 1px solid var(--note-line2); border-radius: 10px; box-shadow: none; }
.msg.note-msg .note-head { font-size: 12.5px; font-weight: 600; color: var(--note-text); margin-bottom: 2px; }
.msg.note-msg .note-head .muted { font-weight: 400; }
/* reminders */
.tag.rem { background: var(--note-bg2); color: var(--note-text); }
.tag.rem.due { background: var(--danger-bg2); color: var(--danger-text); font-weight: 600; }
.info-body h4 .btn.small { padding: 1px 8px; font-size: 11.5px; margin-inline-start: 6px; }
.reminders { display: grid; gap: 6px; }
.rem { background: var(--note-bg); border: 1px solid var(--note-line); border-radius: 8px; padding: 7px 9px; font-size: 13.5px; }
.rem.due { background: var(--danger-bg); border-color: var(--danger-line); }
.rem-body { margin-top: 2px; }
.rem-actions { display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; }
.rem-actions .btn.small { padding: 2px 8px; font-size: 11.5px; }
/* quick replies window */
.ql-bar { flex-wrap: wrap; }
.ql-bar input[type=search] { flex: 1; min-width: 160px; }
.ql-form { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 8px; background: var(--head-bg); }
.ql-form label { display: grid; gap: 4px; font-size: 14px; font-weight: 500; }
.ql-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; max-height: 50vh; overflow-y: auto; }
.ql-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line-soft); cursor: pointer; font-size: 14px; }
.ql-item:hover { background: var(--blue-soft); }
.ql-icon { flex: none; font-size: 13px; }
.ql-body { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ql-by { flex: none; }
.ql-edit { width: 28px; height: 28px; font-size: 14px; }

/* notifications: bell in the rail + panel */
.rail-btn { position: relative; }
.rail-badge { margin-inline-start: auto; background: var(--danger); color: #fff; border-radius: 999px; font-size: 10px; min-width: 17px; height: 17px; padding: 0 4px; display: grid; place-items: center; font-weight: 700; }
.rail-btn.active-bell { background: var(--side-hover); color: var(--text); }
.notif-panel { position: fixed; top: 0; bottom: 0; inset-inline-start: var(--rail-w); width: min(400px, calc(100vw - var(--rail-w))); background: var(--panel); border-inline-end: 1px solid var(--line); box-shadow: 8px 0 30px var(--shadow); z-index: 30; display: flex; flex-direction: column; }
.np-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.np-head h3 { margin: 0; font-size: 16px; }
.np-tabs { display: flex; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.np-tabs button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 10px; font-size: 13.5px; cursor: pointer; white-space: nowrap; display: inline-flex; gap: 5px; align-items: center; }
.np-tabs button.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.np-tabs b { background: var(--danger); color: #fff; border-radius: 999px; font-size: 10px; min-width: 16px; height: 16px; padding: 0 4px; display: inline-grid; place-items: center; }
.np-tabs b:empty { display: none; }
.np-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.np-item { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); cursor: pointer; position: relative; }
.np-item:hover { background: var(--hover); }
.np-item.unread { background: var(--unread-bg); }
.np-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 700; background: var(--bg); color: var(--muted); font-size: 14px; }
.np-icon.mention { background: var(--note-bg2); color: var(--note-text); }
.np-icon.assigned, .np-icon.unassigned { background: var(--sel-bg); color: var(--sel-text); }
.np-icon.reminder { background: var(--danger-bg2); color: var(--danger-text); }
.np-main { flex: 1; min-width: 0; }
.np-title { font-weight: 600; font-size: 14px; }
.np-text { font-size: 14px; color: var(--text-2); margin-top: 2px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.np-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.np-dot { position: absolute; inset-inline-end: 12px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.np-upcoming { padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--note-bg); font-size: 13.5px; display: grid; gap: 4px; }
.np-sub { font-weight: 600; color: var(--note-text); }
.np-up { cursor: pointer; }
.np-up:hover { text-decoration: underline; }
.mention { background: var(--mention-bg); color: var(--mention-text); border-radius: 4px; padding: 0 3px; font-weight: 600; }

/* dialogs & toast */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(420px, 92vw); background: var(--panel); color: var(--text); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
html[data-theme="dark"] dialog { border: 1px solid var(--line); }
dialog::backdrop { background: rgba(11, 31, 58, .45); }
.dialog-form { padding: 20px; display: grid; gap: 12px; }
.dialog-form h3 { margin: 0; }
.dialog-form label { display: grid; gap: 4px; font-size: 14px; font-weight: 500; }
.qr-box ol { margin: 0; padding-inline-start: 18px; }
.qr-image { display: grid; place-items: center; min-height: 300px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.qr-image img { width: 280px; height: 280px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 50; max-width: 90vw; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); }
.toast.err { background: var(--danger); }
.toast-btn { margin-inline-start: 14px; border: 0; background: transparent; color: var(--teal-light); font-weight: 700; cursor: pointer; padding: 0; }

/* the ⋯ menu and "Actions with selected" */
.menu { position: fixed; z-index: 40; min-width: 236px; max-width: min(320px, calc(100vw - 16px)); max-height: min(72vh, 480px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 16px 40px var(--shadow), 0 2px 6px rgba(15, 23, 42, .06); }
.mi { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 14.5px; text-align: start; color: var(--text); }
.mi:hover { background: var(--hover); }
.mi svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; color: var(--text-2); }
.mi-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi-side { font-size: 13px; color: var(--muted); max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi > svg:last-child:not(:first-child) { width: 15px; height: 15px; color: var(--muted-2); }
.mi-check svg { width: 16px; height: 16px; color: var(--accent-text); stroke-width: 2.4; }
.mi.danger, .mi.danger svg { color: var(--danger); }
.mi.danger:hover { background: var(--danger-bg); }
.mi-back { font-weight: 600; border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0; margin-bottom: 4px; }
.mi-head { font-size: 13px; font-weight: 600; color: var(--muted); padding: 6px 10px 4px; }
.mi-note { padding: 8px 10px; font-size: 14px; color: var(--muted); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }
.lab-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.agent-dot.small { width: 20px; height: 20px; font-size: 9px; }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-fill:hover { background: #b91c1c; }
/* a deleted chat (admins open it from the "Deleted" filter) */
.del-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 14px; background: var(--hover); color: var(--text-2); border-bottom: 1px solid var(--line); font-size: 14px; }
.tag.deleted { background: var(--hover); color: var(--text-2); border: 1px solid var(--line); }
.chip[data-f="deleted"].active { background: #3f3f46; border-color: #3f3f46; }
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .85); display: grid; place-items: center; z-index: 60; cursor: zoom-out; }
.lightbox img { max-width: 94vw; max-height: 94vh; }

/* mobile: one column at a time */
/* laptops (and while a chat is open on screens up to 1500 px): the left menu shrinks to icons with short names.
   app.js sets body.rail-mini */
@media (max-width: 1180px) and (min-width: 821px) {
  :root { --list-w: 340px; }
}
@media (min-width: 821px) {
  body.rail-mini { --rail-w: 76px; }
  body.rail-mini .rail { padding: 12px 6px 8px; align-items: center; }
  body.rail-mini .rail-brand { padding: 0 0 12px; border-radius: 10px; }
  body.rail-mini .brand-name, body.rail-mini .me-text { display: none; }
  body.rail-mini .rail-btn { flex-direction: column; justify-content: center; gap: 3px; width: 64px; padding: 8px 0; border-radius: 10px; font-size: 10.5px; text-align: center; }
  body.rail-mini .rail-btn.active::before { display: none; }
  body.rail-mini .rail-btn span[data-s] { font-size: 0; }
  body.rail-mini .rail-btn span[data-s]::after { content: attr(data-s); font-size: 10.5px; }
  body.rail-mini .rail-sep { font-size: 0; width: 40px; padding: 0; margin: 8px 0 6px; border-top: 1px solid var(--line-2); }
  body.rail-mini .rail-badge { position: absolute; top: 2px; inset-inline-end: 6px; margin: 0; }
  body.rail-mini .rail-me { padding: 8px 0; }
  body.rail-mini .rail-me .conn-dot { position: absolute; top: 8px; inset-inline-end: 14px; border: 2px solid var(--side); width: 11px; height: 11px; margin: 0; }
}

/* phones: one column at a time, menu at the bottom */
@media (max-width: 820px) {
  :root { --rail-w: 0px; --nav-h: calc(58px + env(safe-area-inset-bottom, 0px)); }
  /* 16px text in boxes you type in: smaller makes iPhones zoom the page in when you tap them */
  input, select, textarea { font-size: 16px !important; }

  /* bottom bar: Chats, Calls, Alerts, (Analytics for admins), More. Hidden inside an open chat */
  .rail { position: fixed; bottom: 0; inset-inline-start: 0; inset-inline-end: 0; width: auto; height: var(--nav-h); flex-direction: row; align-items: stretch; gap: 0; padding: 0 4px env(safe-area-inset-bottom, 0px); z-index: 10; justify-content: space-around; background: var(--panel); border-inline-end: 0; border-top: 1px solid var(--line); overflow: visible; }
  .rail-brand, .rail-spacer, .rail-sep, .me-text, .rail-me .conn-dot, .theme-btn, .rail .m-hide { display: none !important; }
  .more-btn { display: flex; }
  .home-mini { display: block; }
  .rail-btn { flex: 1; min-width: 0; max-width: 110px; flex-direction: column; justify-content: center; gap: 3px; padding: 4px 0; border-radius: 0; font-size: 11px; text-align: center; color: var(--muted); }
  .rail-btn svg { width: 22px; height: 22px; }
  .rail-btn:hover { background: transparent; }
  .rail-btn.active { background: transparent; color: var(--brand-text); font-weight: 600; }
  .rail-btn.active::before { inset-inline-start: 25%; inset-inline-end: 25%; top: 0; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .rail-btn span[data-s] { font-size: 0; }
  .rail-btn span[data-s]::after { content: attr(data-s); font-size: 11px; }
  .rail-badge { position: absolute; top: 4px; inset-inline-end: calc(50% - 22px); margin: 0; }
  .app { padding-bottom: var(--nav-h); }
  body.chat-open .rail { display: none; }
  body.chat-open .app { padding-bottom: 0; }
  .notif-panel { inset-inline-start: 0; width: 100vw; bottom: var(--nav-h); }

  /* "More" sheet above the bottom bar */
  .more-sheet { position: fixed; inset-inline-start: 0; inset-inline-end: 0; top: 0; bottom: var(--nav-h); z-index: 25; background: rgba(11, 31, 58, .38); display: flex; align-items: flex-end; }
  .ms-panel { width: 100%; max-height: 100%; overflow-y: auto; overscroll-behavior: contain; background: var(--panel); border-radius: 16px 16px 0 0; padding: 10px 8px 10px; box-shadow: 0 -10px 30px var(--shadow); animation: sheet-up .16s ease-out; }
  .ms-me { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: var(--hover); border-radius: 12px; padding: 10px 12px; text-align: start; cursor: pointer; color: var(--text); }
  .ms-me .avatar.small { width: 38px; height: 38px; font-size: 14px; }
  .ms-me > span:last-child { display: grid; line-height: 1.3; min-width: 0; }
  .ms-me b { font-size: 16px; font-weight: 600; }
  .ms-me small { color: var(--muted); font-size: 13.5px; }
  .ms-sep { padding: 12px 12px 4px; font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted-2); }
  .ms-sep:empty { padding: 0; margin: 6px 4px; border-top: 1px solid var(--line); }
  .ms-item { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 50px; border: 0; background: transparent; border-radius: 10px; padding: 0 12px; font-size: 16px; font-weight: 500; color: var(--text); cursor: pointer; text-align: start; }
  .ms-item:active, .ms-item.active { background: var(--sel-bg); color: var(--sel-text); }
  .ms-item svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

  /* chat list: search on top, then Filters + Select + the filters that are on (one line, swipe sideways) */
  .list-pane, .inbox.chat-open .list-pane { width: 100%; border-inline-end: 0; }
  .inbox.chat-open .list-pane { display: none; }
  .list-head, .inbox.chat-open .list-head { padding: 10px 12px 0; gap: 8px; }
  .btn.green { padding: 0; width: 42px; font-size: 22px; }
  .btn.green span { display: none; }
  .toolbar { flex-wrap: nowrap; gap: 8px; padding-bottom: 8px; }
  .f-inline { display: inline-flex; flex: none; }
  .af-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; margin-inline-end: -12px; padding-inline-end: 12px; }
  .af-row::-webkit-scrollbar { display: none; }
  .af-chip, .af-clear { flex: none; }
  .af-chip { height: 36px; }
  .sel-btn, #bulkBtn, #selCancel { height: 36px; }
  /* Filters panel: slides in from the left over the list, with a dark background behind it */
  .inbox.fp-float .filter-pane { position: fixed; top: 0; inset-inline-start: 0; bottom: var(--nav-h); width: min(330px, 88vw); z-index: 26; }
  .inbox.fp-float .fp-backdrop { display: block; position: fixed; top: 0; inset-inline-start: 0; inset-inline-end: 0; bottom: var(--nav-h); z-index: 25; background: rgba(11, 31, 58, .38); }
  .fp-head { min-height: 56px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
  .filter-pane .chip, .filter-pane .num-pill { min-height: 44px; font-size: 16px; }
  .fp-foot { display: block; padding: 10px 12px; border-top: 1px solid var(--line); }
  .fp-foot .btn { height: 44px; font-size: 16px; }
  /* each chat: the assigned person is the small round badge next to the message (saves a line per chat) */
  .chat-item { padding-block: 10px 10px; padding-inline: 14px 4px; gap: 10px; }
  .chat-resp { display: none; }
  .inbox:not(.chat-open) .chat-bottom .agent-dot { display: inline-grid; }
  .row-menu { width: 38px; height: 38px; margin: -9px 0 0 0; }
  .team-bar { padding: 5px 10px; }
  .tb-person .agent-dot { width: 26px; height: 26px; font-size: 10px; }

  /* an open chat fills the screen */
  .messages { padding: 12px 10px; }
  .msg { max-width: 88%; }
  .msg .actions { display: block; position: absolute; top: auto; bottom: 2px; inset-inline-end: auto; inset-inline-start: 6px; padding: 0; }
  .msg.out .actions { inset-inline-start: 6px; }
  .msg .actions button { width: 22px; height: 22px; font-size: 11px; box-shadow: none; background: transparent; opacity: .6; }
  .msg .meta { padding-inline-start: 18px; } /* keep the time clear of the small reply arrow */
  .convo-head { gap: 4px; padding-block: 6px 6px; padding-inline: 2px 8px; }
  .back-btn { width: 34px; font-size: 32px; }
  .convo-head .avatar { width: 36px; height: 36px; font-size: 14px; }
  .convo-title .name { font-size: 16px; }
  .convo-title .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; }
  .assign-wrap { position: relative; display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%; cursor: pointer; }
  .assign-face { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: var(--muted); }
  .assign-face .agent-dot { width: 34px; height: 34px; font-size: 12px; }
  .assign-face.none { border: 1.5px dashed var(--line-2); }
  .assign-face svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .assign-wrap select { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; padding: 0; opacity: 0; cursor: pointer; }
  #cRemindBtn { display: none; } /* the composer's "⏰ Reminder" tab does the same on phones */
  .composer-tabs { padding: 4px 8px 0; overflow-x: auto; scrollbar-width: none; }
  .composer-tabs::-webkit-scrollbar { display: none; }
  .ctab { flex: none; padding: 7px 10px; }
  .composer { padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px)); gap: 4px; }
  .composer .btn.primary { height: 42px; padding: 0 14px; }
  .recording, .offline-bar { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  .reply-bar, .file-bar { padding: 6px 10px; }
  .picker { inset-inline-start: 8px; inset-inline-end: 8px; }
  .pk-keys { display: none; }
  .pk-item { padding: 10px 12px; }

  /* details panel: full screen, bigger buttons */
  .info-pane { position: fixed; inset: 0 0 var(--nav-h) 0; width: auto; z-index: 20; }
  body.chat-open .info-pane { bottom: 0; }
  .info-body { padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
  .info-body .btn.small, .rem-actions .btn.small { padding: 7px 12px; font-size: 14px; }
  .info-body h4 .btn.small { padding: 4px 10px; font-size: 13px; }
  .note .nm button { padding-block: 6px 6px; padding-inline: 8px 2px; font-size: 13px; }
  .info-actions { flex-wrap: wrap; }

  /* pop-ups */
  .toast { bottom: calc(var(--nav-h) + 12px); }
  body.chat-open .toast { bottom: calc(112px + env(safe-area-inset-bottom, 0px)); }
  dialog { width: calc(100vw - 24px); }
  .dialog-form { padding: 16px; }
  .ql-item { align-items: flex-start; }
  .ql-by { display: none; }
  .ql-body { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .ql-edit { width: 36px; height: 36px; margin: -6px 0; }
  .mi { min-height: 44px; font-size: 15.5px; }

  /* pages */
  .page { padding: 16px; }
  .page-head { flex-wrap: wrap; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat .v { font-size: 22px; }
  /* team analytics on phones: period buttons scroll sideways, custom dates below them */
  .an-controls { width: 100%; justify-content: flex-start; }
  .an-controls .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .an-controls .seg button { flex: none; }
  .an-custom { width: 100%; }
  .date-btn { width: 100%; justify-content: center; }
  .date-pop { inset-inline-start: 0; inset-inline-end: auto; width: min(340px, calc(100vw - 32px)); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .v { font-size: 22px; }
  .an-card-head { padding: 12px; }
  #clPeriod { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  #clPeriod button { flex: none; }
  .cl-filters select { flex: 1 1 140px; min-width: 0; }
  /* Calls: one card per call instead of a wide table */
  .cl-table { min-width: 0; }
  .cl-table thead { display: none; }
  .cl-table, .cl-table tbody { display: block; }
  .cl-table tr { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 3px 10px; padding: 11px 14px; border-bottom: 1px solid var(--line-soft); }
  .cl-table tr:last-child { border-bottom: 0; }
  .cl-table td { display: block; padding: 0 !important; border: 0; white-space: normal; text-align: start !important; min-width: 0; overflow-wrap: anywhere; }
  .cl-table td:nth-child(1) { grid-area: 1 / 1 / 2 / 3; font-weight: 600; }
  .cl-table td:nth-child(5) { grid-area: 1 / 3; }
  .cl-table td:nth-child(3) { grid-area: 2 / 1 / 3 / 4; }
  .cl-table td:nth-child(4) { grid-area: 3 / 1 / 4 / 4; }
  .cl-table td:nth-child(3)::before { content: 'From'; }
  .cl-table td:nth-child(4)::before { content: 'To'; }
  .cl-table td:nth-child(3)::before, .cl-table td:nth-child(4)::before { display: inline-block; width: 42px; color: var(--muted); font-size: 13px; }
  .cl-table td:nth-child(2) { grid-area: 4 / 1; }
  .cl-table td:nth-child(7) { grid-area: 4 / 2; color: var(--muted); font-size: 13.5px; }
  .cl-table td:nth-child(6) { grid-area: 4 / 3; text-align: end !important; color: var(--muted); font-size: 13.5px; }
  .cl-table td[colspan] { grid-area: 1 / 1 / 2 / 4; }
  /* Team: one card per person */
  .team-table thead { display: none; }
  .team-table, .team-table tbody { display: block; }
  .team-table tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .team-table tr:last-child { border-bottom: 0; }
  .team-table td { display: block; padding: 0; border: 0; text-align: start !important; white-space: normal !important; }
  .team-table td:nth-child(1) { grid-area: 1 / 1; font-weight: 600; }
  .team-table td:nth-child(4) { grid-area: 1 / 2; font-size: 14px; }
  .team-table td:nth-child(2) { grid-area: 2 / 1; color: var(--muted); font-size: 14px; }
  .team-table td:nth-child(3) { grid-area: 2 / 2; color: var(--muted); font-size: 14px; }
  .team-table td:nth-child(5) { grid-area: 3 / 1 / 4 / 3; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
  .team-table td:nth-child(5) .btn.small { padding: 7px 12px; font-size: 14px; }
  #userForm input, #userForm select { flex: 1 1 100%; }
  #labelForm input[name=name] { flex: 1 1 160px; min-width: 0; }
  .card .actions .btn { padding: 8px 12px; }
}
@keyframes sheet-up { from { transform: translateY(18px); opacity: 0; } }

/* Numbers page: many buttons → they wrap under each other on the right; the title keeps one line */
#view-numbers .page-head { align-items: flex-start; }
#view-numbers .page-head h2 { white-space: nowrap; }
#view-numbers .page-head > .row.gap { flex-wrap: wrap; justify-content: flex-end; }

/* ===== CONTACT INFO: click the customer's name → picture, Media, links and docs, Starred messages (like WhatsApp) ===== */
:root { --star: #e0a100; --mv-bg: #0b1019; }
html[data-theme="dark"] { --star: #f5c542; }
#cAvatar, .convo-title { cursor: pointer; }
.convo-title:hover .name { text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.convo-title:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.ci-profile { display: grid; justify-items: center; gap: 3px; padding: 4px 0 12px; border-bottom: 1px solid var(--line); text-align: center; }
.ci-avatar { width: 84px; height: 84px; font-size: 30px; margin-bottom: 6px; }
.ci-name { font-size: 19px; font-weight: 600; overflow-wrap: anywhere; }
.ci-phone { font-size: 14px; color: var(--muted); }
.ci-section { border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.ci-row { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; padding: 7px 6px; margin: 0 -6px; width: calc(100% + 12px); font: inherit; color: var(--text); cursor: pointer; text-align: start; border-radius: 8px; }
.ci-row:hover { background: var(--hover); }
.ci-row-t { flex: 1; font-weight: 600; font-size: 14.5px; }
.ci-star { color: var(--star); }
.ci-count { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.ci-chev { color: var(--muted); font-size: 22px; line-height: 1; margin-top: -2px; }
.ci-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 6px; }
.ci-strip:empty { display: none; }
.info-pane.sub-open .info-main-head, .info-pane.sub-open .info-main { display: none; }
.info-sub-head { justify-content: flex-start; gap: 4px; padding-block: 8px 8px; padding-inline: 6px 10px; }
.info-sub-head h3 { flex: 1; }
#subBack { font-size: 26px; line-height: 1; }
.info-sub { gap: 4px; }
.sub-tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 4px; flex: none; }
.sub-tabs button { flex: 1; border: 0; background: none; padding: 10px 2px 9px; font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.sub-tabs button b { font-weight: 500; font-size: 12px; color: var(--muted-2); margin-inline-start: 1px; }
.sub-tabs button:hover { color: var(--text); }
.sub-tabs button.active { color: var(--brand-text); border-bottom-color: var(--teal); }
.sh-month { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 8px 0 4px; }
.sh-month:first-child { margin-top: 0; }
.sh-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.sh-tile { position: relative; aspect-ratio: 1; border: 0; padding: 0; border-radius: 6px; overflow: hidden; background: var(--hover-2); cursor: zoom-in; display: grid; place-items: center; }
.sh-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.sh-tile:hover img { filter: brightness(.88); }
.sh-tile:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.sh-ph { font-size: 22px; opacity: .55; }
.sh-vid { position: absolute; inset-inline-start: 4px; bottom: 4px; color: #fff; font-size: 11.5px; font-weight: 600; background: rgba(0, 0, 0, .55); padding: 0 5px; border-radius: 4px; line-height: 17px; }
.sh-star { position: absolute; inset-inline-end: 4px; top: 2px; color: #f5c542; font-size: 13px; text-shadow: 0 0 3px rgba(0, 0, 0, .7); }
.sh-list { display: grid; }
.sh-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.sh-row.link, .sh-row.audio { align-items: start; }
.sh-ic { width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; font-size: 10.5px; font-weight: 700; letter-spacing: .02em; color: #fff; background: #64748b; overflow: hidden; }
.sh-ic.thumb { background: var(--hover-2); }
.sh-ic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sh-ic.link { background: var(--blue-soft); font-size: 18px; }
.sh-main { min-width: 0; display: grid; gap: 2px; }
.sh-name { font-weight: 500; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); text-decoration: none; }
.sh-name:hover { text-decoration: underline; }
.sh-meta { font-size: 12.5px; color: var(--muted); }
.sh-url { display: grid; color: var(--accent-text); font-weight: 600; font-size: 14px; text-decoration: none; min-width: 0; }
.sh-url small { font-weight: 400; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-url:hover small { text-decoration: underline; }
.sh-text { font-size: 13.5px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.sh-row audio { width: 100%; height: 36px; }
.sh-go { width: 30px; height: 30px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; font-size: 15px; }
.sh-go:hover { background: var(--hover-2); color: var(--text); }
.sh-empty { text-align: center; color: var(--muted); padding: 34px 10px; font-size: 14px; line-height: 1.5; }
.sh-more { justify-self: center; margin: 10px auto 4px; }
.cs-item { display: grid; gap: 2px; text-align: start; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); cursor: pointer; margin-bottom: 6px; }
.cs-item:hover, .cs-item:focus-visible { border-color: var(--teal); outline: none; }
.cs-text { font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.cs-meta { font-size: 12px; color: var(--muted); }
.cs-who { color: var(--star); font-weight: 500; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.cs-unstar { border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; padding: 2px 0; text-decoration: underline; }

/* ===== STAR on messages (☆ beside the bubble when the mouse is over it, ★ next to the time) ===== */
.msg .actions { flex-direction: column; gap: 4px; }
.msg:hover .actions, .msg .actions:focus-within { display: flex; }
.msg .actions .star-btn { font-size: 14px; line-height: 1; }
.msg .actions .star-btn.on { color: var(--star); }
.msg .star-mark { color: var(--muted); font-size: 12px; cursor: default; }
.msg .star-mark.mine { color: var(--star); }

/* ===== STARRED page ===== */
.st-list { display: grid; gap: 10px; margin-top: 14px; max-width: 900px; }
.st-item { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer; display: grid; gap: 6px; }
.st-item:hover, .st-item:focus-visible { border-color: var(--teal); outline: none; }
.st-top { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 13.5px; }
.st-chat { font-weight: 600; font-size: 15px; }
.st-time { margin-inline-start: auto; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.st-body { border-inline-start: 3px solid var(--line-2); padding-block: 2px 2px; padding-inline: 10px 0; display: grid; gap: 1px; }
.st-body.out { border-inline-start-color: var(--teal); }
.st-from { font-size: 12px; color: var(--muted); font-weight: 600; }
.st-text { font-size: 15px; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.st-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--muted); }
.st-who { color: var(--star); font-weight: 500; }
#stSearch { min-width: 260px; }

/* ===== PHOTO / VIDEO VIEWER ===== */
.mv { position: fixed; inset: 0; z-index: 70; background: var(--mv-bg); color: #fff; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.mv-head { display: flex; align-items: center; gap: 4px; padding-block: 8px 8px; padding-inline: 18px 12px; }
.mv-who { flex: 1; min-width: 0; display: grid; }
.mv-who b { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-who span { font-size: 12.5px; opacity: .75; }
.mv-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: #fff; font-size: 19px; cursor: pointer; display: grid; place-items: center; text-decoration: none; flex: none; }
.mv-btn:hover { background: rgba(255, 255, 255, .13); }
.mv-btn.on { color: #f5c542; }
.mv-stage { display: flex; align-items: center; justify-content: center; min-height: 0; padding: 0 72px; overflow: hidden; }
.mv-stage img, .mv-stage video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; background: #000; }
.mv-stage img { background: transparent; }
.mv-msg { opacity: .8; font-size: 14.5px; text-align: center; max-width: 360px; line-height: 1.5; }
.mv-missing { display: grid; justify-items: center; gap: 14px; }
.mv-missing img { width: min(320px, 70vw); aspect-ratio: 1; object-fit: cover; border-radius: 6px; filter: blur(1.5px) brightness(.8); }
.mv-caption { text-align: center; padding: 10px 18px 16px; font-size: 15px; max-height: 22vh; overflow: auto; white-space: pre-wrap; }
.mv-caption:empty { padding: 0 0 12px; }
.mv-caption a { color: var(--teal-light); }
.mv-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .12); color: #fff; font-size: 32px; line-height: 1; cursor: pointer; display: grid; place-items: center; padding-bottom: 4px; }
.mv-nav:hover:not(:disabled) { background: rgba(255, 255, 255, .22); }
.mv-nav:disabled { opacity: .2; cursor: default; }
.mv-prev { inset-inline-start: 14px; }
.mv-next { inset-inline-end: 14px; }
body.mv-on { overflow: hidden; }

@media (max-width: 820px) {
  .msg .actions { display: flex; flex-direction: row; gap: 2px; }
  .msg .meta { padding-inline-start: 44px; } /* room for ↩ and ☆ */
  .msg .star-mark.mine { display: none; } /* the ★ button in the corner already shows it */
  .ci-row { padding: 10px 6px; }
  .sub-tabs button { padding: 12px 2px 11px; font-size: 14.5px; }
  .sh-go { width: 38px; height: 38px; }
  .cs-unstar { padding: 6px 0; font-size: 13px; }
  #stSearch { min-width: 0; flex: 1 1 100%; }
  .st-time { margin-inline-start: 0; width: 100%; }
  .st-foot { flex-wrap: wrap; }
  .mv-head { padding: calc(6px + env(safe-area-inset-top, 0px)) 6px 6px 14px; gap: 0; }
  .mv-stage { padding: 0; }
  .mv-stage img, .mv-stage video { border-radius: 0; }
  .mv-nav { width: 40px; height: 40px; font-size: 28px; background: rgba(0, 0, 0, .35); }
  .mv-prev { inset-inline-start: 6px; }
  .mv-next { inset-inline-end: 6px; }
  .mv-caption { padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
}

/* ===== FORWARD (like WhatsApp Web): ➦ beside a message, "Forward to…" window, "Select more messages" ===== */
.fwd-ic { width: 15px; height: 15px; fill: currentColor; display: block; flex: none; }
.msg .actions .fwd-btn { display: grid; place-items: center; padding: 0; color: var(--text-2); }
.msg .actions .fwd-btn .fwd-ic { width: 14px; height: 14px; }
.msg .fwd-label { display: flex; align-items: center; gap: 3px; font-size: 12.5px; font-style: italic; color: var(--muted); margin: -2px 0 2px; }
.msg .fwd-label .fwd-ic { width: 13px; height: 13px; }
.msg .fwd-label.many .fwd-ic + .fwd-ic { margin-inline-start: -9px; }
.mv-btn .fwd-ic { width: 20px; height: 20px; }
.sel-fwd, .fwd-send { display: inline-flex; align-items: center; gap: 6px; }
.sel-fwd .fwd-ic, .fwd-send .fwd-ic { width: 16px; height: 16px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent-text); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.link-btn:hover { text-decoration: underline; }

/* "Select more messages": a tick box beside each message, the bar below replaces the message box */
.sel-bar { display: none; align-items: center; gap: 10px; padding: 10px 14px; background: var(--panel); border-top: 1px solid var(--line); }
.convo.selecting .sel-bar { display: flex; }
.convo.selecting :is(#composerTabs, #composer, #replyBar, #fileBar, #picker, #recording) { display: none !important; }
.sel-count { font-weight: 600; font-size: 15px; white-space: nowrap; }
.sel-hint { flex: 1; min-width: 0; color: var(--muted); font-size: 13.5px; }
.convo.selecting .messages { padding-inline-start: max(6%, 52px); }
.convo.selecting .msg .actions { display: none !important; }
.convo.selecting .msg > * { pointer-events: none; }
.convo.selecting .msg.can-fwd { cursor: pointer; }
.convo.selecting .msg:not(.can-fwd) { opacity: .5; }
.convo.selecting .msg.can-fwd::before { content: ''; position: absolute; inset-inline-start: -36px; top: 50%; width: 20px; height: 20px; margin-top: -10px; box-sizing: border-box; border: 2px solid var(--line-2); border-radius: 5px; background: var(--panel); }
.convo.selecting .msg.picked::before { content: '✓'; background: var(--teal); border-color: var(--teal); color: #fff; font-size: 13px; font-weight: 700; line-height: 16px; text-align: center; }
.convo.selecting .msg.picked { box-shadow: 0 0 0 2px var(--teal); }

/* "Forward to…" window */
dialog.fwd-dialog { width: min(480px, 94vw); }
.fwd-form { gap: 10px; max-height: min(88vh, 780px); grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto auto minmax(0, 1fr); overflow: hidden; }
.fwd-form > * { min-width: 0; }
.fwd-form > .row h3 { flex: 1; font-size: 18px; }
.fwd-preview { display: flex; align-items: center; gap: 10px; background: var(--quote-bg); border-inline-start: 3px solid var(--teal); border-radius: 6px; padding: 7px 10px; font-size: 14px; }
.fwd-pv-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.fwd-bar input { flex: 1; min-width: 0; }
.fwd-bar select { max-width: 160px; }
.fwd-head { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }
.fwd-list { list-style: none; margin: 0 -8px; padding: 0; overflow-y: auto; min-height: 140px; max-height: 44vh; }
.fwd-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.fwd-item:hover, .fwd-item:focus-visible { background: var(--hover); outline: none; }
.fwd-item.off { opacity: .45; cursor: not-allowed; }
.fwd-check { width: 20px; height: 20px; box-sizing: border-box; border: 2px solid var(--line-2); border-radius: 5px; flex: none; display: grid; place-items: center; }
.fwd-item.on .fwd-check { background: var(--teal); border-color: var(--teal); }
.fwd-item.on .fwd-check::after { content: '✓'; color: #fff; font-size: 13px; font-weight: 700; line-height: 1; }
.fwd-item .avatar { width: 38px; height: 38px; font-size: 14px; flex: none; }
.fwd-main { min-width: 0; display: grid; }
.fwd-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fwd-sub { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; overflow: hidden; white-space: nowrap; }
.fwd-sub i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.fwd-empty { color: var(--muted); text-align: center; padding: 28px 0; }
.fwd-limit { margin: 0; font-size: 13px; color: var(--warn-text); background: var(--warn-bg); border-radius: 6px; padding: 6px 10px; }
.fwd-note { margin: 0; }
.fwd-form .error { margin: 0; font-size: 13.5px; line-height: 1.45; }
.fwd-form .error:empty { display: none; }
.fwd-foot { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.fwd-picked { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.fwd-chip { display: inline-flex; align-items: center; gap: 2px; background: var(--sel-bg); color: var(--sel-text); border: 1px solid var(--sel-line); border-radius: 999px; padding-block: 2px 2px; padding-inline: 10px 3px; font-size: 13px; max-width: 190px; }
.fwd-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fwd-chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 11px; width: 20px; height: 20px; border-radius: 50%; padding: 0; flex: none; }
.fwd-chip button:hover { background: var(--sel-hover); }
.fwd-send { flex: none; }
.fwd-dialog.busy :is(.fwd-list, .fwd-bar, .fwd-preview, .fwd-picked) { opacity: .6; pointer-events: none; }

@media (max-width: 820px) {
  .msg .meta { padding-inline-start: 66px; } /* room for ↩ ☆ ➦ */
  .sel-bar { padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px)); gap: 6px; }
  .sel-hint { font-size: 12.5px; }
  .convo.selecting .messages { padding-inline-start: 44px; }
  .convo.selecting .msg.can-fwd::before { inset-inline-start: -32px; }
  .fwd-form { max-height: calc(100dvh - 32px); }
  .fwd-list { max-height: none; }
  .fwd-bar select { max-width: 120px; }
  .fwd-item { padding: 9px 8px; }
  .fwd-chip { max-width: 150px; }
}

/* ===== GROUPS: who wrote each message inside a WhatsApp group ===== */
.msg .g-sender { font-size: 12.5px; font-weight: 600; line-height: 1.3; margin-bottom: 2px; }
.msg.out .g-sender { display: none; } /* our own messages need no name */

/* ================= CHAT INSIGHTS & MARKETING ================= */
.in-kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.in-kpis .kpi.warn .v { color: var(--danger-text); }
.table.dt.in-table td { white-space: normal; vertical-align: top; }
.table.dt.in-table td.num { white-space: nowrap; }
.table.dt.in-table td:last-child { text-align: start; }
.table.dt.in-table td.num:last-child, .table.dt.in-table th.num:last-child { text-align: end; }
.table.dt.in-table td:first-child { white-space: nowrap; }
.in-wrap { min-width: 220px; max-width: 420px; line-height: 1.45; }
.in-next { font-weight: 600; color: var(--text); }
.in-none { color: var(--danger-text); font-weight: 600; }
.in-row-warn td { background: var(--danger-bg2); }
a.in-chat { color: var(--accent-text); font-weight: 600; text-decoration: none; }
a.in-chat:hover { text-decoration: underline; }
a.in-chat.gone { color: var(--muted); text-decoration: line-through; }
.in-chats { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: 13.5px; }
.in-list { margin: 0; padding-block: 12px 14px; padding-inline: 34px 16px; display: grid; gap: 7px; line-height: 1.5; }
.in-limits { color: var(--muted); font-size: 13.5px; border-top: 1px solid var(--line); }
.in-finds { display: grid; gap: 0; }
.in-find { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); }
.in-find:last-child { border-bottom: 0; }
.in-find h4 { margin: 0 0 3px; font-size: 15.5px; color: var(--text); }
.in-find p { margin: 0; line-height: 1.5; max-width: 980px; }
.in-find .in-idea { margin-top: 5px; color: var(--text); }
.in-share { font-size: 12px; font-weight: 600; color: #fff; background: var(--teal); border-radius: 999px; padding: 1px 8px; margin-inline-start: 4px; vertical-align: 2px; }
.in-warns { display: grid; }
.in-warn { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); align-items: flex-start; }
.in-warn:last-child { border-bottom: 0; }
.in-warn p { margin: 2px 0 0; line-height: 1.5; max-width: 980px; }
.in-warn-top { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.in-sev { flex: none; width: 66px; text-align: center; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-radius: 6px; padding: 3px 0; color: #fff; background: #64748b; }
.in-warn.high .in-sev { background: #dc2626; }
.in-warn.medium .in-sev { background: #d97706; }
.in-warn.good .in-sev { background: #16a34a; }
.in-temp { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-radius: 6px; padding: 3px 8px; color: #fff; background: #64748b; }
.in-temp.hot { background: #dc2626; }
.in-temp.warm { background: #d97706; }
.in-bars-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 28px; padding: 14px 16px 16px; }
.in-bars h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.in-bar { display: grid; grid-template-columns: minmax(90px, 40%) 1fr auto; gap: 8px; align-items: center; font-size: 14px; padding: 3px 0; }
.in-bar-k { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.in-bar-v { font-variant-numeric: tabular-nums; min-width: 62px; text-align: end; }
.in-bar-v small { color: var(--muted); }
#inWarnCount:empty { display: none; }
@media (max-width: 1300px) { .in-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 820px) {
  .in-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .in-bars-grid { grid-template-columns: 1fr; }
  #inTabs { max-width: 100%; overflow-x: auto; }
  .in-warn { flex-direction: column; gap: 6px; }
  .in-wrap { min-width: 180px; }
}

/* ================= URGENT TO REPLY ================= */
.rail-btn[data-view="urgent"] svg { color: var(--danger); }
.rail-btn[data-view="urgent"].active svg { color: #fff; }
#ugShow button b { font-size: 12px; font-weight: 700; margin-inline-start: 4px; opacity: .8; }
#ugShow button b:empty { display: none; }
.ug-sec .an-card-head h3 { display: flex; align-items: center; gap: 8px; }
.ug-n { font-size: 12.5px; font-weight: 700; color: #fff; background: #64748b; border-radius: 999px; padding: 1px 9px; }
.ug-sec.complaint .ug-n { background: #dc2626; }
.ug-sec.hot .ug-n { background: #d97706; }
.ug-item { display: flex; gap: 16px; align-items: flex-start; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); border-inline-start: 4px solid transparent; }
.ug-item:last-child { border-bottom: 0; }
.ug-item.p1 { border-inline-start-color: #dc2626; }
.ug-item.p2 { border-inline-start-color: #d97706; }
.ug-item.is-done { opacity: .72; border-inline-start-color: #16a34a; }
.ug-main { flex: 1; min-width: 0; }
.ug-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
a.ug-name { font-size: 16px; font-weight: 700; color: var(--accent-text); text-decoration: none; }
a.ug-name:hover { text-decoration: underline; }
.ug-owner { font-size: 13px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 9px; }
.ug-none { color: var(--danger-text); font-weight: 600; }
.ug-note { margin: 6px 0 0; line-height: 1.6; max-width: 900px; color: var(--text); }
.ug-next, .ug-donenote { margin: 4px 0 0; line-height: 1.6; max-width: 900px; }
.ug-next { font-weight: 600; color: var(--text); }
.ug-foot { margin-top: 7px; font-size: 13px; }
.ug-state { color: var(--muted); }
.ug-state.wait { color: var(--danger-text); font-weight: 600; }
.ug-state.wrote { color: var(--accent-text); font-weight: 600; }
.ug-state.done { color: #16a34a; font-weight: 600; }
.ug-acts { display: flex; flex-direction: column; gap: 6px; flex: none; }
.ug-acts .btn { text-align: center; text-decoration: none; }
.ug-del { color: var(--muted); }
/* the two lists: tabs on the page + the small menu beside "Urgent to reply" in the left menu (mouse over it) */
.ug-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; background: #64748b; }
.ug-dot.complaint { background: #dc2626; }
.ug-dot.hot { background: #d97706; }
.ug-kinds { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 10px 0 14px; }
.ug-kinds button { display: inline-flex; align-items: center; gap: 9px; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; background: transparent; padding: 10px 14px 9px; border-radius: 8px 8px 0 0; font-size: 16px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.ug-kinds button:hover { background: var(--hover); color: var(--text); }
.ug-kinds button.active { color: var(--brand-text); border-bottom-color: var(--brand-text); }
.ug-kinds b, .fly-n { font-size: 12px; font-weight: 700; color: #fff; background: #64748b; border-radius: 999px; padding: 1px 8px; min-width: 22px; text-align: center; line-height: 1.5; }
.ug-kinds b:empty, .fly-n:empty { display: none; }
.ug-kinds [data-k="complaint"] b, .fly-n.complaint { background: #dc2626; }
.ug-kinds [data-k="leads"] b, .fly-n.leads { background: #d97706; }
.rail-fly { z-index: 45; min-width: 280px; }
.rail-fly .mi { min-height: 40px; font-weight: 500; }
.rail-fly .mi.current { background: var(--sel-bg); color: var(--sel-text); }
.rail-btn[data-view="urgent"][aria-expanded="true"]:not(.active) { background: var(--side-hover); color: var(--text); }
@media (max-width: 820px) {
  .rail-fly { display: none !important; }
  .ug-kinds { margin: 8px -16px 12px; padding: 0 8px; }
  .ug-kinds button { flex: 1 1 0; min-width: 0; justify-content: center; white-space: normal; text-align: center; line-height: 1.25; padding: 9px 6px 8px; font-size: 15px; gap: 7px; }
  .ug-item { flex-direction: column; gap: 10px; }
  .ug-acts { flex-direction: row; flex-wrap: wrap; }
  #view-urgent .page-head { flex-wrap: wrap; }
}

/* ================= AUTOMATIC READING (Claude) ================= */
.ai-bar { display: flex; align-items: center; gap: 10px; padding: 9px 12px; margin: 0 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font-size: 14px; line-height: 1.45; }
.ai-bar:empty { display: none; }
.ai-bar .ai-text { flex: 1; min-width: 0; color: var(--text-2); }
.ai-bar .ai-text b { color: var(--text); }
.ai-bar .btn { flex: none; }
.ai-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--muted-2); }
.ai-bar.on .ai-dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, .2); }
.ai-bar.test .ai-dot { background: #d97706; box-shadow: 0 0 0 3px rgba(217, 119, 6, .2); }
.ai-bar.run .ai-dot { background: var(--teal); animation: ai-pulse 1s ease-in-out infinite alternate; }
@keyframes ai-pulse { from { opacity: .35; } to { opacity: 1; } }
.ai-err { display: block; color: var(--danger-text); font-weight: 600; margin-top: 2px; }
.in-draft { display: inline-block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-radius: 6px; padding: 2px 8px; color: #fff; background: #d97706; margin-inline-end: 4px; }
#inNote .btn { margin-inline-start: 4px; vertical-align: 1px; }
.ai-form .row { justify-content: space-between; align-items: center; }
.ai-form .row.ai-now { justify-content: flex-start; flex-wrap: wrap; }
.ai-modes { display: grid; gap: 8px; }
.dialog-form label.ai-mode { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 400; }
.ai-mode.on { border-color: var(--brand); background: var(--blue-soft); }
.ai-mode input { margin-top: 3px; flex: none; width: auto; }
.ai-mode span { display: grid; gap: 2px; }
.ai-mode small { color: var(--text-2); font-size: 13.5px; line-height: 1.4; }
.ai-form code { background: var(--hover-2); border-radius: 4px; padding: 1px 5px; font-size: 13px; }
.ai-log { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; max-height: 340px; overflow-y: auto; }
.ai-log li { display: grid; grid-template-columns: 118px 126px 1fr; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; align-items: start; }
.ai-log li:last-child { border-bottom: 0; }
.ai-when { color: var(--muted); font-variant-numeric: tabular-nums; }
.ai-tag { justify-self: start; font-size: 11.5px; font-weight: 700; border-radius: 6px; padding: 2px 8px; color: #fff; background: #64748b; white-space: nowrap; }
.ai-tag.complaint, .ai-tag.err { background: #dc2626; }
.ai-tag.hot { background: #d97706; }
.ai-tag.waiting { background: var(--teal); }
.ai-tag.night { background: var(--brand); }
.ai-note, .ai-why { display: block; margin-top: 2px; }
.ai-why { color: var(--muted); }
.ug-auto { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-radius: 5px; padding: 1px 6px; color: var(--accent-text); background: var(--blue-soft); cursor: help; }
html[data-theme="dark"] .ug-auto { color: var(--teal-light); }
@media (max-width: 820px) {
  .ai-bar { flex-wrap: wrap; }
  .ai-log li { grid-template-columns: 1fr; gap: 3px; }
}
#aiErr:empty { display: none; }

/* ===== AI BRIEF: "✨ AI summary" at the top of a chat (public/js/brief.js) ===== */
.brief { flex: none; background: var(--panel); border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.5; }
.brief.hidden { display: none; }
.brief-head { display: flex; align-items: center; gap: 8px; padding-block: 6px 6px; padding-inline: 14px 10px; min-height: 38px; }
.brief.closed .brief-head { cursor: pointer; }
.brief-title { flex: none; font-weight: 700; color: var(--brand-text); }
.brief-peek { flex: 1; min-width: 0; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brief-gap { flex: 1; }
.brief-actions { flex: none; display: flex; align-items: center; gap: 2px; }
.brief-when, .brief-busy { color: var(--muted); font-size: 13px; margin-inline-end: 6px; white-space: nowrap; }
.brief-busy { color: var(--accent-text); font-weight: 600; }
.brief-btn { border: 0; background: none; color: var(--accent-text); font: inherit; font-size: 13.5px; padding: 4px 7px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.brief-btn:hover { background: var(--hover-2); }
.brief-toggle { font-size: 15px; color: var(--muted); }
.brief-chip { flex: none; font-size: 12.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.brief-chip.wait-us { background: var(--danger-bg2); color: var(--danger-text); }
.brief-chip.wait-them { background: var(--info-bg); color: var(--info-text); }
.brief-chip.sug { background: var(--cf-bg); color: var(--cf-text); }
.brief-body { padding: 0 14px 10px; max-height: min(38vh, 340px); overflow-y: auto; }
.brief-body p { margin: 0 0 6px; }
.brief-sum { color: var(--text); }
.brief-next { color: var(--text); background: var(--blue-soft); border-radius: 8px; padding: 5px 9px; }
.brief-next b { color: var(--brand-text); }
.brief-sub { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin: 8px 0 4px; }
.brief-dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 14px; margin: 0; }
.brief-dl div { min-width: 0; }
.brief-dl dt { font-size: 12.5px; color: var(--muted); }
.brief-dl dd { margin: 0; color: var(--text); overflow-wrap: anywhere; text-align: start; }
.brief-missing { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 6px; font-size: 13px; color: var(--text-2); }
.brief-miss { background: var(--warn-bg); color: var(--warn-text); border-radius: 999px; padding: 0 8px; font-weight: 600; font-size: 12.5px; }
.brief-labels { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.brief-labels .brief-sub { width: 100%; margin-bottom: 0; }
.brief-sug { display: inline-flex; align-items: center; gap: 3px; border: 1px dashed var(--line-2); border-radius: 999px; padding-block: 2px 2px; padding-inline: 2px 3px; }
.brief-sug.remove .tag { opacity: .75; text-decoration: line-through; }
.brief-sug button { border: 0; width: 24px; height: 24px; border-radius: 50%; cursor: pointer; font-size: 13px; line-height: 1; background: var(--hover-2); color: var(--text-2); }
.brief-sug .brief-yes:hover { background: var(--ok-bg); color: var(--ok-text); }
.brief-sug .brief-no:hover { background: var(--danger-bg2); color: var(--danger-text); }
.brief-why { width: 100%; font-size: 13px; color: var(--muted); text-align: start; }
.brief-stale { font-size: 13px; color: var(--warn-text); }
.brief-err { color: var(--danger-text); font-size: 13.5px; }
.brief-foot { font-size: 12px; color: var(--muted-2); margin: 6px 0 0 !important; }
@media (max-width: 820px) {
  .brief-head { padding-block: 4px 4px; padding-inline: 12px 6px; gap: 4px 6px; flex-wrap: wrap; }
  .brief:not(.closed) .brief-actions { margin-inline-start: auto; }
  .brief.closed .brief-chip { display: none; }
  .brief-when, .brief.closed .brief-chip.sug { display: none; }
  .brief-btn { padding: 6px 7px; }
  .brief-body { max-height: 30vh; }
  .brief-dl { grid-template-columns: 1fr 1fr; }
}

/* ===================== INSTAGRAM DIRECT ===================== */
/* Instagram's colours, used only to mark Instagram chats and buttons */
:root { --ig-grad: linear-gradient(45deg, #f9ce34 0%, #ee2a7b 45%, #6228d7 100%); --ig-pink: #d6249f; }
.ig-glyph { display: inline-block; width: 15px; height: 15px; border-radius: 5px; background: var(--ig-grad); position: relative; vertical-align: -2px; margin-inline-end: 6px; flex: none; }
.ig-glyph::before { content: ''; position: absolute; inset: 3.5px; border: 1.6px solid #fff; border-radius: 50%; }
.ig-glyph::after { content: ''; position: absolute; width: 2.4px; height: 2.4px; top: 2px; inset-inline-end: 2px; background: #fff; border-radius: 50%; }
.avatar { position: relative; }
.avatar .ig-dot { position: absolute; inset-inline-end: -2px; bottom: -2px; width: 16px; height: 16px; border-radius: 6px; background: var(--ig-grad); border: 2px solid var(--panel); box-sizing: border-box; }
.avatar .ig-dot::before { content: ''; position: absolute; inset: 3px; border: 1.3px solid #fff; border-radius: 50%; }
.chat-item.selected .avatar .ig-dot, .chat-item.active .avatar .ig-dot { border-color: var(--sel-bg); }
.ig-bar { display: flex; align-items: flex-start; gap: 4px; padding: 7px 14px; font-size: 13.5px; line-height: 1.35; background: #fdf2fa; color: #86198f; border-top: 1px solid #f5d0e9; }
.ig-bar .ig-glyph { margin-top: 1px; }
.ig-bar.soon { background: var(--warn-bg); color: var(--warn-text); border-top-color: #fde68a; }
.ig-bar.closed { background: var(--danger-bg); color: var(--danger-text); border-top-color: var(--danger-line); }
html[data-theme="dark"] .ig-bar { background: #3b1838; color: #f5c2e7; border-top-color: #5b2553; }
html[data-theme="dark"] .ig-bar.soon { background: var(--warn-bg); color: var(--warn-text); }
html[data-theme="dark"] .ig-bar.closed { background: var(--danger-bg); color: var(--danger-text); }
/* window closed: the reply box is greyed out (notes still work — they switch the mode back) */
.composer.ig-closed #text, .composer.ig-closed #micBtn, .composer.ig-closed label.icon-btn { opacity: .45; }
.composer.ig-closed #sendBtn { opacity: .55; cursor: not-allowed; }
.btn.ig-btn { border-color: #e9b8d9; color: var(--ig-pink); }
.btn.ig-btn:hover { background: #fdf2fa; }
html[data-theme="dark"] .btn.ig-btn { color: #f5a3d9; border-color: #6b2d60; }
html[data-theme="dark"] .btn.ig-btn:hover { background: #3b1838; }
.card.ig-card h3 { display: flex; align-items: center; }
.status.token_error { background: var(--danger-bg2); color: var(--danger-text); }
.meta-copy { display: grid; gap: 6px; margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--head-bg); }
.meta-copy code { font-size: 12.5px; word-break: break-all; background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }
.ig-steps { margin: 6px 0 10px; padding-inline-start: 20px; }
.ig-steps li { margin-bottom: 4px; }
#igToken { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
@media (max-width: 820px) {
  #view-numbers .page-head .row.gap { flex-wrap: wrap; }
  .ig-bar { font-size: 13px; padding: 6px 10px; }
}

/* ===== OLD NUMBERS (history only, src/archive.js) and the AI AGENT (src/ai/agent.js) ===== */
.arch-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; padding: 7px 14px; font-size: 13.5px; line-height: 1.35; background: var(--hover-2); color: var(--text-2); border-top: 1px solid var(--line); }
.arch-bar.hidden, .agent-bar.hidden { display: none; }
.arch-live { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.arch-live .btn { text-decoration: none; }
.composer.arch-closed #text, .composer.arch-closed #micBtn, .composer.arch-closed label.icon-btn { opacity: .45; }
.composer.arch-closed #sendBtn { opacity: .55; cursor: not-allowed; }
.agent-bar { padding: 7px 14px; font-size: 13.5px; line-height: 1.35; background: var(--blue-soft); color: var(--accent-text); border-bottom: 1px solid var(--line); }
html[data-theme="dark"] .agent-bar { color: var(--teal-light); }
.ns-sub { padding: 12px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2); }
.num-pill.arch { color: var(--muted); }
.filter-pane .num-pill.arch { color: var(--muted); font-style: normal; }
.filter-pane .num-pill.arch.active { color: #fff; }
.status.archive { background: var(--hover-2); color: var(--text-2); }
.arch-card h3 { color: var(--text-2); }
.by.src.agent { color: var(--accent-text); font-weight: 600; }
html[data-theme="dark"] .by.src.agent { color: var(--teal-light); }
.agent-accounts { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.agent-accounts label.chk { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }
.agent-accounts input { width: auto; }
.agent-log .agent-msg { margin: 3px 0; padding: 5px 9px; border-radius: 8px; background: var(--hover-2); white-space: pre-wrap; }
.agent-log a.agent-chat { font-weight: 600; }
#agentErr:empty { display: none; }

/* ===================== SAAS: sign-in screens, status bar, settings, plan & billing, first steps ===================== */
.login-card.auth-card { max-width: 420px; box-sizing: border-box; }
.auth-card > img { margin: 0 auto; }
#authBody { min-width: 0; }
.auth-form { display: grid; gap: 10px; text-align: start; margin-top: 10px; }
.auth-form label { display: grid; gap: 4px; font-size: 14px; font-weight: 500; }
.login-card .auth-form label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; font-size: 13px; line-height: 1.4; }
.auth-form label.check input { margin-top: 3px; flex: none; }
.auth-form input:not([type=checkbox]) { width: 100%; box-sizing: border-box; }
.auth-form p { margin: 2px 0; }
.auth-links { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 14px; margin-top: 4px; }
.auth-links a { color: var(--accent-text); }

.banner { position: fixed; top: 0; inset-inline-start: 0; inset-inline-end: 0; z-index: 40; min-height: 40px; box-sizing: border-box; display: flex; align-items: center; justify-content: center;
  padding: 6px 14px; font-size: 14px; text-align: center; background: var(--info-bg); color: var(--info-text); border-bottom: 1px solid var(--line); }
.banner > span { line-height: 1.6; }
.banner .btn { margin-inline-start: 8px; vertical-align: middle; }
.banner.warn { background: var(--warn-bg); color: var(--warn-text); }
.banner.danger { background: var(--danger-bg2); color: var(--danger-text); }
.banner .sep { opacity: .5; }
.banner .btn.pulse { animation: pulse 1s ease-in-out 3; }
@keyframes pulse { 50% { transform: scale(1.08); } }
body.has-banner .app { padding-top: 40px; box-sizing: border-box; }
@media (max-width: 820px) { .banner { font-size: 13px; } body.has-banner .app { padding-top: 56px; } }

.pill-owner { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--cf-bg); color: var(--cf-text); border: 1px solid var(--cf-line); vertical-align: 1px; }
.invite-link { margin: 10px 0 16px; padding: 10px 12px; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn-text); font-size: 14px; }
.invite-link input { width: min(560px, 100%); margin-block: 6px 0; margin-inline: 0 6px; }
#view-team h3 { margin: 22px 0 8px; }

.ws-box { margin: 18px 0; }
.ws-list { list-style: none; padding: 0; margin: 8px 0 12px; max-width: 560px; }
.ws-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 6px; background: var(--panel); }
.ws-list li.current { border-color: var(--brand); }
#profileForm label { display: inline-flex; gap: 8px; align-items: center; }

.set-body { display: grid; gap: 16px; max-width: 860px; margin-top: 12px; }
.set-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.set-card h3 { margin: 0 0 10px; font-size: 16px; }
.set-row { display: grid; grid-template-columns: minmax(200px, 1fr) minmax(220px, 1.2fr); gap: 6px 18px; align-items: start; padding: 9px 0; border-top: 1px solid var(--line-soft); }
.set-row:first-of-type { border-top: 0; }
.set-row > span { display: grid; gap: 2px; }
.set-row small { font-size: 12.5px; line-height: 1.35; }
.set-row input:not([type=checkbox]):not([type=color]):not([type=file]), .set-row select, .set-row textarea { width: 100%; box-sizing: border-box; }
.set-row.toggle { grid-template-columns: auto 1fr; align-items: start; cursor: pointer; }
.set-row.toggle input { margin-top: 3px; width: 18px; height: 18px; }
.set-row > .unit, .unit { display: inline-flex; align-items: center; gap: 6px; }
.set-row > .logo-pick { display: inline-flex; }
.unit input { width: 90px !important; }
.logo-pick { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.logo-pick img { border-radius: 8px; border: 1px solid var(--line); object-fit: contain; background: #fff; }
.danger-zone { border-color: var(--danger-line); }
@media (max-width: 820px) { .set-row { grid-template-columns: 1fr; } }

.bill-now { display: flex; gap: 24px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 12px 0 16px; }
.bill-now h3 { font-size: 20px; margin: 0; }
.bill-use { display: grid; gap: 6px; min-width: 260px; font-size: 14px; }
.use-bar { display: block; height: 6px; border-radius: 99px; background: var(--hover-2); margin-top: 3px; overflow: hidden; }
.use-bar i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.bill-alert { padding: 10px 14px; border-radius: var(--radius); background: var(--danger-bg2); color: var(--danger-text); }
.bill-cycle { align-items: center; margin: 4px 0 12px; flex-wrap: wrap; }
.bill-cycle .save { font-size: 11px; font-weight: 700; color: var(--ok-text); }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 16px; }
.plan { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.plan.popular { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; }
.plan.current { background: var(--sel-bg); }
.plan .tag { position: absolute; top: -10px; inset-inline-end: 14px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.plan h3 { margin: 0; }
.plan .price b { font-size: 28px; }
.plan .price span { color: var(--muted); font-size: 13px; margin-inline-start: 4px; }
.plan ul { margin: 4px 0 10px; padding-inline-start: 18px; font-size: 14px; flex: 1; }
.plan li { margin: 3px 0; }
#view-billing .set-card { margin-bottom: 14px; }
#view-billing .row.gap input[type=number] { width: 80px; }

.onboard { margin: 10px 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.onboard .ob-head { display: flex; align-items: center; gap: 8px; }
.onboard .ob-head .icon-btn { margin-inline-start: auto; }
.ob-toggle { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; min-height: 36px; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: start; cursor: pointer; }
.ob-chev { font-size: 18px; line-height: 1; color: var(--muted); transform: rotate(180deg); transition: transform .15s; }
.onboard.ob-folded .ob-chev { transform: none; }
.onboard .ob-next { display: none; }
.onboard.ob-folded .ob-next { display: block; width: 100%; padding: 2px 0 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 14px; text-align: start; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.onboard.ob-folded ol { display: none; }
.onboard.ob-folded { padding-block: 6px 8px; }
.onboard ol { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.onboard li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line-soft); }
.onboard li > span:nth-child(2) { display: grid; flex: 1; font-size: 14px; }
.onboard li small { font-size: 12.5px; }
.onboard li.ok b { text-decoration: line-through; color: var(--muted); }
.ob-check { width: 20px; height: 20px; flex: none; border-radius: 50%; border: 2px solid var(--line-2); display: grid; place-items: center; font-size: 12px; color: #fff; }
.onboard li.ok .ob-check { background: var(--ok); border-color: var(--ok); }
.btn.link { background: none; border-color: transparent; color: var(--accent-text); }

/* what the platform or the company's plan does not include */
body.no-instagram .ig-btn, body.no-instagram #metaAppBtn, body.no-instagram #addIgBtn { display: none !important; }
body.no-instagram .ig-on-only, body:not(.no-instagram) .ig-off-only { display: none !important; }
body.no-ai #aiBar, body.no-ai #aiBrief, body.no-ai-agent #agentBtn { display: none !important; }
body.no-calls .rail-btn[data-view="calls"] > span::after, body.no-export .rail-btn[data-view="export"] > span::after { content: ' 🔒'; font-size: 11px; }
.set-body, .set-card, .set-row > * { min-width: 0; }
.set-row select, .set-row input, .set-row textarea { max-width: 100%; }
@media (max-width: 820px) { .set-body { margin-top: 8px; } .set-card { padding: 14px; } #view-settings .page-head { position: sticky; top: -16px; z-index: 2; background: var(--bg); padding: 8px 0; } }

/* ---------- language (English / Arabic) ---------- */
/* the small switch under the sign-in card */
.lang-switch { display: flex; justify-content: center; gap: 4px; margin-top: 2px; }
.lang-switch button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; padding: 4px 9px; border-radius: 6px; cursor: pointer; }
.lang-switch button.active { color: var(--brand-text); font-weight: 600; background: var(--bg); }
/* right-to-left: Arabic letters in a clear system font; e-mails, phones, passwords and links are typed left-to-right */
[dir=rtl] { --font: "Source Sans 3", "Segoe UI", Tahoma, "Noto Sans Arabic", "Geeza Pro", system-ui, sans-serif; }
[dir=rtl] input[type=email], [dir=rtl] input[type=tel], [dir=rtl] input[type=url], [dir=rtl] input[type=password], [dir=rtl] .ltr { direction: ltr; text-align: end; unicode-bidi: isolate; }
[dir=rtl] .inbox.fp-float .filter-pane { animation-name: fp-in-rtl; }
@keyframes fp-in-rtl { from { transform: translateX(14px); opacity: 0; } }
/* names and last messages written in English still line up on the right in the Arabic chat list */
[dir=rtl] .chat-item [dir=auto] { text-align: right; }

/* ---------- two-step sign-in (js/twostep.js) ---------- */
.ts-on { color: var(--green); font-weight: 600; }
.ts-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ts-setup { margin-top: 12px; display: grid; gap: 8px; justify-items: start; }
.ts-steps { margin: 0; padding-inline-start: 20px; }
.ts-qr { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 6px; }
.ts-key { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--bg); padding: 2px 6px; border-radius: 5px; letter-spacing: .04em; }
.ts-codes { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 0; columns: 2; column-gap: 28px; }
.code-input { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .15em; font-size: 18px; max-width: 160px; direction: ltr; text-align: center; }
#tsForced .ts-setup { justify-items: center; text-align: center; }

/* ---------- import from TimelinesAI / Wassenger (js/import.js) ---------- */
.im-card { margin-bottom: 14px; max-width: 980px; }
.im-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.im-row label { display: grid; gap: 4px; font-size: 13px; font-weight: 500; }
.im-row .grow { flex: 1; min-width: 220px; }
.im-row input, .im-row select, #imPlan select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.im-opts { display: grid; gap: 8px; margin: 12px 0; }
.im-opts label { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.lbl-chip { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); }

/* ---------- AI agent window: what it says, when it answers ---------- */
.agent-setup { display: grid; gap: 10px; margin-top: 6px; }
.agent-setup > label { display: grid; gap: 4px; font-size: 13px; font-weight: 500; }
.agent-setup input:not([type=radio]):not([type=checkbox]), .agent-setup textarea, .agent-setup select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.agent-hours { display: grid; gap: 6px; }
.agent-hours-detail { display: none; gap: 8px; flex-wrap: wrap; align-items: center; padding-inline-start: 24px; }
.agent-setup.hours-outside .agent-hours-detail { display: flex; }
.agent-days { display: flex; flex-wrap: wrap; gap: 4px 12px; }
