:root {
  --ink: #0c1222;
  --ink-2: #151c2c;
  --accent: #5b8def;
  --accent-2: #4c7ae0;
  --accent-soft: #eef3ff;
  --ok: #12b76a;
  --ok-soft: #ecfdf3;
  --warn: #f79009;
  --warn-soft: #fffaeb;
  --danger: #f04438;
  --danger-soft: #fef3f2;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --line: #e7ebf2;
  --line-strong: #d5dce8;
  --text: #121826;
  --muted: #667085;
  --faint: #98a2b3;
  --sidebar-w: clamp(196px, 16vw, 248px);
  --list-w: clamp(300px, 32vw, 460px);
  --customer-w: clamp(240px, 22vw, 300px);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.04);
  --font: 'Plus Jakarta Sans', ui-sans-serif, system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html {
  margin: 0;
  height: 100%;
  font-size: clamp(13px, 0.28vw + 12.2px, 16px);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html, body {
  max-width: 100%;
  overflow-x: hidden;
  overflow-x: clip;
}
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 0.875rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img, svg, video, canvas { max-width: 100%; }
button, input, textarea, select { min-width: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
input, textarea, select {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(91, 141, 239, 0.16);
}
#app { min-height: 100%; min-height: 100dvh; max-width: 100%; }
.ico { width: 1.25rem; height: 1.25rem; flex: 0 0 auto; pointer-events: none; }

/* ── Login ── */

.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  width: 100%;
}
.login-hero {
  background:
    radial-gradient(900px 500px at 10% 10%, rgba(91, 141, 239, 0.28), transparent 55%),
    radial-gradient(700px 420px at 90% 90%, rgba(18, 183, 106, 0.16), transparent 50%),
    var(--ink);
  color: #fff;
  padding: clamp(1.5rem, 5vw, 3.5rem) clamp(1.25rem, 5vw, 4rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  overflow: hidden;
}
.login-hero-foot {
  color: rgba(255,255,255,.45);
  font-size: 0.8rem;
}
.login-mark {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.04em;
}
.login-mark-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  display: grid;
  place-items: center;
}
.login-hero h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: -0.05em;
  line-height: 1.1;
  max-width: 11ch;
}
.login-hero p {
  margin: 0;
  max-width: 36ch;
  color: rgba(255,255,255,0.72);
  font-size: 1.05rem;
}
.login-pills { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1.5rem; }
.login-pill {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  font-size: 0.78rem;
  color: rgba(255,255,255,0.8);
}
.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1.1rem, 3vw, 2rem);
  background: var(--bg);
  min-width: 0;
}
.login-card {
  width: min(26.25rem, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: clamp(1.25rem, 3vw, 2rem);
  box-shadow: var(--shadow);
}
.login-card h2 { margin: 0 0 0.35rem; font-size: 1.45rem; letter-spacing: -0.03em; }
.login-card .sub { margin: 0 0 1.5rem; color: var(--muted); }
.login-field { margin-bottom: 0.85rem; }
.login-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.login-field input { width: 100%; padding: 0.8rem 0.9rem; }
.login-btn {
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.9rem;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  border-radius: 12px;
  transition: transform 0.15s, background 0.15s;
}
.login-btn:hover { background: var(--ink-2); transform: translateY(-1px); }
.login-btn:disabled { opacity: 0.6; cursor: wait; transform: none; }
.login-error { color: var(--danger); font-size: 0.85rem; min-height: 1.2rem; margin: 0.35rem 0 0; }
.login-hint {
  margin-top: 1.1rem;
  padding: 0.85rem 1rem;
  background: var(--accent-soft);
  border-radius: 12px;
  color: #34508f;
  font-size: 0.82rem;
}
.login-text-btn {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}
.login-text-btn:hover { color: var(--ink); }
.login-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  background: var(--bg);
  padding: 0.25rem;
  border-radius: 12px;
  margin-bottom: 1.1rem;
}
.login-tabs button {
  padding: 0.55rem 0.4rem;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
}
.login-tabs button.active {
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow);
}

/* ── Layout ── */

.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) var(--list-w) minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}
.app-layout.with-customer {
  grid-template-columns: var(--sidebar-w) var(--list-w) minmax(0, 1fr) var(--customer-w);
}
.app-layout.page {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

/* ── Sidebar ── */

.nav-sidebar {
  background: var(--ink);
  color: #c9d4ea;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: auto;
  padding: 1rem 0.85rem 0.85rem;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.45rem 0.55rem 1.1rem;
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.04em;
}
.nav-brand-badge {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent);
  display: grid;
  place-items: center;
  color: #fff;
}
.nav-menu { flex: 1; display: flex; flex-direction: column; gap: 0.2rem; min-height: 0; overflow: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.7rem 0.8rem;
  color: #9aa8c3;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 12px;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: rgba(91, 141, 239, 0.18); color: #fff; }
.nav-user {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.75rem 0.55rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-top: 0.5rem;
  min-width: 0;
}
.nav-user > div { min-width: 0; }
.nav-user strong, .nav-user span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #243049;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
}
.nav-user strong { display: block; color: #fff; font-size: 0.84rem; }
.nav-user span { font-size: 0.72rem; color: #8b98b3; }
.nav-logout {
  margin-top: 0.25rem;
  padding: 0.55rem 0.8rem;
  color: #8b98b3;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: left;
  border-radius: 10px;
}
.nav-logout:hover { color: #fda29b; background: rgba(240, 68, 56, 0.12); }

/* ── Chat list ── */

.chat-list-panel {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  min-width: 0;
}
.panel-head { padding: 1.15rem 1.1rem 0.85rem; }
.panel-head h2 {
  margin: 0 0 0.75rem;
  font-size: 1.2rem;
  letter-spacing: -0.03em;
}
.search-wrap { position: relative; }
.search-wrap .ico {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  width: 16px;
  height: 16px;
}
.search-input {
  width: 100%;
  padding: 0.65rem 0.75rem 0.65rem 2.2rem;
  background: var(--bg);
  border-color: transparent;
}
.search-input:focus { background: #fff; }
.channel-tabs, .status-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 1.1rem 0.75rem;
}
.channel-tab, .status-tab {
  padding: 0.38rem 0.78rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--muted);
  background: var(--bg);
  white-space: nowrap;
  flex: 0 0 auto;
}
.channel-tab:hover, .status-tab:hover { color: var(--text); }
.channel-tab.active, .status-tab.active {
  background: var(--ink);
  color: #fff;
}
.chat-list { flex: 1; overflow-y: auto; min-height: 0; list-style: none; margin: 0; padding: 0 0.55rem 1rem; }
.chat-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  padding: 0.8rem 0.75rem;
  border-radius: 14px;
  transition: background 0.15s;
}
.chat-item:hover { background: var(--bg); }
.chat-item.active { background: var(--accent-soft); }
.chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.78rem;
  color: #fff;
  position: relative;
}
.chat-avatar .ch-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--accent);
}
.chat-item-main { min-width: 0; }
.chat-item-top { display: flex; justify-content: space-between; gap: 0.65rem; align-items: baseline; }
.chat-item-name {
  font-weight: 700;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.chat-item.new .chat-item-name { font-weight: 800; }
.chat-item-time { font-size: 0.72rem; color: var(--faint); flex: 0 0 auto; }
.chat-item-preview {
  margin-top: 0.15rem;
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-item-meta { display: flex; gap: 0.35rem; align-items: center; margin-top: 0.4rem; flex-wrap: wrap; }
.channel-badge, .status-chip, .vip-badge, .sla-chip {
  font-size: 0.75rem;
  line-height: 1.2;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-weight: 700;
  flex: 0 0 auto;
  white-space: nowrap;
}
.channel-badge.whatsapp { background: #d1fadf; color: #067647; }
.channel-badge.telegram { background: #e0f2fe; color: #026aa2; }
.channel-badge.vk { background: #e0e7ff; color: #3538cd; }
.channel-badge.avito { background: #d1fadf; color: #027a48; }
.channel-badge.instagram { background: #fce7f6; color: #c11574; }
.channel-badge.max { background: #f4ebff; color: #6941c6; }
.channel-badge.email { background: #ffead5; color: #b54708; }
.channel-badge.webchat { background: var(--accent-soft); color: #3538cd; }
.status-chip { background: var(--bg); color: var(--muted); }
.status-chip.new { background: var(--ok-soft); color: #067647; }
.status-chip.sla, .sla-chip { background: var(--danger-soft); color: #b42318; }
.vip-badge { background: var(--warn-soft); color: #b54708; }
.empty-state {
  margin: 2rem 1rem;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  background: var(--bg);
  border-radius: 16px;
}
.empty-state strong { display: block; color: var(--text); margin-bottom: 0.25rem; }

/* ── Conversation ── */

.conversation-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  min-width: 0;
  background:
    radial-gradient(circle at 1px 1px, #e7ebf2 1px, transparent 0) 0 0 / 22px 22px,
    #f7f8fb;
}
.conv-header {
  padding: 0.85rem 1.15rem;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  flex: 0 0 auto;
}
.conv-title { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.conv-header h1 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-header p, .conv-channel {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.back-btn, .icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: none;
  place-items: center;
  color: var(--muted);
  background: var(--bg);
}
.icon-btn { display: grid; }
.icon-btn:hover, .back-btn:hover { color: var(--text); }
.conv-actions { display: flex; gap: 0.45rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.conv-actions select { padding: 0.4rem 0.55rem; font-size: 0.78rem; background: var(--bg); border-color: transparent; }
.btn-sm {
  padding: 0.42rem 0.8rem;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 700;
}
.btn-green, .btn-primary { background: var(--ink); color: #fff; }
.btn-green:hover, .btn-primary:hover { background: var(--ink-2); }
.btn-outline { background: var(--bg); color: var(--muted); }
.btn-outline:hover { color: var(--text); }
.messages-area {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 1.35rem 1.35rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.msg-row { display: flex; }
.msg-row.outgoing { justify-content: flex-end; }
.msg-bubble {
  max-width: min(78%, 35rem);
  padding: 0.7rem 0.9rem;
  border-radius: 18px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
}
.msg-bubble.incoming {
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}
.msg-bubble.outgoing {
  background: var(--ink);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.msg-bubble.outgoing .msg-meta { color: rgba(255,255,255,0.55); }
.msg-meta { font-size: 0.68rem; color: var(--faint); margin-top: 0.3rem; }
.composer-wrap {
  margin: 0.5rem clamp(0.6rem, 1.5vw, 1rem) clamp(0.6rem, 1.5vw, 1rem);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  min-width: 0;
  flex: 0 0 auto;
}
.macros-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.7rem 0.85rem 0;
}
.macro-btn {
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 650;
  color: var(--muted);
  background: var(--bg);
}
.macro-btn:hover { color: var(--text); background: var(--accent-soft); }
.composer-area {
  padding: 0.55rem 0.7rem 0.7rem;
  display: flex;
  gap: 0.55rem;
  align-items: flex-end;
}
.composer-area textarea {
  flex: 1;
  min-height: 44px;
  max-height: 140px;
  resize: none;
  padding: 0.7rem 0.4rem;
  border: 0;
  box-shadow: none;
  background: transparent;
}
.composer-area textarea:focus { box-shadow: none; }
.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.send-btn:hover { background: var(--accent-2); }
.send-btn:disabled { opacity: 0.5; cursor: wait; }
.hint-enter { font-size: 0.7rem; color: var(--faint); padding: 0 1rem 0.65rem; }
.conv-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}
.conv-empty-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2.2rem 2rem;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.conv-empty h2 { font-size: 1.3rem; letter-spacing: -0.03em; margin: 0 0 0.4rem; }
.conv-empty p { margin: 0; color: var(--muted); }

/* ── Customer ── */

.customer-panel {
  background: var(--surface);
  border-left: 1px solid var(--line);
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
}
.customer-panel-head { padding: 1.25rem 1.1rem 1rem; text-align: center; }
.customer-avatar {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: #34508f;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  font-weight: 800;
  margin: 0 auto 0.7rem;
}
.customer-panel-head h3 { margin: 0; font-size: 1rem; }
.customer-panel-head p { margin: 0.25rem 0 0; font-size: 0.8rem; color: var(--muted); }
.customer-section { padding: 0.9rem 1.1rem; border-top: 1px solid var(--line); }
.customer-section h4 {
  margin: 0 0 0.55rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  font-weight: 700;
}
.customer-field {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.84rem;
  padding: 0.28rem 0;
}
.customer-field span:first-child { color: var(--muted); }
.customer-field span:last-child { text-align: right; word-break: break-all; }
.tag-list { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.tag {
  padding: 0.15rem 0.5rem;
  background: var(--accent-soft);
  color: #34508f;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 650;
}

/* ── Pages ── */

.page-content {
  padding: clamp(1rem, 2.2vw, 1.6rem) clamp(1rem, 2.4vw, 1.8rem) 2.5rem;
  overflow-y: auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
  grid-column: 2 / -1;
}
.page-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1.4rem;
}
.page-content h2 { margin: 0; font-size: 1.55rem; letter-spacing: -0.04em; }
.page-lead { margin: 0.3rem 0 0; color: var(--muted); }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 12.5rem), 1fr));
  gap: 1rem;
  margin-bottom: 1.2rem;
}
.stat-card, .stats-block, .channel-card, .settings-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.stat-card { padding: 1.15rem 1.2rem; }
.stat-card .label { font-size: 0.78rem; color: var(--muted); font-weight: 650; margin-bottom: 0.4rem; }
.stat-card .value { font-size: 1.85rem; font-weight: 800; letter-spacing: -0.04em; }
.stat-card .value.danger { color: var(--danger); }
.stats-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17.5rem), 1fr)); gap: 1rem; }
.stats-block { padding: 1.1rem 1.15rem; }
.stats-block h3 { margin: 0 0 0.75rem; font-size: 0.95rem; }
.stats-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  font-size: 0.86rem;
  border-bottom: 1px solid var(--line);
}
.stats-row:last-child { border-bottom: none; }
.bar {
  height: 6px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 0.35rem;
}
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }

.channels-layout {
  display: grid;
  grid-template-columns: minmax(0, 23.75rem) minmax(0, 1fr);
  gap: 1.1rem;
  align-items: start;
}
.channels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15.6rem), 1fr));
  gap: 0.9rem;
}
.channel-card, .settings-card { padding: 1.15rem; }
.channel-card-head, .settings-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}
.channel-card-head h3, .settings-card h3 { margin: 0; font-size: 0.98rem; }
.channel-state {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
}
.channel-state.active { background: var(--ok-soft); color: #067647; }
.channel-state.disabled { background: var(--bg); color: var(--muted); }
.channel-state.error { background: var(--danger-soft); color: #b42318; }
.channel-state.stale { background: var(--warn-soft); color: #b54708; }
.channel-card p, .settings-card p { margin: 0; font-size: 0.82rem; color: var(--muted); }
.channel-card-actions { margin-top: 0.9rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.channel-name { display: flex; align-items: center; gap: 0.65rem; min-width: 0; }
.channel-name h3 {
  margin: 0;
  font-size: 1.12rem;
  letter-spacing: -0.03em;
  white-space: nowrap;
}
.channel-name-mark {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  flex: 0 0 auto;
}
.channel-mode-row {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.85rem 0 0.15rem;
  border-top: 1px solid var(--line);
  margin-top: 0.7rem;
}
.channel-mode-copy strong {
  display: inline-block;
  margin-right: 0.5rem;
  font-size: 0.95rem;
  color: var(--text);
}
.channel-mode-copy p { margin: 0.35rem 0 0; }
.channel-mode-row .channel-card-actions { margin-top: 0.15rem; }
.connect-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.85rem 0 0.2rem;
}
.connect-mode {
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}
.connect-mode.active { background: var(--ink); color: #fff; }
.catalog-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
}
.connect-card { min-height: 0; }
.add-channel-card {
  border: 1.5px dashed var(--line-strong);
  border-radius: 16px;
  padding: 1.6rem 1rem;
  text-align: center;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  font-weight: 700;
}
.add-channel-card:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.7rem; }
.field label { font-size: 0.74rem; font-weight: 700; color: var(--muted); }
.field input, .field select { width: 100%; padding: 0.65rem 0.75rem; }
.code-box {
  margin-top: 0.7rem;
  padding: 0.7rem 0.8rem;
  background: var(--bg);
  border-radius: 10px;
  font-size: 0.75rem;
  overflow-x: auto;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.team-table {
  width: 100%;
  min-width: 36rem;
  background: var(--surface);
  border-collapse: collapse;
}
.team-table th, .team-table td {
  padding: 0.85rem 1rem;
  text-align: left;
  font-size: 0.86rem;
  border-bottom: 1px solid var(--line);
}
.team-table th {
  background: #fafbfe;
  font-weight: 700;
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.online-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.4rem;
}
.online-indicator.on { background: var(--ok); box-shadow: 0 0 0 4px rgba(18,183,106,0.15); }
.online-indicator.off { background: var(--faint); }

.mobile-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 0.4rem 0.4rem calc(0.4rem + env(safe-area-inset-bottom));
  grid-template-columns: repeat(5, 1fr);
}
.mobile-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.4rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 10px;
}
.mobile-nav button.active { color: var(--accent); background: var(--accent-soft); }

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 13.75rem), 1fr));
  gap: 0.75rem;
  margin-top: 0.85rem;
}
.choice-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.95rem 1rem;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  background: #fff;
}
.choice-card input { accent-color: var(--accent); margin-bottom: 0.2rem; }
.choice-card strong { font-size: 0.92rem; }
.choice-card span { font-size: 0.8rem; color: var(--muted); line-height: 1.4; }
.choice-card.selected, .choice-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.settings-stack { display: flex; flex-direction: column; gap: 1rem; max-width: 860px; }
.settings-stack .settings-card h3 { margin: 0 0 0.35rem; }
.settings-stack .settings-card > p { margin: 0; color: var(--muted); font-size: 0.86rem; }
.start-pack {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 1.1rem;
  padding: 1.05rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.start-pack strong { font-size: 0.95rem; }
.start-pack span { color: var(--muted); font-size: 0.86rem; line-height: 1.45; }
.start-pack-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.catalog-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
}
.attach-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--bg);
  color: var(--muted);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.attach-btn:hover { color: var(--text); background: var(--accent-soft); }
.file-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0.85rem 0.35rem;
  padding: 0.25rem 0.55rem;
  background: var(--accent-soft);
  border-radius: 999px;
  font-size: 0.74rem;
  width: fit-content;
}
.file-chip button { font-size: 1rem; line-height: 1; color: var(--muted); }
.macro-list { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.75rem; }
.macro-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.7rem 0.8rem;
  background: var(--bg);
  border-radius: 12px;
}
.macro-item strong { display: block; font-size: 0.86rem; }
.macro-item span { color: var(--muted); font-size: 0.8rem; white-space: pre-wrap; word-break: break-word; }
.connect-card { min-height: 0; display: flex; flex-direction: column; }
.connect-card .channel-card-actions { margin-top: 0.15rem; }
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 18, 34, 0.55);
  display: grid;
  place-items: center;
  z-index: 80;
  padding: clamp(0.7rem, 3vw, 1.2rem);
}
.modal-card {
  width: min(36rem, 100%);
  max-height: min(90dvh, 47.5rem);
  overflow: auto;
  background: #fff;
  border-radius: 20px;
  padding: 1.35rem 1.4rem 1.25rem;
  box-shadow: 0 24px 64px rgba(12, 18, 34, 0.28);
}
.modal-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.modal-head h2 { margin: 0.15rem 0 0; font-size: 1.25rem; letter-spacing: -0.03em; }
.modal-kicker {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.modal-blurb { color: var(--muted); margin: 0.7rem 0 0.85rem; }
.modal-steps { margin: 0 0 0.85rem; padding-left: 1.15rem; color: var(--text); }
.modal-steps li { margin: 0.25rem 0; }
.modal-note {
  background: var(--accent-soft);
  color: #34508f;
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  font-size: 0.8rem;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.4rem; }
.modal-card .icon-btn { font-size: 1.3rem; line-height: 1; }
.pair-box {
  margin: 0.9rem 0 0.2rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  text-align: center;
}
.pair-box .qr-img { margin: 0.2rem auto 0.6rem; }
.qr-img {
  display: block;
  width: 220px;
  height: 220px;
  margin: 0.8rem auto;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.health-error { color: #b42318; font-size: 0.78rem; margin: 0.4rem 0 0; }
.webhook-url {
  margin: 0.45rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  word-break: break-all;
}
.webhook-url code { font-size: 0.7rem; }
.invite-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1rem;
}
.invite-row input, .invite-row select {
  padding: 0.55rem 0.7rem;
  min-width: 0;
  flex: 1 1 10rem;
}
.folder-count {
  font-size: 0.68rem;
  font-weight: 800;
  background: var(--accent-soft);
  color: #34508f;
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
}
.msg-photo {
  display: block;
  max-width: min(15rem, 100%);
  max-height: 13.75rem;
  border-radius: 10px;
  margin-bottom: 0.4rem;
}
.msg-file {
  display: inline-block;
  margin-bottom: 0.35rem;
  color: var(--accent);
  font-weight: 650;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.id-chip {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.74rem;
  background: var(--bg);
}
.id-chip.active { background: var(--accent-soft); border-color: var(--accent); color: #34508f; }
.merge-input { width: 100%; padding: 0.5rem 0.65rem; margin-top: 0.3rem; }
.merge-hits { display: flex; flex-direction: column; gap: 0.25rem; margin-top: 0.4rem; }
.merge-hit {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  background: var(--bg);
  font-size: 0.8rem;
}
.merge-hit:hover { background: var(--accent-soft); }
.toast {
  position: fixed;
  bottom: max(1.4rem, env(safe-area-inset-bottom));
  right: max(1rem, env(safe-area-inset-right));
  max-width: min(22rem, calc(100vw - 2rem));
  background: var(--ink);
  color: #fff;
  padding: 0.8rem 1.05rem;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 12px 32px rgba(12, 18, 34, 0.25);
  z-index: 100;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1180px) {
  .app-layout.with-customer {
    grid-template-columns: var(--sidebar-w) var(--list-w) minmax(0, 1fr);
  }
  .customer-panel { display: none; }
  .customer-panel.open {
    display: block;
    position: fixed;
    right: 0;
    top: 0;
    width: min(20rem, 92vw);
    height: 100dvh;
    z-index: 30;
    box-shadow: var(--shadow);
  }
  .channels-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1024px) {
  :root {
    --sidebar-w: clamp(176px, 22vw, 220px);
    --list-w: clamp(260px, 38vw, 380px);
  }
  .login-hero h1 { max-width: none; }
}
@media (max-width: 860px) {
  .login-page {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }
  .login-hero {
    padding: 1.1rem 1.15rem 1.2rem;
    justify-content: flex-start;
    gap: 0.75rem;
  }
  .login-hero h1 { font-size: 1.35rem; margin: 0; }
  .login-hero p, .login-pills, .login-hero-foot { display: none; }
  .login-mark { font-size: 1.05rem; }
  .app-layout, .app-layout.with-customer, .app-layout.page {
    grid-template-columns: minmax(0, 1fr);
    padding-bottom: calc(4rem + env(safe-area-inset-bottom));
  }
  .nav-sidebar { display: none; }
  .mobile-nav { display: grid; }
  .page-content { grid-column: 1 / -1; }
  .chat-list-panel, .conversation-panel { height: 100%; }
  .app-layout.thread .chat-list-panel { display: none; }
  .app-layout:not(.thread) .conversation-panel { display: none; }
  .back-btn { display: grid; }
  .msg-bubble { max-width: min(88%, 100%); }
  .composer-area { align-items: stretch; }
  .conv-header { padding: 0.7rem 0.85rem; }
  .page-content { padding-bottom: 1.5rem; }
  .qr-img { width: min(13.75rem, 70vw); height: auto; aspect-ratio: 1; }
}
@media (max-width: 520px) {
  .login-card { padding: 1.1rem; border-radius: 16px; }
  .stat-card .value { font-size: 1.45rem; }
  .channel-card-actions { flex-wrap: wrap; }
  .toast { left: 1rem; right: 1rem; }
}
