*{box-sizing:border-box}
:root{
    --bg:#ecefe8;
    --panel:#ffffff;
    --panel-soft:#f7f8f4;
    --panel-muted:#f2f4ee;
    --line:#dde3d7;
    --line-soft:#eaeee6;
    --text:#16202a;
    --muted:#687481;
    --primary:#2563eb;
    --primary-weak:#eaf1ff;
    --success:#15803d;
    --success-weak:#edf9f0;
    --danger:#dc2626;
    --accent:#0f766e;
}
body{margin:0;font-family:Arial,"PingFang SC","Microsoft YaHei",sans-serif;background:linear-gradient(180deg,#eff2ea 0%,#e8ede5 100%);color:var(--text);height:100vh;overflow:hidden}
button,input,textarea{font:inherit}
a{text-decoration:none}
body.login{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:24px;background:linear-gradient(180deg,#f2f5ee 0%,#e8ede5 100%);color:#1f2937}
.login-card{width:100%;max-width:420px;background:rgba(255,255,255,.94);border-radius:16px;padding:32px;box-shadow:0 28px 90px rgba(15,23,42,.1);border:1px solid rgba(221,227,215,.9)}
.login-title{margin:0 0 8px;font-size:28px;font-weight:700}
.login-subtitle{margin:0 0 24px;color:#6b7280;font-size:14px}
.field{margin-bottom:16px}
.field label{display:block;font-size:14px;margin-bottom:8px;color:#374151}
.field input{width:100%;height:46px;border:1px solid #d7ddd1;border-radius:12px;padding:0 14px;font-size:15px;outline:none;background:#fbfcfa}
.field input:focus{border-color:var(--primary);box-shadow:0 0 0 4px rgba(37,99,235,.08)}
.login-card .btn{width:100%;height:46px;border:0;border-radius:12px;background:var(--primary);color:#fff;font-size:15px;font-weight:700;cursor:pointer}
.login-card .btn:hover{background:#1d4ed8}
.error{margin-bottom:16px;padding:12px 14px;border-radius:12px;background:#fef2f2;color:var(--danger);font-size:14px}
.meta{margin-top:16px;font-size:13px;color:#6b7280;text-align:center}
.layout{display:flex;height:100vh}
.sidebar{width:372px;min-width:328px;background:rgba(255,255,255,.86);border-right:1px solid rgba(221,227,215,.95);box-shadow:12px 0 34px rgba(15,23,42,.04);backdrop-filter:saturate(160%) blur(10px);display:flex;flex-direction:column}
.sidebar-top{padding:20px 18px 14px;border-bottom:1px solid var(--line-soft)}
.brand{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}
.brand-copy{min-width:0}
.brand h1{margin:0;font-size:24px;line-height:1.1;letter-spacing:0}
.brand-sub{margin-top:6px;font-size:12px;color:var(--muted)}
.brand a{display:inline-flex;align-items:center;justify-content:center;height:32px;padding:0 12px;border-radius:10px;background:var(--panel-muted);border:1px solid var(--line);color:#425466;font-size:13px;white-space:nowrap}
.webhook-status{position:fixed;left:50%;top:50%;transform:translate(-50%,-50%) scale(.94);display:inline-flex;align-items:center;gap:12px;width:fit-content;min-width:0;max-width:min(92vw,280px);padding:12px 14px;border-radius:999px;background:#fff;border:1px solid #e5eaf2;color:#1d4ed8;font-size:14px;font-weight:700;box-shadow:0 12px 32px rgba(15,23,42,.12);opacity:0;pointer-events:none;z-index:60;white-space:nowrap;transition:opacity .18s ease,transform .18s ease}
.webhook-status.show{opacity:1;pointer-events:auto;transform:translate(-50%,-50%) scale(1)}
.webhook-status-text{font-size:14px;line-height:1.35;font-weight:700;word-break:break-word}
.webhook-status.loading{color:#2563eb}
.webhook-status.ready{color:var(--success)}
.webhook-status.error{color:var(--danger)}
.webhook-ring{width:18px;height:18px;border-radius:50%;border:2.5px solid currentColor;border-top-color:transparent;animation:spin .8s linear infinite;flex:none}
.webhook-status.ready .webhook-ring{border:2.5px solid currentColor;border-top-color:transparent;animation:spin .8s linear infinite}
.webhook-status.error .webhook-ring{border:2.5px solid currentColor;border-top-color:transparent;animation:spin .8s linear infinite}
.search-box{margin-top:14px}
.search-box input{width:100%;height:42px;border:1px solid #d9dfd4;border-radius:12px;padding:0 14px;background:var(--panel-soft);outline:none}
.search-box input:focus{border-color:var(--primary);box-shadow:0 0 0 4px rgba(37,99,235,.08)}
.contact-list{flex:1;overflow:auto;padding:12px 10px 14px}
.contact-item{position:relative;width:calc(100% - 6px);height:68px;margin:0 auto 8px;padding:8px 12px;border-radius:16px;cursor:pointer;border:1px solid rgba(223,228,216,.92);background:linear-gradient(180deg,#ffffff 0%,#fbfcf9 100%);box-shadow:0 8px 20px rgba(15,23,42,.03);overflow:hidden;display:grid;grid-template-columns:40px minmax(0,1fr) auto;align-items:center;gap:10px;transition:background .16s ease,border-color .16s ease,box-shadow .16s ease,transform .16s ease}
.contact-item:hover{background:linear-gradient(180deg,#ffffff 0%,#f8faf6 100%);box-shadow:0 10px 22px rgba(15,23,42,.05);transform:translateY(-1px)}
.contact-item.active{background:linear-gradient(180deg,#eef5ff 0%,#eaf2ff 100%);border-color:#c8d9fb;box-shadow:0 12px 24px rgba(37,99,235,.08)}
.contact-item.pinned{background:linear-gradient(180deg,#fffdf7 0%,#fff8e8 100%);border-color:#f4d98f}
.contact-item.pinned:hover{background:linear-gradient(180deg,#fffdf3 0%,#fff4dd 100%)}
.contact-item.pinned.active{background:linear-gradient(180deg,#fff7d8 0%,#ffefc0 100%);border-color:#efb84a}
.contact-avatar{width:40px;height:40px;border-radius:12px;display:flex;align-items:center;justify-content:center;font-size:13px;font-weight:700;letter-spacing:0;box-shadow:inset 0 0 0 1px rgba(255,255,255,.7);overflow:hidden;background:#f6f8f3;color:#425466;flex:none}
.contact-avatar-image{display:block;width:100%;height:100%;object-fit:cover;border-radius:inherit}
.contact-content{min-width:0;display:flex;flex-direction:column;justify-content:center;gap:6px}
.contact-name{font-size:14px;font-weight:700;color:#16202a;line-height:1.08;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
.contact-time{font-size:10px;color:#94a3b8;white-space:nowrap;line-height:1}
.contact-preview{font-size:12px;color:#63707b;line-height:1.1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
.contact-side{display:flex;flex-direction:column;align-items:flex-end;justify-content:space-between;align-self:stretch;min-width:48px}
.contact-meta{display:flex;align-items:center;justify-content:flex-end;gap:6px;pointer-events:none;min-height:18px}
.badge{display:inline-flex;align-items:center;justify-content:center;min-width:16px;height:16px;padding:0 4px;border-radius:999px;background:#ef4444;color:#fff;font-size:10px;font-weight:700;line-height:1;box-shadow:0 0 0 2px #fff}
.blocked{display:inline-flex;align-items:center;height:18px;padding:0 6px;border-radius:999px;background:#17212b;color:#fff;font-size:10px}
.contact-menu{position:fixed;z-index:90;display:flex;flex-direction:column;min-width:184px;padding:6px;background:#fff;border:1px solid var(--line);border-radius:14px;box-shadow:0 20px 50px rgba(15,23,42,.14)}
.contact-menu-item{height:38px;padding:0 12px;border:0;background:transparent;border-radius:10px;text-align:left;font-size:13px;color:#16202a;cursor:pointer}
.contact-menu-item:hover{background:var(--panel-soft)}
.contact-menu-item.danger{color:#dc2626}
.contact-menu-item.danger:hover{background:#fef2f2}
.main{flex:1;display:flex;flex-direction:column;background:linear-gradient(180deg,#f6f8f2 0%,#eef2ea 100%)}
.chat-header{padding:18px 24px;border-bottom:1px solid rgba(221,227,215,.9);background:rgba(255,255,255,.86);backdrop-filter:saturate(160%) blur(10px);display:flex;align-items:center;justify-content:space-between;gap:18px;box-shadow:0 6px 18px rgba(15,23,42,.03)}
.chat-title{display:flex;flex-direction:column;gap:6px;min-width:0}
.chat-name{font-size:20px;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-sub{font-size:13px;color:var(--muted);display:flex;flex-wrap:wrap;gap:10px}
.chat-actions{display:flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:flex-end}
.btn{height:38px;border:0;border-radius:10px;padding:0 16px;font-weight:700;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:6px;transition:transform .16s ease,background .16s ease,box-shadow .16s ease}
.btn:hover{transform:translateY(-1px)}
.btn-primary{background:var(--primary);color:#fff;box-shadow:0 10px 20px rgba(37,99,235,.18)}
.btn-primary:hover{background:#1d4ed8}
.btn-light{background:#eef1ec;color:#1c2731;border:1px solid var(--line)}
.btn-light:hover{background:#e5e9e2}
.btn-danger{background:#17212b;color:#fff}
.btn-danger:hover{background:#0f1720}
.btn:disabled{opacity:.55;cursor:not-allowed;transform:none}
.chat-body{flex:1;overflow:auto;padding:28px 24px 22px;display:flex;flex-direction:column;gap:10px}
.bubble-row{display:flex;align-items:flex-end}
.bubble-row.in{justify-content:flex-start}
.bubble-row.out{justify-content:flex-end}
.bubble{max-width:min(72%,720px);padding:0;font-size:14px;line-height:1.65;word-break:break-word}
.bubble.in .bubble-inner{background:#fff;color:#16202a;border:1px solid #e3e8df;border-top-left-radius:6px;box-shadow:0 8px 20px rgba(15,23,42,.04)}
.bubble.out .bubble-inner{background:#edf8f5;color:#16202a;border:1px solid #d5ece5;border-top-right-radius:6px;box-shadow:0 8px 20px rgba(15,118,110,.06)}
.bubble-row.system{justify-content:center}
.bubble.system .bubble-inner{background:#fff8e8;color:#8a5a00;border:1px solid #f4dfae;border-radius:999px}
.bubble-inner{display:flex;flex-direction:column;gap:4px;max-width:100%;padding:10px 12px;border-radius:14px}
.bubble-text{white-space:pre-wrap;word-break:break-word}
.bubble-time{font-size:11px;line-height:1;opacity:.58;align-self:flex-end;letter-spacing:0}
.bubble.in .bubble-time{color:#94a3b8}
.bubble.out .bubble-time{color:#5f7b76}
.chat-input{padding:18px 24px;border-top:1px solid rgba(221,227,215,.9);background:rgba(255,255,255,.92)}
.chat-form{display:block}
.chat-compose{display:flex;flex-direction:column;gap:12px;padding:12px;border:1px solid #dfe5da;border-radius:22px;background:linear-gradient(180deg,#ffffff 0%,#f8faf5 100%);box-shadow:0 16px 40px rgba(15,23,42,.05)}
.chat-form textarea{display:block;width:100%;min-height:92px;max-height:200px;border:1px solid #d9dfd4;border-radius:18px;padding:14px 16px;resize:vertical;outline:none;background:var(--panel-soft);line-height:1.65}
.chat-form textarea:focus{border-color:var(--primary);box-shadow:0 0 0 4px rgba(37,99,235,.08)}
.chat-compose-bar{display:flex;align-items:center;justify-content:space-between;gap:12px}
.compose-hint{font-size:12px;color:#7b8794;line-height:1;white-space:nowrap}
.chat-send-btn{min-width:132px;height:42px;border-radius:14px;padding:0 18px;box-shadow:0 12px 24px rgba(37,99,235,.2)}
.chat-send-icon{display:inline-flex;align-items:center;justify-content:center;font-size:14px;transform:translateY(-1px)}
.placeholder{margin:auto;max-width:520px;text-align:center;color:#64748b}
.placeholder-title{font-size:24px;font-weight:700;color:#1e293b;margin-bottom:12px}
.toast{position:fixed;right:20px;bottom:20px;min-width:220px;max-width:360px;padding:14px 16px;border-radius:14px;background:#18212b;color:#fff;box-shadow:0 18px 60px rgba(15,23,42,.22);opacity:0;pointer-events:none;transform:translateY(16px);transition:all .2s ease}
.toast.show{opacity:1;transform:translateY(0)}
.toast.error{background:#b91c1c}
.dialog-backdrop{position:fixed;inset:0;z-index:120;display:flex;align-items:center;justify-content:center;padding:20px;background:rgba(15,23,42,.28);opacity:0;pointer-events:none;transition:opacity .18s ease}
.dialog-backdrop.show{opacity:1;pointer-events:auto}
.dialog-card{width:min(92vw,420px);padding:22px 20px 18px;border-radius:20px;background:rgba(255,255,255,.98);border:1px solid rgba(221,227,215,.96);box-shadow:0 24px 70px rgba(15,23,42,.18)}
.dialog-title{font-size:19px;font-weight:700;color:#16202a;line-height:1.2}
.dialog-text{margin-top:10px;font-size:14px;line-height:1.65;color:#5b6673}
.dialog-input-wrap{margin-top:16px}
.dialog-input{width:100%;height:44px;border:1px solid #d9dfd4;border-radius:12px;padding:0 14px;background:var(--panel-soft);outline:none;color:var(--text)}
.dialog-input:focus{border-color:var(--primary);box-shadow:0 0 0 4px rgba(37,99,235,.08)}
.dialog-actions{margin-top:18px;display:flex;align-items:center;justify-content:flex-end;gap:10px}
.hidden{display:none}
@keyframes spin{to{transform:rotate(360deg)}}
@media (max-width:1100px){.sidebar{width:332px}}
@media (max-width:860px){body{overflow:auto;height:auto}.layout{flex-direction:column;height:auto;min-height:100vh}.sidebar{width:100%;min-width:0;height:42vh}.main{min-height:58vh}.chat-header{flex-direction:column;align-items:flex-start}.chat-actions{width:100%;justify-content:flex-start}.bubble{max-width:88%}.chat-input{padding:14px 14px 16px}.chat-compose{padding:10px;border-radius:18px}.chat-compose-bar{flex-direction:column;align-items:stretch}.compose-hint{white-space:normal;line-height:1.4}.chat-send-btn{width:100%}.dialog-card{width:min(94vw,420px);padding:20px 16px 16px}.dialog-actions{justify-content:stretch}.dialog-actions .btn{flex:1}}