:root {
  --navy: #0d1b3d;
  --navy-2: #15295c;
  --gold: #d8ad43;
  --cream: #fffaf0;
  --muted: #6b7280;
  --line: #e5e7eb;
}
* { box-sizing: border-box; }
body { background: #f7f4ed; color: #1f2937; font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif; }
a { text-decoration: none; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 270px; background: linear-gradient(180deg, var(--navy), #071126); color: #fff; padding: 18px; position: fixed; top: 0; bottom: 0; overflow-y: auto; }
.brand { display: flex; gap: 12px; align-items: center; padding: 10px 8px 22px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 14px; }
.brand-mark { width: 42px; height: 42px; border-radius: 12px; background: var(--gold); color: var(--navy); display: grid; place-items: center; font-size: 24px; font-weight: 800; }
.brand-title { font-size: 18px; font-weight: 800; letter-spacing: .3px; }
.brand small { color: #d9e0ff; }
.sidebar .nav-link { color: #dbe4ff; padding: 11px 12px; border-radius: 12px; margin: 3px 0; display: flex; gap: 10px; align-items: center; }
.sidebar .nav-link:hover, .sidebar .nav-link.active { background: rgba(216,173,67,.16); color: #fff; }
.sidebar-footer { position: sticky; top: 100%; margin-top: 24px; padding: 14px; border-radius: 14px; background: rgba(255,255,255,.08); color: #eef2ff; }
.main { margin-left: 270px; flex: 1; }
.topbar { background: rgba(255,255,255,.78); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: 20px 28px; display: flex; justify-content: space-between; gap: 15px; align-items: center; position: sticky; top: 0; z-index: 10; }
.topbar h1 { font-size: 24px; margin: 0; font-weight: 800; color: var(--navy); }
.pill { padding: 8px 12px; border-radius: 999px; background: var(--cream); border: 1px solid #f0dfb6; color: #6d4e05; }
.stat-card { background: #fff; padding: 20px; border-radius: 20px; box-shadow: 0 8px 25px rgba(13,27,61,.06); border: 1px solid rgba(13,27,61,.06); min-height: 132px; }
.stat-title { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.stat-value { font-size: 34px; font-weight: 900; color: var(--navy); margin-top: 8px; }
.stat-subtitle { color: var(--muted); font-size: 13px; }
.panel { background: #fff; border: 1px solid rgba(13,27,61,.08); border-radius: 20px; padding: 20px; box-shadow: 0 8px 24px rgba(13,27,61,.05); }
.panel-title { color: var(--navy); font-weight: 800; margin-bottom: 14px; }
.table thead th { font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.btn-primary { background: var(--navy-2); border-color: var(--navy-2); }
.btn-primary:hover { background: var(--navy); border-color: var(--navy); }
.btn-gold { background: var(--gold); color: var(--navy); font-weight: 800; border: none; }
.chat-box { height: 520px; overflow-y: auto; background: #f8fafc; border-radius: 18px; padding: 18px; border: 1px solid #e2e8f0; }
.msg { max-width: 78%; padding: 12px 14px; margin-bottom: 12px; border-radius: 16px; white-space: pre-wrap; }
.msg.incoming { background: #fff; border: 1px solid #e2e8f0; }
.msg.outgoing { background: #e8f1ff; margin-left: auto; border: 1px solid #cfe1ff; }
.msg.internal { background: #fff7df; margin: 0 auto 12px; border: 1px solid #f3d98a; }
.disclaimer { background: #fff7ed; border: 1px solid #fed7aa; color: #7c2d12; padding: 14px; border-radius: 14px; }
.codebox { background: #071126; color: #dbeafe; border-radius: 14px; padding: 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow-x: auto; }
@media (max-width: 991px) {
  .sidebar { width: 100%; position: static; }
  .main { margin-left: 0; }
  .app-shell { display: block; }
  .topbar { display: block; }
}

.public-page { min-height: 100vh; background: linear-gradient(135deg,#0d1b3d 0%,#233b83 45%,#f7f4ed 45%); }
.public-policy-panel { line-height: 1.75; }
.public-policy-panel h1 { color: var(--navy); font-weight: 900; }
.public-policy-panel h2 { color: var(--navy); font-size: 1.25rem; margin-top: 1.5rem; font-weight: 800; }
.public-policy-panel p, .public-policy-panel li { color: #374151; }

/* v1.2 inbox and flow builder improvements */
.inbox-panel { padding: 18px; }
.conversation-list { display: grid; gap: 10px; }
.conversation-card { display: flex; gap: 14px; padding: 14px; border: 1px solid #e5e7eb; border-radius: 18px; color: inherit; background: #fff; transition: .15s ease; }
.conversation-card:hover { transform: translateY(-1px); border-color: #d8ad43; box-shadow: 0 8px 24px rgba(13,27,61,.08); }
.avatar-circle { width: 44px; height: 44px; min-width: 44px; border-radius: 50%; background: linear-gradient(135deg, var(--navy-2), var(--gold)); color: #fff; display: grid; place-items: center; font-weight: 900; text-transform: uppercase; }
.avatar-circle.big { width: 58px; height: 58px; min-width: 58px; font-size: 22px; }
.conversation-main { flex: 1; min-width: 0; }
.conversation-preview { margin-top: 4px; color: #4b5563; }
.incoming-preview { font-weight: 600; color: #111827; }
.empty-state { border: 1px dashed #cbd5e1; border-radius: 18px; padding: 32px; text-align: center; color: #64748b; background: #f8fafc; }
.chat-panel { padding: 0; overflow: hidden; }
.chat-header { padding: 18px 20px; border-bottom: 1px solid #e5e7eb; display: flex; justify-content: space-between; align-items: center; gap: 15px; background: linear-gradient(180deg,#fff,#fffaf0); }
.improved-chat { height: 560px; border-radius: 0; border: 0; background: linear-gradient(180deg,#f8fafc,#eef2ff); }
.msg-row { display: flex; margin-bottom: 12px; }
.msg-row.outgoing { justify-content: flex-end; }
.msg-row.internal { justify-content: center; }
.msg-row.incoming { justify-content: flex-start; }
.msg-time { display: block; margin-top: 8px; color: #64748b; font-size: 11px; }
.reply-box { padding: 0 20px 20px; }
.flow-list-item { display: block; border: 1px solid #e5e7eb; border-radius: 14px; padding: 12px; margin-bottom: 10px; color: inherit; background: #fff; }
.flow-list-item:hover, .flow-list-item.active { border-color: var(--gold); background: #fffaf0; }
.flow-step-card { border: 1px solid #e5e7eb; border-radius: 16px; padding: 14px; background: #f8fafc; }
.flow-help-card { border: 1px dashed #d8ad43; border-radius: 16px; background: #fffaf0; padding: 15px; min-height: 105px; }
.bg-info-subtle { background: #e0f2fe !important; }
@media (max-width: 767px) {
  .conversation-card { align-items: flex-start; }
  .chat-header { align-items: flex-start; display: block; }
  .chat-header .text-end { text-align: left !important; margin-top: 10px; }
  .msg { max-width: 92%; }
}

/* v1.3 WhatsApp-like inbox and AI chat */
.wa-page { height: calc(100vh - 128px); min-height: 690px; display: grid; grid-template-columns: 390px 1fr; background: #efeae2; border: 1px solid #d8dfe3; border-radius: 20px; overflow: hidden; box-shadow: 0 12px 30px rgba(13,27,61,.08); }
.wa-sidebar-panel { background: #fff; border-right: 1px solid #d9dee3; min-width: 0; display: flex; flex-direction: column; }
.wa-sidebar-top { height: 72px; background: #f0f2f5; display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid #e5e7eb; }
.wa-title { font-weight: 900; font-size: 22px; color: #111827; }
.wa-subtitle { color: #667781; font-size: 12px; }
.wa-icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: #54656f; background: #fff; border: 1px solid #d9dee3; font-size: 22px; font-weight: 700; }
.wa-icon-btn:hover { color: #075e54; background: #e9edef; }
.wa-search-wrap { padding: 10px 12px; border-bottom: 1px solid #eef0f1; background: #fff; }
.wa-search { display: flex; align-items: center; gap: 8px; background: #f0f2f5; color: #667781; border-radius: 9px; padding: 8px 12px; }
.wa-search input { border: 0; outline: 0; background: transparent; width: 100%; font-size: 14px; }
.wa-filter-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 7px; margin-top: 8px; }
.wa-chat-list { overflow-y: auto; flex: 1; background: #fff; }
.wa-chat-item { display: flex; gap: 12px; color: inherit; padding: 12px 14px; border-bottom: 1px solid #eef0f1; transition: background .12s ease; }
.wa-chat-item:hover, .wa-chat-item.active { background: #f0f2f5; }
.wa-avatar { width: 48px; height: 48px; min-width: 48px; border-radius: 50%; background: linear-gradient(135deg,#dfe5e7,#9baeb6); display: grid; place-items: center; position: relative; overflow: hidden; }
.wa-avatar span { background: linear-gradient(135deg,#6b7cff,#00a884); width: 100%; height: 100%; display: grid; place-items: center; color: #fff; font-weight: 900; text-transform: uppercase; }
.wa-avatar.large { width: 46px; height: 46px; min-width: 46px; }
.wa-chat-meta { min-width: 0; flex: 1; }
.wa-chat-line1 { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.wa-chat-line1 strong { font-size: 15px; color: #111b21; font-weight: 700; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.wa-chat-line1 time { color: #667781; font-size: 11px; min-width: max-content; }
.wa-chat-line2 { display: flex; justify-content: space-between; gap: 8px; color: #667781; font-size: 13px; line-height: 1.35; }
.wa-last { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
.wa-last.unreadish { color: #111b21; font-weight: 700; }
.wa-unread { color: #00a884; font-size: 11px; }
.wa-mini-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.wa-mini-tags span { border-radius: 999px; background: #eef2f7; color: #54656f; font-size: 10px; padding: 2px 7px; }
.wa-mini-tags span.danger { background: #fee2e2; color: #991b1b; }
.wa-chat-panel { min-width: 0; background: #efeae2; display: flex; flex-direction: column; position: relative; }
.wa-chat-panel::before { content: ""; position: absolute; inset: 0; opacity: .18; pointer-events: none; background-image: radial-gradient(circle at 18px 18px, rgba(17,27,33,.08) 2px, transparent 2px), radial-gradient(circle at 58px 40px, rgba(17,27,33,.06) 1.5px, transparent 1.5px); background-size: 86px 86px; }
.wa-chat-panel > * { position: relative; z-index: 1; }
.wa-chat-panel.single-chat { min-height: calc(100vh - 175px); border: 1px solid #d8dfe3; border-radius: 20px; overflow: hidden; box-shadow: 0 12px 30px rgba(13,27,61,.08); }
.wa-chat-header { min-height: 72px; background: #f0f2f5; border-bottom: 1px solid #d9dee3; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 18px; }
.wa-contact-name { color: #111b21; font-weight: 800; line-height: 1.2; }
.wa-contact-status { color: #667781; font-size: 12px; }
.wa-message-area { flex: 1; overflow-y: auto; padding: 18px 8.5% 20px; }
.wa-message-area.full-height { min-height: 520px; max-height: calc(100vh - 355px); }
.wa-date-pill { width: max-content; margin: 0 auto 14px; background: rgba(255,255,255,.82); color: #54656f; border-radius: 8px; padding: 6px 12px; font-size: 12px; box-shadow: 0 1px 1px rgba(0,0,0,.05); }
.wa-bubble-row { display: flex; margin: 3px 0; }
.wa-bubble-row.incoming { justify-content: flex-start; }
.wa-bubble-row.outgoing { justify-content: flex-end; }
.wa-bubble-row.internal { justify-content: center; }
.wa-bubble { max-width: min(72%, 680px); padding: 8px 10px 17px; border-radius: 7.5px; color: #111b21; white-space: pre-wrap; font-size: 14px; line-height: 1.45; position: relative; box-shadow: 0 1px .5px rgba(11,20,26,.13); }
.wa-bubble.incoming { background: #fff; border-top-left-radius: 0; }
.wa-bubble.outgoing { background: #d9fdd3; border-top-right-radius: 0; }
.wa-bubble.internal { background: #fff4cf; color: #7c2d12; text-align: center; max-width: 80%; }
.wa-bubble-time { position: absolute; right: 8px; bottom: 3px; color: #667781; font-size: 10px; }
.wa-ai-bar { background: #f7f9fa; border-top: 1px solid #d9dee3; padding: 8px 14px; }
.wa-composer { background: #f0f2f5; display: flex; align-items: flex-end; gap: 8px; padding: 10px 14px; border-top: 1px solid #d9dee3; }
.wa-composer textarea { min-height: 42px; max-height: 160px; resize: none; border: 0; border-radius: 10px; padding: 10px 14px; outline: none; flex: 1; background: #fff; }
.wa-emoji, .wa-send { width: 42px; height: 42px; border: 0; border-radius: 50%; display: grid; place-items: center; }
.wa-emoji { color: #54656f; background: transparent; font-size: 21px; }
.wa-send { background: #00a884; color: #fff; font-weight: 900; }
.wa-send:hover { background: #008f72; }
.wa-empty-chat { height: 100%; display: grid; place-items: center; align-content: center; text-align: center; color: #54656f; padding: 40px; }
.wa-empty-icon { font-size: 58px; margin-bottom: 12px; }
.wa-draft-note { background: #fff7df; color: #7c2d12; font-size: 12px; padding: 8px 14px; border-top: 1px solid #f3d98a; }
@media (max-width: 1199px) { .wa-page { grid-template-columns: 340px 1fr; } .wa-message-area { padding-left: 5%; padding-right: 5%; } }
@media (max-width: 900px) { .wa-page { height: auto; min-height: 0; display: block; } .wa-sidebar-panel { height: 420px; border-right: 0; border-bottom: 1px solid #d9dee3; } .wa-chat-panel { min-height: 620px; } .wa-bubble { max-width: 88%; } .wa-filter-row { grid-template-columns: 1fr; } }
.preview-box { white-space: pre-wrap; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 14px; padding: 14px; min-height: 220px; font-family: inherit; font-size: .94rem; }
.wa-message-area { scroll-behavior: smooth; }
.wa-bubble.internal { background: #fff6d7; color: #5c4300; border: 1px dashed #e3c45f; }
.wa-bubble-row.internal { justify-content: center; }
.flow-step-card select, .flow-step-card input, .flow-step-card textarea { font-size: .92rem; }

.nav-section{font-size:.72rem;text-transform:uppercase;letter-spacing:.08em;color:#9fb1d8;margin:14px 14px 6px;font-weight:700}.codebox{background:#f5f7fb;border:1px solid #e1e7f5;border-radius:10px;padding:10px;font-family:ui-monospace,Consolas,monospace;word-break:break-all}.pill{display:inline-block;background:#eef3ff;border:1px solid #d8e2ff;border-radius:999px;padding:6px 10px;font-size:.82rem}

.wa-shell{display:grid;grid-template-columns:360px 1fr;height:calc(100vh - 155px);min-height:560px;background:#fff;border:1px solid #e5e7eb;border-radius:18px;overflow:hidden}.wa-list{border-right:1px solid #e5e7eb;overflow:auto;background:#f8fafc}.wa-chat{display:flex;gap:12px;padding:12px 14px;text-decoration:none;color:#111;border-bottom:1px solid #edf2f7}.wa-chat:hover,.wa-chat.active{background:#eaf7ef}.wa-avatar{width:42px;height:42px;border-radius:50%;background:#16a34a;color:#fff;display:flex;align-items:center;justify-content:center;font-weight:700}.wa-chat-main{flex:1;min-width:0}.wa-panel{display:flex;flex-direction:column;min-width:0}.wa-header{height:70px;padding:12px 16px;border-bottom:1px solid #e5e7eb;background:#f8fafc;display:flex;justify-content:space-between;gap:12px;align-items:center}.wa-messages{flex:1;overflow:auto;padding:18px;background:#efeae2}.wa-bubble{max-width:72%;padding:10px 12px;border-radius:12px;margin-bottom:10px;box-shadow:0 1px 1px #0001}.wa-bubble.in{background:#fff}.wa-bubble.out{background:#d9fdd3;margin-left:auto}.wa-bubble small{display:block;text-align:right;color:#667085;font-size:.72rem;margin-top:4px}.wa-composer{display:flex;gap:10px;padding:12px;background:#f8fafc;border-top:1px solid #e5e7eb}@media(max-width:900px){.wa-shell{grid-template-columns:1fr;height:auto}.wa-list{max-height:320px}.wa-messages{min-height:420px}.wa-bubble{max-width:88%}}

/* v1.5.4 stable inbox overrides: isolated classes to avoid older WA CSS conflicts */
.mini-stat{background:#fff;border:1px solid #e5e7eb;border-radius:14px;padding:12px 14px;box-shadow:0 6px 16px rgba(15,23,42,.04)}
.mini-stat strong{display:block;font-size:24px;color:#0f172a;line-height:1}.mini-stat span{font-size:12px;color:#64748b}
.inbox154-shell{display:grid;grid-template-columns:380px minmax(0,1fr);height:calc(100vh - 245px);min-height:620px;background:#fff;border:1px solid #d9dee3;border-radius:18px;overflow:hidden;box-shadow:0 10px 28px rgba(15,23,42,.06)}
.inbox154-list{min-width:0;background:#fff;border-right:1px solid #d9dee3;display:flex;flex-direction:column}.inbox154-list-head{padding:14px;background:#f0f2f5;border-bottom:1px solid #e5e7eb}.inbox154-chat-scroll{overflow-y:auto;flex:1;background:#fff}
.inbox154-chat{display:flex;gap:12px;padding:12px 14px;border-bottom:1px solid #eef0f1;color:#111b21;text-decoration:none}.inbox154-chat:hover,.inbox154-chat.active{background:#e9edef;color:#111b21}.inbox154-avatar{width:46px;height:46px;min-width:46px;border-radius:50%;display:grid;place-items:center;background:linear-gradient(135deg,#00a884,#128c7e);color:#fff;font-weight:800}.inbox154-avatar.big{width:48px;height:48px;min-width:48px}.inbox154-chat-main{min-width:0;flex:1}.inbox154-line1{display:flex;align-items:center;justify-content:space-between;gap:10px}.inbox154-line1 strong{font-size:15px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.inbox154-line1 time{font-size:11px;color:#667781;min-width:max-content}.inbox154-line2{font-size:13px;color:#667781;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-top:2px}.inbox154-panel{min-width:0;display:flex;flex-direction:column;background:#efeae2;position:relative}.inbox154-panel:before{content:"";position:absolute;inset:0;opacity:.16;background-image:radial-gradient(circle at 18px 18px,rgba(17,27,33,.08) 2px,transparent 2px),radial-gradient(circle at 58px 40px,rgba(17,27,33,.06) 1.5px,transparent 1.5px);background-size:86px 86px;pointer-events:none}.inbox154-panel>*{position:relative;z-index:1}.inbox154-header{min-height:74px;background:#f0f2f5;border-bottom:1px solid #d9dee3;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 16px}.inbox154-messages{flex:1;overflow-y:auto;padding:18px 7% 20px}.inbox154-date{width:max-content;margin:0 auto 14px;background:rgba(255,255,255,.85);color:#54656f;border-radius:8px;padding:5px 12px;font-size:12px;box-shadow:0 1px 1px rgba(0,0,0,.05)}.inbox154-row{display:flex;margin:5px 0}.inbox154-row.incoming{justify-content:flex-start}.inbox154-row.outgoing{justify-content:flex-end}.inbox154-row.internal{justify-content:center}.inbox154-bubble{max-width:min(75%,720px);border-radius:8px;padding:8px 10px 18px;box-shadow:0 1px .5px rgba(11,20,26,.18);font-size:14px;line-height:1.45;position:relative;white-space:pre-wrap;word-break:break-word}.inbox154-bubble.incoming{background:#fff;border-top-left-radius:0}.inbox154-bubble.outgoing{background:#d9fdd3;border-top-right-radius:0}.inbox154-bubble.internal{background:#fff6d7;color:#5c4300;border:1px dashed #e3c45f;text-align:center}.inbox154-bubble time{position:absolute;right:8px;bottom:3px;font-size:10px;color:#667781}.inbox154-composer{display:flex;gap:10px;align-items:flex-end;background:#f0f2f5;border-top:1px solid #d9dee3;padding:10px 14px}.inbox154-composer textarea{flex:1;border:0;outline:0;resize:none;border-radius:11px;padding:10px 14px;background:#fff;min-height:44px;max-height:150px}.inbox154-empty{height:100%;display:grid;place-items:center;align-content:center;text-align:center;color:#667781;padding:40px}.inbox154-empty div{font-size:58px}.min-w-0{min-width:0}
@media(max-width:1000px){.inbox154-shell{grid-template-columns:1fr;height:auto}.inbox154-list{height:420px;border-right:0;border-bottom:1px solid #d9dee3}.inbox154-panel{min-height:620px}.inbox154-header{align-items:flex-start;flex-direction:column}.inbox154-messages{min-height:460px;padding-left:14px;padding-right:14px}.inbox154-bubble{max-width:88%}}

/* v1.7.7 WhatsApp Inbox Scroll Stability
   Fixes flexbox min-height overflow, mobile scroll lock, and composer overlay. */
.inbox154-shell{
  height: min(760px, calc(100dvh - 220px));
  min-height: 620px;
  max-height: calc(100dvh - 180px);
  overflow: hidden !important;
}
.inbox154-list,
.inbox154-panel,
.inbox154-chat-scroll,
.inbox154-messages{
  min-height: 0 !important;
}
.inbox154-panel{
  height: 100%;
  overflow: hidden !important;
}
.inbox154-chat-scroll{
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}
.inbox154-messages,
.inbox177-messages{
  flex: 1 1 auto !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: 34px !important;
}
.inbox154-header,
.inbox154-composer{
  flex: 0 0 auto !important;
}
.inbox177-bottom-anchor{height:1px;width:100%;clear:both;}
.inbox177-latest{
  display:none;
  position:absolute;
  right:22px;
  bottom:78px;
  z-index:5;
  border:0;
  border-radius:999px;
  background:#ffffff;
  color:#128c7e;
  box-shadow:0 6px 18px rgba(15,23,42,.18);
  padding:7px 13px;
  font-size:12px;
  font-weight:700;
}
.inbox177-composer{position:relative;z-index:4;}
.inbox154-bubble{overflow-wrap:anywhere;}

@media(max-width:1000px){
  .inbox154-shell{
    display:flex !important;
    flex-direction:column;
    height:calc(100dvh - 145px) !important;
    min-height:720px;
    max-height:none;
  }
  .inbox154-list{
    flex:0 0 310px;
    height:310px !important;
    max-height:310px !important;
  }
  .inbox154-panel{
    flex:1 1 auto;
    min-height:0 !important;
    height:auto !important;
  }
  .inbox154-header{
    min-height:64px;
    padding:10px 12px;
  }
  .inbox154-messages,
  .inbox177-messages{
    min-height:0 !important;
    height:auto !important;
    padding:14px 12px 38px !important;
  }
  .inbox154-bubble{max-width:92%;font-size:13.5px;}
  .inbox177-latest{bottom:76px;right:14px;}
}

@media(max-width:600px){
  .inbox154-shell{
    height:calc(100dvh - 118px) !important;
    min-height:680px;
    border-radius:12px;
  }
  .inbox154-list{flex-basis:270px;height:270px!important;max-height:270px!important;}
  .inbox154-composer{padding:8px 10px;}
  .inbox154-composer textarea{min-height:42px;}
}

/* v1.7.9 Messaging App Inbox Rebuild - isolated from older WhatsApp CSS */
.ym-inbox-page{height:calc(100vh - 125px);display:flex;flex-direction:column;min-height:640px;}
.ym-inbox-stats{flex:0 0 auto;}
.ym-msg-shell{flex:1 1 auto;min-height:0;display:grid;grid-template-columns:390px minmax(0,1fr);background:#fff;border:1px solid #d8dee4;border-radius:20px;overflow:hidden;box-shadow:0 12px 30px rgba(15,23,42,.08);}
.ym-msg-list{display:flex;flex-direction:column;min-width:0;border-right:1px solid #d8dee4;background:#fff;min-height:0;}
.ym-msg-list-head{flex:0 0 auto;padding:14px;background:#f5f7f9;border-bottom:1px solid #e5e7eb;}
.ym-msg-title{font-weight:800;font-size:20px;color:#111827;line-height:1;}
.ym-msg-subtitle{font-size:12px;color:#667085;margin-top:4px;}
.ym-msg-search .form-control,.ym-msg-search .form-select{border-radius:12px;}
.ym-msg-list-scroll{flex:1 1 auto;min-height:0;overflow-y:auto;background:#fff;-webkit-overflow-scrolling:touch;}
.ym-msg-contact{display:flex;gap:12px;padding:12px 14px;color:#111827;text-decoration:none;border-bottom:1px solid #f0f2f4;transition:background .12s ease;}
.ym-msg-contact:hover,.ym-msg-contact.active{background:#eefcf4;color:#111827;}
.ym-msg-avatar{width:45px;height:45px;min-width:45px;border-radius:999px;display:grid;place-items:center;background:linear-gradient(135deg,#0ea66b,#0f766e);color:#fff;font-weight:900;box-shadow:0 3px 10px rgba(16,185,129,.22);}
.ym-msg-avatar.big{width:48px;height:48px;min-width:48px;}
.ym-msg-contact-main{flex:1;min-width:0;}
.ym-msg-contact-line1{display:flex;justify-content:space-between;align-items:center;gap:8px;}
.ym-msg-contact-line1 strong{font-size:15px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}
.ym-msg-contact-line1 time{font-size:11px;color:#667085;white-space:nowrap;}
.ym-msg-preview{font-size:13px;color:#667085;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:3px;}
.ym-msg-badges{display:flex;align-items:center;gap:5px;margin-top:7px;}
.ym-msg-badge{font-size:10px;border-radius:99px;padding:2px 7px;background:#e6f4ea;color:#146c43;text-transform:capitalize;}
.ym-msg-badge.pending_human{background:#fff4d6;color:#946200;}
.ym-msg-badge.resolved,.ym-msg-badge.closed{background:#e8f1ff;color:#175cd3;}
.ym-msg-badge.light{background:#f2f4f7;color:#475467;}
.ym-msg-dot{width:8px;height:8px;border-radius:50%;background:#25d366;display:inline-block;margin-left:auto;}
.ym-msg-panel{position:relative;display:flex;flex-direction:column;min-width:0;min-height:0;background:#efeae2;}
.ym-msg-panel:before{content:"";position:absolute;inset:0;opacity:.18;background-image:radial-gradient(circle at 20px 18px,rgba(17,27,33,.08) 2px,transparent 2px),radial-gradient(circle at 70px 48px,rgba(17,27,33,.07) 1.5px,transparent 1.5px);background-size:92px 92px;pointer-events:none;}
.ym-msg-panel>*{position:relative;z-index:1;}
.ym-msg-header{flex:0 0 auto;min-height:70px;background:#f0f2f5;border-bottom:1px solid #d8dee4;display:flex;align-items:center;gap:12px;padding:10px 14px;}
.ym-msg-back{display:none;color:#0f766e;text-decoration:none;font-weight:700;margin-right:2px;}
.ym-msg-head-main{min-width:0;flex:1;}
.ym-msg-head-name{font-weight:800;color:#111827;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.ym-msg-head-meta{font-size:12px;color:#667085;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.ym-msg-status-form{display:flex;align-items:center;gap:7px;min-width:230px;}
.ym-msg-status-form .form-select{border-radius:11px;}
.ym-msg-quickbar{flex:0 0 auto;display:flex;gap:8px;flex-wrap:wrap;padding:8px 12px;background:rgba(255,255,255,.72);border-bottom:1px solid rgba(216,222,228,.8);}
.ym-msg-messages{flex:1 1 auto;min-height:0;overflow-y:auto;-webkit-overflow-scrolling:touch;padding:18px 7% 20px;scroll-behavior:smooth;}
.ym-msg-date{width:max-content;max-width:90%;margin:0 auto 16px;background:rgba(255,255,255,.88);color:#54656f;border-radius:9px;padding:5px 12px;font-size:12px;box-shadow:0 1px 2px rgba(0,0,0,.08);}
.ym-msg-row{display:flex;margin:6px 0;clear:both;}
.ym-msg-row.incoming{justify-content:flex-start;}
.ym-msg-row.outgoing{justify-content:flex-end;}
.ym-msg-row.internal{justify-content:center;}
.ym-msg-bubble{max-width:min(76%,760px);border-radius:12px;padding:9px 12px 20px;box-shadow:0 1px .5px rgba(11,20,26,.18);font-size:14.5px;line-height:1.48;position:relative;white-space:pre-wrap;overflow-wrap:anywhere;word-break:normal;}
.ym-msg-bubble.incoming{background:#fff;border-top-left-radius:3px;}
.ym-msg-bubble.outgoing{background:#d9fdd3;border-top-right-radius:3px;}
.ym-msg-bubble.internal{background:#fff7d6;color:#6b4e00;border:1px dashed #e5c04f;text-align:center;max-width:82%;}
.ym-msg-type{display:inline-block;font-size:11px;background:#eef2ff;color:#3730a3;border-radius:999px;padding:2px 7px;margin-bottom:5px;}
.ym-msg-body{min-width:70px;}
.ym-msg-bubble time{position:absolute;right:8px;bottom:4px;font-size:10px;color:#667085;}
.ym-msg-latest{display:none;position:absolute;right:18px;bottom:86px;z-index:5;border:0;border-radius:999px;padding:7px 13px;background:#fff;color:#0f766e;box-shadow:0 6px 18px rgba(0,0,0,.18);font-weight:700;font-size:12px;}
.ym-msg-composer{flex:0 0 auto;display:flex;align-items:flex-end;gap:10px;padding:11px 14px;background:#f0f2f5;border-top:1px solid #d8dee4;}
.ym-msg-composer textarea{flex:1;border:0;outline:0;resize:none;border-radius:14px;background:#fff;min-height:46px;max-height:155px;padding:11px 14px;line-height:1.4;box-shadow:inset 0 0 0 1px #eef0f2;}
.ym-msg-composer .btn{border-radius:14px;padding-left:20px;padding-right:20px;}
.ym-msg-empty{height:100%;display:grid;place-items:center;align-content:center;text-align:center;color:#667085;padding:40px;}
.ym-msg-empty div{font-size:62px;margin-bottom:8px;}
@media(max-width:1050px){
  .ym-inbox-page{height:auto;min-height:0;}
  .ym-msg-shell{grid-template-columns:1fr;height:auto;min-height:0;}
  .ym-msg-list{height:430px;border-right:0;border-bottom:1px solid #d8dee4;}
  .ym-msg-panel{height:calc(100vh - 130px);min-height:650px;}
  .ym-msg-header{align-items:flex-start;gap:9px;}
  .ym-msg-status-form{min-width:0;flex-wrap:wrap;justify-content:flex-end;}
  .ym-msg-messages{padding-left:14px;padding-right:14px;}
  .ym-msg-bubble{max-width:90%;font-size:14px;}
}
@media(max-width:720px){
  body{overflow-x:hidden;}
  .ym-inbox-stats{display:none;}
  .ym-msg-shell{border-radius:0;border-left:0;border-right:0;margin-left:-12px;margin-right:-12px;}
  .ym-msg-shell.mobile-chat-open .ym-msg-list{display:none;}
  .ym-msg-shell:not(.mobile-chat-open) .ym-msg-panel{display:none;}
  .ym-msg-back{display:inline-block;}
  .ym-msg-list{height:calc(100vh - 125px);min-height:520px;}
  .ym-msg-panel{height:calc(100vh - 86px);min-height:0;}
  .ym-msg-header{min-height:64px;padding:8px 10px;}
  .ym-msg-avatar.big{width:40px;height:40px;min-width:40px;}
  .ym-msg-head-meta{font-size:11px;}
  .ym-msg-status-form{display:none;}
  .ym-msg-quickbar{overflow-x:auto;flex-wrap:nowrap;padding:7px 9px;}
  .ym-msg-quickbar .btn{white-space:nowrap;}
  .ym-msg-messages{padding:12px 10px 14px;}
  .ym-msg-bubble{max-width:92%;font-size:13.8px;padding:8px 10px 19px;}
  .ym-msg-composer{padding:8px 9px;gap:7px;}
  .ym-msg-composer textarea{min-height:42px;border-radius:12px;}
  .ym-msg-composer .btn{padding-left:14px;padding-right:14px;}
  .ym-msg-latest{bottom:70px;right:12px;}
}

/* v1.8.1 Messenger-style inbox rebuild */
.ymx-inbox-wrap{width:100%;max-width:1240px;margin:0 auto;height:calc(100dvh - 150px);min-height:640px;}
.ymx-messenger{height:100%;display:grid;grid-template-columns:360px minmax(0,1fr);background:#fff;border:1px solid #e4e7ec;border-radius:18px;box-shadow:0 10px 28px rgba(15,23,42,.10);overflow:hidden;isolation:isolate;}
.ymx-sidebar{min-width:0;min-height:0;display:flex;flex-direction:column;background:#fff;border-right:1px solid #e5e7eb;}
.ymx-sidebar-head{flex:0 0 auto;padding:18px 18px 12px;background:#fff;border-bottom:1px solid #f0f2f5;}
.ymx-title-row{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;margin-bottom:12px;}
.ymx-title{font-size:24px;font-weight:800;line-height:1;color:#050505;letter-spacing:-.02em;}
.ymx-subtitle{font-size:12px;color:#667085;margin-top:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:230px;}
.ymx-debug{font-size:12px;font-weight:700;color:#0f766e;text-decoration:none;background:#eafaf4;border-radius:999px;padding:6px 10px;white-space:nowrap;}
.ymx-search-form{margin:0;}
.ymx-search-input{width:100%;border:0;outline:0;border-radius:999px;background:#f0f2f5;color:#111827;font-size:14px;padding:10px 15px;}
.ymx-search-input:focus{box-shadow:0 0 0 2px rgba(14,166,107,.15);background:#f7f9fb;}
.ymx-filter-row{display:flex;gap:8px;margin-top:9px;}
.ymx-filter-select{flex:1;border:0;background:#f0f2f5;border-radius:12px;padding:8px 10px;font-size:13px;color:#344054;outline:0;}
.ymx-filter-btn{border:0;border-radius:12px;background:#0084ff;color:#fff;font-weight:700;padding:8px 14px;font-size:13px;}
.ymx-mini-stats{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px;}
.ymx-mini-stats span{font-size:11px;background:#f5f7fa;color:#475467;border-radius:999px;padding:4px 8px;}
.ymx-chat-list{flex:1 1 auto;min-height:0;overflow-y:auto;-webkit-overflow-scrolling:touch;background:#fff;}
.ymx-chat-item{display:flex;align-items:center;gap:12px;padding:12px 18px;color:#050505;text-decoration:none;border-bottom:1px solid #f6f7f8;transition:background .15s ease;}
.ymx-chat-item:hover,.ymx-chat-item.active{background:#f2f4f7;color:#050505;text-decoration:none;}
.ymx-avatar{width:48px;height:48px;min-width:48px;border-radius:50%;display:grid;place-items:center;color:#fff;font-weight:800;background:linear-gradient(135deg,#0084ff,#14b8a6);box-shadow:0 2px 8px rgba(0,132,255,.18);}
.ymx-avatar-lg{width:48px;height:48px;min-width:48px;}
.ymx-chat-meta{flex:1;min-width:0;}
.ymx-chat-top{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:3px;}
.ymx-chat-top strong{font-size:15px;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.ymx-chat-top time{font-size:11px;color:#65676b;white-space:nowrap;}
.ymx-preview{font-size:13px;color:#65676b;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:245px;}
.ymx-tags{display:flex;align-items:center;gap:5px;margin-top:6px;}
.ymx-tag{font-size:10px;line-height:1;border-radius:999px;padding:4px 7px;background:#e8f1ff;color:#175cd3;text-transform:capitalize;}
.ymx-tag.pending_human{background:#fff4d6;color:#946200;}
.ymx-tag.closed,.ymx-tag.resolved{background:#e6f4ea;color:#146c43;}
.ymx-tag.muted{background:#f2f4f7;color:#667085;}
.ymx-unread{display:inline-block;width:8px;height:8px;border-radius:50%;background:#0084ff;margin-left:auto;}
.ymx-empty-list{padding:40px 20px;text-align:center;color:#667085;font-size:14px;}
.ymx-window{position:relative;min-width:0;min-height:0;display:flex;flex-direction:column;background:#fff;}
.ymx-chat-header{flex:0 0 auto;min-height:72px;display:flex;align-items:center;gap:12px;padding:12px 18px;background:#fff;border-bottom:1px solid #e5e7eb;}
.ymx-back{display:none;color:#0084ff;text-decoration:none;font-weight:800;white-space:nowrap;}
.ymx-header-text{flex:1;min-width:0;}
.ymx-name{font-weight:800;color:#050505;font-size:15px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.ymx-status-line{font-size:12px;color:#65676b;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:2px;}
.ymx-status-form{display:flex;gap:7px;align-items:center;}
.ymx-status-form select{border:0;background:#f0f2f5;border-radius:12px;padding:8px 10px;font-size:13px;color:#344054;outline:0;}
.ymx-status-form button{border:0;border-radius:12px;background:#e8f1ff;color:#175cd3;font-weight:800;padding:8px 12px;font-size:13px;}
.ymx-actions{flex:0 0 auto;display:flex;align-items:center;gap:8px;overflow-x:auto;padding:9px 14px;background:#fff;border-bottom:1px solid #f0f2f5;-webkit-overflow-scrolling:touch;}
.ymx-actions form{margin:0;}
.ymx-actions button,.ymx-actions a{border:0;border-radius:999px;background:#f0f2f5;color:#344054;text-decoration:none;font-weight:700;font-size:12px;padding:8px 12px;white-space:nowrap;display:inline-block;}
.ymx-actions button:hover,.ymx-actions a:hover{background:#e5e7eb;color:#111827;}
.ymx-message-area{flex:1 1 auto;min-height:0;overflow-y:auto;-webkit-overflow-scrolling:touch;padding:20px 24px 18px;background:#fff;display:flex;flex-direction:column;gap:10px;scroll-behavior:smooth;}
.ymx-date-pill{align-self:center;background:#f0f2f5;color:#65676b;border-radius:999px;font-size:12px;padding:5px 11px;margin:6px 0;}
.ymx-message-row{display:flex;width:100%;}
.ymx-message-row.incoming{justify-content:flex-start;}
.ymx-message-row.outgoing{justify-content:flex-end;}
.ymx-message-row.internal{justify-content:center;}
.ymx-message{max-width:min(64%,760px);border-radius:18px;padding:10px 16px 20px;font-size:15px;line-height:1.45;position:relative;white-space:pre-wrap;overflow-wrap:anywhere;box-shadow:none;}
.ymx-message.incoming{background:#e4e6eb;color:#050505;border-top-left-radius:5px;}
.ymx-message.outgoing{background:#0084ff;color:#fff;border-top-right-radius:5px;}
.ymx-message.internal{background:#fff7d6;color:#7a5600;border:1px dashed #e5c04f;max-width:78%;text-align:center;}
.ymx-message-type{display:inline-block;font-size:11px;background:rgba(255,255,255,.7);color:#175cd3;border-radius:999px;padding:2px 7px;margin-bottom:5px;}
.ymx-message-text{min-width:56px;}
.ymx-message time{position:absolute;right:12px;bottom:5px;font-size:10px;opacity:.68;}
.ymx-message.outgoing time{color:rgba(255,255,255,.85);}
.ymx-no-messages{align-self:center;margin:auto;color:#667085;font-size:14px;}
.ymx-jump{display:none;position:absolute;right:22px;bottom:82px;border:0;border-radius:999px;background:#fff;color:#0084ff;font-weight:800;font-size:12px;padding:8px 13px;box-shadow:0 8px 22px rgba(15,23,42,.18);z-index:4;}
.ymx-input-area{flex:0 0 auto;display:flex;align-items:flex-end;gap:12px;padding:15px 18px;background:#fff;border-top:1px solid #e5e7eb;}
.ymx-input-area textarea{flex:1;min-height:44px;max-height:132px;resize:none;border:0;outline:0;border-radius:22px;background:#f0f2f5;padding:12px 16px;font-size:15px;line-height:1.35;}
.ymx-input-area textarea:focus{background:#f7f9fb;box-shadow:0 0 0 2px rgba(0,132,255,.12);}
.ymx-input-area button{border:0;border-radius:999px;background:#0084ff;color:#fff;font-weight:800;padding:11px 20px;min-height:44px;}
.ymx-empty-window{height:100%;display:grid;place-items:center;align-content:center;text-align:center;color:#667085;padding:30px;}
.ymx-empty-window div{font-size:64px;margin-bottom:8px;}
.ymx-empty-window strong{font-size:18px;color:#344054;}
.ymx-empty-window p{margin:5px 0 0;font-size:14px;}
@media (max-width: 991.98px){
  .ymx-inbox-wrap{height:calc(100dvh - 112px);min-height:560px;max-width:none;}
  .ymx-messenger{grid-template-columns:330px minmax(0,1fr);border-radius:14px;}
  .ymx-message{max-width:78%;}
  .ymx-status-form{display:none;}
}
@media (max-width: 767.98px){
  .ymx-inbox-wrap{height:calc(100dvh - 78px);min-height:0;margin-left:-12px;margin-right:-12px;width:calc(100% + 24px);}
  .ymx-messenger{display:block;height:100%;border-left:0;border-right:0;border-radius:0;box-shadow:none;}
  .ymx-sidebar,.ymx-window{height:100%;width:100%;}
  .ymx-messenger.ymx-chat-open .ymx-sidebar{display:none;}
  .ymx-messenger:not(.ymx-chat-open) .ymx-window{display:none;}
  .ymx-sidebar{border-right:0;}
  .ymx-sidebar-head{padding:14px 14px 10px;}
  .ymx-title{font-size:22px;}
  .ymx-chat-item{padding:11px 14px;}
  .ymx-preview{max-width:calc(100vw - 150px);}
  .ymx-back{display:inline-block;}
  .ymx-chat-header{min-height:62px;padding:8px 10px;gap:9px;}
  .ymx-avatar-lg{width:40px;height:40px;min-width:40px;}
  .ymx-status-line{font-size:11px;}
  .ymx-actions{padding:7px 9px;}
  .ymx-message-area{padding:14px 10px 12px;gap:8px;}
  .ymx-message{max-width:88%;font-size:14px;padding:9px 12px 19px;}
  .ymx-message.internal{max-width:92%;}
  .ymx-input-area{padding:9px 9px;gap:8px;}
  .ymx-input-area textarea{min-height:42px;border-radius:18px;padding:10px 13px;}
  .ymx-input-area button{min-height:42px;padding:10px 15px;}
  .ymx-jump{bottom:70px;right:12px;}
}


/* v1.8.2 Inbox Latest Position Fix
   Keep chat naturally at latest without visible top-to-bottom smooth scrolling.
   If admin scrolls up, preserve reading position and show Latest button. */
.ymx-message-area{scroll-behavior:auto !important;}
.ymx-jump{transition:opacity .12s ease;}

/* v1.10.0 premium SaaS polish */
:root{
  --ym-bg:#f6f8fc;--ym-card:#ffffff;--ym-ink:#101828;--ym-muted:#667085;--ym-line:#e6eaf2;--ym-blue:#2563eb;--ym-purple:#7c3aed;--ym-gold:#d6a21e;--ym-soft:#eef4ff;
}
body{background:linear-gradient(135deg,#f7f9ff 0%,#f8fafc 45%,#fffaf0 100%);color:var(--ym-ink)}
.sidebar{background:linear-gradient(180deg,#0b1220 0%,#111827 55%,#1e1b4b 100%);box-shadow:8px 0 30px rgba(15,23,42,.12)}
.brand{padding:18px 16px;border-bottom:1px solid rgba(255,255,255,.08)}
.brand-mark{background:linear-gradient(135deg,var(--ym-blue),var(--ym-purple));box-shadow:0 10px 24px rgba(37,99,235,.35)}
.nav-section{font-size:11px;text-transform:uppercase;letter-spacing:.12em;color:#94a3b8;margin:18px 16px 7px;font-weight:700}.nav-link{border-radius:12px;margin:2px 10px;padding:10px 12px;color:#dbeafe}.nav-link:hover,.nav-link.active{background:rgba(255,255,255,.10);color:#fff}.topbar{background:rgba(255,255,255,.82);backdrop-filter:blur(12px);border-bottom:1px solid var(--ym-line);box-shadow:0 8px 24px rgba(15,23,42,.04)}
.panel,.stat-card{background:rgba(255,255,255,.92);border:1px solid var(--ym-line);border-radius:18px;box-shadow:0 18px 45px rgba(15,23,42,.06)}
.ym-panel-premium{background:linear-gradient(180deg,#fff 0%,#fbfdff 100%)}.panel-title{font-weight:800;color:#111827}.stat-title{color:#667085;font-weight:700;text-transform:uppercase;letter-spacing:.06em;font-size:12px}.stat-value{font-weight:900;color:#111827}.btn-primary{background:linear-gradient(135deg,var(--ym-blue),var(--ym-purple));border:0;box-shadow:0 10px 18px rgba(37,99,235,.2)}.btn-outline-primary{border-color:#bfdbfe;color:#1d4ed8}.form-control,.form-select{border-radius:12px;border-color:#d9e2ef}.table thead th{font-size:12px;text-transform:uppercase;letter-spacing:.05em;color:#667085}.badge{border-radius:999px;padding:.45em .65em}.pill{background:#eff6ff;border:1px solid #dbeafe;color:#1e40af;border-radius:999px;padding:6px 10px;font-size:12px}
.ym-rule-card{border-left:4px solid var(--ym-blue);background:#fff;border-radius:14px;padding:14px 16px}.ym-danger-zone{border:1px solid #fecaca;background:#fff7f7;border-radius:16px;padding:16px}.ym-category-chip{display:inline-flex;align-items:center;gap:6px;border-radius:999px;background:#f1f5f9;padding:5px 10px;font-size:12px;font-weight:700;color:#334155}
@media(max-width:991px){.sidebar{position:relative;width:100%;height:auto}.app-shell{display:block}.main{margin-left:0}.topbar{position:sticky;top:0;z-index:20}.container-fluid{padding-left:12px!important;padding-right:12px!important}.panel,.stat-card{border-radius:14px}}
