:root {
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --line: #e4ebe7;
  --text: #17251f;
  --muted: #8b9a91;
  --muted-deep: #62736a;
  --primary: #09a978;
  --primary-deep: #058361;
  --primary-soft: #e2f7ef;
  --blue: #4a86ff;
  --blue-soft: #eaf1ff;
  --amber: #f6a51c;
  --amber-soft: #fff3dc;
  --red: #e75b66;
  --shadow: 0 8px 24px rgba(24, 47, 37, 0.045);
  --sidebar-width: 280px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; margin: 0; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(9, 169, 120, .25); outline-offset: 2px; }
body { overflow-x: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

[data-icon] { width: 20px; height: 20px; display: inline-grid; place-items: center; flex: 0 0 auto; }
[data-icon] svg { width: 100%; height: 100%; stroke: currentColor; stroke-width: 1.9; fill: none; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { min-height: 100vh; background: var(--bg); }
.app-loading > :not(.boot-screen) { visibility: hidden; }
.boot-screen { display: none; }
.app-loading .boot-screen { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--bg); font-size: 20px; }
.boot-spinner { width: 19px; height: 19px; border: 2px solid #cae8de; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: var(--sidebar-width); z-index: 20; display: flex; flex-direction: column; padding: 22px 14px 16px; background: var(--surface); border-right: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 12px; min-height: 54px; padding: 0 13px; color: inherit; text-decoration: none; }
.brand-mark { width: 37px; height: 37px; display: inline-grid; place-items: center; background: var(--primary); color: white; font-size: 21px; font-weight: 900; border-radius: 13px 13px 13px 3px; box-shadow: 0 7px 16px rgba(9,169,120,.2); }
.brand b { display: block; font-size: 19px; line-height: 1.05; letter-spacing: -.5px; }
.brand small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: 1.2px; }
.side-nav { margin-top: 35px; overflow-y: auto; }
.nav-caption { margin: 0 17px 11px; color: #a5b2aa; font-size: 11px; font-weight: 800; letter-spacing: .85px; }
.nav-caption-bottom { margin-top: 31px; }
.nav-link { position: relative; width: 100%; min-height: 52px; border: 0; display: flex; align-items: center; gap: 14px; padding: 0 18px; color: var(--muted-deep); background: transparent; border-radius: 15px; text-align: left; font-size: 16px; font-weight: 650; transition: .17s ease; }
.nav-link:hover { color: var(--primary-deep); background: #f2faf6; }
.nav-link.active { color: #007f5b; background: var(--primary-soft); }
.nav-link.active [data-icon] { color: var(--primary); }
.nav-link.muted { color: #778980; }
.nav-badge { min-width: 24px; height: 24px; margin-left: auto; display: inline-grid; place-items: center; padding: 0 7px; border-radius: 10px; color: #527167; background: #edf3f0; font-size: 12px; }
.sidebar-footer { margin: auto 4px 0; padding: 15px 14px; display: flex; align-items: flex-start; gap: 10px; background: #f9fbfa; border: 1px solid var(--line); border-radius: 16px; font-size: 12px; }
.sidebar-footer b { display: block; font-size: 12px; }
.sidebar-footer small { display: block; margin-top: 4px; color: var(--muted); }
.status-dot, .live-label i, .updated-indicator i { width: 9px; height: 9px; flex: 0 0 9px; margin-top: 3px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 4px #e4f9f0; }

/* The sidebar is fixed, so the content reserves its own left-hand space. */
.main { min-width: 0; margin-left: var(--sidebar-width); }
.topbar { min-height: 101px; display: flex; align-items: center; gap: 24px; padding: 17px 38px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); }
.page-heading { min-width: 220px; }
.page-heading h1 { margin: 0; font-size: 27px; line-height: 1.1; letter-spacing: -.75px; }
.page-heading p { margin: 6px 0 0; color: var(--muted); font-size: 15px; }
.topbar-actions { position: relative; margin-left: auto; display: flex; align-items: center; gap: 12px; }
.global-search { width: min(360px, 28vw); height: 52px; display: flex; align-items: center; gap: 11px; padding: 0 13px 0 16px; color: var(--muted); background: #fbfcfc; border: 1px solid var(--line); border-radius: 16px; }
.global-search input { width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; }
.global-search input::placeholder, .conversation-search input::placeholder, .crm-search input::placeholder, .message-composer textarea::placeholder { color: #adb9b2; }
kbd { min-width: 23px; height: 23px; display: grid; place-items: center; border: 1px solid #dde7e1; border-radius: 7px; color: #95a29b; background: white; font-size: 12px; }
.icon-button { width: 51px; height: 51px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 16px; color: #60736a; background: white; transition: .16s ease; }
.icon-button:hover { color: var(--primary-deep); background: var(--primary-soft); border-color: #c8eadc; }
.user-button { min-height: 51px; display: flex; align-items: center; gap: 9px; padding: 5px 11px 5px 6px; border: 1px solid var(--line); border-radius: 16px; color: var(--text); background: white; font-weight: 700; }
.user-initials { width: 37px; height: 37px; display: grid; place-items: center; border-radius: 12px; color: white; background: linear-gradient(135deg, #12b98a, #058163); font-size: 14px; }
.user-button [data-icon] { width: 15px; height: 15px; color: var(--muted); }
.user-menu { position: absolute; top: 60px; right: 0; z-index: 50; width: 150px; padding: 6px; background: white; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.user-menu button { width: 100%; display: flex; align-items: center; gap: 9px; padding: 10px; border: 0; border-radius: 8px; color: #ba4149; background: transparent; text-align: left; }
.user-menu button:hover { background: #fff2f3; }
.mobile-menu { display: none; }

.toolbar { min-height: 84px; display: flex; align-items: center; gap: 15px; padding: 13px 38px; }
.bot-select-wrap { height: 49px; display: flex; align-items: center; gap: 10px; padding: 0 12px 0 15px; background: white; border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 2px 6px rgba(38,62,51,.02); }
.bot-select-wrap label { color: var(--muted-deep); font-weight: 700; font-size: 13px; }
.bot-select-wrap select { max-width: 235px; min-width: 155px; border: 0; outline: 0; color: var(--text); background: transparent; font-weight: 750; }
.period-switcher { display: flex; align-items: center; gap: 3px; padding: 4px; background: white; border: 1px solid var(--line); border-radius: 16px; }
.period-switcher button { min-width: 65px; height: 39px; padding: 0 11px; border: 0; border-radius: 13px; color: #617269; background: transparent; font-size: 14px; font-weight: 700; }
.period-switcher button:hover { background: #f1f7f4; }
.period-switcher button.active { color: #007c58; background: var(--primary-soft); }
.updated-indicator { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; color: var(--muted); font-size: 13px; }
.updated-indicator i { margin: 0; width: 7px; height: 7px; flex-basis: 7px; box-shadow: none; }

.view { display: none; padding: 18px 38px 42px; }
.view.active { display: block; animation: view-in .22s ease both; }
@keyframes view-in { from { opacity: .35; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 22px; }
.metric-card { min-height: 188px; padding: 26px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.metric-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 16px; color: var(--blue); background: var(--blue-soft); }
.metric-icon.green { color: var(--primary); background: var(--primary-soft); }
.metric-icon.amber { color: #e68c00; background: var(--amber-soft); }
.metric-icon.purple { color: #8166d9; background: #f0ecff; }
.metric-value { margin-top: auto; font-size: clamp(29px, 2.35vw, 42px); line-height: 1; letter-spacing: -1.9px; font-weight: 800; }
.metric-label { margin-top: 11px; color: var(--muted); font-size: 15px; }
.loading-card { overflow: hidden; position: relative; justify-content: space-between; }
.loading-card:after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.75), transparent); animation: skeleton 1.2s infinite; }
.loading-card span, .loading-card div { display: block; border-radius: 9px; background: #edf2ef; }
.loading-card span { width: 50px; height: 50px; }
.loading-card div { width: 68%; height: 32px; }
@keyframes skeleton { to { transform: translateX(100%); } }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.62fr) minmax(300px, 1fr); gap: 22px; margin-top: 22px; }
.bottom-grid { grid-template-columns: minmax(0, 1.62fr) minmax(300px, 1fr); }
.panel { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.chart-panel { min-height: 397px; padding: 29px 27px 22px; }
.bot-status-panel { min-height: 397px; padding: 29px 27px; }
.panel-heading { display: flex; align-items: flex-start; gap: 14px; }
.panel-heading h2, .crm-toolbar h2 { margin: 0; font-size: 20px; letter-spacing: -.45px; }
.panel-heading p, .crm-toolbar p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.panel-value { margin-left: auto; padding-top: 3px; color: var(--primary-deep); font-weight: 800; font-size: 14px; }
.live-label { display: inline-flex; align-items: center; gap: 7px; margin-left: auto; padding: 8px 11px; color: #0a8d67; background: var(--primary-soft); border-radius: 99px; white-space: nowrap; font-size: 12px; font-weight: 800; }
.live-label i { width: 6px; height: 6px; flex-basis: 6px; margin: 0; box-shadow: none; }
/* The gap is supplied by the script: a 7-day chart wants wide spacing, a
   30-day one has to fit thirty columns inside the same panel. */
.bar-chart { height: 270px; display: grid; grid-template-columns: repeat(var(--columns, 7), minmax(0, 1fr)); align-items: end; gap: var(--bar-gap, 14px); padding: 32px 24px 0; }
.bar-item { height: 100%; display: grid; grid-template-rows: 1fr 30px; align-items: end; gap: 10px; min-width: 0; }
.bar-wrap { height: 100%; display: flex; align-items: end; padding: 0 var(--bar-pad, 5px); }
.bar { width: 100%; min-height: 5px; border-radius: 11px 11px 5px 5px; background: linear-gradient(180deg, #a9ead1, #dff5eb); transition: height .45s cubic-bezier(.2,.7,.2,1); }
.bar-item.today .bar { background: linear-gradient(180deg, #11b884, #b9edd8); }
.bar-item label { overflow: visible; color: #a0ada6; font-size: clamp(10px, .85vw, 13px); font-weight: 700; text-align: center; white-space: nowrap; }
.bar-item.today label { color: var(--primary); }
.chart-empty { height: 270px; }
.empty-block { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 30px; color: var(--muted); text-align: center; }
.empty-block [data-icon] { width: 37px; height: 37px; color: #9cb0a6; }
.empty-block h2, .empty-block p { margin: 0; }
.empty-block h2 { color: #5d7066; font-size: 18px; }
.empty-block p { font-size: 14px; }

.bot-status-list { margin-top: 18px; }
.bot-status-item { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid #edf2ef; }
.bot-status-item:last-child { border-bottom: 0; }
.bot-avatar { width: 39px; height: 39px; display: grid; place-items: center; flex: 0 0 39px; border-radius: 13px; color: white; background: linear-gradient(135deg, #1cbb8d, #04765b); font-size: 14px; font-weight: 800; }
.bot-status-info { min-width: 0; }
.bot-status-info b, .bot-status-info small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-status-info b { font-size: 14px; }
.bot-status-info small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.status-pill { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; padding: 6px 8px; color: #07855f; background: var(--primary-soft); border-radius: 99px; font-size: 11px; font-weight: 800; }
.status-pill.offline { color: #a87919; background: var(--amber-soft); }
.status-pill i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.recent-panel { padding: 27px; }
.recent-conversations { margin-top: 11px; }
.recent-item { width: 100%; display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 4px; border: 0; border-bottom: 1px solid #edf2ef; color: inherit; background: transparent; text-align: left; }
.recent-item:last-child { border-bottom: 0; }
.recent-item:hover { color: var(--primary-deep); }
.mini-avatar, .avatar, .profile-avatar { display: grid; place-items: center; overflow: hidden; color: #fff; background: linear-gradient(135deg, #70c6af, #138d70); font-weight: 800; }
.mini-avatar { width: 40px; height: 40px; border-radius: 13px; font-size: 13px; }
.recent-copy { min-width: 0; }
.recent-copy b, .recent-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-copy b { font-size: 14px; }
.recent-copy span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.recent-time { color: var(--muted); font-size: 12px; }
.text-button { display: inline-flex; align-items: center; gap: 5px; padding: 2px; border: 0; color: var(--primary-deep); background: transparent; font-size: 13px; font-weight: 800; }
.text-button [data-icon] { width: 16px; height: 16px; }
.quick-panel { padding: 27px; }
.quick-action { width: 100%; display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 13px 0; border: 0; border-bottom: 1px solid #edf2ef; color: inherit; background: transparent; text-align: left; }
.quick-action:last-child { border-bottom: 0; }
.quick-action:hover b { color: var(--primary-deep); }
.quick-action > [data-icon] { width: 17px; height: 17px; margin-left: auto; color: #9eaea6; }
.quick-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: var(--primary); background: var(--primary-soft); }
.quick-icon.orange { color: #db8900; background: var(--amber-soft); }
.quick-action b, .quick-action small { display: block; }
.quick-action b { font-size: 14px; }
.quick-action small { margin-top: 3px; color: var(--muted); font-size: 12px; }

/* Conversations */
/* The chat column is bound to the viewport so the composer is always visible:
   the message list scrolls inside it, exactly like Telegram. */
.conversation-layout { height: calc(100vh - 226px); min-height: 520px; display: grid; grid-template-columns: 355px minmax(400px, 1fr) 253px; gap: 18px; }
.conversation-list-panel { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.conversation-search { display: flex; align-items: center; gap: 8px; margin: 19px 18px 13px; padding: 0 8px 0 14px; color: #8e9e96; border: 1px solid var(--line); border-radius: 14px; background: #fcfdfd; }
.conversation-search input { width: 100%; height: 48px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13px; }
.conversation-search button { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 10px; color: #798c83; background: transparent; }
.conversation-search button:hover { background: var(--primary-soft); color: var(--primary-deep); }
.conversation-search button [data-icon] { width: 17px; height: 17px; }
.conversation-tabs { display: flex; gap: 6px; padding: 0 18px 14px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.conversation-tabs button { min-height: 38px; display: inline-flex; align-items: center; gap: 7px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; color: #64756c; background: white; white-space: nowrap; font-size: 13px; font-weight: 750; }
.conversation-tabs button.active { color: #007e5a; border-color: transparent; background: var(--primary-soft); }
.conversation-tabs em { min-width: 20px; height: 20px; display: grid; place-items: center; border-radius: 8px; color: #fff; background: var(--primary); font-size: 11px; font-style: normal; }
.conversation-tabs button:not(.active) em { color: #708077; background: #edf3f0; }
.conversation-list { flex: 1; min-height: 0; overflow: auto; padding: 8px; }
.conversation-row { width: 100%; display: grid; grid-template-columns: 47px minmax(0, 1fr) auto; gap: 10px; padding: 12px 10px; border: 0; border-radius: 15px; color: var(--text); background: transparent; text-align: left; transition: .15s ease; }
.conversation-row:hover { background: #f6faf8; }
.conversation-row.active { background: var(--primary-soft); }
.conversation-avatar { width: 47px; height: 47px; display: grid; place-items: center; overflow: hidden; border-radius: 50%; color: white; background: linear-gradient(135deg, #77bea9, #168768); font-size: 14px; font-weight: 800; }
.conversation-avatar img, .avatar img, .profile-avatar img, .mini-avatar img { width: 100%; height: 100%; object-fit: cover; }
.conversation-copy { min-width: 0; }
.conversation-row-top { display: flex; align-items: baseline; gap: 7px; }
.conversation-row b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.conversation-row p { overflow: hidden; margin: 5px 0 0; color: #8a9a91; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.conversation-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; color: #a6b0aa; font-size: 11px; white-space: nowrap; }
.unread-badge { min-width: 19px; height: 19px; display: grid; place-items: center; padding: 0 5px; border-radius: 8px; color: white; background: var(--primary); font-size: 10px; font-weight: 800; }
.load-more { width: calc(100% - 36px); min-height: 38px; margin: 10px 18px 18px; border: 1px solid #bfe8d8; border-radius: 11px; color: var(--primary-deep); background: #f1fbf6; font-size: 13px; font-weight: 750; }
.chat-panel { position: relative; min-height: 0; display: flex; overflow: hidden; }
.chat-placeholder, .profile-placeholder { width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 11px; padding: 30px; color: var(--muted); text-align: center; }
.chat-placeholder [data-icon], .profile-placeholder [data-icon] { width: 46px; height: 46px; color: #a6b8af; }
.chat-placeholder h2 { margin: 0; color: #596e63; font-size: 19px; }
.chat-placeholder p, .profile-placeholder p { max-width: 250px; margin: 0; font-size: 14px; }
/* Without an explicit column the implicit grid track sizes to max-content, so the composer kept its natural width and the send button sat outside the panel (clipped by overflow:hidden). minmax(0,1fr) pins the column to the panel width and lets the row shrink. */
.chat-content { width: 100%; height: 100%; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; }
.chat-header { min-height: 82px; display: flex; align-items: center; gap: 11px; padding: 14px 19px; border-bottom: 1px solid var(--line); }
.avatar { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%; font-size: 13px; }
.chat-contact { min-width: 0; }
.chat-contact h2 { overflow: hidden; margin: 0; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.chat-contact p { overflow: hidden; margin: 4px 0 0; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.chat-header .icon-button { width: 40px; height: 40px; margin-left: auto; border-radius: 13px; }
.back-to-list { display: none; width: 35px; height: 35px; border: 0; border-radius: 10px; color: var(--muted-deep); background: #f4f8f6; }
.messages { min-height: 0; overflow-y: auto; padding: 21px clamp(19px, 4vw, 50px); background: linear-gradient(180deg, #fcfefd 0%, #f7faf8 100%); }
.message-day { width: max-content; margin: 0 auto 20px; padding: 6px 11px; border-radius: 10px; color: #779087; background: #eaf1ed; font-size: 11px; font-weight: 750; }
.message { width: fit-content; max-width: min(82%, 560px); margin: 0 0 14px; padding: 12px 14px 9px; border: 1px solid #e2e9e5; border-radius: 18px 18px 18px 5px; background: white; color: #2d4037; box-shadow: 0 2px 5px rgba(22,46,35,.025); }
.message.outgoing { margin-left: auto; border-color: transparent; border-radius: 18px 18px 5px 18px; color: white; background: #0cac7c; }
.message p { margin: 0; line-height: 1.45; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.message footer { display: flex; align-items: center; justify-content: flex-end; gap: 5px; margin-top: 4px; color: #a0ada7; font-size: 10px; }
.message.outgoing footer { color: rgba(255,255,255,.78); }
.message footer [data-icon] { width: 13px; height: 13px; }
/* A grid item defaults to min-width:auto, so without this the composer keeps its content width and pushes the send button past the panel edge while recording. */
.message-composer { min-width: 0; display: flex; align-items: flex-end; gap: 10px; padding: 14px 17px; border-top: 1px solid var(--line); background: white; }
/* width:100% as a flex-basis plus the default min-width:auto stops the textarea shrinking, which pushed the send button outside the panel. */
.message-composer textarea { width: 100%; min-width: 0; flex: 1 1 0; max-height: 130px; min-height: 47px; resize: none; padding: 13px 15px; border: 1px solid var(--line); border-radius: 15px; outline: none; color: var(--text); background: #fbfcfb; line-height: 1.35; }
.message-composer textarea:focus { border-color: #99d8c2; background: white; }
.send-button { width: 47px; height: 47px; display: grid; place-items: center; flex: 0 0 47px; border: 0; border-radius: 15px; color: white; background: var(--primary); box-shadow: 0 5px 11px rgba(9,169,120,.18); }
.send-button:hover { background: var(--primary-deep); }
.send-button:disabled { opacity: .48; box-shadow: none; }
.send-button [data-icon] { width: 20px; height: 20px; }
.lead-profile { min-height: 0; overflow-y: auto; }
.profile-top { padding: 30px 23px 21px; text-align: center; border-bottom: 1px solid var(--line); }
.profile-avatar { width: 69px; height: 69px; margin: 0 auto 12px; border-radius: 24px; font-size: 20px; }
.profile-top h2 { overflow: hidden; margin: 0; font-size: 17px; text-overflow: ellipsis; white-space: nowrap; }
.profile-top p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.profile-details { margin: 0; padding: 12px 21px; }
.profile-details div { padding: 12px 0; border-bottom: 1px solid #eef2ef; }
.profile-details div:last-child { border-bottom: 0; }
.profile-details dt { color: #9aa89f; font-size: 11px; font-weight: 700; }
.profile-details dd { margin: 5px 0 0; color: #30443a; font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
.profile-stage { display: inline-flex; padding: 4px 8px; border-radius: 8px; color: #9a6915; background: var(--amber-soft); }
.amo-link { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 5px 21px 21px; min-height: 42px; border: 1px solid #bae6d4; border-radius: 12px; color: var(--primary-deep); background: #f2fbf6; text-decoration: none; font-size: 13px; font-weight: 800; }
.amo-link:hover { background: var(--primary-soft); }
.amo-link [data-icon] { width: 16px; height: 16px; }

/* CRM */
.crm-toolbar { display: flex; align-items: center; gap: 15px; margin-bottom: 20px; }
.crm-search { width: min(330px, 45vw); height: 47px; display: flex; align-items: center; gap: 9px; margin-left: auto; padding: 0 14px; color: #8e9e96; background: white; border: 1px solid var(--line); border-radius: 14px; }
.crm-search input { width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 14px; }
.pipeline-navigation { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 58px; margin: -5px 0 10px; padding: 9px 10px 9px 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.82); }
.pipeline-navigation-title { display: inline-flex; align-items: center; gap: 8px; color: #597168; font-size: 12px; font-weight: 800; white-space: nowrap; }
.pipeline-navigation-title [data-icon] { width: 17px; height: 17px; color: var(--primary); }
.pipeline-stage-tabs { display: flex; gap: 7px; min-width: 0; overflow-x: auto; scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: #b7d8ca transparent; }
.pipeline-stage-tab { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; flex: 0 0 auto; max-width: 210px; padding: 0 10px; border: 1px solid #e1eae5; border-radius: 11px; color: #61766b; background: #fff; white-space: nowrap; font-size: 12px; font-weight: 750; }
.pipeline-stage-tab:hover, .pipeline-stage-tab.active { border-color: #a9dfc9; color: #087c5a; background: var(--primary-soft); }
.pipeline-stage-tab i { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: var(--stage-color, var(--primary)); }
.pipeline-stage-tab span { overflow: hidden; text-overflow: ellipsis; }
.pipeline-stage-tab b { display: grid; min-width: 19px; height: 19px; place-items: center; padding: 0 4px; border-radius: 7px; color: #587367; background: #eef4f1; font-size: 10px; }
.pipeline-navigation-actions { display: flex; gap: 6px; }
.pipeline-scroll-button { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid #dfe9e4; border-radius: 11px; color: #557067; background: #fff; }
.pipeline-scroll-button:hover:not(:disabled) { border-color: #9ad8c0; color: #067b58; background: var(--primary-soft); }
.pipeline-scroll-button:disabled { cursor: not-allowed; opacity: .38; }
.pipeline-scroll-button [data-icon] { width: 17px; height: 17px; }
.pipeline-scroll-hint { margin: 0 0 12px; color: #789087; font-size: 12px; }
.pipeline-board { display: flex; min-height: calc(100vh - 375px); gap: 16px; overflow-x: auto; overscroll-behavior-x: contain; padding: 2px 2px 14px; scroll-behavior: smooth; scroll-padding-inline: 2px; scroll-snap-type: x proximity; scrollbar-color: #9bcfba #eef4f1; scrollbar-width: thin; }
.pipeline-board::-webkit-scrollbar { height: 10px; }
.pipeline-board::-webkit-scrollbar-track { border-radius: 99px; background: #eef4f1; }
.pipeline-board::-webkit-scrollbar-thumb { border: 2px solid #eef4f1; border-radius: 99px; background: #9bcfba; }
.stage-column { width: min(320px, 79vw); min-width: 263px; display: flex; flex-direction: column; max-height: calc(100vh - 352px); min-height: 540px; padding: 14px 12px; border: 1px solid var(--line); border-radius: 19px; background: #ebf0ed; scroll-snap-align: start; scroll-margin-inline: 3px; }
.stage-header { display: flex; align-items: center; gap: 8px; padding: 2px 4px 13px; }
.stage-color { width: 9px; height: 9px; border-radius: 50%; background: var(--stage-color, var(--primary)); }
.stage-header h3 { overflow: hidden; margin: 0; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.stage-header span { margin-left: auto; min-width: 22px; height: 22px; display: grid; place-items: center; border-radius: 8px; color: #5f7569; background: white; font-size: 11px; font-weight: 800; }
.stage-leads { min-height: 50px; overflow-y: auto; padding-right: 2px; }
.lead-card { width: 100%; padding: 13px; margin-bottom: 9px; border: 1px solid #e7edea; border-radius: 14px; color: inherit; background: white; box-shadow: 0 2px 5px rgba(21,44,33,.035); text-align: left; }
.lead-card:hover { border-color: #a4ddc7; transform: translateY(-1px); box-shadow: 0 7px 13px rgba(23,65,46,.07); }
.lead-card-top { display: flex; align-items: flex-start; gap: 9px; }
.lead-card .mini-avatar { width: 32px; height: 32px; flex-basis: 32px; border-radius: 10px; font-size: 11px; }
.lead-card b { display: block; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.lead-card small { display: block; overflow: hidden; margin-top: 3px; color: #8b9b92; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.lead-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 5px; margin-top: 12px; color: #92a198; font-size: 11px; }
.lead-card-tag { overflow: hidden; max-width: 130px; padding: 4px 6px; border-radius: 7px; color: #087f5c; background: var(--primary-soft); text-overflow: ellipsis; white-space: nowrap; }
.stage-empty { padding: 24px 8px; color: #87988e; text-align: center; font-size: 12px; }
.pipeline-empty { min-height: 300px; border: 1px dashed #c7d8cf; border-radius: 22px; background: #fbfdfc; }

/* login + notifications */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: linear-gradient(125deg, rgba(228,247,239,.96), rgba(244,247,246,.98) 43%, rgba(232,245,240,.96)); transition: opacity .22s, visibility .22s; }
.modal-backdrop.hidden { visibility: hidden; opacity: 0; pointer-events: none; }
.login-card { width: min(100%, 410px); padding: 40px; border: 1px solid rgba(255,255,255,.75); border-radius: 28px; background: rgba(255,255,255,.93); box-shadow: 0 25px 80px rgba(12,61,42,.15); }
.login-mark { margin-bottom: 19px; }
.eyebrow { margin: 0; color: var(--primary-deep); font-size: 11px; font-weight: 850; letter-spacing: 1.15px; }
.login-card h1 { margin: 8px 0 6px; font-size: 29px; letter-spacing: -.8px; }
.login-copy { margin: 0 0 25px; color: var(--muted-deep); line-height: 1.5; font-size: 14px; }
.login-card label { display: block; margin-top: 15px; color: #556a5f; font-size: 12px; font-weight: 750; }
.login-card input { width: 100%; height: 50px; margin-top: 7px; padding: 0 14px; outline: 0; border: 1px solid var(--line); border-radius: 13px; color: var(--text); background: #fbfcfb; }
.login-card input:focus { border-color: #91d6be; background: #fff; }
.form-error { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; color: #a34249; background: #fff1f2; font-size: 13px; }
.login-submit { width: 100%; min-height: 52px; display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 21px; border: 0; border-radius: 14px; color: #fff; background: var(--primary); box-shadow: 0 8px 16px rgba(9,169,120,.21); font-weight: 800; }
.login-submit:hover { background: var(--primary-deep); }
.login-submit:disabled { opacity: .7; }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 150; display: flex; flex-direction: column; gap: 9px; width: min(370px, calc(100vw - 40px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 13px 15px; border: 1px solid #c6e9da; border-radius: 14px; color: #17543f; background: white; box-shadow: 0 12px 30px rgba(20,63,45,.12); animation: toast-in .25s ease both; font-size: 13px; }
.toast.error { border-color: #f3c7cb; color: #a3444d; }
.toast [data-icon] { width: 18px; height: 18px; color: var(--primary); }
.toast.error [data-icon] { color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 1270px) {
  :root { --sidebar-width: 248px; }
  .topbar, .toolbar, .view { padding-left: 25px; padding-right: 25px; }
  .conversation-layout { grid-template-columns: 320px minmax(380px, 1fr); }
  .lead-profile { display: none; }
  .metric-grid { gap: 16px; }
  .metric-card { padding: 22px; }
}
@media (max-width: 1020px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; box-shadow: 12px 0 35px rgba(27,51,41,.13); }
  .app-shell.nav-open .sidebar { transform: translateX(0); }
  .main { margin-left: 0; }
  .mobile-menu { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 13px; color: var(--muted-deep); background: white; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .global-search { width: min(310px, 34vw); }
}
@media (max-width: 760px) {
  .topbar { min-height: 74px; gap: 12px; padding: 11px 16px; }
  .page-heading h1 { font-size: 20px; }
  .page-heading p { display: none; }
  .topbar-actions { gap: 7px; }
  .global-search { display: none; }
  .user-name { display: none; }
  .user-button { padding-right: 5px; }
  .toolbar { min-height: auto; flex-wrap: wrap; gap: 10px; padding: 13px 16px; }
  .bot-select-wrap { flex: 1; min-width: 205px; }
  .bot-select-wrap select { width: 100%; min-width: 0; }
  .updated-indicator { width: 100%; margin-left: 0; }
  .view { padding: 12px 16px 27px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 11px; }
  .metric-card { min-height: 145px; padding: 16px; border-radius: 18px; }
  .metric-icon { width: 39px; height: 39px; border-radius: 12px; }
  .metric-value { font-size: 28px; }
  .metric-label { margin-top: 8px; font-size: 12px; }
  .chart-panel, .bot-status-panel, .recent-panel, .quick-panel { padding: 20px 16px; border-radius: 19px; }
  .chart-panel { min-height: 325px; }
  .bar-chart { height: 205px; padding: 20px 4px 0; }
  .panel-heading h2, .crm-toolbar h2 { font-size: 17px; }
  .panel-heading p, .crm-toolbar p { font-size: 12px; }
  .conversation-layout { display: block; height: calc(100vh - 190px); min-height: 460px; }
  .conversation-list-panel, .chat-panel { height: 100%; min-height: 0; border-radius: 19px; }
  .conversation-layout.chat-open .conversation-list-panel { display: none; }
  .conversation-layout:not(.chat-open) .chat-panel { display: none; }
  .back-to-list { display: grid; place-items: center; }
  .messages { padding: 17px; }
  .message { max-width: 88%; }
  .crm-toolbar { flex-wrap: wrap; margin: 3px 0 16px; }
  .crm-search { width: 100%; margin-left: 0; }
  .pipeline-navigation { grid-template-columns: 1fr auto; gap: 8px; padding: 9px 10px; }
  .pipeline-navigation-title { grid-column: 1 / -1; }
  .pipeline-stage-tabs { grid-column: 1; }
  .pipeline-navigation-actions { grid-column: 2; }
  .pipeline-scroll-hint { line-height: 1.4; }
  .pipeline-board { min-height: calc(100vh - 415px); margin-right: -16px; padding-right: 16px; }
  .stage-column { min-width: min(310px, 85vw); }
}
@media (max-width: 410px) {
  .period-switcher { width: 100%; }
  .period-switcher button { flex: 1; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 126px; }
  .metric-card { flex-direction: row; align-items: center; gap: 14px; }
  .metric-value { margin: 0; }
  .metric-label { margin: 0 0 0 4px; }
  .login-card { padding: 30px 24px; }
}

/* ==== v5: attachments, lead card, dashboard hints ==== */

.metric-hint { margin-top: 6px; color: #9aa89f; font-size: 11px; font-weight: 650; }
.bar-item.zero .bar { background: #e8efeb; }
.bar-item label { min-height: 14px; }

/* Chat attachments */
.message.media-only { padding: 6px 6px 5px; }
.message-image { display: block; width: 100%; max-width: 320px; padding: 0; border: 0; border-radius: 14px; overflow: hidden; background: #eef3f0; cursor: zoom-in; }
.message-image img { display: block; width: 100%; height: auto; max-height: 340px; object-fit: cover; }
.message-image-fallback { display: none; padding: 22px 14px; color: #8a9a91; font-size: 12px; }
.message-image.broken img { display: none; }
.message-image.broken .message-image-fallback { display: block; }
.message-image + p { margin-top: 8px; }
.message.outgoing .message-image { background: rgba(255,255,255,.2); }
.message-file { display: flex; align-items: center; gap: 11px; min-width: 210px; padding: 9px 11px; border-radius: 13px; background: #f1f6f3; color: inherit; text-decoration: none; }
.message.outgoing .message-file { background: rgba(255,255,255,.16); }
.message-file-icon, .message-file-download { flex: 0 0 auto; width: 20px; height: 20px; }
.message-file-copy { min-width: 0; flex: 1; }
.message-file-copy b { display: block; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.message-file-copy small { display: block; margin-top: 2px; opacity: .7; font-size: 11px; }
.message-file + p { margin-top: 8px; }
.message-muted { opacity: .7; font-style: italic; }

/* Composer */
.composer-attachment { display: flex; align-items: center; gap: 9px; margin: 0 17px; padding: 9px 11px; border: 1px solid #cfeade; border-radius: 12px 12px 0 0; background: #f3fbf7; color: #2c6a53; font-size: 12px; }
.composer-attachment [data-icon] { width: 16px; height: 16px; flex: 0 0 16px; }
.composer-attachment-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.composer-attachment button { width: 26px; height: 26px; display: grid; place-items: center; flex: 0 0 26px; border: 0; border-radius: 8px; color: #43705f; background: transparent; }
.composer-attachment button:hover { background: #dff3e9; }
.attach-button { width: 47px; height: 47px; display: grid; place-items: center; flex: 0 0 47px; border: 1px solid var(--line); border-radius: 15px; color: #6d8378; background: #fbfcfb; }
.attach-button:hover:not(:disabled) { color: var(--primary-deep); border-color: #99d8c2; background: #f2fbf6; }
.attach-button:disabled { opacity: .45; }
.attach-button [data-icon] { width: 20px; height: 20px; }

/* CRM cards */
.lead-card-price { padding: 3px 7px; border-radius: 7px; color: #1d6b50; background: var(--primary-soft); font-style: normal; font-size: 11px; font-weight: 800; }
.stage-more { width: 100%; min-height: 36px; margin-top: 4px; border: 1px dashed #c9dbd2; border-radius: 12px; color: #4b7666; background: transparent; font-size: 12px; font-weight: 750; }
.stage-more:hover { border-style: solid; background: #f4faf7; }

/* Lead card modal */
body.modal-open { overflow: hidden; }
.lead-modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px; }
.lead-modal[hidden] { display: none; }
.lead-modal-backdrop { position: absolute; inset: 0; background: rgba(16,38,29,.5); backdrop-filter: blur(2px); }
.lead-modal-card { position: relative; width: min(560px, 100%); max-height: min(84vh, 720px); display: flex; flex-direction: column; overflow: hidden; border-radius: 22px; background: white; box-shadow: 0 26px 60px rgba(12,40,28,.28); animation: view-in .18s ease both; }
.lead-modal-header { display: flex; align-items: center; gap: 13px; padding: 20px 20px 17px; border-bottom: 1px solid var(--line); }
.lead-modal-avatar { width: 48px; height: 48px; display: grid; place-items: center; flex: 0 0 48px; border-radius: 16px; color: white; background: linear-gradient(135deg, #77bea9, #168768); font-size: 15px; font-weight: 800; }
.lead-modal-title { min-width: 0; flex: 1; }
.lead-modal-title h2 { overflow: hidden; margin: 0; font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }
.lead-modal-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.lead-modal-body { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 20px 14px; }
.lead-modal-loading { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 44px 20px; color: var(--muted); text-align: center; }
.lead-modal-loading [data-icon] { width: 38px; height: 38px; color: #d08a8a; }
.lead-section { padding: 15px 0 4px; }
.lead-section + .lead-section { border-top: 1px solid #eef2ef; }
.lead-section h3 { margin: 0 0 8px; color: #9aa89f; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.lead-rows { margin: 0; }
.lead-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; padding: 9px 0; border-bottom: 1px solid #f2f5f3; }
.lead-row:last-child { border-bottom: 0; }
.lead-row dt { display: flex; align-items: center; gap: 7px; color: #8b9a92; font-size: 12px; font-weight: 700; }
.lead-row dt [data-icon] { width: 15px; height: 15px; }
.lead-row dd { margin: 0; color: #2c4038; font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
.lead-contact { display: flex; align-items: center; gap: 11px; padding: 9px 0; }
.lead-contact-copy { min-width: 0; }
.lead-contact-copy b { display: block; font-size: 13px; }
.lead-contact-copy a { display: block; margin-top: 3px; color: var(--primary-deep); font-size: 13px; font-weight: 700; text-decoration: none; }
.lead-contact-copy a:hover { text-decoration: underline; }
.lead-contact-copy small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.lead-empty { margin: 4px 0 10px; color: var(--muted); font-size: 13px; }
.lead-modal-footer { display: flex; gap: 10px; padding: 14px 20px 18px; border-top: 1px solid var(--line); }
.lead-modal-amo, .lead-modal-chat { flex: 1; min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 8px; border-radius: 13px; font-size: 13px; font-weight: 800; text-decoration: none; }
.lead-modal-amo { border: 1px solid #bae6d4; color: var(--primary-deep); background: #f2fbf6; }
.lead-modal-amo:hover { background: #e6f7ee; }
.lead-modal-chat { border: 0; color: white; background: var(--primary); }
.lead-modal-chat:hover { background: var(--primary-deep); }
.lead-modal-amo [data-icon], .lead-modal-chat [data-icon] { width: 17px; height: 17px; }

/* Full-size image viewer */
.image-viewer { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 30px; background: rgba(10,26,20,.86); }
.image-viewer[hidden] { display: none; }
.image-viewer img { max-width: 100%; max-height: 100%; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.image-viewer-close { position: absolute; top: 18px; right: 18px; width: 42px; height: 42px; display: grid; place-items: center; border: 0; border-radius: 14px; color: white; background: rgba(255,255,255,.16); }
.image-viewer-close:hover { background: rgba(255,255,255,.28); }
.image-viewer-close [data-icon] { width: 20px; height: 20px; }

@media (max-width: 760px) {
  .lead-modal { padding: 0; }
  .lead-modal-card { width: 100%; max-height: 100vh; height: 100%; border-radius: 0; }
  .lead-row { grid-template-columns: 1fr; gap: 3px; }
  .lead-modal-footer { flex-direction: column; }
  .attach-button { width: 42px; height: 42px; flex: 0 0 42px; }
}

body.chat-view { overflow: hidden; }
.message-author { display: block; margin-bottom: 4px; font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; opacity: .75; }
.message.outgoing.by-operator { background: #0b8a67; }

/* Keep the conversation composer inside the viewport.
   Previously the conversation grid had a fixed minimum height (520px). On a
   720px-high desktop, the top bar, toolbar and page padding already consume
   more than the remaining space; because chat-view hides the document
   overflow, the bottom composer was cut off. In chat mode the whole main area
   is now a three-row flex layout and the conversation grid simply uses the
   exact remaining height. Only the message list scrolls. */
body.chat-view { height: 100vh; height: 100dvh; }
body.chat-view .app-shell { min-height: 0; height: 100%; }
body.chat-view .main { height: 100%; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
body.chat-view .topbar, body.chat-view .toolbar { flex: 0 0 auto; }
body.chat-view .view.active { min-height: 0; flex: 1 1 auto; display: flex; flex-direction: column; overflow: hidden; }
body.chat-view .conversation-layout { width: 100%; height: auto; min-height: 0; flex: 1 1 auto; }

/* ==== v6: delete, confirm dialog, stage hint ==== */
.icon-button.danger { color: #b9525c; }
.icon-button.danger:hover { color: #a53b46; border-color: #f2cdd1; background: #fff3f4; }
.chat-header .icon-button { margin-left: 0; }
.chat-header #open-lead-profile { margin-left: auto; }

.stage-hint { margin: 6px 2px 0; color: #93a49b; font-size: 11px; line-height: 1.4; }

.confirm-modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; }
.confirm-modal[hidden] { display: none; }
.confirm-card { position: relative; width: min(420px, 100%); padding: 26px 24px 20px; border-radius: 22px; background: white; text-align: center; box-shadow: 0 26px 60px rgba(12,40,28,.28); animation: view-in .18s ease both; }
.confirm-icon { width: 46px; height: 46px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 16px; color: #c0505b; background: #fdeef0; }
.confirm-icon [data-icon], .confirm-icon svg { width: 24px; height: 24px; }
.confirm-card h2 { margin: 0 0 8px; font-size: 19px; }
.confirm-card p { margin: 0 0 20px; color: var(--muted-deep); font-size: 13px; line-height: 1.5; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions button { flex: 1; min-height: 44px; border-radius: 13px; font-size: 14px; font-weight: 800; }
.confirm-cancel { border: 1px solid var(--line); color: var(--muted-deep); background: white; }
.confirm-cancel:hover { background: #f6f9f7; }
.confirm-ok { border: 0; color: white; background: #c0505b; }
.confirm-ok:hover { background: #a8434d; }

/* ==== v7: client-attachment filter ==== */
.conversation-row-marks { display: flex; align-items: center; gap: 5px; }
.file-badge { display: inline-flex; align-items: center; gap: 3px; height: 19px; padding: 0 6px; border-radius: 8px; color: #4b7666; background: #eaf3ee; font-size: 10px; font-style: normal; font-weight: 800; }
.file-badge [data-icon] { width: 11px; height: 11px; }
.conversation-row.active .file-badge { background: #d7ede2; }

/* ==== v8: voice notes ==== */
.voice-recording { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 47px; padding: 0 15px; border: 1px solid #f0cdd1; border-radius: 15px; background: #fff6f7; }
.voice-dot { width: 10px; height: 10px; flex: 0 0 10px; border-radius: 50%; background: #d0505f; animation: voice-pulse 1.1s ease-in-out infinite; }
@keyframes voice-pulse { 50% { opacity: .25; } }
.voice-timer { color: #a83c48; font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.voice-hint { flex: 1; min-width: 0; overflow: hidden; color: #a4737a; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.voice-cancel { flex: 0 0 auto; min-height: 30px; padding: 0 11px; border: 1px solid #e9c3c8; border-radius: 10px; color: #a83c48; background: white; font-size: 12px; font-weight: 750; }
.voice-cancel:hover { background: #fdeef0; }
.attach-button.recording { color: white; border-color: transparent; background: #d0505f; }
.attach-button.recording:hover:not(:disabled) { color: white; border-color: transparent; background: #bb4552; }

.video-note-recording { position: relative; width: 132px; height: 132px; flex: 0 0 132px; overflow: hidden; margin: 6px auto; border: 4px solid #12ad7f; border-radius: 50%; background: #12241d; box-shadow: 0 8px 24px rgba(12,40,28,.2); }
.video-note-recording video { width: 100%; height: 100%; display: block; object-fit: cover; transform: scaleX(-1); }
.video-note-timer { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); padding: 3px 8px; border-radius: 10px; color: white; background: rgba(0,0,0,.58); font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.video-note-cancel { position: absolute; top: 7px; right: 7px; width: 27px; height: 27px; overflow: hidden; padding: 0; border: 0; border-radius: 50%; color: transparent; background: rgba(192,80,91,.9); }
.video-note-cancel::before, .video-note-cancel::after { content: ""; position: absolute; top: 7px; left: 13px; width: 2px; height: 13px; background: white; transform: rotate(45deg); }
.video-note-cancel::after { transform: rotate(-45deg); }

.message.voice-message { width: min(292px, 100%); }
.message-voice { display: block; width: 100%; }
.message-voice audio { display: block; width: 100%; height: 38px; }
.message-voice + p { margin-top: 8px; }

.message.video-note-message { width: min(292px, 100%); background: transparent; box-shadow: none; }
.message-video-note { display: block; width: min(240px, 66vw); aspect-ratio: 1; overflow: hidden; border-radius: 50%; background: #12241d; box-shadow: 0 8px 24px rgba(12,40,28,.18); }
.message-video-note video { display: block; width: 100%; height: 100%; object-fit: cover; }
.message.video-note-message footer { width: fit-content; padding: 3px 7px; margin: 5px auto 0; border-radius: 9px; color: white; background: rgba(12,40,28,.65); }

@media (max-width: 760px) {
  .voice-hint { display: none; }
  .message.voice-message { width: min(240px, 100%); }
}

/* ==== v9: queued mass messages ==== */
.broadcast-open { min-height: 43px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 14px; border: 1px solid #b8e5d3; border-radius: 14px; color: #087d5a; background: #f1fbf6; font-size: 13px; font-weight: 800; white-space: nowrap; }
.broadcast-open:hover { border-color: #86d3b6; color: #fff; background: var(--primary); }
.broadcast-open [data-icon] { width: 17px; height: 17px; }
.broadcast-modal { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; padding: 20px; }
.broadcast-modal[hidden] { display: none; }
.broadcast-card { position: relative; width: min(640px, 100%); max-height: min(90vh, 790px); max-height: min(90dvh, 790px); display: flex; flex-direction: column; overflow: hidden; border: 1px solid rgba(255,255,255,.7); border-radius: 23px; background: #fff; box-shadow: 0 28px 70px rgba(12,40,28,.31); animation: view-in .18s ease both; }
.broadcast-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 21px 22px 17px; border-bottom: 1px solid var(--line); }
.broadcast-header .eyebrow { margin-bottom: 5px; }
.broadcast-header h2 { margin: 0; font-size: 21px; letter-spacing: -.45px; }
.broadcast-header .icon-button { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 13px; }
.broadcast-body { min-height: 0; overflow-y: auto; padding: 18px 22px 20px; }
.broadcast-bot { display: flex; align-items: center; gap: 11px; padding: 13px; border: 1px solid #d8eee4; border-radius: 16px; background: #f3fbf7; }
.broadcast-bot .bot-avatar { width: 38px; height: 38px; flex-basis: 38px; border-radius: 12px; }
.broadcast-bot div { min-width: 0; }
.broadcast-bot b, .broadcast-bot small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.broadcast-bot b { color: #215440; font-size: 14px; }
.broadcast-bot small { margin-top: 3px; color: #698679; font-size: 11px; }
.broadcast-field { display: block; margin-top: 17px; color: #516a5e; font-size: 12px; font-weight: 800; }
.broadcast-field select, .broadcast-field textarea, .broadcast-confirmation input { width: 100%; margin-top: 7px; border: 1px solid var(--line); border-radius: 13px; outline: 0; color: var(--text); background: #fbfcfb; }
.broadcast-field select { height: 47px; padding: 0 12px; font-weight: 700; }
.broadcast-field textarea { display: block; min-height: 106px; max-height: 220px; padding: 12px 13px; resize: vertical; line-height: 1.45; }
.broadcast-field select:focus, .broadcast-field textarea:focus, .broadcast-confirmation input:focus { border-color: #91d6be; background: #fff; }
.broadcast-field small { display: block; margin-top: 5px; color: #93a49b; font-size: 11px; font-weight: 700; text-align: right; }
.broadcast-step-picker { display: none; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 9px; }
.broadcast-step-picker.visible { display: grid; }
.broadcast-step-picker label { display: flex; align-items: center; gap: 7px; min-height: 42px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 11px; color: #385548; background: #fbfcfb; cursor: pointer; font-size: 11px; font-weight: 750; }
.broadcast-step-picker input { accent-color: var(--primary); }
.broadcast-step-picker label i { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: var(--stage-color); }
@media (max-width: 620px) { .broadcast-step-picker { grid-template-columns: 1fr; } }
.settings-shell { max-width: 900px; margin: 0 auto; padding: 24px; }
.settings-warning, .settings-status { display: flex; gap: 10px; margin: 18px 0; padding: 13px; border-radius: 13px; color: #785b16; background: #fff7df; }
.settings-warning [data-icon] { width: 20px; flex: 0 0 20px; }
.settings-stage-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-top: 14px; }
.settings-field { display: grid; gap: 7px; color: #516a5e; font-size: 12px; font-weight: 800; }
.settings-field select { width: 100%; height: 47px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfb; }
.settings-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.settings-actions button { min-height: 44px; padding: 0 18px; border: 1px solid var(--line); border-radius: 12px; font-weight: 800; }
.settings-actions button[type="submit"] { color: white; border-color: var(--primary); background: var(--primary); }
.settings-status { color: #087b59; background: var(--primary-soft); }
.settings-status.error { color: #a33; background: #fff0f0; }
.settings-history { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 18px; }
.settings-history h3 { margin: 0 0 12px; }
.settings-history #settings-history-list > div { display: flex; justify-content: space-between; gap: 15px; padding: 10px 0; border-bottom: 1px solid #edf2ef; font-size: 12px; }
@media (max-width: 700px) { .settings-stage-grid { grid-template-columns: 1fr; } }
.broadcast-recipient-preview { min-height: 48px; display: flex; align-items: center; gap: 9px; margin-top: 11px; padding: 10px 12px; border-radius: 13px; color: #237457; background: #edf9f3; font-size: 13px; font-weight: 750; }
.broadcast-recipient-preview .boot-spinner { width: 16px; height: 16px; }
.broadcast-recipient-preview strong { color: #087e5a; font-size: 16px; }
.broadcast-attachment-row { min-height: 43px; display: flex; align-items: center; gap: 9px; margin-top: 13px; }
.broadcast-attachment-button { min-height: 42px; display: inline-flex; align-items: center; gap: 7px; padding: 0 12px; border: 1px dashed #addbc9; border-radius: 12px; color: #237457; background: #f7fcf9; font-size: 12px; font-weight: 800; }
.broadcast-attachment-button:hover { border-style: solid; background: #edf9f3; }
.broadcast-attachment-button [data-icon] { width: 17px; height: 17px; }
#broadcast-attachment-name { min-width: 0; overflow: hidden; color: #516d61; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 750; }
.broadcast-attachment-clear { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 30px; border: 0; border-radius: 9px; color: #a34a52; background: #fff1f2; }
.broadcast-attachment-clear [data-icon] { width: 16px; height: 16px; }
.broadcast-note { display: flex; align-items: flex-start; gap: 8px; margin: 17px 0 0; padding: 11px 12px; border: 1px solid #f1dfba; border-radius: 13px; color: #806521; background: #fff9e9; font-size: 12px; line-height: 1.45; }
.broadcast-note [data-icon] { width: 17px; height: 17px; flex: 0 0 17px; color: #d68f12; }
.broadcast-confirmation { margin-top: 17px; padding: 13px; border: 1px solid #e4ebe7; border-radius: 15px; background: #fbfcfb; }
.broadcast-confirmation p { margin: 0; color: #596d63; font-size: 12px; font-weight: 750; }
.broadcast-confirmation code { display: inline-block; margin-top: 8px; padding: 5px 7px; border-radius: 7px; color: #087e5a; background: #e3f7ee; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; font-weight: 800; }
.broadcast-confirmation input { height: 45px; padding: 0 12px; font-size: 13px; }
.broadcast-status { margin-top: 16px; padding: 12px; border: 1px solid #c7e9d9; border-radius: 13px; color: #28654e; background: #f1fbf6; font-size: 13px; line-height: 1.45; }
.broadcast-status.error { border-color: #f2cbcf; color: #9f4750; background: #fff5f6; }
.broadcast-status b { color: inherit; }
.broadcast-footer { display: flex; align-items: center; gap: 10px; padding: 14px 22px 19px; border-top: 1px solid var(--line); }
.broadcast-footer button { min-height: 44px; padding: 0 14px; border-radius: 13px; font-size: 13px; font-weight: 800; }
.broadcast-footer .confirm-cancel { flex: 0 0 auto; }
.broadcast-cancel { margin-left: auto; border: 1px solid #f0c8cd; color: #aa4751; background: #fff4f5; }
.broadcast-cancel:hover { background: #fee9eb; }
.broadcast-submit { display: inline-flex; align-items: center; justify-content: center; gap: 8px; margin-left: auto; border: 0; color: white; background: var(--primary); }
.broadcast-submit:hover:not(:disabled) { background: var(--primary-deep); }
.broadcast-submit:disabled { opacity: .5; box-shadow: none; }
.broadcast-submit [data-icon] { width: 17px; height: 17px; }

@media (max-width: 760px) {
  .broadcast-open { margin-left: auto; }
  .broadcast-modal { padding: 0; }
  .broadcast-card { width: 100%; height: 100%; max-height: none; border-radius: 0; }
  .broadcast-header, .broadcast-body, .broadcast-footer { padding-left: 16px; padding-right: 16px; }
  .broadcast-footer { flex-wrap: wrap; }
  .broadcast-footer .confirm-cancel { flex: 1 1 auto; }
  .broadcast-submit { flex: 1 1 auto; }
}
