:root {
  --brand: #22c55e;
  --brand-bright: #35d07f;
  --brand-dim: #15361f;
  --brand-glow: rgba(34, 197, 94, .28);
  --bg: #0b1017;
  --panel: #141b24;
  --panel-2: #1a222d;
  --line: #253040;
  --text: #e6edf3;
  --muted: #8896a8;
  --danger: #f0616d;
  --amber: #e9b949;
  --sidebar: #0a0e14;
  --sidebar-ink: #c7d3e2;
  --sidebar-ink-2: #7e8ca0;
  --sidebar-active: #16202c;
  --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 "Segoe UI", system-ui, -apple-system, sans-serif; }

/* ---------- auth page ---------- */
.authpage { min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(900px 400px at 50% -10%, rgba(34,197,94,.12), transparent 60%), var(--bg); }
.authcard { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 34px; width: 340px; text-align: center; }
.authlogo { display: inline-flex; filter: drop-shadow(0 4px 14px var(--brand-glow)); margin-bottom: 12px; }
.authlogo svg { border-radius: 12px; }
.authtitle { margin: 0 0 4px; font-size: 20px; font-weight: 500; }
.authtitle b { font-weight: 750; }
.authsub { color: var(--muted); font-size: 13.5px; margin: 4px 0 18px; }
.authcard input { width: 100%; box-sizing: border-box; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 9px; padding: 11px 13px; margin: 7px 0; font: inherit; outline: none; }
.authcard input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.autherr { color: var(--danger); font-size: 13px; min-height: 18px; margin: 4px 0; }
.authok { color: var(--brand-bright); font-size: 13px; margin: 4px 0; }
.authswap { color: var(--muted); font-size: 13px; margin-top: 14px; }
.authswap a { color: var(--brand-bright); text-decoration: none; }
.authnote { color: var(--muted); font-size: 12px; margin-top: 10px; opacity: .8; }
.authfoot { position: fixed; bottom: 16px; width: 100%; text-align: center; color: var(--muted); font-size: 12px; opacity: .6; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--sidebar); display: flex; flex-direction: column; padding: 18px 14px; gap: 4px; position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-size: 17px; font-weight: 500; color: #fff; }
.brand svg { width: 30px; height: 30px; flex: 0 0 auto; border-radius: 8px; }
.brand b { font-weight: 750; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; border: 0; background: transparent; color: var(--sidebar-ink-2); font-size: 13.5px; font-weight: 500; cursor: pointer; text-align: left; width: 100%; transition: background .12s, color .12s; }
.nav-item svg { width: 18px; height: 18px; flex: 0 0 auto; }
.nav-item:hover { color: var(--sidebar-ink); background: rgba(255,255,255,.04); }
.nav-item.active { color: #fff; background: var(--sidebar-active); }
.nav-item.active svg { color: var(--brand-bright); }
.side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.side-user { display: flex; align-items: center; gap: 10px; padding: 8px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #04220f; display: grid; place-items: center; font-weight: 700; }
.su-name { font-size: 13px; font-weight: 600; color: #fff; }
.su-plan { font-size: 11.5px; color: var(--sidebar-ink-2); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { padding: 20px 28px 14px; border-bottom: 1px solid var(--line); background: rgba(9,13,19,.4); }
.topbar-title { font-size: 18px; font-weight: 650; }
.topbar-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.content { padding: 24px 28px 60px; max-width: 1240px; width: 100%; }

/* ---------- panels / form ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.panel.narrow { max-width: 460px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.wide { grid-column: span 2; }
.field.small { max-width: 150px; }
.field span { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; }
input:not([type="checkbox"]), .select { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 9px; padding: 10px 12px; font: inherit; outline: none; transition: border-color .15s, box-shadow .15s; }
input:not([type="checkbox"]):focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
/* searchable cascading dropdowns */
.combo { position: relative; }
.combo-input { width: 100%; }
.combo-input:disabled { opacity: .55; cursor: not-allowed; }
.combo-list { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0; max-height: 260px; overflow-y: auto;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 12px 30px rgba(0,0,0,.4); padding: 4px; }
.combo-opt { padding: 9px 11px; border-radius: 7px; cursor: pointer; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-opt:hover, .combo-opt.hl { background: var(--brand-dim); color: var(--brand-bright); }
.combo-opt.all { color: var(--brand-bright); font-weight: 600; border-bottom: 1px solid var(--line); border-radius: 0; margin-bottom: 2px; }
.combo-empty { padding: 10px 11px; color: var(--muted); font-size: 13px; }

.opts { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-top: 18px; }
.spacer { flex: 1; }
.check { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); cursor: pointer; user-select: none; font-size: 13px; }
.check input { accent-color: var(--brand); width: 15px; height: 15px; }
button, .btnlink { font: inherit; border-radius: 9px; padding: 10px 18px; cursor: pointer; border: 1px solid transparent; text-decoration: none; display: inline-block; transition: filter .15s, border-color .15s; }
.primary { background: var(--brand); color: #04220f; font-weight: 650; box-shadow: 0 4px 14px var(--brand-glow); }
.primary:hover { filter: brightness(1.08); }
.primary:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.primary.wide { width: 100%; margin-top: 8px; }
.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.ghost:hover { border-color: var(--muted); }
.link { background: none; border: none; color: var(--muted); padding: 0; font-size: 12px; text-decoration: underline; cursor: pointer; }
.link.del { color: var(--danger); }

/* ---------- status + stepper ---------- */
.statusrow { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; padding: 15px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.stats { display: flex; gap: 28px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; }
.stat b { font-size: 23px; font-weight: 700; color: var(--brand-bright); font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.statusmsg { display: flex; align-items: center; gap: 10px; color: var(--muted); margin-left: auto; }
.dotpulse { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); animation: pulse 1.4s infinite; }
.dotpulse.done { animation: none; } .dotpulse.err { background: var(--danger); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--brand-glow); } 70% { box-shadow: 0 0 0 9px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.processing { padding: 8px 20px 16px; }
.procgrid { display: flex; flex-direction: column; }
.step { display: grid; grid-template-columns: 34px 1fr; gap: 14px; padding: 13px 0; position: relative; }
.step:not(:last-child)::before { content: ""; position: absolute; left: 16px; top: 34px; bottom: -1px; width: 2px; background: var(--line); }
.step.done:not(:last-child)::before { background: var(--brand-dim); }
.step .icon { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 2px solid var(--line); background: var(--panel-2); color: var(--muted); font-size: 15px; z-index: 1; transition: all .25s; }
.step .body { padding-top: 4px; min-width: 0; }
.step .title { font-weight: 550; color: var(--muted); transition: color .25s; }
.step .detail { color: var(--muted); font-size: 12.5px; margin-top: 2px; opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step.pending .icon { opacity: .5; } .step.pending .title { opacity: .6; }
.step.active .icon { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 4px var(--brand-glow); }
.step.active .title { color: var(--text); }
.step.active .spinner { width: 15px; height: 15px; border: 2px solid var(--brand-dim); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
.step.done .icon { border-color: var(--brand); background: var(--brand); color: #04220f; }
.step.done .title { color: var(--text); }
.step.error .icon { border-color: var(--danger); color: var(--danger); } .step.error .title, .step.error .detail { color: var(--danger); }
.step.skipped .icon { border-style: dashed; } .step.skipped .title { text-decoration: line-through; opacity: .5; } .step.skipped .detail { opacity: .5; }
@keyframes spin { to { transform: rotate(360deg); } }
.pbar { height: 5px; border-radius: 3px; background: var(--panel-2); overflow: hidden; margin-top: 9px; max-width: 340px; }
.pbar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-dim), var(--brand)); border-radius: 3px; transition: width .3s ease; }
.showlog { display: inline-block; margin: 6px 0 2px 48px; }
pre#logBox { margin: 10px 0 4px 48px; max-height: 190px; overflow: auto; font: 12px/1.7 ui-monospace, Consolas, monospace; color: #9fb0c3; white-space: pre-wrap; }

/* ---------- tables ---------- */
.tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.tools input, .tools .select { min-width: 160px; }
.tools input#filterText, .tools input#savedFilter { flex: 1; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 9px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; background: var(--panel-2); color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 11px 12px; position: sticky; top: 0; }
td { padding: 11px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
tr:hover td { background: #172029; }
td.num { color: var(--muted); width: 40px; }
td a { color: #6fb2ff; text-decoration: none; } td a:hover { text-decoration: underline; }
.cat { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.email { color: var(--brand-bright); }
.vbadge { display: inline-block; font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 20px; margin-left: 4px; text-transform: uppercase; letter-spacing: .03em; vertical-align: middle; cursor: help; }
.v-valid { background: var(--brand-dim); color: var(--brand-bright); }
.v-risky { background: rgba(233,185,73,.16); color: var(--amber); }
.v-invalid { background: rgba(240,97,109,.14); color: var(--danger); }
.v-unknown { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.empty { color: var(--muted); padding: 18px; text-align: center; }
.savebtn { background: var(--brand-dim); color: var(--brand-bright); border: 1px solid transparent; border-radius: 7px; padding: 6px 12px; font-size: 12px; }
.savebtn:hover { filter: brightness(1.15); }
.savebtn.saved { background: transparent; color: var(--muted); border-color: var(--line); cursor: default; }
.noteInp { width: 100%; min-width: 130px; padding: 7px 9px !important; font-size: 12.5px; }
.statusSel { padding: 6px 8px; font-size: 12.5px; }
.status-new { color: var(--muted); } .status-contacted { color: var(--amber); }
.status-replied { color: #6fb2ff; } .status-won { color: var(--brand-bright); } .status-not_interested { color: var(--danger); }

/* ---------- history / admin / account ---------- */
.logtitle { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px; }
.historylist { display: flex; flex-direction: column; gap: 8px; }
.histitem { display: flex; align-items: center; gap: 14px; padding: 11px 13px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; cursor: pointer; transition: border-color .15s; }
.histitem:hover { border-color: var(--brand-dim); }
.histitem .q { flex: 1; } .histitem .meta { color: var(--muted); font-size: 12px; }
.err { color: var(--danger); }
.userform { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.userform input { flex: 1; min-width: 150px; }
.badge { font-size: 10.5px; padding: 3px 9px; border-radius: 20px; text-transform: capitalize; }
.b-active { background: var(--brand-dim); color: var(--brand-bright); }
.b-pending { background: rgba(233,185,73,.16); color: var(--amber); }
.b-disabled { background: rgba(240,97,109,.14); color: var(--danger); }
.acts { display: flex; gap: 10px; white-space: nowrap; }
.kv { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; } .kv span { color: var(--muted); }
.muted-p { color: var(--muted); font-size: 13px; }
.usebar { height: 8px; border-radius: 4px; background: var(--panel-2); overflow: hidden; margin-top: 12px; }
.usebar > i { display: block; height: 100%; background: var(--brand); border-radius: 4px; transition: width .3s; }
.usebar > i.warn { background: var(--amber); } .usebar > i.full { background: var(--danger); }

/* number picker */
.numlist { display: flex; flex-direction: column; gap: 8px; }
.numrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; }
.numrow b { font-size: 15px; letter-spacing: .3px; }
.buynum { padding: 8px 14px; font-size: 13px; }

/* messenger (TextNow style) */
.messenger { max-width: 620px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; margin-bottom: 16px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.msgr-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; background: linear-gradient(120deg, var(--brand-dim), rgba(34,197,94,.06)); border-bottom: 1px solid var(--line); }
.msgr-badge { width: 40px; height: 40px; border-radius: 50%; background: var(--brand); color: #04220f; display: grid; place-items: center; }
.msgr-badge svg { width: 20px; height: 20px; }
.msgr-title { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.msgr-num { font-size: 16px; font-weight: 700; letter-spacing: .4px; }
.pill-info { font-size: 11.5px; color: var(--brand-bright); background: var(--brand-dim); padding: 5px 11px; border-radius: 20px; cursor: help; }
.msgr-body { padding: 18px; }
.msgr-label { display: block; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 6px 0; }
.msgr-area { width: 100%; box-sizing: border-box; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 12px 14px; font: inherit; resize: vertical; outline: none; }
.msgr-area:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.bubblewrap { margin-bottom: 6px; }
.msgr-area.bubble { border-radius: 16px 16px 16px 4px; background: linear-gradient(160deg, rgba(34,197,94,.10), var(--panel-2)); }
.msgr-foot { display: flex; align-items: center; gap: 12px; margin-top: 14px; }

/* rich-text email editor */
.rt-wrap { border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); overflow: hidden; }
.rt-wrap:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.rt-toolbar { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--panel); }
.rt-btn { background: transparent; border: 1px solid transparent; color: var(--text); border-radius: 7px; min-width: 30px; height: 30px; padding: 0 7px; cursor: pointer; display: inline-grid; place-items: center; font-size: 14px; line-height: 1; }
.rt-btn:hover { background: rgba(255,255,255,.06); border-color: var(--line); }
.rt-btn.active { background: var(--brand-dim); color: var(--brand-bright); border-color: var(--brand); }
.rt-btn svg { width: 17px; height: 17px; }
.rt-sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.rt-editor { min-height: 150px; max-height: 340px; overflow-y: auto; padding: 12px 14px; font: inherit; font-size: 14px; line-height: 1.5; color: var(--text); outline: none; }
.rt-editor-sm { min-height: 44px; max-height: 160px; padding: 9px 12px; }
.rt-reply { align-items: flex-end; }
.rt-reply .rt-toolbar { padding: 4px 6px; }
.rt-reply .rt-btn { min-width: 26px; height: 26px; }
.rt-editor:empty::before { content: attr(data-ph); color: var(--muted); }
.rt-editor a { color: var(--brand-bright); text-decoration: underline; }
.rt-editor ul, .rt-editor ol { margin: 6px 0; padding-left: 22px; }
.att-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 10px; }
.att-list:not(:empty) { padding: 10px; border-top: 1px solid var(--line); }
.att-chip { display: inline-flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px 6px 10px; font-size: 12.5px; max-width: 220px; }
.att-chip .att-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-chip .att-size { color: var(--muted); flex: 0 0 auto; }
.att-chip .att-x { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; flex: 0 0 auto; }
.att-chip .att-x:hover { color: var(--danger); }
/* rendered attachment note inside a sent bubble */
.tn-att { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--muted); }

/* TextNow-style two-way messenger */
.tn { display: grid; grid-template-columns: 300px 1fr; height: 640px; max-height: calc(100vh - 190px); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.tn-side { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel-2); }
.tn-side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.tn-num { font-size: 15px; font-weight: 700; letter-spacing: .3px; }
.tn-head-actions { display: flex; gap: 6px; }
.iconbtn { background: transparent; border: 1px solid var(--line); color: var(--text); border-radius: 9px; width: 36px; height: 36px; padding: 0; cursor: pointer; display: inline-grid; place-items: center; flex: 0 0 auto; }
.iconbtn:hover { border-color: var(--brand); color: var(--brand-bright); }
.tn-tabs { display: flex; border-bottom: 1px solid var(--line); }
.tn-tab { flex: 1; background: transparent; border: 0; color: var(--muted); font-size: 12.5px; font-weight: 600; padding: 11px 8px; cursor: pointer; border-bottom: 2px solid transparent; }
.tn-tab.active { color: var(--text); border-bottom-color: var(--brand); }
.tn-badge { display: inline-block; background: var(--brand); color: #04220f; font-size: 10px; font-weight: 700; border-radius: 20px; padding: 1px 6px; margin-left: 4px; }
.tn-list { flex: 1; min-height: 0; overflow-y: auto; }
.tn-conv { display: flex; align-items: center; gap: 11px; padding: 12px 14px; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,.03); position: relative; }
.tn-conv:hover { background: rgba(255,255,255,.03); }
.tn-conv.active { background: var(--sidebar-active); }
.tn-conv.unread .tn-conv-name { font-weight: 700; }
.tn-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--brand-dim); color: var(--brand-bright); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: 0 0 auto; text-transform: uppercase; }
.tn-avatar.missed { background: rgba(240,97,109,.16); color: var(--danger); font-size: 18px; }
.tn-conv-body { min-width: 0; flex: 1; }
.tn-conv-top { display: flex; justify-content: space-between; gap: 8px; }
.tn-conv-name { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tn-conv-time { color: var(--muted); font-size: 11px; flex: 0 0 auto; }
.tn-conv-prev { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.tn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex: 0 0 auto; }

.tn-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.tn-chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.callbtn { flex: 0 0 auto; }
.tn-chat-name { font-size: 15px; font-weight: 650; }
.callbtn { width: 40px; height: 40px; border-radius: 50%; background: var(--brand); color: #04220f; border: 0; cursor: pointer; display: grid; place-items: center; box-shadow: 0 3px 10px var(--brand-glow); }
.callbtn:hover { filter: brightness(1.08); } .callbtn svg { width: 19px; height: 19px; }
.tn-thread { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 4px; background: var(--bg); }
.tn-empty { margin: auto; color: var(--muted); text-align: center; padding: 30px; }
.tn-msg { display: flex; flex-direction: column; max-width: 74%; margin-bottom: 6px; }
.tn-msg.out { align-self: flex-end; align-items: flex-end; }
.tn-msg.in { align-self: flex-start; align-items: flex-start; }
.tn-bubble { padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.4; word-wrap: break-word; }
.tn-msg.out .tn-bubble { background: var(--brand); color: #04220f; border-bottom-right-radius: 4px; }
.tn-msg.in .tn-bubble { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.tn-meta { font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.tn-composer { display: flex; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); align-items: flex-end; }
.tn-composer textarea { flex: 1; resize: none; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 20px; padding: 11px 16px; font: inherit; outline: none; max-height: 120px; }
.tn-composer textarea:focus { border-color: var(--brand); }
.tn-composer .primary { border-radius: 20px; }
.tn-broadcast { position: absolute; inset: 0; background: var(--panel); padding: 18px; overflow-y: auto; z-index: 5; }

.tn-back { display: none; background: transparent; border: 0; color: var(--text); padding: 0; width: 32px; height: 32px; align-items: center; justify-content: center; cursor: pointer; flex: 0 0 auto; }
.tn-back svg { width: 22px; height: 22px; }

@media (max-width: 760px) {
  .tn { grid-template-columns: 1fr; height: 70vh; }
  .tn-side { border-right: 0; }
  /* Master-detail: show the list OR the open conversation, not both stacked. */
  .tn-main { display: none; }
  .tn.show-thread .tn-side { display: none; }
  .tn.show-thread .tn-main { display: flex; }
  .tn-back { display: inline-flex; }
  /* When a conversation is open on mobile, give it the whole screen. */
  .page[data-page="email"]:has(.tn.show-thread) .acct-bar,
  .page[data-page="email"]:has(.tn.show-thread) .mstat-row,
  .page[data-page="text"]:has(.tn.show-thread) .mstat-row { display: none; }
  .tn.show-thread { height: calc(100vh - 150px); }
}

/* delivery tracking bar */
.mstat-row { display: flex; align-items: center; gap: 22px; padding: 14px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.mstat { display: flex; align-items: center; gap: 8px; }
.mstat b { font-size: 19px; font-variant-numeric: tabular-nums; }
.mstat span:last-child { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }
.mstat-ico { width: 9px; height: 9px; border-radius: 50%; }
.st-sent { background: #6fb2ff; } .st-delivered { background: var(--brand); } .st-failed { background: var(--danger); } .st-received { background: var(--amber); }
.mstat-num { font-weight: 700; letter-spacing: .3px; color: var(--brand-bright); background: var(--brand-dim); padding: 7px 13px; border-radius: 20px; font-size: 13.5px; }
.voicechip { display: inline-flex; align-items: center; gap: 7px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 20px; padding: 6px 13px; font-size: 13px; cursor: pointer; }
.voicechip:hover { border-color: var(--brand); }
.voicechip svg { width: 15px; height: 15px; color: var(--brand-bright); }
.voice-clone { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin: 8px 0 4px; }
.voice-list { display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow-y: auto; }
.voice-item { display: flex; align-items: center; gap: 12px; padding: 11px 13px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.voice-item:hover { border-color: var(--brand-dim); }
.voice-item.sel { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-glow); }
.voice-item .vi-main { flex: 1; min-width: 0; }
.voice-item .vi-name { font-weight: 600; font-size: 13.5px; }
.voice-item .vi-desc { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-item .vi-tag { font-size: 10px; padding: 2px 7px; border-radius: 20px; background: var(--brand-dim); color: var(--brand-bright); flex: 0 0 auto; }

/* refined messenger bits */
.tn-side-head { flex-direction: column; align-items: stretch; gap: 10px; }
.tn-side-head .tn-tabs { border: 0; }
.tn-head-actions { display: flex; gap: 8px; justify-content: flex-end; }
.iconbtn.primary-ico { background: var(--brand); color: #04220f; border-color: transparent; }
.iconbtn.primary-ico:hover { filter: brightness(1.08); color: #04220f; }
.iconbtn svg { width: 17px; height: 17px; }
.tn-search { padding: 0 12px 10px; }
.tn-search input { width: 100%; box-sizing: border-box; background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 20px; padding: 8px 14px; font: inherit; font-size: 13px; outline: none; }
.tn-search input:focus { border-color: var(--brand); }
.tn-chat-id { min-width: 0; }
.tn-empty-ico { width: 54px; height: 54px; margin: 0 auto 12px; color: var(--brand-dim); }
.tn-empty-ico svg { width: 100%; height: 100%; }
.sendcircle { width: 42px; height: 42px; border-radius: 50%; background: var(--brand); color: #04220f; border: 0; display: grid; place-items: center; cursor: pointer; flex: 0 0 auto; box-shadow: 0 3px 10px var(--brand-glow); }
.sendcircle:hover { filter: brightness(1.08); } .sendcircle svg { width: 18px; height: 18px; }
.tn-leadinfo { border-bottom: 1px solid var(--line); background: var(--panel-2); padding: 12px 16px; font-size: 12.5px; display: flex; gap: 18px; flex-wrap: wrap; }
.tn-leadinfo .li { display: flex; flex-direction: column; }
.tn-leadinfo .li span { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; }
.tn-leadinfo .li b { font-size: 13px; }
.li-badge { align-self: center; margin-left: auto; }
.nav-badge, .li-badge { background: var(--brand); color: #04220f; font-size: 10px; font-weight: 700; border-radius: 20px; padding: 1px 7px; }
.nav-badge { margin-left: 6px; }

/* toasts */
.toast-wrap { position: fixed; top: 18px; right: 18px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--brand); color: var(--text); padding: 12px 16px; border-radius: 10px; font-size: 13.5px; box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: 340px; animation: toastin .2s ease; }
.toast.error { border-left-color: var(--danger); } .toast.warn { border-left-color: var(--amber); }
@keyframes toastin { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* modal */
.modal-root { position: fixed; inset: 0; z-index: 1001; display: grid; place-items: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4,7,11,.6); backdrop-filter: blur(2px); }
.modal-card { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: 380px; max-width: calc(100vw - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal-title { font-size: 16px; font-weight: 650; margin-bottom: 8px; }
.modal-body { color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.modal-input { width: 100%; box-sizing: border-box; margin-top: 14px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 9px; padding: 11px 13px; font: inherit; outline: none; }
.modal-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* call screen */
.call-overlay { position: fixed; inset: 0; z-index: 1002; display: grid; place-items: center; background: rgba(4,7,11,.75); backdrop-filter: blur(4px); }
.call-card { background: linear-gradient(180deg, var(--panel), var(--panel-2)); border: 1px solid var(--line); border-radius: 20px; padding: 40px 48px; text-align: center; width: 340px; box-shadow: 0 25px 70px rgba(0,0,0,.55); }
.call-avatar { width: 92px; height: 92px; border-radius: 50%; background: var(--brand-dim); color: var(--brand-bright); display: grid; place-items: center; font-size: 36px; font-weight: 700; margin: 0 auto 18px; }
.call-avatar.active { animation: callpulse 1.6s infinite; }
@keyframes callpulse { 0% { box-shadow: 0 0 0 0 var(--brand-glow); } 70% { box-shadow: 0 0 0 18px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.call-name { font-size: 20px; font-weight: 650; }
.call-status { color: var(--muted); font-size: 13.5px; margin-top: 6px; text-transform: capitalize; }
.call-timer { color: var(--brand-bright); font-size: 15px; font-variant-numeric: tabular-nums; margin-top: 8px; min-height: 20px; }
.call-actions { display: flex; justify-content: center; gap: 26px; margin-top: 30px; }
.call-btn { width: 60px; height: 60px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; color: #fff; }
.call-btn svg { width: 24px; height: 24px; }
.call-mute { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); }
.call-mute.on { background: var(--amber); color: #21160a; }
.call-end { background: var(--danger); }
.call-end:hover { filter: brightness(1.1); }
.call-mode { display: inline-flex; margin: 22px auto 0; background: var(--panel-2); border: 1px solid var(--line); border-radius: 20px; padding: 3px; }
.cm-opt { background: transparent; border: 0; color: var(--muted); padding: 7px 16px; border-radius: 18px; font-size: 12.5px; cursor: pointer; }
.cm-opt.active { background: var(--brand); color: #04220f; font-weight: 600; }
.call-say { display: flex; gap: 8px; margin-top: 14px; }
.call-say input { flex: 1; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 20px; padding: 10px 15px; font: inherit; outline: none; }
.call-say input:focus { border-color: var(--brand); }
.call-say .sendcircle { width: 40px; height: 40px; }
.call-clonenote { margin-top: 16px; font-size: 11.5px; color: var(--brand-bright); text-transform: uppercase; letter-spacing: .05em; }
.call-listen { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; color: var(--muted); font-size: 13.5px; }
.listen-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); animation: pulse 1.2s infinite; }
#callHeard { color: var(--text); font-style: italic; }

/* alerts setup steps */
.setup-steps { display: flex; flex-direction: column; gap: 9px; margin: 14px 0 18px; padding: 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; font-size: 13px; color: var(--muted); }
.setup-steps b { color: var(--brand-bright); }
.setup-steps code { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; color: var(--text); font-size: 12px; }

/* alert rules list */
.alert-list { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 4px; }
.alert-row { display: flex; align-items: center; gap: 14px; padding: 13px 15px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; }
.alert-row.off { opacity: .55; }
.alert-ico { width: 36px; height: 36px; border-radius: 9px; background: var(--brand-dim); color: var(--brand-bright); display: grid; place-items: center; flex: 0 0 auto; }
.alert-ico svg { width: 18px; height: 18px; }
.alert-main { flex: 1; min-width: 0; }
.alert-name { font-weight: 600; font-size: 14px; }
.alert-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.alert-acts { display: flex; gap: 12px; align-items: center; flex: 0 0 auto; }
.switch { position: relative; width: 38px; height: 22px; flex: 0 0 auto; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--line); border-radius: 20px; transition: .2s; }
.switch .track::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::before { transform: translateX(16px); }
.alert-form { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; max-width: 460px; }
.alert-empty { color: var(--muted); font-size: 13px; padding: 8px 0; }

/* email account switcher */
.acct-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.acct-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 20px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); font-size: 13px; cursor: pointer; }
.acct-pill.active { border-color: var(--brand); background: var(--brand-dim); color: var(--brand-bright); }
.acct-pill .rm { color: var(--muted); font-size: 15px; line-height: 1; }
.acct-pill .rm:hover { color: var(--danger); }
.acct-add { padding: 8px 14px; border-radius: 20px; background: transparent; border: 1px dashed var(--line); color: var(--muted); font-size: 13px; cursor: pointer; }
.acct-add:hover { border-color: var(--brand); color: var(--brand-bright); }


@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .brand { padding: 4px 8px; } .nav { flex-direction: row; flex-wrap: wrap; margin: 0; }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; display: flex; gap: 8px; align-items: center; }
  .field.wide { grid-column: span 1; }
}
