:root {
  --bg: #09090b;
  --panel: #0f0f12;
  --card: #141418;
  --card-hover: #1a1a1f;
  --line: #1e1e24;
  --line-light: #2a2a32;
  --text: #e8e8ed;
  --text-secondary: #a1a1aa;
  --muted: #71717a;
  --dim: #52525b;
  --accent: #f4f4f5;
  --good: #22c55e;
  --good-bg: rgba(34,197,94,.08);
  --good-border: rgba(34,197,94,.2);
  --warn: #f59e0b;
  --warn-bg: rgba(245,158,11,.08);
  --warn-border: rgba(245,158,11,.2);
  --bad: #ef4444;
  --bad-bg: rgba(239,68,68,.08);
  --bad-border: rgba(239,68,68,.2);
  --blue: #3b82f6;
  --blue-bg: rgba(59,130,246,.08);
  --blue-border: rgba(59,130,246,.2);
  --purple: #a78bfa;
  --purple-bg: rgba(167,139,250,.08);
  --purple-border: rgba(167,139,250,.2);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
[hidden] { display: none !important; }
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; transition: all .15s ease; }
::selection { background: rgba(59,130,246,.3); }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2a32; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a42; }

/* ---- LOGIN ---- */
.login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, rgba(59,130,246,.04) 0%, transparent 60%);
}
.login-card { width: 340px; text-align: center; }
.login-mark {
  width: 52px; height: 52px; border-radius: 14px;
  background: #3b82f6;
  display: grid; place-items: center;
  margin: 0 auto 20px;
  color: #fff; box-shadow: var(--shadow);
}
.login-mark svg { width: 26px; height: 26px; display: block; }
.login-card h1 { font-size: 24px; font-weight: 600; letter-spacing: -.4px; color: var(--text); }
.login-card p { color: var(--muted); margin: 8px 0 24px; font-size: 14px; }
.login-card input {
  width: 100%; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px; outline: none; margin-bottom: 12px;
  font-size: 14px; transition: border-color .15s;
}
.login-card input:focus { border-color: var(--blue); }
.login-card button, .btn-primary {
  width: 100%; background: var(--blue); color: #fff; border: 0;
  border-radius: var(--radius-sm); padding: 11px 16px; font-weight: 600; font-size: 14px;
}
.login-card button:hover, .btn-primary:hover { background: #2563eb; }
.err { color: var(--bad); margin-top: 12px; font-size: 13px; }

/* ---- LAYOUT ---- */
#app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

/* ---- SIDEBAR ---- */
.side {
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px 16px; font-weight: 600; font-size: 15px;
  border-bottom: 1px solid var(--line);
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: #3b82f6;
  display: grid; place-items: center;
  color: #fff; flex-shrink: 0;
}
.brand-mark svg { width: 18px; height: 18px; display: block; }
.brand-name { white-space: nowrap; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; padding: 12px 10px; }
.nav-group { padding: 16px 8px 6px; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; color: var(--dim); }
.nav-group:first-child { padding-top: 4px; }
.nav {
  background: none; border: 0; text-align: left; color: var(--muted);
  padding: 8px 10px; border-radius: var(--radius-xs); display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 500;
}
.nav svg { width: 16px; height: 16px; opacity: .5; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav:hover { background: rgba(255,255,255,.04); color: var(--text); }
.nav:hover svg { opacity: .7; }
.nav.on { background: rgba(59,130,246,.1); color: var(--blue); }
.nav.on svg { opacity: 1; }
.side-foot {
  display: flex; align-items: center; gap: 8px; color: var(--dim);
  padding: 14px 18px; border-top: 1px solid var(--line); font-size: 12px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 6px rgba(34,197,94,.4); }
.dot.off { background: var(--bad); box-shadow: 0 0 6px rgba(239,68,68,.4); }

/* ---- MAIN ---- */
.main { padding: 28px 36px; overflow-y: auto; min-height: 100vh; }
.page { display: none; animation: fadeIn .2s ease; }
.page.on { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.page-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.page-h h2 { font-size: 22px; font-weight: 600; letter-spacing: -.3px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; }

/* ---- BUTTONS ---- */
.ghost {
  background: transparent; border: 1px solid var(--line); color: var(--text-secondary);
  padding: 7px 14px; border-radius: var(--radius-xs); font-size: 12px; font-weight: 500;
}
.ghost:hover { background: rgba(255,255,255,.04); border-color: var(--line-light); color: var(--text); }
.solid {
  background: var(--blue); color: #fff; border: 0;
  border-radius: var(--radius-xs); padding: 9px 18px; font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
}
.solid:hover { background: #2563eb; }
.file-btn {
  display: inline-flex; align-items: center; cursor: pointer;
  background: transparent; border: 1px solid var(--line); color: var(--text-secondary);
  padding: 7px 14px; border-radius: var(--radius-xs); font-size: 12px; font-weight: 500;
}
.file-btn:hover { background: rgba(255,255,255,.04); border-color: var(--line-light); }
.file-btn input { display: none; }
.btn-danger {
  background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad-border);
  padding: 7px 14px; border-radius: var(--radius-xs); font-size: 12px; font-weight: 500;
}
.btn-danger:hover { background: rgba(239,68,68,.15); }

/* ---- STAT CARDS ---- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px 16px; position: relative; overflow: hidden; transition: border-color .15s;
}
.stat:hover { border-color: var(--line-light); }
.stat b { display: block; font-size: 30px; font-weight: 700; letter-spacing: -.8px; line-height: 1.1; margin-bottom: 4px; }
.stat span { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .3px; }
.stat .stat-icon {
  position: absolute; top: 16px; right: 16px; width: 36px; height: 36px;
  border-radius: 9px; display: grid; place-items: center;
}
.stat .stat-icon svg { width: 18px; height: 18px; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.stat.orange b { color: var(--warn); }
.stat.orange .stat-icon { background: var(--warn-bg); }
.stat.orange .stat-icon svg { stroke: var(--warn); }
.stat.green b { color: var(--good); }
.stat.green .stat-icon { background: var(--good-bg); }
.stat.green .stat-icon svg { stroke: var(--good); }
.stat.red b { color: var(--bad); }
.stat.red .stat-icon { background: var(--bad-bg); }
.stat.red .stat-icon svg { stroke: var(--bad); }
.stat.blue b { color: var(--blue); }
.stat.blue .stat-icon { background: var(--blue-bg); }
.stat.blue .stat-icon svg { stroke: var(--blue); }
.stat.purple b { color: var(--purple); }
.stat.purple .stat-icon { background: var(--purple-bg); }
.stat.purple .stat-icon svg { stroke: var(--purple); }

/* ---- CARDS ---- */
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 14px;
}
.card h3 {
  font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 14px;
  text-transform: uppercase; letter-spacing: .5px;
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* ---- DEVICES ---- */
.device {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; transition: border-color .15s;
}
.device:hover { border-color: var(--line-light); }
.device.online { border-left: 3px solid var(--good); }
.device.offline { border-left: 3px solid var(--dim); }
.device .top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.device .top b { font-size: 14px; }
.device .dev-model { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; text-align: center; }
.nums > div { background: rgba(255,255,255,.02); border-radius: var(--radius-xs); padding: 8px 4px; }
.nums b { display: block; font-size: 18px; font-weight: 600; }
.nums span { color: var(--dim); font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: .3px; }
.device .dev-actions { display: flex; gap: 8px; margin-top: 4px; }
.device .dev-actions .ghost { flex: 1; text-align: center; }

/* ---- FORMS ---- */
label { display: block; color: var(--text-secondary); font-size: 12px; font-weight: 500; margin-bottom: 12px; }
input, select, textarea {
  width: 100%; margin-top: 6px; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius-xs); padding: 9px 12px; outline: none; font-size: 13px;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); }
select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2371717a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px;
}
textarea { resize: vertical; min-height: 60px; }
.row3, .row4 { display: grid; gap: 12px; }
.row3 { grid-template-columns: 1fr 1fr auto; align-items: end; }
.row4 { grid-template-columns: 1.2fr .9fr .9fr .9fr; }
.form .solid { margin-top: 6px; }

/* ---- SWITCH ---- */
.sw { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 500; }
.sw input { display: none; width: auto; margin: 0; }
.sw span {
  width: 38px; height: 22px; background: #27272a; border-radius: 11px; position: relative;
  transition: background .2s; flex-shrink: 0;
}
.sw span:after {
  content: ""; width: 16px; height: 16px; background: #71717a; border-radius: 50%;
  position: absolute; top: 3px; left: 3px; transition: .2s;
}
.sw input:checked + span { background: var(--good); }
.sw input:checked + span:after { left: 19px; background: #fff; }

/* ---- TABLES ---- */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; color: var(--dim); font-size: 11px; font-weight: 600;
  padding: 10px 10px; border-bottom: 1px solid var(--line); text-transform: uppercase; letter-spacing: .5px;
}
td {
  padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle;
  word-break: break-word; font-size: 13px;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.toolbar input { width: 200px; margin: 0; }
.toolbar span { font-size: 13px; color: var(--muted); font-weight: 500; }

/* ---- PILLS ---- */
.pill {
  font-size: 11px; padding: 3px 10px; border-radius: 99px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px; letter-spacing: .2px;
}
.pill.on, .status-sent { background: var(--good-bg); color: var(--good); border: 1px solid var(--good-border); }
.pill.off, .status-failed { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad-border); }
.status-pending { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-border); }
.status-retrying { background: var(--purple-bg); color: var(--purple); border: 1px solid var(--purple-border); }
.status-queued { background: var(--blue-bg); color: var(--blue); border: 1px solid var(--blue-border); }
.status-cancelled { background: rgba(113,113,122,.08); color: var(--muted); border: 1px solid var(--line-light); }
.dev-tag { display: block; font-size: 10px; color: var(--dim); font-weight: 500; }
.msg-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.msg-actions .ghost { padding: 4px 10px; font-size: 11px; }

/* ---- DANGER ZONE ---- */
.danger-zone { display: flex; flex-direction: column; gap: 8px; }
.danger-zone .btn-danger { text-align: left; padding: 9px 14px; }
.danger-big {
  margin-top: 6px; padding: 12px 14px !important; font-weight: 700 !important;
  background: rgba(239,68,68,.15) !important; border-width: 2px !important;
}
.icon-btn {
  background: none; border: 1px solid var(--line); color: var(--muted);
  width: 30px; height: 30px; border-radius: var(--radius-xs); display: inline-grid; place-items: center;
  font-size: 14px;
}
.icon-btn:hover { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-border); }

/* ---- MESSAGE LISTS ---- */
.msg-list, .mini-list { display: flex; flex-direction: column; gap: 6px; }
.msg {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; display: grid; grid-template-columns: 80px 130px 1fr auto auto;
  gap: 12px; align-items: center; transition: border-color .15s;
}
.msg:hover { border-color: var(--line-light); }
.msg .msg-time { color: var(--dim); font-size: 12px; font-weight: 500; }
.phone { color: var(--blue); font-weight: 600; font-size: 13px; }
.msg .msg-body { color: var(--text-secondary); font-size: 13px; }

.mini {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 14px; display: flex; align-items: center; gap: 10px; font-size: 13px;
  transition: border-color .15s;
}
.mini:hover { border-color: var(--line-light); }
.mini .phone { font-size: 13px; }
.mini .mini-body { color: var(--text-secondary); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- API ---- */
pre {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 18px; white-space: pre-wrap; color: var(--text-secondary); font-size: 13px;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace; line-height: 1.6;
}

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center; padding: 40px 20px; color: var(--muted);
}
.empty-state svg { width: 40px; height: 40px; stroke: var(--dim); margin-bottom: 12px; }
.empty-state p { font-size: 13px; }

/* ---- DASHBOARD EXTRAS ---- */
.stat .stat-sub { color: var(--dim); font-size: 11px; margin-top: 6px; }
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-bottom: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card-head h3 { margin-bottom: 0; }
.legend { display: flex; gap: 14px; font-size: 11px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.lg { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.lg-blue { background: var(--blue); }
.lg-green { background: var(--good); }
canvas#dash-chart { display: block; width: 100%; }

/* ---- DONUT ---- */
.donut-wrap { display: flex; align-items: center; gap: 20px; padding: 8px 0; }
.donut-box { position: relative; flex-shrink: 0; }
.donut-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none;
}
.donut-center b { font-size: 22px; font-weight: 700; letter-spacing: -.5px; }
.donut-center span { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .5px; }
.donut-legend { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.dl-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dl-row i { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dl-row span { color: var(--text-secondary); flex: 1; }
.dl-row b { font-weight: 600; }

/* ---- AVATARS ---- */
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--blue) 0%, #6366f1 100%);
  color: #fff; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
}
.mini-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mini { cursor: pointer; }
.mini .phone { display: block; }

/* ---- CONVERSATIONS ---- */
.convo-layout { display: grid; grid-template-columns: 320px 1fr; gap: 14px; }
.convo-list-card { margin-bottom: 0; padding: 14px; max-height: calc(100vh - 160px); overflow-y: auto; }
.convo-list { display: flex; flex-direction: column; gap: 4px; }
.convo {
  display: flex; align-items: center; gap: 10px; padding: 10px;
  border-radius: var(--radius-sm); cursor: pointer; border: 1px solid transparent;
  transition: background .12s;
}
.convo:hover { background: rgba(255,255,255,.03); }
.convo.on { background: rgba(59,130,246,.08); border-color: var(--blue-border); }
.convo-main { flex: 1; min-width: 0; }
.convo-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.convo-top b { font-size: 13px; font-weight: 600; }
.convo-prev {
  color: var(--muted); font-size: 12px; display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px;
}
.convo-n {
  background: var(--blue-bg); color: var(--blue); border: 1px solid var(--blue-border);
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 99px; flex-shrink: 0;
}

/* ---- THREAD ---- */
.thread-card { margin-bottom: 0; padding: 0; display: flex; flex-direction: column; max-height: calc(100vh - 160px); }
.thread-head {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  font-size: 14px; font-weight: 600; color: var(--text);
}
.thread { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.bub { max-width: 70%; }
.bub.in { align-self: flex-start; }
.bub.out { align-self: flex-end; }
.bub-body {
  padding: 10px 14px; border-radius: 14px; font-size: 13px; line-height: 1.45;
  word-break: break-word;
}
.bub.in .bub-body { background: #1c1c22; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bub.out .bub-body { background: rgba(59,130,246,.15); border: 1px solid var(--blue-border); border-bottom-right-radius: 4px; }
.bub-meta { display: block; font-size: 10px; color: var(--dim); margin-top: 4px; }
.bub.out .bub-meta { text-align: right; }
.thread-compose {
  display: flex; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line);
}
.thread-compose input { margin: 0; flex: 1; }
.thread-compose .solid { margin: 0; }

/* ---- TOASTS ---- */
#toasts {
  position: fixed; top: 20px; right: 20px; z-index: 999;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line-light); border-radius: var(--radius-sm);
  padding: 11px 16px; font-size: 13px; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(8px); transition: all .25s ease;
  max-width: 340px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.toast.info .toast-dot { background: var(--blue); }
.toast.ok .toast-dot { background: var(--good); }
.toast.error .toast-dot { background: var(--bad); }

/* ---- RESPONSIVE ---- */
@media (max-width: 1200px) {
  .dash-grid, .convo-layout { grid-template-columns: 1fr; }
  .convo-list-card, .thread-card { max-height: none; }
  .thread { min-height: 300px; }
}
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .row4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 980px) {
  #app { display: flex; flex-direction: column; min-height: 100vh; }
  .side {
    display: flex; flex-direction: row; align-items: center; width: auto; height: auto;
    border-right: 0; border-bottom: 1px solid var(--line);
    overflow-x: auto; overflow-y: hidden; position: sticky; top: 0; z-index: 20;
    scrollbar-width: none;
  }
  .side::-webkit-scrollbar { display: none; }
  .side .brand { padding: 10px 12px; border-bottom: 0; border-right: 1px solid var(--line); flex-shrink: 0; }
  .side .brand span:last-child { display: none; }
  .side nav { flex-direction: row; padding: 6px; gap: 2px; flex: none; }
  .nav-group { display: none; }
  .nav { white-space: nowrap; }
  .nav svg { display: none; }
  .side-foot { border-top: 0; border-left: 1px solid var(--line); padding: 10px 12px; margin-left: auto; }
  .stats, .two, .row3, .row4 { grid-template-columns: 1fr; }
  .msg { grid-template-columns: 1fr; gap: 6px; }
  .main { padding: 20px 16px; min-height: 0; }
}

/* ---- THEME TOGGLE ---- */
.theme-btn {
  margin-left: auto; background: none; border: 0; color: var(--dim);
  width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center;
}
.theme-btn:hover { color: var(--text); background: rgba(128,128,140,.12); }
.theme-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
html[data-theme="light"] .theme-btn svg { fill: none; }

/* ---- QR MODAL ---- */
.qr-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; z-index: 60;
}
.qr-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px; width: 320px; text-align: center; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 12px; align-items: center;
}
.qr-card h3 { font-size: 15px; font-weight: 600; }
.qr-card img { width: 220px; height: 220px; border-radius: 10px; background: #fff; padding: 10px; }
.qr-link {
  font-size: 11px; color: var(--muted); word-break: break-all;
  background: var(--bg); padding: 8px 10px; border-radius: var(--radius-xs); width: 100%;
}
.qr-actions { display: flex; gap: 8px; width: 100%; justify-content: center; }

/* ---- LIGHT THEME ---- */
html[data-theme="light"] {
  --bg: #f5f5f7;
  --panel: #ffffff;
  --card: #ffffff;
  --card-hover: #f7f7fa;
  --line: #e4e4e9;
  --line-light: #d3d3da;
  --text: #1d1d1f;
  --text-secondary: #48484f;
  --muted: #6e6e78;
  --dim: #a1a1aa;
  --accent: #0a84ff;
  --good: #16a34a;
  --good-bg: rgba(22,163,74,.09);
  --good-border: rgba(22,163,74,.3);
  --warn: #d97706;
  --warn-bg: rgba(217,119,6,.09);
  --warn-border: rgba(217,119,6,.3);
  --bad: #dc2626;
  --bad-bg: rgba(220,38,38,.09);
  --bad-border: rgba(220,38,38,.3);
  --blue: #0a84ff;
  --blue-bg: rgba(10,132,255,.09);
  --blue-border: rgba(10,132,255,.3);
  --purple: #7c3aed;
  --purple-bg: rgba(124,58,237,.09);
  --purple-border: rgba(124,58,237,.3);
  --shadow: 0 1px 3px rgba(0,0,0,.07);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12);
}
html[data-theme="light"] ::-webkit-scrollbar-thumb { background: #d3d3da; }
html[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #b8b8c2; }
html[data-theme="light"] ::selection { background: rgba(10,132,255,.25); }
html[data-theme="light"] .login { background: var(--bg); }
html[data-theme="light"] .login-mark { background: #0a84ff; }
html[data-theme="light"] .nav:hover,
html[data-theme="light"] .ghost:hover,
html[data-theme="light"] .file-btn:hover { background: rgba(0,0,0,.045); }
html[data-theme="light"] .nav.on { background: rgba(10,132,255,.1); }
html[data-theme="light"] .nums > div { background: rgba(0,0,0,.028); }
html[data-theme="light"] tr:hover td { background: rgba(0,0,0,.02); }
html[data-theme="light"] .convo:hover { background: rgba(0,0,0,.03); }
html[data-theme="light"] .convo.on { background: rgba(10,132,255,.08); }
html[data-theme="light"] .bub.in .bub-body { background: #e9e9ec; border-color: transparent; }
html[data-theme="light"] .sw span { background: #e4e4e9; }
html[data-theme="light"] .sw span:after { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
html[data-theme="light"] .solid:hover { background: #0077e0; }
html[data-theme="light"] .icon-btn:hover { background: rgba(0,0,0,.05); }
html[data-theme="light"] .dot { box-shadow: none; }
html[data-theme="light"] .dot.off { box-shadow: none; }

/* ---- DEVICE TELEMETRY ---- */
.dev-tel { display: flex; gap: 6px; margin: 4px 0 12px; flex-wrap: wrap; }
.tel {
  font-size: 11px; color: var(--muted); background: var(--bg);
  border: 1px solid var(--line); padding: 2px 8px; border-radius: 99px;
}
.tel-bad { color: var(--bad); border-color: var(--bad-border); background: var(--bad-bg); }

/* campaign modal checkboxes — override global input{width:100%} */
#camp-modal input[type="checkbox"], #lead-modal input[type="checkbox"] {
  width: auto !important; margin: 0 !important; flex-shrink: 0;
}
#camp-modal label { display: flex; align-items: center; gap: 8px; margin-bottom: 0; cursor: pointer; }
#camp-modal .camp-lbl { display: block; color: var(--dim); font-size: 12px; font-weight: 600; margin-bottom: 8px; text-transform: uppercase; letter-spacing: .4px; cursor: default; }
#camp-modal { left: 0; top: 0; }

/* ─── collapsible sidebar (icon-only) ─── */
#nav-toggle { background: none; border: 1px solid var(--line-light); border-radius: 6px; color: var(--dim);
  width: 24px; height: 24px; display: grid; place-items: center; cursor: pointer; font-size: 13px; flex-shrink: 0; margin-left: auto; }
#nav-toggle:hover { color: var(--text); border-color: var(--dim); }
body.nav-collapsed #app { grid-template-columns: 66px 1fr; }
body.nav-collapsed .brand { font-size: 0; justify-content: center; padding: 20px 8px 16px; }
body.nav-collapsed .brand-name { display: none; }
body.nav-collapsed .brand-mark { width: 28px; height: 28px; }
body.nav-collapsed .nav-group { display: none; }
body.nav-collapsed .nav { font-size: 0; gap: 0; justify-content: center; padding: 10px 0; }
body.nav-collapsed .nav svg { width: 19px; height: 19px; }
body.nav-collapsed .side-foot { font-size: 0; justify-content: center; gap: 10px; }
body.nav-collapsed #nav-toggle { margin-left: 0; }
body.nav-collapsed .brand { flex-wrap: wrap; gap: 8px; }

/* ---- SMTP PAGE ---- */
.badge {
  font-size: 10px; padding: 3px 9px; border-radius: 99px; font-weight: 700;
  letter-spacing: .4px; text-transform: uppercase; display: inline-flex;
  align-items: center; gap: 5px; white-space: nowrap;
}
.badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-good { background: var(--good-bg); color: var(--good); border: 1px solid var(--good-border); }
.b-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-border); }
.b-bad { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad-border); }
.b-dim { background: rgba(113,113,122,.1); color: var(--muted); border: 1px solid var(--line-light); }
.b-blue { background: var(--blue-bg); color: var(--blue); border: 1px solid var(--blue-border); }
.b-purple { background: var(--purple-bg); color: var(--purple); border: 1px solid var(--purple-border); }

.smtp-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.smtp-stats .stat { padding: 14px 16px; }
.smtp-stats .stat b { font-size: 24px; }

.smtp-card { border-left: 3px solid var(--dim); margin-bottom: 0; }
.smtp-card.lvl-ok { border-left-color: var(--good); }
.smtp-card.lvl-warn { border-left-color: var(--warn); }
.smtp-card.lvl-bad { border-left-color: var(--bad); }
.smtp-card.lvl-off { border-left-color: var(--dim); opacity: .72; }
.smtp-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.smtp-name { font-size: 14px; font-weight: 600; letter-spacing: -.1px; }
.smtp-host { color: var(--muted); font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; margin-top: 3px; }
.smtp-from { color: var(--text-secondary); font-size: 12px; margin-top: 6px; }
.smtp-from b { color: var(--text); font-weight: 600; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip {
  font-size: 10px; padding: 3px 8px; border-radius: 6px; font-weight: 600;
  background: rgba(255,255,255,.04); border: 1px solid var(--line); color: var(--text-secondary);
}
.chip.c-purple { color: var(--purple); border-color: var(--purple-border); background: var(--purple-bg); }
.chip.c-blue { color: var(--blue); border-color: var(--blue-border); background: var(--blue-bg); }
.chip.c-warn { color: var(--warn); border-color: var(--warn-border); background: var(--warn-bg); }

.smtp-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; text-align: center; }
.smtp-nums > div { background: rgba(255,255,255,.02); border-radius: var(--radius-xs); padding: 8px 4px; }
.smtp-nums b { display: block; font-size: 17px; font-weight: 700; }
.smtp-nums span { color: var(--dim); font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.smtp-nums .v-ok { color: var(--good); }
.smtp-nums .v-bad { color: var(--bad); }

.smtp-foot { display: flex; gap: 8px; margin-top: 4px; }
.smtp-foot .ghost { flex: 1; text-align: center; padding: 6px 8px; font-size: 11px; }
.smtp-foot .del { color: var(--bad); }
.smtp-foot .del:hover { background: var(--bad-bg); border-color: var(--bad-border); }

.tpl-card .tpl-subj { color: var(--text-secondary); font-size: 12px; margin-top: 4px; }
.tpl-card .tpl-snip { color: var(--dim); font-size: 11px; margin-top: 8px; line-height: 1.4; }

/* segmented channel picker (campaign modal) */
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }
.seg button {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; text-align: left; color: var(--muted);
}
.seg button b { font-size: 13px; font-weight: 600; color: var(--text-secondary); display: flex; gap: 7px; align-items: center; }
.seg button small { font-size: 11px; margin-top: 2px; display: block; }
.seg button.on { border-color: var(--blue); background: var(--blue-bg); }
.seg button.on b { color: var(--blue); }

/* checkbox picker rows (campaign modal) */
.pick { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 7px 10px;
  border: 1px solid var(--line-light); border-radius: 8px; margin-bottom: 6px; cursor: pointer; }
.pick:hover { border-color: var(--blue); }
.pick input { width: auto; margin: 0; }
.pick .hdot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* ---- NAV: counts + locked perms ---- */
.nav { position: relative; }
.nav-count {
  margin-left: auto; font-size: 10px; font-weight: 700; color: var(--dim);
  background: rgba(255,255,255,.04); border: 1px solid var(--line);
  border-radius: 99px; padding: 1px 7px; min-width: 18px; text-align: center;
}
.nav-count.n-on { color: var(--good); border-color: var(--good-border); background: var(--good-bg); }
.nav-locked { opacity: .38; cursor: not-allowed; }
.nav-locked:hover { background: none; color: var(--muted); }
.nav-locked:after { content: "🔒"; font-size: 9px; margin-left: 6px; opacity: .8; }
.nav-locked .nav-count { margin-left: 0; }

/* ---- CAMPAIGN CARDS ---- */
.camp-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 12px; transition: border-color .15s;
}
.camp-card:hover { border-color: var(--line-light); }
.camp-card.st-running { border-left: 3px solid var(--good); }
.camp-card.st-paused { border-left: 3px solid var(--warn); }
.camp-card.st-done { border-left: 3px solid var(--blue); }
.camp-card.st-stopped { border-left: 3px solid var(--dim); }
.camp-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.camp-title { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; flex-wrap: wrap; }
.camp-ico {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  font-size: 14px; background: rgba(255,255,255,.04); border: 1px solid var(--line-light);
  flex-shrink: 0;
}
.camp-senders { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.prog { background: rgba(255,255,255,.04); border-radius: 99px; height: 7px; margin: 10px 0 8px; overflow: hidden; position: relative; }
.prog-fill {
  height: 100%; border-radius: 99px; background: var(--good); transition: width .5s ease;
}
.st-running .prog-fill { background: linear-gradient(90deg, var(--good), #4ade80); animation: progPulse 2s ease-in-out infinite; }
.st-paused .prog-fill { background: var(--warn); }
.st-done .prog-fill { background: var(--blue); }
.st-stopped .prog-fill { background: var(--dim); }
@keyframes progPulse { 0%,100% { opacity: 1; } 50% { opacity: .65; } }
.camp-meta { color: var(--muted); font-size: 11.5px; line-height: 1.7; }
.camp-meta b { color: var(--text-secondary); }
.camp-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.camp-actions .ghost, .camp-actions .btn-danger { font-size: 11px; padding: 5px 10px; }
.camp-actions input[type="number"] { width: 56px; margin: 0; padding: 4px 6px; font-size: 11px; }

/* ---- OUTBOX day separators ---- */
.day-sep {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .7px;
  color: var(--dim); padding: 14px 4px 6px; position: sticky; top: -1px;
  background: var(--card); z-index: 2;
}
.day-sep:first-child { padding-top: 4px; }
