:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1b1f24;
  --muted: #667085;
  --line: #e3e6ea;
  --brand: #1f6feb;
  --brand-ink: #ffffff;
  --ok-bg: #e7f6ec; --ok-ink: #12683a; --ok-line: #9bd8b4;
  --warn-bg: #fdf3e2; --warn-ink: #8a5a00; --warn-line: #eccb8d;
  --bad-bg: #fdecec; --bad-ink: #9b1c1c; --bad-line: #f0b0b0;
  --sidebar: #14181f;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.shell { display: flex; min-height: 100vh; }

/* ---------- sidebar ---------- */
.sidebar {
  width: 232px; flex: 0 0 232px;
  background: var(--sidebar); color: #cdd5e0;
  display: flex; flex-direction: column; padding: 18px 14px;
}
.brand { color: #fff; font-weight: 650; font-size: 15px; letter-spacing: .2px; }
.brand small { display: block; color: #8b97a8; font-weight: 400; font-size: 12px; margin-top: 2px; }

.nav { margin-top: 22px; display: flex; flex-direction: column; gap: 2px; }
.nav button {
  all: unset; cursor: pointer; padding: 9px 11px; border-radius: 8px;
  font-size: 14px; color: #cdd5e0; display: flex; align-items: center; gap: 9px;
}
.nav button:hover { background: #1e242e; }
.nav button.active { background: var(--brand); color: #fff; font-weight: 550; }
.nav .dot { width: 6px; height: 6px; border-radius: 50%; background: #6ee7a8; }

.tenant { margin-top: auto; border-top: 1px solid #232a34; padding-top: 14px; }
.tenant label { display: block; font-size: 11px; text-transform: uppercase;
  letter-spacing: .6px; color: #79839a; margin: 0 0 5px; }
.tenant select {
  width: 100%; padding: 7px 8px; border-radius: 7px; font-size: 13px;
  background: #1e242e; color: #e6ebf2; border: 1px solid #2c3441; margin-bottom: 10px;
}
.tenant .plan { font-size: 12px; color: #79839a; }

/* ---------- main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 13px 22px; display: flex; align-items: center; gap: 12px;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 600; }
.topbar .spacer { flex: 1; }

.content { padding: 22px; flex: 1; min-width: 0; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.card h2 { font-size: 15px; margin: 0 0 4px; font-weight: 600; }
.card .sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }

button.btn {
  all: unset; cursor: pointer; background: var(--brand); color: var(--brand-ink);
  padding: 8px 14px; border-radius: 8px; font-size: 14px; font-weight: 550;
}
button.btn:hover { filter: brightness(1.08); }
button.btn[disabled] { opacity: .5; cursor: not-allowed; }
button.btn.ghost { background: transparent; color: var(--brand); box-shadow: inset 0 0 0 1px var(--line); }

input.text {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; font-family: inherit; min-width: 260px;
}

/* ---------- notices ---------- */
.notice { border-radius: 9px; padding: 11px 13px; font-size: 13.5px; margin-bottom: 14px; border: 1px solid; }
.notice.ok   { background: var(--ok-bg);   color: var(--ok-ink);   border-color: var(--ok-line); }
.notice.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }
.notice.bad  { background: var(--bad-bg);  color: var(--bad-ink);  border-color: var(--bad-line); }
.notice strong { display: block; margin-bottom: 3px; }
.notice code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

/* ---------- chat frame ---------- */
.frame-wrap {
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; background: #fff; height: calc(100vh - 250px); min-height: 460px;
}
.frame-wrap iframe { width: 100%; height: 100%; border: 0; display: block; }

.placeholder {
  height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 14px;
}

/* ---------- hybrid conversations ---------- */
.hybrid {
  display: grid; grid-template-columns: minmax(270px, 350px) 1fr;
  gap: 14px; align-items: start;
}
@media (max-width: 920px) { .hybrid { grid-template-columns: 1fr; } }

.hybrid-list, .hybrid-thread {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.hybrid-list { max-height: calc(100vh - 270px); overflow-y: auto; }
.hybrid-thread { display: flex; flex-direction: column; min-height: 470px; }

.conv-list { list-style: none; margin: 0; padding: 0; }
.conv-list li {
  display: flex; gap: 10px; padding: 12px 13px; cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.conv-list li:last-child { border-bottom: 0; }
.conv-list li:hover { background: #f8f9fb; }
.conv-list li.active { background: #eaf1fd; }
.conv-list li.unread .nm { font-weight: 700; }
.conv-list .grow { flex: 1; min-width: 0; display: block; }
.conv-list .line1 { display: flex; align-items: baseline; gap: 8px; }
.conv-list .nm { font-weight: 550; font-size: 14px; }
.conv-list .when { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.conv-list .line2 { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.conv-list .prev {
  color: var(--muted); font-size: 13px; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conv-list .line3 { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.conv-list .pill {
  background: var(--brand); color: #fff; font-size: 11px; font-weight: 650;
  border-radius: 999px; padding: 1px 7px; min-width: 18px; text-align: center;
}

.avatar {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%;
  background: #e6ecf5; color: #46566e; font-size: 12px; font-weight: 650;
  display: flex; align-items: center; justify-content: center;
}

.thread-head {
  display: flex; align-items: center; gap: 8px; font-size: 14px;
  padding: 9px 13px; border-bottom: 1px solid var(--line);
}
.frame-wrap.flush {
  border: 0; border-radius: 0; height: calc(100vh - 340px); min-height: 410px;
}
.empty { padding: 26px 18px; text-align: center; }

/* ---------- steps ---------- */
.steps { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13px; }
.steps li { padding: 4px 0 4px 20px; position: relative; color: #2c3a2f; }
.steps li::before { content: "✓"; position: absolute; left: 2px; color: #12683a; font-weight: 700; }

/* ---------- channel tabs ---------- */
.chan-tabs {
  display: flex; gap: 4px; margin: 0 0 16px;
  border-bottom: 1px solid var(--line);
}
.chan-tabs button {
  all: unset; cursor: pointer; padding: 8px 14px; font-size: 14px;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.chan-tabs button:hover { color: var(--ink); }
.chan-tabs button.active {
  color: var(--brand); border-bottom-color: var(--brand); font-weight: 600;
}

/* ---------- pages / inboxes ---------- */
.page-list { list-style: none; margin: 0 0 14px; padding: 0; }
.page-list li {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; margin-bottom: 8px;
}
.page-list li.taken { opacity: .55; background: #fafbfc; }
.page-list .nm { font-weight: 550; }
.page-list .id { color: var(--muted); font-size: 12px; }
.page-list .grow { flex: 1; min-width: 0; }
.badge {
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  padding: 3px 7px; border-radius: 999px; background: #eef1f5; color: var(--muted);
}
.badge.live { background: var(--ok-bg); color: var(--ok-ink); }

table.inboxes { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.inboxes th, table.inboxes td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.inboxes th { color: var(--muted); font-weight: 550; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }

.meter { font-size: 13px; color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  word-break: break-all; color: var(--muted); }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 24px;
}
.login-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 30px 28px;
  width: 100%; max-width: 380px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
}
.login-card h1 { font-size: 19px; margin: 0 0 2px; font-weight: 650; }
.login-card .sub { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }
.login-card label {
  display: block; font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px; margin: 0 0 5px;
}
.login-card input.text { width: 100%; min-width: 0; margin-bottom: 16px; }
.login-card button.btn { width: 100%; text-align: center; }
