:root{
  --g1:#00b14f; --g2:#00863b; --g3:#005c29;
  --bg:#f2f6f4; --card:#ffffff; --ink:#12241a; --muted:#6b7f74; --line:#e4ece7;
  --red:#e5484d; --amber:#f5a524; --blue:#2f7cf6;
  --radius:18px; --shadow:0 6px 24px rgba(0,60,30,.08);
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{font-family:'Poppins','Segoe UI',system-ui,-apple-system,Arial,sans-serif;background:var(--bg);color:var(--ink);font-size:14px;-webkit-font-smoothing:antialiased}
a{color:var(--g2);text-decoration:none}

/* ---------- Layout ---------- */
.app{display:flex;min-height:100vh}
.sidebar{width:250px;background:linear-gradient(180deg,var(--g3),var(--g2) 60%,var(--g1));color:#fff;padding:26px 18px;position:fixed;inset:0 auto 0 0;display:flex;flex-direction:column}
.brand{display:flex;align-items:center;gap:12px;padding:0 8px 26px}
.brand .logo{width:42px;height:42px;border-radius:13px;background:#fff;color:var(--g2);display:grid;place-items:center;font-weight:700;font-size:18px;box-shadow:0 4px 14px rgba(0,0,0,.2)}
.brand b{display:block;font-size:16px;line-height:1.1}
.brand small{opacity:.75;font-size:11px}
.nav a{display:flex;align-items:center;gap:13px;padding:13px 14px;border-radius:14px;color:rgba(255,255,255,.85);font-weight:500;margin-bottom:6px;transition:.2s}
.nav a svg{width:20px;height:20px;flex:none}
.nav a:hover{background:rgba(255,255,255,.12);color:#fff}
.nav a.active{background:#fff;color:var(--g2);box-shadow:0 6px 16px rgba(0,0,0,.18)}
.side-foot{margin-top:auto}
.side-foot a{display:flex;align-items:center;gap:12px;padding:12px 14px;border-radius:14px;color:#fff;background:rgba(255,255,255,.12)}
.side-foot svg{width:19px;height:19px}

.main{margin-left:250px;flex:1;padding:26px 34px 60px;min-width:0}
.topbar{display:flex;justify-content:space-between;align-items:center;margin-bottom:24px}
.topbar h1{margin:0;font-size:22px;font-weight:600}
.topbar p{margin:2px 0 0;color:var(--muted);font-size:13px}
.avatar{display:flex;align-items:center;gap:10px;background:var(--card);padding:6px 14px 6px 6px;border-radius:40px;box-shadow:var(--shadow)}
.avatar span.c{width:34px;height:34px;border-radius:50%;background:linear-gradient(135deg,var(--g1),var(--g3));color:#fff;display:grid;place-items:center;font-weight:600}
.avatar em{font-style:normal;font-weight:500;font-size:13px}

/* ---------- Cards ---------- */
.card{background:var(--card);border-radius:var(--radius);padding:22px 24px;box-shadow:var(--shadow);margin-bottom:22px}
.card h3{margin:0 0 16px;font-size:16px;font-weight:600}
.grid{display:grid;gap:18px}
.g4{grid-template-columns:repeat(4,1fr)}
.g2{grid-template-columns:1fr 1fr}
.hero-row{display:grid;grid-template-columns:1.5fr 1fr;gap:22px;margin-bottom:22px}

.hero{background:linear-gradient(135deg,var(--g1) 0%,var(--g2) 55%,var(--g3) 100%);color:#fff;border-radius:24px;padding:28px 30px;position:relative;overflow:hidden;box-shadow:0 14px 34px rgba(0,130,60,.35)}
.hero:before,.hero:after{content:"";position:absolute;border-radius:50%;background:rgba(255,255,255,.08)}
.hero:before{width:240px;height:240px;right:-70px;top:-90px}
.hero:after{width:170px;height:170px;right:70px;bottom:-100px}
.hero .lbl{opacity:.85;font-size:13px}
.hero .big{font-size:44px;font-weight:700;margin:6px 0 2px;letter-spacing:-1px}
.hero .sub{opacity:.85;font-size:13px}
.hero .chips{display:flex;gap:10px;margin-top:20px;flex-wrap:wrap;position:relative;z-index:1}
.chip{background:rgba(255,255,255,.16);padding:8px 14px;border-radius:30px;font-size:12.5px;backdrop-filter:blur(4px)}
.chip b{font-weight:600}

.quick{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;align-content:center}
.quick a{display:flex;flex-direction:column;align-items:center;gap:9px;padding:16px 6px;background:var(--card);border-radius:18px;box-shadow:var(--shadow);color:var(--ink);font-weight:500;font-size:12.5px;text-align:center;transition:.2s}
.quick a:hover{transform:translateY(-3px)}
.quick i{width:46px;height:46px;border-radius:15px;display:grid;place-items:center;background:#e6f7ed;color:var(--g2)}
.quick i svg{width:22px;height:22px}

.stat{display:flex;align-items:center;gap:14px}
.stat .ic{width:48px;height:48px;border-radius:15px;display:grid;place-items:center;flex:none}
.stat .ic svg{width:23px;height:23px}
.ic.green{background:#e6f7ed;color:var(--g2)} .ic.red{background:#fdeceb;color:var(--red)}
.ic.blue{background:#e9f1fe;color:var(--blue)} .ic.amber{background:#fef4e2;color:#c98207}
.stat .n{font-size:24px;font-weight:700;line-height:1.1}
.stat .t{color:var(--muted);font-size:12.5px}

/* ---------- Chart ---------- */
.chart{display:flex;align-items:flex-end;gap:12px;height:170px;padding-top:10px}
.bar{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;height:100%}
.bar div{width:100%;max-width:38px;border-radius:10px 10px 4px 4px;background:linear-gradient(180deg,var(--g1),var(--g2));min-height:4px}
.bar span{font-size:11px;color:var(--muted);margin-top:7px}
.bar em{font-style:normal;font-size:11px;font-weight:600;margin-bottom:4px}

/* ---------- Table / list ---------- */
.tbl{width:100%;border-collapse:collapse}
.tbl th{text-align:left;font-size:12px;color:var(--muted);font-weight:500;padding:10px 12px;border-bottom:1px solid var(--line);text-transform:uppercase;letter-spacing:.4px}
.tbl td{padding:14px 12px;border-bottom:1px solid var(--line);vertical-align:middle}
.tbl tr:last-child td{border-bottom:0}
.scroll{overflow-x:auto}
.pill{display:inline-block;padding:4px 12px;border-radius:20px;font-size:11.5px;font-weight:600}
.pill.sent,.pill.active{background:#e6f7ed;color:var(--g2)}
.pill.sending{background:#fef4e2;color:#a86a00}
.pill.draft{background:#eceff1;color:#546e7a}
.pill.unsubscribed,.pill.bounced{background:#fdeceb;color:var(--red)}
.empty{text-align:center;color:var(--muted);padding:26px}

/* ---------- Forms ---------- */
label{display:block;font-weight:500;font-size:13px;margin:0 0 7px}
input[type=text],input[type=email],input[type=password],input[type=file],input[type=search]{width:100%;padding:14px 16px;border:1.5px solid var(--line);border-radius:14px;font-size:14.5px;font-family:inherit;background:#fafcfb;outline:none;transition:.2s;color:var(--ink)}
input:focus{border-color:var(--g1);background:#fff;box-shadow:0 0 0 4px rgba(0,177,79,.12)}
.field{margin-bottom:16px}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:9px;background:linear-gradient(135deg,var(--g1),var(--g2));color:#fff;border:0;padding:14px 26px;border-radius:14px;font-size:14.5px;font-weight:600;font-family:inherit;cursor:pointer;box-shadow:0 8px 20px rgba(0,150,70,.3);transition:.2s}
.btn:hover{transform:translateY(-2px)}
.btn:disabled{opacity:.6;cursor:not-allowed;transform:none}
.btn.block{width:100%}
.btn.danger{background:#fdeceb;color:var(--red);box-shadow:none;padding:8px 14px;font-size:12.5px;border-radius:10px}
.btn svg{width:18px;height:18px}
.msg{padding:13px 16px;border-radius:14px;background:#e6f7ed;color:#0b6b36;margin-bottom:18px;font-size:13.5px}
.msg.err{background:#fdeceb;color:#a12a2e}
.hint{color:var(--muted);font-size:12.5px;margin-top:8px}
.warn{background:#fff8e6;color:#8a5a00;padding:12px 16px;border-radius:14px;font-size:12.5px;margin-top:18px}
.searchbar{display:flex;gap:10px;margin-bottom:16px}

/* ---------- Progress ---------- */
.progress{display:none;margin-top:22px}
.track{height:14px;background:#e6efe9;border-radius:10px;overflow:hidden}
.fill{height:100%;width:0;background:linear-gradient(90deg,var(--g1),var(--g2));border-radius:10px;transition:width .3s}
#ptext{margin-top:10px;font-size:13px;color:var(--muted)}
.ql-toolbar.ql-snow{border:1.5px solid var(--line)!important;border-radius:14px 14px 0 0;background:#fafcfb}
.ql-container.ql-snow{border:1.5px solid var(--line)!important;border-top:0!important;border-radius:0 0 14px 14px;font-family:inherit;font-size:14.5px}
#editor{height:260px}

/* ---------- Auth pages ---------- */
.auth{min-height:100vh;display:grid;place-items:center;padding:20px;background:linear-gradient(140deg,var(--g3),var(--g2) 50%,var(--g1))}
.auth .box{background:#fff;width:100%;max-width:400px;border-radius:26px;padding:38px 34px;box-shadow:0 30px 70px rgba(0,0,0,.3)}
.auth .logo{width:60px;height:60px;border-radius:18px;background:linear-gradient(135deg,var(--g1),var(--g3));color:#fff;display:grid;place-items:center;font-size:26px;font-weight:700;margin:0 auto 14px}
.auth h2{text-align:center;margin:0 0 4px;font-size:22px}
.auth p.s{text-align:center;color:var(--muted);margin:0 0 26px;font-size:13px}

/* ---------- Mobile ---------- */
.bottomnav{display:none}
@media(max-width:900px){
  .sidebar{display:none}
  .main{margin-left:0;padding:18px 16px 96px}
  .g4{grid-template-columns:1fr 1fr}
  .g2,.hero-row{grid-template-columns:1fr}
  .hero .big{font-size:36px}
  .avatar em{display:none}
  .bottomnav{display:flex;position:fixed;left:12px;right:12px;bottom:12px;background:#fff;border-radius:22px;box-shadow:0 10px 34px rgba(0,60,30,.22);padding:8px;z-index:50;justify-content:space-around}
  .bottomnav a{display:flex;flex-direction:column;align-items:center;gap:3px;font-size:10.5px;color:var(--muted);padding:7px 10px;border-radius:15px;font-weight:500}
  .bottomnav a svg{width:21px;height:21px}
  .bottomnav a.active{background:#e6f7ed;color:var(--g2)}
}

/* ---------- Chat ---------- */
.nbadge{background:#e5484d;color:#fff;border-radius:20px;font-size:11px;font-style:normal;font-weight:600;padding:1px 7px;margin-left:auto}
.bottomnav a{position:relative}
.bottomnav .nbadge{position:absolute;top:2px;right:4px;margin:0;padding:0 5px}
.btn.small{padding:7px 14px;font-size:12.5px;border-radius:10px;box-shadow:none}
.chat{display:grid;grid-template-columns:340px 1fr;gap:18px}
.chat-list,.chat-thread{padding:0;margin:0;height:calc(100vh - 150px);display:flex;flex-direction:column;overflow:hidden}
.chat-head{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:14px 18px;border-bottom:1px solid var(--line);background:#fff}
.chat-thread .chat-head{justify-content:flex-start}
.chat-head small{color:var(--muted)}
.back{display:none;font-size:20px;color:var(--g2);padding-right:4px}
.clist{overflow-y:auto;flex:1}
.ci{display:flex;align-items:center;gap:12px;padding:13px 16px;border-bottom:1px solid var(--line);color:var(--ink)}
.ci:hover,.ci.active{background:#f0f9f3}
.ci .av{width:42px;height:42px;border-radius:50%;background:linear-gradient(135deg,var(--g1),var(--g3));color:#fff;display:grid;place-items:center;font-weight:600;flex:none}
.ci .ct{flex:1;min-width:0}
.ci .ct b{display:block;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ci .ct em{display:block;font-style:normal;color:var(--muted);font-size:12.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ci .cm{display:flex;flex-direction:column;align-items:flex-end;gap:5px;font-size:11px;color:var(--muted)}
.ci .cm .nbadge{margin:0}
.msgs{flex:1;overflow-y:auto;padding:18px;background:#eef5f0;display:flex;flex-direction:column;gap:8px}
.b{max-width:78%;padding:10px 14px;border-radius:16px;font-size:14px;line-height:1.5;word-wrap:break-word;overflow-wrap:anywhere}
.b.in{background:#fff;align-self:flex-start;border-bottom-left-radius:4px}
.b.out{background:#d9f7e4;align-self:flex-end;border-bottom-right-radius:4px}
.b.camp{background:#c6ecd6}
.b .lbl{display:block;font-size:10.5px;font-weight:600;color:var(--g2);margin-bottom:3px;text-transform:uppercase;letter-spacing:.4px}
.b small{display:block;color:var(--muted);font-size:10.5px;margin-top:4px;text-align:right}
.replybox{display:flex;gap:10px;padding:12px;border-top:1px solid var(--line);background:#fff;align-items:flex-end}
.replybox textarea{flex:1;padding:12px 14px;border:1.5px solid var(--line);border-radius:14px;font-family:inherit;font-size:14.5px;resize:none;max-height:120px;outline:none}
.replybox textarea:focus{border-color:var(--g1)}
.cerr{background:#fdeceb;color:#a12a2e;padding:10px 16px;font-size:12.5px}
@media(max-width:900px){
  .chat{grid-template-columns:1fr}
  .chat-list,.chat-thread{height:calc(100vh - 230px)}
  .chat.has-thread .chat-list{display:none}
  .chat:not(.has-thread) .chat-thread{display:none}
  .back{display:block}
  .bottomnav a{padding:7px 6px;font-size:10px}
}
