*{box-sizing:border-box}
body{margin:0;font-family:"Sarabun","Segoe UI",Tahoma,sans-serif;background:#f3f5fa;color:#1f2937;font-size:15px}
.hidden{display:none!important}
header{background:#fff;box-shadow:0 2px 8px #0001;display:flex;align-items:center;gap:20px;padding:10px 24px;position:sticky;top:0;z-index:10;flex-wrap:wrap}
.logo{font-size:22px;background:linear-gradient(90deg,#4f46e5,#c026d3);-webkit-background-clip:text;color:transparent}
nav{display:flex;gap:4px;flex-wrap:wrap}
nav a{padding:8px 12px;border-radius:10px;cursor:pointer;font-weight:600;color:#374151}
nav a:hover{background:#eef2ff}
nav a.active{background:#4f46e5;color:#fff}
main{max-width:1300px;margin:0 auto;padding:24px}
h1{color:#4338ca;margin:0 0 16px}
h3{margin:0 0 10px}
.card{background:#fff;border-radius:16px;box-shadow:0 4px 18px #0000000d;padding:20px;margin-bottom:18px}
.grid{display:grid;gap:14px}
.g2{grid-template-columns:repeat(auto-fit,minmax(280px,1fr))}
.g4{grid-template-columns:repeat(auto-fit,minmax(180px,1fr))}
.stat{font-size:32px;font-weight:700;color:#4f46e5}
label{display:block;font-weight:600;margin:10px 0 4px;font-size:14px}
.help{color:#6b7280;font-size:12.5px;margin-top:3px}
.muted{color:#6b7280}.small{font-size:12px}
input,textarea,select{width:100%;padding:9px 11px;border:1px solid #d1d5db;border-radius:10px;font:inherit;background:#fff}
textarea{min-height:90px;resize:vertical}
textarea.big{min-height:260px}
input:focus,textarea:focus,select:focus{outline:2px solid #a5b4fc;border-color:#6366f1}
.btn{border:0;border-radius:10px;padding:9px 16px;font:inherit;font-weight:600;cursor:pointer;background:#e5e7eb}
.btn.primary{background:#4f46e5;color:#fff}.btn.green{background:#16a34a;color:#fff}.btn.red{background:#dc2626;color:#fff}.btn.sm{padding:5px 10px;font-size:13px}
.btn:hover{filter:brightness(.95)}
.row{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.switch{display:flex;align-items:center;gap:10px;margin:10px 0;font-weight:600;cursor:pointer}
.switch input{width:42px;height:22px;appearance:none;background:#d1d5db;border-radius:20px;position:relative;cursor:pointer;padding:0;border:0;flex:none}
.switch input:checked{background:#4f46e5}
.switch input::after{content:"";position:absolute;top:3px;left:3px;width:16px;height:16px;border-radius:50%;background:#fff;transition:.2s}
.switch input:checked::after{left:23px}
.step{border:1px solid #e5e7eb;border-radius:12px;padding:12px;margin:10px 0;background:#fafbff}
.step .head{display:flex;gap:8px;align-items:center;margin-bottom:8px}
.step .num{background:#4f46e5;color:#fff;border-radius:8px;padding:2px 9px;font-weight:700}
.count{font-size:12px;text-align:right;color:#6b7280}.count.over{color:#dc2626;font-weight:700}
.thumb{max-height:90px;border-radius:8px;margin-top:6px}
.save-bar{position:sticky;bottom:0;background:#fffffff0;padding:12px;border-top:1px solid #e5e7eb;text-align:right;border-radius:0 0 16px 16px;z-index:5}
.layout{display:grid;grid-template-columns:1fr 380px;gap:18px;align-items:start}
@media(max-width:1000px){.layout{grid-template-columns:1fr}}
.preview{position:sticky;top:80px;height:calc(100vh - 110px);display:flex;flex-direction:column}
.chat{flex:1;overflow:auto;padding:8px;background:#f9fafb;border-radius:12px;display:flex;flex-direction:column;gap:6px}
.bubble{max-width:85%;padding:8px 12px;border-radius:14px;white-space:pre-wrap;word-break:break-word;font-size:14px}
.bubble.user{align-self:flex-end;background:#4f46e5;color:#fff}
.bubble.assistant{align-self:flex-start;background:#fff;border:1px solid #e5e7eb}
.bubble.admin{align-self:flex-start;background:#fef3c7;border:1px solid #fcd34d}
.bubble img,.bubble video{max-width:220px;border-radius:8px;display:block}
.bubble .meta{font-size:11px;opacity:.6;margin-top:3px}
.inbox{display:grid;grid-template-columns:330px 1fr 300px;gap:14px;height:calc(100vh - 120px)}
@media(max-width:1100px){.inbox{grid-template-columns:1fr;height:auto}}
.list{overflow:auto}
.cust{display:flex;gap:10px;padding:10px;border-radius:10px;cursor:pointer;align-items:center}
.cust:hover{background:#f3f4f6}.cust.active{background:#eef2ff}
.avatar{width:40px;height:40px;border-radius:50%;background:#c7d2fe;flex:none;object-fit:cover;display:flex;align-items:center;justify-content:center;font-weight:700}
.tag{display:inline-block;padding:1px 8px;border-radius:20px;font-size:11.5px;font-weight:700;margin-right:4px}
.tag.fb{background:#dbeafe;color:#1d4ed8}.tag.line{background:#dcfce7;color:#15803d}.tag.buy{background:#fef3c7;color:#b45309}.tag.off{background:#fee2e2;color:#b91c1c}
.badge{background:#dc2626;color:#fff;border-radius:20px;padding:0 7px;font-size:12px}
table{width:100%;border-collapse:collapse}td,th{padding:8px;border-bottom:1px solid #eee;text-align:left;font-size:14px;vertical-align:top}
#toast{position:fixed;bottom:24px;left:50%;transform:translateX(-50%);background:#111827;color:#fff;padding:10px 20px;border-radius:12px;opacity:0;transition:.3s;pointer-events:none;z-index:99}
#toast.show{opacity:1}
code{background:#eef2ff;padding:2px 6px;border-radius:6px;font-size:13px;word-break:break-all}
.chips{display:flex;gap:6px;flex-wrap:wrap;margin-top:6px}.chip{background:#eef2ff;border-radius:20px;padding:3px 10px;font-size:13px}.chip b{cursor:pointer;margin-left:6px;color:#dc2626}

/* Omega-Style Multi-Channel & Multi-Bot */
.platform-badge{display:inline-block;padding:3px 10px;border-radius:6px;font-weight:700;font-size:11px;letter-spacing:.5px;text-transform:uppercase}
.platform-badge.fb{background:#1877f2;color:#fff}
.platform-badge.line{background:#06c755;color:#fff}
.status-pill{display:inline-flex;align-items:center;gap:6px;padding:3px 10px;border-radius:20px;font-size:12px;font-weight:600}
.status-pill.active{background:#dcfce7;color:#15803d}
.status-pill.inactive{background:#f3f4f6;color:#6b7280}
.status-pill::before{content:"";width:8px;height:8px;border-radius:50%;background:currentColor}
.modal-overlay{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.5);display:flex;align-items:center;justify-content:center;z-index:100;backdrop-filter:blur(2px)}
.modal-box{background:#fff;border-radius:18px;max-width:560px;width:92%;max-height:90vh;overflow-y:auto;padding:24px;box-shadow:0 10px 30px rgba(0,0,0,0.2)}
.bot-card{border:1px solid #e5e7eb;border-radius:14px;padding:16px;background:#fff;transition:.2s;display:flex;flex-direction:column;justify-content:space-between}
.bot-card:hover{border-color:#6366f1;box-shadow:0 4px 14px rgba(99,102,241,0.1)}
.bot-title{font-size:17px;font-weight:700;color:#1f2937;margin-bottom:6px;display:flex;align-items:center;justify-content:space-between}
.bot-desc{font-size:13px;color:#6b7280;line-height:1.5;margin-bottom:14px;max-height:4.5em;overflow:hidden}
.table-responsive{overflow-x:auto}
.channel-table th{background:#f9fafb;font-weight:700;color:#374151;border-bottom:2px solid #e5e7eb}
.channel-table td{vertical-align:middle;padding:12px 10px}
.copy-btn{cursor:pointer;background:#eef2ff;color:#4f46e5;border:1px solid #c7d2fe;padding:3px 8px;border-radius:6px;font-size:12px;font-weight:600}
.copy-btn:hover{background:#e0e7ff}
