/* A Travels Inbox
   Glass dashboard over a wallpaper (Figma: "Sidebar Navigation Menu for Dashboard",
   dark + light). Frosted sidebar that collapses to a rail, a glass workspace, a
   mobile tab bar. Tokens first, then components. `--indigo` is the accent slot
   (A Travels royal blue); the name is kept so component rules stay unchanged. */

:root {
  /* Layer scale (fixed overlays). Tooltips sit on top of everything they can point at. */
  --z-tabbar: 1040; --z-dialog: 1070; --z-popover: 1090; --z-call: 1095; --z-notify: 1100; --z-tooltip: 1110;
  --indigo: #1E5BB8;
  --indigo-strong: #174A96;
  --teal: #3F8F55;
  --amber: #B7791F;
  --rose: #C8433A;

  --ink: #14213D;
  --ink-soft: rgba(20, 33, 61, .58);
  --ink-mute: rgba(20, 33, 61, .42);
  --paper: #A9C6F4;
  --surface: rgba(255, 255, 255, .34);
  --surface-2: rgba(20, 33, 61, .04);
  --surface-solid: #E8F0FD;
  --bubble: rgba(255, 255, 255, .62);
  --line: rgba(20, 33, 61, .09);
  --shadow: 0 1px 2px rgba(0, 37, 102, .08), 0 12px 32px rgba(0, 37, 102, .14);
  --shadow-sm: 0 1px 2px rgba(0, 37, 102, .1);

  --glass: rgba(218, 232, 255, .52);
  --glass-border: rgba(235, 241, 250, .4);
  --glass-shadow: 0 64px 64px -32px rgba(0, 37, 102, .56);
  --glass-blur: blur(80px) saturate(1.2);
  --glow: rgba(139, 170, 230, .9);
  --active-bg: rgba(20, 33, 61, .04);
  --active-border: rgba(235, 241, 250, .16);
  --active-shadow: none;
  --accent-shadow: 0 4px 12px rgba(6, 70, 204, .3);
  --wallpaper: url("/static/img/bg-light.jpg?v=blue");
  --paper-fill: #79A3E0;  /* the wallpaper's average colour: shown until it is decoded */

  --side-w: 256px;
  --side-rail: 104px;
  --gap: 12px;
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xl: 28px;
  --ease: cubic-bezier(.22, .61, .36, 1);

  --s-new-fg: #8A5B00;         --s-new-bg: #FDF0D5;
  --s-in_progress-fg: #1E5BB8; --s-in_progress-bg: #E3EDFC;
  --s-quoted-fg: #6B3FB8;      --s-quoted-bg: #F0E9FC;
  --s-follow_up-fg: #0B7C68;   --s-follow_up-bg: #DEF3EE;
  --s-won-fg: #1D7A41;         --s-won-bg: #E1F4E7;
  --s-lost-fg: #5C6577;        --s-lost-bg: #ECEFF4;

  --font-ui: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-script: "Noto Naskh Arabic", "Segoe UI", Tahoma, sans-serif;

  --bs-body-font-family: var(--font-ui);
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--paper);
  --bs-border-color: var(--line);
  --bs-link-color: var(--indigo);
  --bs-link-hover-color: var(--indigo-strong);
  --bs-focus-ring-color: rgba(30, 91, 184, .28);
}

[data-bs-theme="dark"] {
  --indigo: #4C8DF0;
  --indigo-strong: #6FA3F5;
  --teal: #7FBA7A;
  --amber: #E0AB62;
  --rose: #F07A6E;

  --ink: #FFFFFF;
  --ink-soft: rgba(255, 255, 255, .58);
  --ink-mute: rgba(255, 255, 255, .34);
  --paper: #070E1C;
  --surface: rgba(255, 255, 255, .025);
  --surface-2: rgba(255, 255, 255, .05);
  --surface-solid: #0F1A2E;
  --bubble: rgba(8, 13, 24, .6);
  --line: rgba(110, 150, 220, .2);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 40px rgba(0, 12, 41, .5);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);

  --glass: rgba(8, 13, 24, .56);
  --glass-border: rgba(110, 150, 220, .55);
  --glass-shadow: 0 64px 64px -32px rgba(0, 12, 41, .56);
  --active-bg: rgba(255, 255, 255, .03);
  --active-border: rgba(110, 150, 220, .55);
  --active-shadow: 0 0 16px rgba(255, 255, 255, .6);
  --accent-shadow: 0 4px 12px rgba(5, 60, 168, .3);
  --wallpaper: url("/static/img/bg-dark.jpg?v=blue");
  --paper-fill: #122A56;

  --s-new-fg: #F1C270;         --s-new-bg: rgba(241, 194, 112, .14);
  --s-in_progress-fg: #8DB8F7; --s-in_progress-bg: rgba(76, 141, 240, .18);
  --s-quoted-fg: #C5B6F5;      --s-quoted-bg: rgba(150, 125, 230, .18);
  --s-follow_up-fg: #9ED8C4;   --s-follow_up-bg: rgba(116, 220, 194, .12);
  --s-won-fg: #A6DDA2;         --s-won-bg: rgba(127, 186, 122, .16);
  --s-lost-fg: rgba(255, 255, 255, .6); --s-lost-bg: rgba(255, 255, 255, .06);

  --bs-secondary-color: var(--ink-soft);
  --bs-emphasis-color: var(--ink);
}

html { background: var(--paper-fill); }
body { font-size: 14px; line-height: 1.45; background: var(--paper-fill) var(--wallpaper) center / cover fixed no-repeat; color: var(--ink); -webkit-font-smoothing: antialiased; }
:where([dir="auto"], .bubble-text, .conv-preview) { font-family: var(--font-ui), var(--font-script); }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.btn-primary {
  --bs-btn-bg: var(--indigo); --bs-btn-border-color: var(--indigo);
  --bs-btn-hover-bg: var(--indigo-strong); --bs-btn-hover-border-color: var(--indigo-strong);
  --bs-btn-active-bg: var(--indigo-strong); --bs-btn-active-border-color: var(--indigo-strong);
  --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff;
  --bs-btn-disabled-bg: color-mix(in srgb, var(--indigo) 55%, var(--surface-solid));
  --bs-btn-disabled-border-color: transparent; --bs-btn-disabled-color: #fff;
  --bs-btn-font-weight: 600; --bs-btn-border-radius: var(--radius-sm);
  box-shadow: var(--accent-shadow);
}
.btn-outline-secondary { --bs-btn-color: var(--ink-soft); --bs-btn-border-color: var(--line); --bs-btn-hover-bg: var(--surface-2); --bs-btn-hover-color: var(--ink); --bs-btn-hover-border-color: var(--line); --bs-btn-border-radius: 10px; }
.form-control, .form-select { background-color: var(--surface); color: var(--ink); border-color: var(--line); border-radius: 10px; }
.form-control:focus, .form-select:focus { border-color: var(--indigo); box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); background-color: var(--surface); color: var(--ink); }
.form-control::placeholder { color: var(--ink-mute); }
.form-select option { background: var(--surface-solid); color: var(--ink); }
.form-check-input:checked { background-color: var(--indigo); border-color: var(--indigo); }
.modal-content, .offcanvas, .dropdown-menu { background: var(--surface-solid); color: var(--ink); border-color: var(--glass-border); }
.modal-content { border-radius: var(--radius-xl); box-shadow: var(--glass-shadow); }
.modal-header, .modal-footer { border-color: var(--line); }
.table { --bs-table-bg: transparent; --bs-table-color: var(--ink); }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: auto 1fr; gap: var(--gap); height: var(--app-h, 100dvh); padding: var(--gap); }

/* Frosted panels: sidebar and workspace float over the wallpaper. */
.sidebar, .workspace {
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius-xl);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
}
/* Every page: fixed header (.page-bar), scrolling <main>, fixed footer (.page-foot or the page's own). */
.workspace { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.workspace > .page-bar, .workspace > .page-foot { flex: none; }
.workspace > main { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.workspace > main.inbox { overflow: hidden; }

.sidebar {
  width: var(--side-w);
  display: flex; flex-direction: column; gap: .25rem;
  padding: 1.5rem 1.5rem 1.25rem;
  position: relative; min-height: 0;
  z-index: 2;  /* its own layer (backdrop-filter) must sit above .workspace, or the rail labels hide behind it */
  transition: width .28s var(--ease), padding .28s var(--ease);
}
.rail .sidebar { width: var(--side-rail); padding-inline: 1.5rem; }
/* Soft glowing hairline used as the design's section divider. */
.sidebar-top::after, .sidebar-foot::before {
  content: ""; position: absolute; left: -1.5rem; right: -1.5rem; height: 1px; opacity: .32;
  background: radial-gradient(closest-side, var(--glow), transparent);
}
.sidebar-top { display: flex; align-items: center; gap: .75rem; padding: 0 0 1.4rem; margin-bottom: .6rem; position: relative; }
.sidebar-top::after { bottom: 0; }
.brand { display: flex; align-items: center; gap: .75rem; color: var(--ink); text-decoration: none; font-weight: 600; letter-spacing: -.01em; font-size: 1rem; min-width: 0; }
.brand:hover { color: var(--ink); }
.brand-text { display: flex; flex-direction: column; line-height: 20px; font-size: 14px; font-weight: 500; text-shadow: var(--active-shadow); }
.brand-text small { font-size: 11px; line-height: 22px; letter-spacing: .4px; text-transform: uppercase; color: var(--ink-mute); text-shadow: none; }
.brand-mark { width: 40px; height: 40px; border-radius: 50%; background: radial-gradient(circle at 30% 30%, #7FB0F5, var(--indigo) 55%, #0E3470); box-shadow: 0 0 0 3px var(--active-bg), var(--accent-shadow); flex: none; }
.rail-toggle {
  position: absolute; right: -2.25rem; top: 50%; translate: 0 calc(-50% - .7rem);
  border: 1px solid var(--glass-border); background: var(--glass); color: var(--ink-soft);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; padding: 0; z-index: 2;
  transition: color .18s var(--ease), transform .28s var(--ease);
}
.rail-toggle .icon { width: 14px; height: 14px; }
.rail-toggle:hover { color: var(--ink); }
.rail .rail-toggle { transform: rotate(180deg); }

.nav-label { font-size: 11px; font-weight: 500; letter-spacing: .4px; text-transform: uppercase; color: var(--ink-mute); line-height: 24px; padding: 0 1.25rem; white-space: nowrap; }
.rail .nav-label { padding: 0; text-align: center; }
.sidebar-nav { display: flex; flex-direction: column; gap: .1rem; }
.nav-item {
  display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem; border-radius: var(--radius-sm);
  color: var(--ink-soft); text-decoration: none; font-weight: 500; line-height: 20px; position: relative; isolation: isolate;
  white-space: nowrap; overflow: visible; border: .5px solid transparent;
  transition: background .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease);
}
.nav-item .icon { width: 24px; height: 24px; stroke-width: 1.5; }
.nav-item:hover { color: var(--ink); background: var(--active-bg); }
/* Active item: hairline border plus the design's soft pink glow (a gradient, so rail tooltips aren't clipped). */
.nav-item.active {
  border-color: var(--active-border); color: var(--ink); text-shadow: var(--active-shadow);
  background: radial-gradient(60% 120% at 42% 50%, rgba(30, 91, 184, .16), rgba(30, 91, 184, .06) 50%, transparent 80%), var(--active-bg);
}
.rail .nav-item { padding-inline: 0; }
.nav-badge { margin-left: auto; min-width: 22px; text-align: center; padding: 0 .4rem; border-radius: 999px; background: var(--indigo); color: #fff; font-size: .72rem; font-weight: 700; line-height: 1.5; text-shadow: none; box-shadow: var(--accent-shadow); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: .5rem; padding-top: 1.1rem; position: relative; }
.sidebar-foot::before { top: 0; }
.avail { display: flex; align-items: center; gap: .75rem; padding: .4rem 1.25rem; margin: 0; color: var(--ink-soft); font-weight: 500; cursor: pointer; }
.avail .form-check-input { margin: 0; flex: none; }

.theme-toggle { display: flex; align-items: center; gap: .75rem; padding: .4rem 1.25rem; border: 0; background: transparent; color: var(--ink-soft); font-weight: 500; border-radius: var(--radius-sm); }
.theme-toggle:hover { background: var(--active-bg); color: var(--ink); }
.theme-track { position: relative; width: 46px; height: 26px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 5px; flex: none; }
.theme-knob { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--indigo); box-shadow: var(--accent-shadow); transition: transform .28s var(--ease); }
[data-bs-theme="dark"] .theme-knob { transform: translateX(20px); }
.theme-track .icon { width: 13px; height: 13px; position: relative; z-index: 1; }
.theme-sun { color: #fff; }
.theme-moon { color: var(--ink-soft); }
[data-bs-theme="dark"] .theme-moon { color: #fff; }
[data-bs-theme="dark"] .theme-sun { color: var(--ink-soft); }

/* Promo-block look from the design, used for the signed-in user. */
.user-card { display: flex; align-items: center; gap: .6rem; padding: .6rem .7rem; border-radius: 20px; background: var(--surface); border: .5px solid var(--glass-border); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(140deg, #7FB0F5, var(--indigo) 50%, #0E3470); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.user-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.user-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .74rem; color: var(--ink-soft); text-transform: capitalize; }
.icon-btn { border: 0; background: transparent; color: var(--ink-soft); border-radius: 8px; padding: .3rem; display: grid; place-items: center; }
.icon-btn:hover { background: var(--surface); color: var(--ink); }
.user-card .logout { margin-left: auto; }

.nav-text { overflow: hidden; transition: opacity .18s var(--ease); }
.rail .nav-text { opacity: 0; width: 0; }
.rail .nav-item, .rail .avail, .rail .theme-toggle, .rail .user-card { justify-content: center; gap: 0; }
.rail .user-card .logout { display: none; }
.rail .sidebar-top { justify-content: center; }
.rail :is(.avail, .theme-toggle) { padding-inline: 0; }
.rail .user-card { padding: .5rem 0; border-radius: var(--radius-sm); }
.rail .nav-badge { position: absolute; top: .25rem; left: 2rem; margin: 0; min-width: 18px; font-size: .65rem; }
.rail :is(.nav-item, .avail, .theme-toggle, .notify-toggle, .user-card) { position: relative; }
.rail :is(.nav-item, .avail, .theme-toggle, .notify-toggle, .user-card)::after {
  content: attr(data-label); position: absolute; left: calc(100% + .45rem); z-index: 1200;
  background: var(--surface-solid); color: var(--ink); border: 1px solid var(--glass-border); box-shadow: var(--shadow);
  padding: .3rem .6rem; border-radius: 10px; font-size: .78rem; text-shadow: none;
  white-space: nowrap; opacity: 0; pointer-events: none; transform: translateX(-6px);
  transition: opacity .15s var(--ease), transform .15s var(--ease);
}
.rail :is(.nav-item, .avail, .theme-toggle, .notify-toggle, .user-card):hover::after { opacity: 1; transform: translateX(0); }

.tabbar { display: none; }

/* ------------------------------------------------------------------ page header */
.page-bar {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .8rem clamp(.85rem, 2vw, 1.5rem); border-bottom: 1px solid var(--line); background: var(--surface);
}
.page-bar h1 { font-size: 1.15rem; font-weight: 700; margin: 0; letter-spacing: -.015em; }
.page-bar .spacer { margin-left: auto; }
.open-pill { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .6rem; border-radius: 999px; background: var(--surface-2); color: var(--ink-soft); font-size: .8rem; font-weight: 500; }
.open-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); }
.open-pill.is-closed .dot { background: var(--ink-soft); }

/* ------------------------------------------------------------------ inbox */
.inbox { display: grid; grid-template-columns: minmax(300px, 360px) minmax(0, 1fr); flex: 1; min-height: 0; }
.pane-list { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-right: 1px solid var(--line); }
.list-head { padding: .75rem .8rem; border-bottom: 1px solid var(--line); display: grid; gap: .55rem; }
.view-tabs { display: flex; gap: .2rem; background: var(--surface-2); padding: .25rem; border-radius: 12px; }
.view-tabs button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: .4rem .3rem; font-size: .86rem; font-weight: 600; color: var(--ink-soft); transition: background .2s var(--ease), color .2s var(--ease); }
.view-tabs button.active { background: var(--bubble); color: var(--ink); box-shadow: var(--shadow-sm); }
/* Sliding pill (common.js segmentedTabs): one highlight moves from tab to tab instead of each tab fading. */
.view-tabs.has-ind { position: relative; isolation: isolate; }
.view-tabs.has-ind button, .view-tabs.has-ind button.active { background: transparent; box-shadow: none; position: relative; transition: color .2s var(--ease); }
.seg-ind { position: absolute; top: .25rem; bottom: .25rem; left: 0; width: 0; z-index: -1; border-radius: 9px; pointer-events: none;
  background: var(--bubble); box-shadow: var(--shadow-sm); opacity: 0;
  transition: transform .25s var(--ease), width .25s var(--ease); will-change: transform; }
@media (prefers-reduced-motion: reduce) { .seg-ind { transition: none; } }
.tab-count:not(:empty) { display: inline-block; margin-left: .25rem; padding: 0 .35em; border-radius: 999px; background: var(--amber); color: #fff; font-size: .7rem; }
/* Second column fits its label but never more than 55%: a long ad name ends in "…" instead of
   pushing the row past the screen edge. */
.filters { display: grid; grid-template-columns: minmax(0, 1fr) fit-content(55%); gap: .4rem; }
.filters > * { min-width: 0; }
.search-wrap { position: relative; }
.search-wrap .icon { position: absolute; left: .55rem; top: 50%; translate: 0 -50%; width: 16px; height: 16px; color: var(--ink-soft); }
.search-wrap input { padding-left: 2rem; }

.conv-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.conv { display: grid; gap: .2rem; width: 100%; text-align: left; border: 0; background: transparent; color: inherit; padding: .7rem .85rem .7rem 1rem; border-bottom: 1px solid var(--line); position: relative; }
.conv:hover { background: var(--surface-2); }
.conv[aria-current="true"] { background: color-mix(in srgb, var(--indigo) 10%, transparent); }
.conv::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: transparent; }
.conv.is-waiting::before { background: var(--amber); }
.conv.is-overdue::before { background: var(--rose); }
.conv.is-fresh { animation: slide-in .35s var(--ease); }
@keyframes slide-in { from { opacity: 0; transform: translateY(-6px); } }
.conv-top { display: flex; align-items: baseline; gap: .5rem; }
.conv-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-top time { margin-left: auto; font-size: .76rem; color: var(--ink-soft); white-space: nowrap; }
.conv-preview { color: var(--ink-soft); font-size: .87rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin-top: .15rem; font-size: .73rem; }
.unread { margin-left: auto; background: var(--indigo); color: #fff; border-radius: 999px; padding: 0 .45rem; font-weight: 700; }
.tag { border: 1px solid var(--line); border-radius: 6px; padding: 0 .35rem; color: var(--ink-soft); }
.tag-dept { display: inline-flex; align-items: center; gap: .3rem; }
.tag-dept .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.waiting-for { color: var(--amber); font-weight: 600; }
.waiting-for.is-overdue { color: var(--rose); }
.list-empty { padding: 2.5rem 1.25rem; color: var(--ink-soft); text-align: center; }
/* Infinite-scroll sentinel at the end of the chat list. */
.conv-more { list-style: none; padding: .6rem 1rem; }
.conv-more[hidden] { display: none; }
.conv-more-hint { display: block; text-align: center; font-size: .75rem; color: var(--ink-mute); }
.conv-skel { display: grid; gap: .4rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.conv-skel .sk-line { height: 9px; }
/* "Earlier messages" marker at the top of a long thread. */
.older-pill { align-self: center; font-size: .74rem; color: var(--ink-soft); background: var(--bubble); border: 1px dashed var(--line); border-radius: 999px; padding: .15rem .75rem; margin: .2rem 0 .4rem; }

.chip { display: inline-block; border-radius: 6px; padding: .05rem .4rem; font-weight: 600; font-size: .73rem; }
.s-new { color: var(--s-new-fg); background: var(--s-new-bg); }
.s-in_progress { color: var(--s-in_progress-fg); background: var(--s-in_progress-bg); }
.s-quoted { color: var(--s-quoted-fg); background: var(--s-quoted-bg); }
.s-follow_up { color: var(--s-follow_up-fg); background: var(--s-follow_up-bg); }
.s-won { color: var(--s-won-fg); background: var(--s-won-bg); }
.s-lost { color: var(--s-lost-fg); background: var(--s-lost-bg); }

.pane-thread { min-height: 0; display: flex; flex-direction: column; background: transparent; }
.thread-empty { flex: 1; display: grid; place-items: center; color: var(--ink-soft); text-align: center; padding: 2rem; }
.thread { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.thread[hidden] { display: none; }
.thread-head { display: flex; align-items: center; gap: .6rem; padding: .65rem clamp(.7rem, 2vw, 1.1rem); background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.back-btn { display: none; border: 0; background: transparent; color: var(--ink-soft); padding: .25rem; border-radius: 8px; }
.who { min-width: 0; flex: 1; }
.who h1 { font-size: 1.02rem; font-weight: 700; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who p { margin: 0; font-size: .8rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; }
.thread-actions { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.thread-actions .form-select { width: auto; min-width: 8.5rem; }

.reply-window { display: flex; align-items: center; gap: .7rem; padding: .35rem clamp(.7rem, 2vw, 1.1rem); background: var(--surface); border-bottom: 1px solid var(--line); font-size: .78rem; color: var(--ink-soft); }
.reply-window[hidden] { display: none; }
.reply-window-track { flex: 0 0 120px; height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.reply-window-track span { display: block; height: 100%; background: var(--teal); transition: width .6s var(--ease); }
.reply-window.is-low { color: var(--amber); }
.reply-window.is-low .reply-window-track span { background: var(--amber); }
.reply-window.is-closed { color: var(--rose); }
.reply-window.is-closed .reply-window-track span { width: 0 !important; }

.messages { flex: 1; overflow-y: auto; padding: 1rem clamp(.75rem, 3vw, 2rem); display: flex; flex-direction: column; gap: .3rem; }
.day { align-self: center; font-size: .73rem; color: var(--ink-soft); background: var(--bubble); border: 1px solid var(--line); border-radius: 999px; padding: .1rem .65rem; margin: .7rem 0 .35rem; }
.bubble { max-width: min(560px, 84%); padding: .5rem .7rem .3rem; border-radius: 16px; background: var(--bubble); border: .5px solid var(--glass-border); align-self: flex-start; box-shadow: var(--shadow-sm); }
.bubble.out { align-self: flex-end; background: color-mix(in srgb, var(--indigo) 20%, var(--bubble)); border-color: color-mix(in srgb, var(--indigo) 40%, transparent); }
.bubble.automated { background: var(--surface-2); border-style: dashed; }
.bubble.failed { border-color: var(--rose); background: color-mix(in srgb, var(--rose) 14%, var(--bubble)); }
.bubble-text { white-space: pre-wrap; overflow-wrap: anywhere; }
/* Media in bubbles */
.media-link { display: block; margin: -.2rem -.35rem .3rem; border-radius: 12px; overflow: hidden; line-height: 0; }
.media-img { display: block; max-width: min(320px, 100%); max-height: 360px; width: auto; height: auto; object-fit: cover; background: var(--surface-2); min-height: 80px; min-width: 120px; }
.media-img.is-sticker { max-width: 150px; background: transparent; min-height: 0; min-width: 0; }
.media-audio { display: block; width: min(300px, 70vw); height: 40px; margin: .1rem 0 .25rem; }
/* A fixed frame from the start, so the thread doesn't grow when the video's size becomes known. */
.media-video { display: block; width: min(340px, 100%); aspect-ratio: 16 / 9; max-height: 360px; object-fit: contain; background: #000;
  border-radius: 12px; margin-bottom: .3rem; }
.media-doc { display: flex; align-items: center; gap: .5rem; padding: .5rem .65rem; margin-bottom: .3rem; border-radius: 10px; background: var(--surface-2); color: var(--ink); text-decoration: none; font-size: .88rem; }
.media-doc small { margin-left: auto; color: var(--indigo); font-weight: 600; }
.media-fallback { display: inline-block; font-size: .8rem; color: var(--rose); margin-bottom: .3rem; }
.bubble-text:dir(rtl) { font-family: var(--font-script); font-size: 1.05em; line-height: 1.85; }
.bubble-meta { display: flex; justify-content: flex-end; gap: .45rem; font-size: .7rem; color: var(--ink-soft); margin-top: .15rem; }
.bubble-error { font-size: .74rem; color: var(--rose); }

.composer { background: var(--surface); border-top: 1px solid var(--line); padding: .6rem clamp(.7rem, 2vw, 1.1rem) calc(.6rem + env(safe-area-inset-bottom)); position: relative; }
.claim-bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.claim-bar[hidden], #reply-form[hidden] { display: none; }
#reply-form { display: flex; gap: .5rem; align-items: flex-end; }
#reply-text { resize: none; max-height: 170px; border-radius: 12px; }
.composer-note { margin: 0; font-size: .84rem; color: var(--ink-soft); }
.send-btn, .quick-btn { border-radius: 12px; height: 42px; width: 46px; display: grid; place-items: center; }

.quick-panel {
  position: absolute; left: clamp(.7rem, 2vw, 1.1rem); right: clamp(.7rem, 2vw, 1.1rem); bottom: calc(100% - .3rem);
  max-height: 260px; overflow-y: auto; background: var(--surface-solid); border: 1px solid var(--glass-border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: .35rem; z-index: 20;
}
.quick-panel[hidden] { display: none; }
.quick-item { display: grid; gap: .1rem; width: 100%; text-align: left; border: 0; background: transparent; color: inherit; padding: .5rem .6rem; border-radius: var(--radius-sm); }
.quick-item:hover, .quick-item.active { background: color-mix(in srgb, var(--indigo) 12%, transparent); }
.quick-title { font-weight: 600; font-size: .9rem; display: flex; gap: .4rem; align-items: center; }
.quick-shortcut { color: var(--indigo); font-weight: 600; font-size: .78rem; }
.quick-body { color: var(--ink-soft); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.history { list-style: none; padding: 0; margin: 0; }
.history li { padding: .55rem 0; border-bottom: 1px solid var(--line); font-size: .88rem; }
.history time { display: block; font-size: .74rem; color: var(--ink-soft); }
.history .is-note { background: color-mix(in srgb, var(--amber) 12%, transparent); margin: 0 -.5rem; padding: .55rem .5rem; border-radius: 8px; }

/* ------------------------------------------------------------------ pages */
.page { --page-pad: clamp(1rem, 2vw, 1.6rem); padding: var(--page-pad) max(var(--page-pad), calc((100% - 1240px) / 2));
  display: grid; grid-auto-rows: max-content; gap: 1rem; align-content: start; width: 100%; }  /* rows never shrink below their content */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow-sm); }
.panel h2 { font-size: 1rem; font-weight: 700; margin-bottom: .3rem; }
.panel .hint { color: var(--ink-soft); font-size: .86rem; margin-bottom: .9rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; align-items: start; }
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; }
.figure { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow-sm); }
.figure strong { display: block; font-size: 1.85rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.figure span { color: var(--ink-soft); font-size: .85rem; }
.figure.is-alert strong { color: var(--rose); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-alert { color: var(--rose); font-weight: 600; }
.muted-row td { color: var(--ink-soft); }
.table th { font-size: .78rem; font-weight: 600; color: var(--ink-soft); white-space: nowrap; }

.swatch { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.dept-name { font-weight: 600; }
.dept-meta { color: var(--ink-soft); font-size: .82rem; }
.chiplist { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .2rem; }
.settings-tabs { display: flex; gap: .3rem; overflow-x: auto; padding-bottom: .2rem; }
.settings-tabs button { border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-soft); border-radius: 999px; padding: .35rem .85rem; font-weight: 600; font-size: .88rem; white-space: nowrap; }
.settings-tabs button.active { background: var(--indigo); border-color: var(--indigo); color: #fff; }

/* ------------------------------------------------------------------ login */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; }
.login-card {
  width: 100%; max-width: 380px; padding: 2rem; border-radius: var(--radius-xl);
  background: var(--glass); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
}
.login-card .brand { margin-bottom: .3rem; font-size: 1.3rem; }
.login-lede { color: var(--ink-soft); margin-bottom: 1.4rem; }

/* ------------------------------------------------------------------ dashboard */
/* Chart colours were checked with the dataviz palette validator (light surface #F3F7FD, dark #101E36). */
:root {
  --good: #2F7D46; --bad: #B23A30;
  --chart-line: #1E5BB8;
  --heat-0: rgba(20, 33, 61, .05);
  --heat-1: #BBD2F5; --heat-2: #8CB3EC; --heat-3: #5B8FDD; --heat-4: #2F68C2; --heat-5: #173F80;
  --src-ad: #1E5BB8; --src-direct: #1F9E8F;
}
[data-bs-theme="dark"] {
  --good: #8FD39A; --bad: #FF8F84;
  --chart-line: #6FA3F5;
  --heat-0: rgba(255, 255, 255, .05);
  --heat-1: #173F80; --heat-2: #2F68C2; --heat-3: #4C8DF0; --heat-4: #8CB3EC; --heat-5: #CFE0FA;
  --src-ad: #4C8DF0; --src-direct: #4FC7B6;
}

.dash { max-width: none; gap: 1.1rem; }
.dash-greet h2 { font-size: 1.45rem; font-weight: 600; letter-spacing: -.02em; margin: 0; text-shadow: var(--active-shadow); }
.dash-greet p { margin: .15rem 0 0; color: var(--ink-soft); }
.dash-period { padding: .2rem; }
.dash-period button { padding: .3rem .75rem; flex: none; }
.live-pill { display: inline-flex; align-items: center; gap: .45rem; font-size: .78rem; color: var(--ink-soft); white-space: nowrap; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-mute); position: relative; }
.live-pill.is-live .live-dot { background: var(--good); }
.live-pill.is-live .live-dot::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--good); opacity: 0; animation: live-ping 2s var(--ease) infinite; }
@keyframes live-ping { 0% { transform: scale(.4); opacity: .8; } 100% { transform: scale(1.4); opacity: 0; } }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.kpi {
  position: relative; overflow: hidden; display: grid; gap: .35rem; align-content: start; min-height: 132px;
  padding: 1.1rem 1.2rem; border-radius: 20px; background: var(--surface); border: .5px solid var(--glass-border);
  box-shadow: var(--shadow-sm); animation: rise .6s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms);
}
.kpi::before { content: ""; position: absolute; inset: -40% -20% auto auto; width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(30, 91, 184, .18), transparent); pointer-events: none; }
.kpi-label { font-size: 11px; font-weight: 500; letter-spacing: .4px; text-transform: uppercase; color: var(--ink-mute); }
.kpi-num { font-size: 2.2rem; font-weight: 600; line-height: 1.05; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.kpi-reply .kpi-num { font-size: 1.7rem; line-height: 1.3; }
.kpi-foot { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem; font-size: .78rem; position: relative; z-index: 1; }
.kpi-hint { color: var(--ink-soft); }
.delta { display: inline-flex; align-items: center; gap: .1rem; padding: .05rem .45rem; border-radius: 999px; font-weight: 600; background: var(--surface-2); color: var(--ink-soft); }
.delta.is-good { color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }
.delta.is-bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }
.delta-arrow { font-size: .62rem; }
.delta-vs { font-weight: 400; color: var(--ink-soft); }
.spark { position: absolute; right: 1rem; top: 1rem; width: 96px; height: 32px; overflow: visible; }
.spark-line { fill: none; stroke: var(--chart-line); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark-area { fill: color-mix(in srgb, var(--chart-line) 16%, transparent); stroke: none; }

/* Card grid */
.dash-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; align-items: stretch; }
.card { display: flex; flex-direction: column; gap: .8rem; min-width: 0; border-radius: 20px; background: var(--surface); border-color: var(--glass-border); animation: rise .6s var(--ease) both; animation-delay: .15s; }
.span-2 { grid-column: span 2; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; }
.card-head h2 { margin: 0; }
.card-head .hint { margin: .1rem 0 0; }
.table-toggle { font-size: .8rem; color: var(--ink-soft); text-decoration: none; padding: .1rem .4rem; }
.table-toggle:hover { color: var(--indigo); }
.chart { position: relative; min-height: 120px; }
.empty { color: var(--ink-soft); font-size: .88rem; margin: 1rem 0; text-align: center; }
.dash-table { font-size: .82rem; margin: 0; }

/* Trend chart */
.trend-svg { display: block; width: 100%; height: auto; overflow: visible; }
.trend-svg .grid { stroke: var(--line); stroke-dasharray: 3 4; }
.trend-svg .baseline { stroke: color-mix(in srgb, var(--ink) 22%, transparent); }
.trend-svg .axis { fill: var(--ink-mute); font-size: 11px; font-variant-numeric: tabular-nums; }
.trend-line { fill: none; stroke: var(--chart-line); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.trend-area { fill: url(#trend-fill); animation: fade .9s var(--ease) both .2s; }
.trend-stop-top { stop-color: var(--chart-line); stop-opacity: .32; }
.trend-stop-bottom { stop-color: var(--chart-line); stop-opacity: 0; }
.crosshair { stroke: color-mix(in srgb, var(--ink) 30%, transparent); stroke-dasharray: 3 3; }
.trend-dot { fill: var(--chart-line); stroke: var(--surface-solid); stroke-width: 2; }

/* Heatmap */
.heat { display: grid; grid-template-columns: 2.4rem repeat(24, minmax(0, 1fr)); gap: 3px; align-items: center; }
.heat-hour { font-size: 10px; color: var(--ink-mute); text-align: left; white-space: nowrap; }
.heat-day { font-size: 11px; color: var(--ink-soft); }
.heat-cell { aspect-ratio: 1; min-height: 12px; border-radius: 4px; background: var(--heat-0); animation: pop .4s var(--ease) both; animation-delay: var(--d, 0ms); }
.heat-cell.q1 { background: var(--heat-1); } .heat-cell.q2 { background: var(--heat-2); } .heat-cell.q3 { background: var(--heat-3); }
.heat-cell.q4 { background: var(--heat-4); } .heat-cell.q5 { background: var(--heat-5); }
.heat .heat-cell:hover { outline: 2px solid var(--ink); outline-offset: 1px; }
.heat-legend { display: flex; align-items: center; gap: 3px; justify-content: flex-end; font-size: 11px; color: var(--ink-mute); margin-top: .5rem; }
.heat-legend .heat-cell { width: 14px; min-height: 14px; animation: none; }
.heat-legend > span:first-child { margin-right: .3rem; } .heat-legend > span:last-child { margin-left: .3rem; }

/* Bar lists (pipeline, departments) */
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.bar-row { display: grid; grid-template-columns: minmax(6rem, 38%) 1fr auto; align-items: center; gap: .7rem; font-size: .86rem; }
.bar-label { display: flex; align-items: center; gap: .45rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-swatch { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.bar-track { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-fill { display: block; height: 100%; width: var(--w); min-width: 2px; border-radius: 999px; background: var(--chart-line); transform-origin: left; animation: grow .8s var(--ease) both; animation-delay: calc(.25s + var(--i, 0) * 70ms); }
.bar-row.is-muted .bar-fill { background: color-mix(in srgb, var(--ink) 30%, transparent); }
.bar-value { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; min-width: 2rem; }
.bar-value small { display: block; font-weight: 400; font-size: .72rem; color: var(--ink-soft); }
.bar-sep { height: 1px; background: var(--line); margin: .15rem 0; }

/* Source split */
.split-hero { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .8rem; color: var(--ink-soft); font-size: .88rem; }
.split-big { font-size: 2.4rem; font-weight: 600; letter-spacing: -.03em; color: var(--ink); font-variant-numeric: tabular-nums; }
.split { display: flex; gap: 2px; height: 14px; border-radius: 999px; overflow: hidden; }
.split-seg { width: var(--w); transform-origin: left; animation: grow .9s var(--ease) both .3s; }
.split-seg.is-ad, .sw.is-ad { background: var(--src-ad); }
.split-seg.is-direct, .sw.is-direct { background: var(--src-direct); }
.split-legend { list-style: none; padding: 0; margin: .9rem 0 0; display: grid; gap: .45rem; font-size: .86rem; }
.split-legend li { display: flex; align-items: center; gap: .5rem; color: var(--ink-soft); }
.split-legend b { margin-left: auto; color: var(--ink); font-variant-numeric: tabular-nums; }
.sw { width: 10px; height: 10px; border-radius: 3px; }

/* Team leaderboard */
.team-list { display: grid; }
.team-row { display: grid; grid-template-columns: minmax(10rem, 1.6fr) .6fr 1.6fr 1fr .6fr; gap: .8rem; align-items: center; padding: .6rem .2rem; border-bottom: 1px solid var(--line); font-size: .88rem; animation: rise .5s var(--ease) both; animation-delay: calc(.3s + var(--i, 0) * 60ms); }
.team-row:last-child { border-bottom: 0; }
.team-head { font-size: 11px; letter-spacing: .4px; text-transform: uppercase; color: var(--ink-mute); animation: none; padding-top: 0; }
.team-who { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.team-who b { display: block; font-weight: 600; }
.team-who small { display: inline-flex; align-items: center; gap: .3rem; color: var(--ink-soft); font-size: .74rem; }
.team-who small i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-mute); }
.team-who small.is-on i { background: var(--good); }
.avatar.sm { width: 30px; height: 30px; font-size: .8rem; }
.team-row .num { text-align: left; font-variant-numeric: tabular-nums; }
.team-bar { display: grid; grid-template-columns: 1fr 2rem; align-items: center; gap: .5rem; }
.team-bar b { text-align: right; font-variant-numeric: tabular-nums; }

/* Tooltip */
.dash-tip { position: fixed; z-index: var(--z-tooltip); pointer-events: none; padding: .45rem .65rem; border-radius: 10px; font-size: .8rem; line-height: 1.35;
  background: var(--surface-solid); color: var(--ink); border: 1px solid var(--glass-border); box-shadow: var(--shadow); }
.tip-title { font-weight: 600; margin-bottom: .1rem; }
.tip-muted { color: var(--ink-soft); }

/* Skeletons */
.sk { display: block; border-radius: 8px; background: linear-gradient(90deg, var(--surface-2) 25%, color-mix(in srgb, var(--ink) 8%, transparent) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.sk-line { height: 10px; width: 60%; } .sk-line.short { width: 35%; } .sk-num { height: 32px; width: 45%; }
.sk-chart { height: 200px; } .sk-block { height: 140px; }
.kpi.is-loading { animation: none; }

/* Animations; live refreshes (".quiet") don't replay them. */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.4); } }
@keyframes grow { from { transform: scaleX(0); } }
@keyframes shimmer { to { background-position: -200% 0; } }
.dash.quiet :is(.kpi, .card, .bar-fill, .heat-cell, .split-seg, .team-row, .trend-area) { animation: none; }

@media (max-width: 1199.98px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2 { grid-column: 1 / -1; }
}
@media (max-width: 767.98px) {
  .dash-grid { grid-template-columns: 1fr; }
  .team-row { grid-template-columns: minmax(8rem, 1.5fr) .5fr 1.3fr .6fr; }
  .team-row > :nth-child(4) { display: none; }
  .live-pill { display: none; }
}
@media (max-width: 575.98px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .kpi { min-height: 116px; padding: .9rem; }
  .kpi-num { font-size: 1.7rem; }
  .spark { display: none; }
  .heat { grid-template-columns: 1.9rem repeat(24, minmax(0, 1fr)); gap: 2px; }
  .heat-hour { font-size: 8px; }
}

/* ------------------------------------------------------------------ sticky-column table + pagination */
.btn-icon-text { display: inline-flex; align-items: center; gap: .35rem; }
.btn-icon-text .icon { width: 16px; height: 16px; }

/* First and last columns stay put; the middle scrolls sideways. Pinned cells need a solid background. */
:root {
  --th-bg: color-mix(in srgb, var(--indigo) 16%, var(--surface-solid)); --th-ink: #12346B;
  --th-line: color-mix(in srgb, var(--indigo) 35%, transparent);
  --pin-bg: color-mix(in srgb, var(--indigo) 8%, #F3F7FD);
  --pin-edge: color-mix(in srgb, var(--indigo) 30%, transparent);
  --row-hover: color-mix(in srgb, var(--indigo) 7%, transparent);
  --pin-hover: color-mix(in srgb, var(--indigo) 15%, #F3F7FD);
  --edge-shadow: rgba(10, 30, 70, .22);
}
[data-bs-theme="dark"] {
  --th-bg: color-mix(in srgb, var(--indigo) 22%, #101E36); --th-ink: #B9D3FA;
  --pin-bg: color-mix(in srgb, var(--indigo) 10%, #101E36);
  --pin-edge: color-mix(in srgb, var(--indigo) 38%, transparent);
  --row-hover: color-mix(in srgb, var(--indigo) 9%, transparent);
  --pin-hover: color-mix(in srgb, var(--indigo) 18%, #101E36);
  --edge-shadow: rgba(0, 0, 0, .8);
}

/* The panel fills the page; rows scroll inside it, the footer stays at the bottom. */
/* Settings → Team: on desktop the panel fills the page and rows scroll inside it (like Ads). */
@media (min-width: 768px) {
  body.team-mode #settings-page { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; padding-inline: var(--page-pad); }
  body.team-mode .team-panel:not([hidden]) { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  body.team-mode .team-panel > :not(.sticky-table) { flex: none; }
}
.sticky-table { flex: 1; min-height: 0; overflow: auto; position: relative; border-radius: 12px; }
.team-table { min-width: 860px; margin: 0; border-collapse: separate; border-spacing: 0; }
.team-table > :not(caption) > * > * { background: transparent; }
.team-table tbody tr:hover > td { background: var(--row-hover); }

/* Header row: its own tint and ink, sticky to the top of the scroller. */
.team-table thead th {
  position: sticky; top: 0; z-index: 3; background: var(--th-bg); color: var(--th-ink);
  font-size: 11px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; white-space: nowrap;
  border-bottom: 1px solid var(--th-line); padding-block: .7rem;
}
.team-table thead th:first-child { border-top-left-radius: 12px; }
.team-table thead th:last-child { border-top-right-radius: 12px; }

/* Pinned first/last columns: warm tinted surface (opaque so scrolled cells don't show through). */
.team-table :is(th, td):is(.col-name, .col-actions) { position: sticky; z-index: 2; transition: box-shadow .2s var(--ease), background .15s var(--ease); }
.team-table td:is(.col-name, .col-actions) { background: var(--pin-bg); }
.team-table tbody tr:hover > td:is(.col-name, .col-actions) { background: var(--pin-hover); }
.team-table th:is(.col-name, .col-actions) { z-index: 4; }
.team-table .col-name { left: 0; min-width: 14rem; max-width: 18rem; box-shadow: inset -1px 0 0 var(--pin-edge); }
.team-table .col-name .dept-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-table .col-actions { right: 0; text-align: right; white-space: nowrap; width: 1%; box-shadow: inset 1px 0 0 var(--pin-edge); }
.muted-row :is(.col-name, .col-actions) { color: var(--ink-soft); }
.team-table .num { text-align: center; }
.team-table .num .cstep { margin-inline: auto; }
.sticky-table:not(.at-start) .col-name { box-shadow: inset -1px 0 0 var(--pin-edge), 10px 0 12px -10px var(--edge-shadow); }
.sticky-table:not(.at-end) .col-actions { box-shadow: inset 1px 0 0 var(--pin-edge), -10px 0 12px -10px var(--edge-shadow); }

/* Actions: one segmented pill, each action with its own colour. */
:root {
  --act-reset: #4148B8; --act-reset-bg: rgba(65, 72, 184, .1);
  --act-danger: #B42318; --act-danger-bg: rgba(180, 35, 24, .09);
  --act-ok: #1F6F3A; --act-ok-bg: rgba(31, 111, 58, .11);
}
[data-bs-theme="dark"] {
  --act-reset: #AFB3FF; --act-reset-bg: rgba(175, 179, 255, .13);
  --act-danger: #FF9A90; --act-danger-bg: rgba(255, 143, 132, .12);
  --act-ok: #97DBA2; --act-ok-bg: rgba(143, 211, 154, .12);
}
.action-group { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface-solid); vertical-align: middle; }
.act {
  display: inline-flex; align-items: center; gap: .35rem; border: 0; padding: .32rem .7rem; font-size: .8rem; font-weight: 600; white-space: nowrap;
  color: var(--c); background: var(--c-bg); transition: background .15s var(--ease), filter .15s var(--ease);
}
.act + .act { border-left: 1px solid var(--line); }
.act .icon { width: 15px; height: 15px; }
.act:hover { background: color-mix(in srgb, var(--c) 20%, transparent); }
.act:focus-visible { outline: 0; box-shadow: inset 0 0 0 2px var(--c); }
.act-reset { --c: var(--act-reset); --c-bg: var(--act-reset-bg); }
.act-danger { --c: var(--act-danger); --c-bg: var(--act-danger-bg); }
.act-ok { --c: var(--act-ok); --c-bg: var(--act-ok-bg); }
.act-none { color: var(--ink-mute); padding-inline: .7rem; }
.skel-row td { padding-block: 1rem; }

.table-foot { display: flex; align-items: center; justify-content: space-between; gap: .75rem 1rem; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: .8rem; margin-top: .4rem; }
.table-summary { color: var(--ink-soft); font-size: .85rem; font-variant-numeric: tabular-nums; }
.pager { display: flex; align-items: center; gap: .25rem; }
.pager-btn {
  min-width: 32px; height: 32px; padding: 0 .55rem; border-radius: 10px; display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-soft); font-weight: 600; font-size: .85rem; font-variant-numeric: tabular-nums;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.pager-btn .icon { width: 16px; height: 16px; }
.pager-btn .icon.flip { transform: scaleX(-1); }
.pager-btn:hover:not(:disabled):not([aria-current]) { color: var(--ink); border-color: color-mix(in srgb, var(--indigo) 40%, var(--line)); }
.pager-btn[aria-current="page"] { background: var(--indigo); border-color: var(--indigo); color: #fff; box-shadow: var(--accent-shadow); }
.pager-btn:disabled { opacity: .4; cursor: not-allowed; }
.pager-btn:focus-visible { outline: 0; box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }
.pager-gap { color: var(--ink-mute); padding: 0 .2rem; }
.per-page { display: flex; align-items: center; gap: .5rem; margin: 0; color: var(--ink-soft); font-size: .85rem; white-space: nowrap; }

/* ------------------------------------------------------------------ standard table footer (tableFooter, common.js)
   Rows per page (left) · pages (centre) · Showing X–Y of Z (right). Phones: still one row; the label and
   the word "Showing" hide and the pager shrinks to ‹ current ›. Never wider than the screen. */
.tbl-foot { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); grid-template-areas: "size pages sum";
  align-items: center; gap: .5rem 1rem; width: 100%; min-width: 0; }
.tbl-foot[hidden] { display: none; }
.tbl-foot .per-page { grid-area: size; justify-self: start; min-width: 0; }
.tbl-foot .per-page .form-select, .tbl-foot .per-page .cselect-trigger { width: auto; min-width: 4.4rem; }
.tbl-foot .pager { grid-area: pages; justify-self: center; min-width: 0; }
.tbl-foot .table-summary { grid-area: sum; justify-self: end; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel > .tbl-foot, .card .tbl-foot { border-top: 1px solid var(--line); padding-top: .6rem; margin-top: .4rem; }
@media (max-width: 575.98px) {
  /* One row on phones: selector · ‹ current › · "11–20 of 222" (page numbers other than the current one hide). */
  .tbl-foot { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "size pages sum"; gap: .5rem; }
  .tbl-foot .pager-btn:not([aria-current]):not(:first-child):not(:last-child), .tbl-foot .pager-gap { display: none; }
  .tbl-foot .per-page-label, .tbl-foot .sum-word { display: none; }
  .tbl-foot .table-summary { font-size: .8rem; }
  .tbl-foot .pager { gap: .2rem; }
  .tbl-foot .pager-btn { min-width: 30px; height: 30px; padding: 0 .4rem; font-size: .8rem; border-radius: 9px; }
  .team-table .col-name { min-width: 10rem; }
}
.page-foot .foot-block > .tbl-foot { flex: 1 1 auto; }

/* Shared table cells: name with a colour dot / shortcut, one-line clipped text */
.name-with-swatch { display: inline-flex; align-items: center; gap: .5rem; flex-wrap: wrap; min-width: 0; }
.name-with-swatch .swatch { flex: none; }
.name-with-swatch .tag { margin: 0; }
.data-table .cell-clip { max-width: 22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hours-table input[type="time"], .hours-table .ctime-trigger { width: 8.5rem; max-width: 100%; }
@media (max-width: 767.98px) {
  .data-table.table-stack .cell-clip { max-width: none; white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
}

/* ------------------------------------------------------------------ native control replacements (controls.js) */
:root { --scroll-thumb: rgba(20, 33, 61, .2); --scroll-thumb-hover: rgba(20, 33, 61, .36); }
[data-bs-theme="dark"] { --scroll-thumb: rgba(111, 163, 245, .35); --scroll-thumb-hover: rgba(111, 163, 245, .6); }

/* Scrollbars: thin, rounded, transparent track. */
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-thumb-hover); }

/* The native element stays in the DOM (value source) but is invisible. */
.cnative { position: absolute !important; width: 1px !important; height: 1px !important; opacity: 0 !important; pointer-events: none !important; clip-path: inset(50%) !important; margin: 0 !important; }

/* Triggers reuse .form-select / .form-control sizing. */
.cselect-trigger, .ctime-trigger, .ccolor-trigger {
  display: flex; align-items: center; gap: .5rem; text-align: left; cursor: pointer; background-image: none;
  background-color: var(--surface); color: var(--ink); border: var(--bs-border-width) solid var(--line);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.cselect-trigger { padding-right: .6rem; min-width: 0; max-width: 100%; }  /* long values end in "…", never widen the row */
.cselect-trigger:hover:not(:disabled), .ctime-trigger:hover:not(:disabled), .ccolor-trigger:hover:not(:disabled) { border-color: color-mix(in srgb, var(--indigo) 45%, var(--line)); }
.cselect-trigger:focus-visible, .ctime-trigger:focus-visible, .ccolor-trigger:focus-visible { outline: 0; border-color: var(--indigo); box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }
.cselect-trigger:disabled, .ctime-trigger:disabled, .ccolor-trigger:disabled { opacity: .55; cursor: not-allowed; background-color: var(--surface-2); }
.cselect-trigger[aria-expanded="true"] { border-color: var(--indigo); }
.cselect-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cselect-trigger.is-placeholder .cselect-label { color: var(--ink-soft); }
.cselect-chevron { width: 16px; height: 16px; color: var(--ink-soft); transition: transform .2s var(--ease); }
.cselect-trigger[aria-expanded="true"] .cselect-chevron { transform: rotate(180deg); }

/* Popover panel (appended to <body>, fixed, above modals). */
.cpop {
  position: fixed; z-index: var(--z-popover); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface-solid); color: var(--ink); border: 1px solid var(--glass-border); border-radius: 14px;
  box-shadow: var(--shadow), var(--glass-shadow); padding: .3rem;
  animation: cpop-in .14s var(--ease);
}
@keyframes cpop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.cpop-search { margin: .1rem .1rem .35rem; width: calc(100% - .2rem); position: sticky; top: 0; z-index: 1; background-color: var(--surface-solid); }
.copt { display: flex; align-items: center; gap: .45rem; padding: .45rem .6rem; border-radius: 9px; cursor: pointer; white-space: nowrap; font-size: .9rem; }
.copt.is-active { background: color-mix(in srgb, var(--indigo) 14%, transparent); }
.copt.is-selected { font-weight: 600; }
.copt.is-disabled { opacity: .42; cursor: not-allowed; }
.copt-check { width: 16px; display: grid; place-items: center; color: var(--indigo); visibility: hidden; flex: none; }
.copt-check .icon { width: 15px; height: 15px; }
.copt.is-selected .copt-check { visibility: visible; }
/* Long option names (ads): "…" inside the panel instead of running past it; on phones they wrap
   to two lines so they can be read. Touch screens get taller rows to tap. */
.cpop { overflow-x: hidden; }
/* Select lists: the search box is a fixed header and only the options scroll, so rows never
   pass under or over it. The chosen option is tinted + ticked; the hover/keyboard row is lighter. */
.cpop-select { display: flex; flex-direction: column; overflow: hidden; }
.cpop-select .cpop-search { position: static; flex: none; width: 100%; margin: 0 0 .35rem; }
.cpop-select .copt-list { position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
.copt.is-active { background: color-mix(in srgb, var(--indigo) 7%, transparent); }
.copt.is-selected { background: color-mix(in srgb, var(--indigo) 13%, transparent); color: var(--indigo); }
.copt.is-selected.is-active { background: color-mix(in srgb, var(--indigo) 18%, transparent); }
.copt-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 767.98px) {
  .cpop-select .copt { white-space: normal; }
  .cpop-select .copt-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere; }
}
@media (pointer: coarse) { .copt { min-height: 40px; } }
.copt-empty { padding: .6rem; color: var(--ink-soft); font-size: .85rem; text-align: center; }

/* Time picker */
.ctime-icon { width: 16px; height: 16px; color: var(--ink-soft); }
.cpop-time { padding: .35rem; overflow: hidden; }
.ctime-cols { display: grid; grid-template-columns: auto auto; gap: .3rem; height: 232px; }
.ctime-col { overflow-y: auto; display: flex; flex-direction: column; gap: .1rem; padding-right: .15rem; min-width: 5rem; }
.ctime-opt { border: 0; background: transparent; color: var(--ink); border-radius: 8px; padding: .35rem .6rem; text-align: left; font-size: .88rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ctime-opt:hover { background: color-mix(in srgb, var(--indigo) 12%, transparent); }
.ctime-opt.is-selected { background: var(--indigo); color: #fff; font-weight: 600; box-shadow: var(--accent-shadow); }

/* Colour picker */
.ccolor-trigger { height: calc(1.5em + .75rem + 2 * var(--bs-border-width)); }
.ccolor-swatch { width: 20px; height: 20px; border-radius: 6px; border: 1px solid rgba(0, 0, 0, .12); flex: none; }
.ccolor-hex { font-variant-numeric: tabular-nums; font-size: .88rem; }
.cpop-color { padding: .6rem; width: 232px; }
.ccolor-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: .4rem; margin-bottom: .6rem; }
.ccolor-cell { aspect-ratio: 1; border-radius: 8px; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); padding: 0; transition: transform .12s var(--ease); }
.ccolor-cell:hover { transform: scale(1.08); }
.ccolor-cell.is-selected { border-color: var(--ink); }
.ccolor-row { display: flex; gap: .4rem; }
.ccolor-row .form-control { font-variant-numeric: tabular-nums; text-transform: uppercase; }

/* Number stepper: native spinners off, − / + buttons. */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.cstep { flex-wrap: nowrap; }
.table .cstep { width: 7.25rem; }
.table .cstep .cstep-input { min-width: 2.5rem; padding-inline: .2rem; }
.cstep .cstep-input { text-align: center; font-variant-numeric: tabular-nums; min-width: 3rem; }
.cstep-btn { border: var(--bs-border-width) solid var(--line); background: var(--surface-2); color: var(--ink-soft); display: grid; place-items: center; padding-inline: .55rem; }
.cstep-btn .icon { width: 16px; height: 16px; }
.cstep-btn:hover:not(:disabled) { color: var(--indigo); background: color-mix(in srgb, var(--indigo) 12%, transparent); border-color: var(--line); }
.cstep-btn:disabled { opacity: .4; border-color: var(--line); }

/* Checkboxes and switches (Bootstrap already sets appearance: none). */
.form-check-input { background-color: var(--surface-2); border: 1px solid color-mix(in srgb, var(--ink) 22%, transparent); transition: background-color .18s var(--ease), border-color .18s var(--ease), background-position .2s var(--ease), box-shadow .18s var(--ease); cursor: pointer; }
.form-check-input:checked { background-color: var(--indigo); border-color: var(--indigo); box-shadow: var(--accent-shadow); }
.form-check-input:focus { border-color: var(--indigo); box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }
.form-check-input:disabled { opacity: .45; }
.form-check-input[type="checkbox"]:not([role="switch"]) { border-radius: 6px; }
.form-switch .form-check-input, .form-check-input[role="switch"] { width: 2.4em; height: 1.35em; border-radius: 999px; }
.form-switch .form-check-input:not(:checked), .form-check-input[role="switch"]:not(:checked) {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23a08a80'/%3e%3c/svg%3e");
}
[data-bs-theme="dark"] .form-switch .form-check-input:not(:checked), [data-bs-theme="dark"] .form-check-input[role="switch"]:not(:checked) {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba(255,255,255,.55)'/%3e%3c/svg%3e");
}

/* Stacked dialog (confirm over another modal). */
.cdialog { z-index: var(--z-dialog); }
.modal-backdrop ~ .modal-backdrop { z-index: 1065; }
.cdialog .modal-dialog { max-width: 420px; }
.cdialog .modal-body { padding: 1.4rem 1.4rem .6rem; }
.cdialog-title { font-size: 1.05rem; font-weight: 600; margin-bottom: .4rem; }
.cdialog-msg { color: var(--ink-soft); margin-bottom: 0; }
.cdialog-input { margin-top: .9rem; }
.cdialog .modal-footer { border: 0; padding: .6rem 1.4rem 1.2rem; gap: .4rem; }
.cdialog .modal-footer > * { margin: 0; }

/* ------------------------------------------------------------------ notifications (live.js) */
.notify-toggle { display: flex; align-items: center; gap: .75rem; padding: .4rem 1.25rem; border: 0; background: transparent; color: var(--ink-soft); font-weight: 500; border-radius: var(--radius-sm); position: relative; }
.notify-toggle:hover { background: var(--active-bg); color: var(--ink); }
.rail .notify-toggle { justify-content: center; gap: 0; padding-inline: 0; }
.notify-bell { position: relative; width: 46px; display: grid; place-items: center; flex: none; }
.notify-bell .icon { width: 20px; height: 20px; }
.notify-dot { position: absolute; top: -2px; right: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--indigo); box-shadow: 0 0 0 2px var(--surface-solid); }
.notify-dot[hidden] { display: none; }

.notify-panel { width: 290px; padding: .9rem 1rem; display: grid; gap: .7rem; }
.np-title { font-weight: 600; font-size: .9rem; }
.np-row { display: grid; gap: .15rem; }
.np-row .form-check { display: flex; align-items: center; gap: .55rem; padding-left: 0; }
.np-row .form-check-input { margin: 0; float: none; }
.np-note, .np-scope { color: var(--ink-soft); font-size: .76rem; line-height: 1.35; }
.np-note:empty { display: none; }
.np-scope { border-top: 1px solid var(--line); padding-top: .6rem; }

.notif-stack { position: fixed; top: 1rem; right: 1rem; z-index: var(--z-notify); display: grid; gap: .6rem; width: min(360px, calc(100vw - 2rem)); pointer-events: none; }
.notif {
  pointer-events: auto; position: relative; display: grid; grid-template-columns: auto 1fr; gap: .7rem; padding: .85rem .9rem .8rem;
  background: var(--surface-solid); color: var(--ink); border: 1px solid var(--glass-border); border-radius: 16px;
  box-shadow: var(--shadow), var(--glass-shadow); animation: notif-in .32s var(--ease) both;
}
.notif::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--indigo); }
.notif.is-leaving { animation: notif-out .22s var(--ease) both; }
.notif.bump { animation: notif-bump .35s var(--ease); }
@keyframes notif-in { from { opacity: 0; transform: translateX(24px) scale(.98); } }
@keyframes notif-out { to { opacity: 0; transform: translateX(24px); } }
@keyframes notif-bump { 40% { transform: scale(1.03); } }
.notif-body { min-width: 0; padding-right: 1.2rem; }
.notif-top { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; font-size: .88rem; }
.notif-top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 12rem; }
.notif-top time { margin-left: auto; font-size: .72rem; color: var(--ink-mute); }
.notif-tag { font-size: .68rem; font-weight: 600; padding: 0 .4rem; border-radius: 6px; color: var(--dc, var(--ink-soft)); background: color-mix(in srgb, var(--dc, var(--ink)) 14%, transparent); }
.notif-tag.is-ad { --dc: var(--indigo); }
.notif-text { margin: .2rem 0 .55rem; color: var(--ink-soft); font-size: .86rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.notif-actions { display: flex; align-items: center; gap: .6rem; }
.notif-hint { font-size: .74rem; color: var(--ink-mute); }
.notif-x { position: absolute; top: .6rem; right: .6rem; width: .6rem; height: .6rem; background-size: .6rem; }
[data-bs-theme="dark"] .notif-x { filter: invert(1) grayscale(100%) brightness(200%); }
.notif-burst { background: var(--indigo); }
.notif-burst .icon { width: 16px; height: 16px; color: #fff; }
@media (max-width: 991.98px) { .notif-stack { top: .6rem; right: .6rem; } }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1199.98px) {
  .sidebar { width: var(--side-rail); }
  .sidebar .nav-text { opacity: 0; width: 0; }
  .sidebar :is(.nav-item, .avail, .theme-toggle, .notify-toggle, .user-card) { justify-content: center; gap: 0; }
  .sidebar-top { justify-content: center; }
  .sidebar .nav-label { padding: 0; text-align: center; }
  .sidebar :is(.nav-item, .avail, .theme-toggle) { padding-inline: 0; }
  .sidebar .user-card { padding: .5rem 0; border-radius: var(--radius-sm); }
  .rail-toggle, .user-card .logout { display: none; }
  .inbox { grid-template-columns: minmax(270px, 320px) minmax(0, 1fr); }
}

@media (max-width: 991.98px) {
  .sidebar { display: none; }
  :root { --gap: 8px; }
  .shell { grid-template-columns: 1fr; padding-bottom: calc(var(--gap) * 2 + 62px + env(safe-area-inset-bottom)); }
  .workspace { border-radius: 20px; }
  .tabbar {
    display: flex; position: fixed; bottom: calc(var(--gap) + env(safe-area-inset-bottom)); left: var(--gap); right: var(--gap); z-index: var(--z-tabbar);
    background: var(--glass); border: 1px solid var(--glass-border); border-radius: 20px; box-shadow: var(--glass-shadow);
    -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
    padding: .3rem .4rem;
  }
  .tab { flex: 1; display: grid; justify-items: center; gap: .1rem; padding: .35rem .2rem; border: 0; background: transparent; color: var(--ink-soft); text-decoration: none; font-size: .7rem; font-weight: 600; border-radius: 10px; position: relative; }
  .tab.active { color: var(--indigo); }
  .tab-badge { position: absolute; top: .1rem; right: 22%; min-width: 17px; padding: 0 .25rem; border-radius: 999px; background: var(--amber); color: #fff; font-size: .65rem; font-weight: 700; }
  .inbox { grid-template-columns: 1fr; }
  .pane-thread { display: none; }
  .inbox.show-thread .pane-list { display: none; }
  .inbox.show-thread .pane-thread { display: flex; }
  .back-btn { display: grid; place-items: center; }
  .thread-actions { width: 100%; }
  .thread-actions .form-select { flex: 1; min-width: 0; }
  /* Typing: the on-screen keyboard plus the bar would squeeze the thread, so the bar steps aside. */
  /* Inside a chat the page header (title, quota) steps aside; the list view still shows it. */
  body:has(.inbox.show-thread) .page-bar { display: none; }
  html.kb-open .tabbar { display: none; }
  html.kb-open .shell { padding-bottom: var(--gap); }
}

@media (max-width: 575.98px) {
  .page { padding: .8rem .7rem 1.2rem; }
  .figure strong { font-size: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Connected WhatsApp number under the brand */
.brand-number { display: inline-flex; align-items: center; gap: .3rem; margin-top: .1rem; font-size: 11.5px; font-weight: 500; line-height: 1.3;
  color: var(--ink-soft); text-shadow: none; font-variant-numeric: tabular-nums; white-space: nowrap; }
.brand-number .icon { width: 13px; height: 13px; color: #25A244; }
[data-bs-theme="dark"] .brand-number .icon { color: #5ED47A; }

/* Cost bar: free ad window / blocked / charged (services.send_policy) */
.cost-bar { display: flex; align-items: center; gap: .55rem; padding: .35rem clamp(.7rem, 2vw, 1.1rem); font-size: .78rem; font-weight: 500;
  border-bottom: 1px solid var(--line); background: var(--surface); }
.cost-bar[hidden] { display: none; }
.cost-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: currentColor; }
.cost-bar.is-free { color: var(--good); }
.cost-bar.is-charged { color: var(--amber); }
.cost-bar.is-blocked { color: var(--bad); }
.cost-bar.is-direct { color: var(--ink-soft); }
.cost-unlock { margin-left: auto; padding: .15rem .6rem; font-size: .75rem; font-weight: 600; border: 1px solid currentColor; color: var(--bad); background: transparent; border-radius: 8px; }
.cost-unlock:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.tag-direct { color: var(--ink-soft); border-style: dashed; }
.lock-note { display: flex; gap: .5rem; align-items: flex-start; padding: .55rem .7rem; border-radius: 10px;
  background: color-mix(in srgb, var(--indigo) 10%, transparent); color: var(--ink); }
.lock-note .icon { width: 16px; height: 16px; flex: none; margin-top: .1rem; color: var(--indigo); }
.settings-stack { display: grid; gap: 1rem; }
.settings-stack .form-text { margin-left: 2.9em; color: var(--ink-soft); }

.notif.is-billed::before { background: var(--bad); }
.notif.is-billed .notif-burst { background: var(--bad); color: #fff; font-weight: 700; }

/* Settings: ads & packages */
.ads-table { min-width: 760px; }
.ads-table td { vertical-align: middle; }
.ads-table tr.is-draft td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
.ad-headline { max-width: 18rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-draft { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 50%, transparent); font-size: .72rem; }

/* Monthly free-message allowance (inbox top bar) */
.quota { display: inline-flex; align-items: center; gap: .55rem; font-size: .76rem; color: var(--ink-soft); white-space: nowrap; }
.quota[hidden] { display: none; }
.quota-label { font-weight: 500; }
.quota-track { width: 120px; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.quota-fill { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--good); transition: width .6s var(--ease); }
.quota.is-warn .quota-fill { background: var(--amber); }
.quota.is-over .quota-fill { background: var(--bad); }
.quota.is-over .quota-text { color: var(--bad); font-weight: 600; }
.quota-text { font-variant-numeric: tabular-nums; }
@media (max-width: 767.98px) { .quota-label { display: none; } .quota-track { width: 70px; } }

/* Package chip + deal checklist under the chat header */
.deal-bar { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem .9rem; padding: .45rem clamp(.7rem, 2vw, 1.1rem);
  border-bottom: 1px solid var(--line); background: var(--surface); }
.deal-bar[hidden] { display: none; }
.pkg-chip { --pc: var(--indigo); display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; padding: .2rem .6rem; border-radius: 999px;
  background: color-mix(in srgb, var(--pc) 13%, transparent); color: var(--ink); max-width: 100%; }
.pkg-chip b { color: var(--pc); font-weight: 600; }
.pkg-chip span:not(.pkg-dot) { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 16rem; }
.pkg-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pc); flex: none; }
.pkg-chip.is-draft { outline: 1px dashed var(--amber); }
.pkg-chip.is-draft a { color: var(--amber); font-weight: 600; text-decoration: none; }
.pkg-chip.is-direct { --pc: var(--ink-soft); }
.stage-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.stage { display: inline-flex; align-items: center; gap: .35rem; margin: 0; padding: .1rem .15rem .1rem .55rem; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); font-size: .78rem; }
.stage-name { font-weight: 600; white-space: nowrap; }
.stage .cselect-trigger, .stage .form-select { min-width: 7.2rem; border: 0; background-color: transparent; font-size: .78rem; padding-block: .15rem; }
.stage.stage-done { border-color: color-mix(in srgb, var(--good) 45%, transparent); background: color-mix(in srgb, var(--good) 12%, transparent); }
.stage.stage-done .stage-name { color: var(--good); }
.stage.stage-na { opacity: .6; }
.stage-sum { font-size: .76rem; color: var(--ink-soft); margin-left: auto; font-variant-numeric: tabular-nums; }
.stage-sum.is-complete { color: var(--good); font-weight: 600; }
.tag-pkg { max-width: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ads-table td:nth-child(2) .form-control { min-width: 12rem; }
.ads-table td:nth-child(3) .cselect-trigger { min-width: 10rem; }

/* ---------------------------------------------------------------- WhatsApp calls */
.call-stack {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: var(--z-call);
  display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 32px));
}
.call-card, .call-bar {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--surface-solid); animation: call-in .25s ease-out;
}
.call-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.call-info strong, .call-bar strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-actions { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.call-pulse, .call-dot { flex: none; border-radius: 50%; background: #25a55f; }
.call-pulse { width: 14px; height: 14px; animation: call-pulse 1.2s ease-out infinite; }
.call-dot { width: 10px; height: 10px; }
.call-clock { font-variant-numeric: tabular-nums; color: var(--ink-soft, inherit); }
@keyframes call-pulse { 0% { box-shadow: 0 0 0 0 rgba(37, 165, 95, .6); } 100% { box-shadow: 0 0 0 14px rgba(37, 165, 95, 0); } }
@keyframes call-in { from { opacity: 0; transform: translateY(-8px); } }
@media (prefers-reduced-motion: reduce) { .call-pulse, .call-card, .call-bar { animation: none; } }
@media (max-width: 480px) { .call-card, .call-bar { flex-wrap: wrap; } }
.call-bar { flex-wrap: wrap; }
.call-rec {
  font-size: .7rem; font-weight: 700; letter-spacing: .04em; color: #fff; background: #d6332a;
  border-radius: 4px; padding: 1px 6px; animation: call-rec-blink 1.6s ease-in-out infinite;
}
.call-note { flex-basis: 100%; margin: 0; font-size: .8rem; color: var(--ink-soft, inherit); }
@keyframes call-rec-blink { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .call-rec { animation: none; } }
.rec-line { margin-top: 6px; }
.rec-line .media-audio { width: 100%; min-width: 220px; }
.rec-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .8rem; }

/* Team table on phones: no pinned columns, normal sideways swipe, actions in a ⋯ menu. */
.act-more {
  width: 36px; height: 32px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-solid);
  color: var(--ink); font-size: 1.1rem; line-height: 1; display: inline-grid; place-items: center;
}
.act-more:focus-visible { outline: 0; box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }
/* ------------------------------------------------------------------ phone tables: stacked card rows
   table.table-stack below 768 px: each row is a card, the first column (.col-name) its title,
   every other cell a "Label … value" line (labels copied from <th> by common.js stackTable). */
@media (max-width: 767.98px) {
  .sticky-table:has(.table-stack) { overflow: visible; flex: none; max-height: none; }
  .table-stack { min-width: 0 !important; width: 100%; border-collapse: separate; }
  .table-stack thead { display: none; }
  .table-stack tbody { display: grid; gap: .6rem; }
  .table-stack tr {
    display: block; position: relative; padding: .55rem .8rem; border: 1px solid var(--line);
    border-radius: 14px; background: var(--surface-solid);
  }
  .table-stack tbody tr:hover > td { background: transparent; }
  .table-stack td {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    padding: .3rem 0 !important; border: 0 !important; background: transparent !important; text-align: right;
    position: static !important; box-shadow: none !important; min-width: 0 !important; max-width: none !important; width: auto !important;
  }
  .table-stack td + td { border-top: 1px dashed var(--line) !important; }
  .table-stack td::before {
    content: attr(data-label); flex: none; max-width: 50%; text-align: left;
    color: var(--ink-soft); font-size: .78rem; font-weight: 600;
  }
  .table-stack td:not([data-label])::before, .table-stack td[data-label=""]::before { content: none; }
  .table-stack td.col-name { display: block; text-align: left; font-weight: 600; padding-right: 3rem !important; }
  .table-stack td.col-name::before { content: none; }
  .table-stack td.col-name + td { border-top: 0 !important; }
  .table-stack td.col-actions { position: absolute !important; top: .5rem; right: .6rem; padding: 0 !important; border: 0 !important; }
  .table-stack td.col-actions::before { content: none; }
  .table-stack td .form-control, .table-stack td .form-select, .table-stack td .cselect-trigger { max-width: 60%; }
  .table-stack td.cell-block { display: grid; justify-content: stretch; text-align: left; gap: .25rem; }
  .table-stack td.cell-block .form-control, .table-stack td.cell-block .form-select,
  .table-stack td.cell-block .cselect-trigger { max-width: none; }
  .table-stack tr.skel-row td::before { content: none; }
  .table-stack td.ad-cell { display: flex; justify-content: flex-start; gap: .6rem; }
  /* Open chat on a phone: deal stages on one swipeable line so the messages keep their room. */
  .stage-list { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .stage { flex: none; }
  .table-stack td:last-child:empty { display: none; }
  .ads-table.table-stack td.text-end { justify-content: flex-end; }
}

/* Proof files per deal stage */
.proof-btn {
  display: inline-flex; align-items: center; gap: .15rem; border: 0; background: transparent; color: var(--ink-mute);
  padding: .1rem .3rem; border-radius: 8px; font-size: .75rem; font-weight: 700;
}
.proof-btn .icon { width: 15px; height: 15px; }
.proof-btn:hover { color: var(--ink); background: var(--surface-solid); }
.proof-btn.has-files { color: var(--good); }
.proof-btn:focus-visible { outline: 0; box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }
.proof-list, .proof-uploads { list-style: none; padding: 0; margin: 0 0 .6rem; display: grid; gap: .35rem; }
.proof-list li, .proof-uploads li { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.proof-list a { font-weight: 600; word-break: break-all; }
.proof-list small, .proof-uploads small { color: var(--ink-soft); }
.proof-list button { margin-left: auto; }
.proof-uploads li.is-error small { color: var(--bs-danger); }
.proof-drop {
  display: grid; place-items: center; min-height: 84px; border: 1.5px dashed var(--line); border-radius: 12px;
  color: var(--ink-soft); cursor: pointer; text-align: center; padding: .8rem; margin-bottom: .6rem;
  transition: border-color .15s, background .15s;
}
.proof-drop:hover, .proof-drop.is-over { border-color: var(--indigo); background: var(--surface-2); color: var(--ink); }

/* Facebook ads sync + history */
.ad-cell { display: flex; gap: .6rem; align-items: flex-start; }
.ad-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; background: var(--surface-2); }
.fb-status { margin-right: .3rem; }
.fb-active { color: var(--good); }
.fb-deleted, .fb-disapproved, .fb-with_issues { color: var(--bs-danger); }
.card-wide { grid-column: 1 / -1; }
.adhist-range { width: auto; }
.adhist-figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .6rem; margin-bottom: .8rem; }
.adhist-figs .figure { padding: .6rem .7rem; border-radius: 12px; background: var(--surface-2); display: flex; flex-direction: column; }
.adhist-figs .figure strong { font-size: 1.15rem; }
.adhist-figs .figure span { font-size: .78rem; color: var(--ink-soft); }
.adhist-h { font-size: .85rem; font-weight: 700; margin: .8rem 0 .4rem; }
#adhist .table-responsive, #adhist table { max-width: 100%; }
#adhist { overflow-x: auto; }

/* Ads & packages table: toolbar, sortable headers, auto-save tick */
.ads-toolbar { display: flex; align-items: center; gap: .8rem 1.2rem; flex-wrap: wrap; margin-bottom: .7rem; }
.ads-search { max-width: 340px; flex: 1 1 220px; }
.th-sort { border: 0; background: transparent; color: inherit; font: inherit; padding: 0; display: inline-flex; align-items: center; gap: .3rem; cursor: pointer; }
.th-sort::after { content: "↕"; opacity: .35; font-size: .8em; }
[aria-sort="ascending"] > .th-sort::after { content: "▲"; opacity: .8; }
[aria-sort="descending"] > .th-sort::after { content: "▼"; opacity: .8; }
.th-sort:focus-visible { outline: 0; box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); border-radius: 4px; }
.num > .th-sort { margin-inline: auto; }
.cat-cell { display: flex; align-items: center; gap: .5rem; }
.cat-cell .form-select, .cat-cell .cselect-trigger { min-width: 11rem; }
.save-tick { font-size: .78rem; color: var(--ink-soft); white-space: nowrap; min-width: 4.5rem; }
.save-tick.is-ok { color: var(--good); }
.ads-foot { margin-top: .6rem; }
@media (max-width: 767.98px) { .cat-cell { width: 100%; } .cat-cell .form-select, .cat-cell .cselect-trigger { flex: 1; min-width: 0; } }

/* Ads & packages: sticky pager, clickable rows, ad popup */
.ad-row { cursor: pointer; }
.ad-row:focus-visible { outline: 2px solid var(--indigo); outline-offset: -2px; }
.ad-row:hover .ad-headline { text-decoration: underline; text-underline-offset: 3px; }
.ad-modal-body { display: grid; grid-template-columns: minmax(300px, 420px) minmax(0, 1fr); gap: 1.25rem; }
.ad-formats { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .6rem; }
.ad-format { border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-soft); border-radius: 999px; padding: .2rem .65rem; font-size: .78rem; font-weight: 600; }
.ad-format[aria-selected="true"] { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.ad-frame { display: grid; place-items: start center; min-height: 420px; }
.ad-iframe { width: 100%; max-width: 400px; height: 640px; border: 0; border-radius: 12px; background: #fff; }
.ad-iframe:is(.fmt-facebook_story, .fmt-instagram_story) { height: 720px; }
.ad-sk { width: 100%; height: 420px; }
.ad-nopreview { text-align: center; }
.ad-nopreview img { max-width: 100%; border-radius: 12px; margin-bottom: .6rem; }
.ad-figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .5rem; margin-bottom: .9rem; }
.ad-figs .figure { padding: .55rem .7rem; border-radius: 12px; background: var(--surface-2); display: flex; flex-direction: column; }
.ad-figs .figure strong { font-size: 1.05rem; }
.ad-figs .figure span { font-size: .76rem; color: var(--ink-soft); }
.ad-kvs { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .3rem 1rem; margin-bottom: .8rem; }
.ad-kv { display: flex; justify-content: space-between; gap: .6rem; border-bottom: 1px dashed var(--line); padding: .25rem 0; font-size: .85rem; }
.ad-kv span { color: var(--ink-soft); }
.ad-h { font-size: .85rem; font-weight: 700; margin: .7rem 0 .3rem; }
.ad-text { white-space: pre-wrap; line-height: 1.5; margin: 0; }
@media (max-width: 767.98px) {
  .ad-modal-body { grid-template-columns: 1fr; }
  .ad-iframe { height: 560px; }
}

.fb-card { width: 100%; max-width: 400px; background: #fff; color: #1c1e21; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.15); overflow: hidden; font-size: .9rem; }
.fb-card header { display: flex; align-items: center; gap: .55rem; padding: .7rem .8rem .3rem; }
.fb-card header img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.fb-card header div { display: flex; flex-direction: column; line-height: 1.2; }
.fb-card header small { color: #65676b; font-size: .75rem; }
.fb-card-text { white-space: pre-wrap; padding: .3rem .8rem .8rem; margin: 0; line-height: 1.45; }
.fb-card footer { display: flex; align-items: center; justify-content: space-between; gap: .6rem; background: #f0f2f5; padding: .6rem .8rem; font-weight: 600; }
.fb-card-cta { background: #e4e6eb; border-radius: 6px; padding: .35rem .7rem; font-size: .82rem; }
.fb-card-note { padding: .5rem .8rem .7rem; margin: 0; font-size: .74rem; color: #65676b; }

/* Ads & packages: compact 8-column grid */
.ads-compact { min-width: 980px; font-size: .85rem; }
.ads-compact > :not(caption) > * > * { padding: .45rem .55rem; }
.ads-compact thead th { position: sticky; top: 0; z-index: 2; background: var(--th-bg, var(--surface-solid)); color: var(--th-ink, inherit);
  font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.ads-compact td { border-color: var(--line); }
.ads-compact .num, .ads-compact .nowrap { white-space: nowrap; font-variant-numeric: tabular-nums; }
.ads-compact .ad-cell { display: flex; align-items: center; gap: .55rem; min-width: 240px; }
.ads-compact .ad-thumb { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; flex: none; }
.ads-compact .ad-thumb-empty { display: inline-block; background: var(--surface-2); }
.ads-compact .ad-headline { font-weight: 600; white-space: nowrap; }
.ads-compact tr.is-draft td { box-shadow: none; }
.need-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); flex: none; }
.ads-compact .cat-cell .form-select, .ads-compact .cat-cell .cselect-trigger { min-width: 9.5rem; max-width: 12rem; font-size: .8rem; }
.ads-compact .save-tick { min-width: 3.5rem; font-size: .72rem; }
.ads-compact .cur { font-weight: 500; opacity: .7; text-transform: none; }
.st-pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 600; white-space: nowrap; }
.st-running { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.st-paused { background: color-mix(in srgb, var(--amber) 18%, transparent); color: color-mix(in srgb, var(--amber) 75%, var(--ink)); }
.st-ended { background: var(--surface-2); color: var(--ink-soft); }
.st-issue { background: color-mix(in srgb, var(--bs-danger) 14%, transparent); color: var(--bs-danger); }
.st-review { background: color-mix(in srgb, var(--indigo) 14%, transparent); color: var(--indigo); }
@media (max-width: 767.98px) {
  .ads-compact { min-width: 0; }
  .ads-compact .ad-cell { min-width: 0; }
}

/* Ads & packages: one compact header; on wide screens the table is the only scroller
   (sticky column header inside it) and the pager sits fixed below it. */
.ads-head { display: flex; align-items: center; gap: .4rem 1rem; flex-wrap: wrap; margin-bottom: .55rem; }
.ads-head h2 { margin: 0; display: inline-flex; align-items: center; gap: .45rem; }
.ads-meta { color: var(--ink-soft); font-size: .8rem; margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#ads-sync.is-error .ads-meta { color: var(--bs-danger); }
.info-dot { display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; border: 1px solid var(--line);
  font: 600 .7rem/1 inherit; color: var(--ink-soft); cursor: help; }
.info-dot:focus-visible { outline: 0; box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }
.ads-toolbar { margin-bottom: .55rem; }
.ads-count { margin-left: auto; color: var(--ink-soft); font-size: .8rem; }
.ads-compact > :not(caption) > * > * { padding-block: .35rem; }
.ads-compact .ad-thumb { width: 32px; height: 32px; }
.ads-compact .cat-cell .form-select, .ads-compact .cat-cell .cselect-trigger { min-height: 28px; padding-block: .15rem; }
.ads-compact tbody tr:hover > td { background: var(--row-hover, color-mix(in srgb, var(--indigo) 7%, transparent)); }
.ads-compact thead th[aria-sort="ascending"], .ads-compact thead th[aria-sort="descending"] { color: var(--ink); }
.ads-compact thead th { box-shadow: inset 0 -1px 0 var(--line); }
@media (min-width: 768px) {
  body.ads-mode #settings-page { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; padding-inline: var(--page-pad); }
  body.ads-mode .panel[data-panel="ads"] { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  body.ads-mode .panel[data-panel="ads"] > :not(.ads-scroll) { flex: none; }
  body.ads-mode .ads-scroll { flex: 1; min-height: 0; overflow: auto; border-radius: 10px; }
  body.ads-mode .ads-foot { margin-top: .5rem; }
}
@media (max-width: 767.98px) {
  .ads-meta { margin-left: 0; flex-basis: 100%; white-space: normal; }
  .ads-foot { position: sticky; bottom: 0; z-index: 3; background: var(--surface-solid); padding-block: .6rem; }
}

/* Chat header: name + status pill + ⋮ (WhatsApp style); one thin info row under it */
.thread-head { flex-wrap: nowrap; }
.thread-actions { flex: none; flex-wrap: nowrap; gap: .3rem; }
.status-pill { border: 0; display: inline-flex; align-items: center; gap: .25rem; padding: .25rem .6rem; border-radius: 999px; font-size: .78rem; cursor: pointer; }
.status-pill .icon { width: 13px; height: 13px; }
.status-pill:disabled { cursor: default; opacity: 1; }
.status-pill:disabled .icon { display: none; }
.status-pill:focus-visible, .kebab-btn:focus-visible, .stage-chip:focus-visible { outline: 0; box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }
.kebab-btn { width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; color: var(--ink-soft); display: grid; place-items: center; }
.kebab-btn:hover, .kebab-btn[aria-expanded="true"] { background: var(--surface-2); color: var(--ink); }
.kebab-btn .icon { width: 20px; height: 20px; }
/* Every dropdown menu (status pill, Air Ticket/Visa/Hotel chips, ⋮, Team ⋯) opens in the shared
   popover from controls.js (.cpop-menu); the <ul class="dropdown-menu"> is only its hidden source. */
.cmenu-source { display: none !important; }
.cpop-menu { min-width: 11rem; }
.cpop-menu .copt-text { display: flex; align-items: center; gap: .55rem; font-size: .88rem; }
.cpop-menu .copt-text .icon { width: 16px; height: 16px; opacity: .75; flex: none; }
.cpop-menu .copt.is-danger { color: var(--bad, #C8433A); }
.cpop-menu .copt.copt-sep { margin-top: .55rem; position: relative; }
.cpop-menu .copt.copt-sep::before { content: ""; position: absolute; left: .2rem; right: .2rem; top: -.3rem; border-top: 1px solid var(--line); }
.status-dot, .stage-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: currentColor; }
.stage-dot.is-done { background: var(--good); } .stage-dot.is-pending { background: var(--amber); } .stage-dot.is-na { background: var(--ink-mute, #999); }
.info-row { flex-wrap: nowrap; gap: .5rem; padding-block: .35rem; overflow-x: auto; scrollbar-width: none; }
.info-row > * { flex: none; }
.stage-chip { display: inline-flex; align-items: center; gap: .3rem; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  border-radius: 999px; padding: .15rem .55rem; font-size: .76rem; font-weight: 600; }
.stage-chip b { font-weight: 700; }
.stage-chip.is-done { border-color: color-mix(in srgb, var(--good) 45%, transparent); color: var(--good); background: color-mix(in srgb, var(--good) 10%, transparent); }
.stage-chip.is-pending b { color: var(--amber); }
.stage-chip.is-na { color: var(--ink-soft); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--ink-soft) 50%, transparent); }
.stage-chip:disabled { opacity: 1; cursor: default; }
.stage-files { display: inline-flex; align-items: center; gap: .1rem; font-size: .7rem; color: var(--ink-soft); }
.stage-files .icon { width: 12px; height: 12px; }
.win-text { display: inline-flex; align-items: center; gap: .3rem; margin-left: auto; font-size: .76rem; color: var(--ink-soft); white-space: nowrap; }
.win-text .icon { width: 14px; height: 14px; }
.win-text.is-low { color: var(--amber); } .win-text.is-closed { color: var(--rose, var(--bs-danger)); }
.win-text[hidden] { display: none; }
@media (max-width: 991.98px) {
  .thread-actions { width: auto; }
  .info-row .pkg-chip span:not(.pkg-dot) { max-width: 9rem; }
}

/* Phones: the chat column must never be wider than the screen. A plain 1fr track grows to
   its widest content (the one-line info row), pushing the header and bubbles off-screen. */
.pane-thread, .thread, .thread-head, .info-row, .messages { min-width: 0; }
@media (max-width: 991.98px) {
  .inbox { grid-template-columns: minmax(0, 1fr); }
  .who p { white-space: nowrap; }  /* subtitle on one line, ellipsised */
}

/* Trip menu (trip_bot) */
.trip-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 600;
  background: color-mix(in srgb, var(--indigo) 10%, transparent); color: var(--ink); white-space: nowrap; }
.trip-chip.is-active { background: color-mix(in srgb, var(--amber) 14%, transparent); }
.trip-chip[hidden] { display: none; }

/* Settings → Packages */
.pkg-head { display: flex; align-items: center; gap: .5rem 1rem; flex-wrap: wrap; margin-bottom: .8rem; }
.pkg-head h2 { margin: 0; display: inline-flex; align-items: center; gap: .45rem; }
.pkg-head #pkg-add { margin-left: auto; }
.pkg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .9rem; }
.pkg-card { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface-solid); cursor: pointer;
  display: flex; flex-direction: column; transition: transform .15s var(--ease), box-shadow .15s var(--ease); }
.pkg-card:hover, .pkg-card:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow); outline: 0; }
.pkg-card.is-off { opacity: .6; }
.pkg-card img, .pkg-noimg { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.pkg-noimg { display: grid; place-items: center; background: var(--surface-2); color: var(--ink-soft); font-size: .85rem; }
.pkg-body { padding: .65rem .75rem .7rem; display: grid; gap: .2rem; }
.pkg-kind { font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--ink-soft); }
.pkg-name { line-height: 1.25; }
.pkg-facts { font-size: .8rem; color: var(--ink-soft); }
.pkg-foot { display: flex; align-items: center; justify-content: space-between; margin-top: .3rem; }
.pkg-price { font-weight: 700; font-variant-numeric: tabular-nums; }
.pkg-edit { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 1rem; }
.pkg-img-drop { display: grid; place-items: center; aspect-ratio: 1; border: 1.5px dashed var(--line); border-radius: 12px; overflow: hidden;
  cursor: pointer; text-align: center; color: var(--ink-soft); background: var(--surface-2); }
.pkg-img-drop img { width: 100%; height: 100%; object-fit: cover; }
.pkg-caption { white-space: pre-wrap; font: inherit; font-size: .78rem; background: #e9f7ef; color: #1c1e21; border-radius: 10px; padding: .6rem .7rem;
  max-height: 220px; overflow: auto; margin: 0; }
@media (max-width: 767.98px) { .pkg-edit { grid-template-columns: 1fr; } }

/* Phone: Team page scrolls normally (the desktop fixed-header table layout doesn't apply to card rows) */
@media (max-width: 767.98px) {
  .team-panel { display: block; }
}

/* Phone "Me" tab + sheet */
.tab-avatar { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; font-weight: 700;
  background: var(--indigo); color: #fff; }
.me-sheet { height: auto !important; max-height: 80vh; border-radius: 20px 20px 0 0; background: var(--surface-solid); color: var(--ink); }
.me-sheet .offcanvas-header { gap: .7rem; border-bottom: 1px solid var(--line); }
.me-avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--indigo); color: #fff; flex: none; }
.me-who { flex: 1; min-width: 0; }
.me-who small { color: var(--ink-soft); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-sheet .offcanvas-body { display: grid; gap: .25rem; padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
.me-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; width: 100%; padding: .85rem .4rem; border: 0;
  border-bottom: 1px solid var(--line); background: transparent; color: inherit; font-size: .95rem; text-align: left; cursor: pointer; }
.me-row > span:first-child { display: inline-flex; align-items: center; gap: .6rem; }
.me-row .icon { width: 18px; height: 18px; opacity: .75; }
.me-row .form-check-input { margin: 0; width: 2.4em; height: 1.3em; }
.me-chev, .me-state { color: var(--ink-soft); }
.me-logout { color: var(--bs-danger); border-bottom: 0; }
.me-row:focus-visible { outline: 0; box-shadow: inset 0 0 0 2px var(--bs-focus-ring-color); border-radius: 8px; }

/* Dashboard → Ads history: funnel + clicked-vs-chatted bars */
.ad-funnel { display: flex; align-items: stretch; gap: .4rem; flex-wrap: wrap; margin-bottom: .6rem; }
.ad-funnel-step { flex: 1 1 140px; border-radius: 12px; padding: .65rem .8rem; display: flex; flex-direction: column; gap: .1rem; }
.ad-funnel-step strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.ad-funnel-step span { font-size: .76rem; color: var(--ink-soft); }
.ad-funnel-step.s0 { background: var(--surface-2); }
.ad-funnel-step.s1 { background: color-mix(in srgb, var(--amber) 16%, transparent); }
.ad-funnel-step.s2 { background: color-mix(in srgb, var(--good) 16%, transparent); }
.ad-funnel-arrow { display: grid; place-items: center; align-content: center; color: var(--ink-soft); font-size: 1.1rem; min-width: 2.6rem; }
.ad-funnel-arrow small { font-size: .72rem; font-weight: 700; color: var(--ink); }
.ad-pairs { display: grid; gap: .55rem; margin-bottom: .6rem; }
.ad-pairs-legend { display: flex; align-items: center; gap: .4rem .8rem; flex-wrap: wrap; font-size: .76rem; color: var(--ink-soft); }
.ad-pairs-legend .k { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-right: -.4rem; }
.k-click { background: color-mix(in srgb, var(--amber) 55%, transparent); }
.k-chat { background: var(--good); }
.ad-pair { display: grid; grid-template-columns: minmax(150px, 220px) minmax(0, 1fr) 150px; gap: .8rem; align-items: center; }
.ad-pair-name { font-size: .82rem; font-weight: 600; line-height: 1.2; overflow: hidden; }
.ad-pair-name small { display: block; font-weight: 400; color: var(--ink-soft); font-size: .72rem; }
.ad-pair-bars { display: grid; gap: 3px; }
.ad-bar { height: 10px; border-radius: 5px; min-width: 2px; transition: width .6s var(--ease); }
.ad-pair-num { text-align: right; font-size: .8rem; font-variant-numeric: tabular-nums; }
.ad-pair-num small { display: block; color: var(--ink-soft); font-size: .72rem; }
@media (max-width: 767.98px) {
  .ad-pair { grid-template-columns: 1fr auto; }
  .ad-pair-bars { grid-column: 1 / -1; grid-row: 2; }
  .ad-funnel-arrow { min-width: 100%; grid-auto-flow: column; gap: .4rem; }
}

/* Ads history: ⓘ notes + each-day chart */
.info-tip { border: 0; background: transparent; padding: 0 0 0 .25rem; color: var(--ink-soft); line-height: 1; vertical-align: -2px; cursor: help; }
.info-tip .icon { width: 14px; height: 14px; }
.info-tip:hover, .info-tip:focus-visible { color: var(--ink); }
.ad-funnel-arrow .info-tip { padding: 0; }
.tip-text { max-width: 280px; white-space: normal; line-height: 1.35; }
#dash-tip { max-width: 320px; }
.ad-daily { margin: .4rem 0 .8rem; }
.ad-daily-head { display: flex; align-items: center; gap: .6rem 1rem; flex-wrap: wrap; margin-bottom: .4rem; }
.ad-daily-nav { display: inline-flex; align-items: center; gap: .4rem; }
.ad-daily-nav strong { min-width: 9.5rem; text-align: center; font-size: .9rem; }
.ad-daily-nav .btn { padding: 0 .55rem; line-height: 1.5; }
.ad-daily-head .ad-pairs-legend { margin-left: auto; }
.ad-daily-scroll { overflow-x: auto; }
.daily-svg { display: block; width: 100%; min-width: 560px; height: auto; }
.daily-svg .bar-click { fill: color-mix(in srgb, var(--amber) 70%, transparent); }
.daily-svg .bar-chat { fill: var(--good); }
.daily-svg .daily-hit { fill: transparent; }
.daily-svg .daily-day:hover .daily-hit { fill: color-mix(in srgb, var(--ink) 5%, transparent); }
.daily-svg .grid { stroke: var(--line); stroke-dasharray: 3 4; }
.daily-svg .baseline { stroke: color-mix(in srgb, var(--ink) 22%, transparent); }
.daily-svg .axis { fill: var(--ink-mute); font-size: 11px; font-variant-numeric: tabular-nums; }
.daily-svg .daily-sep { opacity: .5; }

/* ------------------------------------------------------------------ smooth page / tab switches */
/* Full page loads: the browser keeps the old page until the new one has painted, then cross-fades.
   In-app page changes (nav.js) use the page loader below instead.
   Sidebar and phone tab bar have their own names, so they hold still instead of fading. */
@view-transition { navigation: auto; }
#sidebar { view-transition-name: sidebar; }
.tabbar { view-transition-name: tabbar; }
::view-transition-old(root) { animation: 140ms ease-out both vt-out; }
::view-transition-new(root) { animation: 200ms ease-out both vt-in; }
::view-transition-group(sidebar), ::view-transition-group(tabbar) { animation-duration: 0s; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; } }

/* Content that replaces a skeleton or the previous tab fades in; content being reloaded dims. */
.fade-in { animation: fade 200ms var(--ease) both; }
.is-refreshing { opacity: .55; transition: opacity .15s var(--ease); }

/* Thin progress line at the top: only for requests / page loads slower than 150 ms. */
#nav-progress { position: fixed; inset: env(safe-area-inset-top, 0px) 0 auto 0; height: 2px; z-index: calc(var(--z-tooltip) + 1); pointer-events: none;
  overflow: hidden; opacity: 0; transition: opacity .2s; }
#nav-progress.on { opacity: 1; }
#nav-progress::before { content: ""; position: absolute; inset: 0; width: 40%; background: var(--indigo);
  box-shadow: 0 0 8px var(--indigo); animation: nav-progress 1.1s var(--ease) infinite; }
@keyframes nav-progress { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

/* Skeletons: inbox chat rows, packages, generic panel rows. */
.sk-conv { display: grid; grid-template-columns: 36px 1fr; gap: .35rem .7rem; padding: .7rem .6rem; border-bottom: 1px solid var(--line); }
.sk-conv .sk-avatar { width: 36px; height: 36px; border-radius: 50%; grid-row: span 2; }
.sk-conv .sk-line { height: 9px; align-self: center; }
.sk-line { height: 10px; }
.sk-line.short { width: 55%; }
.sk-card { height: 220px; border-radius: var(--radius); }
.sk-rows { display: grid; gap: .7rem; padding: .4rem 0; }
.figures .sk { height: 74px; border-radius: var(--radius-sm); }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .fade-in, #nav-progress::before { animation: none; }
}

/* ------------------------------------------------------------------ page loader → reveal */
.page-loader { display: none; }
html.is-loading .workspace { position: relative; overflow: hidden; }
html.is-loading .workspace > :not(.page-loader),
html.is-loading .login-wrap { opacity: 0; pointer-events: none; transition: opacity .12s var(--ease); }  /* in-app page change: old page fades out */
html.is-loading .page-loader {
  display: grid; place-content: center; justify-items: center; gap: .9rem; position: absolute; inset: 0; z-index: 5;
  color: var(--ink-soft); font-size: .85rem; font-weight: 500; letter-spacing: .01em;
  animation: loader-in .3s var(--ease) .2s both;  /* fast pages never show it */
}
body > .page-loader { position: fixed; }
html.is-loading body > .page-loader { position: fixed; }
.page-loader-mark { position: relative; width: 56px; height: 56px; display: grid; place-items: center; }
.page-loader-mark::before { content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2.5px solid color-mix(in srgb, var(--indigo) 18%, transparent); border-top-color: var(--indigo);
  animation: loader-spin .9s linear infinite; }
.page-loader-mark .brand-mark { width: 30px; height: 30px; box-shadow: none; animation: loader-pulse 1.4s ease-in-out infinite; }
@keyframes loader-in { from { opacity: 0; transform: translateY(4px); } }
@keyframes loader-spin { to { transform: rotate(360deg); } }
@keyframes loader-pulse { 50% { transform: scale(.82); opacity: .75; } }
/* Reveal: the finished page fades in with a small rise. */
html.is-revealed .workspace > :not(.page-loader),
html.is-revealed .login-wrap { animation: page-reveal .24s var(--ease) both; }
@keyframes page-reveal { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) {
  html.is-loading .page-loader { animation: none; }
  .page-loader-mark::before, .page-loader-mark .brand-mark { animation: none; }
  html.is-revealed .workspace > :not(.page-loader), html.is-revealed .login-wrap { animation: none; }
}

/* ------------------------------------------------------------------ colourful pills (soft tint)
   Every pill: pale background + strong text in its colour + a small dot. Colour comes from --pc,
   so light/dark only swap the palette below. */
:root {
  --pc-amber: #A86A00; --pc-blue: #1E5BB8; --pc-green: #1D7A41; --pc-grey: #5C6577; --pc-violet: #6B3FB8;
  --pc-teal: #0B7C72; --pc-rose: #C0362C; --pc-orange: #C2570C; --pc-pink: #B4237A; --pc-indigo: #3F49C9;
}
[data-bs-theme="dark"] {
  --pc-amber: #F1C270; --pc-blue: #8DB8F7; --pc-green: #8FD39A; --pc-grey: #AEB6C6; --pc-violet: #C5B6F5;
  --pc-teal: #7FD8CC; --pc-rose: #FF9A90; --pc-orange: #FFB27A; --pc-pink: #F59AD0; --pc-indigo: #A9B0FF;
}
.chip, .tag, .pill, .st-pill, .waiting-for, .stage-chip {
  --pc: var(--pc-grey);
  display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap;
  border-radius: 999px; padding: .08rem .55rem; font-size: .73rem; font-weight: 600; line-height: 1.5;
  color: var(--pc); background: color-mix(in srgb, var(--pc) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--pc) 22%, transparent);
}
.chip::before, .tag::before, .pill::before, .st-pill::before, .waiting-for::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none;
}
/* chat status */
.chip.s-new, .status-pill.s-new { --pc: var(--pc-amber); }
.chip.s-in_progress, .status-pill.s-in_progress { --pc: var(--pc-blue); }
.chip.s-quoted, .status-pill.s-quoted { --pc: var(--pc-violet); }
.chip.s-follow_up, .status-pill.s-follow_up { --pc: var(--pc-teal); }
.chip.s-won, .status-pill.s-won { --pc: var(--pc-green); }
.chip.s-lost, .status-pill.s-lost { --pc: var(--pc-grey); }
.status-pill.chip { font-size: .78rem; padding: .22rem .65rem; }
.status-pill.chip::before { display: none; }  /* the header pill has its own dot */
/* inbox list tags */
.tag-ad { --pc: var(--pc-pink); }
.tag-direct { --pc: var(--pc-teal); border-style: solid; }
.tag-pkg { --pc: var(--pc-indigo); display: inline-flex; }
.tag-returning { --pc: var(--pc-orange); }
.tag-owner { --pc: var(--pc-grey); }
.tag-owner.is-me { --pc: var(--pc-blue); }
.tag-draft { --pc: var(--pc-amber); }
.tag-sample { --pc: var(--pc-amber); }
.tag-default { --pc: var(--pc-blue); }
.tag-off { --pc: var(--pc-grey); }
/* categories: their own saved colour */
.tag-dept { --pc: currentColor; }
.tag-dept::before { display: none; }
.waiting-for { --pc: var(--pc-amber); }
.waiting-for.is-overdue { --pc: var(--pc-rose); }
/* ads table */
.st-running { --pc: var(--pc-green); }
.st-paused { --pc: var(--pc-amber); }
.st-ended { --pc: var(--pc-grey); }
.st-issue { --pc: var(--pc-rose); }
.st-review { --pc: var(--pc-blue); }
/* team table */
.pill-role-superadmin { --pc: var(--pc-violet); }
.pill-role-admin { --pc: var(--pc-blue); }
.pill-role-agent { --pc: var(--pc-teal); }
.pill-on { --pc: var(--pc-green); }
.pill-away { --pc: var(--pc-amber); }
.pill-off { --pc: var(--pc-grey); }
/* deal chips: Air Ticket / Visa / Hotel */
.stage-chip { font-size: .76rem; padding: .15rem .6rem; color: var(--ink); --pc: var(--pc-grey); }
.stage-chip.is-done { --pc: var(--pc-green); color: var(--pc); }
.stage-chip.is-pending { --pc: var(--pc-amber); }
.stage-chip.is-pending b { color: var(--pc); }
.stage-chip.is-na { --pc: var(--pc-grey); color: var(--ink-soft); }

/* ------------------------------------------------------------------ fixed page footer */
/* The header's twin, flipped: same height, padding and glass; the divider sits on top. */
.page-bar, .page-foot { min-height: 58px; }
.page-foot {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .8rem clamp(.85rem, 2vw, 1.5rem); border-top: 1px solid var(--line); background: var(--surface);
  font-size: .85rem; color: var(--ink-soft);
}
.page-foot .foot-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-foot .foot-end { margin-left: auto; display: inline-flex; align-items: center; gap: .5rem; flex: none; }
.foot-block { display: flex; align-items: center; gap: .6rem 1rem; width: 100%; min-width: 0; }
.foot-block[hidden] { display: none; }
.foot-dirty { display: inline-flex; align-items: center; gap: .4rem; color: var(--pc-amber, var(--amber)); font-weight: 600; }
.foot-dirty::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.foot-dirty[hidden] { display: none; }
@media (max-width: 575.98px) {
  .page-foot { padding-inline: .8rem; min-height: 48px; }
  .page-foot .btn { padding-inline: .7rem; }
}


/* Pagers living in the page footer (Team, Settings → Ads): summary · pages · rows per page. */


/* ------------------------------------------------------------------ Settings tabs in the fixed header */
.settings-bar { row-gap: .55rem; padding-bottom: .65rem; }
.settings-bar .settings-tabs { flex: 1 1 100%; min-width: 0; }
.settings-tabs {
  display: flex; gap: .3rem; overflow-x: auto; overflow-y: hidden; padding: 2px; margin: -2px;
  scrollbar-width: none; overscroll-behavior-x: contain;
  --fade-l: 0px; --fade-r: 0px;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
}
.settings-tabs::-webkit-scrollbar { display: none; }
.settings-tabs.can-left { --fade-l: 28px; }
.settings-tabs.can-right { --fade-r: 28px; }
.settings-tabs button { flex: none; min-height: 34px; line-height: 1.2; }
.settings-tabs button:hover:not(.active) { color: var(--ink); border-color: color-mix(in srgb, var(--indigo) 35%, var(--line)); }
.settings-tabs button:focus-visible { outline: 0; box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }
@media (max-width: 575.98px) {
  .settings-tabs button { padding: .3rem .7rem; font-size: .82rem; }
}

/* ------------------------------------------------------------------ dashboard layout: greeting in the header,
   KPI row, then two rows of charts that fit the screen (Facebook ads; New leads + busy hours), rest scrolls. */
.dash-title { display: flex; align-items: baseline; gap: .2rem .7rem; flex-wrap: wrap; min-width: 0; }
.dash-title h1 { font-size: 1.15rem; }
.dash-title .hint { margin: 0; font-size: .82rem; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.dash-fold { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.dash-fold.one-row { grid-template-rows: minmax(0, 1fr); }
.dash-fold > .card { min-height: 0; overflow: hidden; }
.dash-fold .card-body { flex: 1; min-height: 0; position: relative; }
.dash-fold .ad-daily-scroll { overflow: hidden; }
.dash-fold .daily-svg { min-width: 0; }
.dash-fold .ad-daily-head { flex-wrap: nowrap; margin-bottom: .2rem; gap: .6rem; }
.dash-fold .ad-daily-head .ad-pairs-legend { margin-left: auto; font-size: .72rem; flex-wrap: nowrap; white-space: nowrap; }
.dash-fold .ad-daily-nav strong { min-width: 7.5rem; font-size: .85rem; }
/* Funnel as three stacked steps in its card */
#funnel .ad-funnel { flex-wrap: nowrap; height: 100%; align-items: stretch; gap: .35rem; margin: 0; }
#funnel .ad-funnel-step { flex: 1 1 0; min-width: 0; justify-content: center; padding: .6rem .8rem; border-radius: 14px; }
#funnel .ad-funnel-step strong { font-size: clamp(1.05rem, 1.6vw, 1.5rem); }
#funnel .ad-funnel-arrow { min-width: 2.4rem; flex: none; }
/* Busy-hours map fills its card */
.dash-fold #heat { display: flex; flex-direction: column; }
.dash-fold #heat .heat { flex: 1 1 0; min-height: 0; grid-template-rows: auto repeat(7, minmax(0, 1fr)); align-items: stretch; align-content: stretch; }
.dash-fold #heat .heat-cell { aspect-ratio: auto; min-height: 0; }
.dash-fold #heat .heat-day, .dash-fold #heat .heat-hour { align-self: center; }

/* A little colour: soft tinted cards, a blue→teal trend line, a teal→blue busy-hours ramp */
.card-fb { background: linear-gradient(160deg, color-mix(in srgb, var(--indigo) 9%, var(--surface)) 0%, var(--surface) 70%); }
.card-leads { background: linear-gradient(160deg, color-mix(in srgb, #2B8FB3 10%, var(--surface)) 0%, var(--surface) 70%); }
.card-heat { background: linear-gradient(160deg, color-mix(in srgb, #1F9E8F 10%, var(--surface)) 0%, var(--surface) 70%); }
.trend-line { stroke: url(#trend-stroke); stroke-width: 2.5; }
.trend-stroke-a { stop-color: var(--indigo); }
.trend-stroke-b { stop-color: #1F9E8F; }
.trend-stop-top { stop-color: #2B8FB3; stop-opacity: .3; }
:root { --heat-1: #CDEFEA; --heat-2: #93D9D0; --heat-3: #4FB8C4; --heat-4: #2F82C6; --heat-5: #1E4FA8; }
[data-bs-theme="dark"] { --heat-1: #12364A; --heat-2: #155E6E; --heat-3: #1F8C9A; --heat-4: #3E9BE0; --heat-5: #9CCBFA; }

@media (max-width: 991.98px) {
  .dash-fold { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; height: auto !important; }
  .dash-fold > .card { min-height: 280px; }
  .dash-fold .card-body { min-height: 220px; }
  .dash-title .hint { display: none; }
}

@media (max-width: 991.98px) {
  #funnel .ad-funnel { flex-wrap: wrap; }
  .dash-fold .ad-daily-head { flex-wrap: wrap; }
}
.card-heat { --heat-0: color-mix(in srgb, #1F9E8F 9%, transparent); }

/* ------------------------------------------------------------------ Facebook charts: stacked daily bars, donut, months area */
.k-noreply { background: color-mix(in srgb, var(--pc-amber, #B7791F) 55%, transparent); }
.daily-svg .bar-chat { fill: var(--good); }
.daily-svg .bar-noreply { fill: color-mix(in srgb, var(--pc-amber, #B7791F) 55%, transparent); }
.daily-svg .axis-rot { font-size: 10px; }
.daily-svg .daily-day rect:not(.daily-hit) { animation: grow-y .5s var(--ease) both; animation-delay: calc(var(--i) * 12ms); transform-box: fill-box; transform-origin: bottom; }
@keyframes grow-y { from { transform: scaleY(0); } }
.ad-donut { display: flex; align-items: center; justify-content: center; gap: 1.4rem; height: 100%; flex-wrap: wrap; }
.ad-donut-chart { height: 100%; max-height: 210px; aspect-ratio: 1; min-height: 140px; }
.donut { width: 100%; height: 100%; display: block; }
.donut-track { fill: none; stroke: var(--surface-2); }
.donut-seg { fill: none; transition: stroke-width .15s; cursor: default; }
.donut-seg:hover { stroke-width: 26; }
.donut-chat { stroke: var(--good); }
.donut-noreply { stroke: color-mix(in srgb, var(--pc-amber, #B7791F) 60%, transparent); }
.donut-num { font-size: 26px; font-weight: 700; fill: var(--ink); font-variant-numeric: tabular-nums; }
.donut-cap { font-size: 12px; fill: var(--ink-soft); }
.ad-donut-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; font-size: .85rem; }
.ad-donut-legend li { display: flex; align-items: center; gap: .45rem; }
.ad-donut-legend .k { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: none; }
.ad-donut-legend b { font-variant-numeric: tabular-nums; }
.ad-donut-legend .muted { color: var(--ink-soft); font-size: .78rem; }
.months-svg { margin-bottom: .4rem; }
.months-line { fill: none; stroke: var(--indigo); stroke-width: 2.5; stroke-linecap: round; }
.months-area { fill: url(#months-fill); animation: fade .9s var(--ease) both .2s; }
.months-stop-top { stop-color: var(--indigo); stop-opacity: .28; }
.months-stop-bottom { stop-color: var(--indigo); stop-opacity: .03; }
.months-dot { fill: var(--surface-solid); stroke: var(--indigo); stroke-width: 2; }
.months-dot:hover { fill: var(--indigo); r: 5; }
@media (prefers-reduced-motion: reduce) { .daily-svg .daily-day rect { animation: none; } }

/* Dashboard cards: title only (sub-text in the ⓘ badge), tighter head so charts get the room */
.dash .card { gap: .5rem; }
.dash .card-head { align-items: center; }
.dash .card-head h2 { display: inline-flex; align-items: center; gap: .1rem; }
.dash .card-head .hint[hidden] { display: none; }
.dash .card-head .info-tip .icon { width: 15px; height: 15px; }

/* Card title row: tools (date switcher, legend) on the right */
.card-tools { display: flex; align-items: center; gap: .4rem .9rem; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; min-width: 0; }
.card-tools .ad-pairs-legend { font-size: .72rem; flex-wrap: nowrap; white-space: nowrap; margin: 0; }
.card-tools .ad-daily-nav { gap: .3rem; }
.card-tools .ad-daily-nav strong { min-width: 0; font-size: .8rem; white-space: nowrap; }
.card-tools .ad-daily-nav .btn { padding: 0 .45rem; line-height: 1.4; }
#card-daily .card-head > div:first-child { flex: none; }

/* ------------------------------------------------------------------ Facebook charts in the CRM blues
   One palette for every ad chart: deep blue = messaged on WhatsApp, light blue = clicked but didn't
   message / ad clicks. Defined once here; it overrides the earlier green/amber rules. */
:root { --fb-strong: var(--indigo); --fb-soft: color-mix(in srgb, var(--indigo) 32%, transparent); }
[data-bs-theme="dark"] { --fb-soft: color-mix(in srgb, var(--indigo) 38%, transparent); }
.k-chat, .ad-bar.k-chat { background: var(--fb-strong); }
.k-click, .ad-bar.k-click, .k-noreply { background: var(--fb-soft); }
.daily-svg .bar-chat { fill: var(--fb-strong); }
.daily-svg .bar-click, .daily-svg .bar-noreply { fill: var(--fb-soft); }
.donut-chat { stroke: var(--fb-strong); }
.donut-noreply { stroke: var(--fb-soft); }
.donut-track { stroke: color-mix(in srgb, var(--indigo) 8%, transparent); }
.ad-funnel-step.s1 { background: color-mix(in srgb, var(--indigo) 12%, transparent); }
.ad-funnel-step.s2 { background: color-mix(in srgb, var(--indigo) 22%, transparent); }

/* New leads + busy hours: same CRM blues (no teal) */
.card-leads, .card-heat { background: linear-gradient(160deg, color-mix(in srgb, var(--indigo) 9%, var(--surface)) 0%, var(--surface) 70%); }
.trend-stroke-b { stop-color: color-mix(in srgb, var(--indigo) 55%, white); }
.trend-stop-top { stop-color: var(--indigo); stop-opacity: .26; }
:root { --heat-1: #D6E4FA; --heat-2: #A9C6F2; --heat-3: #6E9FE6; --heat-4: #3A75CF; --heat-5: #1A4C9C; }
[data-bs-theme="dark"] { --heat-1: #15284A; --heat-2: #1E3F78; --heat-3: #2F63B8; --heat-4: #5B92E8; --heat-5: #A9C9F7; }
.card-heat { --heat-0: color-mix(in srgb, var(--indigo) 7%, transparent); }
.dash.quiet :is(.daily-svg .daily-day rect, .months-area, .ad-daily, #funnel, #daily) { animation: none !important; }

/* ------------------------------------------------------------------ dashboard on phones (Android / iPhone) */
@media (max-width: 767.98px) {
  /* Header: greeting + Live on one line, period buttons as a full-width row; the office pill is on the Inbox. */
  .page-bar:has(#greet) { row-gap: .5rem; padding-block: .6rem; }
  .page-bar:has(#greet) .open-pill, .page-bar:has(#greet) .spacer { display: none; }
  .page-bar:has(#greet) .dash-title { flex: 1 1 auto; }
  .page-bar:has(#greet) .dash-title h1 { font-size: 1.05rem; }
  .page-bar:has(#greet) .live-pill { margin-left: auto; }
  .page-bar:has(#greet) .dash-period { flex: 1 1 100%; display: grid; grid-template-columns: repeat(4, 1fr); }
  .page-bar:has(#greet) .dash-period button { padding-block: .4rem; }
  /* KPIs: two compact columns, the odd one out spans both */
  .dash .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .dash .kpi { min-height: 0; padding: .75rem .8rem; gap: .25rem; border-radius: 16px; }
  .dash .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .dash .kpi-num { font-size: 1.55rem; }
  .dash .kpi-reply .kpi-num { font-size: 1.3rem; }
  .dash .kpi-foot { font-size: .72rem; gap: .2rem .4rem; }
  .dash .kpi .spark { display: none; }
  .dash .kpi .delta-vs { display: none; }
  /* Cards: a little tighter */
  .dash .card { padding: .85rem; border-radius: 16px; }
  .dash .card-head { flex-wrap: wrap; row-gap: .4rem; }
  .card-tools { justify-content: flex-start; margin-left: 0; flex: 1 1 100%; }
  .ad-donut { gap: .8rem; }
  .ad-donut-chart { max-height: 170px; min-height: 130px; }
}
/* Touch screens: comfortable tap areas without changing the look */
@media (pointer: coarse) {
  .dash .info-tip { position: relative; }
  .dash .info-tip::after { content: ""; position: absolute; inset: -10px; }
  .card-tools .ad-daily-nav .btn { min-width: 36px; min-height: 34px; }
  .dash .table-toggle { min-height: 34px; padding-inline: .6rem; }
}

/* Ad spend → WhatsApp chats (top of the dashboard): spend = pale blue bars (left scale),
   ad clicks = mid-blue line, WhatsApp chats = deep blue line (right scale). CRM blues only. */
#card-adperf .card-body { min-height: 220px; display: flex; flex-direction: column; gap: .35rem; }
.perf-figs { display: flex; flex-wrap: wrap; gap: .3rem .5rem; font-size: .8rem; color: var(--ink-soft); }
.perf-fig { padding: .15rem .55rem; border-radius: 999px; background: color-mix(in srgb, var(--indigo) 8%, transparent); white-space: nowrap; }
.perf-fig b { color: var(--ink); font-variant-numeric: tabular-nums; }
.perf-fig.muted { background: none; padding-inline: .2rem; }
.perf-svg { display: block; width: 100%; height: auto; overflow: visible; }
.perf-svg .grid { stroke: var(--line); stroke-dasharray: 3 4; }
.perf-svg .baseline { stroke: color-mix(in srgb, var(--ink) 22%, transparent); }
.perf-svg .axis { fill: var(--ink-mute); font-size: 11px; font-variant-numeric: tabular-nums; }
.perf-svg .axis-rot { font-size: 10px; }
.perf-svg .axis-cap { font-size: 10px; font-weight: 600; }
.perf-spend { fill: color-mix(in srgb, var(--indigo) 16%, transparent); stroke: color-mix(in srgb, var(--indigo) 38%, transparent); stroke-width: 1;
  animation: grow-y .5s var(--ease) both; animation-delay: calc(var(--i) * 25ms); transform-box: fill-box; transform-origin: bottom; }
.perf-line { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.perf-line.perf-click { stroke: color-mix(in srgb, var(--indigo) 55%, var(--surface-solid)); stroke-width: 2.2; stroke-dasharray: 6 4; }
.perf-line.perf-chat { stroke: var(--indigo); stroke-width: 3; }
.perf-dot { stroke: var(--surface-solid); stroke-width: 1.5; }
.perf-dot.perf-click { fill: color-mix(in srgb, var(--indigo) 60%, var(--surface-solid)); }
.perf-dot.perf-chat { fill: var(--indigo); }
.perf-hit { fill: transparent; cursor: default; }
.perf-hit:hover { fill: color-mix(in srgb, var(--indigo) 5%, transparent); }
.perf-legend .k { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-right: -.4rem; }
.perf-legend .k-spend { background: color-mix(in srgb, var(--indigo) 16%, transparent); border: 1px solid color-mix(in srgb, var(--indigo) 38%, transparent); }
.perf-legend .k-line { width: 18px; height: 0; border-top: 3px solid; display: inline-block; margin-right: -.3rem; border-radius: 2px; }
.perf-legend .k-line.perf-click { border-top: 2px dashed color-mix(in srgb, var(--indigo) 55%, var(--surface-solid)); }
.perf-legend .k-line.perf-chat { border-color: var(--indigo); }
.dash-tip .tip-strong { font-weight: 700; margin-top: .15rem; }
.dash.quiet .perf-spend { animation: none; }
@media (prefers-reduced-motion: reduce) { .perf-spend { animation: none; } }
@media (max-width: 767.98px) { .perf-figs { font-size: .74rem; } }

/* ------------------------------------------------------------------ testimonial videos (Settings tab + chat picker) */
.vid-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .9rem; }
.vid-card { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface-solid); cursor: pointer;
  transition: transform .15s var(--ease), box-shadow .15s var(--ease); }
.vid-card:hover, .vid-card:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow); outline: 0; }
.vid-card.is-off { opacity: .6; }
.vid-thumb { position: relative; aspect-ratio: 16 / 10; background: color-mix(in srgb, var(--indigo) 12%, var(--surface-2)); display: grid; place-items: center; overflow: hidden; }
.vid-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vid-nothumb { color: var(--ink-soft); font-size: .8rem; }
.vid-play { position: absolute; inset: 50% auto auto 50%; translate: -50% -50%; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0, 0, 0, .45); color: #fff; font-size: .85rem; padding-left: 3px; }
.vid-dur { position: absolute; right: .4rem; bottom: .4rem; background: rgba(0, 0, 0, .6); color: #fff; font-size: .72rem; font-weight: 600;
  padding: .05rem .4rem; border-radius: 6px; font-variant-numeric: tabular-nums; }
.vid-edit { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
.vid-edit-media { display: grid; gap: .5rem; align-content: start; }
.vid-edit-media video { width: 100%; max-height: 320px; border-radius: 12px; background: #000; }
.vid-drop { display: grid; place-items: center; aspect-ratio: 16 / 10; border: 1.5px dashed var(--line); border-radius: 12px; cursor: pointer;
  text-align: center; color: var(--ink-soft); padding: 1rem; margin: 0; }
.vid-drop:hover { border-color: var(--indigo); color: var(--ink); }
.vid-drop[hidden] { display: none; }
.vid-file-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-height: 31px; }
.vid-progress { height: 6px; }
@media (max-width: 767.98px) { .vid-edit { grid-template-columns: minmax(0, 1fr); } .vid-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } }

/* Chat: 🎬 button + picker */
.video-btn { flex: none; }
.vpick-tools { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 11rem); gap: .5rem; margin-bottom: .6rem; }
.vpick-list { display: grid; gap: .35rem; }
.vpick-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: .7rem; align-items: center; width: 100%; text-align: left;
  border: 1px solid var(--line); border-radius: 12px; padding: .4rem; background: var(--surface-solid); color: var(--ink); }
.vpick-row:hover, .vpick-row:focus-visible { border-color: color-mix(in srgb, var(--indigo) 45%, var(--line)); outline: 0; }
.vpick-row .vid-thumb { border-radius: 8px; aspect-ratio: 16 / 10; }
.vpick-row .vid-play { width: 26px; height: 26px; font-size: .65rem; }
.vpick-title { font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.vpick-meta { color: var(--ink-soft); font-size: .78rem; }
.vpick-preview video { width: 100%; max-height: 42vh; border-radius: 12px; background: #000; }
.vpick-preview[hidden], .vpick-browse[hidden] { display: none; }
@media (max-width: 575.98px) {
  #video-modal .modal-dialog { margin: 0; max-width: none; height: 100%; }
  #video-modal .modal-content { height: 100%; border-radius: 0; }
  .vpick-row { grid-template-columns: 84px minmax(0, 1fr); }
}.vp-back { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border-radius: 50%; }
.vp-back[hidden] { display: none; }
.vp-back .icon { width: 16px; height: 16px; }
.vid-status { font-size: .85rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.vid-status[hidden] { display: none; }
.vid-status.is-ok { color: var(--good); font-weight: 600; }
.vid-status.is-error { color: var(--bad, #C8433A); }
.vpick-note { margin: -.2rem 0 .5rem; font-size: .8rem; }
.vpick-error { margin: .5rem 0 0; color: var(--bad, #C8433A); font-size: .85rem; }
.vpick-error[hidden], .vpick-note[hidden] { display: none; }
#video-modal .modal-footer { position: sticky; bottom: 0; background: var(--surface-solid); }
