: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%}}
