:root {
  --bg: #f6f7fb;
  --panel: #fff;
  --text: #1b1f2a;
  --muted: #6a7285;
  --line: #e4e7ef;
  --brand: #4f46e5;
  --brand-text: #fff;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --ok-bg: #dcfce7;
  --warn-bg: #fef3c7;
  --bad-bg: #fee2e2;
  --info-bg: #e0e7ff;
  --neutral-bg: #eef0f6;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1220;
    --panel: #171b2d;
    --text: #e8eaf3;
    --muted: #9aa3bd;
    --line: #262c45;
    --brand: #818cf8;
    --brand-text: #0f1220;
    --ok: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
    --ok-bg: #12301f;
    --warn-bg: #3a2c0c;
    --bad-bg: #3d1717;
    --info-bg: #232a5c;
    --neutral-bg: #232842;
    --shadow: none;
  }
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    14px/1.5 system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
}
h1 {
  font-size: 20px;
  margin: 0;
}
h2 {
  font-size: 15px;
  margin: 0 0 10px;
}
h3 {
  font-size: 13px;
  margin: 14px 0 6px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
a {
  color: var(--brand);
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
input,
select,
textarea {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  min-width: 0;
}
input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}
textarea {
  width: 100%;
  resize: vertical;
  min-height: 90px;
}
button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 6px 12px;
}
button:hover {
  background: var(--neutral-bg);
}
button.primary {
  background: var(--brand);
  color: var(--brand-text);
  border-color: var(--brand);
  font-weight: 600;
}
button.primary:hover {
  filter: brightness(1.08);
}
button.danger {
  color: var(--bad);
}
button.small {
  padding: 3px 9px;
  font-size: 12px;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}

.auth {
  max-width: 380px;
  margin: 9vh auto;
  padding: 0 16px;
}
.auth .card {
  padding: 24px;
}
.auth form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
}
.logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--brand);
  color: var(--brand-text);
  display: grid;
  place-items: center;
  font-weight: 800;
}

.shell {
  display: grid;
  grid-template-columns: 210px 1fr;
  min-height: 100vh;
}
.side {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side .brand {
  padding: 0 8px 14px;
}
.side a.nav {
  color: var(--text);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
}
.side a.nav:hover {
  background: var(--neutral-bg);
}
.side a.nav.active {
  background: var(--info-bg);
  color: var(--brand);
  font-weight: 600;
}
.side .spacer {
  flex: 1;
}
.main {
  min-width: 0;
}
.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-wrap: wrap;
}
.top .grow {
  flex: 1;
}
.content {
  padding: 20px 24px 60px;
  max-width: 1200px;
}
.page-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.page-head .grow {
  flex: 1;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.grid {
  display: grid;
  gap: 14px;
}
.stats {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}
.cols2 {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
.stat .label {
  color: var(--muted);
  font-size: 12px;
}
.stat .value {
  font-size: 24px;
  font-weight: 700;
  margin-top: 2px;
}
.stat .sub {
  color: var(--muted);
  font-size: 12px;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 12px;
}
.nowrap {
  white-space: nowrap;
}
.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.row.end {
  justify-content: flex-end;
}
.stack {
  display: grid;
  gap: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
}
th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
tr:last-child td {
  border-bottom: 0;
}
.tablewrap {
  overflow-x: auto;
}

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--neutral-bg);
  white-space: nowrap;
}
.badge.ok,
.badge.published,
.badge.positive,
.badge.connected {
  background: var(--ok-bg);
  color: var(--ok);
}
.badge.warn,
.badge.pending_approval,
.badge.scheduled,
.badge.pending,
.badge.publishing,
.badge.partially_published {
  background: var(--warn-bg);
  color: var(--warn);
}
.badge.bad,
.badge.failed,
.badge.negative,
.badge.disconnected,
.badge.spam {
  background: var(--bad-bg);
  color: var(--bad);
}
.badge.info,
.badge.approved,
.badge.open {
  background: var(--info-bg);
  color: var(--brand);
}

.bars {
  display: grid;
  gap: 6px;
}
.bar {
  display: grid;
  grid-template-columns: 90px 1fr 44px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}
.bar .track {
  background: var(--neutral-bg);
  border-radius: 6px;
  height: 10px;
  overflow: hidden;
}
.bar .fill {
  background: var(--brand);
  height: 100%;
  border-radius: 6px;
}
.bar .fill.positive {
  background: var(--ok);
}
.bar .fill.negative {
  background: var(--bad);
}
.bar .fill.neutral {
  background: var(--muted);
}
.spark {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 70px;
}
.spark span {
  flex: 1;
  background: var(--brand);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  opacity: 0.85;
}

.split {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 14px;
  align-items: start;
}
.list {
  padding: 0;
  overflow: hidden;
}
.item {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.item:last-child {
  border-bottom: 0;
}
.item:hover {
  background: var(--neutral-bg);
}
.item.sel {
  background: var(--info-bg);
}
.item .t {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.bubble {
  background: var(--neutral-bg);
  border-radius: 10px;
  padding: 8px 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble.mine {
  background: var(--info-bg);
  margin-left: 40px;
}
.tag {
  background: var(--neutral-bg);
  border-radius: 6px;
  padding: 0 6px;
  font-size: 12px;
}
.empty {
  color: var(--muted);
  text-align: center;
  padding: 28px 10px;
}
.err {
  color: var(--bad);
}

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 45%);
  display: grid;
  place-items: start center;
  padding: 6vh 12px;
  overflow-y: auto;
  z-index: 50;
}
.modal {
  width: min(560px, 100%);
}
.modal .foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}
label.f {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}
label.f > :not(span) {
  color: var(--text);
}
.checks {
  display: grid;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
}
.checks label {
  display: flex;
  gap: 8px;
  align-items: center;
}
#toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 8px;
  z-index: 100;
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 9px 14px;
  border-radius: 8px;
  max-width: 360px;
  box-shadow: 0 4px 14px rgb(0 0 0 / 25%);
}
.toast.bad {
  background: var(--bad);
  color: #fff;
}

@media (max-width: 800px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .side {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .side .brand {
    display: none;
  }
  .side .spacer {
    display: none;
  }
  .split {
    grid-template-columns: 1fr;
  }
  .content,
  .top {
    padding-left: 14px;
    padding-right: 14px;
  }
}
