/* Lougha Team — mobile-first design system (dark).
 * One stylesheet for the whole PWA: auth screen, app shell (header + scrolling
 * view + bottom tab bar), and the follow-up feed (sections, lead cards, chips).
 * Mobile-first, RTL-aware (names use dir="auto"), safe-area insets everywhere.
 */

:root {
  color-scheme: light;

  /* palette */
  --bg: #f1f4f3;
  --surface: #ffffff;
  --surface-2: #f6f8f7;
  --surface-3: #e9efed;
  --border: #dfe7e4;
  --border-2: #cbd7d3;
  --text: #172522;
  --muted: #71807c;
  --muted-2: #53645f;
  --accent: #246bfd;
  --accent-ink: #ffffff;
  --success: #1aa16f;
  --danger: #d94b5b;
  --warning: #d7911d;

  /* metrics */
  --r-sm: 8px;
  --r: 8px;
  --r-lg: 8px;
  --tap: 44px;
  --header-h: 56px;
  --tabbar-h: 60px;
  --pad: 16px;
  --shadow: 0 14px 40px rgba(25, 52, 45, 0.12);

  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

button {
  font: inherit;
  color: inherit;
}

/* ---------- Auth screen ---------------------------------------------------- */
.auth-screen {
  flex: 1;
  display: grid;
  place-items: center;
  padding: max(var(--pad), var(--safe-top)) var(--pad) max(var(--pad), var(--safe-bottom));
}

.auth-screen .card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card h1 {
  margin: 0 0 16px;
  font-size: 22px;
  line-height: 1.25;
}

.role {
  color: var(--muted);
  font-weight: 500;
  font-size: 15px;
}

label {
  display: block;
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--muted-2);
}

input,
select {
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  font-size: 16px; /* >=16px avoids iOS zoom-on-focus */
  border-radius: var(--r-sm);
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: #fff;
}

input:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn {
  width: 100%;
  padding: 13px 16px;
  font-size: 16px;
  font-weight: 600;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  min-height: var(--tap);
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--muted-2);
  margin-top: 10px;
}

.ok {
  color: var(--success);
  margin: 0 0 4px;
}

.err {
  color: var(--danger);
  margin: 12px 0 0;
}

/* ---------- App shell ------------------------------------------------------ */
.app-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) var(--pad) 0;
  background: rgba(11, 18, 32, 0.85);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.app-header .brand {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-header .brand .dot {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent);
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  min-width: var(--tap);
  min-height: var(--tap);
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted-2);
  cursor: pointer;
}

.icon-btn:active {
  background: var(--surface-3);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

.icon-btn.spinning svg {
  animation: spin 0.8s linear infinite;
}

/* scrolling content region */
.view {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--pad) var(--pad) calc(var(--tabbar-h) + var(--safe-bottom) + var(--pad));
}

.updated {
  margin: -4px 2px 14px;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Feed sections + cards ------------------------------------------ */
.section {
  margin: 0 0 22px;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 2px 10px;
}

.section-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--muted-2);
}

.count {
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted-2);
}

.section.rappels .section-head h2 {
  color: var(--warning);
}

.cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lead-card {
  width: 100%;
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: start;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.12s ease;
}

.lead-card:active {
  transform: scale(0.985);
  background: var(--surface-3);
}

.lead-card .avatar {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  color: #cfe0ff;
  background: linear-gradient(160deg, #1c2c49, #17233a);
  border: 1px solid var(--border-2);
}

.lead-card .body {
  flex: 1 1 auto;
  min-width: 0;
}

.lead-card .name {
  font-size: 15.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lead-card .sub {
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lead-card .sub .sep {
  opacity: 0.5;
  padding: 0 6px;
}

.lead-card .side {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.lead-card .when {
  font-size: 12px;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}

.lead-card .chev {
  color: var(--muted);
  opacity: 0.6;
}

/* stage chips */
.chip {
  display: inline-block;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.4;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--muted-2);
  border: 1px solid var(--border-2);
}

.chip.s-new {
  background: rgba(59, 130, 246, 0.16);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.35);
}
.chip.s-contacted {
  background: rgba(56, 189, 248, 0.14);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.32);
}
.chip.s-no_answer {
  background: rgba(251, 191, 36, 0.14);
  color: #fcd34d;
  border-color: rgba(251, 191, 36, 0.32);
}
.chip.s-test_scheduled {
  background: rgba(167, 139, 250, 0.16);
  color: #c4b5fd;
  border-color: rgba(167, 139, 250, 0.34);
}
.chip.s-no_show {
  background: rgba(248, 113, 113, 0.14);
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.32);
}
.chip.s-test_done {
  background: rgba(52, 211, 153, 0.14);
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, 0.32);
}
.chip.s-proforma_sent {
  background: rgba(45, 212, 191, 0.14);
  color: #5eead4;
  border-color: rgba(45, 212, 191, 0.32);
}
.chip.s-paid {
  background: rgba(74, 222, 128, 0.18);
  color: #86efac;
  border-color: rgba(74, 222, 128, 0.36);
}
.chip.s-lost {
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.3);
}

/* ---------- Empty / loading / toast ---------------------------------------- */
.empty {
  padding: 18px 14px;
  border: 1px dashed var(--border-2);
  border-radius: var(--r);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  background: rgba(19, 28, 46, 0.4);
}

.feed-loading,
.feed-error {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
}

.feed-error .btn {
  margin-top: 16px;
  max-width: 220px;
}

.spinner {
  width: 26px;
  height: 26px;
  margin: 0 auto 12px;
  border-radius: 50%;
  border: 3px solid var(--border-2);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  transform: translateX(-50%) translateY(8px);
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  border-radius: 999px;
  background: #1f2a40;
  border: 1px solid var(--border-2);
  color: var(--text);
  font-size: 13.5px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 40;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Bottom tab bar ------------------------------------------------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(11, 18, 32, 0.92);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-top: 1px solid var(--border);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}

.tab svg {
  width: 24px;
  height: 24px;
}

.tab.active {
  color: var(--accent);
}

.stub {
  padding: 60px 16px;
  text-align: center;
  color: var(--muted);
}

.stub h2 {
  color: var(--text);
  font-size: 18px;
  margin: 0 0 6px;
}

/* ========================================================================== */
/* Discussions list + global search (inbox.js)                                */
/* ========================================================================== */
.list-search {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: -4px -2px 12px;
  padding: 2px;
}

.list-search input {
  margin-top: 0;
  background: var(--surface);
  border-color: var(--border);
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-row,
.result-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: start;
  padding: 10px 12px;
  min-height: 64px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.12s ease;
}

.chat-row:active,
.result-row:active {
  transform: scale(0.985);
  background: var(--surface-3);
}

.chat-row .body,
.result-row .body {
  flex: 1 1 auto;
  min-width: 0;
}

.chat-row .top,
.result-row .top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.chat-row .name,
.result-row .name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 15.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-row .when {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.chat-row .bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}

.chat-row .preview,
.result-row .preview {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-row .preview {
  margin-top: 3px;
}

.muted {
  color: var(--muted);
  opacity: 0.7;
}

.unread {
  flex: 0 0 auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
}

.ch-tag,
.src-tag {
  flex: 0 0 auto;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted-2);
  border: 1px solid var(--border-2);
}

.src-tag {
  text-transform: uppercase;
}

.search-hint {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ========================================================================== */
/* Conversation overlay (boot.js openChat + conversation.js)                  */
/* ========================================================================== */
body.chat-open {
  overflow: hidden;
}

.chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.chat-overlay[hidden] {
  display: none;
}

.conv {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.conv-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) var(--pad) 0 6px;
  background: rgba(11, 18, 32, 0.9);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.conv-back {
  flex: 0 0 auto;
  min-width: var(--tap);
  min-height: var(--tap);
  display: inline-grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.conv-back svg {
  width: 24px;
  height: 24px;
}

.avatar.sm {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  color: #cfe0ff;
  background: linear-gradient(160deg, #1c2c49, #17233a);
  border: 1px solid var(--border-2);
}

.conv-id {
  flex: 1 1 auto;
  min-width: 0;
}

.conv-name {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-sub {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.conv-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px var(--pad) 18px;
}

.conv-loading {
  margin: auto;
  padding: 40px;
}

.day-divider {
  align-self: center;
  margin: 10px 0 6px;
}

.day-divider span {
  display: inline-block;
  padding: 3px 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}

/* message rows + bubbles */
.msg-row {
  display: flex;
  max-width: 100%;
}

.msg-row.me {
  justify-content: flex-end;
}

.msg-row.note {
  justify-content: center;
}

.bubble {
  max-width: 80%;
  padding: 8px 11px 6px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
}

.bubble.me {
  background: #1e3a8a;
  border-color: #2547a6;
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 5px;
}

.bubble.note {
  max-width: 90%;
  background: rgba(251, 191, 36, 0.08);
  border: 1px dashed rgba(251, 191, 36, 0.4);
  border-radius: 12px;
}

.bubble .sender {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
}

.bubble.me .sender {
  color: #bcd0ff;
}

.msg-text {
  font-size: 15px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  margin-top: 3px;
}

.msg-meta .time {
  font-size: 10.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.bubble.me .msg-meta .time {
  color: #9fb4de;
}

.tick {
  font-size: 11px;
  line-height: 1;
  color: #9fb4de;
  letter-spacing: -1px;
}

.tick-read {
  color: #5eb3f6;
}

.tick-failed {
  color: var(--danger);
  letter-spacing: 0;
}

/* media in bubbles */
.msg-audio {
  display: block;
  width: 232px;
  max-width: 62vw;
  height: 40px;
  margin: 2px 0;
}

.msg-img,
.msg-sticker {
  display: block;
  max-width: 220px;
  max-height: 280px;
  width: auto;
  height: auto;
  border-radius: 10px;
  margin: 2px 0;
  cursor: pointer;
}

.msg-sticker {
  max-width: 130px;
  cursor: default;
}

.msg-video {
  display: block;
  max-width: 240px;
  max-height: 300px;
  border-radius: 10px;
  margin: 2px 0;
}

.audio-dur {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}

.msg-doc {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin: 2px 0;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}

.msg-doc .doc-ico svg {
  width: 20px;
  height: 20px;
  color: var(--muted-2);
}

/* call bubble */
.bubble.call {
  min-width: 190px;
}

.call-head {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.call-ico svg {
  width: 16px;
  height: 16px;
  color: var(--muted-2);
}

.call-label {
  font-size: 14px;
  font-weight: 600;
}

.call-src {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  opacity: 0.6;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 1px 7px;
}

.call-dur {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-inline-start: auto;
}

.call-summary {
  margin-top: 5px;
  font-size: 13px;
  color: var(--muted-2);
  line-height: 1.35;
}

/* composer */
.composer {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px var(--pad) calc(8px + var(--safe-bottom));
  background: rgba(11, 18, 32, 0.95);
  border-top: 1px solid var(--border);
}

.composer.masked {
  justify-content: center;
  padding-top: 12px;
}

.composer-hint {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.composer-input {
  flex: 1 1 auto;
  width: auto;
  margin-top: 0;
  max-height: 120px;
  min-height: var(--tap);
  padding: 11px 14px;
  resize: none;
  line-height: 1.35;
  border-radius: 22px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  font-family: inherit;
}

.composer-send,
.composer-mic,
.composer-tpl {
  flex: 0 0 auto;
  width: var(--tap);
  height: var(--tap);
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.composer-send {
  background: var(--accent);
  color: #fff;
}

.composer-send svg {
  width: 20px;
  height: 20px;
  margin-inline-start: -1px;
}

.composer-send:disabled {
  opacity: 0.5;
}

.composer-tpl {
  background: var(--surface-3);
  color: var(--muted-2);
  border: 1px solid var(--border-2);
}

.composer-mic {
  background: var(--surface-3);
  color: var(--muted-2);
  border: 1px solid var(--border-2);
}

.composer-mic svg,
.composer-tpl svg {
  width: 20px;
  height: 20px;
}

.composer-mic.recording {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  animation: pulse 1.1s ease-in-out infinite;
}

.composer-mic:disabled,
.composer-tpl.off {
  opacity: 0.45;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* recording overlay strip */
.rec-bar {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--tap);
  padding: 0 14px;
  border-radius: 22px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1.1s ease-in-out infinite;
}

.rec-time {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.rec-wave {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 3px;
  height: 22px;
  overflow: hidden;
}

.rec-wave i {
  flex: 0 0 auto;
  width: 3px;
  border-radius: 2px;
  background: var(--muted-2);
  animation: wave 0.9s ease-in-out infinite;
}

.rec-slide {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.rec-bar.canceling {
  border-color: var(--danger);
}

.rec-bar.canceling .rec-slide {
  color: var(--danger);
  font-weight: 600;
}

@keyframes wave {
  0%, 100% { height: 5px; }
  50% { height: 20px; }
}

.rec-hint {
  font-size: 12.5px;
  color: var(--warning);
  padding: 4px 2px 0;
  text-align: center;
}

/* ========================================================================== */
/* Template picker sheet (templates.js)                                       */
/* ========================================================================== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet {
  width: 100%;
  max-width: 520px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 14px var(--pad) calc(16px + var(--safe-bottom));
  box-shadow: var(--shadow);
  animation: sheet-up 0.2s ease;
}

@keyframes sheet-up {
  from { transform: translateY(24px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sheet-head h3 {
  margin: 0;
  font-size: 16px;
}

.sheet-close {
  border: 0;
  background: transparent;
  color: var(--muted-2);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}

.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tpl-search {
  width: 100%;
  min-height: 46px;
  margin: 0 0 12px;
  padding: 10px 13px;
  color: var(--text);
  background: #f1f5f3;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  font-size: 16px;
}

.tpl-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tpl-item {
  width: 100%;
  text-align: start;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  cursor: pointer;
}

.tpl-item:active {
  background: var(--surface-3);
}

.tpl-item.disabled {
  opacity: 0.55;
  cursor: default;
}

.tpl-item .tpl-name {
  font-size: 14.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tpl-item .tpl-body {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tpl-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 1px 7px;
  border-radius: 999px;
  text-transform: uppercase;
}

.tpl-badge.ok {
  background: rgba(74, 222, 128, 0.16);
  color: #86efac;
  border: 1px solid rgba(74, 222, 128, 0.32);
}

.tpl-badge.no {
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.tpl-field {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted-2);
}

.tpl-preview {
  margin: 6px 0 12px;
  padding: 10px 12px;
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------- Conversation call buttons (3CX + WhatsApp) --------------------- */
.conv-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 2px;
  margin-inline-start: 4px;
}
.conv-call {
  flex: 0 0 auto;
  min-width: var(--tap);
  min-height: var(--tap);
  display: inline-grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted-2);
  cursor: pointer;
  border-radius: 12px;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s, background 0.15s, opacity 0.15s;
}
.conv-call svg {
  width: 21px;
  height: 21px;
}
.conv-call:active {
  background: var(--surface-3);
}
.conv-call-3cx {
  color: #8fd6ff;
}
.conv-call-wa {
  color: #34d399;
}
/* 3CX is office-only from the mobile app: mute it and stamp a "bureau" badge so
   remote agents reach for the WhatsApp call (the one that carries audio). */
.conv-call-office {
  color: var(--muted-2);
  opacity: 0.72;
  position: relative;
  overflow: visible;
}
.conv-call-office::after {
  content: attr(data-badge);
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  text-transform: uppercase;
  color: var(--muted);
  pointer-events: none;
}
.conv-call:disabled,
.conv-call.is-off {
  opacity: 0.38;
  cursor: not-allowed;
  color: var(--muted);
}
.conv-call.is-loading {
  animation: conv-call-pulse 1s ease-in-out infinite;
}
@keyframes conv-call-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* ---------- WhatsApp in-call panel (self-rendered; 3CX uses softphone's) --- */
.wa-call-panel {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: calc(var(--safe-top) + 10px);
  width: min(340px, calc(100vw - 24px));
  z-index: 99998;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: wacp-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes wacp-in {
  from {
    transform: translate(-50%, -10px);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}
.wacp-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 8px;
}
.wacp-avatar {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  color: #d7f7e6;
  background: linear-gradient(160deg, #12362a, #0f2a22);
  border: 1px solid #1c5a45;
}
.wacp-id {
  flex: 1 1 auto;
  min-width: 0;
}
.wacp-name {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wacp-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.wacp-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warning);
  animation: wacp-pulse 1.3s ease-in-out infinite;
}
.wa-call-panel[data-state='connected'] .wacp-dot {
  background: var(--success);
  animation: none;
}
.wa-call-panel[data-state='failed'] .wacp-dot,
.wa-call-panel[data-state='ended'] .wacp-dot {
  background: var(--muted);
  animation: none;
}
@keyframes wacp-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}
.wacp-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 12px;
  font-size: 13px;
  color: var(--muted-2);
}
.wacp-timer {
  margin-inline-start: auto;
  font-variant-numeric: tabular-nums;
  color: var(--muted-2);
  font-weight: 600;
}
.wacp-btns {
  display: flex;
  gap: 10px;
  padding: 0 14px 14px;
}
.wacp-b {
  flex: 1;
  border: 0;
  border-radius: 12px;
  padding: 12px 0;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  min-height: var(--tap);
}
.wacp-mute {
  background: var(--surface-3);
  color: var(--muted-2);
}
.wacp-mute.on {
  background: var(--warning);
  color: #0b1220;
}
.wacp-end {
  background: var(--danger);
}
.wacp-b:active {
  transform: translateY(1px);
}
/* Meta-138006 follow-up: full-width "send the Allow-calls prompt" action shown
   in the failure panel when the recipient hasn't granted call permission. */
.wacp-perm {
  display: flex;
  margin-top: 10px;
}
.wacp-ask {
  background: #34d399;
  color: #06281c;
}
.wacp-ask:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ── Inbound-call ringer (full-screen, WhatsApp incoming) ────────────────────
 * Sits above the softphone panel (99999) and the wa-call-panel (99998) so it's
 * the unmistakable foreground while ringing. Dismissed on answer/reject/timeout.
 */
.wa-ringer {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  place-items: center;
  padding: calc(var(--safe-top) + 24px) 20px calc(var(--safe-bottom) + 28px);
  background: radial-gradient(120% 90% at 50% 12%, #10241d 0%, #0a0f18 60%, #070b12 100%);
  animation: war-fade 0.2s ease-out;
}
@keyframes war-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.war-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  width: 100%;
  max-width: 360px;
}
.war-kicker {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--success);
  margin-bottom: 18px;
}
.war-avatar {
  width: 116px;
  height: 116px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 40px;
  font-weight: 700;
  color: #d7f7e6;
  background: linear-gradient(160deg, #12362a, #0f2a22);
  border: 1px solid #1c5a45;
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.45);
  animation: war-pulse 1.8s ease-out infinite;
}
@keyframes war-pulse {
  0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.4); }
  70% { box-shadow: 0 0 0 26px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}
.war-name {
  margin-top: 20px;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.war-phone {
  font-size: 15px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  direction: ltr;
}
.war-stage {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 4px 12px;
  border-radius: 999px;
  color: var(--muted-2);
  background: var(--surface-3);
  border: 1px solid var(--border-2);
}
.war-stage[hidden] {
  display: none;
}
.war-actions {
  display: flex;
  gap: 56px;
  margin-top: 48px;
}
.war-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--muted-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
/* The SVG itself is the coloured disc (padding sizes the glyph inside it) —
 * simpler and sturdier than an absolute icon over a ::before circle. */
.war-btn svg {
  width: 68px;
  height: 68px;
  padding: 18px;
  border-radius: 50%;
  color: #fff;
  box-sizing: border-box;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.war-accept svg {
  background: linear-gradient(160deg, #22c55e, #16a34a);
  box-shadow: 0 10px 26px rgba(34, 197, 94, 0.4);
}
.war-decline svg {
  background: linear-gradient(160deg, #f87171, #dc2626);
  box-shadow: 0 10px 26px rgba(220, 38, 38, 0.4);
}
.war-btn:active svg {
  transform: translateY(2px) scale(0.96);
  filter: brightness(1.05);
}
.war-btn span {
  margin-top: 2px;
}

/* Web Push enablement banner (Phase 2B) */
.push-banner{position:fixed;left:12px;right:12px;bottom:calc(64px + env(safe-area-inset-bottom,0));z-index:400;
  background:#1b2740;border:1px solid #2b3b5c;border-radius:14px;padding:12px 14px;color:#e6edf7;
  font-size:14px;line-height:1.4;box-shadow:0 8px 30px rgba(0,0,0,.4);display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.push-banner b{color:#fff}
.push-banner button{margin-left:auto;background:#2563eb;color:#fff;border:0;border-radius:10px;padding:8px 14px;font-weight:600;font-size:14px}
.push-banner button#push-x,.push-banner button:last-child{background:transparent;color:#9fb0c9;font-weight:500;padding:8px 10px}

/* ── Équipe (team chat) ─────────────────────────────────────────────────────
 * Roster sections, presence dots, room avatars, thread presence line, quoted
 * replies, and the peer-call panel accents. Bubbles reuse the house
 * .msg-row/.bubble system; rows reuse .chat-row.
 */
.team-section {
  padding: 14px 16px 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.chat-row .avatar {
  position: relative;
}
.presence-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--muted);
  border: 2px solid var(--surface-1, #0b1220);
}
.presence-dot.on {
  background: #34d399;
}
.avatar.room {
  background: #233553;
  color: #8fb8ff;
  font-weight: 800;
}
.team-pres {
  color: var(--muted);
}
.team-pres.on {
  color: #34d399;
}
.team-quote {
  border-inline-start: 3px solid #4c6ea8;
  background: rgba(76, 110, 168, 0.14);
  border-radius: 8px;
  padding: 6px 9px;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: var(--muted-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}
.conv-call-team {
  color: #8fb8ff;
}
.conv-call-team.is-off {
  opacity: 0.38;
}
.team-call-panel .wacp-accept {
  background: #34d399;
  color: #06281c;
}

/* ========================================================================== */
/* Lougha Team 2.0                                                            */
/* Familiar messaging ergonomics on mobile, focused workspace on desktop.     */
/* ========================================================================== */

body {
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  letter-spacing: 0;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(36, 107, 253, 0.28);
  outline-offset: 2px;
}

/* ---------- Sign in ------------------------------------------------------- */
.auth-screen {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  place-items: stretch;
  min-height: 100dvh;
  padding: 0;
  background: #eef3f1;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  min-height: 100%;
  padding: clamp(48px, 8vw, 112px);
  color: #ffffff;
  background: #13343b;
}

.auth-logo {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.2);
}

.auth-eyebrow {
  margin: 28px 0 8px;
  color: #82ddbc;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.auth-brand h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.05;
  letter-spacing: 0;
}

.auth-brand > p:not(.auth-eyebrow) {
  max-width: 510px;
  margin: 18px 0 0;
  color: #c9d9d5;
  font-size: 18px;
  line-height: 1.55;
}

.auth-features {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 40px;
}

.auth-features span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: #e8f2ef;
  font-size: 13px;
  font-weight: 650;
}

.auth-features svg {
  width: 17px;
  height: 17px;
  color: #82ddbc;
}

.auth-screen .auth-card {
  align-self: center;
  width: min(420px, calc(100% - 56px));
  margin: 28px auto;
  padding: 34px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-card-head {
  margin-bottom: 26px;
}

.auth-card-head h2 {
  margin: 0 0 5px;
  color: var(--text);
  font-size: 24px;
  line-height: 1.25;
}

.auth-card-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.auth-card label {
  color: var(--muted-2);
  font-weight: 650;
}

.auth-card input {
  min-height: 48px;
  background: var(--bg);
  color: var(--text);
}

.auth-card .btn {
  min-height: 48px;
  margin-top: 4px;
}

/* ---------- App frame ----------------------------------------------------- */
.app-shell {
  min-height: 100dvh;
  background: var(--bg);
}

.workspace {
  min-width: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-header {
  height: calc(68px + var(--safe-top));
  padding: var(--safe-top) 20px 0;
  background: var(--cream);
  border-bottom: 1px solid var(--border);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.app-header .brand {
  min-width: 0;
  gap: 11px;
}

.app-header .brand > img {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.header-title {
  display: flex;
  min-width: 0;
  flex-direction: column;
  line-height: 1.1;
}

.header-title small {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.header-title b {
  overflow: hidden;
  color: var(--text);
  font-size: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 650;
}

.connection-state i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(26, 161, 111, 0.12);
}

.icon-btn {
  color: var(--muted-2);
  border-radius: 8px;
}

.icon-btn:hover,
.icon-btn:active {
  background: var(--surface-3);
}

.view {
  min-height: 0;
  padding: 20px clamp(16px, 3vw, 34px) 34px;
}

.updated {
  margin: 0 2px 16px;
  color: var(--muted);
}

/* ---------- Navigation ---------------------------------------------------- */
.tabbar {
  background: #13343b;
  border: 0;
}

.nav-brand,
.nav-account {
  display: none;
}

.more-menu {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 10px);
  z-index: 80;
  overflow: hidden;
  padding: 6px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(18, 49, 40, 0.2);
  max-height: min(72dvh, 590px);
  overflow-y: auto;
}

.more-menu[hidden] {
  display: none;
}

.more-menu button {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  cursor: pointer;
}

.more-menu button:last-child {
  border-bottom: 0;
}

.more-menu button:hover,
.more-menu button:active {
  background: #f2f6f4;
}

.more-menu button > svg {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  color: #586763;
}

.more-menu button > span {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.more-menu button b {
  font-size: 15px;
}

.more-menu button small {
  color: var(--muted);
  font-size: 11px;
}

.more-menu-divider {
  display: block;
  height: 7px;
  margin: 0 -6px;
  background: #edf2f0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.nav-items {
  display: contents;
}

.tab {
  color: #6f7e7a;
}

.tab svg {
  width: 23px;
  height: 23px;
}

.tab.active {
  color: #146c58;
}

/* ---------- Lists and follow-up ------------------------------------------ */
.section {
  max-width: 920px;
  margin-bottom: 28px;
}

.section-head {
  margin: 0 2px 10px;
}

.section-head h2,
.section.rappels .section-head h2 {
  color: var(--text);
  font-size: 14px;
  font-weight: 750;
}

.count {
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  color: #4d5e59;
  background: #dde6e3;
  border: 0;
}

.cards,
.chat-list {
  overflow: hidden;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 3px 12px rgba(29, 58, 50, 0.04);
}

.lead-card,
.chat-row,
.result-row {
  min-height: 76px;
  background: var(--cream);
  border-color: var(--border);
  color: var(--text);
}

.lead-card {
  border-radius: 0;
}

.lead-card:hover,
.chat-row:hover,
.result-row:hover,
.lead-card:active,
.chat-row:active,
.result-row:active {
  background: var(--bg);
}

.lead-card .avatar,
.chat-row .avatar,
.result-row .avatar,
.avatar.sm {
  color: #1b5d53;
  background: #dff0eb;
  border: 0;
}

.chat-row .avatar,
.result-row .avatar {
  flex: 0 0 46px;
  width: 46px;
  min-width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 2px;
  border-radius: 50%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Arabic", Arial, sans-serif;
  font-size: 16px;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.lead-card:nth-child(3n + 2) .avatar,
.chat-row:nth-child(3n + 2) .avatar,
.result-row:nth-child(3n + 2) .avatar {
  color: #2455a6;
  background: #e2ebfb;
}

.lead-card:nth-child(3n) .avatar,
.chat-row:nth-child(3n) .avatar,
.result-row:nth-child(3n) .avatar {
  color: #8a5a0a;
  background: #f7ead2;
}

.lead-card .name,
.chat-row .name,
.result-row .name {
  color: var(--text);
  font-weight: 700;
}

.lead-card .body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.lead-card .name,
.lead-card .sub {
  display: block;
  width: 100%;
  max-width: 100%;
}

.lead-card .sub,
.lead-card .when,
.chat-row .preview,
.result-row .preview,
.chat-row .when {
  color: var(--muted);
}

.lead-card .chev {
  color: #9ba9a5;
}

.chip,
.ch-tag,
.src-tag {
  border: 0;
}

.chip.s-new { color: #2455a6; background: #e2ebfb; }
.chip.s-contacted { color: #176b59; background: #dff2eb; }
.chip.s-no_answer,
.chip.s-no_show { color: #9b353e; background: #f8e3e5; }
.chip.s-test_scheduled,
.chip.s-test_done { color: #76510a; background: #f8ecd2; }
.chip.s-proforma_sent { color: #6c45a4; background: #eee5fa; }
.chip.s-paid { color: #116f49; background: #dbf1e6; }
.chip.s-lost { color: #586560; background: #e8edeb; }

.unread {
  min-width: 20px;
  height: 20px;
  background: #1aa16f;
  box-shadow: none;
}

.empty,
.feed-loading,
.feed-error,
.search-hint {
  color: var(--muted);
}

.empty {
  background: rgba(255, 255, 255, 0.58);
  border-color: var(--border-2);
}

.spinner {
  border-color: #cbd7d3;
  border-top-color: var(--accent);
}

.list-search {
  max-width: 920px;
  margin: 0 0 14px;
  padding: 0;
  background: transparent;
}

.list-search input {
  min-height: 46px;
  margin: 0;
  padding: 11px 16px;
  color: var(--text);
  background: #e6ecea;
  border: 1px solid transparent;
  border-radius: 8px;
}

.list-search input::placeholder {
  color: #788681;
}

#inboxList,
#searchResults,
#teamRoster {
  max-width: 920px;
}

.surface-tabs {
  position: sticky;
  top: -20px;
  z-index: 8;
  width: 100%;
  max-width: 920px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin: 0 0 18px;
  padding: 5px;
  background: #e8eeec;
  border: 1px solid #d8e1de;
  border-radius: 8px;
}

.surface-tab {
  min-width: 0;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 10px;
  color: #64736f;
  background: transparent;
  border: 0;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.surface-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.55);
}

.surface-tab.active {
  color: var(--text);
  background: var(--cream);
  box-shadow: 0 1px 4px rgba(22, 51, 43, 0.12);
}

.surface-tab-icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
}

.surface-tab-icon svg {
  width: 19px;
  height: 19px;
}

.surface-tab-icon b {
  font-size: 21px;
  line-height: 1;
  font-weight: 500;
}

.surface-count {
  flex: 0 0 auto;
  min-width: 23px;
  height: 21px;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  color: #ffffff;
  background: #246bfd;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.inbox-tools {
  width: 100%;
  max-width: 920px;
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(260px, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.inbox-tools .list-search,
.team-tools .list-search {
  max-width: none;
  margin: 0;
}

.team-tools {
  width: 100%;
  max-width: 920px;
  margin-bottom: 14px;
}

.pipeline-filter {
  position: relative;
  min-width: 0;
  margin: 0;
}

.pipeline-filter-btn {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 13px;
  color: var(--text);
  background: var(--cream);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
}

.pipeline-filter-label {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.pipeline-filter-label small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.pipeline-filter-label b {
  overflow: hidden;
  margin-top: 2px;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pipeline-filter-chevron {
  flex: 0 0 auto;
  color: #52635e;
  font-size: 20px;
  line-height: 1;
}

.pipeline-filter-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  width: min(330px, calc(100vw - 24px));
  max-height: min(540px, 68dvh);
  overflow-y: auto;
  padding: 6px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(18, 49, 40, 0.22);
}

.pipeline-filter-menu[hidden] {
  display: none;
}

.pipeline-option {
  width: 100%;
  min-height: 43px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  color: #40504b;
  background: transparent;
  border: 0;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}

.pipeline-option:hover,
.pipeline-option.active {
  color: var(--text);
  background: #f1f5f3;
}

.filter-check {
  flex: 0 0 16px;
  width: 16px;
  color: #176b59;
  font-size: 14px;
  font-weight: 900;
  text-align: center;
}

.pipeline-filter-dot {
  flex: 0 0 13px;
  width: 13px;
  height: 13px;
  border-radius: 4px;
  background: #c9d3d0;
}

.pipeline-filter-dot.awaiting { border-radius: 50%; background: #18a66f; }
.pipeline-filter-dot[data-stage="new"] { background: #60a5fa; }
.pipeline-filter-dot[data-stage="contacted"] { background: #2563eb; }
.pipeline-filter-dot[data-stage="book_test"] { background: #fbbf24; }
.pipeline-filter-dot[data-stage="test_done"] { background: #f59e0b; }
.pipeline-filter-dot[data-stage="proforma_sent"] { background: #34d399; }
.pipeline-filter-dot[data-stage="paid"] { background: #25d366; }
.pipeline-filter-dot[data-stage="no_answer"] { background: #fca5a5; }
.pipeline-filter-dot[data-stage="no_show"] { background: #ef4444; }
.pipeline-filter-dot[data-stage="lost"] { background: #991b1b; }
}

/* Match the platform inbox: pipeline stage is visible before reading text. */
.chat-row[data-stage="new"] { background: rgba(96, 165, 250, 0.10); }
.chat-row[data-stage="contacted"] { background: rgba(37, 99, 235, 0.10); }
.chat-row[data-stage="book_test"] { background: rgba(251, 191, 36, 0.13); }
.chat-row[data-stage="test_done"] { background: rgba(245, 158, 11, 0.14); }
.chat-row[data-stage="proforma_sent"] { background: rgba(52, 211, 153, 0.13); }
.chat-row[data-stage="paid"] { background: rgba(37, 211, 102, 0.15); }
.chat-row[data-stage="no_answer"] { background: rgba(220, 38, 38, 0.08); }
.chat-row[data-stage="no_show"] { background: rgba(220, 38, 38, 0.14); }
.chat-row[data-stage="lost"] { background: rgba(153, 27, 27, 0.18); }

.chat-row[data-stage]:hover,
.chat-row[data-stage]:active {
  filter: brightness(0.98);
}

.chat-list {
  gap: 0;
}

.chat-list .chat-row,
.chat-list .result-row {
  border-width: 0 0 1px;
  border-radius: 0;
}

.chat-list .chat-row:last-child,
.chat-list .result-row:last-child {
  border-bottom: 0;
}

.team-section {
  padding: 19px 4px 7px;
  color: var(--muted);
}

.avatar.room {
  color: #6d45a4;
  background: #eee5fa;
}

.presence-dot {
  width: 12px;
  height: 12px;
  background: #a4afac;
  border-color: #ffffff;
}

.presence-dot.on,
.team-pres.on {
  background: var(--success);
  color: var(--success);
}

/* ---------- Conversation -------------------------------------------------- */
.chat-overlay {
  background: #e9eeec;
}

.conv-header {
  height: calc(68px + var(--safe-top));
  padding: var(--safe-top) 16px 0 8px;
  background: var(--cream);
  border-bottom: 1px solid var(--border);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.conv-back {
  color: #41514c;
  border-radius: 50%;
}

.conv-back:hover,
.conv-back:active {
  background: var(--surface-3);
}

.conv-name {
  color: var(--text);
  font-weight: 700;
}

.conv-sub,
.team-pres {
  color: var(--muted);
}

.conv-scroll {
  gap: 3px;
  padding: 18px clamp(14px, 4vw, 56px) 22px;
  background-color: #e9eeec;
}

.conv-toolstrip {
  flex: 0 0 50px;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
}

.conv-tool {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #5b6b66;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.conv-tool:hover,
.conv-tool:active {
  color: #176b59;
  background: #e8f3ef;
}

.conv-tool svg {
  width: 21px;
  height: 21px;
}

.chat-tools-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: rgba(14, 31, 27, 0.42);
}

.chat-tools-drawer {
  width: 100%;
  max-height: min(76dvh, 720px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--text);
  background: var(--cream);
  border-radius: 8px 8px 0 0;
  box-shadow: 0 -18px 48px rgba(18, 49, 40, 0.2);
  animation: drawer-up 0.18s ease-out;
}

@keyframes drawer-up {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.chat-tools-head {
  flex: 0 0 auto;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.chat-tools-head h3 {
  margin: 0;
  font-size: 17px;
}

.chat-tools-body {
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
}

.tool-note-compose {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.tool-note-input,
.tool-search-input {
  width: 100%;
  margin: 0;
  padding: 12px 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  font: inherit;
  resize: vertical;
}

.tool-save,
.tool-upload {
  width: auto;
  margin-top: 10px;
}

.tool-note-list,
.tool-doc-list,
.tool-search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.tool-note-card {
  padding: 12px 14px;
  background: #fff5d9;
  border: 1px solid #ecd798;
  border-radius: 8px;
}

.tool-note-meta {
  margin-bottom: 5px;
  color: #80621e;
  font-size: 11px;
  font-weight: 750;
}

.tool-note-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tool-upload-row {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.tool-doc-row {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 58px;
  padding: 10px 12px;
  color: var(--text);
  background: #f7f9f8;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
}

.tool-doc-icon {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: #2455a6;
  background: #e2ebfb;
  border-radius: 8px;
}

.tool-doc-icon svg {
  width: 19px;
  height: 19px;
}

.tool-doc-row > span:last-child {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.tool-doc-row b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-doc-row small {
  color: var(--muted);
}

.tool-profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.tool-profile-head .profile-avatar {
  width: 58px;
  height: 58px;
  font-size: 18px;
}

.tool-profile-head h3,
.tool-profile-head p {
  margin: 0;
}

.tool-profile-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.tool-profile-grid {
  margin-top: 8px;
}

.tool-profile-grid > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 52px;
  border-bottom: 1px solid var(--border);
}

.tool-profile-grid span {
  color: var(--muted);
  font-size: 12px;
}

.tool-profile-grid b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-subtitle {
  margin: 20px 0 8px;
  font-size: 13px;
  text-transform: uppercase;
}

.tool-company {
  padding: 11px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.tool-search-row {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 11px 12px;
  color: var(--text);
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: start;
  cursor: pointer;
}

.tool-search-row span {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.tool-search-row small {
  color: var(--muted);
}

.msg-row.search-hit .bubble {
  outline: 3px solid rgba(36, 107, 253, 0.36);
  outline-offset: 2px;
}

/* ---------- Compact CRM shortcuts ---------------------------------------- */
.crm-toolbar {
  width: 100%;
  max-width: 920px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.crm-toolbar .list-search {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.crm-refresh {
  flex: 0 0 auto;
  color: #52635e;
  background: var(--cream);
  border: 1px solid var(--border);
}

.crm-list {
  width: 100%;
  max-width: 920px;
  overflow: hidden;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.crm-row {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
}

.crm-row:last-child {
  border-bottom: 0;
}

.crm-row[role="button"] {
  cursor: pointer;
}

.crm-row[role="button"]:hover,
.crm-row[role="button"]:active {
  filter: brightness(0.98);
}

.crm-row .avatar {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  color: #1b5d53;
  background: #dff0eb;
  line-height: 1;
}

.crm-row-body {
  min-width: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
}

.crm-row-body b,
.crm-row-body small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-row-body small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.crm-row-side {
  flex: 0 0 auto;
  max-width: 105px;
  overflow: hidden;
  padding: 4px 8px;
  color: #52635e;
  background: #e9efed;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-rest-row.bucket-past { background: #fff0f1; }
.crm-rest-row.bucket-current { background: #eef8f4; }
.crm-rest-row.bucket-upcoming { background: #fff8e8; }

/* ---------- Operational views -------------------------------------------- */
.ops-loading {
  min-height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.ops-error,
.ops-empty {
  width: 100%;
  padding: 24px 16px;
  color: #667671;
  background: var(--cream);
  border: 1px dashed #cbd8d4;
  border-radius: 8px;
  text-align: center;
}

.ops-error b { color: #8d2932; }
.ops-error p { margin: 7px 0 14px; }
.ops-empty.compact { padding: 15px 10px; }

.ops-result-count {
  display: block;
  margin: 1px 2px 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.ops-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.ops-section-head h3 {
  margin: 0;
  font-size: 15px;
}

.ops-section-head > span {
  color: var(--muted);
  font-size: 11px;
}

.ops-period-control,
.group-status-filter {
  width: 100%;
  max-width: 920px;
  min-height: 42px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  padding: 4px;
  margin-bottom: 14px;
  background: #e8eeec;
  border-radius: 8px;
}

.ops-period-control button,
.group-status-filter button,
.tests-chips button {
  min-width: 0;
  color: #5f6d69;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.ops-period-control button.active,
.group-status-filter button.active,
.tests-chips button.active {
  color: #115e4d;
  background: var(--cream);
  box-shadow: 0 1px 4px rgba(20, 52, 45, 0.12);
}

.objective-week-control {
  width: 100%;
  max-width: 920px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: -4px 0 14px;
}

.objective-week-control[hidden] { display: none; }
.objective-week-control > span {
  margin-left: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.objective-week-control select {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  color: var(--text);
  background: var(--cream);
  border: 1px solid #cdd8d4;
  border-radius: 7px;
  font: inherit;
  font-size: 13px;
  font-weight: 750;
}

.objective-view,
.schedule-view,
.book-results,
.tests-mobile-list,
.tickets-mobile-list {
  width: 100%;
  max-width: 920px;
}

.objective-hero {
  padding: 20px;
  color: #eef8f5;
  background: #143d3d;
  border-radius: 8px;
}

.objective-review-button {
  width: 100%;
  min-height: 64px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  margin: 9px 0;
  color: var(--text);
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
}

.objective-review-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: #15664f;
  background: #e1f3ed;
  border-radius: 7px;
}
.objective-review-icon svg { width: 22px; height: 22px; }
.objective-review-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.objective-review-copy b,
.objective-review-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.objective-review-copy b { font-size: 13px; }
.objective-review-copy small { color: var(--muted); font-size: 10px; }
.objective-review-arrow { color: #7c8b86; font-weight: 850; text-align: right; }

.objective-eyebrow {
  color: #b9cfca;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.objective-total {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 7px 0 16px;
}

.objective-total strong {
  overflow-wrap: anywhere;
  font-family: Georgia, serif;
  font-size: 44px;
  line-height: 1;
  letter-spacing: 0;
}

.objective-total span { color: #b9cfca; font-weight: 800; }
.objective-track,
.objective-agent-copy > i,
.book-progress {
  height: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
}
.objective-track i,
.objective-agent-copy > i > i,
.book-progress i {
  height: 100%;
  display: block;
  background: #28b787;
  border-radius: inherit;
}

.objective-progress-copy {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 13px;
  margin-top: 9px;
  color: #b9cfca;
  font-size: 11px;
}
.objective-progress-copy b { color: #ffffff; }
.objective-progress-copy .done { color: #73dfb4; }

.objective-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.objective-stat {
  min-height: 82px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 13px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-left: 4px solid #7e908a;
  border-radius: 8px;
}
.objective-stat strong { overflow-wrap: anywhere; font-size: 18px; }
.objective-stat span { margin-top: 5px; color: var(--muted); font-size: 11px; }
.objective-stat.blue { border-left-color: #2b6df6; }
.objective-stat.green { border-left-color: #1aa66f; }
.objective-stat.amber { border-left-color: #e5a126; }

.objective-commission {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px 12px;
  padding: 16px;
  margin-bottom: 10px;
  color: #273b35;
  background: #f6f4ef;
  border: 1px solid #e1ddd3;
  border-radius: 8px;
}
.objective-commission > div { display: flex; flex-direction: column; gap: 4px; }
.objective-commission span,
.objective-commission small { color: var(--muted); font-size: 11px; }
.objective-commission strong { font-family: Georgia, serif; font-size: 26px; letter-spacing: 0; }
.objective-commission .objective-tier { padding: 4px 8px; color: #115e4d; background: #dff3eb; border-radius: 999px; font-weight: 800; }
.objective-commission > small { grid-column: 1 / -1; }

.objective-week-tiers {
  padding: 14px;
  margin-bottom: 10px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.objective-week-tier {
  min-height: 44px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  margin-top: 6px;
  color: #53635e;
  background: #f2f5f4;
  border-left: 3px solid #a2b0ac;
  border-radius: 6px;
}
.objective-week-tier b,
.objective-week-tier strong { font-size: 12px; }
.objective-week-tier strong { text-align: right; }
.objective-week-tier span { color: var(--muted); font-size: 10px; }
.objective-week-tier.reached { color: #146a4e; background: #e8f6f0; border-left-color: #1aa66f; }

.payment-review-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 13px;
}
.payment-review-summary > span {
  min-height: 66px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 11px;
  background: #f2f6f4;
  border-radius: 7px;
}
.payment-review-summary b { overflow-wrap: anywhere; font-size: 17px; }
.payment-review-summary small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.payment-review-list { overflow: hidden; border: 1px solid var(--border); border-radius: 8px; }
.payment-review-row {
  width: 100%;
  min-height: 72px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  color: var(--text);
  background: var(--cream);
  border: 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
button.payment-review-row { cursor: pointer; }
.payment-review-row:last-child { border-bottom: 0; }
.payment-review-avatar { width: 40px; height: 40px; display: grid; place-items: center; color: #155e52; background: #dff0eb; border-radius: 50%; font-size: 11px; font-weight: 850; }
.payment-review-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.payment-review-copy b,
.payment-review-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.payment-review-copy b { font-size: 12px; }
.payment-review-copy small { color: var(--muted); font-size: 9px; }
.payment-review-agent { color: #157357 !important; }
.payment-review-row > strong { max-width: 95px; overflow-wrap: anywhere; font-size: 11px; text-align: right; }

.objective-board {
  overflow: hidden;
  padding: 14px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.objective-agent {
  min-height: 66px;
  display: grid;
  grid-template-columns: 22px 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 9px 0;
  border-top: 1px solid var(--border);
}
.objective-agent.top { background: #eef9f5; margin: 0 -14px; padding: 9px 14px; }
.objective-rank { color: var(--muted); text-align: center; }
.objective-avatar { width: 38px; height: 38px; display: grid; place-items: center; color: #1b5d53; background: #dff0eb; border-radius: 50%; font-size: 11px; font-weight: 850; }
.objective-agent-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.objective-agent-copy b,
.objective-agent-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.objective-agent-copy small { color: var(--muted); font-size: 10px; }
.objective-agent-copy > i { width: 100%; height: 4px; background: #e6ecea; }
.objective-agent > strong { max-width: 100px; overflow-wrap: anywhere; font-size: 12px; text-align: right; }

.ops-date-toolbar {
  width: 100%;
  max-width: 920px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto 40px;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
}
.ops-date-toolbar input,
.ops-select,
.tests-dates input,
.tests-search,
.book-search input,
.book-filters select,
.ops-form-field input,
.ops-form-field textarea {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--text);
  background: var(--cream);
  border: 1px solid #cdd8d4;
  border-radius: 7px;
  font: inherit;
}
.ops-select { max-width: 920px; margin-bottom: 10px; }

.schedule-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}
.schedule-stats > div {
  min-width: 0;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-top: 3px solid #899993;
  border-radius: 7px;
}
.schedule-stats strong { font-size: 17px; }
.schedule-stats span { margin-top: 3px; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.schedule-stats .available { border-top-color: #34c993; }
.schedule-stats .booked { border-top-color: #2b6df6; }
.schedule-stats .done { border-top-color: #1aa66f; }
.schedule-stats .no-show { border-top-color: #e95059; }

.schedule-list { overflow: hidden; background: var(--cream); border: 1px solid var(--border); border-radius: 8px; }
.schedule-row { min-height: 62px; display: grid; grid-template-columns: 58px minmax(0, 1fr); border-bottom: 1px solid var(--border); }
.schedule-row:last-child { border-bottom: 0; }
.schedule-row > time { display: grid; place-items: center; padding: 8px 5px; color: #53635e; background: #f4f7f6; border-right: 1px solid var(--border); font-size: 12px; font-weight: 800; }
.schedule-seats { min-width: 0; display: flex; flex-direction: column; gap: 5px; padding: 6px; }
.schedule-seat { min-width: 0; min-height: 48px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; padding: 7px 9px; color: var(--text); background: var(--bg); border: 0; border-left: 3px solid #2b6df6; border-radius: 5px; text-align: left; cursor: pointer; }
.schedule-seat > span { grid-column: 1; color: #2b6df6; font-size: 9px; font-weight: 850; text-transform: uppercase; }
.schedule-seat > b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.schedule-seat > small { grid-column: 2; grid-row: 1 / 3; align-self: center; max-width: 95px; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.schedule-seat.status-completed { border-left-color: #1aa66f; }
.schedule-seat.status-completed > span { color: #16845a; }
.schedule-seat.status-no_show { border-left-color: #e95059; }
.schedule-seat.status-no_show > span { color: #bd313a; }
.schedule-seat.status-in_test { border-left-color: #e5a126; }
.schedule-available { display: flex; align-items: center; min-height: 48px; padding: 0 10px; color: #357864; background: #eef8f4; border-radius: 5px; font-size: 11px; font-weight: 750; }
.schedule-available.compact { min-height: 24px; padding: 3px 8px; }

.book-search { width: 100%; max-width: 920px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 7px; margin-bottom: 10px; }
.book-search-input { position: relative; min-width: 0; }
.book-suggestions {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  z-index: 35;
  max-height: min(48dvh, 360px);
  overflow-y: auto;
  padding: 5px;
  background: var(--cream);
  border: 1px solid #c8d6d1;
  border-radius: 8px;
  box-shadow: 0 15px 34px rgba(18, 49, 40, 0.2);
}
.book-suggestions[hidden] { display: none; }
.book-suggestion {
  width: 100%;
  min-height: 60px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 8px;
  color: var(--text);
  background: var(--cream);
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 5px;
  text-align: left;
  cursor: pointer;
}
.book-suggestion:last-child { border-bottom: 0; }
.book-suggestion:hover,
.book-suggestion:active { background: #eef8f4; }
.book-suggestion-avatar { width: 38px; height: 38px; display: grid; place-items: center; color: #155e52; background: #dff0eb; border-radius: 50%; font-size: 10px; font-weight: 850; }
.book-suggestion-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.book-suggestion-copy b,
.book-suggestion-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-suggestion-copy b { font-size: 12px; }
.book-suggestion-copy small { color: var(--muted); font-size: 9px; }
.book-suggestion-level { padding: 4px 7px; color: #1c5eb7; background: #e5efff; border-radius: 999px; font-size: 10px; font-weight: 850; }
.book-filters { width: 100%; max-width: 920px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; padding: 10px; background: #f2f5f4; border: 1px solid var(--border); border-radius: 8px; }
.book-filters label { min-width: 0; }
.book-filters label > span { display: block; margin: 0 0 4px 2px; color: var(--muted); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.book-room-toggle { width: 100%; max-width: 920px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 3px; color: #53635e; font-size: 12px; }
.book-room-toggle input { width: 20px; height: 20px; accent-color: #1f7a61; }
.book-student { display: flex; align-items: center; gap: 11px; padding: 11px; margin-bottom: 9px; background: #eef8f4; border: 1px solid #cfe5dd; border-radius: 8px; }
.book-student-avatar { width: 40px; height: 40px; display: grid; flex: 0 0 auto; place-items: center; color: #155e52; background: #d4eee5; border-radius: 50%; font-weight: 850; }
.book-student > span:last-child { min-width: 0; display: flex; flex-direction: column; }
.book-student small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.book-group-card { position: relative; padding: 14px; margin-bottom: 8px; background: var(--cream); border: 1px solid var(--border); border-left: 4px solid #23a86f; border-radius: 8px; }
.book-group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.book-group-head h3 { min-width: 0; margin: 0; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.book-score { width: 42px; height: 38px; display: grid; flex: 0 0 auto; place-items: center; color: #ffffff; background: #15995d; border-radius: 7px; font-weight: 850; }
.book-group-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 14px; margin: 12px 0; }
.book-group-meta .ops-detail-row { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 0; border: 0; }
.book-group-meta .ops-detail-row span { font-size: 9px; text-transform: uppercase; }
.book-group-meta .ops-detail-row b { max-width: 100%; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.book-progress { height: 4px; margin-bottom: 12px; background: #e7edeb; }
.book-trial { width: auto; min-height: 36px; padding: 7px 14px; }

.tests-dates { width: 100%; max-width: 920px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 9px; }
.tests-dates label { min-width: 0; }
.tests-dates label > span { display: block; margin: 0 0 4px 2px; color: var(--muted); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.tests-chips { width: 100%; max-width: 920px; display: flex; gap: 5px; margin-bottom: 9px; overflow-x: auto; padding-bottom: 2px; }
.tests-chips button { flex: 0 0 auto; min-height: 34px; padding: 7px 11px; background: #e8eeec; }
.tests-chips button.active { background: #dff3eb; box-shadow: none; }
.tests-search { max-width: 920px; margin-bottom: 10px; }
.test-mobile-row { width: 100%; min-height: 72px; display: grid; grid-template-columns: 65px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px; color: var(--text); background: var(--cream); border: 1px solid var(--border); border-bottom: 0; text-align: left; cursor: pointer; }
.test-mobile-row:first-of-type { border-radius: 8px 8px 0 0; }
.test-mobile-row:last-child { border-bottom: 1px solid var(--border); border-radius: 0 0 8px 8px; }
.test-date-block,
.test-row-copy { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.test-date-block b { font-size: 11px; }
.test-date-block small,
.test-row-copy small { color: var(--muted); font-size: 10px; }
.test-row-copy b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.test-status,
.ticket-status,
.ticket-priority { padding: 4px 7px; border-radius: 999px; color: #52635e; background: #e9efed; font-size: 9px; font-weight: 850; text-transform: capitalize; white-space: nowrap; }
.test-status.status-completed { color: #147a50; background: #dff5e9; }
.test-status.status-no_show,
.test-status.status-cancelled { color: #a72e37; background: #ffe5e7; }
.test-status.status-booked,
.test-status.status-confirmed { color: #2559ad; background: #e5eeff; }
.test-status.status-in_test { color: #9c5700; background: #fff0d1; }

/* Groups and tickets */
.groups-mobile-list .crm-row { width: 100%; border: 0; border-bottom: 1px solid var(--border); text-align: left; }
.groups-mobile-list .crm-row:last-child { border-bottom: 0; }
.group-students-preview { margin-top: 20px; padding-top: 15px; border-top: 1px solid var(--border); }
.group-students-preview .ops-loading { min-height: 90px; }
.group-student-row { display: flex; align-items: center; gap: 9px; padding: 9px 0; border-top: 1px solid var(--border); }
.mini-avatar { width: 34px; height: 34px; display: grid; flex: 0 0 auto; place-items: center; color: #155e52; background: #dff0eb; border-radius: 50%; font-size: 10px; font-weight: 850; }
.group-student-row > span:last-child { min-width: 0; display: flex; flex-direction: column; }
.group-student-row b,
.group-student-row small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-student-row small { margin-top: 3px; color: var(--muted); font-size: 10px; }

.ticket-mobile-card { width: 100%; min-height: 104px; display: flex; flex-direction: column; gap: 8px; padding: 13px; color: var(--text); background: var(--cream); border: 1px solid var(--border); border-bottom: 0; text-align: left; cursor: pointer; }
.ticket-mobile-card:first-of-type { border-radius: 8px 8px 0 0; }
.ticket-mobile-card:last-child { border-bottom: 1px solid var(--border); border-radius: 0 0 8px 8px; }
.ticket-card-head { min-width: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ticket-card-head b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.ticket-status.new { color: #06749c; background: #ddf4fb; }
.ticket-status.waiting { color: #9b6100; background: #fff1d6; }
.ticket-status.attention { color: #b42d38; background: #ffe3e7; }
.ticket-status.closed { color: #37705c; background: #e4f1ec; }
.ticket-card-meta { display: flex; flex-wrap: wrap; gap: 6px; color: var(--muted); font-size: 10px; }
.ticket-card-meta > span:not(.ticket-priority) { padding: 4px 7px; background: #f2f4f3; border-radius: 999px; }
.ticket-priority.priority-urgent,
.ticket-priority.priority-high { color: #b42d38; background: #ffe3e7; }
.ticket-priority.priority-medium { color: #9b6100; background: #fff1d6; }
.ticket-card-contact { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

/* Shared responsive details sheet */
.ops-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 240;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 18px 0 0;
  background: rgba(19, 45, 43, 0.54);
  opacity: 0;
  transition: opacity 0.16s ease;
}
.ops-sheet-backdrop.show { opacity: 1; }
.ops-sheet { width: 100%; max-width: 760px; max-height: min(82dvh, 760px); display: flex; flex-direction: column; background: var(--cream); border-radius: 8px 8px 0 0; transform: translateY(18px); transition: transform 0.18s ease; }
.ops-sheet-backdrop.show .ops-sheet { transform: translateY(0); }
.ops-sheet-head { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.ops-sheet-title { min-width: 0; }
.ops-sheet-title h2 { margin: 0; overflow: hidden; font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }
.ops-sheet-title p { margin: 4px 0 0; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.ops-sheet-close { flex: 0 0 auto; color: #53635e; background: transparent; font-size: 18px; font-weight: 800; }
.ops-sheet-body { overflow-y: auto; padding: 14px 16px calc(20px + var(--safe-bottom)); }
.ops-detail-list { width: 100%; }
.ops-detail-row { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.ops-detail-row > span { flex: 0 0 40%; color: var(--muted); font-size: 11px; }
.ops-detail-row > b { min-width: 0; max-width: 60%; overflow-wrap: anywhere; font-size: 12px; text-align: right; }
.ops-sheet-actions { display: flex; padding: 10px 16px calc(10px + var(--safe-bottom)); border-top: 1px solid var(--border); }
.ops-sheet-actions > * { flex: 1; }
.ops-form-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 11px; }
.ops-form-field > span { color: #475852; font-size: 11px; font-weight: 800; }
.ops-form-field textarea { resize: vertical; line-height: 1.45; }
.book-sheet-form > .btn,
.book-message-preview > .btn { width: 100%; }
.book-send-status { min-height: 18px; margin: 7px 0; color: #a72e37; font-size: 11px; }
.book-message-preview { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.book-preview-warning { padding: 8px 10px; color: #8d5700; background: #fff3d9; border-radius: 6px; font-size: 11px; }

@media (min-width: 900px) {
  .objective-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .objective-hero { padding: 28px; }
  .objective-total strong { font-size: 58px; }
  .schedule-row { grid-template-columns: 78px minmax(0, 1fr); }
  .ops-sheet-backdrop { align-items: center; padding: 28px; }
  .ops-sheet { border-radius: 8px; }
}

@media (max-width: 520px) {
  .book-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .schedule-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .test-mobile-row { grid-template-columns: 58px minmax(0, 1fr); }
  .test-status { grid-column: 2; justify-self: start; }
}

.day-divider span {
  color: #52635e;
  background: rgba(255, 255, 255, 0.9);
  border: 0;
  box-shadow: 0 1px 2px rgba(18, 49, 40, 0.08);
}

.bubble {
  max-width: min(78%, 620px);
  color: var(--text);
  background: var(--cream);
  border: 0;
  border-radius: 8px;
  border-bottom-left-radius: 2px;
  box-shadow: 0 1px 2px rgba(18, 49, 40, 0.1);
}

.bubble.me {
  color: var(--text);
  background: #d8f3e5;
  border: 0;
  border-radius: 8px;
  border-bottom-right-radius: 2px;
}

.bubble.note {
  color: #644b18;
  background: #fff5d9;
  border-color: #e8c76f;
}

.bubble .sender {
  color: #176b59;
}

.bubble.me .sender,
.bubble.me .msg-meta .time,
.tick {
  color: #5f7770;
}

.tick-read {
  color: #168bd2;
}

.msg-doc {
  color: var(--text);
  background: rgba(255, 255, 255, 0.55);
  border-color: rgba(104, 129, 120, 0.24);
}

.team-quote {
  color: #52635e;
  background: rgba(255, 255, 255, 0.45);
  border-inline-start-color: #1aa16f;
}

.composer {
  gap: 8px;
  padding: 9px 14px calc(9px + var(--safe-bottom));
  background: #f3f5f4;
  border-top: 1px solid #dfe6e3;
}

.composer-input {
  min-height: 46px;
  color: var(--text);
  background: var(--cream);
  border: 1px solid #d8e0dd;
  border-radius: 23px;
}

.composer-input::placeholder {
  color: #7b8985;
}

.composer-tpl,
.composer-mic {
  color: #53645f;
  background: var(--cream);
  border-color: #d8e0dd;
}

.composer-send {
  background: #1a8f70;
}

.composer-send[hidden],
.composer-mic[hidden] {
  display: none;
}

.rec-bar {
  color: var(--text);
  background: var(--cream);
  border-color: #d8e0dd;
}

.conv-call {
  color: #176b59;
  background: transparent;
  border-color: transparent;
}

.conv-call:hover,
.conv-call:active {
  background: var(--surface-3);
}

.conv-call-3cx {
  color: #49627e;
}

.conv-call-wa,
.conv-call-team {
  color: #13825f;
}

/* ---------- Account ------------------------------------------------------- */
.profile-panel {
  width: 100%;
  max-width: 680px;
  overflow: hidden;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 3px 12px rgba(29, 58, 50, 0.04);
}

.profile-identity {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 28px;
  border-bottom: 1px solid var(--border);
}

.profile-avatar {
  flex: 0 0 auto;
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: #176b59;
  font-size: 23px;
  font-weight: 800;
}

.profile-identity h2 {
  margin: 0 0 3px;
  font-size: 21px;
}

.profile-identity .role {
  margin: 0;
}

.profile-info {
  padding: 4px 28px;
}

.profile-info > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 58px;
  border-bottom: 1px solid var(--border);
}

.profile-info > div:last-child {
  border-bottom: 0;
}

.profile-info span {
  color: var(--muted);
  font-size: 13px;
}

.profile-info b {
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn.danger-ghost {
  width: auto;
  margin: 20px 28px 28px;
  color: var(--danger);
  background: transparent;
  border: 1px solid #efc8cd;
}

.btn.danger-ghost:hover,
.btn.danger-ghost:active {
  background: #fff1f2;
}

.toast {
  color: #ffffff;
  background: #243632;
  border: 0;
  box-shadow: 0 12px 28px rgba(25, 52, 45, 0.2);
}

.push-banner {
  color: #eaf4f1;
  background: #183d3e;
  border-color: #2d5b58;
  border-radius: 8px;
}

/* ---------- Desktop ------------------------------------------------------- */
@media (min-width: 900px) {
  .app-shell {
    display: grid;
    grid-template-columns: 272px minmax(0, 1fr);
  }

  .workspace {
    grid-column: 2;
  }

  .tabbar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: 272px;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 24px 16px 18px;
    color: #ffffff;
  }

  .more-menu {
    left: 16px;
    right: auto;
    bottom: 92px;
    width: 240px;
  }

  .nav-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    height: 48px;
    padding: 0 10px;
    margin-bottom: 24px;
  }

  .nav-brand img {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .nav-brand > span {
    display: flex;
    flex-direction: column;
    line-height: 1.08;
  }

  .nav-brand b {
    font-size: 17px;
  }

  .nav-brand small {
    color: #9ab4ae;
    font-size: 12px;
  }

  .nav-items {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 5px;
  }

  .tab {
    width: 100%;
    min-height: 48px;
    flex: 0 0 auto;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    gap: 13px;
    padding: 0 14px;
    color: #adc0bc;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 650;
  }

  .tab:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.07);
  }

  .tab.active {
    color: #ffffff;
    background: #1f5960;
  }

  .tab svg {
    width: 21px;
    height: 21px;
  }

  .nav-account {
    width: 100%;
    min-height: 62px;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
    border: 0;
    border-radius: 8px;
    cursor: pointer;
  }

  .nav-account:hover {
    background: rgba(255, 255, 255, 0.1);
  }

  .nav-avatar {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #123b34;
    background: #9fe1c9;
    font-size: 13px;
    font-weight: 800;
  }

  .nav-account-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.25;
  }

  .nav-account-copy b,
  .nav-account-copy small {
    max-width: 164px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-account-copy b {
    font-size: 13px;
  }

  .nav-account-copy small {
    color: #9ab4ae;
    font-size: 11px;
  }

  .view {
    padding-top: 28px;
  }

  .chat-overlay {
    left: 272px;
  }

  .chat-tools-backdrop {
    left: 272px;
    align-items: stretch;
    justify-content: flex-end;
  }

  .chat-tools-drawer {
    width: min(430px, 42vw);
    max-height: none;
    height: 100%;
    border-radius: 0;
    animation-name: drawer-side;
  }

  @keyframes drawer-side {
    from { transform: translateX(26px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
  }

  .conv-scroll {
    padding-right: clamp(40px, 8vw, 120px);
    padding-left: clamp(40px, 8vw, 120px);
  }

  .push-banner {
    left: 290px;
    right: 18px;
    bottom: 18px;
  }
}

/* ---------- Phone --------------------------------------------------------- */
@media (max-width: 899px) {
  .app-header {
    height: calc(62px + var(--safe-top));
    padding: var(--safe-top) 10px 0 14px;
    color: #ffffff;
    background: #13343b;
    border-bottom: 0;
  }

  .app-header .brand > img {
    display: block;
  }

  .header-title small {
    display: none;
  }

  .header-title b {
    color: #ffffff;
    font-size: 19px;
  }

  .connection-state {
    display: none;
  }

  .app-header .icon-btn {
    color: #d7e5e1;
  }

  .app-header .icon-btn:active {
    background: rgba(255, 255, 255, 0.1);
  }

  .view {
    padding: 14px 12px calc(var(--tabbar-h) + var(--safe-bottom) + 18px);
  }

  .surface-tabs {
    top: -14px;
    margin-right: 0;
    margin-left: 0;
  }

  .surface-tab {
    min-height: 40px;
    gap: 6px;
    padding: 6px 4px;
    font-size: 12.5px;
  }

  .surface-tab-icon,
  .surface-tab-icon svg {
    width: 18px;
    height: 18px;
  }

  .surface-count {
    min-width: 20px;
    height: 19px;
    padding: 0 5px;
    font-size: 10px;
  }

  .inbox-tools {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .tabbar {
    height: calc(var(--tabbar-h) + var(--safe-bottom));
    padding: 2px 4px var(--safe-bottom);
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 20px rgba(24, 55, 47, 0.06);
  }

  .tab {
    min-width: 0;
    padding: 4px 2px 3px;
    color: #71807c;
    font-size: 10.5px;
    font-weight: 650;
  }

  .tab.active {
    color: #176b59;
  }

  .tab.active svg {
    stroke-width: 2.3;
  }

  .section {
    margin-bottom: 22px;
  }

  .cards,
  .chat-list {
    border-right: 0;
    border-left: 0;
  }

  .lead-card,
  .chat-row,
  .result-row {
    min-height: 72px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .lead-card .avatar,
  .chat-row .avatar,
  .result-row .avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
  }

  .lead-card .side {
    max-width: 110px;
  }

  .chip {
    max-width: 105px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .conv-header {
    height: calc(62px + var(--safe-top));
    padding-right: 6px;
  }

  .conv-header .avatar.sm {
    width: 38px;
    height: 38px;
    border-radius: 50%;
  }

  .conv-actions {
    gap: 0;
  }

  .conv-call {
    width: 42px;
    height: 42px;
  }

  .conv-scroll {
    padding: 14px 10px 18px;
  }

  .bubble {
    max-width: 86%;
  }

  .composer {
    padding-right: 8px;
    padding-left: 8px;
  }

  .composer-send,
  .composer-mic,
  .composer-tpl {
    width: 44px;
    height: 44px;
  }

  .profile-panel {
    border-right: 0;
    border-left: 0;
  }
}

@media (max-width: 700px) {
  .auth-screen {
    grid-template-columns: 1fr;
    align-content: start;
    background: var(--cream);
  }

  .auth-brand {
    min-height: auto;
    align-items: center;
    padding: max(42px, calc(var(--safe-top) + 28px)) 24px 38px;
    text-align: center;
  }

  .auth-logo {
    width: 62px;
    height: 62px;
    border-radius: 16px;
  }

  .auth-eyebrow {
    margin-top: 18px;
  }

  .auth-brand h1 {
    font-size: 32px;
  }

  .auth-brand > p:not(.auth-eyebrow) {
    display: none;
  }

  .auth-features {
    margin-top: 22px;
    justify-content: center;
  }

  .auth-features span {
    padding: 7px 9px;
    font-size: 11px;
  }

  .auth-screen .auth-card {
    align-self: start;
    width: 100%;
    margin: 0;
    padding: 30px 22px max(30px, var(--safe-bottom));
    border: 0;
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========================================================================== */
/* Structured document builder                                                */
/* ========================================================================== */
.doc-builder-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150000;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(18, 38, 34, 0.56);
  backdrop-filter: blur(5px);
}

.doc-builder {
  width: min(1060px, 100%);
  height: min(900px, calc(100dvh - 44px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  color: var(--text);
  background: var(--cream);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(12, 30, 26, 0.32);
}

.doc-builder-head {
  min-height: 68px;
  display: grid;
  grid-template-columns: 40px 34px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
}

.doc-builder-head h2 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 20px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-builder-head-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #1c66e5;
  background: #eaf2ff;
  border-radius: 8px;
}

.doc-builder-head-icon svg,
.doc-preview-file svg {
  width: 20px;
  height: 20px;
}

.doc-builder .icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  color: #52635e;
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.doc-builder .icon-btn:hover,
.doc-builder .icon-btn:active {
  background: #edf2f0;
}

.doc-builder-back[hidden] {
  visibility: hidden;
}

.doc-builder-body {
  min-height: 0;
  overflow-y: auto;
  padding: 22px 28px 28px;
  -webkit-overflow-scrolling: touch;
}

.doc-builder-footer {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px 28px max(12px, var(--safe-bottom));
  background: var(--cream);
  border-top: 1px solid var(--border);
}

.doc-builder-footer .btn {
  min-height: 46px;
  padding: 10px 18px;
}

.doc-footer-hint {
  margin-right: auto;
  color: var(--muted);
  font-size: 13px;
}

.doc-primary,
.doc-send {
  color: #ffffff;
  background: #1f7a61;
  border-color: #1f7a61;
}

.doc-send {
  min-width: 190px;
}

.doc-client-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: -22px -28px 22px;
  padding: 16px 28px;
  color: #ffffff;
  background: #1d3d48;
}

.doc-client-avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #184f46;
  background: #d7eee7;
  font-weight: 800;
}

.doc-client-strip > span:last-child {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.doc-client-strip b,
.doc-client-strip small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-client-strip small {
  margin-top: 3px;
  color: #c6d7d3;
}

.doc-picker-intro {
  margin: 0 0 16px;
  color: #52635e;
}

.doc-type-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.doc-type-row {
  min-width: 0;
  min-height: 88px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 13px;
  padding: 14px;
  color: var(--text);
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: start;
  cursor: pointer;
}

.doc-type-row:hover,
.doc-type-row:active {
  background: #f6faf8;
  border-color: #a9c5bd;
}

.doc-type-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: #f2f5f4;
  border-radius: 8px;
  font-size: 23px;
}

.doc-type-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.doc-type-copy b,
.doc-type-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-type-copy b {
  font-size: 15px;
}

.doc-type-copy small {
  color: var(--muted);
  font-size: 12px;
}

.doc-type-arrow {
  color: #9baba6;
  font-size: 28px;
}

.doc-accent-orange .doc-type-icon { color: #9a5700; background: #fff1d8; }
.doc-accent-sky .doc-type-icon { color: #225ab4; background: #e6efff; }
.doc-accent-cyan .doc-type-icon { color: #087b88; background: #e0f5f6; }
.doc-accent-emerald .doc-type-icon { color: #15664f; background: #def3ea; }
.doc-accent-indigo .doc-type-icon { color: #4d4fa6; background: #ebebff; }
.doc-accent-amber .doc-type-icon { color: #8a6000; background: #fff0c7; }
.doc-accent-violet .doc-type-icon { color: #6b4199; background: #f0e7f9; }

.doc-upload-existing {
  margin-left: auto;
}

.doc-prefill-loading {
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
}

.doc-form {
  width: 100%;
  max-width: 920px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 17px 18px;
  margin: 0 auto;
}

.doc-field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.doc-field:has(textarea),
.doc-field[data-doc-key="caption"],
.doc-field[data-doc-key="body_paragraphs"],
.doc-complex-field {
  grid-column: 1 / -1;
}

.doc-field-label,
.doc-complex-field > h3,
.doc-section-label {
  margin: 0;
  color: #34453f;
  font-size: 13px;
  font-weight: 800;
}

.doc-field input:not([type="checkbox"]),
.doc-field select,
.doc-field textarea,
.doc-complex-field input:not([type="checkbox"]),
.doc-complex-field textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 12px;
  color: var(--text);
  background: var(--cream);
  border: 1px solid #cfdad6;
  border-radius: 8px;
  font: inherit;
}

.doc-field textarea,
.doc-complex-field textarea {
  min-height: 86px;
  line-height: 1.5;
  resize: vertical;
}

.doc-field input:focus,
.doc-field select:focus,
.doc-field textarea:focus,
.doc-complex-field input:focus,
.doc-complex-field textarea:focus {
  border-color: #1f7a61;
  outline: 3px solid rgba(31, 122, 97, 0.12);
}

.doc-field-help {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.doc-field-toggle {
  min-height: 46px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  align-items: center;
  align-self: end;
  padding: 0 3px 0 0;
}

.doc-field-toggle input {
  position: absolute;
  opacity: 0;
}

.doc-toggle-track {
  width: 44px;
  height: 26px;
  position: relative;
  background: #c6d2ce;
  border-radius: 999px;
  transition: background 0.18s ease;
}

.doc-toggle-track::after {
  content: "";
  width: 20px;
  height: 20px;
  position: absolute;
  top: 3px;
  left: 3px;
  background: var(--cream);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  transition: transform 0.18s ease;
}

.doc-field-toggle input:checked + .doc-toggle-track { background: #1f7a61; }
.doc-field-toggle input:checked + .doc-toggle-track::after { transform: translateX(18px); }

.doc-section-label {
  width: 100%;
  max-width: 920px;
  margin: 0 auto 11px;
  text-transform: uppercase;
}

.doc-pack-grid {
  width: 100%;
  max-width: 920px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0 auto 24px;
}

.doc-pack-card {
  min-width: 0;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px;
  color: var(--text);
  background: var(--cream);
  border: 1px solid #d9e1df;
  border-radius: 8px;
  text-align: start;
  cursor: pointer;
}

.doc-pack-card.selected {
  background: #eef8f4;
  border-color: #1f7a61;
  box-shadow: 0 0 0 2px rgba(31, 122, 97, 0.1);
}

.doc-pack-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.doc-pack-top b { color: #1c66e5; }
.doc-pack-card strong,
.doc-pack-card small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
}
.doc-pack-card strong {
  display: -webkit-box;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.doc-pack-card small { color: var(--muted); font-size: 11px; }

.doc-complex-field {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 15px;
  background: #f6f9f8;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.doc-line-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.doc-line-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 12px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.doc-line-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.doc-line-card .doc-remove-line {
  width: 30px;
  height: 30px;
  color: #a33a43;
  background: #fff0f1;
  font-size: 20px;
}

.doc-line-numbers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.doc-line-numbers label {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
}

.doc-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #52635e;
  font-size: 12px;
}

.doc-add-line {
  align-self: flex-start;
}

.doc-form-errors {
  width: 100%;
  max-width: 920px;
  margin: 0 auto 18px;
  padding: 10px 13px;
  color: #8d2932;
  background: #fff0f1;
  border: 1px solid #efc0c5;
  border-radius: 8px;
}

.doc-form-errors p { margin: 3px 0; }

.doc-preview-meta {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 14px;
}

.doc-preview-file {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #1c66e5;
  background: #eaf2ff;
  border-radius: 8px;
}

.doc-preview-meta > span:last-child {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.doc-preview-meta b,
.doc-preview-meta small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-preview-meta small { margin-top: 3px; color: var(--muted); }

.doc-preview-frame {
  width: 100%;
  height: calc(100% - 58px);
  min-height: 520px;
  display: block;
  background: #e4e8e6;
  border: 1px solid var(--border);
  border-radius: 6px;
}

@media (max-width: 899px) {
  .doc-builder-backdrop {
    place-items: stretch;
    padding: 0;
    background: rgba(18, 38, 34, 0.5);
    backdrop-filter: none;
  }

  .doc-builder {
    width: 100%;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .doc-builder-head {
    min-height: calc(58px + var(--safe-top));
    padding: calc(8px + var(--safe-top)) 10px 8px;
    grid-template-columns: 38px 30px minmax(0, 1fr) 38px;
  }

  .doc-builder-head h2 { font-size: 17px; }
  .doc-builder-head-icon { width: 30px; height: 30px; }
  .doc-builder-body { padding: 16px 14px 22px; }
  .doc-builder-footer {
    min-height: calc(64px + var(--safe-bottom));
    padding: 9px 12px calc(9px + var(--safe-bottom));
  }
  .doc-footer-hint { display: none; }
  .doc-builder-footer .btn { flex: 1; padding: 9px 10px; }
  .doc-client-strip { margin: -16px -14px 16px; padding: 13px 14px; }
  .doc-type-list { grid-template-columns: 1fr; gap: 8px; }
  .doc-type-row { min-height: 78px; padding: 11px; }
  .doc-type-copy small { white-space: normal; }
  .doc-form { grid-template-columns: 1fr; gap: 14px; }
  .doc-pack-grid {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(158px, 44vw);
    gap: 8px;
    margin-bottom: 18px;
    overflow-x: auto;
    padding-bottom: 5px;
    scroll-snap-type: x proximity;
  }
  .doc-pack-card { min-height: 106px; scroll-snap-align: start; }
  .doc-line-list { grid-template-columns: 1fr; }
  .doc-preview-frame {
    height: calc(100dvh - 210px - var(--safe-top) - var(--safe-bottom));
    min-height: 360px;
  }
  .doc-send { min-width: 0; }
}

@media (max-width: 380px) {
  .doc-builder-head-icon { display: none; }
  .doc-builder-head { grid-template-columns: 38px minmax(0, 1fr) 38px; }
  .doc-pack-grid { grid-auto-columns: minmax(150px, 56vw); }
  .doc-pack-card { min-height: 96px; }
}

/* ========================================================================== */
/* Mobile viewport hardening + native-style conversation audio                 */
/* ========================================================================== */
html,
body,
#app,
.app-shell,
.workspace,
.view {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

body.chat-open .more-menu {
  display: none !important;
}

.chat-overlay,
.conv {
  width: 100%;
  max-width: 100vw;
  min-width: 0;
  overflow: hidden;
}

.conv-header,
.conv-scroll,
.composer,
.msg-row,
.bubble,
.msg-doc {
  min-width: 0;
  max-width: 100%;
}

.msg-row { width: 100%; }
.bubble { max-width: min(86%, calc(100vw - 44px)); overflow: hidden; }
.msg-img,
.msg-video { max-width: 100%; }
.msg-doc { width: 100%; overflow: hidden; }
.msg-doc > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wa-audio {
  width: min(272px, calc(100vw - 88px));
  max-width: 100%;
  min-width: 210px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}

.wa-audio-native {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.wa-audio-play {
  width: 38px;
  height: 38px;
  position: relative;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: #1a8f70;
  border: 0;
  border-radius: 50%;
}

.wa-audio-play::before {
  content: "";
  width: 0;
  height: 0;
  margin-left: 3px;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 11px solid currentColor;
}

.wa-audio.is-playing .wa-audio-play::before {
  width: 4px;
  height: 15px;
  margin-left: -6px;
  background: currentColor;
  border: 0;
  box-shadow: 8px 0 0 currentColor;
}

.wa-audio-track {
  min-width: 0;
  height: 34px;
  position: relative;
  display: flex;
  align-items: center;
}

.wa-audio-wave {
  width: 100%;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  overflow: hidden;
}

.wa-audio-wave i {
  width: 2px;
  flex: 0 0 2px;
  background: #8ca19a;
  border-radius: 2px;
}

.wa-audio-wave i.played { background: #16876a; }
.wa-audio-scrub {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}
.wa-audio-time {
  color: #61746e;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.rec-bar {
  min-width: 0;
  gap: 7px;
  padding: 0 4px;
}
.rec-delete,
.rec-pause,
.rec-send {
  width: 38px;
  height: 38px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 50%;
}
.rec-delete { color: #b42332; background: transparent; }
.rec-delete svg,
.rec-send svg { width: 21px; height: 21px; }
.rec-pause { position: relative; color: #ffffff; background: #d9194b; }
.rec-pause::before {
  content: "";
  width: 4px;
  height: 16px;
  margin-left: -7px;
  background: currentColor;
  box-shadow: 9px 0 0 currentColor;
}
.rec-bar.is-paused .rec-pause::before {
  width: 0;
  height: 0;
  margin-left: 3px;
  background: transparent;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 11px solid currentColor;
  box-shadow: none;
}
.rec-bar.is-paused .rec-wave i { animation-play-state: paused; }
.rec-send { color: #ffffff; background: #1a8f70; }
.rec-time { flex: 0 0 auto; }
.rec-wave { min-width: 36px; gap: 2px; }
.rec-wave i { width: 2px; }

/* Operations filters and rows stay inside the phone viewport. */
.ops-rest-filters,
.ops-rest-range,
.reminder-custom-range {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.ops-rest-range[hidden],
.reminder-custom-range[hidden] { display: none; }
.ops-rest-list {
  display: grid;
  min-width: 0;
  overflow: hidden;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.ops-rest-card {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 92px;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  padding: 11px 10px;
  color: var(--text);
  background: var(--cream);
  border: 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.ops-rest-card:last-child { border-bottom: 0; }
.ops-rest-card.bucket-past { border-left: 3px solid #d94b5b; }
.ops-rest-card.bucket-current { border-left: 3px solid #1aa16f; }
.ops-rest-card.bucket-upcoming { border-left: 3px solid #d7911d; }
.ops-rest-avatar {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  color: #176b59;
  background: #def0ea;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
}
.ops-rest-copy,
.ops-rest-name-line { min-width: 0; }
.ops-rest-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ops-rest-name-line {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ops-rest-name-line b { flex: 1 1 auto; font-size: 13px; }
.ops-rest-status {
  flex: 0 0 auto;
  padding: 2px 6px;
  color: #5d6e69;
  background: #edf2f0;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
}
.ops-rest-name-line b,
.ops-rest-program,
.ops-rest-dates {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ops-rest-program,
.ops-rest-dates { display: block; color: var(--muted); font-size: 10px; }
.ops-rest-amount {
  max-width: 92px;
  justify-self: end;
  padding: 5px 7px;
  color: #40524c;
  background: #e9efed;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}
.ops-rest-filters select {
  margin-top: 5px;
  color: var(--text);
  background: var(--cream);
}
.reminder-date-filter {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow-x: auto;
}
.reminder-date-filter button { min-width: max-content; }
.reminder-filtered-feed,
.ops-reminder-section { min-width: 0; }

.inbox-filter-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.inbox-tools {
  grid-template-columns: minmax(360px, 1fr) minmax(260px, 1fr);
}
.date-filter-menu { right: 0; left: auto; }
.date-range-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  padding: 8px;
  border-top: 1px solid var(--border);
}
.date-range-fields[hidden] { display: none; }
.date-range-fields label { min-width: 0; margin: 0; }
.date-range-fields label span { display: block; margin-bottom: 3px; font-size: 10px; font-weight: 750; }
.date-range-fields input { min-width: 0; margin: 0; padding: 9px 7px; color: var(--text); background: var(--cream); }
.date-range-apply { grid-column: 1 / -1; padding: 8px; }
.inbox-load-sentinel,
.inbox-list-end {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
}
.inbox-load-more-btn {
  width: min(100%, 320px);
  min-height: 44px;
  padding: 9px 16px;
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--accent);
  font-size: 14px;
}
.inbox-load-more-btn:active { background: var(--surface-2); }
.inbox-load-sentinel .spinner {
  width: 18px;
  height: 18px;
  margin: 0;
  border-width: 2px;
}
.inbox-load-announcer {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
@media (max-width: 899px) {
  .inbox-tools { grid-template-columns: 1fr; }
  .inbox-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pipeline-filter-label b { font-size: 12px; }
}

@media (max-width: 380px) {
  .wa-audio { min-width: 190px; grid-template-columns: 36px minmax(0, 1fr) 38px; gap: 6px; }
  .wa-audio-wave { gap: 1px; }
  .rec-bar { gap: 4px; }
  .rec-delete,
  .rec-pause,
  .rec-send { width: 36px; height: 36px; }
}

/* Placement assessment (mobile) — CEFR auto-fill eval form inside the test sheet */
.test-eval { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.test-eval-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 2px; }
.test-eval-head h3 { margin: 2px 0 0; font-size: 16px; color: var(--text); }
.test-eval-kicker { font-size: 9px; font-weight: 800; letter-spacing: .12em; color: var(--accent); }
.test-eval-overall { min-width: 76px; text-align: center; padding: 6px 10px; border-radius: var(--r); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--border)); }
.test-eval-overall span { display: block; font-size: 9px; font-weight: 700; text-transform: uppercase; color: var(--accent); }
.test-eval-overall strong { display: block; font-size: 18px; color: var(--accent); font-variant-numeric: tabular-nums; }
.test-eval-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 8px; }
.test-eval-levels { display: flex; flex-wrap: wrap; gap: 6px; }
.test-cefr { min-width: 44px; min-height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 700; color: var(--text); font-size: 14px; }
.test-cefr.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.test-skill-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.test-skill { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }
.test-skill-name { font-weight: 600; font-size: 13px; }
.test-skill-input { display: flex; align-items: center; gap: 3px; }
.test-skill-field { width: 48px; height: 38px; text-align: center; border: 1px solid var(--border); border-radius: 6px; font-size: 15px; font-weight: 700; background: var(--bg); color: var(--text); }
.test-skill-input em { color: var(--muted); font-style: normal; font-size: 12px; }
.test-eval-notes { width: 100%; border: 1px solid var(--border); border-radius: var(--r); padding: 10px; font: inherit; resize: vertical; background: var(--surface); color: var(--text); }
.test-rec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.test-rec { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); text-align: left; min-height: var(--tap); color: var(--text); }
.test-rec b { font-size: 13px; }
.test-rec small { color: var(--muted); font-size: 11px; }
.test-rec-dur { margin-top: 2px; font-size: 11px; font-weight: 700; color: var(--accent); }
.test-rec.is-active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.test-eval-err { color: var(--danger); font-size: 12px; font-weight: 600; }
.test-eval-save { width: 100%; }

/* ---- Pipeline (views/pipeline.js) ---------------------------------------- */
.pl-agent { width: 100%; margin: -6px 0 10px; }
.pl-stages { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding: 2px 0 10px; margin: 0 -4px; }
.pl-stages::-webkit-scrollbar { display: none; }
.pl-stage-chip { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 6px 11px 6px 12px; color: #475852; background: var(--cream); border: 1px solid var(--border); border-radius: 999px; font: inherit; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pl-stage-chip b { min-width: 18px; padding: 1px 6px; color: #ffffff; background: #899993; border-radius: 999px; font-size: 10.5px; text-align: center; }
.pl-stage-chip.active { color: #ffffff; background: var(--accent); border-color: var(--accent); }
.pl-stage-chip.active b { color: var(--accent); background: var(--cream); }
.pl-stage-chip:active { transform: scale(0.97); }
.pl-list .lead-card .chip { max-width: 112px; overflow: hidden; text-overflow: ellipsis; }
.chip.s-book_test { color: #76510a; background: #f8ecd2; }
.chip.s-not_interested { color: #8d3b3b; background: #f8e2e2; }
.chip.s-all { color: #475852; background: #e9efed; }

.pl-sheet { display: flex; flex-direction: column; gap: 14px; }
.pl-head { display: flex; align-items: center; gap: 12px; }
.pl-avatar { width: 46px; height: 46px; flex: 0 0 46px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #1f3b7a; background: #e6eefc; font-weight: 800; }
.pl-head-copy { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.pl-head-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pl-muted { color: var(--muted); font-size: 11.5px; overflow-wrap: anywhere; }

.pl-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pl-action, .pl-actions .conv-call { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 66px; padding: 8px 6px; color: #243632; background: var(--cream); border: 1px solid var(--border); border-radius: 10px; font: inherit; font-size: 11.5px; font-weight: 700; text-align: center; line-height: 1.2; }
.pl-actions .conv-call { margin: 0; width: auto; }
.pl-actions .conv-call svg, .pl-action-ico svg { width: 20px; height: 20px; }
.pl-action:disabled { opacity: 0.45; }
.pl-action:active, .pl-actions .conv-call:active { background: var(--surface-2); }
.pl-action-ico { display: inline-flex; color: var(--accent); }

.pl-block { padding-top: 12px; border-top: 1px solid var(--border); }
.pl-stage-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.pl-stage-row select, .pl-stage-row input, .pl-select, .pl-pay select, .pl-pay input, .pl-pay textarea, .pl-add input, .pl-add textarea, .pl-sheet .ops-form-field select {
  width: 100%; min-width: 0; min-height: 42px; padding: 9px 11px; color: var(--text); background: var(--cream); border: 1px solid #cdd8d4; border-radius: 7px; font: inherit;
}
.pl-pay { margin-bottom: 8px; padding: 12px; background: #f4f7f6; border: 1px dashed #c7d3ce; border-radius: 10px; }
.pl-pay-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.pl-pay .ops-form-field { margin-bottom: 9px; }
.pl-save { width: 100%; margin-top: 4px; }

.pl-tabs { display: flex; gap: 4px; padding: 3px; background: #e9efed; border-radius: 9px; margin-bottom: 12px; }
.pl-tab { flex: 1; min-height: 36px; color: #52635e; background: transparent; border: 0; border-radius: 7px; font: inherit; font-size: 12.5px; font-weight: 700; }
.pl-tab.active { color: var(--text); background: var(--cream); box-shadow: 0 1px 2px rgba(20, 40, 35, 0.12); }
.pl-items { display: flex; flex-direction: column; gap: 8px; }
.pl-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; background: var(--cream); border: 1px solid var(--border); border-radius: 9px; }
.pl-item > div, .pl-item > p { min-width: 0; flex: 1; }
.pl-item p { margin: 0 0 3px; font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; white-space: pre-wrap; }
.pl-item small { display: block; color: var(--muted); font-size: 11px; }
.pl-item:not(.pl-hist) { flex-direction: row; }
.pl-item.pl-hist { flex-direction: column; align-items: flex-start; gap: 4px; }
.pl-hist-stages { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pl-arrow { color: var(--muted); }
.pl-rem.overdue { border-color: #f0b8b8; background: #fff6f6; }
.pl-rem.done { opacity: 0.6; }
.pl-rem-done { flex: 0 0 auto; color: #116f49; background: #dbf1e6; }
.pl-add { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.pl-add .btn { width: 100%; }

.pl-slots { display: flex; flex-direction: column; gap: 14px; }
.pl-teacher h4 { margin: 0 0 8px; font-size: 13px; }
.pl-slot-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.pl-slot { min-height: 42px; color: #1f3b7a; background: #eef3ff; border: 1px solid #c9d8fb; border-radius: 8px; font: inherit; font-size: 13px; font-weight: 800; }
.pl-slot:active { background: #dbe6ff; }
.pl-slot:disabled { opacity: 0.5; }

@media (min-width: 900px) {
  .pl-actions { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .pl-pay-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pl-slot-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}
.pl-actions .conv-call .pl-action-label { display: block; font-size: 11.5px; font-weight: 700; color: #243632; }
.pl-actions .conv-call-office::after { top: 4px; right: 6px; }

/* ---- Channels + Tutoriels (views/channels.js) ----------------------------- */
.composer-wrap { flex: 0 0 auto; display: flex; flex-direction: column; }
.ch-strip { display: flex; gap: 6px; padding: 7px 14px 0; background: #f3f5f4; border-top: 1px solid #dfe6e3; }
.composer-wrap .composer { border-top: 0; }
.ch-seg { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 4px 11px; color: #52635e; background: var(--cream); border: 1px solid #d8e0dd; border-radius: 999px; font: inherit; font-size: 12px; font-weight: 700; }
.ch-seg svg { width: 15px; height: 15px; }
.ch-seg.active { color: #ffffff; background: #128c7e; border-color: #128c7e; }
.ch-seg.active:nth-child(2) { background: #3559b8; border-color: #3559b8; }
.ch-seg-mail { margin-left: auto; color: #6c45a4; border-color: #d9cdf0; background: #f6f1fd; }
.msg-row .bubble[data-channel="sms"] .msg-meta::before { content: 'SMS'; margin-right: 6px; padding: 0 5px; border-radius: 4px; background: #e6ecfb; color: #3559b8; font-size: 9.5px; font-weight: 800; }
.ch-mail textarea { min-height: 120px; }
.ch-mail input[type="file"] { padding: 8px; background: var(--cream); border: 1px dashed #c7d3ce; border-radius: 7px; }

.tuto-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tuto-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; text-align: left; color: var(--text); background: var(--cream); border: 1px solid var(--border); border-radius: 12px; font: inherit; }
.tuto-card:active { background: var(--surface-2); }
.tuto-card:disabled, .tuto-card.sending { opacity: 0.55; }
.tuto-thumb { position: relative; aspect-ratio: 16 / 10; display: grid; place-items: center; background: #0f2a33; color: #ffffff; overflow: hidden; }
.tuto-thumb img { width: 100%; height: 100%; object-fit: cover; }
.tuto-thumb > span:not(.tuto-badge) svg { width: 34px; height: 34px; opacity: 0.9; }
.tuto-badge { position: absolute; right: 6px; bottom: 6px; padding: 2px 6px; background: rgba(0, 0, 0, 0.62); color: #ffffff; border-radius: 5px; font-size: 10.5px; font-weight: 800; }
.tuto-copy { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; }
.tuto-copy b { font-size: 12.5px; line-height: 1.3; overflow-wrap: anywhere; }
.tuto-copy small { color: var(--muted); font-size: 11px; }
@media (min-width: 900px) { .tuto-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.pl-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
.pl-kpi { display: flex; flex-direction: column; gap: 2px; min-height: 54px; padding: 8px; background: var(--cream); border: 1px solid var(--border); border-top: 3px solid #899993; border-radius: 7px; }
.pl-kpi small { color: var(--muted); font-size: 10.5px; font-weight: 700; }
.pl-kpi b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-kpi.ok { border-top-color: #116f49; } .pl-kpi.warn { border-top-color: #b7791f; } .pl-kpi.bad { border-top-color: #a72e37; }
.pl-kpi.s-paid { border-top-color: #116f49; } .pl-kpi.s-proforma_sent { border-top-color: #6c45a4; }
.pl-rest .ops-detail-row { width: 100%; min-height: 34px; padding: 5px 0; }
.pl-rest.bucket-past { border-color: #f0b8b8; background: #fff6f6; }
.pl-rest.bucket-current { border-color: #f3d9a4; background: #fffaf0; }
.pl-total { padding: 6px 2px 0; color: var(--text); font-size: 12.5px; font-weight: 800; text-align: right; }
.pl-pay-actions { margin-top: 12px; }
.pl-slot { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.pl-slot small { font-size: 9.5px; font-weight: 700; color: #4a6aa8; }
