:root {
  --ink: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f7f8fa;
  --line: #e7e9ee;
  --hair: #f1f2f5;
  --text: #141821;
  --muted: #6b7280;
  --dim: #9ca3af;

  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-soft: #eeecfb;
  --brand-tint: #f7f5ff;

  --live: #15803d;
  --live-soft: #e9f6ee;
  --wait: #a86a08;
  --wait-soft: #fdf4e7;
  --dead: #c0392f;
  --dead-soft: #fdeeed;

  --bn: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  --r: 10px;
  --shadow: 0 1px 2px rgba(20, 24, 33, .05), 0 1px 3px rgba(20, 24, 33, .04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--bn);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }

.eyebrow {
  display: block;
  font-family: var(--bn);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}

.hint { margin: 8px 0 0; font-size: 13px; color: var(--muted); line-height: 1.6; }
.hint b { color: var(--text); font-weight: 600; }
.empty { color: var(--muted); font-size: 14px; margin: 0; }

/* ---------- app frame ---------- */

.app {
  display: grid;
  grid-template-columns: 212px minmax(0, 1fr);
  min-height: 100vh;
}

.nav {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 20px; }
.brand__mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--brand);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 16px;
  flex: none;
}
.brand__name { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.brand__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--dead);
  margin-left: auto;
  transition: background .3s;
}
.brand__dot.on { background: var(--live); }

.nav__item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 11px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: #4b5563;
  font-size: 14.5px;
  text-align: left;
  cursor: pointer;
  transition: background .16s, color .16s;
}
.nav__item i { font-size: 19px; flex: none; }
.nav__item:hover { background: var(--panel-2); }
.nav__item.is-active { background: var(--brand-soft); color: var(--brand); font-weight: 500; }
.nav__item:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.nav__badge {
  margin-left: auto;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-family: var(--bn);
  font-size: 11.5px;
  font-weight: 600;
}

.nav__foot {
  margin-top: 20px;
  padding: 12px 13px;
  border-radius: var(--r);
  background: var(--panel-2);
}
.nav__foot-k { display: block; font-size: 12.5px; color: var(--muted); }
.nav__foot-v { display: block; font-size: 15px; font-weight: 600; color: var(--live); margin-top: 1px; }

.view { background: var(--ink); min-width: 0; }

.page { display: none; }
.page.is-active { display: block; }

/* ---------- shared panes ---------- */

[hidden] { display: none !important; }

.pane { padding: 22px 24px 34px; }

.pane__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.pane__title { font-size: 23px; font-weight: 600; letter-spacing: -.015em; margin: 3px 0 0; }
.pane__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.panel__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.form { display: grid; gap: 14px; }
.form__row { display: grid; gap: 7px; }
.form__actions { display: flex; justify-content: flex-end; }

.grid2, .grid3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.rows { display: grid; gap: 11px; }
.row { display: flex; justify-content: space-between; gap: 14px; font-size: 14px; }
.row span:first-child { color: var(--muted); }

.subhead { font-size: 16px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 12px; }
.subhead--sp { margin-top: 26px; }

.note, .est {
  margin-top: 14px;
  padding: 13px 15px;
  background: var(--panel-2);
  border-radius: var(--r);
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.6;
}
.est b, .note b { color: var(--text); font-weight: 600; }

.placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--panel);
  border: 1px dashed #dde1e8;
  border-radius: var(--r);
  padding: 44px 20px;
  text-align: center;
  font-size: 14px;
}

.inline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 14.5px;
  color: #4b5563;
}

.modes { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- form controls ---------- */

input[type="text"], textarea, select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid #dfe3ea;
  border-radius: 9px;
  background: var(--panel);
  font-family: var(--bn);
  font-size: 14.5px;
  box-shadow: var(--shadow);
}
textarea { min-height: 120px; resize: vertical; line-height: 1.65; }
select { cursor: pointer; }

input[type="number"] {
  width: 78px;
  padding: 10px 12px;
  border: 1px solid #dfe3ea;
  border-radius: 9px;
  background: var(--panel);
  font-family: var(--bn);
  font-size: 14.5px;
  text-align: center;
  box-shadow: var(--shadow);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input { flex: 1; min-width: 200px; }
.filters select { min-width: 160px; width: auto; }

/* ---------- buttons ---------- */

.btn {
  padding: 9px 17px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: #374151;
  font-family: var(--bn);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow);
  transition: border-color .16s, background .16s, color .16s;
}
.btn:hover { border-color: #d3d7de; }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn--go { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--go:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn--danger { color: var(--dead); border-color: #f0cdca; }
.btn--danger:hover { border-color: var(--dead); background: var(--dead-soft); }
.btn--ghost { background: var(--panel-2); border-color: transparent; color: var(--muted); box-shadow: none; }
.btn--ghost:hover { color: var(--text); background: #eef0f4; }

.mini {
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: #4b5563;
  font-family: var(--bn);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .16s, color .16s;
}
.mini:hover { border-color: #d3d7de; color: var(--text); }
.mini--danger:hover { color: var(--dead); border-color: #f0cdca; }
.mini:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.mini:disabled { opacity: .45; cursor: not-allowed; }

.backlink {
  border: 0;
  background: none;
  padding: 0;
  color: var(--brand);
  font-family: var(--bn);
  font-size: 13.5px;
  cursor: pointer;
}
.backlink:hover { text-decoration: underline; }

/* ---------- pills and badges ---------- */

.pill, .badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-family: var(--bn);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--panel-2);
  color: var(--muted);
  border: 0;
}
.pill--draft { background: var(--panel-2); color: var(--muted); }
.pill--running { background: var(--live-soft); color: var(--live); }
.pill--paused { background: var(--wait-soft); color: var(--wait); }
.pill--done { background: var(--brand-soft); color: var(--brand); }
.pill--stopped { background: var(--dead-soft); color: var(--dead); }
.badge--yes { background: var(--live-soft); color: var(--live); }
.badge--blocked { background: var(--dead-soft); color: var(--dead); }

/* ---------- stat cards ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 15px 17px;
  box-shadow: var(--shadow);
}
.stat__label { font-size: 13px; color: var(--muted); }
.stat__value {
  font-family: var(--bn);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -.02em;
  margin-top: 2px;
}

/* ---------- devices ---------- */

.shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  gap: 16px;
  padding: 22px 24px 34px;
  align-items: start;
}

.slots, .detail {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px;
  box-shadow: var(--shadow);
}
.slots { display: flex; flex-direction: column; gap: 16px; }

.slot-list { display: flex; flex-direction: column; gap: 8px; }

.slot {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  cursor: pointer;
  text-align: left;
  transition: border-color .16s, background .16s;
}
.slot:hover { border-color: #d3d7de; }
.slot[aria-current="true"] { border-color: var(--brand); background: var(--brand-tint); }
.slot:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.slot__lamp { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--dim); }
.slot__lamp[data-s="connected"] { background: var(--live); }
.slot__lamp[data-s="awaiting-scan"] { background: var(--wait); animation: breathe 1.6s ease-in-out infinite; }
.slot__lamp[data-s="connecting"],
.slot__lamp[data-s="reconnecting"] { background: var(--wait); animation: breathe 1s ease-in-out infinite; }
.slot__lamp[data-s="failed"],
.slot__lamp[data-s="logged-out"] { background: var(--dead); }

.slot__text { min-width: 0; }
.slot__id { display: block; font-size: 14.5px; font-weight: 500; letter-spacing: -.01em; }
.slot__sub {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

.newslot { border-top: 1px solid var(--hair); padding-top: 16px; }
.newslot__row { display: flex; gap: 8px; margin-top: 9px; }

.detail { display: flex; flex-direction: column; gap: 18px; min-height: 420px; }

.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.head__id { font-size: 21px; font-weight: 600; letter-spacing: -.015em; margin: 4px 0 0; }
.head__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.state { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); margin-top: 4px; }
.state__lamp { width: 9px; height: 9px; border-radius: 50%; }

.scan { display: flex; gap: 28px; flex-wrap: wrap; align-items: flex-start; }

.frame {
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  line-height: 0;
  box-shadow: var(--shadow);
}
.frame img { width: 212px; height: 212px; display: block; }

.scan__side { flex: 1; min-width: 240px; }
.steps { margin: 10px 0 0; padding-left: 20px; color: var(--muted); font-size: 14.5px; line-height: 1.9; }
.steps b { color: var(--text); font-weight: 600; }

.freshness { height: 4px; background: var(--hair); border-radius: 999px; overflow: hidden; margin-top: 18px; }
.freshness__fill { height: 100%; background: var(--wait); width: 100%; transform-origin: left; border-radius: 999px; }

/* ---------- tables ---------- */

.table {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.trow {
  display: grid;
  grid-template-columns: 1.3fr 1.4fr .9fr .8fr 96px;
  gap: 12px;
  align-items: center;
  padding: 13px 16px;
  border-bottom: 1px solid var(--hair);
  font-size: 14px;
}
.trow:last-child { border-bottom: 0; }
.trow--head {
  font-family: var(--bn);
  font-size: 12.5px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}
.trow--leads { grid-template-columns: 24px 1.1fr 1.1fr .55fr .75fr 118px; }
.trow--leads input[type="checkbox"] { accent-color: var(--brand); width: 16px; height: 16px; }

.selbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 11px 15px;
  border: 1px solid var(--dead);
  background: var(--dead-soft);
  border-radius: var(--r);
  margin-bottom: 14px;
}
.selbar b { color: var(--dead); }
.trow--dev { grid-template-columns: minmax(0, 1.6fr) 80px 80px; }

.trow__cell { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow__num { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.trow__acts { display: flex; gap: 6px; justify-content: flex-end; }

.table__empty { padding: 30px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.table__foot {
  padding: 11px 16px;
  border-top: 1px solid var(--hair);
  font-size: 12.5px;
  color: var(--muted);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 13px;
  font-size: 13px;
  color: var(--muted);
}
.pager__btns { display: flex; gap: 7px; }

/* ---------- audience lists ---------- */

.alist {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.arow {
  display: grid;
  grid-template-columns: 24px 1.6fr .8fr .8fr auto;
  gap: 14px;
  align-items: center;
  padding: 13px 16px;
  border-bottom: 1px solid var(--hair);
  cursor: default;
  transition: background .15s;
}
.arow:last-child { border-bottom: 0; }
.arow:hover { background: var(--panel-2); }
.arow--head {
  background: var(--panel-2);
  font-size: 12px;
  letter-spacing: .02em;
  color: var(--muted);
}
.arow--head:hover { background: var(--panel-2); }
.arow__name { font-size: 14.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arow__num { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.arow__acts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.arow input[type="checkbox"] { accent-color: var(--brand); width: 16px; height: 16px; }

/* ---------- campaign list ---------- */

.cfilters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.cfilter {
  padding: 7px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-family: var(--bn);
  font-size: 13.5px;
  cursor: pointer;
  transition: background .16s, color .16s, border-color .16s;
}
.cfilter:hover { color: var(--text); }
.cfilter.is-on { background: var(--brand); border-color: var(--brand); color: #fff; }
.cfilter:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.clist {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.clist .crow:first-child { border-radius: var(--r) var(--r) 0 0; }
.clist .crow:last-child { border-radius: 0 0 var(--r) var(--r); }

.crow {
  display: grid;
  grid-template-columns: 24px minmax(0, 1.3fr) 100px minmax(120px, .8fr) 70px 40px;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--hair);
  cursor: pointer;
  transition: background .15s;
}
.crow:last-child { border-bottom: 0; }
.crow:hover { background: #fcfcfd; }
.crow--head {
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  cursor: default;
  font-family: var(--bn);
  font-size: 12.5px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}
.crow--head:hover { background: var(--panel-2); }

.crow__name { font-size: 15px; font-weight: 500; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow__meta { display: block; font-size: 12.5px; color: var(--dim); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow__num { display: block; font-family: var(--bn); font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.crow__acts { position: relative; display: flex; justify-content: flex-end; }
.crow input[type="checkbox"] { accent-color: var(--brand); width: 16px; height: 16px; }

.kebab {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  display: grid;
  place-items: center;
  line-height: 1;
}
.kebab:hover { border-color: #c7ccd4; color: var(--text); }

.cmenu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(20, 24, 33, .16);
  min-width: 175px;
  padding: 6px;
  z-index: 20;
  display: none;
}
.cmenu.is-open { display: block; }
.cmenu__item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  background: none;
  border-radius: 7px;
  color: #374151;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.cmenu__item:hover { background: var(--panel-2); }
.cmenu__item i { font-size: 16px; color: var(--dim); width: 16px; text-align: center; }
.cmenu__item.is-danger { color: var(--dead); }
.cmenu__item.is-danger i { color: var(--dead); }

/* ---------- next-round status card ---------- */

.nextround {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel-2);
}
.nextround i { font-size: 20px; color: var(--brand); }
.nextround.is-done i { color: var(--live); }
.nextround.is-wait i { color: var(--wait); }
.nextround__k { display: block; font-size: 12.5px; color: var(--muted); }
.nextround__v { display: block; font-family: var(--mono); font-size: 19px; font-weight: 600; margin-top: 1px; }
.nextround.is-done .nextround__v, .nextround.is-wait .nextround__v { font-family: var(--bn); font-size: 15px; }
.nextround__note { font-size: 12.5px; color: var(--dim); margin-top: 8px; }

/* ---------- campaign detail ---------- */

.chead {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 17px 20px;
  margin: 12px 0 14px;
  box-shadow: var(--shadow);
}
.chead__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.chead__name { font-size: 22px; font-weight: 600; letter-spacing: -.015em; }
.chead__acts { display: flex; gap: 8px; flex-wrap: wrap; }
.chead__ready {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 15px;
  padding-top: 14px;
  border-top: 1px solid var(--hair);
  font-size: 13.5px;
}
.ready { display: flex; align-items: center; gap: 7px; color: var(--muted); }
.ready.is-ok { color: var(--live); }
.ready.is-off { color: var(--dead); }

.cpanel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.tabs { display: flex; gap: 2px; padding: 0 14px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  padding: 14px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font-family: var(--bn);
  font-size: 14.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .16s;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.tab:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

.tabbody { padding: 20px; min-width: 0; }

.progress { height: 6px; background: var(--hair); border-radius: 999px; overflow: hidden; }
.progress__fill { height: 100%; background: var(--brand); border-radius: 999px; transition: width .4s; }

.kv {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--hair);
  font-size: 14px;
}
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { font-family: var(--bn); font-size: 14px; text-align: right; }

.logrow {
  display: grid;
  grid-template-columns: 62px 1.3fr 92px auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--hair);
  font-size: 13.5px;
}
.logrow:last-child { border-bottom: 0; }
.logrow span { font-family: var(--bn); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logrow__st { text-align: right; }

.chk, .checkline {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  margin-bottom: 9px;
  cursor: pointer;
  font-size: 14.5px;
  box-shadow: var(--shadow);
  transition: border-color .16s, background .16s;
}
.chk.is-on, .checkline.is-on { border-color: var(--brand); background: var(--brand-tint); box-shadow: none; }
.chk input, .checkline input { accent-color: var(--brand); width: 17px; height: 17px; }
.chk__main { flex: 1; min-width: 0; }
.chk__sub { display: block; font-family: var(--mono); font-size: 12px; color: var(--dim); margin-top: 1px; }
.chk__right { text-align: right; font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.checkline__id { font-size: 14.5px; }
.checkline__num { font-family: var(--mono); font-size: 12px; color: var(--dim); }

.days { display: flex; gap: 8px; flex-wrap: wrap; }
.dayb {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-family: var(--bn);
  font-size: 13.5px;
  cursor: pointer;
}
.dayb.is-on { border-color: var(--brand); background: var(--brand-tint); color: var(--brand); font-weight: 500; }

/* ---------- templates ---------- */

/* ---------- template editor ---------- */

.tpl-dropzone {
  border: 1.5px dashed #c7ccd4;
  border-radius: var(--r);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  background: var(--panel-2);
}
.tpl-dropzone:hover { border-color: var(--brand); }
.tpl-dropzone i { font-size: 24px; color: var(--dim); }
.tpl-dropzone p { margin: 7px 0 0; font-size: 13px; color: var(--muted); }
.tpl-dropzone.has-img { padding: 0; border-style: solid; overflow: hidden; }
.tpl-dropzone.has-img img { width: 100%; height: 140px; object-fit: cover; display: block; }
.tpl-imgrow { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.tpl-imgrow button { font-size: 12.5px; color: var(--dead); background: none; border: 0; cursor: pointer; }

.tplbtn { border: 1px solid var(--line); border-radius: 9px; padding: 11px 13px; margin-bottom: 8px; background: var(--panel); }
.tplbtn__top { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.tplbtn__top select { flex: none; }
.tplbtn__top .rm { margin-left: auto; background: none; border: 0; color: var(--dim); cursor: pointer; font-size: 16px; }
.tplbtn__top .rm:hover { color: var(--dead); }
.tplbtn input { margin-top: 7px; }

.tpl-thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--panel-2); flex: none; }
.tpl-thumb--empty { width: 40px; height: 40px; border-radius: 8px; background: var(--panel-2); display: grid; place-items: center; color: var(--dim); font-size: 17px; flex: none; }

.tpl {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 17px 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.tpl__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.tpl__name { font-size: 15.5px; font-weight: 600; letter-spacing: -.01em; }
.tpl__var {
  margin-top: 11px;
  padding: 12px 15px;
  background: var(--panel-2);
  border-radius: 9px;
  font-size: 14.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.ph { color: var(--wait); font-family: var(--mono); font-size: 13.5px; }

/* ---------- message builder ---------- */

.builder {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(250px, .75fr);
  gap: 20px;
  align-items: start;
}
.builder__side { position: sticky; top: 16px; }

.pv__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pv__toggle { display: flex; gap: 4px; }

.pvbtn {
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-family: var(--bn);
  font-size: 13px;
  cursor: pointer;
  transition: color .16s, border-color .16s, background .16s;
}
.pvbtn:hover { color: var(--text); }
.pvbtn.is-on { color: var(--brand); border-color: var(--brand); background: var(--brand-tint); }
.pvbtn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.pv { display: flex; justify-content: center; }

.phone {
  width: 262px;
  border: 8px solid #2b313b;
  border-radius: 26px;
  overflow: hidden;
  background: #ece7e0;
  box-shadow: 0 8px 24px rgba(20, 24, 33, .14);
}

.desktop {
  width: 100%;
  border: 1px solid #d3d8df;
  border-radius: 10px;
  overflow: hidden;
  background: #ece7e0;
  box-shadow: 0 6px 18px rgba(20, 24, 33, .1);
}

.pv__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #f0f2f5;
  border-bottom: 1px solid #d8dde3;
}
.pv__avatar {
  width: 29px; height: 29px;
  border-radius: 50%;
  background: #b9c0cb;
  flex: none;
  display: grid;
  place-items: center;
  font-family: var(--bn);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}
.pv__who { min-width: 0; }
.pv__name { display: block; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #141821; }
.pv__num { display: block; font-family: var(--mono); font-size: 11px; color: #6b7280; }

.pv__body { padding: 14px 12px 20px; min-height: 150px; display: flex; flex-direction: column; }
.desktop .pv__body { min-height: 190px; padding: 20px 24px 26px; }

.obubble {
  align-self: flex-end;
  max-width: 86%;
  background: #d7f5c6;
  border-radius: 10px 3px 10px 10px;
  padding: 8px 11px 6px;
  font-size: 14px;
  line-height: 1.5;
  color: #0f1720;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 1px rgba(20, 24, 33, .1);
}
.desktop .obubble { max-width: 62%; }
.desktop .tplmsg { max-width: 62%; }

.obubble__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
  font-size: 10.5px;
  color: #5b6a73;
}
.ticks { color: #2f9bd6; letter-spacing: -3px; }

.pv__empty { align-self: center; margin: auto; color: #6d7681; font-size: 13px; text-align: center; padding: 0 14px; }

/* ---------- rich template preview (header image/text + body + footer + buttons) ---------- */
/* Ported directly from the approved demo — kept separate from .obubble so nothing else can interfere. */

.tplmsg { align-self: flex-end; max-width: 86%; background: #d7f5c6; border-radius: 10px 3px 10px 10px; overflow: hidden; box-shadow: 0 1px 1px rgba(20, 24, 33, .1); }
.tplmsg img { width: 100%; display: block; max-height: 150px; object-fit: cover; background: var(--panel-2); border-radius: 10px 3px 0 0; }
.tplmsg__body { padding: 8px 11px 6px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.tplmsg__time { display: block; text-align: right; font-size: 10.5px; color: #5b6a73; padding: 0 11px 6px; }

.estrows { display: grid; gap: 11px; margin-top: 13px; }
.estrow { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.estrow span:first-child { color: var(--muted); }

.countbox {
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  font-size: 14.5px;
}

/* ---------- inbox ---------- */

.inbox {
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.inbox__list {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow-y: auto;
  max-height: 580px;
  box-shadow: var(--shadow);
}

.chat {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--hair);
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .16s;
}
.chat:hover { background: var(--panel-2); }
.chat.is-open { background: var(--brand-tint); }
.chat:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

.chat__top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.chat__who { font-size: 14.5px; font-weight: 500; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat__time { font-size: 11.5px; color: var(--dim); flex: none; }
.chat__last {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 3px;
}
.chat__dot {
  display: inline-block;
  min-width: 19px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-family: var(--bn);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  margin-left: 7px;
}

.inbox__thread {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  display: flex;
  flex-direction: column;
  min-width: 0;
  box-shadow: var(--shadow);
}

.thread__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 15px 18px;
  border-bottom: 1px solid var(--hair);
}
.thread__who { font-size: 15.5px; font-weight: 600; letter-spacing: -.01em; }
.thread__meta { font-family: var(--mono); font-size: 12px; color: var(--dim); margin-top: 1px; }

.thread__body {
  flex: 1;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: 360px;
  background: #f8f7f4;
}

.bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 1px rgba(20, 24, 33, .07);
}
.bubble--in { align-self: flex-start; background: #fff; border-bottom-left-radius: 4px; }
.bubble--out { align-self: flex-end; background: #d7f5c6; border-bottom-right-radius: 4px; }
.bubble__time { display: block; font-size: 11px; color: #6b7280; margin-top: 5px; }

.thread__reply {
  border-top: 1px solid var(--hair);
  padding: 14px 18px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.thread__reply textarea { min-height: 48px; }

/* ---------- modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 33, .45);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 30;
}
.modal__box {
  background: var(--panel);
  border-radius: 14px;
  padding: 24px;
  width: min(400px, 100%);
  box-shadow: 0 18px 50px rgba(20, 24, 33, .26);
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%; bottom: 26px;
  transform: translate(-50%, 14px);
  padding: 13px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(20, 24, 33, .16);
  font-size: 14.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  max-width: min(92vw, 480px);
  z-index: 40;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: #f0cdca; color: var(--dead); }
.toast.good { border-color: #cfe8d9; color: var(--live); }

/* ---------- reports placeholder ---------- */

.soon { padding: 44px 26px; max-width: 580px; }
.soon h2 { font-size: 23px; font-weight: 600; letter-spacing: -.015em; margin: 8px 0 10px; }
.soon p { color: var(--muted); margin: 0 0 10px; }
.soon__note {
  display: inline-block;
  font-size: 13.5px;
  color: var(--wait);
  background: var(--wait-soft);
  border-radius: 9px;
  padding: 10px 14px;
  margin-top: 18px;
}

/* ---------- proxies ---------- */

.proxy-list { display: flex; flex-direction: column; gap: 9px; margin-bottom: 4px; }

.proxy-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 13px 15px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.proxy-row__main { flex: 1; min-width: 180px; }
.proxy-row__main b { display: block; font-size: 14.5px; font-weight: 500; }
.proxy-row__main span { display: block; font-family: var(--mono); font-size: 12px; color: var(--dim); margin-top: 1px; }

.tabs2 { display: flex; gap: 7px; margin-bottom: 15px; }
.tab2 {
  padding: 7px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13.5px;
  cursor: pointer;
}
.tab2.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- warmup ---------- */

.wu-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.wu-status__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); flex: none; }
.wu-status--live { border-color: var(--live); background: var(--live-soft); }
.wu-status--live .wu-status__dot { background: var(--live); }
.wu-status b { display: block; font-size: 15px; font-weight: 600; }
.wu-status span { display: block; font-size: 13px; color: var(--muted); margin-top: 1px; }

.panel.is-locked { opacity: .55; pointer-events: none; }

.wu-scripts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 4px; }
.wu-script {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
  background: var(--panel);
}
.wu-script__tag { font-size: 11px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--dim); margin-bottom: 8px; }
.wu-script__turn { display: flex; gap: 7px; margin-bottom: 6px; font-size: 13.5px; }
.wu-script__turn:last-child { margin-bottom: 0; }
.wu-script__turn span { font-family: var(--mono); font-size: 11px; color: var(--dim); flex: none; width: 13px; padding-top: 2px; }
.wu-script__del {
  position: absolute; top: 8px; right: 9px;
  border: 0; background: none; color: var(--dim);
  cursor: pointer; font-size: 15px; padding: 2px;
}
.wu-script__del:hover { color: var(--dead); }

/* ---------- inbox tabs ---------- */

.itabs { display: flex; gap: 2px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.itab {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 4px; margin-right: 24px;
  border: 0; border-bottom: 2px solid transparent;
  background: none; color: var(--muted);
  font-size: 14px; cursor: pointer;
}
.itab.is-active { color: var(--live); border-bottom-color: var(--live); font-weight: 600; }
.itab__count {
  background: var(--panel-2); color: var(--muted);
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: 9px;
}
.itab.is-active .itab__count { background: var(--live); color: #fff; }

.pill-warm {
  display: inline-block;
  margin-top: 5px;
  padding: 1px 9px;
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--wait);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
}

/* ---------- unsaved-changes indicators ---------- */

.nav__dot, .tab__dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--wait);
  margin-left: 7px;
  vertical-align: 2px;
}
.nav__item .nav__dot { margin-left: auto; }

.savebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--hair);
}
.savebar__msg {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--wait);
  visibility: hidden;
}
.savebar__msg.show { visibility: visible; }
.savebar__msg .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--wait); }
.savebar__msg.is-saved { color: var(--live); }
.savebar__msg.is-saved .dot { background: var(--live); }

/* ---------- small screens ---------- */

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; min-height: 0; }
  .nav {
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 10px 12px;
    gap: 6px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand { padding: 0 10px 0 4px; }
  .brand__dot { margin-left: 8px; }
  .nav__item { width: auto; white-space: nowrap; }
  .nav__foot { display: none; }

  .shell { grid-template-columns: 1fr; padding: 18px 14px 30px; }
  .pane { padding: 18px 14px 30px; }
  .frame img { width: min(62vw, 212px); height: auto; }

  .trow, .trow--leads, .trow--dev { grid-template-columns: 1fr 1fr; row-gap: 6px; }
  .trow--head { display: none; }
  .trow__acts { justify-content: flex-start; }

  .crow { grid-template-columns: minmax(0, 1fr) 112px; row-gap: 10px; }
  .crow > :nth-child(3), .crow > :nth-child(4) { grid-column: 1 / -1; }
  .crow--head { display: none; }
  .crow__acts { grid-column: 1 / -1; justify-content: flex-start; }

  .arow { grid-template-columns: minmax(0, 1fr) auto; row-gap: 8px; }
  .arow > :nth-child(2), .arow > :nth-child(3) { grid-column: 1 / -1; }
  .arow--head { display: none; }
  .arow__acts { grid-column: 1 / -1; justify-content: flex-start; }

  .inbox { grid-template-columns: 1fr; }
  .inbox__list { max-height: 260px; }

  .builder { grid-template-columns: 1fr; }
  .builder__side { position: static; }

  .logrow { grid-template-columns: 1fr 1fr; row-gap: 4px; }
  .logrow__st { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}