:root{
  --bg:#0b141a;
  --panel:#111b21;
  --panel2:#202c33;
  --panel3:#182229;
  --line:#2a3942;
  --text:#e9edef;
  --muted:#8696a0;
  --green:#00a884;
  --green2:#005c4b;
  --danger:#ff5f5f;
  --bubble:#005c4b;
  --bubble-in:#202c33;
  --shadow:0 18px 50px rgba(0,0,0,.35);
}
*{box-sizing:border-box}
html,body{height:100%}
body{margin:0;background:var(--bg);color:var(--text);font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;overflow:hidden}
button,input,textarea,select{font:inherit}
button{border:0;cursor:pointer;color:var(--text)}
.hidden{display:none!important}
.login-screen{height:100%;display:grid;place-items:center;background:radial-gradient(circle at 20% 10%,rgba(0,168,132,.16),transparent 30%),var(--bg);padding:20px}
.login-card{width:min(420px,100%);background:rgba(17,27,33,.92);border:1px solid var(--line);border-radius:24px;padding:30px;box-shadow:var(--shadow)}
.login-mark{width:62px;height:62px;border-radius:22px;background:linear-gradient(135deg,var(--green),#02785f);display:grid;place-items:center;font-size:30px;font-weight:900;color:#fff;margin-bottom:18px}
.login-card h1{margin:0 0 8px;font-size:28px}
.login-card p{margin:0 0 22px;color:var(--muted);line-height:1.45}
.login-card label{display:block;margin:14px 0 8px;color:#b8c5cc;font-size:14px}
.login-card input{width:100%;height:48px;border-radius:14px;background:var(--panel2);border:1px solid transparent;color:var(--text);padding:0 16px;outline:0}
.login-card input:focus{border-color:var(--green)}
.primary{width:100%;height:48px;background:var(--green);border-radius:14px;margin-top:20px;font-weight:800;color:#06241d}
.login-card small{display:block;color:var(--danger);min-height:20px;margin-top:12px}
.app{height:100%;display:grid;grid-template-columns:410px 1fr;position:relative;background:var(--bg)}
.sidebar{height:100%;background:var(--panel);border-right:1px solid var(--line);display:flex;flex-direction:column;min-width:0}
.side-head,.chat-head{height:64px;background:var(--panel2);display:flex;align-items:center;padding:0 14px;gap:12px;flex-shrink:0}
.me{display:flex;align-items:center;gap:12px;min-width:0;flex:1}
.me b,.chat-title b{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:16px}
.me span,.chat-title span{display:block;color:var(--muted);font-size:12px;margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.avatar{width:42px;height:42px;border-radius:50%;background:linear-gradient(135deg,#4a3d1e,#1f2e37);display:grid;place-items:center;font-weight:800;flex-shrink:0;color:#f4f4f4;overflow:hidden}
.head-actions{display:flex;gap:8px}
.head-actions button,.back,.mini,.drawer header button{height:38px;min-width:38px;border-radius:12px;background:transparent;color:#d1d7db;font-weight:700}
.head-actions button:hover,.back:hover,.mini:hover,.drawer header button:hover{background:rgba(255,255,255,.08)}
.search-wrap{padding:10px 12px;background:var(--panel)}
.search-wrap input{width:100%;height:42px;border-radius:22px;background:var(--panel2);border:0;outline:0;color:var(--text);padding:0 18px;font-size:15px}
.chat-list{overflow:auto;flex:1;padding-bottom:76px}
.chat-item{height:76px;display:grid;grid-template-columns:54px 1fr auto;gap:12px;align-items:center;padding:0 12px;cursor:pointer;border-bottom:1px solid rgba(42,57,66,.45)}
.chat-item:hover,.chat-item.active{background:var(--panel3)}
.chat-main{min-width:0}
.chat-row{display:flex;justify-content:space-between;gap:8px;min-width:0}
.chat-row b{font-size:16px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-row time{font-size:12px;color:var(--muted);white-space:nowrap}
.chat-sub{display:flex;align-items:center;gap:6px;color:var(--muted);font-size:14px;margin-top:4px;min-width:0}
.chat-sub span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.badge{min-width:22px;height:22px;border-radius:14px;background:#25d366;color:#06241d;display:grid;place-items:center;padding:0 6px;font-weight:900;font-size:12px}
.status-dot{width:8px;height:8px;border-radius:50%;background:var(--green);display:inline-block;flex-shrink:0}
.status-dot.off{background:#6b7680}
.bottom-nav{position:absolute;bottom:0;left:0;width:410px;height:66px;background:rgba(17,27,33,.97);border-top:1px solid var(--line);display:grid;grid-template-columns:repeat(3,1fr);z-index:4}
.bottom-nav button{background:transparent;color:var(--muted);font-weight:700}
.bottom-nav button.active{color:var(--text);position:relative}
.bottom-nav button.active:before{content:"";position:absolute;left:24%;right:24%;top:10px;height:4px;border-radius:4px;background:var(--green)}
.chat-panel{height:100%;display:flex;flex-direction:column;min-width:0;background:var(--bg);position:relative}
.chat-panel:before{content:"";position:absolute;inset:0;background-image:radial-gradient(circle at 20px 20px,rgba(255,255,255,.035) 1px,transparent 1.5px);background-size:42px 42px;opacity:.65;pointer-events:none}
.chat-head{position:relative;z-index:2;border-bottom:1px solid var(--line)}
.chat-title{min-width:0;flex:1}
.back{display:none;font-size:24px}
.mini{background:var(--panel3);padding:0 12px;color:#d7dee2}
.danger{color:#ffb4b4;background:rgba(255,95,95,.08)}
.empty-state{position:relative;z-index:1;max-width:520px;margin:auto;text-align:center;color:var(--muted);padding:30px}
.empty-icon{width:92px;height:92px;border-radius:34px;background:rgba(255,255,255,.05);display:grid;place-items:center;margin:0 auto 16px;font-size:40px;color:#d6dfe3}
.empty-state h2{margin:0 0 8px;color:#dce4e8}
.empty-state p{margin:0;line-height:1.5}
.messages{position:relative;z-index:1;flex:1;overflow:auto;padding:18px 8% 22px;display:flex;flex-direction:column;gap:6px}
.msg{max-width:min(68%,760px);padding:8px 10px 6px;border-radius:10px;background:var(--bubble-in);align-self:flex-start;box-shadow:0 1px 0 rgba(0,0,0,.18);white-space:pre-wrap;word-wrap:break-word;line-height:1.42;font-size:15px;position:relative}
.msg.out{background:var(--bubble);align-self:flex-end;border-top-right-radius:3px}
.msg.in{border-top-left-radius:3px}
.msg.deleted{opacity:.58;font-style:italic}
.msg.filtered:before{content:"Terfilter";display:inline-block;font-size:11px;color:#1d1616;background:#ffd166;border-radius:10px;padding:2px 8px;margin-bottom:5px;font-weight:800}
.msg-meta{display:flex;justify-content:flex-end;gap:6px;align-items:center;color:rgba(233,237,239,.65);font-size:11px;margin-top:3px}
.msg-admin{font-size:11px;color:#b6d7ce;margin-top:5px;text-align:right}
.reply-box{position:relative;z-index:2;min-height:64px;background:var(--panel2);display:flex;align-items:center;gap:10px;padding:10px 14px}
.reply-box input{height:44px;flex:1;border:0;outline:0;border-radius:24px;background:#2a3942;color:var(--text);padding:0 18px}
.reply-box button{height:44px;border-radius:24px;padding:0 18px;background:var(--green);color:#06241d;font-weight:900}
.drawer{position:absolute;right:0;top:0;width:min(420px,100%);height:100%;background:var(--panel);border-left:1px solid var(--line);box-shadow:var(--shadow);z-index:20;display:flex;flex-direction:column}
.drawer header{height:64px;background:var(--panel2);display:flex;align-items:center;justify-content:space-between;padding:0 16px;flex-shrink:0}
.drawer-body{overflow:auto;padding:16px;display:flex;flex-direction:column;gap:14px}
.card{background:var(--panel2);border:1px solid var(--line);border-radius:18px;padding:16px}
.card h3{margin:0 0 14px;font-size:17px}
.grid{display:grid;grid-template-columns:repeat(2,1fr);gap:10px}
.stat{background:rgba(255,255,255,.04);border-radius:14px;padding:12px}
.stat b{display:block;font-size:24px;color:#fff}.stat span{font-size:12px;color:var(--muted)}
.field{display:flex;flex-direction:column;gap:7px;margin-bottom:12px}.field label{color:#b8c5cc;font-size:13px}
.field input,.field textarea,.field select{width:100%;border:1px solid transparent;border-radius:13px;background:#2a3942;color:var(--text);outline:0;padding:12px}.field textarea{min-height:90px;resize:vertical}
.field input:focus,.field textarea:focus,.field select:focus{border-color:var(--green)}
.switch-row{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px 0;border-bottom:1px solid rgba(255,255,255,.06)}
.switch-row:last-child{border-bottom:0}.switch-row span{color:#d9e0e3}.switch-row small{display:block;color:var(--muted);font-size:12px;margin-top:2px}
.switch{width:48px;height:28px;border-radius:20px;background:#3b4a54;position:relative;flex-shrink:0}.switch.on{background:var(--green)}.switch:after{content:"";position:absolute;width:22px;height:22px;border-radius:50%;background:#fff;top:3px;left:3px;transition:.16s}.switch.on:after{left:23px}
.row-actions{display:flex;gap:8px;flex-wrap:wrap}.row-actions button,.small-btn{background:var(--green2);border-radius:12px;height:38px;padding:0 12px;color:#dff7f0;font-weight:700}.row-actions .ghost,.small-btn.ghost{background:#2a3942;color:#dce4e8}.row-actions .red,.small-btn.red{background:rgba(255,95,95,.13);color:#ffb4b4}
.admin-row{display:flex;justify-content:space-between;gap:10px;align-items:center;padding:10px 0;border-bottom:1px solid rgba(255,255,255,.06)}.admin-row:last-child{border-bottom:0}.admin-row small{color:var(--muted)}
.toast{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);background:#23333b;color:#fff;border:1px solid var(--line);box-shadow:var(--shadow);padding:12px 16px;border-radius:14px;z-index:100;max-width:90%;text-align:center}
.code-box{font-size:30px;font-weight:900;text-align:center;letter-spacing:8px;background:#0b141a;border:1px dashed var(--green);border-radius:18px;padding:18px;margin-top:8px;color:#eafff8}
@media(max-width:820px){
  .app{grid-template-columns:1fr}.sidebar{width:100%;border-right:0}.bottom-nav{width:100%}.chat-panel{position:absolute;inset:0;z-index:10;transform:translateX(100%);transition:.22s ease}.chat-panel.open{transform:translateX(0)}.back{display:grid;place-items:center}.messages{padding:14px 10px 18px}.msg{max-width:84%}.drawer{width:100%;border-left:0}.grid{grid-template-columns:1fr 1fr}
}
.mini-primary{width:auto;margin-top:18px;padding:0 18px;display:inline-flex;align-items:center;justify-content:center}
.notice{background:rgba(255,255,255,.05);border:1px dashed var(--line);border-radius:16px;padding:14px;color:var(--muted);line-height:1.5;margin-top:10px}
.error-text{color:#ffb4b4;background:rgba(255,95,95,.08);border:1px solid rgba(255,95,95,.18);padding:10px 12px;border-radius:12px;line-height:1.45}
.steps{margin:14px 0 0;padding-left:22px;color:var(--muted);line-height:1.7}
.full{width:100%;margin-top:10px}
.wa-card h3{display:flex;align-items:center;gap:8px}
.notice.danger { border-color: rgba(255, 190, 80, .35); color: #ffd9a0; background: rgba(255, 190, 80, .08); }
